{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Transfer.ListWorkflows
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists all of your workflows.
module Amazonka.Transfer.ListWorkflows
  ( -- * Creating a Request
    ListWorkflows (..),
    newListWorkflows,

    -- * Request Lenses
    listWorkflows_nextToken,
    listWorkflows_maxResults,

    -- * Destructuring the Response
    ListWorkflowsResponse (..),
    newListWorkflowsResponse,

    -- * Response Lenses
    listWorkflowsResponse_nextToken,
    listWorkflowsResponse_httpStatus,
    listWorkflowsResponse_workflows,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Transfer.Types

-- | /See:/ 'newListWorkflows' smart constructor.
data ListWorkflows = ListWorkflows'
  { -- | @ListWorkflows@ returns the @NextToken@ parameter in the output. You can
    -- then pass the @NextToken@ parameter in a subsequent command to continue
    -- listing additional workflows.
    ListWorkflows -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specifies the maximum number of workflows to return.
    ListWorkflows -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListWorkflows -> ListWorkflows -> Bool
(ListWorkflows -> ListWorkflows -> Bool)
-> (ListWorkflows -> ListWorkflows -> Bool) -> Eq ListWorkflows
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListWorkflows -> ListWorkflows -> Bool
$c/= :: ListWorkflows -> ListWorkflows -> Bool
== :: ListWorkflows -> ListWorkflows -> Bool
$c== :: ListWorkflows -> ListWorkflows -> Bool
Prelude.Eq, ReadPrec [ListWorkflows]
ReadPrec ListWorkflows
Int -> ReadS ListWorkflows
ReadS [ListWorkflows]
(Int -> ReadS ListWorkflows)
-> ReadS [ListWorkflows]
-> ReadPrec ListWorkflows
-> ReadPrec [ListWorkflows]
-> Read ListWorkflows
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListWorkflows]
$creadListPrec :: ReadPrec [ListWorkflows]
readPrec :: ReadPrec ListWorkflows
$creadPrec :: ReadPrec ListWorkflows
readList :: ReadS [ListWorkflows]
$creadList :: ReadS [ListWorkflows]
readsPrec :: Int -> ReadS ListWorkflows
$creadsPrec :: Int -> ReadS ListWorkflows
Prelude.Read, Int -> ListWorkflows -> ShowS
[ListWorkflows] -> ShowS
ListWorkflows -> String
(Int -> ListWorkflows -> ShowS)
-> (ListWorkflows -> String)
-> ([ListWorkflows] -> ShowS)
-> Show ListWorkflows
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListWorkflows] -> ShowS
$cshowList :: [ListWorkflows] -> ShowS
show :: ListWorkflows -> String
$cshow :: ListWorkflows -> String
showsPrec :: Int -> ListWorkflows -> ShowS
$cshowsPrec :: Int -> ListWorkflows -> ShowS
Prelude.Show, (forall x. ListWorkflows -> Rep ListWorkflows x)
-> (forall x. Rep ListWorkflows x -> ListWorkflows)
-> Generic ListWorkflows
forall x. Rep ListWorkflows x -> ListWorkflows
forall x. ListWorkflows -> Rep ListWorkflows x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListWorkflows x -> ListWorkflows
$cfrom :: forall x. ListWorkflows -> Rep ListWorkflows x
Prelude.Generic)

-- |
-- Create a value of 'ListWorkflows' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'listWorkflows_nextToken' - @ListWorkflows@ returns the @NextToken@ parameter in the output. You can
-- then pass the @NextToken@ parameter in a subsequent command to continue
-- listing additional workflows.
--
-- 'maxResults', 'listWorkflows_maxResults' - Specifies the maximum number of workflows to return.
newListWorkflows ::
  ListWorkflows
newListWorkflows :: ListWorkflows
newListWorkflows =
  ListWorkflows' :: Maybe Text -> Maybe Natural -> ListWorkflows
