{-# 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.IoTAnalytics.Types.BatchPutMessageErrorEntry
-- 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.IoTAnalytics.Types.BatchPutMessageErrorEntry where

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

-- | Contains informations about errors.
--
-- /See:/ 'newBatchPutMessageErrorEntry' smart constructor.
data BatchPutMessageErrorEntry = BatchPutMessageErrorEntry'
  { -- | The code associated with the error.
    BatchPutMessageErrorEntry -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | The message associated with the error.
    BatchPutMessageErrorEntry -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The ID of the message that caused the error. See the value corresponding
    -- to the @messageId@ key in the message object.
    BatchPutMessageErrorEntry -> Maybe Text
messageId :: Prelude.Maybe Prelude.Text
  }
  deriving (BatchPutMessageErrorEntry -> BatchPutMessageErrorEntry -> Bool
(BatchPutMessageErrorEntry -> BatchPutMessageErrorEntry -> Bool)
-> (BatchPutMessageErrorEntry -> BatchPutMessageErrorEntry -> Bool)
-> Eq BatchPutMessageErrorEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchPutMessageErrorEntry -> BatchPutMessageErrorEntry -> Bool
$c/= :: BatchPutMessageErrorEntry -> BatchPutMessageErrorEntry -> Bool
== :: BatchPutMessageErrorEntry -> BatchPutMessageErrorEntry -> Bool
$c== :: BatchPutMessageErrorEntry -> BatchPutMessageErrorEntry -> Bool
Prelude.Eq, ReadPrec [BatchPutMessageErrorEntry]
ReadPrec BatchPutMessageErrorEntry
Int -> ReadS BatchPutMessageErrorEntry
ReadS [BatchPutMessageErrorEntry]
(Int -> ReadS BatchPutMessageErrorEntry)
-> ReadS [BatchPutMessageErrorEntry]
-> ReadPrec BatchPutMessageErrorEntry
-> ReadPrec [BatchPutMessageErrorEntry]
-> Read BatchPutMessageErrorEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchPutMessageErrorEntry]
$creadListPrec :: ReadPrec [BatchPutMessageErrorEntry]
readPrec :: ReadPrec BatchPutMessageErrorEntry
$creadPrec :: ReadPrec BatchPutMessageErrorEntry
readList :: ReadS [BatchPutMessageErrorEntry]
$creadList :: ReadS [BatchPutMessageErrorEntry]
readsPrec :: Int -> ReadS BatchPutMessageErrorEntry
$creadsPrec :: Int -> ReadS BatchPutMessageErrorEntry
Prelude.Read, Int -> BatchPutMessageErrorEntry -> ShowS
[BatchPutMessageErrorEntry] -> ShowS
BatchPutMessageErrorEntry -> String
(Int -> BatchPutMessageErrorEntry -> ShowS)
-> (BatchPutMessageErrorEntry -> String)
-> ([BatchPutMessageErrorEntry] -> ShowS)
-> Show BatchPutMessageErrorEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchPutMessageErrorEntry] -> ShowS
$cshowList :: [BatchPutMessageErrorEntry] -> ShowS
show :: BatchPutMessageErrorEntry -> String
$cshow :: BatchPutMessageErrorEntry -> String
showsPrec :: Int -> BatchPutMessageErrorEntry -> ShowS
$cshowsPrec :: Int -> BatchPutMessageErrorEntry -> ShowS
Prelude.Show, (forall x.
 BatchPutMessageErrorEntry -> Rep BatchPutMessageErrorEntry x)
-> (forall x.
    Rep BatchPutMessageErrorEntry x -> BatchPutMessageErrorEntry)
-> Generic BatchPutMessageErrorEntry
forall x.
Rep BatchPutMessageErrorEntry x -> BatchPutMessageErrorEntry
forall x.
BatchPutMessageErrorEntry -> Rep BatchPutMessageErrorEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchPutMessageErrorEntry x -> BatchPutMessageErrorEntry
$cfrom :: forall x.
BatchPutMessageErrorEntry -> Rep BatchPutMessageErrorEntry x
Prelude.Generic)

-- |
-- Create a value of 'BatchPutMessageErrorEntry' 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', 'batchPutMessageErrorEntry_errorCode' - The code associated with the error.
--
-- 'errorMessage', 'batchPutMessageErrorEntry_errorMessage' - The message associated with the error.
--
-- 'messageId', 'batchPutMessageErrorEntry_messageId' - The ID of the message that caused the error. See the value corresponding
-- to the @messageId@ key in the message object.
newBatchPutMessageErrorEntry ::
  BatchPutMessageErrorEntry
newBatchPutMessageErrorEntry :: BatchPutMessageErrorEntry
newBatchPutMessageErrorEntry =
  BatchPutMessageErrorEntry' :: Maybe Text -> Maybe Text -> Maybe Text -> BatchPutMessageErrorEntry
BatchPutMessageErrorEntry'
    { $sel:errorCode:BatchPutMessageErrorEntry' :: Maybe Text
errorCode =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:BatchPutMessageErrorEntry' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:messageId:BatchPutMessageErrorEntry' :: Maybe Text
messageId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The code associated with the error.
batchPutMessageErrorEntry_errorCode :: Lens.Lens' BatchPutMessageErrorEntry (Prelude.Maybe Prelude.Text)
batchPutMessageErrorEntry_errorCode :: (Maybe Text -> f (Maybe Text))
-> BatchPutMessageErrorEntry -> f BatchPutMessageErrorEntry
batchPutMessageErrorEntry_errorCode = (BatchPutMessageErrorEntry -> Maybe Text)
-> (BatchPutMessageErrorEntry
    -> Maybe Text -> BatchPutMessageErrorEntry)
-> Lens
     BatchPutMessageErrorEntry
     BatchPutMessageErrorEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutMessageErrorEntry' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:BatchPutMessageErrorEntry' :: BatchPutMessageErrorEntry -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: BatchPutMessageErrorEntry
s@BatchPutMessageErrorEntry' {} Maybe Text
a -> BatchPutMessageErrorEntry
s {$sel:errorCode:BatchPutMessageErrorEntry' :: Maybe Text
errorCode = Maybe Text
a} :: BatchPutMessageErrorEntry)

-- | The message associated with the error.
batchPutMessageErrorEntry_errorMessage :: Lens.Lens' BatchPutMessageErrorEntry (Prelude.Maybe Prelude.Text)
batchPutMessageErrorEntry_errorMessage :: (Maybe Text -> f (Maybe Text))
-> BatchPutMessageErrorEntry -> f BatchPutMessageErrorEntry
batchPutMessageErrorEntry_errorMessage = (BatchPutMessageErrorEntry -> Maybe Text)
-> (BatchPutMessageErrorEntry
    -> Maybe Text -> BatchPutMessageErrorEntry)
-> Lens
     BatchPutMessageErrorEntry
     BatchPutMessageErrorEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutMessageErrorEntry' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:BatchPutMessageErrorEntry' :: BatchPutMessageErrorEntry -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: BatchPutMessageErrorEntry
s@BatchPutMessageErrorEntry' {} Maybe Text
a -> BatchPutMessageErrorEntry
s {$sel:errorMessage:BatchPutMessageErrorEntry' :: Maybe Text
errorMessage = Maybe Text
a} :: BatchPutMessageErrorEntry)

-- | The ID of the message that caused the error. See the value corresponding
-- to the @messageId@ key in the message object.
batchPutMessageErrorEntry_messageId :: Lens.Lens' BatchPutMessageErrorEntry (Prelude.Maybe Prelude.Text)
batchPutMessageErrorEntry_messageId :: (Maybe Text -> f (Maybe Text))
-> BatchPutMessageErrorEntry -> f BatchPutMessageErrorEntry
batchPutMessageErrorEntry_messageId = (BatchPutMessageErrorEntry -> Maybe Text)
-> (BatchPutMessageErrorEntry
    -> Maybe Text -> BatchPutMessageErrorEntry)
-> Lens
     BatchPutMessageErrorEntry
     BatchPutMessageErrorEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutMessageErrorEntry' {Maybe Text
messageId :: Maybe Text
$sel:messageId:BatchPutMessageErrorEntry' :: BatchPutMessageErrorEntry -> Maybe Text
messageId} -> Maybe Text
messageId) (\s :: BatchPutMessageErrorEntry
s@BatchPutMessageErrorEntry' {} Maybe Text
a -> BatchPutMessageErrorEntry
s {$sel:messageId:BatchPutMessageErrorEntry' :: Maybe Text
messageId = Maybe Text
a} :: BatchPutMessageErrorEntry)

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

instance Prelude.Hashable BatchPutMessageErrorEntry

instance Prelude.NFData BatchPutMessageErrorEntry