{-# 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.GetShardIterator
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets an Amazon Kinesis shard iterator. A shard iterator expires 5
-- minutes after it is returned to the requester.
--
-- When invoking this API, it is recommended you use the @StreamARN@ input
-- parameter rather than the @StreamName@ input parameter.
--
-- A shard iterator specifies the shard position from which to start
-- reading data records sequentially. The position is specified using the
-- sequence number of a data record in a shard. A sequence number is the
-- identifier associated with every record ingested in the stream, and is
-- assigned when a record is put into the stream. Each stream has one or
-- more shards.
--
-- You must specify the shard iterator type. For example, you can set the
-- @ShardIteratorType@ parameter to read exactly from the position denoted
-- by a specific sequence number by using the @AT_SEQUENCE_NUMBER@ shard
-- iterator type. Alternatively, the parameter can read right after the
-- sequence number by using the @AFTER_SEQUENCE_NUMBER@ shard iterator
-- type, using sequence numbers returned by earlier calls to PutRecord,
-- PutRecords, GetRecords, or DescribeStream. In the request, you can
-- specify the shard iterator type @AT_TIMESTAMP@ to read records from an
-- arbitrary point in time, @TRIM_HORIZON@ to cause @ShardIterator@ to
-- point to the last untrimmed record in the shard in the system (the
-- oldest data record in the shard), or @LATEST@ so that you always read
-- the most recent data in the shard.
--
-- When you read repeatedly from a stream, use a GetShardIterator request
-- to get the first shard iterator for use in your first GetRecords request
-- and for subsequent reads use the shard iterator returned by the
-- GetRecords request in @NextShardIterator@. A new shard iterator is
-- returned by every GetRecords request in @NextShardIterator@, which you
-- use in the @ShardIterator@ parameter of the next GetRecords request.
--
-- If a GetShardIterator request is made too often, you receive a
-- @ProvisionedThroughputExceededException@. For more information about
-- throughput limits, see GetRecords, and
-- <https://docs.aws.amazon.com/kinesis/latest/dev/service-sizes-and-limits.html Streams Limits>
-- in the /Amazon Kinesis Data Streams Developer Guide/.
--
-- If the shard is closed, GetShardIterator returns a valid iterator for
-- the last sequence number of the shard. A shard can be closed as a result
-- of using SplitShard or MergeShards.
--
-- GetShardIterator has a limit of five transactions per second per account
-- per open shard.
module Amazonka.Kinesis.GetShardIterator
  ( -- * Creating a Request
    GetShardIterator (..),
    newGetShardIterator,

    -- * Request Lenses
    getShardIterator_startingSequenceNumber,
    getShardIterator_streamARN,
    getShardIterator_streamName,
    getShardIterator_timestamp,
    getShardIterator_shardId,
    getShardIterator_shardIteratorType,

    -- * Destructuring the Response
    GetShardIteratorResponse (..),
    newGetShardIteratorResponse,

    -- * Response Lenses
    getShardIteratorResponse_shardIterator,
    getShardIteratorResponse_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

-- | Represents the input for @GetShardIterator@.
--
-- /See:/ 'newGetShardIterator' smart constructor.
data GetShardIterator = GetShardIterator'
  { -- | The sequence number of the data record in the shard from which to start
    -- reading. Used with shard iterator type AT_SEQUENCE_NUMBER and
    -- AFTER_SEQUENCE_NUMBER.
    GetShardIterator -> Maybe Text
startingSequenceNumber :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the stream.
    GetShardIterator -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon Kinesis data stream.
    GetShardIterator -> Maybe Text
streamName :: Prelude.Maybe Prelude.Text,
    -- | The time stamp of the data record from which to start reading. Used with
    -- shard iterator type AT_TIMESTAMP. A time stamp is the Unix epoch date
    -- with precision in milliseconds. For example,
    -- @2016-04-04T19:58:46.480-00:00@ or @1459799926.480@. If a record with
    -- this exact time stamp does not exist, the iterator returned is for the
    -- next (later) record. If the time stamp is older than the current trim
    -- horizon, the iterator returned is for the oldest untrimmed data record
    -- (TRIM_HORIZON).
    GetShardIterator -> Maybe POSIX
timestamp :: Prelude.Maybe Data.POSIX,
    -- | The shard ID of the Kinesis Data Streams shard to get the iterator for.
    GetShardIterator -> Text
shardId :: Prelude.Text,
    -- | Determines how the shard iterator is used to start reading data records
    -- from the shard.
    --
    -- The following are the valid Amazon Kinesis shard iterator types:
    --
    -- -   AT_SEQUENCE_NUMBER - Start reading from the position denoted by a
    --     specific sequence number, provided in the value
    --     @StartingSequenceNumber@.
    --
    -- -   AFTER_SEQUENCE_NUMBER - Start reading right after the position
    --     denoted by a specific sequence number, provided in the value
    --     @StartingSequenceNumber@.
    --
    -- -   AT_TIMESTAMP - Start reading from the position denoted by a specific
    --     time stamp, provided in the value @Timestamp@.
    --
    -- -   TRIM_HORIZON - Start reading at the last untrimmed record in the
    --     shard in the system, which is the oldest data record in the shard.
    --
    -- -   LATEST - Start reading just after the most recent record in the
    --     shard, so that you always read the most recent data in the shard.
    GetShardIterator -> ShardIteratorType
shardIteratorType :: ShardIteratorType
  }
  deriving (GetShardIterator -> GetShardIterator -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetShardIterator -> GetShardIterator -> Bool
$c/= :: GetShardIterator -> GetShardIterator -> Bool
== :: GetShardIterator -> GetShardIterator -> Bool
$c== :: GetShardIterator -> GetShardIterator -> Bool
Prelude.Eq, ReadPrec [GetShardIterator]
ReadPrec GetShardIterator
Int -> ReadS GetShardIterator
ReadS [GetShardIterator]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetShardIterator]
$creadListPrec :: ReadPrec [GetShardIterator]
readPrec :: ReadPrec GetShardIterator
$creadPrec :: ReadPrec GetShardIterator
readList :: ReadS [GetShardIterator]
$creadList :: ReadS [GetShardIterator]
readsPrec :: Int -> ReadS GetShardIterator
$creadsPrec :: Int -> ReadS GetShardIterator
Prelude.Read, Int -> GetShardIterator -> ShowS
[GetShardIterator] -> ShowS
GetShardIterator -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetShardIterator] -> ShowS
$cshowList :: [GetShardIterator] -> ShowS
show :: GetShardIterator -> String
$cshow :: GetShardIterator -> String
showsPrec :: Int -> GetShardIterator -> ShowS
$cshowsPrec :: Int -> GetShardIterator -> ShowS
Prelude.Show, forall x. Rep GetShardIterator x -> GetShardIterator
forall x. GetShardIterator -> Rep GetShardIterator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetShardIterator x -> GetShardIterator
$cfrom :: forall x. GetShardIterator -> Rep GetShardIterator x
Prelude.Generic)

-- |
-- Create a value of 'GetShardIterator' 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:
--
-- 'startingSequenceNumber', 'getShardIterator_startingSequenceNumber' - The sequence number of the data record in the shard from which to start
-- reading. Used with shard iterator type AT_SEQUENCE_NUMBER and
-- AFTER_SEQUENCE_NUMBER.
--
-- 'streamARN', 'getShardIterator_streamARN' - The ARN of the stream.
--
-- 'streamName', 'getShardIterator_streamName' - The name of the Amazon Kinesis data stream.
--
-- 'timestamp', 'getShardIterator_timestamp' - The time stamp of the data record from which to start reading. Used with
-- shard iterator type AT_TIMESTAMP. A time stamp is the Unix epoch date
-- with precision in milliseconds. For example,
-- @2016-04-04T19:58:46.480-00:00@ or @1459799926.480@. If a record with
-- this exact time stamp does not exist, the iterator returned is for the
-- next (later) record. If the time stamp is older than the current trim
-- horizon, the iterator returned is for the oldest untrimmed data record
-- (TRIM_HORIZON).
--
-- 'shardId', 'getShardIterator_shardId' - The shard ID of the Kinesis Data Streams shard to get the iterator for.
--
-- 'shardIteratorType', 'getShardIterator_shardIteratorType' - Determines how the shard iterator is used to start reading data records
-- from the shard.
--
-- The following are the valid Amazon Kinesis shard iterator types:
--
-- -   AT_SEQUENCE_NUMBER - Start reading from the position denoted by a
--     specific sequence number, provided in the value
--     @StartingSequenceNumber@.
--
-- -   AFTER_SEQUENCE_NUMBER - Start reading right after the position
--     denoted by a specific sequence number, provided in the value
--     @StartingSequenceNumber@.
--
-- -   AT_TIMESTAMP - Start reading from the position denoted by a specific
--     time stamp, provided in the value @Timestamp@.
--
-- -   TRIM_HORIZON - Start reading at the last untrimmed record in the
--     shard in the system, which is the oldest data record in the shard.
--
-- -   LATEST - Start reading just after the most recent record in the
--     shard, so that you always read the most recent data in the shard.
newGetShardIterator ::
  -- | 'shardId'
  Prelude.Text ->
  -- | 'shardIteratorType'
  ShardIteratorType ->
  GetShardIterator
