{-# 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.GetRecords
-- 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)
--
-- Gets data records from a Kinesis data stream\'s shard.
--
-- Specify a shard iterator using the @ShardIterator@ parameter. The shard
-- iterator specifies the position in the shard from which you want to
-- start reading data records sequentially. If there are no records
-- available in the portion of the shard that the iterator points to,
-- GetRecords returns an empty list. It might take multiple calls to get to
-- a portion of the shard that contains records.
--
-- You can scale by provisioning multiple shards per stream while
-- considering service limits (for more information, see
-- <https://docs.aws.amazon.com/kinesis/latest/dev/service-sizes-and-limits.html Amazon Kinesis Data Streams Limits>
-- in the /Amazon Kinesis Data Streams Developer Guide/). Your application
-- should have one thread per shard, each reading continuously from its
-- stream. To read from a stream continually, call GetRecords in a loop.
-- Use GetShardIterator to get the shard iterator to specify in the first
-- GetRecords call. GetRecords returns a new shard iterator in
-- @NextShardIterator@. Specify the shard iterator returned in
-- @NextShardIterator@ in subsequent calls to GetRecords. If the shard has
-- been closed, the shard iterator can\'t return more data and GetRecords
-- returns @null@ in @NextShardIterator@. You can terminate the loop when
-- the shard is closed, or when the shard iterator reaches the record with
-- the sequence number or other attribute that marks it as the last record
-- to process.
--
-- Each data record can be up to 1 MiB in size, and each shard can read up
-- to 2 MiB per second. You can ensure that your calls don\'t exceed the
-- maximum supported size or throughput by using the @Limit@ parameter to
-- specify the maximum number of records that GetRecords can return.
-- Consider your average record size when determining this limit. The
-- maximum number of records that can be returned per call is 10,000.
--
-- The size of the data returned by GetRecords varies depending on the
-- utilization of the shard. The maximum size of data that GetRecords can
-- return is 10 MiB. If a call returns this amount of data, subsequent
-- calls made within the next 5 seconds throw
-- @ProvisionedThroughputExceededException@. If there is insufficient
-- provisioned throughput on the stream, subsequent calls made within the
-- next 1 second throw @ProvisionedThroughputExceededException@. GetRecords
-- doesn\'t return any data when it throws an exception. For this reason,
-- we recommend that you wait 1 second between calls to GetRecords.
-- However, it\'s possible that the application will get exceptions for
-- longer than 1 second.
--
-- To detect whether the application is falling behind in processing, you
-- can use the @MillisBehindLatest@ response attribute. You can also
-- monitor the stream using CloudWatch metrics and other mechanisms (see
-- <https://docs.aws.amazon.com/kinesis/latest/dev/monitoring.html Monitoring>
-- in the /Amazon Kinesis Data Streams Developer Guide/).
--
-- Each Amazon Kinesis record includes a value,
-- @ApproximateArrivalTimestamp@, that is set when a stream successfully
-- receives and stores a record. This is commonly referred to as a
-- server-side time stamp, whereas a client-side time stamp is set when a
-- data producer creates or sends the record to a stream (a data producer
-- is any data source putting data records into a stream, for example with
-- PutRecords). The time stamp has millisecond precision. There are no
-- guarantees about the time stamp accuracy, or that the time stamp is
-- always increasing. For example, records in a shard or across a stream
-- might have time stamps that are out of order.
--
-- This operation has a limit of five transactions per second per shard.
module Amazonka.Kinesis.GetRecords
  ( -- * Creating a Request
    GetRecords (..),
    newGetRecords,

    -- * Request Lenses
    getRecords_limit,
    getRecords_shardIterator,

    -- * Destructuring the Response
    GetRecordsResponse (..),
    newGetRecordsResponse,

    -- * Response Lenses
    getRecordsResponse_nextShardIterator,
    getRecordsResponse_millisBehindLatest,
    getRecordsResponse_childShards,
    getRecordsResponse_httpStatus,
    getRecordsResponse_records,
  )
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

-- | Represents the input for GetRecords.
--
-- /See:/ 'newGetRecords' smart constructor.
data GetRecords = GetRecords'
  { -- | The maximum number of records to return. Specify a value of up to
    -- 10,000. If you specify a value that is greater than 10,000, GetRecords
    -- throws @InvalidArgumentException@. The default value is 10,000.
    GetRecords -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | The position in the shard from which you want to start sequentially
    -- reading data records. A shard iterator specifies this position using the
    -- sequence number of a data record in the shard.
    GetRecords -> Text
shardIterator :: Prelude.Text
  }
  deriving (GetRecords -> GetRecords -> Bool
(GetRecords -> GetRecords -> Bool)
-> (GetRecords -> GetRecords -> Bool) -> Eq GetRecords
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRecords -> GetRecords -> Bool
$c/= :: GetRecords -> GetRecords -> Bool
== :: GetRecords -> GetRecords -> Bool
$c== :: GetRecords -> GetRecords -> Bool
Prelude.Eq, ReadPrec [GetRecords]
ReadPrec GetRecords
Int -> ReadS GetRecords
ReadS [GetRecords]
(Int -> ReadS GetRecords)
-> ReadS [GetRecords]
-> ReadPrec GetRecords
-> ReadPrec [GetRecords]
-> Read GetRecords
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRecords]
$creadListPrec :: ReadPrec [GetRecords]
readPrec :: ReadPrec GetRecords
$creadPrec :: ReadPrec GetRecords
readList :: ReadS [GetRecords]
$creadList :: ReadS [GetRecords]
readsPrec :: Int -> ReadS GetRecords
$creadsPrec :: Int -> ReadS GetRecords
Prelude.Read, Int -> GetRecords -> ShowS
[GetRecords] -> ShowS
GetRecords -> String
(Int -> GetRecords -> ShowS)
-> (GetRecords -> String)
-> ([GetRecords] -> ShowS)
-> Show GetRecords
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRecords] -> ShowS
$cshowList :: [GetRecords] -> ShowS
show :: GetRecords -> String
$cshow :: GetRecords -> String
showsPrec :: Int -> GetRecords -> ShowS
$cshowsPrec :: Int -> GetRecords -> ShowS
Prelude.Show, (forall x. GetRecords -> Rep GetRecords x)
-> (forall x. Rep GetRecords x -> GetRecords) -> Generic GetRecords
forall x. Rep GetRecords x -> GetRecords
forall x. GetRecords -> Rep GetRecords x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRecords x -> GetRecords
$cfrom :: forall x. GetRecords -> Rep GetRecords x
Prelude.Generic)

-- |
-- Create a value of 'GetRecords' 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:
--
-- 'limit', 'getRecords_limit' - The maximum number of records to return. Specify a value of up to
-- 10,000. If you specify a value that is greater than 10,000, GetRecords
-- throws @InvalidArgumentException@. The default value is 10,000.
--
-- 'shardIterator', 'getRecords_shardIterator' - The position in the shard from which you want to start sequentially
-- reading data records. A shard iterator specifies this position using the
-- sequence number of a data record in the shard.
newGetRecords ::
  -- | 'shardIterator'
  Prelude.Text ->
  GetRecords
newGetRecords :: Text -> GetRecords
newGetRecords Text
pShardIterator_ =
  GetRecords' :: Maybe Natural -> Text -> GetRecords
GetRecords'
    { $sel:limit:GetRecords' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:shardIterator:GetRecords' :: Text
shardIterator = Text
pShardIterator_
    }

-- | The maximum number of records to return. Specify a value of up to
-- 10,000. If you specify a value that is greater than 10,000, GetRecords
-- throws @InvalidArgumentException@. The default value is 10,000.
getRecords_limit :: Lens.Lens' GetRecords (Prelude.Maybe Prelude.Natural)
getRecords_limit :: (Maybe Natural -> f (Maybe Natural)) -> GetRecords -> f GetRecords
getRecords_limit = (GetRecords -> Maybe Natural)
-> (GetRecords -> Maybe Natural -> GetRecords)
-> Lens GetRecords GetRecords (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecords' {Maybe Natural
limit :: Maybe Natural
$sel:limit:GetRecords' :: GetRecords -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: GetRecords
s@GetRecords' {} Maybe Natural
a -> GetRecords
s {$sel:limit:GetRecords' :: Maybe Natural
limit = Maybe Natural
a} :: GetRecords)

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

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

instance Prelude.Hashable GetRecords

instance Prelude.NFData GetRecords

instance Core.ToHeaders GetRecords where
  toHeaders :: GetRecords -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetRecords -> 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.GetRecords" ::
                          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 GetRecords where
  toJSON :: GetRecords -> Value
toJSON GetRecords' {Maybe Natural
Text
shardIterator :: Text
limit :: Maybe Natural
$sel:shardIterator:GetRecords' :: GetRecords -> Text
$sel:limit:GetRecords' :: GetRecords -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Limit" 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
limit,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ShardIterator" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
shardIterator)
          ]
      )

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

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

-- | Represents the output for GetRecords.
--
-- /See:/ 'newGetRecordsResponse' smart constructor.
data GetRecordsResponse = GetRecordsResponse'
  { -- | The next position in the shard from which to start sequentially reading
    -- data records. If set to @null@, the shard has been closed and the
    -- requested iterator does not return any more data.
    GetRecordsResponse -> Maybe Text
nextShardIterator :: Prelude.Maybe Prelude.Text,
    -- | The number of milliseconds the GetRecords response is from the tip of
    -- the stream, indicating how far behind current time the consumer is. A
    -- value of zero indicates that record processing is caught up, and there
    -- are no new records to process at this moment.
    GetRecordsResponse -> Maybe Natural
millisBehindLatest :: Prelude.Maybe Prelude.Natural,
    GetRecordsResponse -> Maybe [ChildShard]
childShards :: Prelude.Maybe [ChildShard],
    -- | The response's http status code.
    GetRecordsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The data records retrieved from the shard.
    GetRecordsResponse -> [Record]
records :: [Record]
  }
  deriving (GetRecordsResponse -> GetRecordsResponse -> Bool
(GetRecordsResponse -> GetRecordsResponse -> Bool)
-> (GetRecordsResponse -> GetRecordsResponse -> Bool)
-> Eq GetRecordsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRecordsResponse -> GetRecordsResponse -> Bool
$c/= :: GetRecordsResponse -> GetRecordsResponse -> Bool
== :: GetRecordsResponse -> GetRecordsResponse -> Bool
$c== :: GetRecordsResponse -> GetRecordsResponse -> Bool
Prelude.Eq, ReadPrec [GetRecordsResponse]
ReadPrec GetRecordsResponse
Int -> ReadS GetRecordsResponse
ReadS [GetRecordsResponse]
(Int -> ReadS GetRecordsResponse)
-> ReadS [GetRecordsResponse]
-> ReadPrec GetRecordsResponse
-> ReadPrec [GetRecordsResponse]
-> Read GetRecordsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRecordsResponse]
$creadListPrec :: ReadPrec [GetRecordsResponse]
readPrec :: ReadPrec GetRecordsResponse
$creadPrec :: ReadPrec GetRecordsResponse
readList :: ReadS [GetRecordsResponse]
$creadList :: ReadS [GetRecordsResponse]
readsPrec :: Int -> ReadS GetRecordsResponse
$creadsPrec :: Int -> ReadS GetRecordsResponse
Prelude.Read, Int -> GetRecordsResponse -> ShowS
[GetRecordsResponse] -> ShowS
GetRecordsResponse -> String
(Int -> GetRecordsResponse -> ShowS)
-> (GetRecordsResponse -> String)
-> ([GetRecordsResponse] -> ShowS)
-> Show GetRecordsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRecordsResponse] -> ShowS
$cshowList :: [GetRecordsResponse] -> ShowS
show :: GetRecordsResponse -> String
$cshow :: GetRecordsResponse -> String
showsPrec :: Int -> GetRecordsResponse -> ShowS
$cshowsPrec :: Int -> GetRecordsResponse -> ShowS
Prelude.Show, (forall x. GetRecordsResponse -> Rep GetRecordsResponse x)
-> (forall x. Rep GetRecordsResponse x -> GetRecordsResponse)
-> Generic GetRecordsResponse
forall x. Rep GetRecordsResponse x -> GetRecordsResponse
forall x. GetRecordsResponse -> Rep GetRecordsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRecordsResponse x -> GetRecordsResponse
$cfrom :: forall x. GetRecordsResponse -> Rep GetRecordsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetRecordsResponse' 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:
--
-- 'nextShardIterator', 'getRecordsResponse_nextShardIterator' - The next position in the shard from which to start sequentially reading
-- data records. If set to @null@, the shard has been closed and the
-- requested iterator does not return any more data.
--
-- 'millisBehindLatest', 'getRecordsResponse_millisBehindLatest' - The number of milliseconds the GetRecords response is from the tip of
-- the stream, indicating how far behind current time the consumer is. A
-- value of zero indicates that record processing is caught up, and there
-- are no new records to process at this moment.
--
-- 'childShards', 'getRecordsResponse_childShards' - Undocumented member.
--
-- 'httpStatus', 'getRecordsResponse_httpStatus' - The response's http status code.
--
-- 'records', 'getRecordsResponse_records' - The data records retrieved from the shard.
newGetRecordsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRecordsResponse
newGetRecordsResponse :: Int -> GetRecordsResponse
newGetRecordsResponse Int
pHttpStatus_ =
  GetRecordsResponse' :: Maybe Text
-> Maybe Natural
-> Maybe [ChildShard]
-> Int
-> [Record]
-> GetRecordsResponse
GetRecordsResponse'
    { $sel:nextShardIterator:GetRecordsResponse' :: Maybe Text
nextShardIterator =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:millisBehindLatest:GetRecordsResponse' :: Maybe Natural
millisBehindLatest = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:childShards:GetRecordsResponse' :: Maybe [ChildShard]
childShards = Maybe [ChildShard]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRecordsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:records:GetRecordsResponse' :: [Record]
records = [Record]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The next position in the shard from which to start sequentially reading
-- data records. If set to @null@, the shard has been closed and the
-- requested iterator does not return any more data.
getRecordsResponse_nextShardIterator :: Lens.Lens' GetRecordsResponse (Prelude.Maybe Prelude.Text)
getRecordsResponse_nextShardIterator :: (Maybe Text -> f (Maybe Text))
-> GetRecordsResponse -> f GetRecordsResponse
getRecordsResponse_nextShardIterator = (GetRecordsResponse -> Maybe Text)
-> (GetRecordsResponse -> Maybe Text -> GetRecordsResponse)
-> Lens
     GetRecordsResponse GetRecordsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecordsResponse' {Maybe Text
nextShardIterator :: Maybe Text
$sel:nextShardIterator:GetRecordsResponse' :: GetRecordsResponse -> Maybe Text
nextShardIterator} -> Maybe Text
nextShardIterator) (\s :: GetRecordsResponse
s@GetRecordsResponse' {} Maybe Text
a -> GetRecordsResponse
s {$sel:nextShardIterator:GetRecordsResponse' :: Maybe Text
nextShardIterator = Maybe Text
a} :: GetRecordsResponse)

-- | The number of milliseconds the GetRecords response is from the tip of
-- the stream, indicating how far behind current time the consumer is. A
-- value of zero indicates that record processing is caught up, and there
-- are no new records to process at this moment.
getRecordsResponse_millisBehindLatest :: Lens.Lens' GetRecordsResponse (Prelude.Maybe Prelude.Natural)
getRecordsResponse_millisBehindLatest :: (Maybe Natural -> f (Maybe Natural))
-> GetRecordsResponse -> f GetRecordsResponse
getRecordsResponse_millisBehindLatest = (GetRecordsResponse -> Maybe Natural)
-> (GetRecordsResponse -> Maybe Natural -> GetRecordsResponse)
-> Lens
     GetRecordsResponse
     GetRecordsResponse
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecordsResponse' {Maybe Natural
millisBehindLatest :: Maybe Natural
$sel:millisBehindLatest:GetRecordsResponse' :: GetRecordsResponse -> Maybe Natural
millisBehindLatest} -> Maybe Natural
millisBehindLatest) (\s :: GetRecordsResponse
s@GetRecordsResponse' {} Maybe Natural
a -> GetRecordsResponse
s {$sel:millisBehindLatest:GetRecordsResponse' :: Maybe Natural
millisBehindLatest = Maybe Natural
a} :: GetRecordsResponse)

-- | Undocumented member.
getRecordsResponse_childShards :: Lens.Lens' GetRecordsResponse (Prelude.Maybe [ChildShard])
getRecordsResponse_childShards :: (Maybe [ChildShard] -> f (Maybe [ChildShard]))
-> GetRecordsResponse -> f GetRecordsResponse
getRecordsResponse_childShards = (GetRecordsResponse -> Maybe [ChildShard])
-> (GetRecordsResponse -> Maybe [ChildShard] -> GetRecordsResponse)
-> Lens
     GetRecordsResponse
     GetRecordsResponse
     (Maybe [ChildShard])
     (Maybe [ChildShard])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecordsResponse' {Maybe [ChildShard]
childShards :: Maybe [ChildShard]
$sel:childShards:GetRecordsResponse' :: GetRecordsResponse -> Maybe [ChildShard]
childShards} -> Maybe [ChildShard]
childShards) (\s :: GetRecordsResponse
s@GetRecordsResponse' {} Maybe [ChildShard]
a -> GetRecordsResponse
s {$sel:childShards:GetRecordsResponse' :: Maybe [ChildShard]
childShards = Maybe [ChildShard]
a} :: GetRecordsResponse) ((Maybe [ChildShard] -> f (Maybe [ChildShard]))
 -> GetRecordsResponse -> f GetRecordsResponse)
-> ((Maybe [ChildShard] -> f (Maybe [ChildShard]))
    -> Maybe [ChildShard] -> f (Maybe [ChildShard]))
-> (Maybe [ChildShard] -> f (Maybe [ChildShard]))
-> GetRecordsResponse
-> f GetRecordsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ChildShard] [ChildShard] [ChildShard] [ChildShard]
-> Iso
     (Maybe [ChildShard])
     (Maybe [ChildShard])
     (Maybe [ChildShard])
     (Maybe [ChildShard])
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 [ChildShard] [ChildShard] [ChildShard] [ChildShard]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | The data records retrieved from the shard.
getRecordsResponse_records :: Lens.Lens' GetRecordsResponse [Record]
getRecordsResponse_records :: ([Record] -> f [Record])
-> GetRecordsResponse -> f GetRecordsResponse
getRecordsResponse_records = (GetRecordsResponse -> [Record])
-> (GetRecordsResponse -> [Record] -> GetRecordsResponse)
-> Lens GetRecordsResponse GetRecordsResponse [Record] [Record]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecordsResponse' {[Record]
records :: [Record]
$sel:records:GetRecordsResponse' :: GetRecordsResponse -> [Record]
records} -> [Record]
records) (\s :: GetRecordsResponse
s@GetRecordsResponse' {} [Record]
a -> GetRecordsResponse
s {$sel:records:GetRecordsResponse' :: [Record]
records = [Record]
a} :: GetRecordsResponse) (([Record] -> f [Record])
 -> GetRecordsResponse -> f GetRecordsResponse)
-> (([Record] -> f [Record]) -> [Record] -> f [Record])
-> ([Record] -> f [Record])
-> GetRecordsResponse
-> f GetRecordsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Record] -> f [Record]) -> [Record] -> f [Record]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData GetRecordsResponse