{-# 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.Firehose.Types.PutRecordBatchResponseEntry
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Firehose.Types.PutRecordBatchResponseEntry where

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

-- | Contains the result for an individual record from a PutRecordBatch
-- request. If the record is successfully added to your delivery stream, it
-- receives a record ID. If the record fails to be added to your delivery
-- stream, the result includes an error code and an error message.
--
-- /See:/ 'newPutRecordBatchResponseEntry' smart constructor.
data PutRecordBatchResponseEntry = PutRecordBatchResponseEntry'
  { -- | The error code for an individual record result.
    PutRecordBatchResponseEntry -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | The error message for an individual record result.
    PutRecordBatchResponseEntry -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The ID of the record.
    PutRecordBatchResponseEntry -> Maybe Text
recordId :: Prelude.Maybe Prelude.Text
  }
  deriving (PutRecordBatchResponseEntry -> PutRecordBatchResponseEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRecordBatchResponseEntry -> PutRecordBatchResponseEntry -> Bool
$c/= :: PutRecordBatchResponseEntry -> PutRecordBatchResponseEntry -> Bool
== :: PutRecordBatchResponseEntry -> PutRecordBatchResponseEntry -> Bool
$c== :: PutRecordBatchResponseEntry -> PutRecordBatchResponseEntry -> Bool
Prelude.Eq, ReadPrec [PutRecordBatchResponseEntry]
ReadPrec PutRecordBatchResponseEntry
Int -> ReadS PutRecordBatchResponseEntry
ReadS [PutRecordBatchResponseEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRecordBatchResponseEntry]
$creadListPrec :: ReadPrec [PutRecordBatchResponseEntry]
readPrec :: ReadPrec PutRecordBatchResponseEntry
$creadPrec :: ReadPrec PutRecordBatchResponseEntry
readList :: ReadS [PutRecordBatchResponseEntry]
$creadList :: ReadS [PutRecordBatchResponseEntry]
readsPrec :: Int -> ReadS PutRecordBatchResponseEntry
$creadsPrec :: Int -> ReadS PutRecordBatchResponseEntry
Prelude.Read, Int -> PutRecordBatchResponseEntry -> ShowS
[PutRecordBatchResponseEntry] -> ShowS
PutRecordBatchResponseEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRecordBatchResponseEntry] -> ShowS
$cshowList :: [PutRecordBatchResponseEntry] -> ShowS
show :: PutRecordBatchResponseEntry -> String
$cshow :: PutRecordBatchResponseEntry -> String
showsPrec :: Int -> PutRecordBatchResponseEntry -> ShowS
$cshowsPrec :: Int -> PutRecordBatchResponseEntry -> ShowS
Prelude.Show, forall x.
Rep PutRecordBatchResponseEntry x -> PutRecordBatchResponseEntry
forall x.
PutRecordBatchResponseEntry -> Rep PutRecordBatchResponseEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutRecordBatchResponseEntry x -> PutRecordBatchResponseEntry
$cfrom :: forall x.
PutRecordBatchResponseEntry -> Rep PutRecordBatchResponseEntry x
Prelude.Generic)

-- |
-- Create a value of 'PutRecordBatchResponseEntry' 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:
--
-- 'errorCode', 'putRecordBatchResponseEntry_errorCode' - The error code for an individual record result.
--
-- 'errorMessage', 'putRecordBatchResponseEntry_errorMessage' - The error message for an individual record result.
--
-- 'recordId', 'putRecordBatchResponseEntry_recordId' - The ID of the record.
newPutRecordBatchResponseEntry ::
  PutRecordBatchResponseEntry
newPutRecordBatchResponseEntry :: PutRecordBatchResponseEntry
newPutRecordBatchResponseEntry =
  PutRecordBatchResponseEntry'
    { $sel:errorCode:PutRecordBatchResponseEntry' :: Maybe Text
errorCode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:PutRecordBatchResponseEntry' :: Maybe Text
errorMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:recordId:PutRecordBatchResponseEntry' :: Maybe Text
recordId = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code for an individual record result.
putRecordBatchResponseEntry_errorCode :: Lens.Lens' PutRecordBatchResponseEntry (Prelude.Maybe Prelude.Text)
putRecordBatchResponseEntry_errorCode :: Lens' PutRecordBatchResponseEntry (Maybe Text)
putRecordBatchResponseEntry_errorCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordBatchResponseEntry' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:PutRecordBatchResponseEntry' :: PutRecordBatchResponseEntry -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: PutRecordBatchResponseEntry
s@PutRecordBatchResponseEntry' {} Maybe Text
a -> PutRecordBatchResponseEntry
s {$sel:errorCode:PutRecordBatchResponseEntry' :: Maybe Text
errorCode = Maybe Text
a} :: PutRecordBatchResponseEntry)

-- | The error message for an individual record result.
putRecordBatchResponseEntry_errorMessage :: Lens.Lens' PutRecordBatchResponseEntry (Prelude.Maybe Prelude.Text)
putRecordBatchResponseEntry_errorMessage :: Lens' PutRecordBatchResponseEntry (Maybe Text)
putRecordBatchResponseEntry_errorMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordBatchResponseEntry' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:PutRecordBatchResponseEntry' :: PutRecordBatchResponseEntry -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: PutRecordBatchResponseEntry
s@PutRecordBatchResponseEntry' {} Maybe Text
a -> PutRecordBatchResponseEntry
s {$sel:errorMessage:PutRecordBatchResponseEntry' :: Maybe Text
errorMessage = Maybe Text
a} :: PutRecordBatchResponseEntry)

-- | The ID of the record.
putRecordBatchResponseEntry_recordId :: Lens.Lens' PutRecordBatchResponseEntry (Prelude.Maybe Prelude.Text)
putRecordBatchResponseEntry_recordId :: Lens' PutRecordBatchResponseEntry (Maybe Text)
putRecordBatchResponseEntry_recordId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecordBatchResponseEntry' {Maybe Text
recordId :: Maybe Text
$sel:recordId:PutRecordBatchResponseEntry' :: PutRecordBatchResponseEntry -> Maybe Text
recordId} -> Maybe Text
recordId) (\s :: PutRecordBatchResponseEntry
s@PutRecordBatchResponseEntry' {} Maybe Text
a -> PutRecordBatchResponseEntry
s {$sel:recordId:PutRecordBatchResponseEntry' :: Maybe Text
recordId = Maybe Text
a} :: PutRecordBatchResponseEntry)

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

instance Prelude.Hashable PutRecordBatchResponseEntry where
  hashWithSalt :: Int -> PutRecordBatchResponseEntry -> Int
hashWithSalt Int
_salt PutRecordBatchResponseEntry' {Maybe Text
recordId :: Maybe Text
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:recordId:PutRecordBatchResponseEntry' :: PutRecordBatchResponseEntry -> Maybe Text
$sel:errorMessage:PutRecordBatchResponseEntry' :: PutRecordBatchResponseEntry -> Maybe Text
$sel:errorCode:PutRecordBatchResponseEntry' :: PutRecordBatchResponseEntry -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recordId

instance Prelude.NFData PutRecordBatchResponseEntry where
  rnf :: PutRecordBatchResponseEntry -> ()
rnf PutRecordBatchResponseEntry' {Maybe Text
recordId :: Maybe Text
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:recordId:PutRecordBatchResponseEntry' :: PutRecordBatchResponseEntry -> Maybe Text
$sel:errorMessage:PutRecordBatchResponseEntry' :: PutRecordBatchResponseEntry -> Maybe Text
$sel:errorCode:PutRecordBatchResponseEntry' :: PutRecordBatchResponseEntry -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recordId