newGetShardIterator :: Text -> ShardIteratorType -> GetShardIterator
newGetShardIterator Text
pShardId_ ShardIteratorType
pShardIteratorType_ =
  GetShardIterator'
    { $sel:startingSequenceNumber:GetShardIterator' :: Maybe Text
startingSequenceNumber =
        forall a. Maybe a
Prelude.Nothing,
      $sel:streamARN:GetShardIterator' :: Maybe Text
streamARN = forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:GetShardIterator' :: Maybe Text
streamName = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:GetShardIterator' :: Maybe POSIX
timestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:shardId:GetShardIterator' :: Text
shardId = Text
pShardId_,
      $sel:shardIteratorType:GetShardIterator' :: ShardIteratorType
shardIteratorType = ShardIteratorType
pShardIteratorType_
    }

-- | The sequence number of the data record in the shard from which to start
-- reading. Used with shard iterator type AT_SEQUENCE_NUMBER and
-- AFTER_SEQUENCE_NUMBER.
getShardIterator_startingSequenceNumber :: Lens.Lens' GetShardIterator (Prelude.Maybe Prelude.Text)
getShardIterator_startingSequenceNumber :: Lens' GetShardIterator (Maybe Text)
getShardIterator_startingSequenceNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetShardIterator' {Maybe Text
startingSequenceNumber :: Maybe Text
$sel:startingSequenceNumber:GetShardIterator' :: GetShardIterator -> Maybe Text
startingSequenceNumber} -> Maybe Text
startingSequenceNumber) (\s :: GetShardIterator
s@GetShardIterator' {} Maybe Text
a -> GetShardIterator
s {$sel:startingSequenceNumber:GetShardIterator' :: Maybe Text
startingSequenceNumber = Maybe Text
a} :: GetShardIterator)

-- | The ARN of the stream.
getShardIterator_streamARN :: Lens.Lens' GetShardIterator (Prelude.Maybe Prelude.Text)
getShardIterator_streamARN :: Lens' GetShardIterator (Maybe Text)
getShardIterator_streamARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetShardIterator' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:GetShardIterator' :: GetShardIterator -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: GetShardIterator
s@GetShardIterator' {} Maybe Text
a -> GetShardIterator
s {$sel:streamARN:GetShardIterator' :: Maybe Text
streamARN = Maybe Text
a} :: GetShardIterator)

-- | The name of the Amazon Kinesis data stream.
getShardIterator_streamName :: Lens.Lens' GetShardIterator (Prelude.Maybe Prelude.Text)
getShardIterator_streamName :: Lens' GetShardIterator (Maybe Text)
getShardIterator_streamName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetShardIterator' {Maybe Text
streamName :: Maybe Text
$sel:streamName:GetShardIterator' :: GetShardIterator -> Maybe Text
streamName} -> Maybe Text
streamName) (\s :: GetShardIterator
s@GetShardIterator' {} Maybe Text
a -> GetShardIterator
s {$sel:streamName:GetShardIterator' :: Maybe Text
streamName = Maybe Text
a} :: GetShardIterator)

-- | The time stamp of the data record from which to start reading. Used with
-- shard iterator type AT_TIMESTAMP. A time stamp is the Unix epoch date
-- with precision in milliseconds. For example,
-- @2016-04-04T19:58:46.480-00:00@ or @1459799926.480@. If a record with
-- this exact time stamp does not exist, the iterator returned is for the
-- next (later) record. If the time stamp is older than the current trim
-- horizon, the iterator returned is for the oldest untrimmed data record
-- (TRIM_HORIZON).
getShardIterator_timestamp :: Lens.Lens' GetShardIterator (Prelude.Maybe Prelude.UTCTime)
getShardIterator_timestamp :: Lens' GetShardIterator (Maybe UTCTime)
getShardIterator_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetShardIterator' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:GetShardIterator' :: GetShardIterator -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: GetShardIterator
s@GetShardIterator' {} Maybe POSIX
a -> GetShardIterator
s {$sel:timestamp:GetShardIterator' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: GetShardIterator) 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 shard ID of the Kinesis Data Streams shard to get the iterator for.
getShardIterator_shardId :: Lens.Lens' GetShardIterator Prelude.Text
getShardIterator_shardId :: Lens' GetShardIterator Text
getShardIterator_shardId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetShardIterator' {Text
shardId :: Text
$sel:shardId:GetShardIterator' :: GetShardIterator -> Text
shardId} -> Text
shardId) (\s :: GetShardIterator
s@GetShardIterator' {} Text
a -> GetShardIterator
s {$sel:shardId:GetShardIterator' :: Text
shardId = Text
a} :: GetShardIterator)

-- | Determines how the shard iterator is used to start reading data records
-- from the shard.
--
-- The following are the valid Amazon Kinesis shard iterator types:
--
-- -   AT_SEQUENCE_NUMBER - Start reading from the position denoted by a
--     specific sequence number, provided in the value
--     @StartingSequenceNumber@.
--
-- -   AFTER_SEQUENCE_NUMBER - Start reading right after the position
--     denoted by a specific sequence number, provided in the value
--     @StartingSequenceNumber@.
--
-- -   AT_TIMESTAMP - Start reading from the position denoted by a specific
--     time stamp, provided in the value @Timestamp@.
--
-- -   TRIM_HORIZON - Start reading at the last untrimmed record in the
--     shard in the system, which is the oldest data record in the shard.
--
-- -   LATEST - Start reading just after the most recent record in the
--     shard, so that you always read the most recent data in the shard.
getShardIterator_shardIteratorType :: Lens.Lens' GetShardIterator ShardIteratorType
getShardIterator_shardIteratorType :: Lens' GetShardIterator ShardIteratorType
getShardIterator_shardIteratorType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetShardIterator' {ShardIteratorType
shardIteratorType :: ShardIteratorType
$sel:shardIteratorType:GetShardIterator' :: GetShardIterator -> ShardIteratorType
shardIteratorType} -> ShardIteratorType
shardIteratorType) (\s :: GetShardIterator
s@GetShardIterator' {} ShardIteratorType
a -> GetShardIterator
s {$sel:shardIteratorType:GetShardIterator' :: ShardIteratorType
shardIteratorType = ShardIteratorType
a} :: GetShardIterator)

instance Core.AWSRequest GetShardIterator where
  type
    AWSResponse GetShardIterator =
      GetShardIteratorResponse
  request :: (Service -> Service)
-> GetShardIterator -> Request GetShardIterator
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 GetShardIterator
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetShardIterator)))
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 -> Int -> GetShardIteratorResponse
GetShardIteratorResponse'
            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
"ShardIterator")
            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 GetShardIterator where
  hashWithSalt :: Int -> GetShardIterator -> Int
hashWithSalt Int
_salt GetShardIterator' {Maybe Text
Maybe POSIX
Text
ShardIteratorType
shardIteratorType :: ShardIteratorType
shardId :: Text
timestamp :: Maybe POSIX
streamName :: Maybe Text
streamARN :: Maybe Text
startingSequenceNumber :: Maybe Text
$sel:shardIteratorType:GetShardIterator' :: GetShardIterator -> ShardIteratorType
$sel:shardId:GetShardIterator' :: GetShardIterator -> Text
$sel:timestamp:GetShardIterator' :: GetShardIterator -> Maybe POSIX
$sel:streamName:GetShardIterator' :: GetShardIterator -> Maybe Text
$sel:streamARN:GetShardIterator' :: GetShardIterator -> Maybe Text
$sel:startingSequenceNumber:GetShardIterator' :: GetShardIterator -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
startingSequenceNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
timestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
shardId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ShardIteratorType
shardIteratorType

instance Prelude.NFData GetShardIterator where
  rnf :: GetShardIterator -> ()
rnf GetShardIterator' {Maybe Text
Maybe POSIX
Text
ShardIteratorType
shardIteratorType :: ShardIteratorType
shardId :: Text
timestamp :: Maybe POSIX
streamName :: Maybe Text
streamARN :: Maybe Text
startingSequenceNumber :: Maybe Text
$sel:shardIteratorType:GetShardIterator' :: GetShardIterator -> ShardIteratorType
$sel:shardId:GetShardIterator' :: GetShardIterator -> Text
$sel:timestamp:GetShardIterator' :: GetShardIterator -> Maybe POSIX
$sel:streamName:GetShardIterator' :: GetShardIterator -> Maybe Text
$sel:streamARN:GetShardIterator' :: GetShardIterator -> Maybe Text
$sel:startingSequenceNumber:GetShardIterator' :: GetShardIterator -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
startingSequenceNumber
      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 Text
streamName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
timestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
shardId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ShardIteratorType
shardIteratorType

instance Data.ToHeaders GetShardIterator where
  toHeaders :: GetShardIterator -> 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.GetShardIterator" ::
                          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 GetShardIterator where
  toJSON :: GetShardIterator -> Value
toJSON GetShardIterator' {Maybe Text
Maybe POSIX
Text
ShardIteratorType
shardIteratorType :: ShardIteratorType
shardId :: Text
timestamp :: Maybe POSIX
streamName :: Maybe Text
streamARN :: Maybe Text
startingSequenceNumber :: Maybe Text
$sel:shardIteratorType:GetShardIterator' :: GetShardIterator -> ShardIteratorType
$sel:shardId:GetShardIterator' :: GetShardIterator -> Text
$sel:timestamp:GetShardIterator' :: GetShardIterator -> Maybe POSIX
$sel:streamName:GetShardIterator' :: GetShardIterator -> Maybe Text
$sel:streamARN:GetShardIterator' :: GetShardIterator -> Maybe Text
$sel:startingSequenceNumber:GetShardIterator' :: GetShardIterator -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"StartingSequenceNumber" 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
startingSequenceNumber,
            (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
"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,
            (Key
"Timestamp" 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
timestamp,
            forall a. a -> Maybe a
Prelude.Just (Key
"ShardId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
shardId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ShardIteratorType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ShardIteratorType
shardIteratorType)
          ]
      )

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

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

-- | Represents the output for @GetShardIterator@.
--
-- /See:/ 'newGetShardIteratorResponse' smart constructor.
data GetShardIteratorResponse = GetShardIteratorResponse'
  { -- | The position in the shard from which to start reading data records
    -- sequentially. A shard iterator specifies this position using the
    -- sequence number of a data record in a shard.
    GetShardIteratorResponse -> Maybe Text
shardIterator :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetShardIteratorResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetShardIteratorResponse -> GetShardIteratorResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetShardIteratorResponse -> GetShardIteratorResponse -> Bool
$c/= :: GetShardIteratorResponse -> GetShardIteratorResponse -> Bool
== :: GetShardIteratorResponse -> GetShardIteratorResponse -> Bool
$c== :: GetShardIteratorResponse -> GetShardIteratorResponse -> Bool
Prelude.Eq, ReadPrec [GetShardIteratorResponse]
ReadPrec GetShardIteratorResponse
Int -> ReadS GetShardIteratorResponse
ReadS [GetShardIteratorResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetShardIteratorResponse]
$creadListPrec :: ReadPrec [GetShardIteratorResponse]
readPrec :: ReadPrec GetShardIteratorResponse
$creadPrec :: ReadPrec GetShardIteratorResponse
readList :: ReadS [GetShardIteratorResponse]
$creadList :: ReadS [GetShardIteratorResponse]
readsPrec :: Int -> ReadS GetShardIteratorResponse
$creadsPrec :: Int -> ReadS GetShardIteratorResponse
Prelude.Read, Int -> GetShardIteratorResponse -> ShowS
[GetShardIteratorResponse] -> ShowS
GetShardIteratorResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetShardIteratorResponse] -> ShowS
$cshowList :: [GetShardIteratorResponse] -> ShowS
show :: GetShardIteratorResponse -> String
$cshow :: GetShardIteratorResponse -> String
showsPrec :: Int -> GetShardIteratorResponse -> ShowS
$cshowsPrec :: Int -> GetShardIteratorResponse -> ShowS
Prelude.Show, forall x.
Rep GetShardIteratorResponse x -> GetShardIteratorResponse
forall x.
GetShardIteratorResponse -> Rep GetShardIteratorResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetShardIteratorResponse x -> GetShardIteratorResponse
$cfrom :: forall x.
GetShardIteratorResponse -> Rep GetShardIteratorResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetShardIteratorResponse' 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:
--
-- 'shardIterator', 'getShardIteratorResponse_shardIterator' - The position in the shard from which to start reading data records
-- sequentially. A shard iterator specifies this position using the
-- sequence number of a data record in a shard.
--
-- 'httpStatus', 'getShardIteratorResponse_httpStatus' - The response's http status code.
newGetShardIteratorResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetShardIteratorResponse
newGetShardIteratorResponse :: Int -> GetShardIteratorResponse
newGetShardIteratorResponse Int
pHttpStatus_ =
  GetShardIteratorResponse'
    { $sel:shardIterator:GetShardIteratorResponse' :: Maybe Text
shardIterator =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetShardIteratorResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The position in the shard from which to start reading data records
-- sequentially. A shard iterator specifies this position using the
-- sequence number of a data record in a shard.
getShardIteratorResponse_shardIterator :: Lens.Lens' GetShardIteratorResponse (Prelude.Maybe Prelude.Text)
getShardIteratorResponse_shardIterator :: Lens' GetShardIteratorResponse (Maybe Text)
getShardIteratorResponse_shardIterator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetShardIteratorResponse' {Maybe Text
shardIterator :: Maybe Text
$sel:shardIterator:GetShardIteratorResponse' :: GetShardIteratorResponse -> Maybe Text
shardIterator} -> Maybe Text
shardIterator) (\s :: GetShardIteratorResponse
s@GetShardIteratorResponse' {} Maybe Text
a -> GetShardIteratorResponse
s {$sel:shardIterator:GetShardIteratorResponse' :: Maybe Text
shardIterator = Maybe Text
a} :: GetShardIteratorResponse)

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

instance Prelude.NFData GetShardIteratorResponse where
  rnf :: GetShardIteratorResponse -> ()
rnf GetShardIteratorResponse' {Int
Maybe Text
httpStatus :: Int
shardIterator :: Maybe Text
$sel:httpStatus:GetShardIteratorResponse' :: GetShardIteratorResponse -> Int
$sel:shardIterator:GetShardIteratorResponse' :: GetShardIteratorResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
shardIterator
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus