{-# 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.Kinesis.ListStreamConsumers
-- 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 the consumers registered to receive data from a stream using
-- enhanced fan-out, and provides information about each consumer.
--
-- This operation has a limit of 5 transactions per second per stream.
--
-- This operation returns paginated results.
module Amazonka.Kinesis.ListStreamConsumers
  ( -- * Creating a Request
    ListStreamConsumers (..),
    newListStreamConsumers,

    -- * Request Lenses
    listStreamConsumers_nextToken,
    listStreamConsumers_streamCreationTimestamp,
    listStreamConsumers_maxResults,
    listStreamConsumers_streamARN,

    -- * Destructuring the Response
    ListStreamConsumersResponse (..),
    newListStreamConsumersResponse,

    -- * Response Lenses
    listStreamConsumersResponse_nextToken,
    listStreamConsumersResponse_consumers,
    listStreamConsumersResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Kinesis.Types
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:/ 'newListStreamConsumers' smart constructor.
data ListStreamConsumers = ListStreamConsumers'
  { -- | When the number of consumers that are registered with the data stream is
    -- greater than the default value for the @MaxResults@ parameter, or if you
    -- explicitly specify a value for @MaxResults@ that is less than the number
    -- of consumers that are registered with the data stream, the response
    -- includes a pagination token named @NextToken@. You can specify this
    -- @NextToken@ value in a subsequent call to @ListStreamConsumers@ to list
    -- the next set of registered consumers.
    --
    -- Don\'t specify @StreamName@ or @StreamCreationTimestamp@ if you specify
    -- @NextToken@ because the latter unambiguously identifies the stream.
    --
    -- You can optionally specify a value for the @MaxResults@ parameter when
    -- you specify @NextToken@. If you specify a @MaxResults@ value that is
    -- less than the number of consumers that the operation returns if you
    -- don\'t specify @MaxResults@, the response will contain a new @NextToken@
    -- value. You can use the new @NextToken@ value in a subsequent call to the
    -- @ListStreamConsumers@ operation to list the next set of consumers.
    --
    -- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
    -- in the response to a call to @ListStreamConsumers@, you have 300 seconds
    -- to use that value. If you specify an expired token in a call to
    -- @ListStreamConsumers@, you get @ExpiredNextTokenException@.
    ListStreamConsumers -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specify this input parameter to distinguish data streams that have the
    -- same name. For example, if you create a data stream and then delete it,
    -- and you later create another data stream with the same name, you can use
    -- this input parameter to specify which of the two streams you want to
    -- list the consumers for.
    --
    -- You can\'t specify this parameter if you specify the NextToken
    -- parameter.
    ListStreamConsumers -> Maybe POSIX
streamCreationTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The maximum number of consumers that you want a single call of
    -- @ListStreamConsumers@ to return.
    ListStreamConsumers -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ARN of the Kinesis data stream for which you want to list the
    -- registered consumers. For more information, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-kinesis-streams Amazon Resource Names (ARNs) and AWS Service Namespaces>.
    ListStreamConsumers -> Text
streamARN :: Prelude.Text
  }
  deriving (ListStreamConsumers -> ListStreamConsumers -> Bool
(ListStreamConsumers -> ListStreamConsumers -> Bool)
-> (ListStreamConsumers -> ListStreamConsumers -> Bool)
-> Eq ListStreamConsumers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStreamConsumers -> ListStreamConsumers -> Bool
$c/= :: ListStreamConsumers -> ListStreamConsumers -> Bool
== :: ListStreamConsumers -> ListStreamConsumers -> Bool
$c== :: ListStreamConsumers -> ListStreamConsumers -> Bool
Prelude.Eq, ReadPrec [ListStreamConsumers]
ReadPrec ListStreamConsumers
Int -> ReadS ListStreamConsumers
ReadS [ListStreamConsumers]
(Int -> ReadS ListStreamConsumers)
-> ReadS [ListStreamConsumers]
-> ReadPrec ListStreamConsumers
-> ReadPrec [ListStreamConsumers]
-> Read ListStreamConsumers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStreamConsumers]
$creadListPrec :: ReadPrec [ListStreamConsumers]
readPrec :: ReadPrec ListStreamConsumers
$creadPrec :: ReadPrec ListStreamConsumers
readList :: ReadS [ListStreamConsumers]
$creadList :: ReadS [ListStreamConsumers]
readsPrec :: Int -> ReadS ListStreamConsumers
$creadsPrec :: Int -> ReadS ListStreamConsumers
Prelude.Read, Int -> ListStreamConsumers -> ShowS
[ListStreamConsumers] -> ShowS
ListStreamConsumers -> String
(Int -> ListStreamConsumers -> ShowS)
-> (ListStreamConsumers -> String)
-> ([ListStreamConsumers] -> ShowS)
-> Show ListStreamConsumers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStreamConsumers] -> ShowS
$cshowList :: [ListStreamConsumers] -> ShowS
show :: ListStreamConsumers -> String
$cshow :: ListStreamConsumers -> String
showsPrec :: Int -> ListStreamConsumers -> ShowS
$cshowsPrec :: Int -> ListStreamConsumers -> ShowS
Prelude.Show, (forall x. ListStreamConsumers -> Rep ListStreamConsumers x)
-> (forall x. Rep ListStreamConsumers x -> ListStreamConsumers)
-> Generic ListStreamConsumers
forall x. Rep ListStreamConsumers x -> ListStreamConsumers
forall x. ListStreamConsumers -> Rep ListStreamConsumers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStreamConsumers x -> ListStreamConsumers
$cfrom :: forall x. ListStreamConsumers -> Rep ListStreamConsumers x
Prelude.Generic)

-- |
-- Create a value of 'ListStreamConsumers' 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', 'listStreamConsumers_nextToken' - When the number of consumers that are registered with the data stream is
-- greater than the default value for the @MaxResults@ parameter, or if you
-- explicitly specify a value for @MaxResults@ that is less than the number
-- of consumers that are registered with the data stream, the response
-- includes a pagination token named @NextToken@. You can specify this
-- @NextToken@ value in a subsequent call to @ListStreamConsumers@ to list
-- the next set of registered consumers.
--
-- Don\'t specify @StreamName@ or @StreamCreationTimestamp@ if you specify
-- @NextToken@ because the latter unambiguously identifies the stream.
--
-- You can optionally specify a value for the @MaxResults@ parameter when
-- you specify @NextToken@. If you specify a @MaxResults@ value that is
-- less than the number of consumers that the operation returns if you
-- don\'t specify @MaxResults@, the response will contain a new @NextToken@
-- value. You can use the new @NextToken@ value in a subsequent call to the
-- @ListStreamConsumers@ operation to list the next set of consumers.
--
-- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
-- in the response to a call to @ListStreamConsumers@, you have 300 seconds
-- to use that value. If you specify an expired token in a call to
-- @ListStreamConsumers@, you get @ExpiredNextTokenException@.
--
-- 'streamCreationTimestamp', 'listStreamConsumers_streamCreationTimestamp' - Specify this input parameter to distinguish data streams that have the
-- same name. For example, if you create a data stream and then delete it,
-- and you later create another data stream with the same name, you can use
-- this input parameter to specify which of the two streams you want to
-- list the consumers for.
--
-- You can\'t specify this parameter if you specify the NextToken
-- parameter.
--
-- 'maxResults', 'listStreamConsumers_maxResults' - The maximum number of consumers that you want a single call of
-- @ListStreamConsumers@ to return.
--
-- 'streamARN', 'listStreamConsumers_streamARN' - The ARN of the Kinesis data stream for which you want to list the
-- registered consumers. For more information, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-kinesis-streams Amazon Resource Names (ARNs) and AWS Service Namespaces>.
newListStreamConsumers ::
  -- | 'streamARN'
  Prelude.Text ->
  ListStreamConsumers
newListStreamConsumers :: Text -> ListStreamConsumers
newListStreamConsumers Text
pStreamARN_ =
  ListStreamConsumers' :: Maybe Text
-> Maybe POSIX -> Maybe Natural -> Text -> ListStreamConsumers
ListStreamConsumers'
    { $sel:nextToken:ListStreamConsumers' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamCreationTimestamp:ListStreamConsumers' :: Maybe POSIX
streamCreationTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListStreamConsumers' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:streamARN:ListStreamConsumers' :: Text
streamARN = Text
pStreamARN_
    }

-- | When the number of consumers that are registered with the data stream is
-- greater than the default value for the @MaxResults@ parameter, or if you
-- explicitly specify a value for @MaxResults@ that is less than the number
-- of consumers that are registered with the data stream, the response
-- includes a pagination token named @NextToken@. You can specify this
-- @NextToken@ value in a subsequent call to @ListStreamConsumers@ to list
-- the next set of registered consumers.
--
-- Don\'t specify @StreamName@ or @StreamCreationTimestamp@ if you specify
-- @NextToken@ because the latter unambiguously identifies the stream.
--
-- You can optionally specify a value for the @MaxResults@ parameter when
-- you specify @NextToken@. If you specify a @MaxResults@ value that is
-- less than the number of consumers that the operation returns if you
-- don\'t specify @MaxResults@, the response will contain a new @NextToken@
-- value. You can use the new @NextToken@ value in a subsequent call to the
-- @ListStreamConsumers@ operation to list the next set of consumers.
--
-- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
-- in the response to a call to @ListStreamConsumers@, you have 300 seconds
-- to use that value. If you specify an expired token in a call to
-- @ListStreamConsumers@, you get @ExpiredNextTokenException@.
listStreamConsumers_nextToken :: Lens.Lens' ListStreamConsumers (Prelude.Maybe Prelude.Text)
listStreamConsumers_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListStreamConsumers -> f ListStreamConsumers
listStreamConsumers_nextToken = (ListStreamConsumers -> Maybe Text)
-> (ListStreamConsumers -> Maybe Text -> ListStreamConsumers)
-> Lens
     ListStreamConsumers ListStreamConsumers (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreamConsumers' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStreamConsumers' :: ListStreamConsumers -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStreamConsumers
s@ListStreamConsumers' {} Maybe Text
a -> ListStreamConsumers
s {$sel:nextToken:ListStreamConsumers' :: Maybe Text
nextToken = Maybe Text
a} :: ListStreamConsumers)

-- | Specify this input parameter to distinguish data streams that have the
-- same name. For example, if you create a data stream and then delete it,
-- and you later create another data stream with the same name, you can use
-- this input parameter to specify which of the two streams you want to
-- list the consumers for.
--
-- You can\'t specify this parameter if you specify the NextToken
-- parameter.
listStreamConsumers_streamCreationTimestamp :: Lens.Lens' ListStreamConsumers (Prelude.Maybe Prelude.UTCTime)
listStreamConsumers_streamCreationTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListStreamConsumers -> f ListStreamConsumers
listStreamConsumers_streamCreationTimestamp = (ListStreamConsumers -> Maybe POSIX)
-> (ListStreamConsumers -> Maybe POSIX -> ListStreamConsumers)
-> Lens
     ListStreamConsumers ListStreamConsumers (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreamConsumers' {Maybe POSIX
streamCreationTimestamp :: Maybe POSIX
$sel:streamCreationTimestamp:ListStreamConsumers' :: ListStreamConsumers -> Maybe POSIX
streamCreationTimestamp} -> Maybe POSIX
streamCreationTimestamp) (\s :: ListStreamConsumers
s@ListStreamConsumers' {} Maybe POSIX
a -> ListStreamConsumers
s {$sel:streamCreationTimestamp:ListStreamConsumers' :: Maybe POSIX
streamCreationTimestamp = Maybe POSIX
a} :: ListStreamConsumers) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListStreamConsumers -> f ListStreamConsumers)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListStreamConsumers
-> f ListStreamConsumers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The maximum number of consumers that you want a single call of
-- @ListStreamConsumers@ to return.
listStreamConsumers_maxResults :: Lens.Lens' ListStreamConsumers (Prelude.Maybe Prelude.Natural)
listStreamConsumers_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListStreamConsumers -> f ListStreamConsumers
listStreamConsumers_maxResults = (ListStreamConsumers -> Maybe Natural)
-> (ListStreamConsumers -> Maybe Natural -> ListStreamConsumers)
-> Lens
     ListStreamConsumers
     ListStreamConsumers
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreamConsumers' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListStreamConsumers' :: ListStreamConsumers -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListStreamConsumers
s@ListStreamConsumers' {} Maybe Natural
a -> ListStreamConsumers
s {$sel:maxResults:ListStreamConsumers' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListStreamConsumers)

-- | The ARN of the Kinesis data stream for which you want to list the
-- registered consumers. For more information, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-kinesis-streams Amazon Resource Names (ARNs) and AWS Service Namespaces>.
listStreamConsumers_streamARN :: Lens.Lens' ListStreamConsumers Prelude.Text
listStreamConsumers_streamARN :: (Text -> f Text) -> ListStreamConsumers -> f ListStreamConsumers
listStreamConsumers_streamARN = (ListStreamConsumers -> Text)
-> (ListStreamConsumers -> Text -> ListStreamConsumers)
-> Lens ListStreamConsumers ListStreamConsumers Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreamConsumers' {Text
streamARN :: Text
$sel:streamARN:ListStreamConsumers' :: ListStreamConsumers -> Text
streamARN} -> Text
streamARN) (\s :: ListStreamConsumers
s@ListStreamConsumers' {} Text
a -> ListStreamConsumers
s {$sel:streamARN:ListStreamConsumers' :: Text
streamARN = Text
a} :: ListStreamConsumers)

instance Core.AWSPager ListStreamConsumers where
  page :: ListStreamConsumers
-> AWSResponse ListStreamConsumers -> Maybe ListStreamConsumers
page ListStreamConsumers
rq AWSResponse ListStreamConsumers
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListStreamConsumers
ListStreamConsumersResponse
rs
            ListStreamConsumersResponse
-> Getting (First Text) ListStreamConsumersResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListStreamConsumersResponse
-> Const (First Text) ListStreamConsumersResponse
Lens' ListStreamConsumersResponse (Maybe Text)
listStreamConsumersResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListStreamConsumersResponse
 -> Const (First Text) ListStreamConsumersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListStreamConsumersResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListStreamConsumers
forall a. Maybe a
Prelude.Nothing
    | Maybe [Consumer] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListStreamConsumers
ListStreamConsumersResponse
rs
            ListStreamConsumersResponse
-> Getting
     (First [Consumer]) ListStreamConsumersResponse [Consumer]
-> Maybe [Consumer]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Consumer] -> Const (First [Consumer]) (Maybe [Consumer]))
-> ListStreamConsumersResponse
-> Const (First [Consumer]) ListStreamConsumersResponse
Lens' ListStreamConsumersResponse (Maybe [Consumer])
listStreamConsumersResponse_consumers
              ((Maybe [Consumer] -> Const (First [Consumer]) (Maybe [Consumer]))
 -> ListStreamConsumersResponse
 -> Const (First [Consumer]) ListStreamConsumersResponse)
-> (([Consumer] -> Const (First [Consumer]) [Consumer])
    -> Maybe [Consumer] -> Const (First [Consumer]) (Maybe [Consumer]))
-> Getting
     (First [Consumer]) ListStreamConsumersResponse [Consumer]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Consumer] -> Const (First [Consumer]) [Consumer])
-> Maybe [Consumer] -> Const (First [Consumer]) (Maybe [Consumer])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListStreamConsumers
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListStreamConsumers -> Maybe ListStreamConsumers
forall a. a -> Maybe a
Prelude.Just (ListStreamConsumers -> Maybe ListStreamConsumers)
-> ListStreamConsumers -> Maybe ListStreamConsumers
forall a b. (a -> b) -> a -> b
Prelude.$
        ListStreamConsumers
rq
          ListStreamConsumers
-> (ListStreamConsumers -> ListStreamConsumers)
-> ListStreamConsumers
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListStreamConsumers -> Identity ListStreamConsumers
Lens
  ListStreamConsumers ListStreamConsumers (Maybe Text) (Maybe Text)
listStreamConsumers_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListStreamConsumers -> Identity ListStreamConsumers)
-> Maybe Text -> ListStreamConsumers -> ListStreamConsumers
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListStreamConsumers
ListStreamConsumersResponse
rs
          ListStreamConsumersResponse
-> Getting (First Text) ListStreamConsumersResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListStreamConsumersResponse
-> Const (First Text) ListStreamConsumersResponse
Lens' ListStreamConsumersResponse (Maybe Text)
listStreamConsumersResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListStreamConsumersResponse
 -> Const (First Text) ListStreamConsumersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListStreamConsumersResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

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

instance Prelude.NFData ListStreamConsumers

instance Core.ToHeaders ListStreamConsumers where
  toHeaders :: ListStreamConsumers -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListStreamConsumers -> 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
"Kinesis_20131202.ListStreamConsumers" ::
                          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 ListStreamConsumers where
  toJSON :: ListStreamConsumers -> Value
toJSON ListStreamConsumers' {Maybe Natural
Maybe Text
Maybe POSIX
Text
streamARN :: Text
maxResults :: Maybe Natural
streamCreationTimestamp :: Maybe POSIX
nextToken :: Maybe Text
$sel:streamARN:ListStreamConsumers' :: ListStreamConsumers -> Text
$sel:maxResults:ListStreamConsumers' :: ListStreamConsumers -> Maybe Natural
$sel:streamCreationTimestamp:ListStreamConsumers' :: ListStreamConsumers -> Maybe POSIX
$sel:nextToken:ListStreamConsumers' :: ListStreamConsumers -> 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
"StreamCreationTimestamp" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
streamCreationTimestamp,
            (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StreamARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
streamARN)
          ]
      )

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

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

-- | /See:/ 'newListStreamConsumersResponse' smart constructor.
data ListStreamConsumersResponse = ListStreamConsumersResponse'
  { -- | When the number of consumers that are registered with the data stream is
    -- greater than the default value for the @MaxResults@ parameter, or if you
    -- explicitly specify a value for @MaxResults@ that is less than the number
    -- of registered consumers, the response includes a pagination token named
    -- @NextToken@. You can specify this @NextToken@ value in a subsequent call
    -- to @ListStreamConsumers@ to list the next set of registered consumers.
    -- For more information about the use of this pagination token when calling
    -- the @ListStreamConsumers@ operation, see
    -- ListStreamConsumersInput$NextToken.
    --
    -- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
    -- in the response to a call to @ListStreamConsumers@, you have 300 seconds
    -- to use that value. If you specify an expired token in a call to
    -- @ListStreamConsumers@, you get @ExpiredNextTokenException@.
    ListStreamConsumersResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of JSON objects. Each object represents one registered
    -- consumer.
    ListStreamConsumersResponse -> Maybe [Consumer]
consumers :: Prelude.Maybe [Consumer],
    -- | The response's http status code.
    ListStreamConsumersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListStreamConsumersResponse -> ListStreamConsumersResponse -> Bool
(ListStreamConsumersResponse
 -> ListStreamConsumersResponse -> Bool)
-> (ListStreamConsumersResponse
    -> ListStreamConsumersResponse -> Bool)
-> Eq ListStreamConsumersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStreamConsumersResponse -> ListStreamConsumersResponse -> Bool
$c/= :: ListStreamConsumersResponse -> ListStreamConsumersResponse -> Bool
== :: ListStreamConsumersResponse -> ListStreamConsumersResponse -> Bool
$c== :: ListStreamConsumersResponse -> ListStreamConsumersResponse -> Bool
Prelude.Eq, ReadPrec [ListStreamConsumersResponse]
ReadPrec ListStreamConsumersResponse
Int -> ReadS ListStreamConsumersResponse
ReadS [ListStreamConsumersResponse]
(Int -> ReadS ListStreamConsumersResponse)
-> ReadS [ListStreamConsumersResponse]
-> ReadPrec ListStreamConsumersResponse
-> ReadPrec [ListStreamConsumersResponse]
-> Read ListStreamConsumersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStreamConsumersResponse]
$creadListPrec :: ReadPrec [ListStreamConsumersResponse]
readPrec :: ReadPrec ListStreamConsumersResponse
$creadPrec :: ReadPrec ListStreamConsumersResponse
readList :: ReadS [ListStreamConsumersResponse]
$creadList :: ReadS [ListStreamConsumersResponse]
readsPrec :: Int -> ReadS ListStreamConsumersResponse
$creadsPrec :: Int -> ReadS ListStreamConsumersResponse
Prelude.Read, Int -> ListStreamConsumersResponse -> ShowS
[ListStreamConsumersResponse] -> ShowS
ListStreamConsumersResponse -> String
(Int -> ListStreamConsumersResponse -> ShowS)
-> (ListStreamConsumersResponse -> String)
-> ([ListStreamConsumersResponse] -> ShowS)
-> Show ListStreamConsumersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStreamConsumersResponse] -> ShowS
$cshowList :: [ListStreamConsumersResponse] -> ShowS
show :: ListStreamConsumersResponse -> String
$cshow :: ListStreamConsumersResponse -> String
showsPrec :: Int -> ListStreamConsumersResponse -> ShowS
$cshowsPrec :: Int -> ListStreamConsumersResponse -> ShowS
Prelude.Show, (forall x.
 ListStreamConsumersResponse -> Rep ListStreamConsumersResponse x)
-> (forall x.
    Rep ListStreamConsumersResponse x -> ListStreamConsumersResponse)
-> Generic ListStreamConsumersResponse
forall x.
Rep ListStreamConsumersResponse x -> ListStreamConsumersResponse
forall x.
ListStreamConsumersResponse -> Rep ListStreamConsumersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListStreamConsumersResponse x -> ListStreamConsumersResponse
$cfrom :: forall x.
ListStreamConsumersResponse -> Rep ListStreamConsumersResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListStreamConsumersResponse' 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', 'listStreamConsumersResponse_nextToken' - When the number of consumers that are registered with the data stream is
-- greater than the default value for the @MaxResults@ parameter, or if you
-- explicitly specify a value for @MaxResults@ that is less than the number
-- of registered consumers, the response includes a pagination token named
-- @NextToken@. You can specify this @NextToken@ value in a subsequent call
-- to @ListStreamConsumers@ to list the next set of registered consumers.
-- For more information about the use of this pagination token when calling
-- the @ListStreamConsumers@ operation, see
-- ListStreamConsumersInput$NextToken.
--
-- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
-- in the response to a call to @ListStreamConsumers@, you have 300 seconds
-- to use that value. If you specify an expired token in a call to
-- @ListStreamConsumers@, you get @ExpiredNextTokenException@.
--
-- 'consumers', 'listStreamConsumersResponse_consumers' - An array of JSON objects. Each object represents one registered
-- consumer.
--
-- 'httpStatus', 'listStreamConsumersResponse_httpStatus' - The response's http status code.
newListStreamConsumersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListStreamConsumersResponse
newListStreamConsumersResponse :: Int -> ListStreamConsumersResponse
newListStreamConsumersResponse Int
pHttpStatus_ =
  ListStreamConsumersResponse' :: Maybe Text
-> Maybe [Consumer] -> Int -> ListStreamConsumersResponse
ListStreamConsumersResponse'
    { $sel:nextToken:ListStreamConsumersResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:consumers:ListStreamConsumersResponse' :: Maybe [Consumer]
consumers = Maybe [Consumer]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListStreamConsumersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | When the number of consumers that are registered with the data stream is
-- greater than the default value for the @MaxResults@ parameter, or if you
-- explicitly specify a value for @MaxResults@ that is less than the number
-- of registered consumers, the response includes a pagination token named
-- @NextToken@. You can specify this @NextToken@ value in a subsequent call
-- to @ListStreamConsumers@ to list the next set of registered consumers.
-- For more information about the use of this pagination token when calling
-- the @ListStreamConsumers@ operation, see
-- ListStreamConsumersInput$NextToken.
--
-- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
-- in the response to a call to @ListStreamConsumers@, you have 300 seconds
-- to use that value. If you specify an expired token in a call to
-- @ListStreamConsumers@, you get @ExpiredNextTokenException@.
listStreamConsumersResponse_nextToken :: Lens.Lens' ListStreamConsumersResponse (Prelude.Maybe Prelude.Text)
listStreamConsumersResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListStreamConsumersResponse -> f ListStreamConsumersResponse
listStreamConsumersResponse_nextToken = (ListStreamConsumersResponse -> Maybe Text)
-> (ListStreamConsumersResponse
    -> Maybe Text -> ListStreamConsumersResponse)
-> Lens' ListStreamConsumersResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreamConsumersResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStreamConsumersResponse' :: ListStreamConsumersResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStreamConsumersResponse
s@ListStreamConsumersResponse' {} Maybe Text
a -> ListStreamConsumersResponse
s {$sel:nextToken:ListStreamConsumersResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListStreamConsumersResponse)

-- | An array of JSON objects. Each object represents one registered
-- consumer.
listStreamConsumersResponse_consumers :: Lens.Lens' ListStreamConsumersResponse (Prelude.Maybe [Consumer])
listStreamConsumersResponse_consumers :: (Maybe [Consumer] -> f (Maybe [Consumer]))
-> ListStreamConsumersResponse -> f ListStreamConsumersResponse
listStreamConsumersResponse_consumers = (ListStreamConsumersResponse -> Maybe [Consumer])
-> (ListStreamConsumersResponse
    -> Maybe [Consumer] -> ListStreamConsumersResponse)
-> Lens' ListStreamConsumersResponse (Maybe [Consumer])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStreamConsumersResponse' {Maybe [Consumer]
consumers :: Maybe [Consumer]
$sel:consumers:ListStreamConsumersResponse' :: ListStreamConsumersResponse -> Maybe [Consumer]
consumers} -> Maybe [Consumer]
consumers) (\s :: ListStreamConsumersResponse
s@ListStreamConsumersResponse' {} Maybe [Consumer]
a -> ListStreamConsumersResponse
s {$sel:consumers:ListStreamConsumersResponse' :: Maybe [Consumer]
consumers = Maybe [Consumer]
a} :: ListStreamConsumersResponse) ((Maybe [Consumer] -> f (Maybe [Consumer]))
 -> ListStreamConsumersResponse -> f ListStreamConsumersResponse)
-> ((Maybe [Consumer] -> f (Maybe [Consumer]))
    -> Maybe [Consumer] -> f (Maybe [Consumer]))
-> (Maybe [Consumer] -> f (Maybe [Consumer]))
-> ListStreamConsumersResponse
-> f ListStreamConsumersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Consumer] [Consumer] [Consumer] [Consumer]
-> Iso
     (Maybe [Consumer])
     (Maybe [Consumer])
     (Maybe [Consumer])
     (Maybe [Consumer])
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 [Consumer] [Consumer] [Consumer] [Consumer]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListStreamConsumersResponse