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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(DeadLetterConfig -> DeadLetterConfig -> Bool)
-> (DeadLetterConfig -> DeadLetterConfig -> Bool)
-> Eq DeadLetterConfig
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]
(Int -> ReadS DeadLetterConfig)
-> ReadS [DeadLetterConfig]
-> ReadPrec DeadLetterConfig
-> ReadPrec [DeadLetterConfig]
-> Read 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
(Int -> DeadLetterConfig -> ShowS)
-> (DeadLetterConfig -> String)
-> ([DeadLetterConfig] -> ShowS)
-> Show DeadLetterConfig
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. DeadLetterConfig -> Rep DeadLetterConfig x)
-> (forall x. Rep DeadLetterConfig x -> DeadLetterConfig)
-> Generic DeadLetterConfig
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' :: Maybe Text -> DeadLetterConfig
DeadLetterConfig' {$sel:arn:DeadLetterConfig' :: Maybe Text
arn = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeadLetterConfig -> f DeadLetterConfig
deadLetterConfig_arn = (DeadLetterConfig -> Maybe Text)
-> (DeadLetterConfig -> Maybe Text -> DeadLetterConfig)
-> Lens DeadLetterConfig DeadLetterConfig (Maybe Text) (Maybe Text)
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 Core.FromJSON DeadLetterConfig where
  parseJSON :: Value -> Parser DeadLetterConfig
parseJSON =
    String
-> (Object -> Parser DeadLetterConfig)
-> Value
-> Parser DeadLetterConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeadLetterConfig"
      ( \Object
x ->
          Maybe Text -> DeadLetterConfig
DeadLetterConfig' (Maybe Text -> DeadLetterConfig)
-> Parser (Maybe Text) -> Parser DeadLetterConfig
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
"Arn")
      )

instance Prelude.Hashable DeadLetterConfig

instance Prelude.NFData DeadLetterConfig

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