{-# 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-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)
--
-- 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.
--
-- 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_records,
    putRecords_streamName,

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

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

-- | A @PutRecords@ request.
--
-- /See:/ 'newPutRecords' smart constructor.
data PutRecords = PutRecords'
  { -- | The records associated with the request.
    PutRecords -> NonEmpty PutRecordsRequestEntry
records :: Prelude.NonEmpty PutRecordsRequestEntry,
    -- | The stream name associated with the request.
    PutRecords -> Text
streamName :: Prelude.Text
  }
  deriving (PutRecords -> PutRecords -> Bool
(PutRecords -> PutRecords -> Bool)
-> (PutRecords -> PutRecords -> Bool) -> Eq PutRecords
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]
(Int -> ReadS PutRecords)
-> ReadS [PutRecords]
-> ReadPrec PutRecords
-> ReadPrec [PutRecords]
-> Read 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
(Int -> PutRecords -> ShowS)
-> (PutRecords -> String)
-> ([PutRecords] -> ShowS)
-> Show PutRecords
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. PutRecords -> Rep PutRecords x)
-> (forall x. Rep PutRecords x -> PutRecords) -> Generic PutRecords
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:
--
-- 'records', 'putRecords_records' - The records associated with the request.
--
-- 'streamName', 'putRecords_streamName' - The stream name associated with the request.
newPutRecords ::
  -- | 'records'
  Prelude.NonEmpty PutRecordsRequestEntry ->
  -- | 'streamName'
  Prelude.Text ->
  PutRecords
newPutRecords :: NonEmpty PutRecordsRequestEntry -> Text -> PutRecords
newPutRecords NonEmpty PutRecordsRequestEntry
pRecords_ Text
pStreamName_ =
  PutRecords' :: NonEmpty PutRecordsRequestEntry -> Text -> PutRecords
PutRecords'
    { $sel:records:PutRecords' :: NonEmpty PutRecordsRequestEntry
records =
        Tagged
  (NonEmpty PutRecordsRequestEntry)
  (Identity (NonEmpty PutRecordsRequestEntry))
-> Tagged
     (NonEmpty PutRecordsRequestEntry)
     (Identity (NonEmpty PutRecordsRequestEntry))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty PutRecordsRequestEntry)
   (Identity (NonEmpty PutRecordsRequestEntry))
 -> Tagged
      (NonEmpty PutRecordsRequestEntry)
      (Identity (NonEmpty PutRecordsRequestEntry)))
-> NonEmpty PutRecordsRequestEntry
-> NonEmpty PutRecordsRequestEntry
forall t b. AReview t b -> b -> t
Lens.# NonEmpty PutRecordsRequestEntry
pRecords_,
      $sel:streamName:PutRecords' :: Text
streamName = Text
pStreamName_
    }

-- | The records associated with the request.
putRecords_records :: Lens.Lens' PutRecords (Prelude.NonEmpty PutRecordsRequestEntry)
putRecords_records :: (NonEmpty PutRecordsRequestEntry
 -> f (NonEmpty PutRecordsRequestEntry))
-> PutRecords -> f PutRecords
putRecords_records = (PutRecords -> NonEmpty PutRecordsRequestEntry)
-> (PutRecords -> NonEmpty PutRecordsRequestEntry -> PutRecords)
-> Lens
     PutRecords
     PutRecords
     (NonEmpty PutRecordsRequestEntry)
     (NonEmpty PutRecordsRequestEntry)
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) ((NonEmpty PutRecordsRequestEntry
  -> f (NonEmpty PutRecordsRequestEntry))
 -> PutRecords -> f PutRecords)
-> ((NonEmpty PutRecordsRequestEntry
     -> f (NonEmpty PutRecordsRequestEntry))
    -> NonEmpty PutRecordsRequestEntry
    -> f (NonEmpty PutRecordsRequestEntry))
-> (NonEmpty PutRecordsRequestEntry
    -> f (NonEmpty PutRecordsRequestEntry))
-> PutRecords
-> f PutRecords
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty PutRecordsRequestEntry
 -> f (NonEmpty PutRecordsRequestEntry))
-> NonEmpty PutRecordsRequestEntry
-> f (NonEmpty PutRecordsRequestEntry)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Core.AWSRequest PutRecords where
  type AWSResponse PutRecords = PutRecordsResponse
  request :: PutRecords -> Request PutRecords
request = Service -> PutRecords -> Request PutRecords
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutRecords
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutRecords)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PutRecords))
-> Logger
-> Service
-> Proxy PutRecords
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutRecords)))
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 EncryptionType
-> Maybe Natural
-> Int
-> NonEmpty PutRecordsResultEntry
-> PutRecordsResponse
PutRecordsResponse'
            (Maybe EncryptionType
 -> Maybe Natural
 -> Int
 -> NonEmpty PutRecordsResultEntry
 -> PutRecordsResponse)
-> Either String (Maybe EncryptionType)
-> Either
     String
     (Maybe Natural
      -> Int -> NonEmpty PutRecordsResultEntry -> PutRecordsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe EncryptionType)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"EncryptionType")
            Either
  String
  (Maybe Natural
   -> Int -> NonEmpty PutRecordsResultEntry -> PutRecordsResponse)
-> Either String (Maybe Natural)
-> Either
     String
     (Int -> NonEmpty PutRecordsResultEntry -> PutRecordsResponse)
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
"FailedRecordCount")
            Either
  String
  (Int -> NonEmpty PutRecordsResultEntry -> PutRecordsResponse)
-> Either String Int
-> Either
     String (NonEmpty PutRecordsResultEntry -> PutRecordsResponse)
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 (NonEmpty PutRecordsResultEntry -> PutRecordsResponse)
-> Either String (NonEmpty PutRecordsResultEntry)
-> Either String PutRecordsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (NonEmpty PutRecordsResultEntry)
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Records")
      )

instance Prelude.Hashable PutRecords

instance Prelude.NFData PutRecords

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

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

instance Core.ToQuery PutRecords where
  toQuery :: PutRecords -> QueryString
toQuery = QueryString -> PutRecords -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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 AWS 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,
    -- correlated with the request by natural ordering. 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
(PutRecordsResponse -> PutRecordsResponse -> Bool)
-> (PutRecordsResponse -> PutRecordsResponse -> Bool)
-> Eq PutRecordsResponse
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]
(Int -> ReadS PutRecordsResponse)
-> ReadS [PutRecordsResponse]
-> ReadPrec PutRecordsResponse
-> ReadPrec [PutRecordsResponse]
-> Read 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
(Int -> PutRecordsResponse -> ShowS)
-> (PutRecordsResponse -> String)
-> ([PutRecordsResponse] -> ShowS)
-> Show PutRecordsResponse
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. PutRecordsResponse -> Rep PutRecordsResponse x)
-> (forall x. Rep PutRecordsResponse x -> PutRecordsResponse)
-> Generic PutRecordsResponse
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 AWS 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,
-- correlated with the request by natural ordering. 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' :: Maybe EncryptionType
-> Maybe Natural
-> Int
-> NonEmpty PutRecordsResultEntry
-> PutRecordsResponse
PutRecordsResponse'
    { $sel:encryptionType:PutRecordsResponse' :: Maybe EncryptionType
encryptionType =
        Maybe EncryptionType
forall a. Maybe a
Prelude.Nothing,
      $sel:failedRecordCount:PutRecordsResponse' :: Maybe Natural
failedRecordCount = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutRecordsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:records:PutRecordsResponse' :: NonEmpty PutRecordsResultEntry
records = Tagged
  (NonEmpty PutRecordsResultEntry)
  (Identity (NonEmpty PutRecordsResultEntry))
-> Tagged
     (NonEmpty PutRecordsResultEntry)
     (Identity (NonEmpty PutRecordsResultEntry))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty PutRecordsResultEntry)
   (Identity (NonEmpty PutRecordsResultEntry))
 -> Tagged
      (NonEmpty PutRecordsResultEntry)
      (Identity (NonEmpty PutRecordsResultEntry)))
-> NonEmpty PutRecordsResultEntry -> NonEmpty PutRecordsResultEntry
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 AWS KMS key.
putRecordsResponse_encryptionType :: Lens.Lens' PutRecordsResponse (Prelude.Maybe EncryptionType)
putRecordsResponse_encryptionType :: (Maybe EncryptionType -> f (Maybe EncryptionType))
-> PutRecordsResponse -> f PutRecordsResponse
putRecordsResponse_encryptionType = (PutRecordsResponse -> Maybe EncryptionType)
-> (PutRecordsResponse
    -> Maybe EncryptionType -> PutRecordsResponse)
-> Lens
     PutRecordsResponse
     PutRecordsResponse
     (Maybe EncryptionType)
     (Maybe 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 :: (Maybe Natural -> f (Maybe Natural))
-> PutRecordsResponse -> f PutRecordsResponse
putRecordsResponse_failedRecordCount = (PutRecordsResponse -> Maybe Natural)
-> (PutRecordsResponse -> Maybe Natural -> PutRecordsResponse)
-> Lens
     PutRecordsResponse
     PutRecordsResponse
     (Maybe Natural)
     (Maybe Natural)
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 :: (Int -> f Int) -> PutRecordsResponse -> f PutRecordsResponse
putRecordsResponse_httpStatus = (PutRecordsResponse -> Int)
-> (PutRecordsResponse -> Int -> PutRecordsResponse)
-> Lens PutRecordsResponse PutRecordsResponse Int Int
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,
-- correlated with the request by natural ordering. 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 :: (NonEmpty PutRecordsResultEntry
 -> f (NonEmpty PutRecordsResultEntry))
-> PutRecordsResponse -> f PutRecordsResponse
putRecordsResponse_records = (PutRecordsResponse -> NonEmpty PutRecordsResultEntry)
-> (PutRecordsResponse
    -> NonEmpty PutRecordsResultEntry -> PutRecordsResponse)
-> Lens
     PutRecordsResponse
     PutRecordsResponse
     (NonEmpty PutRecordsResultEntry)
     (NonEmpty PutRecordsResultEntry)
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) ((NonEmpty PutRecordsResultEntry
  -> f (NonEmpty PutRecordsResultEntry))
 -> PutRecordsResponse -> f PutRecordsResponse)
-> ((NonEmpty PutRecordsResultEntry
     -> f (NonEmpty PutRecordsResultEntry))
    -> NonEmpty PutRecordsResultEntry
    -> f (NonEmpty PutRecordsResultEntry))
-> (NonEmpty PutRecordsResultEntry
    -> f (NonEmpty PutRecordsResultEntry))
-> PutRecordsResponse
-> f PutRecordsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty PutRecordsResultEntry
 -> f (NonEmpty PutRecordsResultEntry))
-> NonEmpty PutRecordsResultEntry
-> f (NonEmpty PutRecordsResultEntry)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData PutRecordsResponse