{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Lambda.Types.OnFailure 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 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
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]
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
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. 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' {$sel:destination:OnFailure' :: Maybe Text
destination = 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 :: Lens' OnFailure (Maybe Text)
onFailure_destination = 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 Data.FromJSON OnFailure where
  parseJSON :: Value -> Parser OnFailure
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OnFailure"
      ( \Object
x ->
          Maybe Text -> OnFailure
OnFailure' 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
"Destination")
      )

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

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

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