{-# 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.Lambda.Types.OnFailure
-- 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.Lambda.Types.OnFailure where

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

-- | A destination for events that failed processing.
--
-- /See:/ 'newOnFailure' smart constructor.
data OnFailure = OnFailure'
  { -- | The Amazon Resource Name (ARN) of the destination resource.
    OnFailure -> Maybe Text
destination :: Prelude.Maybe Prelude.Text
  }
  deriving (OnFailure -> OnFailure -> Bool
(OnFailure -> OnFailure -> Bool)
-> (OnFailure -> OnFailure -> Bool) -> Eq OnFailure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OnFailure -> OnFailure -> Bool
$c/= :: OnFailure -> OnFailure -> Bool
== :: OnFailure -> OnFailure -> Bool
$c== :: OnFailure -> OnFailure -> Bool
Prelude.Eq, ReadPrec [OnFailure]
ReadPrec OnFailure
Int -> ReadS OnFailure
ReadS [OnFailure]
(Int -> ReadS OnFailure)
-> ReadS [OnFailure]
-> ReadPrec OnFailure
-> ReadPrec [OnFailure]
-> Read OnFailure
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OnFailure]
$creadListPrec :: ReadPrec [OnFailure]
readPrec :: ReadPrec OnFailure
$creadPrec :: ReadPrec OnFailure
readList :: ReadS [OnFailure]
$creadList :: ReadS [OnFailure]
readsPrec :: Int -> ReadS OnFailure
$creadsPrec :: Int -> ReadS OnFailure
Prelude.Read, Int -> OnFailure -> ShowS
[OnFailure] -> ShowS
OnFailure -> String
(Int -> OnFailure -> ShowS)
-> (OnFailure -> String)
-> ([OnFailure] -> ShowS)
-> Show OnFailure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OnFailure] -> ShowS
$cshowList :: [OnFailure] -> ShowS
show :: OnFailure -> String
$cshow :: OnFailure -> String
showsPrec :: Int -> OnFailure -> ShowS
$cshowsPrec :: Int -> OnFailure -> ShowS
Prelude.Show, (forall x. OnFailure -> Rep OnFailure x)
-> (forall x. Rep OnFailure x -> OnFailure) -> Generic OnFailure
forall x. Rep OnFailure x -> OnFailure
forall x. OnFailure -> Rep OnFailure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OnFailure x -> OnFailure
$cfrom :: forall x. OnFailure -> Rep OnFailure x
Prelude.Generic)

-- |
-- Create a value of 'OnFailure' 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:
--
-- 'destination', 'onFailure_destination' - The Amazon Resource Name (ARN) of the destination resource.
newOnFailure ::
  OnFailure
newOnFailure :: OnFailure
newOnFailure =
  OnFailure' :: Maybe Text -> OnFailure
OnFailure' {$sel:destination:OnFailure' :: Maybe Text
destination = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The Amazon Resource Name (ARN) of the destination resource.
onFailure_destination :: Lens.Lens' OnFailure (Prelude.Maybe Prelude.Text)
onFailure_destination :: (Maybe Text -> f (Maybe Text)) -> OnFailure -> f OnFailure
onFailure_destination = (OnFailure -> Maybe Text)
-> (OnFailure -> Maybe Text -> OnFailure)
-> Lens OnFailure OnFailure (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnFailure' {Maybe Text
destination :: Maybe Text
$sel:destination:OnFailure' :: OnFailure -> Maybe Text
destination} -> Maybe Text
destination) (\s :: OnFailure
s@OnFailure' {} Maybe Text
a -> OnFailure
s {$sel:destination:OnFailure' :: Maybe Text
destination = Maybe Text
a} :: OnFailure)

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

instance Prelude.Hashable OnFailure

instance Prelude.NFData OnFailure

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