{-# 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.OnSuccess
-- 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.OnSuccess where

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

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

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

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

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

instance Prelude.NFData OnSuccess

instance Core.ToJSON OnSuccess where
  toJSON :: OnSuccess -> Value
toJSON OnSuccess' {Maybe Text
destination :: Maybe Text
$sel:destination:OnSuccess' :: OnSuccess -> 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]
      )