{-# 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.SecurityHub.Types.AwsLambdaFunctionDeadLetterConfig
-- 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.SecurityHub.Types.AwsLambdaFunctionDeadLetterConfig where

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

-- | The dead-letter queue for failed asynchronous invocations.
--
-- /See:/ 'newAwsLambdaFunctionDeadLetterConfig' smart constructor.
data AwsLambdaFunctionDeadLetterConfig = AwsLambdaFunctionDeadLetterConfig'
  { -- | The ARN of an SQS queue or SNS topic.
    AwsLambdaFunctionDeadLetterConfig -> Maybe Text
targetArn :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsLambdaFunctionDeadLetterConfig
-> AwsLambdaFunctionDeadLetterConfig -> Bool
(AwsLambdaFunctionDeadLetterConfig
 -> AwsLambdaFunctionDeadLetterConfig -> Bool)
-> (AwsLambdaFunctionDeadLetterConfig
    -> AwsLambdaFunctionDeadLetterConfig -> Bool)
-> Eq AwsLambdaFunctionDeadLetterConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsLambdaFunctionDeadLetterConfig
-> AwsLambdaFunctionDeadLetterConfig -> Bool
$c/= :: AwsLambdaFunctionDeadLetterConfig
-> AwsLambdaFunctionDeadLetterConfig -> Bool
== :: AwsLambdaFunctionDeadLetterConfig
-> AwsLambdaFunctionDeadLetterConfig -> Bool
$c== :: AwsLambdaFunctionDeadLetterConfig
-> AwsLambdaFunctionDeadLetterConfig -> Bool
Prelude.Eq, ReadPrec [AwsLambdaFunctionDeadLetterConfig]
ReadPrec AwsLambdaFunctionDeadLetterConfig
Int -> ReadS AwsLambdaFunctionDeadLetterConfig
ReadS [AwsLambdaFunctionDeadLetterConfig]
(Int -> ReadS AwsLambdaFunctionDeadLetterConfig)
-> ReadS [AwsLambdaFunctionDeadLetterConfig]
-> ReadPrec AwsLambdaFunctionDeadLetterConfig
-> ReadPrec [AwsLambdaFunctionDeadLetterConfig]
-> Read AwsLambdaFunctionDeadLetterConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsLambdaFunctionDeadLetterConfig]
$creadListPrec :: ReadPrec [AwsLambdaFunctionDeadLetterConfig]
readPrec :: ReadPrec AwsLambdaFunctionDeadLetterConfig
$creadPrec :: ReadPrec AwsLambdaFunctionDeadLetterConfig
readList :: ReadS [AwsLambdaFunctionDeadLetterConfig]
$creadList :: ReadS [AwsLambdaFunctionDeadLetterConfig]
readsPrec :: Int -> ReadS AwsLambdaFunctionDeadLetterConfig
$creadsPrec :: Int -> ReadS AwsLambdaFunctionDeadLetterConfig
Prelude.Read, Int -> AwsLambdaFunctionDeadLetterConfig -> ShowS
[AwsLambdaFunctionDeadLetterConfig] -> ShowS
AwsLambdaFunctionDeadLetterConfig -> String
(Int -> AwsLambdaFunctionDeadLetterConfig -> ShowS)
-> (AwsLambdaFunctionDeadLetterConfig -> String)
-> ([AwsLambdaFunctionDeadLetterConfig] -> ShowS)
-> Show AwsLambdaFunctionDeadLetterConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsLambdaFunctionDeadLetterConfig] -> ShowS
$cshowList :: [AwsLambdaFunctionDeadLetterConfig] -> ShowS
show :: AwsLambdaFunctionDeadLetterConfig -> String
$cshow :: AwsLambdaFunctionDeadLetterConfig -> String
showsPrec :: Int -> AwsLambdaFunctionDeadLetterConfig -> ShowS
$cshowsPrec :: Int -> AwsLambdaFunctionDeadLetterConfig -> ShowS
Prelude.Show, (forall x.
 AwsLambdaFunctionDeadLetterConfig
 -> Rep AwsLambdaFunctionDeadLetterConfig x)
-> (forall x.
    Rep AwsLambdaFunctionDeadLetterConfig x
    -> AwsLambdaFunctionDeadLetterConfig)
-> Generic AwsLambdaFunctionDeadLetterConfig
forall x.
Rep AwsLambdaFunctionDeadLetterConfig x
-> AwsLambdaFunctionDeadLetterConfig
forall x.
AwsLambdaFunctionDeadLetterConfig
-> Rep AwsLambdaFunctionDeadLetterConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsLambdaFunctionDeadLetterConfig x
-> AwsLambdaFunctionDeadLetterConfig
$cfrom :: forall x.
AwsLambdaFunctionDeadLetterConfig
-> Rep AwsLambdaFunctionDeadLetterConfig x
Prelude.Generic)

-- |
-- Create a value of 'AwsLambdaFunctionDeadLetterConfig' 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:
--
-- 'targetArn', 'awsLambdaFunctionDeadLetterConfig_targetArn' - The ARN of an SQS queue or SNS topic.
newAwsLambdaFunctionDeadLetterConfig ::
  AwsLambdaFunctionDeadLetterConfig
newAwsLambdaFunctionDeadLetterConfig :: AwsLambdaFunctionDeadLetterConfig
newAwsLambdaFunctionDeadLetterConfig =
  AwsLambdaFunctionDeadLetterConfig' :: Maybe Text -> AwsLambdaFunctionDeadLetterConfig
AwsLambdaFunctionDeadLetterConfig'
    { $sel:targetArn:AwsLambdaFunctionDeadLetterConfig' :: Maybe Text
targetArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of an SQS queue or SNS topic.
awsLambdaFunctionDeadLetterConfig_targetArn :: Lens.Lens' AwsLambdaFunctionDeadLetterConfig (Prelude.Maybe Prelude.Text)
awsLambdaFunctionDeadLetterConfig_targetArn :: (Maybe Text -> f (Maybe Text))
-> AwsLambdaFunctionDeadLetterConfig
-> f AwsLambdaFunctionDeadLetterConfig
awsLambdaFunctionDeadLetterConfig_targetArn = (AwsLambdaFunctionDeadLetterConfig -> Maybe Text)
-> (AwsLambdaFunctionDeadLetterConfig
    -> Maybe Text -> AwsLambdaFunctionDeadLetterConfig)
-> Lens
     AwsLambdaFunctionDeadLetterConfig
     AwsLambdaFunctionDeadLetterConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsLambdaFunctionDeadLetterConfig' {Maybe Text
targetArn :: Maybe Text
$sel:targetArn:AwsLambdaFunctionDeadLetterConfig' :: AwsLambdaFunctionDeadLetterConfig -> Maybe Text
targetArn} -> Maybe Text
targetArn) (\s :: AwsLambdaFunctionDeadLetterConfig
s@AwsLambdaFunctionDeadLetterConfig' {} Maybe Text
a -> AwsLambdaFunctionDeadLetterConfig
s {$sel:targetArn:AwsLambdaFunctionDeadLetterConfig' :: Maybe Text
targetArn = Maybe Text
a} :: AwsLambdaFunctionDeadLetterConfig)

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

instance
  Prelude.Hashable
    AwsLambdaFunctionDeadLetterConfig

instance
  Prelude.NFData
    AwsLambdaFunctionDeadLetterConfig

instance
  Core.ToJSON
    AwsLambdaFunctionDeadLetterConfig
  where
  toJSON :: AwsLambdaFunctionDeadLetterConfig -> Value
toJSON AwsLambdaFunctionDeadLetterConfig' {Maybe Text
targetArn :: Maybe Text
$sel:targetArn:AwsLambdaFunctionDeadLetterConfig' :: AwsLambdaFunctionDeadLetterConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"TargetArn" 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
targetArn]
      )