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

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

-- | An object that contains information about an event destination that
-- sends data to Amazon SNS.
--
-- /See:/ 'newSnsDestination' smart constructor.
data SnsDestination = SnsDestination'
  { -- | The Amazon Resource Name (ARN) of the Amazon SNS topic that you want to
    -- publish events to.
    SnsDestination -> Maybe Text
topicArn :: Prelude.Maybe 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 that you want to
-- publish events to.
newSnsDestination ::
  SnsDestination
newSnsDestination :: SnsDestination
newSnsDestination =
  SnsDestination' :: Maybe Text -> SnsDestination
SnsDestination' {$sel:topicArn:SnsDestination' :: Maybe Text
topicArn = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The Amazon Resource Name (ARN) of the Amazon SNS topic that you want to
-- publish events to.
snsDestination_topicArn :: Lens.Lens' SnsDestination (Prelude.Maybe Prelude.Text)
snsDestination_topicArn :: (Maybe Text -> f (Maybe Text))
-> SnsDestination -> f SnsDestination
snsDestination_topicArn = (SnsDestination -> Maybe Text)
-> (SnsDestination -> Maybe Text -> SnsDestination)
-> Lens SnsDestination SnsDestination (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnsDestination' {Maybe Text
topicArn :: Maybe Text
$sel:topicArn:SnsDestination' :: SnsDestination -> Maybe Text
topicArn} -> Maybe Text
topicArn) (\s :: SnsDestination
s@SnsDestination' {} Maybe Text
a -> SnsDestination
s {$sel:topicArn:SnsDestination' :: Maybe Text
topicArn = Maybe 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 ->
          Maybe Text -> SnsDestination
SnsDestination' (Maybe Text -> SnsDestination)
-> Parser (Maybe Text) -> Parser SnsDestination
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
"TopicArn")
      )

instance Prelude.Hashable SnsDestination

instance Prelude.NFData SnsDestination

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