{-# 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.SQS.Types.BatchResultErrorEntry
-- 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.SQS.Types.BatchResultErrorEntry 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

-- | Gives a detailed description of the result of an action on each entry in
-- the request.
--
-- /See:/ 'newBatchResultErrorEntry' smart constructor.
data BatchResultErrorEntry = BatchResultErrorEntry'
  { -- | A message explaining why the action failed on this entry.
    BatchResultErrorEntry -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The @Id@ of an entry in a batch request.
    BatchResultErrorEntry -> Text
id :: Prelude.Text,
    -- | Specifies whether the error happened due to the caller of the batch API
    -- action.
    BatchResultErrorEntry -> Bool
senderFault :: Prelude.Bool,
    -- | An error code representing why the action failed on this entry.
    BatchResultErrorEntry -> Text
code :: Prelude.Text
  }
  deriving (BatchResultErrorEntry -> BatchResultErrorEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchResultErrorEntry -> BatchResultErrorEntry -> Bool
$c/= :: BatchResultErrorEntry -> BatchResultErrorEntry -> Bool
== :: BatchResultErrorEntry -> BatchResultErrorEntry -> Bool
$c== :: BatchResultErrorEntry -> BatchResultErrorEntry -> Bool
Prelude.Eq, ReadPrec [BatchResultErrorEntry]
ReadPrec BatchResultErrorEntry
Int -> ReadS BatchResultErrorEntry
ReadS [BatchResultErrorEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchResultErrorEntry]
$creadListPrec :: ReadPrec [BatchResultErrorEntry]
readPrec :: ReadPrec BatchResultErrorEntry
$creadPrec :: ReadPrec BatchResultErrorEntry
readList :: ReadS [BatchResultErrorEntry]
$creadList :: ReadS [BatchResultErrorEntry]
readsPrec :: Int -> ReadS BatchResultErrorEntry
$creadsPrec :: Int -> ReadS BatchResultErrorEntry
Prelude.Read, Int -> BatchResultErrorEntry -> ShowS
[BatchResultErrorEntry] -> ShowS
BatchResultErrorEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchResultErrorEntry] -> ShowS
$cshowList :: [BatchResultErrorEntry] -> ShowS
show :: BatchResultErrorEntry -> String
$cshow :: BatchResultErrorEntry -> String
showsPrec :: Int -> BatchResultErrorEntry -> ShowS
$cshowsPrec :: Int -> BatchResultErrorEntry -> ShowS
Prelude.Show, forall x. Rep BatchResultErrorEntry x -> BatchResultErrorEntry
forall x. BatchResultErrorEntry -> Rep BatchResultErrorEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchResultErrorEntry x -> BatchResultErrorEntry
$cfrom :: forall x. BatchResultErrorEntry -> Rep BatchResultErrorEntry x
Prelude.Generic)

-- |
-- Create a value of 'BatchResultErrorEntry' 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:
--
-- 'message', 'batchResultErrorEntry_message' - A message explaining why the action failed on this entry.
--
-- 'id', 'batchResultErrorEntry_id' - The @Id@ of an entry in a batch request.
--
-- 'senderFault', 'batchResultErrorEntry_senderFault' - Specifies whether the error happened due to the caller of the batch API
-- action.
--
-- 'code', 'batchResultErrorEntry_code' - An error code representing why the action failed on this entry.
newBatchResultErrorEntry ::
  -- | 'id'
  Prelude.Text ->
  -- | 'senderFault'
  Prelude.Bool ->
  -- | 'code'
  Prelude.Text ->
  BatchResultErrorEntry
newBatchResultErrorEntry :: Text -> Bool -> Text -> BatchResultErrorEntry
newBatchResultErrorEntry Text
pId_ Bool
pSenderFault_ Text
pCode_ =
  BatchResultErrorEntry'
    { $sel:message:BatchResultErrorEntry' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:id:BatchResultErrorEntry' :: Text
id = Text
pId_,
      $sel:senderFault:BatchResultErrorEntry' :: Bool
senderFault = Bool
pSenderFault_,
      $sel:code:BatchResultErrorEntry' :: Text
code = Text
pCode_
    }

-- | A message explaining why the action failed on this entry.
batchResultErrorEntry_message :: Lens.Lens' BatchResultErrorEntry (Prelude.Maybe Prelude.Text)
batchResultErrorEntry_message :: Lens' BatchResultErrorEntry (Maybe Text)
batchResultErrorEntry_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchResultErrorEntry' {Maybe Text
message :: Maybe Text
$sel:message:BatchResultErrorEntry' :: BatchResultErrorEntry -> Maybe Text
message} -> Maybe Text
message) (\s :: BatchResultErrorEntry
s@BatchResultErrorEntry' {} Maybe Text
a -> BatchResultErrorEntry
s {$sel:message:BatchResultErrorEntry' :: Maybe Text
message = Maybe Text
a} :: BatchResultErrorEntry)

-- | The @Id@ of an entry in a batch request.
batchResultErrorEntry_id :: Lens.Lens' BatchResultErrorEntry Prelude.Text
batchResultErrorEntry_id :: Lens' BatchResultErrorEntry Text
batchResultErrorEntry_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchResultErrorEntry' {Text
id :: Text
$sel:id:BatchResultErrorEntry' :: BatchResultErrorEntry -> Text
id} -> Text
id) (\s :: BatchResultErrorEntry
s@BatchResultErrorEntry' {} Text
a -> BatchResultErrorEntry
s {$sel:id:BatchResultErrorEntry' :: Text
id = Text
a} :: BatchResultErrorEntry)

-- | Specifies whether the error happened due to the caller of the batch API
-- action.
batchResultErrorEntry_senderFault :: Lens.Lens' BatchResultErrorEntry Prelude.Bool
batchResultErrorEntry_senderFault :: Lens' BatchResultErrorEntry Bool
batchResultErrorEntry_senderFault = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchResultErrorEntry' {Bool
senderFault :: Bool
$sel:senderFault:BatchResultErrorEntry' :: BatchResultErrorEntry -> Bool
senderFault} -> Bool
senderFault) (\s :: BatchResultErrorEntry
s@BatchResultErrorEntry' {} Bool
a -> BatchResultErrorEntry
s {$sel:senderFault:BatchResultErrorEntry' :: Bool
senderFault = Bool
a} :: BatchResultErrorEntry)

-- | An error code representing why the action failed on this entry.
batchResultErrorEntry_code :: Lens.Lens' BatchResultErrorEntry Prelude.Text
batchResultErrorEntry_code :: Lens' BatchResultErrorEntry Text
batchResultErrorEntry_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchResultErrorEntry' {Text
code :: Text
$sel:code:BatchResultErrorEntry' :: BatchResultErrorEntry -> Text
code} -> Text
code) (\s :: BatchResultErrorEntry
s@BatchResultErrorEntry' {} Text
a -> BatchResultErrorEntry
s {$sel:code:BatchResultErrorEntry' :: Text
code = Text
a} :: BatchResultErrorEntry)

instance Data.FromXML BatchResultErrorEntry where
  parseXML :: [Node] -> Either String BatchResultErrorEntry
parseXML [Node]
x =
    Maybe Text -> Text -> Bool -> Text -> BatchResultErrorEntry
BatchResultErrorEntry'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Message")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Id")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"SenderFault")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Code")

instance Prelude.Hashable BatchResultErrorEntry where
  hashWithSalt :: Int -> BatchResultErrorEntry -> Int
hashWithSalt Int
_salt BatchResultErrorEntry' {Bool
Maybe Text
Text
code :: Text
senderFault :: Bool
id :: Text
message :: Maybe Text
$sel:code:BatchResultErrorEntry' :: BatchResultErrorEntry -> Text
$sel:senderFault:BatchResultErrorEntry' :: BatchResultErrorEntry -> Bool
$sel:id:BatchResultErrorEntry' :: BatchResultErrorEntry -> Text
$sel:message:BatchResultErrorEntry' :: BatchResultErrorEntry -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
senderFault
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
code

instance Prelude.NFData BatchResultErrorEntry where
  rnf :: BatchResultErrorEntry -> ()
rnf BatchResultErrorEntry' {Bool
Maybe Text
Text
code :: Text
senderFault :: Bool
id :: Text
message :: Maybe Text
$sel:code:BatchResultErrorEntry' :: BatchResultErrorEntry -> Text
$sel:senderFault:BatchResultErrorEntry' :: BatchResultErrorEntry -> Bool
$sel:id:BatchResultErrorEntry' :: BatchResultErrorEntry -> Text
$sel:message:BatchResultErrorEntry' :: BatchResultErrorEntry -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
senderFault
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
code