{-# 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.ListShards
-- 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 shards in a stream and provides information about each shard.
-- This operation has a limit of 100 transactions per second per data
-- stream.
--
-- This API is a new operation that is used by the Amazon Kinesis Client
-- Library (KCL). If you have a fine-grained IAM policy that only allows
-- specific operations, you must update your policy to allow calls to this
-- API. For more information, see
-- <https://docs.aws.amazon.com/streams/latest/dev/controlling-access.html Controlling Access to Amazon Kinesis Data Streams Resources Using IAM>.
--
-- This operation returns paginated results.
module Amazonka.Kinesis.ListShards
  ( -- * Creating a Request
    ListShards (..),
    newListShards,

    -- * Request Lenses
    listShards_shardFilter,
    listShards_nextToken,
    listShards_exclusiveStartShardId,
    listShards_streamCreationTimestamp,
    listShards_streamName,
    listShards_maxResults,

    -- * Destructuring the Response
    ListShardsResponse (..),
    newListShardsResponse,

    -- * Response Lenses
    listShardsResponse_nextToken,
    listShardsResponse_shards,
    listShardsResponse_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:/ 'newListShards' smart constructor.
data ListShards = ListShards'
  { ListShards -> Maybe ShardFilter
shardFilter :: Prelude.Maybe ShardFilter,
    -- | When the number of shards in 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 shards in the
    -- data stream, the response includes a pagination token named @NextToken@.
    -- You can specify this @NextToken@ value in a subsequent call to
    -- @ListShards@ to list the next set of shards.
    --
    -- 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 shards 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
    -- @ListShards@ operation.
    --
    -- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
    -- in the response to a call to @ListShards@, you have 300 seconds to use
    -- that value. If you specify an expired token in a call to @ListShards@,
    -- you get @ExpiredNextTokenException@.
    ListShards -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specify this parameter to indicate that you want to list the shards
    -- starting with the shard whose ID immediately follows
    -- @ExclusiveStartShardId@.
    --
    -- If you don\'t specify this parameter, the default behavior is for
    -- @ListShards@ to list the shards starting with the first one in the
    -- stream.
    --
    -- You cannot specify this parameter if you specify @NextToken@.
    ListShards -> Maybe Text
exclusiveStartShardId :: 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 shards for.
    --
    -- You cannot specify this parameter if you specify the @NextToken@
    -- parameter.
    ListShards -> Maybe POSIX
streamCreationTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The name of the data stream whose shards you want to list.
    --
    -- You cannot specify this parameter if you specify the @NextToken@
    -- parameter.
    ListShards -> Maybe Text
streamName :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of shards to return in a single call to @ListShards@.
    -- The minimum value you can specify for this parameter is 1, and the
    -- maximum is 10,000, which is also the default.
    --
    -- When the number of shards to be listed is greater than the value of
    -- @MaxResults@, the response contains a @NextToken@ value that you can use
    -- in a subsequent call to @ListShards@ to list the next set of shards.
    ListShards -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListShards -> ListShards -> Bool
(ListShards -> ListShards -> Bool)
-> (ListShards -> ListShards -> Bool) -> Eq ListShards
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListShards -> ListShards -> Bool
$c/= :: ListShards -> ListShards -> Bool
== :: ListShards -> ListShards -> Bool
$c== :: ListShards -> ListShards -> Bool
Prelude.Eq, ReadPrec [ListShards]
ReadPrec ListShards
Int -> ReadS ListShards
ReadS [ListShards]
(Int -> ReadS ListShards)
-> ReadS [ListShards]
-> ReadPrec ListShards
-> ReadPrec [ListShards]
-> Read ListShards
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListShards]
$creadListPrec :: ReadPrec [ListShards]
readPrec :: ReadPrec ListShards
$creadPrec :: ReadPrec ListShards
readList :: ReadS [ListShards]
$creadList :: ReadS [ListShards]
readsPrec :: Int -> ReadS ListShards
$creadsPrec :: Int -> ReadS ListShards
Prelude.Read, Int -> ListShards -> ShowS
[ListShards] -> ShowS
ListShards -> String
(Int -> ListShards -> ShowS)
-> (ListShards -> String)
-> ([ListShards] -> ShowS)
-> Show ListShards
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListShards] -> ShowS
$cshowList :: [ListShards] -> ShowS
show :: ListShards -> String
$cshow :: ListShards -> String
showsPrec :: Int -> ListShards -> ShowS
$cshowsPrec :: Int -> ListShards -> ShowS
Prelude.Show, (forall x. ListShards -> Rep ListShards x)
-> (forall x. Rep ListShards x -> ListShards) -> Generic ListShards
forall x. Rep ListShards x -> ListShards
forall x. ListShards -> Rep ListShards x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListShards x -> ListShards
$cfrom :: forall x. ListShards -> Rep ListShards x
Prelude.Generic)

