{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 1000 transactions per second per data
-- stream.
--
-- When invoking this API, it is recommended you use the @StreamARN@ input
-- parameter rather than the @StreamName@ input parameter.
--
-- This action does not list expired shards. For information about expired
-- shards, see
-- <https://docs.aws.amazon.com/streams/latest/dev/kinesis-using-sdk-java-after-resharding.html#kinesis-using-sdk-java-resharding-data-routing Data Routing, Data Persistence, and Shard State after a Reshard>.
--
-- 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_exclusiveStartShardId,
    listShards_maxResults,
    listShards_nextToken,
    listShards_shardFilter,
    listShards_streamARN,
    listShards_streamCreationTimestamp,
    listShards_streamName,

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

    -- * Response Lenses
    listShardsResponse_nextToken,
    listShardsResponse_shards,
    listShardsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kinesis.Types
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'
  { -- | 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,
    -- | The maximum number of shards to return in a single call to @ListShards@.
    -- The maximum number of shards to return in a single call. The default
    -- value is 1000. If you specify a value greater than 1000, at most 1000
    -- results are returned.
    --
    -- 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,
    -- | 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,
    -- | Enables you to filter out the response of the @ListShards@ API. You can
    -- only specify one filter at a time.
    --
    -- If you use the @ShardFilter@ parameter when invoking the ListShards API,
    -- the @Type@ is the required property and must be specified. If you
    -- specify the @AT_TRIM_HORIZON@, @FROM_TRIM_HORIZON@, or @AT_LATEST@
    -- types, you do not need to specify either the @ShardId@ or the
    -- @Timestamp@ optional properties.
    --
    -- If you specify the @AFTER_SHARD_ID@ type, you must also provide the
    -- value for the optional @ShardId@ property. The @ShardId@ property is
    -- identical in fuctionality to the @ExclusiveStartShardId@ parameter of
    -- the @ListShards@ API. When @ShardId@ property is specified, the response
    -- includes the shards starting with the shard whose ID immediately follows
    -- the @ShardId@ that you provided.
    --
    -- If you specify the @AT_TIMESTAMP@ or @FROM_TIMESTAMP_ID@ type, you must
    -- also provide the value for the optional @Timestamp@ property. If you
    -- specify the AT_TIMESTAMP type, then all shards that were open at the
    -- provided timestamp are returned. If you specify the FROM_TIMESTAMP type,
    -- then all shards starting from the provided timestamp to TIP are
    -- returned.
    ListShards -> Maybe ShardFilter
shardFilter :: Prelude.Maybe ShardFilter,
    -- | The ARN of the stream.
    ListShards -> Maybe Text
streamARN :: 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 Data.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
  }
  deriving (ListShards -> ListShards -> Bool
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]
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
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. 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:
--
-- '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@.
--
-- 'maxResults', 'listShards_maxResults' - The maximum number of shards to return in a single call to @ListShards@.
-- The maximum number of shards to return in a single call. The default
-- value is 1000. If you specify a value greater than 1000, at most 1000
-- results are returned.
--
-- 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.
--
-- '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@.
--
-- 'shardFilter', 'listShards_shardFilter' - Enables you to filter out the response of the @ListShards@ API. You can
-- only specify one filter at a time.
--
-- If you use the @ShardFilter@ parameter when invoking the ListShards API,
-- the @Type@ is the required property and must be specified. If you
-- specify the @AT_TRIM_HORIZON@, @FROM_TRIM_HORIZON@, or @AT_LATEST@
-- types, you do not need to specify either the @ShardId@ or the
-- @Timestamp@ optional properties.
--
-- If you specify the @AFTER_SHARD_ID@ type, you must also provide the
-- value for the optional @ShardId@ property. The @ShardId@ property is
-- identical in fuctionality to the @ExclusiveStartShardId@ parameter of
-- the @ListShards@ API. When @ShardId@ property is specified, the response
-- includes the shards starting with the shard whose ID immediately follows
-- the @ShardId@ that you provided.
--
-- If you specify the @AT_TIMESTAMP@ or @FROM_TIMESTAMP_ID@ type, you must
-- also provide the value for the optional @Timestamp@ property. If you
-- specify the AT_TIMESTAMP type, then all shards that were open at the
-- provided timestamp are returned. If you specify the FROM_TIMESTAMP type,
-- then all shards starting from the provided timestamp to TIP are
-- returned.
--
-- 'streamARN', 'listShards_streamARN' - The ARN of the stream.
--
-- '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.
newListShards ::
  ListShards
newListShards :: ListShards
newListShards =
  ListShards'
    { $sel:exclusiveStartShardId:ListShards' :: Maybe Text
exclusiveStartShardId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListShards' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListShards' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:shardFilter:ListShards' :: Maybe ShardFilter
shardFilter = forall a. Maybe a
Prelude.Nothing,
      $sel:streamARN:ListShards' :: Maybe Text
streamARN = forall a. Maybe a
Prelude.Nothing,
      $sel:streamCreationTimestamp:ListShards' :: Maybe POSIX
streamCreationTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:ListShards' :: Maybe Text
streamName = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' ListShards (Maybe Text)
listShards_exclusiveStartShardId = 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)

-- | The maximum number of shards to return in a single call to @ListShards@.
-- The maximum number of shards to return in a single call. The default
-- value is 1000. If you specify a value greater than 1000, at most 1000
-- results are returned.
--
-- 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 :: Lens' ListShards (Maybe Natural)
listShards_maxResults = 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)

-- | 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 :: Lens' ListShards (Maybe Text)
listShards_nextToken = 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)

-- | Enables you to filter out the response of the @ListShards@ API. You can
-- only specify one filter at a time.
--
-- If you use the @ShardFilter@ parameter when invoking the ListShards API,
-- the @Type@ is the required property and must be specified. If you
-- specify the @AT_TRIM_HORIZON@, @FROM_TRIM_HORIZON@, or @AT_LATEST@
-- types, you do not need to specify either the @ShardId@ or the
-- @Timestamp@ optional properties.
--
-- If you specify the @AFTER_SHARD_ID@ type, you must also provide the
-- value for the optional @ShardId@ property. The @ShardId@ property is
-- identical in fuctionality to the @ExclusiveStartShardId@ parameter of
-- the @ListShards@ API. When @ShardId@ property is specified, the response
-- includes the shards starting with the shard whose ID immediately follows
-- the @ShardId@ that you provided.
--
-- If you specify the @AT_TIMESTAMP@ or @FROM_TIMESTAMP_ID@ type, you must
-- also provide the value for the optional @Timestamp@ property. If you
-- specify the AT_TIMESTAMP type, then all shards that were open at the
-- provided timestamp are returned. If you specify the FROM_TIMESTAMP type,
-- then all shards starting from the provided timestamp to TIP are
-- returned.
listShards_shardFilter :: Lens.Lens' ListShards (Prelude.Maybe ShardFilter)
listShards_shardFilter :: Lens' ListShards (Maybe ShardFilter)
listShards_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)

-- | The ARN of the stream.
listShards_streamARN :: Lens.Lens' ListShards (Prelude.Maybe Prelude.Text)
listShards_streamARN :: Lens' ListShards (Maybe Text)
listShards_streamARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListShards' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:ListShards' :: ListShards -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: ListShards
s@ListShards' {} Maybe Text
a -> ListShards
s {$sel:streamARN:ListShards' :: Maybe Text
streamARN = 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 :: Lens' ListShards (Maybe UTCTime)
listShards_streamCreationTimestamp = 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) 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 (a :: Format). Iso' (Time a) UTCTime
Data._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 :: Lens' ListShards (Maybe Text)
listShards_streamName = 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)

instance Core.AWSPager ListShards where
  page :: ListShards -> AWSResponse ListShards -> Maybe ListShards
page ListShards
rq AWSResponse ListShards
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListShards
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListShardsResponse (Maybe Text)
listShardsResponse_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 ListShards
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListShardsResponse (Maybe [Shard])
listShardsResponse_shards
            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.$ ListShards
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListShards (Maybe Text)
listShards_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListShards
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListShardsResponse (Maybe Text)
listShardsResponse_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 ListShards where
  type AWSResponse ListShards = ListShardsResponse
  request :: (Service -> Service) -> ListShards -> Request ListShards
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListShards
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListShards)))
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 Text -> Maybe [Shard] -> Int -> ListShardsResponse
ListShardsResponse'
            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
"NextToken")
            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
"Shards" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListShards where
  hashWithSalt :: Int -> ListShards -> Int
hashWithSalt Int
_salt ListShards' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe ShardFilter
streamName :: Maybe Text
streamCreationTimestamp :: Maybe POSIX
streamARN :: Maybe Text
shardFilter :: Maybe ShardFilter
nextToken :: Maybe Text
maxResults :: Maybe Natural
exclusiveStartShardId :: Maybe Text
$sel:streamName:ListShards' :: ListShards -> Maybe Text
$sel:streamCreationTimestamp:ListShards' :: ListShards -> Maybe POSIX
$sel:streamARN:ListShards' :: ListShards -> Maybe Text
$sel:shardFilter:ListShards' :: ListShards -> Maybe ShardFilter
$sel:nextToken:ListShards' :: ListShards -> Maybe Text
$sel:maxResults:ListShards' :: ListShards -> Maybe Natural
$sel:exclusiveStartShardId:ListShards' :: ListShards -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
exclusiveStartShardId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ShardFilter
shardFilter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
streamCreationTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamName

instance Prelude.NFData ListShards where
  rnf :: ListShards -> ()
rnf ListShards' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe ShardFilter
streamName :: Maybe Text
streamCreationTimestamp :: Maybe POSIX
streamARN :: Maybe Text
shardFilter :: Maybe ShardFilter
nextToken :: Maybe Text
maxResults :: Maybe Natural
exclusiveStartShardId :: Maybe Text
$sel:streamName:ListShards' :: ListShards -> Maybe Text
$sel:streamCreationTimestamp:ListShards' :: ListShards -> Maybe POSIX
$sel:streamARN:ListShards' :: ListShards -> Maybe Text
$sel:shardFilter:ListShards' :: ListShards -> Maybe ShardFilter
$sel:nextToken:ListShards' :: ListShards -> Maybe Text
$sel:maxResults:ListShards' :: ListShards -> Maybe Natural
$sel:exclusiveStartShardId:ListShards' :: ListShards -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
exclusiveStartShardId
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ShardFilter
shardFilter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
streamARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
streamCreationTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
streamName

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

instance Data.ToJSON ListShards where
  toJSON :: ListShards -> Value
toJSON ListShards' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe ShardFilter
streamName :: Maybe Text
streamCreationTimestamp :: Maybe POSIX
streamARN :: Maybe Text
shardFilter :: Maybe ShardFilter
nextToken :: Maybe Text
maxResults :: Maybe Natural
exclusiveStartShardId :: Maybe Text
$sel:streamName:ListShards' :: ListShards -> Maybe Text
$sel:streamCreationTimestamp:ListShards' :: ListShards -> Maybe POSIX
$sel:streamARN:ListShards' :: ListShards -> Maybe Text
$sel:shardFilter:ListShards' :: ListShards -> Maybe ShardFilter
$sel:nextToken:ListShards' :: ListShards -> Maybe Text
$sel:maxResults:ListShards' :: ListShards -> Maybe Natural
$sel:exclusiveStartShardId:ListShards' :: ListShards -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ExclusiveStartShardId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
exclusiveStartShardId,
            (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Key
"ShardFilter" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ShardFilter
shardFilter,
            (Key
"StreamARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamARN,
            (Key
"StreamCreationTimestamp" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
streamCreationTimestamp,
            (Key
"StreamName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamName
          ]
      )

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

instance Data.ToQuery ListShards where
  toQuery :: ListShards -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:nextToken:ListShardsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:shards:ListShardsResponse' :: Maybe [Shard]
shards = 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 :: Lens' ListShardsResponse (Maybe Text)
listShardsResponse_nextToken = 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 :: Lens' ListShardsResponse (Maybe [Shard])
listShardsResponse_shards = 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) 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 response's http status code.
listShardsResponse_httpStatus :: Lens.Lens' ListShardsResponse Prelude.Int
listShardsResponse_httpStatus :: Lens' ListShardsResponse Int
listShardsResponse_httpStatus = 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 where
  rnf :: ListShardsResponse -> ()
rnf ListShardsResponse' {Int
Maybe [Shard]
Maybe Text
httpStatus :: Int
shards :: Maybe [Shard]
nextToken :: Maybe Text
$sel:httpStatus:ListShardsResponse' :: ListShardsResponse -> Int
$sel:shards:ListShardsResponse' :: ListShardsResponse -> Maybe [Shard]
$sel:nextToken:ListShardsResponse' :: ListShardsResponse -> Maybe Text
..} =
    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 Maybe [Shard]
shards
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus