{-# 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.AppFlow.ListFlows
-- 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 the flows associated with your account.
module Amazonka.AppFlow.ListFlows
  ( -- * Creating a Request
    ListFlows (..),
    newListFlows,

    -- * Request Lenses
    listFlows_nextToken,
    listFlows_maxResults,

    -- * Destructuring the Response
    ListFlowsResponse (..),
    newListFlowsResponse,

    -- * Response Lenses
    listFlowsResponse_nextToken,
    listFlowsResponse_flows,
    listFlowsResponse_httpStatus,
  )
where

import Amazonka.AppFlow.Types
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

-- | /See:/ 'newListFlows' smart constructor.
data ListFlows = ListFlows'
  { -- | The pagination token for next page of data.
    ListFlows -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specifies the maximum number of items that should be returned in the
    -- result set.
    ListFlows -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListFlows -> ListFlows -> Bool
(ListFlows -> ListFlows -> Bool)
-> (ListFlows -> ListFlows -> Bool) -> Eq ListFlows
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFlows -> ListFlows -> Bool
$c/= :: ListFlows -> ListFlows -> Bool
== :: ListFlows -> ListFlows -> Bool
$c== :: ListFlows -> ListFlows -> Bool
Prelude.Eq, ReadPrec [ListFlows]
ReadPrec ListFlows
Int -> ReadS ListFlows
ReadS [ListFlows]
(Int -> ReadS ListFlows)
-> ReadS [ListFlows]
-> ReadPrec ListFlows
-> ReadPrec [ListFlows]
-> Read ListFlows
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFlows]
$creadListPrec :: ReadPrec [ListFlows]
readPrec :: ReadPrec ListFlows
$creadPrec :: ReadPrec ListFlows
readList :: ReadS [ListFlows]
$creadList :: ReadS [ListFlows]
readsPrec :: Int -> ReadS ListFlows
$creadsPrec :: Int -> ReadS ListFlows
Prelude.Read, Int -> ListFlows -> ShowS
[ListFlows] -> ShowS
ListFlows -> String
(Int -> ListFlows -> ShowS)
-> (ListFlows -> String)
-> ([ListFlows] -> ShowS)
-> Show ListFlows
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFlows] -> ShowS
$cshowList :: [ListFlows] -> ShowS
show :: ListFlows -> String
$cshow :: ListFlows -> String
showsPrec :: Int -> ListFlows -> ShowS
$cshowsPrec :: Int -> ListFlows -> ShowS
Prelude.Show, (forall x. ListFlows -> Rep ListFlows x)
-> (forall x. Rep ListFlows x -> ListFlows) -> Generic ListFlows
forall x. Rep ListFlows x -> ListFlows
forall x. ListFlows -> Rep ListFlows x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFlows x -> ListFlows
$cfrom :: forall x. ListFlows -> Rep ListFlows x
Prelude.Generic)

-- |
-- Create a value of 'ListFlows' 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', 'listFlows_nextToken' - The pagination token for next page of data.
--
-- 'maxResults', 'listFlows_maxResults' - Specifies the maximum number of items that should be returned in the
-- result set.
newListFlows ::
  ListFlows
newListFlows :: ListFlows
newListFlows =
  ListFlows' :: Maybe Text -> Maybe Natural -> ListFlows
ListFlows'
    { $sel:nextToken:ListFlows' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListFlows' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The pagination token for next page of data.
listFlows_nextToken :: Lens.Lens' ListFlows (Prelude.Maybe Prelude.Text)
listFlows_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListFlows -> f ListFlows
listFlows_nextToken = (ListFlows -> Maybe Text)
-> (ListFlows -> Maybe Text -> ListFlows)
-> Lens ListFlows ListFlows (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFlows' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFlows' :: ListFlows -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFlows
s@ListFlows' {} Maybe Text
a -> ListFlows
s {$sel:nextToken:ListFlows' :: Maybe Text
nextToken = Maybe Text
a} :: ListFlows)

-- | Specifies the maximum number of items that should be returned in the
-- result set.
listFlows_maxResults :: Lens.Lens' ListFlows (Prelude.Maybe Prelude.Natural)
listFlows_maxResults :: (Maybe Natural -> f (Maybe Natural)) -> ListFlows -> f ListFlows
listFlows_maxResults = (ListFlows -> Maybe Natural)
-> (ListFlows -> Maybe Natural -> ListFlows)
-> Lens ListFlows ListFlows (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFlows' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListFlows' :: ListFlows -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListFlows
s@ListFlows' {} Maybe Natural
a -> ListFlows
s {$sel:maxResults:ListFlows' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListFlows)

instance Core.AWSRequest ListFlows where
  type AWSResponse ListFlows = ListFlowsResponse
  request :: ListFlows -> Request ListFlows
request = Service -> ListFlows -> Request ListFlows
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListFlows
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListFlows)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListFlows))
-> Logger
-> Service
-> Proxy ListFlows
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListFlows)))
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 -> Maybe [FlowDefinition] -> Int -> ListFlowsResponse
ListFlowsResponse'
            (Maybe Text -> Maybe [FlowDefinition] -> Int -> ListFlowsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [FlowDefinition] -> Int -> ListFlowsResponse)
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 (Maybe [FlowDefinition] -> Int -> ListFlowsResponse)
-> Either String (Maybe [FlowDefinition])
-> Either String (Int -> ListFlowsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [FlowDefinition]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"flows" Either String (Maybe (Maybe [FlowDefinition]))
-> Maybe [FlowDefinition] -> Either String (Maybe [FlowDefinition])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [FlowDefinition]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListFlowsResponse)
-> Either String Int -> Either String ListFlowsResponse
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))
      )

instance Prelude.Hashable ListFlows

instance Prelude.NFData ListFlows

instance Core.ToHeaders ListFlows where
  toHeaders :: ListFlows -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListFlows -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 ListFlows where
  toJSON :: ListFlows -> Value
toJSON ListFlows' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListFlows' :: ListFlows -> Maybe Natural
$sel:nextToken:ListFlows' :: ListFlows -> 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 ListFlows where
  toPath :: ListFlows -> ByteString
toPath = ByteString -> ListFlows -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/list-flows"

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

-- | /See:/ 'newListFlowsResponse' smart constructor.
data ListFlowsResponse = ListFlowsResponse'
  { -- | The pagination token for next page of data.
    ListFlowsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The list of flows associated with your account.
    ListFlowsResponse -> Maybe [FlowDefinition]
flows :: Prelude.Maybe [FlowDefinition],
    -- | The response's http status code.
    ListFlowsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListFlowsResponse -> ListFlowsResponse -> Bool
(ListFlowsResponse -> ListFlowsResponse -> Bool)
-> (ListFlowsResponse -> ListFlowsResponse -> Bool)
-> Eq ListFlowsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFlowsResponse -> ListFlowsResponse -> Bool
$c/= :: ListFlowsResponse -> ListFlowsResponse -> Bool
== :: ListFlowsResponse -> ListFlowsResponse -> Bool
$c== :: ListFlowsResponse -> ListFlowsResponse -> Bool
Prelude.Eq, ReadPrec [ListFlowsResponse]
ReadPrec ListFlowsResponse
Int -> ReadS ListFlowsResponse
ReadS [ListFlowsResponse]
(Int -> ReadS ListFlowsResponse)
-> ReadS [ListFlowsResponse]
-> ReadPrec ListFlowsResponse
-> ReadPrec [ListFlowsResponse]
-> Read ListFlowsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFlowsResponse]
$creadListPrec :: ReadPrec [ListFlowsResponse]
readPrec :: ReadPrec ListFlowsResponse
$creadPrec :: ReadPrec ListFlowsResponse
readList :: ReadS [ListFlowsResponse]
$creadList :: ReadS [ListFlowsResponse]
readsPrec :: Int -> ReadS ListFlowsResponse
$creadsPrec :: Int -> ReadS ListFlowsResponse
Prelude.Read, Int -> ListFlowsResponse -> ShowS
[ListFlowsResponse] -> ShowS
ListFlowsResponse -> String
(Int -> ListFlowsResponse -> ShowS)
-> (ListFlowsResponse -> String)
-> ([ListFlowsResponse] -> ShowS)
-> Show ListFlowsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFlowsResponse] -> ShowS
$cshowList :: [ListFlowsResponse] -> ShowS
show :: ListFlowsResponse -> String
$cshow :: ListFlowsResponse -> String
showsPrec :: Int -> ListFlowsResponse -> ShowS
$cshowsPrec :: Int -> ListFlowsResponse -> ShowS
Prelude.Show, (forall x. ListFlowsResponse -> Rep ListFlowsResponse x)
-> (forall x. Rep ListFlowsResponse x -> ListFlowsResponse)
-> Generic ListFlowsResponse
forall x. Rep ListFlowsResponse x -> ListFlowsResponse
forall x. ListFlowsResponse -> Rep ListFlowsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFlowsResponse x -> ListFlowsResponse
$cfrom :: forall x. ListFlowsResponse -> Rep ListFlowsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListFlowsResponse' 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', 'listFlowsResponse_nextToken' - The pagination token for next page of data.
--
-- 'flows', 'listFlowsResponse_flows' - The list of flows associated with your account.
--
-- 'httpStatus', 'listFlowsResponse_httpStatus' - The response's http status code.
newListFlowsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListFlowsResponse
newListFlowsResponse :: Int -> ListFlowsResponse
newListFlowsResponse Int
pHttpStatus_ =
  ListFlowsResponse' :: Maybe Text -> Maybe [FlowDefinition] -> Int -> ListFlowsResponse
ListFlowsResponse'
    { $sel:nextToken:ListFlowsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:flows:ListFlowsResponse' :: Maybe [FlowDefinition]
flows = Maybe [FlowDefinition]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListFlowsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The pagination token for next page of data.
listFlowsResponse_nextToken :: Lens.Lens' ListFlowsResponse (Prelude.Maybe Prelude.Text)
listFlowsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListFlowsResponse -> f ListFlowsResponse
listFlowsResponse_nextToken = (ListFlowsResponse -> Maybe Text)
-> (ListFlowsResponse -> Maybe Text -> ListFlowsResponse)
-> Lens
     ListFlowsResponse ListFlowsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFlowsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFlowsResponse' :: ListFlowsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFlowsResponse
s@ListFlowsResponse' {} Maybe Text
a -> ListFlowsResponse
s {$sel:nextToken:ListFlowsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListFlowsResponse)

-- | The list of flows associated with your account.
listFlowsResponse_flows :: Lens.Lens' ListFlowsResponse (Prelude.Maybe [FlowDefinition])
listFlowsResponse_flows :: (Maybe [FlowDefinition] -> f (Maybe [FlowDefinition]))
-> ListFlowsResponse -> f ListFlowsResponse
listFlowsResponse_flows = (ListFlowsResponse -> Maybe [FlowDefinition])
-> (ListFlowsResponse
    -> Maybe [FlowDefinition] -> ListFlowsResponse)
-> Lens
     ListFlowsResponse
     ListFlowsResponse
     (Maybe [FlowDefinition])
     (Maybe [FlowDefinition])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFlowsResponse' {Maybe [FlowDefinition]
flows :: Maybe [FlowDefinition]
$sel:flows:ListFlowsResponse' :: ListFlowsResponse -> Maybe [FlowDefinition]
flows} -> Maybe [FlowDefinition]
flows) (\s :: ListFlowsResponse
s@ListFlowsResponse' {} Maybe [FlowDefinition]
a -> ListFlowsResponse
s {$sel:flows:ListFlowsResponse' :: Maybe [FlowDefinition]
flows = Maybe [FlowDefinition]
a} :: ListFlowsResponse) ((Maybe [FlowDefinition] -> f (Maybe [FlowDefinition]))
 -> ListFlowsResponse -> f ListFlowsResponse)
-> ((Maybe [FlowDefinition] -> f (Maybe [FlowDefinition]))
    -> Maybe [FlowDefinition] -> f (Maybe [FlowDefinition]))
-> (Maybe [FlowDefinition] -> f (Maybe [FlowDefinition]))
-> ListFlowsResponse
-> f ListFlowsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [FlowDefinition] [FlowDefinition] [FlowDefinition] [FlowDefinition]
-> Iso
     (Maybe [FlowDefinition])
     (Maybe [FlowDefinition])
     (Maybe [FlowDefinition])
     (Maybe [FlowDefinition])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [FlowDefinition] [FlowDefinition] [FlowDefinition] [FlowDefinition]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListFlowsResponse