{-# 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-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.Firehose.Types.PutRecordBatchResponseEntry where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 ID of the record.
    PutRecordBatchResponseEntry -> Maybe Text
recordId :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (PutRecordBatchResponseEntry -> PutRecordBatchResponseEntry -> Bool
(PutRecordBatchResponseEntry
 -> PutRecordBatchResponseEntry -> Bool)
-> (PutRecordBatchResponseEntry
    -> PutRecordBatchResponseEntry -> Bool)
-> Eq PutRecordBatchResponseEntry
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]
(Int -> ReadS PutRecordBatchResponseEntry)
-> ReadS [PutRecordBatchResponseEntry]
-> ReadPrec PutRecordBatchResponseEntry
-> ReadPrec [PutRecordBatchResponseEntry]
-> Read 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
(Int -> PutRecordBatchResponseEntry -> ShowS)
-> (PutRecordBatchResponseEntry -> String)
-> ([PutRecordBatchResponseEntry] -> ShowS)
-> Show PutRecordBatchResponseEntry
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.
 PutRecordBatchResponseEntry -> Rep PutRecordBatchResponseEntry x)
-> (forall x.
    Rep PutRecordBatchResponseEntry x -> PutRecordBatchResponseEntry)
-> Generic PutRecordBatchResponseEntry
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:
--
-- 'recordId', 'putRecordBatchResponseEntry_recordId' - The ID of the record.
--
-- 'errorCode', 'putRecordBatchResponseEntry_errorCode' - The error code for an individual record result.
--
-- 'errorMessage', 'putRecordBatchResponseEntry_errorMessage' - The error message for an individual record result.
newPutRecordBatchResponseEntry ::
  PutRecordBatchResponseEntry
newPutRecordBatchResponseEntry :: PutRecordBatchResponseEntry
newPutRecordBatchResponseEntry =
  PutRecordBatchResponseEntry' :: Maybe Text
-> Maybe Text -> Maybe Text -> PutRecordBatchResponseEntry
PutRecordBatchResponseEntry'
    { $sel:recordId:PutRecordBatchResponseEntry' :: Maybe Text
recordId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorCode:PutRecordBatchResponseEntry' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:PutRecordBatchResponseEntry' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the record.
putRecordBatchResponseEntry_recordId :: Lens.Lens' PutRecordBatchResponseEntry (Prelude.Maybe Prelude.Text)
putRecordBatchResponseEntry_recordId :: (Maybe Text -> f (Maybe Text))
-> PutRecordBatchResponseEntry -> f PutRecordBatchResponseEntry
putRecordBatchResponseEntry_recordId = (PutRecordBatchResponseEntry -> Maybe Text)
-> (PutRecordBatchResponseEntry
    -> Maybe Text -> PutRecordBatchResponseEntry)
-> Lens
     PutRecordBatchResponseEntry
     PutRecordBatchResponseEntry
     (Maybe Text)
     (Maybe Text)
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)

-- | The error code for an individual record result.
putRecordBatchResponseEntry_errorCode :: Lens.Lens' PutRecordBatchResponseEntry (Prelude.Maybe Prelude.Text)
putRecordBatchResponseEntry_errorCode :: (Maybe Text -> f (Maybe Text))
-> PutRecordBatchResponseEntry -> f PutRecordBatchResponseEntry
putRecordBatchResponseEntry_errorCode = (PutRecordBatchResponseEntry -> Maybe Text)
-> (PutRecordBatchResponseEntry
    -> Maybe Text -> PutRecordBatchResponseEntry)
-> Lens
     PutRecordBatchResponseEntry
     PutRecordBatchResponseEntry
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> PutRecordBatchResponseEntry -> f PutRecordBatchResponseEntry
putRecordBatchResponseEntry_errorMessage = (PutRecordBatchResponseEntry -> Maybe Text)
-> (PutRecordBatchResponseEntry
    -> Maybe Text -> PutRecordBatchResponseEntry)
-> Lens
     PutRecordBatchResponseEntry
     PutRecordBatchResponseEntry
     (Maybe Text)
     (Maybe Text)
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)

instance Core.FromJSON PutRecordBatchResponseEntry where
  parseJSON :: Value -> Parser PutRecordBatchResponseEntry
parseJSON =
    String
-> (Object -> Parser PutRecordBatchResponseEntry)
-> Value
-> Parser PutRecordBatchResponseEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PutRecordBatchResponseEntry"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> PutRecordBatchResponseEntry
PutRecordBatchResponseEntry'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> PutRecordBatchResponseEntry)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> PutRecordBatchResponseEntry)
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
"RecordId")
            Parser (Maybe Text -> Maybe Text -> PutRecordBatchResponseEntry)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> PutRecordBatchResponseEntry)
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 -> PutRecordBatchResponseEntry)
-> Parser (Maybe Text) -> Parser PutRecordBatchResponseEntry
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")
      )

instance Prelude.Hashable PutRecordBatchResponseEntry

instance Prelude.NFData PutRecordBatchResponseEntry