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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(BatchResultErrorEntry -> BatchResultErrorEntry -> Bool)
-> (BatchResultErrorEntry -> BatchResultErrorEntry -> Bool)
-> Eq BatchResultErrorEntry
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]
(Int -> ReadS BatchResultErrorEntry)
-> ReadS [BatchResultErrorEntry]
-> ReadPrec BatchResultErrorEntry
-> ReadPrec [BatchResultErrorEntry]
-> Read 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
(Int -> BatchResultErrorEntry -> ShowS)
-> (BatchResultErrorEntry -> String)
-> ([BatchResultErrorEntry] -> ShowS)
-> Show BatchResultErrorEntry
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. BatchResultErrorEntry -> Rep BatchResultErrorEntry x)
-> (forall x. Rep BatchResultErrorEntry x -> BatchResultErrorEntry)
-> Generic BatchResultErrorEntry
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' :: Maybe Text -> Text -> Bool -> Text -> BatchResultErrorEntry
BatchResultErrorEntry'
    { $sel:message:BatchResultErrorEntry' :: Maybe Text
message = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> BatchResultErrorEntry -> f BatchResultErrorEntry
batchResultErrorEntry_message = (BatchResultErrorEntry -> Maybe Text)
-> (BatchResultErrorEntry -> Maybe Text -> BatchResultErrorEntry)
-> Lens
     BatchResultErrorEntry
     BatchResultErrorEntry
     (Maybe Text)
     (Maybe Text)
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 :: (Text -> f Text)
-> BatchResultErrorEntry -> f BatchResultErrorEntry
batchResultErrorEntry_id = (BatchResultErrorEntry -> Text)
-> (BatchResultErrorEntry -> Text -> BatchResultErrorEntry)
-> Lens BatchResultErrorEntry BatchResultErrorEntry Text Text
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 :: (Bool -> f Bool)
-> BatchResultErrorEntry -> f BatchResultErrorEntry
batchResultErrorEntry_senderFault = (BatchResultErrorEntry -> Bool)
-> (BatchResultErrorEntry -> Bool -> BatchResultErrorEntry)
-> Lens BatchResultErrorEntry BatchResultErrorEntry Bool Bool
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 :: (Text -> f Text)
-> BatchResultErrorEntry -> f BatchResultErrorEntry
batchResultErrorEntry_code = (BatchResultErrorEntry -> Text)
-> (BatchResultErrorEntry -> Text -> BatchResultErrorEntry)
-> Lens BatchResultErrorEntry BatchResultErrorEntry Text Text
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 Core.FromXML BatchResultErrorEntry where
  parseXML :: [Node] -> Either String BatchResultErrorEntry
parseXML [Node]
x =
    Maybe Text -> Text -> Bool -> Text -> BatchResultErrorEntry
BatchResultErrorEntry'
      (Maybe Text -> Text -> Bool -> Text -> BatchResultErrorEntry)
-> Either String (Maybe Text)
-> Either String (Text -> Bool -> Text -> BatchResultErrorEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Message")
      Either String (Text -> Bool -> Text -> BatchResultErrorEntry)
-> Either String Text
-> Either String (Bool -> Text -> BatchResultErrorEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Id")
      Either String (Bool -> Text -> BatchResultErrorEntry)
-> Either String Bool
-> Either String (Text -> BatchResultErrorEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Bool
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"SenderFault")
      Either String (Text -> BatchResultErrorEntry)
-> Either String Text -> Either String BatchResultErrorEntry
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Code")

instance Prelude.Hashable BatchResultErrorEntry

instance Prelude.NFData BatchResultErrorEntry