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

-- | 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 that you want 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
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]
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
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. 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 that you want 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' {$sel:topicArn:SnsDestination' :: Text
topicArn = Text
pTopicArn_}

-- | The Amazon Resource Name (ARN) of the Amazon SNS topic that you want 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 :: Lens' SnsDestination Text
snsDestination_topicArn = 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 Data.FromJSON SnsDestination where
  parseJSON :: Value -> Parser SnsDestination
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SnsDestination"
      ( \Object
x ->
          Text -> SnsDestination
SnsDestination' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"TopicArn")
      )

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

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

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