{-# 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.SESV2.Types.SnsDestination
-- 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.SESV2.Types.SnsDestination where

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

-- | An object that defines an Amazon SNS destination for email events. You
-- can use Amazon SNS to send notification when certain email events occur.
--
-- /See:/ 'newSnsDestination' smart constructor.
data SnsDestination = SnsDestination'
  { -- | The Amazon Resource Name (ARN) of the Amazon SNS topic to publish email
    -- events to. For more information about Amazon SNS topics, see the
    -- <https://docs.aws.amazon.com/sns/latest/dg/CreateTopic.html Amazon SNS Developer Guide>.
    SnsDestination -> Text
topicArn :: Prelude.Text
  }
  deriving (SnsDestination -> SnsDestination -> Bool
(SnsDestination -> SnsDestination -> Bool)
-> (SnsDestination -> SnsDestination -> Bool) -> Eq SnsDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnsDestination -> SnsDestination -> Bool
$c/= :: SnsDestination -> SnsDestination -> Bool
== :: SnsDestination -> SnsDestination -> Bool
$c== :: SnsDestination -> SnsDestination -> Bool
Prelude.Eq, ReadPrec [SnsDestination]
ReadPrec SnsDestination
Int -> ReadS SnsDestination
ReadS [SnsDestination]
(Int -> ReadS SnsDestination)
-> ReadS [SnsDestination]
-> ReadPrec SnsDestination
-> ReadPrec [SnsDestination]
-> Read SnsDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnsDestination]
$creadListPrec :: ReadPrec [SnsDestination]
readPrec :: ReadPrec SnsDestination
$creadPrec :: ReadPrec SnsDestination
readList :: ReadS [SnsDestination]
$creadList :: ReadS [SnsDestination]
readsPrec :: Int -> ReadS SnsDestination
$creadsPrec :: Int -> ReadS SnsDestination
Prelude.Read, Int -> SnsDestination -> ShowS
[SnsDestination] -> ShowS
SnsDestination -> String
(Int -> SnsDestination -> ShowS)
-> (SnsDestination -> String)
-> ([SnsDestination] -> ShowS)
-> Show SnsDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnsDestination] -> ShowS
$cshowList :: [SnsDestination] -> ShowS
show :: SnsDestination -> String
$cshow :: SnsDestination -> String
showsPrec :: Int -> SnsDestination -> ShowS
$cshowsPrec :: Int -> SnsDestination -> ShowS
Prelude.Show, (forall x. SnsDestination -> Rep SnsDestination x)
-> (forall x. Rep SnsDestination x -> SnsDestination)
-> Generic SnsDestination
forall x. Rep SnsDestination x -> SnsDestination
forall x. SnsDestination -> Rep SnsDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnsDestination x -> SnsDestination
$cfrom :: forall x. SnsDestination -> Rep SnsDestination x
Prelude.Generic)

-- |
-- Create a value of 'SnsDestination' 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:
--
-- 'topicArn', 'snsDestination_topicArn' - The Amazon Resource Name (ARN) of the Amazon SNS topic to publish email
-- events to. For more information about Amazon SNS topics, see the
-- <https://docs.aws.amazon.com/sns/latest/dg/CreateTopic.html Amazon SNS Developer Guide>.
newSnsDestination ::
  -- | 'topicArn'
  Prelude.Text ->
  SnsDestination
newSnsDestination :: Text -> SnsDestination
newSnsDestination Text
pTopicArn_ =
  SnsDestination' :: Text -> SnsDestination
SnsDestination' {$sel:topicArn:SnsDestination' :: Text
topicArn = Text
pTopicArn_}

-- | The Amazon Resource Name (ARN) of the Amazon SNS topic to publish email
-- events to. For more information about Amazon SNS topics, see the
-- <https://docs.aws.amazon.com/sns/latest/dg/CreateTopic.html Amazon SNS Developer Guide>.
snsDestination_topicArn :: Lens.Lens' SnsDestination Prelude.Text
snsDestination_topicArn :: (Text -> f Text) -> SnsDestination -> f SnsDestination
snsDestination_topicArn = (SnsDestination -> Text)
-> (SnsDestination -> Text -> SnsDestination)
-> Lens SnsDestination SnsDestination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnsDestination' {Text
topicArn :: Text
$sel:topicArn:SnsDestination' :: SnsDestination -> Text
topicArn} -> Text
topicArn) (\s :: SnsDestination
s@SnsDestination' {} Text
a -> SnsDestination
s {$sel:topicArn:SnsDestination' :: Text
topicArn = Text
a} :: SnsDestination)

instance Core.FromJSON SnsDestination where
  parseJSON :: Value -> Parser SnsDestination
parseJSON =
    String
-> (Object -> Parser SnsDestination)
-> Value
-> Parser SnsDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SnsDestination"
      ( \Object
x ->
          Text -> SnsDestination
SnsDestination' (Text -> SnsDestination) -> Parser Text -> Parser SnsDestination
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TopicArn")
      )

instance Prelude.Hashable SnsDestination

instance Prelude.NFData SnsDestination

instance Core.ToJSON SnsDestination where
  toJSON :: SnsDestination -> Value
toJSON SnsDestination' {Text
topicArn :: Text
$sel:topicArn:SnsDestination' :: SnsDestination -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TopicArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
topicArn)]
      )