{-# 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.PutRecords
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Writes multiple data records into a Kinesis data stream in a single call
-- (also referred to as a @PutRecords@ request). Use this operation to send
-- data into the stream for data ingestion and processing.
--
-- When invoking this API, it is recommended you use the @StreamARN@ input
-- parameter rather than the @StreamName@ input parameter.
--
-- Each @PutRecords@ request can support up to 500 records. Each record in
-- the request can be as large as 1 MiB, up to a limit of 5 MiB for the
-- entire request, including partition keys. Each shard can support writes
-- up to 1,000 records per second, up to a maximum data write total of 1
-- MiB per second.
--
-- You must specify the name of the stream that captures, stores, and
-- transports the data; and an array of request @Records@, with each record
-- in the array requiring a partition key and data blob. The record size
-- limit applies to the total size of the partition key and data blob.
--
-- The data blob can be any type of data; for example, a segment from a log
-- file, geographic\/location data, website clickstream data, and so on.
--
-- The partition key is used by Kinesis Data Streams as input to a hash
-- function that maps the partition key and associated data to a specific
-- shard. An MD5 hash function is used to map partition keys to 128-bit
-- integer values and to map associated data records to shards. As a result
-- of this hashing mechanism, all data records with the same partition key
-- map to the same shard within the stream. For more information, see
-- <https://docs.aws.amazon.com/kinesis/latest/dev/developing-producers-with-sdk.html#kinesis-using-sdk-java-add-data-to-stream Adding Data to a Stream>
-- in the /Amazon Kinesis Data Streams Developer Guide/.
--
-- Each record in the @Records@ array may include an optional parameter,
-- @ExplicitHashKey@, which overrides the partition key to shard mapping.
-- This parameter allows a data producer to determine explicitly the shard
-- where the record is stored. For more information, see
-- <https://docs.aws.amazon.com/kinesis/latest/dev/developing-producers-with-sdk.html#kinesis-using-sdk-java-putrecords Adding Multiple Records with PutRecords>
-- in the /Amazon Kinesis Data Streams Developer Guide/.
--
-- The @PutRecords@ response includes an array of response @Records@. Each
-- record in the response array directly correlates with a record in the
-- request array using natural ordering, from the top to the bottom of the
-- request and response. The response @Records@ array always includes the
-- same number of records as the request array.
--
-- The response @Records@ array includes both successfully and
-- unsuccessfully processed records. Kinesis Data Streams attempts to
-- process all records in each @PutRecords@ request. A single record
-- failure does not stop the processing of subsequent records. As a result,
-- PutRecords doesn\'t guarantee the ordering of records. If you need to
-- read records in the same order they are written to the stream, use
-- PutRecord instead of @PutRecords@, and write to the same shard.
--
-- A successfully processed record includes @ShardId@ and @SequenceNumber@
-- values. The @ShardId@ parameter identifies the shard in the stream where
-- the record is stored. The @SequenceNumber@ parameter is an identifier
-- assigned to the put record, unique to all records in the stream.
--
-- An unsuccessfully processed record includes @ErrorCode@ and
-- @ErrorMessage@ values. @ErrorCode@ reflects the type of error and can be
-- one of the following values: @ProvisionedThroughputExceededException@ or
-- @InternalFailure@. @ErrorMessage@ provides more detailed information
-- about the @ProvisionedThroughputExceededException@ exception including
-- the account ID, stream name, and shard ID of the record that was
-- throttled. For more information about partially successful responses,
-- see
-- <https://docs.aws.amazon.com/kinesis/latest/dev/kinesis-using-sdk-java-add-data-to-stream.html#kinesis-using-sdk-java-putrecords Adding Multiple Records with PutRecords>
-- in the /Amazon Kinesis Data Streams Developer Guide/.
--
-- After you write a record to a stream, you cannot modify that record or
-- its order within the stream.
--
-- By default, data records are accessible for 24 hours from the time that
-- they are added to a stream. You can use IncreaseStreamRetentionPeriod or
-- DecreaseStreamRetentionPeriod to modify this retention period.
module Amazonka.Kinesis.PutRecords
  ( -- * Creating a Request
    PutRecords (..),
    newPutRecords,

    -- * Request Lenses
    putRecords_streamARN,
    putRecords_streamName,
    putRecords_records,

    -- * Destructuring the Response
    PutRecordsResponse (..),
    newPutRecordsResponse,

    -- * Response Lenses
    putRecordsResponse_encryptionType,
    putRecordsResponse_failedRecordCount,
    putRecordsResponse_httpStatus,
    putRecordsResponse_records,
  )
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

-- | A @PutRecords@ request.
--
-- /See:/ 'newPutRecords' smart constructor.
data PutRecords = PutRecords'
  { -- | The ARN of the stream.
    PutRecords -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
    -- | The stream name associated with the request.
    PutRecords -> Maybe Text
streamName :: Prelude.Maybe Prelude.Text,
    -- | The records associated with the request.
    PutRecords -> NonEmpty PutRecordsRequestEntry
records :: Prelude.NonEmpty PutRecordsRequestEntry
  }
  deriving (PutRecords -> PutRecords -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRecords -> PutRecords -> Bool
$c/= :: PutRecords -> PutRecords -> Bool
== :: PutRecords -> PutRecords -> Bool
$c== :: PutRecords -> PutRecords -> Bool
Prelude.Eq, ReadPrec [PutRecords]
ReadPrec PutRecords
Int -> ReadS PutRecords
ReadS [PutRecords]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRecords]
$creadListPrec :: ReadPrec [PutRecords]
readPrec :: ReadPrec PutRecords
$creadPrec :: ReadPrec PutRecords
readList :: ReadS [PutRecords]
$creadList :: ReadS [PutRecords]
readsPrec :: Int -> ReadS PutRecords
$creadsPrec :: Int -> ReadS PutRecords
Prelude.Read, Int -> PutRecords -> ShowS
[PutRecords] -> ShowS
PutRecords -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRecords] -> ShowS
$cshowList :: [PutRecords] -> ShowS
show :: PutRecords -> String
$cshow :: PutRecords -> String
showsPrec :: Int -> PutRecords -> ShowS
$cshowsPrec :: Int -> PutRecords -> ShowS
Prelude.Show, forall x. Rep PutRecords x -> PutRecords
forall x. PutRecords -> Rep PutRecords x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutRecords x -> PutRecords
$cfrom :: forall x. PutRecords -> Rep PutRecords x
Prelude.Generic)

-- |
-- Create a value of 'PutRecords' 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:
--
-- 'streamARN', 'putRecords_streamARN' - The ARN of the stream.
--
-- 'streamName', 'putRecords_streamName' - The stream name associated with the request.
--
-- 'records', 'putRecords_records' - The records associated with the request.
newPutRecords ::
  -- | 'records'
  Prelude.NonEmpty PutRecordsRequestEntry ->
  PutRecords
newPutRecords :: NonEmpty PutRecordsRequestEntry -> PutRecords
newPutRecords NonEmpty PutRecordsRequestEntry
pRecords_ =
  PutRecords'
    { $sel:streamARN:PutRecords' :: Maybe Text
streamARN = forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:PutRecords' :: Maybe Text
streamName = forall a. Maybe a
Prelude.Nothing,
      $sel:records:PutRecords' :: NonEmpty PutRecordsRequestEntry
records = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty PutRecordsRequestEntry
pRecords_
    }

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

-- | The stream name associated with the request.
putRecords_streamName :: Lens.Lens' PutRecords (Prelude.Maybe Prelude.Text)
putRecords_streamName :: Lens' PutRecords (Maybe Text)
putRecords_streamName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecords' {Maybe Text
streamName :: Maybe Text
$sel:streamName:PutRecords' :: PutRecords -> Maybe Text
streamName} -> Maybe Text
streamName) (\s :: PutRecords
s@PutRecords' {} Maybe Text
a -> PutRecords
s {$sel:streamName:PutRecords' :: Maybe Text
streamName = Maybe Text
a} :: PutRecords)

-- | The records associated with the request.
putRecords_records :: Lens.Lens' PutRecords (Prelude.NonEmpty PutRecordsRequestEntry)
putRecords_records :: Lens' PutRecords (NonEmpty PutRecordsRequestEntry)
putRecords_records = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecords' {NonEmpty PutRecordsRequestEntry
records :: NonEmpty PutRecordsRequestEntry
$sel:records:PutRecords' :: PutRecords -> NonEmpty PutRecordsRequestEntry
records} -> NonEmpty PutRecordsRequestEntry
records) (\s :: PutRecords
s@PutRecords' {} NonEmpty PutRecordsRequestEntry
a -> PutRecords
s {$sel:records:PutRecords' :: NonEmpty PutRecordsRequestEntry
records = NonEmpty PutRecordsRequestEntry
a} :: PutRecords) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest PutRecords where
  type AWSResponse PutRecords = PutRecordsResponse
  request :: (Service -> Service) -> PutRecords -> Request PutRecords
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 PutRecords
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutRecords)))
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 EncryptionType
-> Maybe Natural
-> Int
-> NonEmpty PutRecordsResultEntry
-> PutRecordsResponse
PutRecordsResponse'
            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
"EncryptionType")
            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
"FailedRecordCount")
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"Records")
      )

instance Prelude.Hashable PutRecords where
  hashWithSalt :: Int -> PutRecords -> Int
hashWithSalt Int
_salt PutRecords' {Maybe Text
NonEmpty PutRecordsRequestEntry
records :: NonEmpty PutRecordsRequestEntry
streamName :: Maybe Text
streamARN :: Maybe Text
$sel:records:PutRecords' :: PutRecords -> NonEmpty PutRecordsRequestEntry
$sel:streamName:PutRecords' :: PutRecords -> Maybe Text
$sel:streamARN:PutRecords' :: PutRecords -> Maybe Text
..} =
    Int
_salt
      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` NonEmpty PutRecordsRequestEntry
records

instance Prelude.NFData PutRecords where
  rnf :: PutRecords -> ()
rnf PutRecords' {Maybe Text
NonEmpty PutRecordsRequestEntry
records :: NonEmpty PutRecordsRequestEntry
streamName :: Maybe Text
streamARN :: Maybe Text
$sel:records:PutRecords' :: PutRecords -> NonEmpty PutRecordsRequestEntry
$sel:streamName:PutRecords' :: PutRecords -> Maybe Text
$sel:streamARN:PutRecords' :: PutRecords -> Maybe Text
..} =
    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 NonEmpty PutRecordsRequestEntry
records

instance Data.ToHeaders PutRecords where
  toHeaders :: PutRecords -> 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.PutRecords" ::
                          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 PutRecords where
  toJSON :: PutRecords -> Value
toJSON PutRecords' {Maybe Text
NonEmpty PutRecordsRequestEntry
records :: NonEmpty PutRecordsRequestEntry
streamName :: Maybe Text
streamARN :: Maybe Text
$sel:records:PutRecords' :: PutRecords -> NonEmpty PutRecordsRequestEntry
$sel:streamName:PutRecords' :: PutRecords -> Maybe Text
$sel:streamARN:PutRecords' :: PutRecords -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            forall a. a -> Maybe a
Prelude.Just (Key
"Records" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty PutRecordsRequestEntry
records)
          ]
      )

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

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

-- | @PutRecords@ results.
--
-- /See:/ 'newPutRecordsResponse' smart constructor.
data PutRecordsResponse = PutRecordsResponse'
  { -- | The encryption type used on the records. This parameter can be one of
    -- the following values:
    --
    -- -   @NONE@: Do not encrypt the records.
    --
    -- -   @KMS@: Use server-side encryption on the records using a
    --     customer-managed Amazon Web Services KMS key.
    PutRecordsResponse -> Maybe EncryptionType
encryptionType :: Prelude.Maybe EncryptionType,
    -- | The number of unsuccessfully processed records in a @PutRecords@
    -- request.
    PutRecordsResponse -> Maybe Natural
failedRecordCount :: Prelude.Maybe Prelude.Natural,
    -- | The response's http status code.
    PutRecordsResponse -> Int
httpStatus :: Prelude.Int,
    -- | An array of successfully and unsuccessfully processed record results. A
    -- record that is successfully added to a stream includes @SequenceNumber@
    -- and @ShardId@ in the result. A record that fails to be added to a stream
    -- includes @ErrorCode@ and @ErrorMessage@ in the result.
    PutRecordsResponse -> NonEmpty PutRecordsResultEntry
records :: Prelude.NonEmpty PutRecordsResultEntry
  }
  deriving (PutRecordsResponse -> PutRecordsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRecordsResponse -> PutRecordsResponse -> Bool
$c/= :: PutRecordsResponse -> PutRecordsResponse -> Bool
== :: PutRecordsResponse -> PutRecordsResponse -> Bool
$c== :: PutRecordsResponse -> PutRecordsResponse -> Bool
Prelude.Eq, ReadPrec [PutRecordsResponse]
ReadPrec PutRecordsResponse
Int -> ReadS PutRecordsResponse
ReadS [PutRecordsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRecordsResponse]
$creadListPrec :: ReadPrec [PutRecordsResponse]
readPrec :: ReadPrec PutRecordsResponse
$creadPrec :: ReadPrec PutRecordsResponse
readList :: ReadS [PutRecordsResponse]
$creadList :: ReadS [PutRecordsResponse]
readsPrec :: Int -> ReadS PutRecordsResponse
$creadsPrec :: Int -> ReadS PutRecordsResponse
Prelude.Read, Int -> PutRecordsResponse -> ShowS
[PutRecordsResponse] -> ShowS
PutRecordsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRecordsResponse] -> ShowS
$cshowList :: [PutRecordsResponse] -> ShowS
show :: PutRecordsResponse -> String
$cshow :: PutRecordsResponse -> String
showsPrec :: Int -> PutRecordsResponse -> ShowS
$cshowsPrec :: Int -> PutRecordsResponse -> ShowS
Prelude.Show, forall x. Rep PutRecordsResponse x -> PutRecordsResponse
forall x. PutRecordsResponse -> Rep PutRecordsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutRecordsResponse x -> PutRecordsResponse
$cfrom :: forall x. PutRecordsResponse -> Rep PutRecordsResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutRecordsResponse' 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:
--
-- 'encryptionType', 'putRecordsResponse_encryptionType' - The encryption type used on the records. This parameter can be one of
-- the following values:
--
-- -   @NONE@: Do not encrypt the records.
--
-- -   @KMS@: Use server-side encryption on the records using a
--     customer-managed Amazon Web Services KMS key.
--
-- 'failedRecordCount', 'putRecordsResponse_failedRecordCount' - The number of unsuccessfully processed records in a @PutRecords@
-- request.
--
-- 'httpStatus', 'putRecordsResponse_httpStatus' - The response's http status code.
--
-- 'records', 'putRecordsResponse_records' - An array of successfully and unsuccessfully processed record results. A
-- record that is successfully added to a stream includes @SequenceNumber@
-- and @ShardId@ in the result. A record that fails to be added to a stream
-- includes @ErrorCode@ and @ErrorMessage@ in the result.
newPutRecordsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'records'
  Prelude.NonEmpty PutRecordsResultEntry ->
  PutRecordsResponse
newPutRecordsResponse :: Int -> NonEmpty PutRecordsResultEntry -> PutRecordsResponse
newPutRecordsResponse Int
pHttpStatus_ NonEmpty PutRecordsResultEntry
pRecords_ =
  PutRecordsResponse'
    { $sel:encryptionType:PutRecordsResponse' :: Maybe EncryptionType
encryptionType =
        forall a. Maybe a
Prelude.Nothing,
      $sel:failedRecordCount:PutRecordsResponse' :: Maybe Natural
failedRecordCount = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutRecordsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:records:PutRecordsResponse' :: NonEmpty PutRecordsResultEntry
records = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty PutRecordsResultEntry
pRecords_
    }

-- | The encryption type used on the records. This parameter can be one of
-- the following values:
--
-- -   @NONE@: Do not encrypt the records.
--
-- -   @KMS@: Use server-side encryption on the records using a
--     customer-managed Amazon Web Services KMS key.
putRecordsResponse_encryptionType :: Lens.Lens' PutRecordsResponse (Prelude.Maybe EncryptionType)
putRecordsResponse_encryptionType :: Lens' PutRecordsResponse (Maybe EncryptionType)
putRecordsResponse_encryptionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResponse' {Maybe EncryptionType
encryptionType :: Maybe EncryptionType
$sel:encryptionType:PutRecordsResponse' :: PutRecordsResponse -> Maybe EncryptionType
encryptionType} -> Maybe EncryptionType
encryptionType) (\s :: PutRecordsResponse
s@PutRecordsResponse' {} Maybe EncryptionType
a -> PutRecordsResponse
s {$sel:encryptionType:PutRecordsResponse' :: Maybe EncryptionType
encryptionType = Maybe EncryptionType
a} :: PutRecordsResponse)

-- | The number of unsuccessfully processed records in a @PutRecords@
-- request.
putRecordsResponse_failedRecordCount :: Lens.Lens' PutRecordsResponse (Prelude.Maybe Prelude.Natural)
putRecordsResponse_failedRecordCount :: Lens' PutRecordsResponse (Maybe Natural)
putRecordsResponse_failedRecordCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResponse' {Maybe Natural
failedRecordCount :: Maybe Natural
$sel:failedRecordCount:PutRecordsResponse' :: PutRecordsResponse -> Maybe Natural
failedRecordCount} -> Maybe Natural
failedRecordCount) (\s :: PutRecordsResponse
s@PutRecordsResponse' {} Maybe Natural
a -> PutRecordsResponse
s {$sel:failedRecordCount:PutRecordsResponse' :: Maybe Natural
failedRecordCount = Maybe Natural
a} :: PutRecordsResponse)

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

-- | An array of successfully and unsuccessfully processed record results. A
-- record that is successfully added to a stream includes @SequenceNumber@
-- and @ShardId@ in the result. A record that fails to be added to a stream
-- includes @ErrorCode@ and @ErrorMessage@ in the result.
putRecordsResponse_records :: Lens.Lens' PutRecordsResponse (Prelude.NonEmpty PutRecordsResultEntry)
putRecordsResponse_records :: Lens' PutRecordsResponse (NonEmpty PutRecordsResultEntry)
putRecordsResponse_records = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResponse' {NonEmpty PutRecordsResultEntry
records :: NonEmpty PutRecordsResultEntry
$sel:records:PutRecordsResponse' :: PutRecordsResponse -> NonEmpty PutRecordsResultEntry
records} -> NonEmpty PutRecordsResultEntry
records) (\s :: PutRecordsResponse
s@PutRecordsResponse' {} NonEmpty PutRecordsResultEntry
a -> PutRecordsResponse
s {$sel:records:PutRecordsResponse' :: NonEmpty PutRecordsResultEntry
records = NonEmpty PutRecordsResultEntry
a} :: PutRecordsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData PutRecordsResponse where
  rnf :: PutRecordsResponse -> ()
rnf PutRecordsResponse' {Int
Maybe Natural
Maybe EncryptionType
NonEmpty PutRecordsResultEntry
records :: NonEmpty PutRecordsResultEntry
httpStatus :: Int
failedRecordCount :: Maybe Natural
encryptionType :: Maybe EncryptionType
$sel:records:PutRecordsResponse' :: PutRecordsResponse -> NonEmpty PutRecordsResultEntry
$sel:httpStatus:PutRecordsResponse' :: PutRecordsResponse -> Int
$sel:failedRecordCount:PutRecordsResponse' :: PutRecordsResponse -> Maybe Natural
$sel:encryptionType:PutRecordsResponse' :: PutRecordsResponse -> Maybe EncryptionType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EncryptionType
encryptionType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
failedRecordCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty PutRecordsResultEntry
records