-- |
-- Create a value of 'ListShards' 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:
--
-- 'shardFilter', 'listShards_shardFilter' - Undocumented member.
--
-- 'nextToken', 'listShards_nextToken' - When the number of shards in 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 shards in the
-- data stream, the response includes a pagination token named @NextToken@.
-- You can specify this @NextToken@ value in a subsequent call to
-- @ListShards@ to list the next set of shards.
--
-- 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 shards 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
-- @ListShards@ operation.
--
-- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
-- in the response to a call to @ListShards@, you have 300 seconds to use
-- that value. If you specify an expired token in a call to @ListShards@,
-- you get @ExpiredNextTokenException@.
--
-- 'exclusiveStartShardId', 'listShards_exclusiveStartShardId' - Specify this parameter to indicate that you want to list the shards
-- starting with the shard whose ID immediately follows
-- @ExclusiveStartShardId@.
--
-- If you don\'t specify this parameter, the default behavior is for
-- @ListShards@ to list the shards starting with the first one in the
-- stream.
--
-- You cannot specify this parameter if you specify @NextToken@.
--
-- 'streamCreationTimestamp', 'listShards_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 shards for.
--
-- You cannot specify this parameter if you specify the @NextToken@
-- parameter.
--
-- 'streamName', 'listShards_streamName' - The name of the data stream whose shards you want to list.
--
-- You cannot specify this parameter if you specify the @NextToken@
-- parameter.
--
-- 'maxResults', 'listShards_maxResults' - The maximum number of shards to return in a single call to @ListShards@.
-- The minimum value you can specify for this parameter is 1, and the
-- maximum is 10,000, which is also the default.
--
-- When the number of shards to be listed is greater than the value of
-- @MaxResults@, the response contains a @NextToken@ value that you can use
-- in a subsequent call to @ListShards@ to list the next set of shards.
newListShards ::
  ListShards
newListShards :: ListShards
newListShards =
  ListShards' :: Maybe ShardFilter
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Natural
-> ListShards
ListShards'
    { $sel:shardFilter:ListShards' :: Maybe ShardFilter
shardFilter = Maybe ShardFilter
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListShards' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:exclusiveStartShardId:ListShards' :: Maybe Text
exclusiveStartShardId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamCreationTimestamp:ListShards' :: Maybe POSIX
streamCreationTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:ListShards' :: Maybe Text
streamName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListShards' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
listShards_shardFilter :: Lens.Lens' ListShards (Prelude.Maybe ShardFilter)
listShards_shardFilter :: (Maybe ShardFilter -> f (Maybe ShardFilter))
-> ListShards -> f ListShards
listShards_shardFilter = (ListShards -> Maybe ShardFilter)
-> (ListShards -> Maybe ShardFilter -> ListShards)
-> Lens
     ListShards ListShards (Maybe ShardFilter) (Maybe ShardFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListShards' {Maybe ShardFilter
shardFilter :: Maybe ShardFilter
$sel:shardFilter:ListShards' :: ListShards -> Maybe ShardFilter
shardFilter} -> Maybe ShardFilter
shardFilter) (\s :: ListShards
s@ListShards' {} Maybe ShardFilter
a -> ListShards
s {$sel:shardFilter:ListShards' :: Maybe ShardFilter
shardFilter = Maybe ShardFilter
a} :: ListShards)

-- | When the number of shards in 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 shards in the
-- data stream, the response includes a pagination token named @NextToken@.
-- You can specify this @NextToken@ value in a subsequent call to
-- @ListShards@ to list the next set of shards.
--
-- 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 shards 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
-- @ListShards@ operation.
--
-- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
-- in the response to a call to @ListShards@, you have 300 seconds to use
-- that value. If you specify an expired token in a call to @ListShards@,
-- you get @ExpiredNextTokenException@.
listShards_nextToken :: Lens.Lens' ListShards (Prelude.Maybe Prelude.Text)
listShards_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListShards -> f ListShards
listShards_nextToken = (ListShards -> Maybe Text)
-> (ListShards -> Maybe Text -> ListShards)
-> Lens ListShards ListShards (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListShards' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListShards' :: ListShards -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListShards
s@ListShards' {} Maybe Text
a -> ListShards
s {$sel:nextToken:ListShards' :: Maybe Text
nextToken = Maybe Text
a} :: ListShards)

-- | Specify this parameter to indicate that you want to list the shards
-- starting with the shard whose ID immediately follows
-- @ExclusiveStartShardId@.
--
-- If you don\'t specify this parameter, the default behavior is for
-- @ListShards@ to list the shards starting with the first one in the
-- stream.
--
-- You cannot specify this parameter if you specify @NextToken@.
listShards_exclusiveStartShardId :: Lens.Lens' ListShards (Prelude.Maybe Prelude.Text)
listShards_exclusiveStartShardId :: (Maybe Text -> f (Maybe Text)) -> ListShards -> f ListShards
listShards_exclusiveStartShardId = (ListShards -> Maybe Text)
-> (ListShards -> Maybe Text -> ListShards)
-> Lens ListShards ListShards (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListShards' {Maybe Text
exclusiveStartShardId :: Maybe Text
$sel:exclusiveStartShardId:ListShards' :: ListShards -> Maybe Text
exclusiveStartShardId} -> Maybe Text
exclusiveStartShardId) (\s :: ListShards
s@ListShards' {} Maybe Text
a -> ListShards
s {$sel:exclusiveStartShardId:ListShards' :: Maybe Text
exclusiveStartShardId = Maybe Text
a} :: ListShards)

-- | 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 shards for.
--
-- You cannot specify this parameter if you specify the @NextToken@
-- parameter.
listShards_streamCreationTimestamp :: Lens.Lens' ListShards (Prelude.Maybe Prelude.UTCTime)
listShards_streamCreationTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime)) -> ListShards -> f ListShards
listShards_streamCreationTimestamp = (ListShards -> Maybe POSIX)
-> (ListShards -> Maybe POSIX -> ListShards)
-> Lens ListShards ListShards (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListShards' {Maybe POSIX
streamCreationTimestamp :: Maybe POSIX
$sel:streamCreationTimestamp:ListShards' :: ListShards -> Maybe POSIX
streamCreationTimestamp} -> Maybe POSIX
streamCreationTimestamp) (\s :: ListShards
s@ListShards' {} Maybe POSIX
a -> ListShards
s {$sel:streamCreationTimestamp:ListShards' :: Maybe POSIX
streamCreationTimestamp = Maybe POSIX
a} :: ListShards) ((Maybe POSIX -> f (Maybe POSIX)) -> ListShards -> f ListShards)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListShards
-> f ListShards
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 name of the data stream whose shards you want to list.
--
-- You cannot specify this parameter if you specify the @NextToken@
-- parameter.
listShards_streamName :: Lens.Lens' ListShards (Prelude.Maybe Prelude.Text)
listShards_streamName :: (Maybe Text -> f (Maybe Text)) -> ListShards -> f ListShards
listShards_streamName = (ListShards -> Maybe Text)
-> (ListShards -> Maybe Text -> ListShards)
-> Lens ListShards ListShards (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListShards' {Maybe Text
streamName :: Maybe Text
$sel:streamName:ListShards' :: ListShards -> Maybe Text
streamName} -> Maybe Text
streamName) (\s :: ListShards
s@ListShards' {} Maybe Text
a -> ListShards
s {$sel:streamName:ListShards' :: Maybe Text
streamName = Maybe Text
a} :: ListShards)

-- | The maximum number of shards to return in a single call to @ListShards@.
-- The minimum value you can specify for this parameter is 1, and the
-- maximum is 10,000, which is also the default.
--
-- When the number of shards to be listed is greater than the value of
-- @MaxResults@, the response contains a @NextToken@ value that you can use
-- in a subsequent call to @ListShards@ to list the next set of shards.
listShards_maxResults :: Lens.Lens' ListShards (Prelude.Maybe Prelude.Natural)
listShards_maxResults :: (Maybe Natural -> f (Maybe Natural)) -> ListShards -> f ListShards
listShards_maxResults = (ListShards -> Maybe Natural)
-> (ListShards -> Maybe Natural -> ListShards)
-> Lens ListShards ListShards (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListShards' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListShards' :: ListShards -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListShards
s@ListShards' {} Maybe Natural
a -> ListShards
s {$sel:maxResults:ListShards' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListShards)

instance Core.AWSPager ListShards where
  page :: ListShards -> AWSResponse ListShards -> Maybe ListShards
page ListShards
rq AWSResponse ListShards
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListShards
ListShardsResponse
rs
            ListShardsResponse
-> Getting (First Text) ListShardsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListShardsResponse -> Const (First Text) ListShardsResponse
Lens' ListShardsResponse (Maybe Text)
listShardsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListShardsResponse -> Const (First Text) ListShardsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListShardsResponse 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 ListShards
forall a. Maybe a
Prelude.Nothing
    | Maybe [Shard] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListShards
ListShardsResponse
rs
            ListShardsResponse
-> Getting (First [Shard]) ListShardsResponse [Shard]
-> Maybe [Shard]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Shard] -> Const (First [Shard]) (Maybe [Shard]))
-> ListShardsResponse -> Const (First [Shard]) ListShardsResponse
Lens' ListShardsResponse (Maybe [Shard])
listShardsResponse_shards ((Maybe [Shard] -> Const (First [Shard]) (Maybe [Shard]))
 -> ListShardsResponse -> Const (First [Shard]) ListShardsResponse)
-> (([Shard] -> Const (First [Shard]) [Shard])
    -> Maybe [Shard] -> Const (First [Shard]) (Maybe [Shard]))
-> Getting (First [Shard]) ListShardsResponse [Shard]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Shard] -> Const (First [Shard]) [Shard])
-> Maybe [Shard] -> Const (First [Shard]) (Maybe [Shard])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListShards
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListShards -> Maybe ListShards
forall a. a -> Maybe a
Prelude.Just (ListShards -> Maybe ListShards) -> ListShards -> Maybe ListShards
forall a b. (a -> b) -> a -> b
Prelude.$
        ListShards
rq
          ListShards -> (ListShards -> ListShards) -> ListShards
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListShards -> Identity ListShards
Lens ListShards ListShards (Maybe Text) (Maybe Text)
listShards_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListShards -> Identity ListShards)
-> Maybe Text -> ListShards -> ListShards
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListShards
ListShardsResponse
rs
          ListShardsResponse
-> Getting (First Text) ListShardsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListShardsResponse -> Const (First Text) ListShardsResponse
Lens' ListShardsResponse (Maybe Text)
listShardsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListShardsResponse -> Const (First Text) ListShardsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListShardsResponse 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 ListShards where
  type AWSResponse ListShards = ListShardsResponse
  request :: ListShards -> Request ListShards
request = Service -> ListShards -> Request ListShards
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListShards
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListShards)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListShards))
-> Logger
-> Service
-> Proxy ListShards
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListShards)))
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 [Shard] -> Int -> ListShardsResponse
ListShardsResponse'
            (Maybe Text -> Maybe [Shard] -> Int -> ListShardsResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [Shard] -> Int -> ListShardsResponse)
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 [Shard] -> Int -> ListShardsResponse)
-> Either String (Maybe [Shard])
-> Either String (Int -> ListShardsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Shard]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Shards" Either String (Maybe (Maybe [Shard]))
-> Maybe [Shard] -> Either String (Maybe [Shard])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Shard]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListShardsResponse)
-> Either String Int -> Either String ListShardsResponse
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 ListShards

instance Prelude.NFData ListShards

instance Core.ToHeaders ListShards where
  toHeaders :: ListShards -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListShards -> 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.ListShards" ::
                          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 ListShards where
  toJSON :: ListShards -> Value
toJSON ListShards' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe ShardFilter
maxResults :: Maybe Natural
streamName :: Maybe Text
streamCreationTimestamp :: Maybe POSIX
exclusiveStartShardId :: Maybe Text
nextToken :: Maybe Text
shardFilter :: Maybe ShardFilter
$sel:maxResults:ListShards' :: ListShards -> Maybe Natural
$sel:streamName:ListShards' :: ListShards -> Maybe Text
$sel:streamCreationTimestamp:ListShards' :: ListShards -> Maybe POSIX
$sel:exclusiveStartShardId:ListShards' :: ListShards -> Maybe Text
$sel:nextToken:ListShards' :: ListShards -> Maybe Text
$sel:shardFilter:ListShards' :: ListShards -> Maybe ShardFilter
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ShardFilter" Text -> ShardFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ShardFilter -> Pair) -> Maybe ShardFilter -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ShardFilter
shardFilter,
            (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
"ExclusiveStartShardId" 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
exclusiveStartShardId,
            (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
"StreamName" 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
streamName,
            (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 ListShards where
  toPath :: ListShards -> ByteString
toPath = ByteString -> ListShards -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListShardsResponse' smart constructor.
data ListShardsResponse = ListShardsResponse'
  { -- | When the number of shards in 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 shards in the
    -- data stream, the response includes a pagination token named @NextToken@.
    -- You can specify this @NextToken@ value in a subsequent call to
    -- @ListShards@ to list the next set of shards. For more information about
    -- the use of this pagination token when calling the @ListShards@
    -- operation, see ListShardsInput$NextToken.
    --
    -- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
    -- in the response to a call to @ListShards@, you have 300 seconds to use
    -- that value. If you specify an expired token in a call to @ListShards@,
    -- you get @ExpiredNextTokenException@.
    ListShardsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of JSON objects. Each object represents one shard and specifies
    -- the IDs of the shard, the shard\'s parent, and the shard that\'s
    -- adjacent to the shard\'s parent. Each object also contains the starting
    -- and ending hash keys and the starting and ending sequence numbers for
    -- the shard.
    ListShardsResponse -> Maybe [Shard]
shards :: Prelude.Maybe [Shard],
    -- | The response's http status code.
    ListShardsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListShardsResponse -> ListShardsResponse -> Bool
(ListShardsResponse -> ListShardsResponse -> Bool)
-> (ListShardsResponse -> ListShardsResponse -> Bool)
-> Eq ListShardsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListShardsResponse -> ListShardsResponse -> Bool
$c/= :: ListShardsResponse -> ListShardsResponse -> Bool
== :: ListShardsResponse -> ListShardsResponse -> Bool
$c== :: ListShardsResponse -> ListShardsResponse -> Bool
Prelude.Eq, ReadPrec [ListShardsResponse]
ReadPrec ListShardsResponse
Int -> ReadS ListShardsResponse
ReadS [ListShardsResponse]
(Int -> ReadS ListShardsResponse)
-> ReadS [ListShardsResponse]
-> ReadPrec ListShardsResponse
-> ReadPrec [ListShardsResponse]
-> Read ListShardsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListShardsResponse]
$creadListPrec :: ReadPrec [ListShardsResponse]
readPrec :: ReadPrec ListShardsResponse
$creadPrec :: ReadPrec ListShardsResponse
readList :: ReadS [ListShardsResponse]
$creadList :: ReadS [ListShardsResponse]
readsPrec :: Int -> ReadS ListShardsResponse
$creadsPrec :: Int -> ReadS ListShardsResponse
Prelude.Read, Int -> ListShardsResponse -> ShowS
[ListShardsResponse] -> ShowS
ListShardsResponse -> String
(Int -> ListShardsResponse -> ShowS)
-> (ListShardsResponse -> String)
-> ([ListShardsResponse] -> ShowS)
-> Show ListShardsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListShardsResponse] -> ShowS
$cshowList :: [ListShardsResponse] -> ShowS
show :: ListShardsResponse -> String
$cshow :: ListShardsResponse -> String
showsPrec :: Int -> ListShardsResponse -> ShowS
$cshowsPrec :: Int -> ListShardsResponse -> ShowS
Prelude.Show, (forall x. ListShardsResponse -> Rep ListShardsResponse x)
-> (forall x. Rep ListShardsResponse x -> ListShardsResponse)
-> Generic ListShardsResponse
forall x. Rep ListShardsResponse x -> ListShardsResponse
forall x. ListShardsResponse -> Rep ListShardsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListShardsResponse x -> ListShardsResponse
$cfrom :: forall x. ListShardsResponse -> Rep ListShardsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListShardsResponse' 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', 'listShardsResponse_nextToken' - When the number of shards in 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 shards in the
-- data stream, the response includes a pagination token named @NextToken@.
-- You can specify this @NextToken@ value in a subsequent call to
-- @ListShards@ to list the next set of shards. For more information about
-- the use of this pagination token when calling the @ListShards@
-- operation, see ListShardsInput$NextToken.
--
-- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
-- in the response to a call to @ListShards@, you have 300 seconds to use
-- that value. If you specify an expired token in a call to @ListShards@,
-- you get @ExpiredNextTokenException@.
--
-- 'shards', 'listShardsResponse_shards' - An array of JSON objects. Each object represents one shard and specifies
-- the IDs of the shard, the shard\'s parent, and the shard that\'s
-- adjacent to the shard\'s parent. Each object also contains the starting
-- and ending hash keys and the starting and ending sequence numbers for
-- the shard.
--
-- 'httpStatus', 'listShardsResponse_httpStatus' - The response's http status code.
newListShardsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListShardsResponse
newListShardsResponse :: Int -> ListShardsResponse
newListShardsResponse Int
pHttpStatus_ =
  ListShardsResponse' :: Maybe Text -> Maybe [Shard] -> Int -> ListShardsResponse
ListShardsResponse'
    { $sel:nextToken:ListShardsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:shards:ListShardsResponse' :: Maybe [Shard]
shards = Maybe [Shard]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListShardsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | When the number of shards in 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 shards in the
-- data stream, the response includes a pagination token named @NextToken@.
-- You can specify this @NextToken@ value in a subsequent call to
-- @ListShards@ to list the next set of shards. For more information about
-- the use of this pagination token when calling the @ListShards@
-- operation, see ListShardsInput$NextToken.
--
-- Tokens expire after 300 seconds. When you obtain a value for @NextToken@
-- in the response to a call to @ListShards@, you have 300 seconds to use
-- that value. If you specify an expired token in a call to @ListShards@,
-- you get @ExpiredNextTokenException@.
listShardsResponse_nextToken :: Lens.Lens' ListShardsResponse (Prelude.Maybe Prelude.Text)
listShardsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListShardsResponse -> f ListShardsResponse
listShardsResponse_nextToken = (ListShardsResponse -> Maybe Text)
-> (ListShardsResponse -> Maybe Text -> ListShardsResponse)
-> Lens' ListShardsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListShardsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListShardsResponse' :: ListShardsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListShardsResponse
s@ListShardsResponse' {} Maybe Text
a -> ListShardsResponse
s {$sel:nextToken:ListShardsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListShardsResponse)

-- | An array of JSON objects. Each object represents one shard and specifies
-- the IDs of the shard, the shard\'s parent, and the shard that\'s
-- adjacent to the shard\'s parent. Each object also contains the starting
-- and ending hash keys and the starting and ending sequence numbers for
-- the shard.
listShardsResponse_shards :: Lens.Lens' ListShardsResponse (Prelude.Maybe [Shard])
listShardsResponse_shards :: (Maybe [Shard] -> f (Maybe [Shard]))
-> ListShardsResponse -> f ListShardsResponse
listShardsResponse_shards = (ListShardsResponse -> Maybe [Shard])
-> (ListShardsResponse -> Maybe [Shard] -> ListShardsResponse)
-> Lens' ListShardsResponse (Maybe [Shard])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListShardsResponse' {Maybe [Shard]
shards :: Maybe [Shard]
$sel:shards:ListShardsResponse' :: ListShardsResponse -> Maybe [Shard]
shards} -> Maybe [Shard]
shards) (\s :: ListShardsResponse
s@ListShardsResponse' {} Maybe [Shard]
a -> ListShardsResponse
s {$sel:shards:ListShardsResponse' :: Maybe [Shard]
shards = Maybe [Shard]
a} :: ListShardsResponse) ((Maybe [Shard] -> f (Maybe [Shard]))
 -> ListShardsResponse -> f ListShardsResponse)
-> ((Maybe [Shard] -> f (Maybe [Shard]))
    -> Maybe [Shard] -> f (Maybe [Shard]))
-> (Maybe [Shard] -> f (Maybe [Shard]))
-> ListShardsResponse
-> f ListShardsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Shard] [Shard] [Shard] [Shard]
-> Iso
     (Maybe [Shard]) (Maybe [Shard]) (Maybe [Shard]) (Maybe [Shard])
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 [Shard] [Shard] [Shard] [Shard]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListShardsResponse