{-# 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.CloudWatchEvents.Types.DeadLetterConfig
-- 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.CloudWatchEvents.Types.DeadLetterConfig 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

-- | A @DeadLetterConfig@ object that contains information about a
-- dead-letter queue configuration.
--
-- /See:/ 'newDeadLetterConfig' smart constructor.
data DeadLetterConfig = DeadLetterConfig'
  { -- | The ARN of the SQS queue specified as the target for the dead-letter
    -- queue.
    DeadLetterConfig -> Maybe Text
arn :: Prelude.Maybe Prelude.Text
  }
  deriving (DeadLetterConfig -> DeadLetterConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeadLetterConfig -> DeadLetterConfig -> Bool
$c/= :: DeadLetterConfig -> DeadLetterConfig -> Bool
== :: DeadLetterConfig -> DeadLetterConfig -> Bool
$c== :: DeadLetterConfig -> DeadLetterConfig -> Bool
Prelude.Eq, ReadPrec [DeadLetterConfig]
ReadPrec DeadLetterConfig
Int -> ReadS DeadLetterConfig
ReadS [DeadLetterConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeadLetterConfig]
$creadListPrec :: ReadPrec [DeadLetterConfig]
readPrec :: ReadPrec DeadLetterConfig
$creadPrec :: ReadPrec DeadLetterConfig
readList :: ReadS [DeadLetterConfig]
$creadList :: ReadS [DeadLetterConfig]
readsPrec :: Int -> ReadS DeadLetterConfig
$creadsPrec :: Int -> ReadS DeadLetterConfig
Prelude.Read, Int -> DeadLetterConfig -> ShowS
[DeadLetterConfig] -> ShowS
DeadLetterConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeadLetterConfig] -> ShowS
$cshowList :: [DeadLetterConfig] -> ShowS
show :: DeadLetterConfig -> String
$cshow :: DeadLetterConfig -> String
showsPrec :: Int -> DeadLetterConfig -> ShowS
$cshowsPrec :: Int -> DeadLetterConfig -> ShowS
Prelude.Show, forall x. Rep DeadLetterConfig x -> DeadLetterConfig
forall x. DeadLetterConfig -> Rep DeadLetterConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeadLetterConfig x -> DeadLetterConfig
$cfrom :: forall x. DeadLetterConfig -> Rep DeadLetterConfig x
Prelude.Generic)

-- |
-- Create a value of 'DeadLetterConfig' 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:
--
-- 'arn', 'deadLetterConfig_arn' - The ARN of the SQS queue specified as the target for the dead-letter
-- queue.
newDeadLetterConfig ::
  DeadLetterConfig
newDeadLetterConfig :: DeadLetterConfig
newDeadLetterConfig =
  DeadLetterConfig' {$sel:arn:DeadLetterConfig' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing}

-- | The ARN of the SQS queue specified as the target for the dead-letter
-- queue.
deadLetterConfig_arn :: Lens.Lens' DeadLetterConfig (Prelude.Maybe Prelude.Text)
deadLetterConfig_arn :: Lens' DeadLetterConfig (Maybe Text)
deadLetterConfig_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeadLetterConfig' {Maybe Text
arn :: Maybe Text
$sel:arn:DeadLetterConfig' :: DeadLetterConfig -> Maybe Text
arn} -> Maybe Text
arn) (\s :: DeadLetterConfig
s@DeadLetterConfig' {} Maybe Text
a -> DeadLetterConfig
s {$sel:arn:DeadLetterConfig' :: Maybe Text
arn = Maybe Text
a} :: DeadLetterConfig)

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

instance Prelude.Hashable DeadLetterConfig where
  hashWithSalt :: Int -> DeadLetterConfig -> Int
hashWithSalt Int
_salt DeadLetterConfig' {Maybe Text
arn :: Maybe Text
$sel:arn:DeadLetterConfig' :: DeadLetterConfig -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn

instance Prelude.NFData DeadLetterConfig where
  rnf :: DeadLetterConfig -> ()
rnf DeadLetterConfig' {Maybe Text
arn :: Maybe Text
$sel:arn:DeadLetterConfig' :: DeadLetterConfig -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn

instance Data.ToJSON DeadLetterConfig where
  toJSON :: DeadLetterConfig -> Value
toJSON DeadLetterConfig' {Maybe Text
arn :: Maybe Text
$sel:arn:DeadLetterConfig' :: DeadLetterConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      (forall a. [Maybe a] -> [a]
Prelude.catMaybes [(Key
"Arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
arn])