{-# 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.MediaConnect.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)
--
-- Displays a list of flows that are associated with this account. This
-- request returns a paginated result.
--
-- This operation returns paginated results.
module Amazonka.MediaConnect.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 qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaConnect.Types
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 maximum number of results to return per API request. For example,
    -- you submit a ListFlows request with MaxResults set at 5. Although 20
    -- items match your request, the service returns no more than the first 5
    -- items. (The service also returns a NextToken value that you can use to
    -- fetch the next batch of results.) The service might return fewer results
    -- than the MaxResults value. If MaxResults is not included in the request,
    -- the service defaults to pagination with a maximum of 10 results per
    -- page.
    ListFlows -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token that identifies which batch of results that you want to see.
    -- For example, you submit a ListFlows request with MaxResults set at 5.
    -- The service returns the first batch of results (up to 5) and a NextToken
    -- value. To see the next batch of results, you can submit the ListFlows
    -- request a second time and specify the NextToken value.
    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' - The maximum number of results to return per API request. For example,
-- you submit a ListFlows request with MaxResults set at 5. Although 20
-- items match your request, the service returns no more than the first 5
-- items. (The service also returns a NextToken value that you can use to
-- fetch the next batch of results.) The service might return fewer results
-- than the MaxResults value. If MaxResults is not included in the request,
-- the service defaults to pagination with a maximum of 10 results per
-- page.
--
-- 'nextToken', 'listFlows_nextToken' - The token that identifies which batch of results that you want to see.
-- For example, you submit a ListFlows request with MaxResults set at 5.
-- The service returns the first batch of results (up to 5) and a NextToken
-- value. To see the next batch of results, you can submit the ListFlows
-- request a second time and specify the NextToken value.
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
    }

-- | The maximum number of results to return per API request. For example,
-- you submit a ListFlows request with MaxResults set at 5. Although 20
-- items match your request, the service returns no more than the first 5
-- items. (The service also returns a NextToken value that you can use to
-- fetch the next batch of results.) The service might return fewer results
-- than the MaxResults value. If MaxResults is not included in the request,
-- the service defaults to pagination with a maximum of 10 results per
-- page.
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 token that identifies which batch of results that you want to see.
-- For example, you submit a ListFlows request with MaxResults set at 5.
-- The service returns the first batch of results (up to 5) and a NextToken
-- value. To see the next batch of results, you can submit the ListFlows
-- request a second time and specify the NextToken value.
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.AWSPager ListFlows where
  page :: ListFlows -> AWSResponse ListFlows -> Maybe ListFlows
page ListFlows
rq AWSResponse ListFlows
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListFlows
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListFlowsResponse (Maybe Text)
listFlowsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListFlows
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListFlowsResponse (Maybe [ListedFlow])
listFlowsResponse_flows
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListFlows
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListFlows (Maybe Text)
listFlows_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListFlows
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListFlowsResponse (Maybe Text)
listFlowsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListFlows where
  type AWSResponse ListFlows = ListFlowsResponse
  request :: (Service -> Service) -> ListFlows -> Request ListFlows
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (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 [ListedFlow] -> 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.ToPath ListFlows where
  toPath :: ListFlows -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v1/flows"

instance Data.ToQuery ListFlows where
  toQuery :: ListFlows -> QueryString
toQuery 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. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListFlowsResponse' smart constructor.
data ListFlowsResponse = ListFlowsResponse'
  { -- | A list of flow summaries.
    ListFlowsResponse -> Maybe [ListedFlow]
flows :: Prelude.Maybe [ListedFlow],
    -- | The token that identifies which batch of results that you want to see.
    -- For example, you submit a ListFlows request with MaxResults set at 5.
    -- The service returns the first batch of results (up to 5) and a NextToken
    -- value. To see the next batch of results, you can submit the ListFlows
    -- request a second time and specify the NextToken value.
    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' - A list of flow summaries.
--
-- 'nextToken', 'listFlowsResponse_nextToken' - The token that identifies which batch of results that you want to see.
-- For example, you submit a ListFlows request with MaxResults set at 5.
-- The service returns the first batch of results (up to 5) and a NextToken
-- value. To see the next batch of results, you can submit the ListFlows
-- request a second time and specify the NextToken value.
--
-- '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 [ListedFlow]
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_
    }

-- | A list of flow summaries.
listFlowsResponse_flows :: Lens.Lens' ListFlowsResponse (Prelude.Maybe [ListedFlow])
listFlowsResponse_flows :: Lens' ListFlowsResponse (Maybe [ListedFlow])
listFlowsResponse_flows = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFlowsResponse' {Maybe [ListedFlow]
flows :: Maybe [ListedFlow]
$sel:flows:ListFlowsResponse' :: ListFlowsResponse -> Maybe [ListedFlow]
flows} -> Maybe [ListedFlow]
flows) (\s :: ListFlowsResponse
s@ListFlowsResponse' {} Maybe [ListedFlow]
a -> ListFlowsResponse
s {$sel:flows:ListFlowsResponse' :: Maybe [ListedFlow]
flows = Maybe [ListedFlow]
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 token that identifies which batch of results that you want to see.
-- For example, you submit a ListFlows request with MaxResults set at 5.
-- The service returns the first batch of results (up to 5) and a NextToken
-- value. To see the next batch of results, you can submit the ListFlows
-- request a second time and specify the NextToken value.
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 [ListedFlow]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
flows :: Maybe [ListedFlow]
$sel:httpStatus:ListFlowsResponse' :: ListFlowsResponse -> Int
$sel:nextToken:ListFlowsResponse' :: ListFlowsResponse -> Maybe Text
$sel:flows:ListFlowsResponse' :: ListFlowsResponse -> Maybe [ListedFlow]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ListedFlow]
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