{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.PutRecordsResultEntry
-- 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)
module Amazonka.Kinesis.Types.PutRecordsResultEntry where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the result of an individual record from a @PutRecords@
-- request. A record that is successfully added to a stream includes
-- @SequenceNumber@ and @ShardId@ in the result. A record that fails to be
-- added to the stream includes @ErrorCode@ and @ErrorMessage@ in the
-- result.
--
-- /See:/ 'newPutRecordsResultEntry' smart constructor.
data PutRecordsResultEntry = PutRecordsResultEntry'
  { -- | The sequence number for an individual record result.
    PutRecordsResultEntry -> Maybe Text
sequenceNumber :: Prelude.Maybe Prelude.Text,
    -- | The error code for an individual record result. @ErrorCodes@ can be
    -- either @ProvisionedThroughputExceededException@ or @InternalFailure@.
    PutRecordsResultEntry -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | The error message for an individual record result. An @ErrorCode@ value
    -- of @ProvisionedThroughputExceededException@ has an error message that
    -- includes the account ID, stream name, and shard ID. An @ErrorCode@ value
    -- of @InternalFailure@ has the error message
    -- @\"Internal Service Failure\"@.
    PutRecordsResultEntry -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The shard ID for an individual record result.
    PutRecordsResultEntry -> Maybe Text
shardId :: Prelude.Maybe Prelude.Text
  }
  deriving (PutRecordsResultEntry -> PutRecordsResultEntry -> Bool
(PutRecordsResultEntry -> PutRecordsResultEntry -> Bool)
-> (PutRecordsResultEntry -> PutRecordsResultEntry -> Bool)
-> Eq PutRecordsResultEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRecordsResultEntry -> PutRecordsResultEntry -> Bool
$c/= :: PutRecordsResultEntry -> PutRecordsResultEntry -> Bool
== :: PutRecordsResultEntry -> PutRecordsResultEntry -> Bool
$c== :: PutRecordsResultEntry -> PutRecordsResultEntry -> Bool
Prelude.Eq, ReadPrec [PutRecordsResultEntry]
ReadPrec PutRecordsResultEntry
Int -> ReadS PutRecordsResultEntry
ReadS [PutRecordsResultEntry]
(Int -> ReadS PutRecordsResultEntry)
-> ReadS [PutRecordsResultEntry]
-> ReadPrec PutRecordsResultEntry
-> ReadPrec [PutRecordsResultEntry]
-> Read PutRecordsResultEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRecordsResultEntry]
$creadListPrec :: ReadPrec [PutRecordsResultEntry]
readPrec :: ReadPrec PutRecordsResultEntry
$creadPrec :: ReadPrec PutRecordsResultEntry
readList :: ReadS [PutRecordsResultEntry]
$creadList :: ReadS [PutRecordsResultEntry]
readsPrec :: Int -> ReadS PutRecordsResultEntry
$creadsPrec :: Int -> ReadS PutRecordsResultEntry
Prelude.Read, Int -> PutRecordsResultEntry -> ShowS
[PutRecordsResultEntry] -> ShowS
PutRecordsResultEntry -> String
(Int -> PutRecordsResultEntry -> ShowS)
-> (PutRecordsResultEntry -> String)
-> ([PutRecordsResultEntry] -> ShowS)
-> Show PutRecordsResultEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRecordsResultEntry] -> ShowS
$cshowList :: [PutRecordsResultEntry] -> ShowS
show :: PutRecordsResultEntry -> String
$cshow :: PutRecordsResultEntry -> String
showsPrec :: Int -> PutRecordsResultEntry -> ShowS
$cshowsPrec :: Int -> PutRecordsResultEntry -> ShowS
Prelude.Show, (forall x. PutRecordsResultEntry -> Rep PutRecordsResultEntry x)
-> (forall x. Rep PutRecordsResultEntry x -> PutRecordsResultEntry)
-> Generic PutRecordsResultEntry
forall x. Rep PutRecordsResultEntry x -> PutRecordsResultEntry
forall x. PutRecordsResultEntry -> Rep PutRecordsResultEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutRecordsResultEntry x -> PutRecordsResultEntry
$cfrom :: forall x. PutRecordsResultEntry -> Rep PutRecordsResultEntry x
Prelude.Generic)

-- |
-- Create a value of 'PutRecordsResultEntry' 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:
--
-- 'sequenceNumber', 'putRecordsResultEntry_sequenceNumber' - The sequence number for an individual record result.
--
-- 'errorCode', 'putRecordsResultEntry_errorCode' - The error code for an individual record result. @ErrorCodes@ can be
-- either @ProvisionedThroughputExceededException@ or @InternalFailure@.
--
-- 'errorMessage', 'putRecordsResultEntry_errorMessage' - The error message for an individual record result. An @ErrorCode@ value
-- of @ProvisionedThroughputExceededException@ has an error message that
-- includes the account ID, stream name, and shard ID. An @ErrorCode@ value
-- of @InternalFailure@ has the error message
-- @\"Internal Service Failure\"@.
--
-- 'shardId', 'putRecordsResultEntry_shardId' - The shard ID for an individual record result.
newPutRecordsResultEntry ::
  PutRecordsResultEntry
newPutRecordsResultEntry :: PutRecordsResultEntry
newPutRecordsResultEntry =
  PutRecordsResultEntry' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> PutRecordsResultEntry
PutRecordsResultEntry'
    { $sel:sequenceNumber:PutRecordsResultEntry' :: Maybe Text
sequenceNumber =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorCode:PutRecordsResultEntry' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:PutRecordsResultEntry' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:shardId:PutRecordsResultEntry' :: Maybe Text
shardId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The sequence number for an individual record result.
putRecordsResultEntry_sequenceNumber :: Lens.Lens' PutRecordsResultEntry (Prelude.Maybe Prelude.Text)
putRecordsResultEntry_sequenceNumber :: (Maybe Text -> f (Maybe Text))
-> PutRecordsResultEntry -> f PutRecordsResultEntry
putRecordsResultEntry_sequenceNumber = (PutRecordsResultEntry -> Maybe Text)
-> (PutRecordsResultEntry -> Maybe Text -> PutRecordsResultEntry)
-> Lens
     PutRecordsResultEntry
     PutRecordsResultEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResultEntry' {Maybe Text
sequenceNumber :: Maybe Text
$sel:sequenceNumber:PutRecordsResultEntry' :: PutRecordsResultEntry -> Maybe Text
sequenceNumber} -> Maybe Text
sequenceNumber) (\s :: PutRecordsResultEntry
s@PutRecordsResultEntry' {} Maybe Text
a -> PutRecordsResultEntry
s {$sel:sequenceNumber:PutRecordsResultEntry' :: Maybe Text
sequenceNumber = Maybe Text
a} :: PutRecordsResultEntry)

-- | The error code for an individual record result. @ErrorCodes@ can be
-- either @ProvisionedThroughputExceededException@ or @InternalFailure@.
putRecordsResultEntry_errorCode :: Lens.Lens' PutRecordsResultEntry (Prelude.Maybe Prelude.Text)
putRecordsResultEntry_errorCode :: (Maybe Text -> f (Maybe Text))
-> PutRecordsResultEntry -> f PutRecordsResultEntry
putRecordsResultEntry_errorCode = (PutRecordsResultEntry -> Maybe Text)
-> (PutRecordsResultEntry -> Maybe Text -> PutRecordsResultEntry)
-> Lens
     PutRecordsResultEntry
     PutRecordsResultEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResultEntry' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:PutRecordsResultEntry' :: PutRecordsResultEntry -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: PutRecordsResultEntry
s@PutRecordsResultEntry' {} Maybe Text
a -> PutRecordsResultEntry
s {$sel:errorCode:PutRecordsResultEntry' :: Maybe Text
errorCode = Maybe Text
a} :: PutRecordsResultEntry)

-- | The error message for an individual record result. An @ErrorCode@ value
-- of @ProvisionedThroughputExceededException@ has an error message that
-- includes the account ID, stream name, and shard ID. An @ErrorCode@ value
-- of @InternalFailure@ has the error message
-- @\"Internal Service Failure\"@.
putRecordsResultEntry_errorMessage :: Lens.Lens' PutRecordsResultEntry (Prelude.Maybe Prelude.Text)
putRecordsResultEntry_errorMessage :: (Maybe Text -> f (Maybe Text))
-> PutRecordsResultEntry -> f PutRecordsResultEntry
putRecordsResultEntry_errorMessage = (PutRecordsResultEntry -> Maybe Text)
-> (PutRecordsResultEntry -> Maybe Text -> PutRecordsResultEntry)
-> Lens
     PutRecordsResultEntry
     PutRecordsResultEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResultEntry' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:PutRecordsResultEntry' :: PutRecordsResultEntry -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: PutRecordsResultEntry
s@PutRecordsResultEntry' {} Maybe Text
a -> PutRecordsResultEntry
s {$sel:errorMessage:PutRecordsResultEntry' :: Maybe Text
errorMessage = Maybe Text
a} :: PutRecordsResultEntry)

-- | The shard ID for an individual record result.
putRecordsResultEntry_shardId :: Lens.Lens' PutRecordsResultEntry (Prelude.Maybe Prelude.Text)
putRecordsResultEntry_shardId :: (Maybe Text -> f (Maybe Text))
-> PutRecordsResultEntry -> f PutRecordsResultEntry
putRecordsResultEntry_shardId = (PutRecordsResultEntry -> Maybe Text)
-> (PutRecordsResultEntry -> Maybe Text -> PutRecordsResultEntry)
-> Lens
     PutRecordsResultEntry
     PutRecordsResultEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordsResultEntry' {Maybe Text
shardId :: Maybe Text
$sel:shardId:PutRecordsResultEntry' :: PutRecordsResultEntry -> Maybe Text
shardId} -> Maybe Text
shardId) (\s :: PutRecordsResultEntry
s@PutRecordsResultEntry' {} Maybe Text
a -> PutRecordsResultEntry
s {$sel:shardId:PutRecordsResultEntry' :: Maybe Text
shardId = Maybe Text
a} :: PutRecordsResultEntry)

instance Core.FromJSON PutRecordsResultEntry where
  parseJSON :: Value -> Parser PutRecordsResultEntry
parseJSON =
    String
-> (Object -> Parser PutRecordsResultEntry)
-> Value
-> Parser PutRecordsResultEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PutRecordsResultEntry"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> PutRecordsResultEntry
PutRecordsResultEntry'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> PutRecordsResultEntry)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> PutRecordsResultEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SequenceNumber")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> PutRecordsResultEntry)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> PutRecordsResultEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorCode")
            Parser (Maybe Text -> Maybe Text -> PutRecordsResultEntry)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> PutRecordsResultEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorMessage")
            Parser (Maybe Text -> PutRecordsResultEntry)
-> Parser (Maybe Text) -> Parser PutRecordsResultEntry
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ShardId")
      )

instance Prelude.Hashable PutRecordsResultEntry

instance Prelude.NFData PutRecordsResultEntry