ListWorkflows'
    { $sel:nextToken:ListWorkflows' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListWorkflows' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | @ListWorkflows@ returns the @NextToken@ parameter in the output. You can
-- then pass the @NextToken@ parameter in a subsequent command to continue
-- listing additional workflows.
listWorkflows_nextToken :: Lens.Lens' ListWorkflows (Prelude.Maybe Prelude.Text)
listWorkflows_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListWorkflows -> f ListWorkflows
listWorkflows_nextToken = (ListWorkflows -> Maybe Text)
-> (ListWorkflows -> Maybe Text -> ListWorkflows)
-> Lens ListWorkflows ListWorkflows (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkflows' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListWorkflows' :: ListWorkflows -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListWorkflows
s@ListWorkflows' {} Maybe Text
a -> ListWorkflows
s {$sel:nextToken:ListWorkflows' :: Maybe Text
nextToken = Maybe Text
a} :: ListWorkflows)

-- | Specifies the maximum number of workflows to return.
listWorkflows_maxResults :: Lens.Lens' ListWorkflows (Prelude.Maybe Prelude.Natural)
listWorkflows_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListWorkflows -> f ListWorkflows
listWorkflows_maxResults = (ListWorkflows -> Maybe Natural)
-> (ListWorkflows -> Maybe Natural -> ListWorkflows)
-> Lens ListWorkflows ListWorkflows (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkflows' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListWorkflows' :: ListWorkflows -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListWorkflows
s@ListWorkflows' {} Maybe Natural
a -> ListWorkflows
s {$sel:maxResults:ListWorkflows' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListWorkflows)

instance Core.AWSRequest ListWorkflows where
  type
    AWSResponse ListWorkflows =
      ListWorkflowsResponse
  request :: ListWorkflows -> Request ListWorkflows
request = Service -> ListWorkflows -> Request ListWorkflows
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListWorkflows
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListWorkflows)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListWorkflows))
-> Logger
-> Service
-> Proxy ListWorkflows
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListWorkflows)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> [ListedWorkflow] -> ListWorkflowsResponse
ListWorkflowsResponse'
            (Maybe Text -> Int -> [ListedWorkflow] -> ListWorkflowsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> [ListedWorkflow] -> ListWorkflowsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> [ListedWorkflow] -> ListWorkflowsResponse)
-> Either String Int
-> Either String ([ListedWorkflow] -> ListWorkflowsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String ([ListedWorkflow] -> ListWorkflowsResponse)
-> Either String [ListedWorkflow]
-> Either String ListWorkflowsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [ListedWorkflow])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Workflows" Either String (Maybe [ListedWorkflow])
-> [ListedWorkflow] -> Either String [ListedWorkflow]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [ListedWorkflow]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListWorkflows

instance Prelude.NFData ListWorkflows

instance Core.ToHeaders ListWorkflows where
  toHeaders :: ListWorkflows -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListWorkflows -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"TransferService.ListWorkflows" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListWorkflows where
  toJSON :: ListWorkflows -> Value
toJSON ListWorkflows' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListWorkflows' :: ListWorkflows -> Maybe Natural
$sel:nextToken:ListWorkflows' :: ListWorkflows -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )

instance Core.ToPath ListWorkflows where
  toPath :: ListWorkflows -> ByteString
toPath = ByteString -> ListWorkflows -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ListWorkflows where
  toQuery :: ListWorkflows -> QueryString
toQuery = QueryString -> ListWorkflows -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListWorkflowsResponse' smart constructor.
data ListWorkflowsResponse = ListWorkflowsResponse'
  { -- | @ListWorkflows@ returns the @NextToken@ parameter in the output. You can
    -- then pass the @NextToken@ parameter in a subsequent command to continue
    -- listing additional workflows.
    ListWorkflowsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListWorkflowsResponse -> Int
httpStatus :: Prelude.Int,
    -- | Returns the @Arn@, @WorkflowId@, and @Description@ for each workflow.
    ListWorkflowsResponse -> [ListedWorkflow]
workflows :: [ListedWorkflow]
  }
  deriving (ListWorkflowsResponse -> ListWorkflowsResponse -> Bool
(ListWorkflowsResponse -> ListWorkflowsResponse -> Bool)
-> (ListWorkflowsResponse -> ListWorkflowsResponse -> Bool)
-> Eq ListWorkflowsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListWorkflowsResponse -> ListWorkflowsResponse -> Bool
$c/= :: ListWorkflowsResponse -> ListWorkflowsResponse -> Bool
== :: ListWorkflowsResponse -> ListWorkflowsResponse -> Bool
$c== :: ListWorkflowsResponse -> ListWorkflowsResponse -> Bool
Prelude.Eq, ReadPrec [ListWorkflowsResponse]
ReadPrec ListWorkflowsResponse
Int -> ReadS ListWorkflowsResponse
ReadS [ListWorkflowsResponse]
(Int -> ReadS ListWorkflowsResponse)
-> ReadS [ListWorkflowsResponse]
-> ReadPrec ListWorkflowsResponse
-> ReadPrec [ListWorkflowsResponse]
-> Read ListWorkflowsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListWorkflowsResponse]
$creadListPrec :: ReadPrec [ListWorkflowsResponse]
readPrec :: ReadPrec ListWorkflowsResponse
$creadPrec :: ReadPrec ListWorkflowsResponse
readList :: ReadS [ListWorkflowsResponse]
$creadList :: ReadS [ListWorkflowsResponse]
readsPrec :: Int -> ReadS ListWorkflowsResponse
$creadsPrec :: Int -> ReadS ListWorkflowsResponse
Prelude.Read, Int -> ListWorkflowsResponse -> ShowS
[ListWorkflowsResponse] -> ShowS
ListWorkflowsResponse -> String
(Int -> ListWorkflowsResponse -> ShowS)
-> (ListWorkflowsResponse -> String)
-> ([ListWorkflowsResponse] -> ShowS)
-> Show ListWorkflowsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListWorkflowsResponse] -> ShowS
$cshowList :: [ListWorkflowsResponse] -> ShowS
show :: ListWorkflowsResponse -> String
$cshow :: ListWorkflowsResponse -> String
showsPrec :: Int -> ListWorkflowsResponse -> ShowS
$cshowsPrec :: Int -> ListWorkflowsResponse -> ShowS
Prelude.Show, (forall x. ListWorkflowsResponse -> Rep ListWorkflowsResponse x)
-> (forall x. Rep ListWorkflowsResponse x -> ListWorkflowsResponse)
-> Generic ListWorkflowsResponse
forall x. Rep ListWorkflowsResponse x -> ListWorkflowsResponse
forall x. ListWorkflowsResponse -> Rep ListWorkflowsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListWorkflowsResponse x -> ListWorkflowsResponse
$cfrom :: forall x. ListWorkflowsResponse -> Rep ListWorkflowsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListWorkflowsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'listWorkflowsResponse_nextToken' - @ListWorkflows@ returns the @NextToken@ parameter in the output. You can
-- then pass the @NextToken@ parameter in a subsequent command to continue
-- listing additional workflows.
--
-- 'httpStatus', 'listWorkflowsResponse_httpStatus' - The response's http status code.
--
-- 'workflows', 'listWorkflowsResponse_workflows' - Returns the @Arn@, @WorkflowId@, and @Description@ for each workflow.
newListWorkflowsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListWorkflowsResponse
newListWorkflowsResponse :: Int -> ListWorkflowsResponse
newListWorkflowsResponse Int
pHttpStatus_ =
  ListWorkflowsResponse' :: Maybe Text -> Int -> [ListedWorkflow] -> ListWorkflowsResponse
ListWorkflowsResponse'
    { $sel:nextToken:ListWorkflowsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListWorkflowsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:workflows:ListWorkflowsResponse' :: [ListedWorkflow]
workflows = [ListedWorkflow]
forall a. Monoid a => a
Prelude.mempty
    }

-- | @ListWorkflows@ returns the @NextToken@ parameter in the output. You can
-- then pass the @NextToken@ parameter in a subsequent command to continue
-- listing additional workflows.
listWorkflowsResponse_nextToken :: Lens.Lens' ListWorkflowsResponse (Prelude.Maybe Prelude.Text)
listWorkflowsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListWorkflowsResponse -> f ListWorkflowsResponse
listWorkflowsResponse_nextToken = (ListWorkflowsResponse -> Maybe Text)
-> (ListWorkflowsResponse -> Maybe Text -> ListWorkflowsResponse)
-> Lens
     ListWorkflowsResponse
     ListWorkflowsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkflowsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListWorkflowsResponse' :: ListWorkflowsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListWorkflowsResponse
s@ListWorkflowsResponse' {} Maybe Text
a -> ListWorkflowsResponse
s {$sel:nextToken:ListWorkflowsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListWorkflowsResponse)

-- | The response's http status code.
listWorkflowsResponse_httpStatus :: Lens.Lens' ListWorkflowsResponse Prelude.Int
listWorkflowsResponse_httpStatus :: (Int -> f Int) -> ListWorkflowsResponse -> f ListWorkflowsResponse
listWorkflowsResponse_httpStatus = (ListWorkflowsResponse -> Int)
-> (ListWorkflowsResponse -> Int -> ListWorkflowsResponse)
-> Lens ListWorkflowsResponse ListWorkflowsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkflowsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListWorkflowsResponse' :: ListWorkflowsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListWorkflowsResponse
s@ListWorkflowsResponse' {} Int
a -> ListWorkflowsResponse
s {$sel:httpStatus:ListWorkflowsResponse' :: Int
httpStatus = Int
a} :: ListWorkflowsResponse)

-- | Returns the @Arn@, @WorkflowId@, and @Description@ for each workflow.
listWorkflowsResponse_workflows :: Lens.Lens' ListWorkflowsResponse [ListedWorkflow]
listWorkflowsResponse_workflows :: ([ListedWorkflow] -> f [ListedWorkflow])
-> ListWorkflowsResponse -> f ListWorkflowsResponse
listWorkflowsResponse_workflows = (ListWorkflowsResponse -> [ListedWorkflow])
-> (ListWorkflowsResponse
    -> [ListedWorkflow] -> ListWorkflowsResponse)
-> Lens
     ListWorkflowsResponse
     ListWorkflowsResponse
     [ListedWorkflow]
     [ListedWorkflow]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkflowsResponse' {[ListedWorkflow]
workflows :: [ListedWorkflow]
$sel:workflows:ListWorkflowsResponse' :: ListWorkflowsResponse -> [ListedWorkflow]
workflows} -> [ListedWorkflow]
workflows) (\s :: ListWorkflowsResponse
s@ListWorkflowsResponse' {} [ListedWorkflow]
a -> ListWorkflowsResponse
s {$sel:workflows:ListWorkflowsResponse' :: [ListedWorkflow]
workflows = [ListedWorkflow]
a} :: ListWorkflowsResponse) (([ListedWorkflow] -> f [ListedWorkflow])
 -> ListWorkflowsResponse -> f ListWorkflowsResponse)
-> (([ListedWorkflow] -> f [ListedWorkflow])
    -> [ListedWorkflow] -> f [ListedWorkflow])
-> ([ListedWorkflow] -> f [ListedWorkflow])
-> ListWorkflowsResponse
-> f ListWorkflowsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ListedWorkflow] -> f [ListedWorkflow])
-> [ListedWorkflow] -> f [ListedWorkflow]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListWorkflowsResponse