{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_maxResults,
    listFlows_nextToken,

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

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

import Amazonka.AppFlow.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | Specifies the maximum number of items that should be returned in the
    -- result set.
    ListFlows -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token for next page of data.
    ListFlows -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListFlows -> ListFlows -> Bool
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]
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
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. 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:
--
-- 'maxResults', 'listFlows_maxResults' - Specifies the maximum number of items that should be returned in the
-- result set.
--
-- 'nextToken', 'listFlows_nextToken' - The pagination token for next page of data.
newListFlows ::
  ListFlows
newListFlows :: ListFlows
newListFlows =
  ListFlows'
    { $sel:maxResults:ListFlows' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListFlows' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' ListFlows (Maybe Natural)
listFlows_maxResults = 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)

-- | The pagination token for next page of data.
listFlows_nextToken :: Lens.Lens' ListFlows (Prelude.Maybe Prelude.Text)
listFlows_nextToken :: Lens' ListFlows (Maybe Text)
listFlows_nextToken = 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)

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

instance Prelude.Hashable ListFlows where
  hashWithSalt :: Int -> ListFlows -> Int
hashWithSalt Int
_salt ListFlows' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListFlows' :: ListFlows -> Maybe Text
$sel:maxResults:ListFlows' :: ListFlows -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListFlows where
  rnf :: ListFlows -> ()
rnf ListFlows' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListFlows' :: ListFlows -> Maybe Text
$sel:maxResults:ListFlows' :: ListFlows -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListFlows where
  toHeaders :: ListFlows -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Data.ToPath ListFlows where
  toPath :: ListFlows -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/list-flows"

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

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

-- | The list of flows associated with your account.
listFlowsResponse_flows :: Lens.Lens' ListFlowsResponse (Prelude.Maybe [FlowDefinition])
listFlowsResponse_flows :: Lens' ListFlowsResponse (Maybe [FlowDefinition])
listFlowsResponse_flows = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The pagination token for next page of data.
listFlowsResponse_nextToken :: Lens.Lens' ListFlowsResponse (Prelude.Maybe Prelude.Text)
listFlowsResponse_nextToken :: Lens' ListFlowsResponse (Maybe Text)
listFlowsResponse_nextToken = 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 response's http status code.
listFlowsResponse_httpStatus :: Lens.Lens' ListFlowsResponse Prelude.Int
listFlowsResponse_httpStatus :: Lens' ListFlowsResponse Int
listFlowsResponse_httpStatus = 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 where
  rnf :: ListFlowsResponse -> ()
rnf ListFlowsResponse' {Int
Maybe [FlowDefinition]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
flows :: Maybe [FlowDefinition]
$sel:httpStatus:ListFlowsResponse' :: ListFlowsResponse -> Int
$sel:nextToken:ListFlowsResponse' :: ListFlowsResponse -> Maybe Text
$sel:flows:ListFlowsResponse' :: ListFlowsResponse -> Maybe [FlowDefinition]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FlowDefinition]
flows
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus