{-# 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.DevOpsGuru.Types.SnsChannelConfig
-- 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.DevOpsGuru.Types.SnsChannelConfig where

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

-- | Contains the Amazon Resource Name (ARN) of an Amazon Simple Notification
-- Service topic.
--
-- If you use an Amazon SNS topic in another account, you must attach a
-- policy to it that grants DevOps Guru permission to it notifications.
-- DevOps Guru adds the required policy on your behalf to send
-- notifications using Amazon SNS in your account. For more information,
-- see
-- <https://docs.aws.amazon.com/devops-guru/latest/userguide/sns-required-permissions.html Permissions for cross account Amazon SNS topics>.
--
-- If you use an Amazon SNS topic that is encrypted by an AWS Key
-- Management Service customer-managed key (CMK), then you must add
-- permissions to the CMK. For more information, see
-- <https://docs.aws.amazon.com/devops-guru/latest/userguide/sns-kms-permissions.html Permissions for AWS KMS–encrypted Amazon SNS topics>.
--
-- /See:/ 'newSnsChannelConfig' smart constructor.
data SnsChannelConfig = SnsChannelConfig'
  { -- | The Amazon Resource Name (ARN) of an Amazon Simple Notification Service
    -- topic.
    SnsChannelConfig -> Maybe Text
topicArn :: Prelude.Maybe Prelude.Text
  }
  deriving (SnsChannelConfig -> SnsChannelConfig -> Bool
(SnsChannelConfig -> SnsChannelConfig -> Bool)
-> (SnsChannelConfig -> SnsChannelConfig -> Bool)
-> Eq SnsChannelConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnsChannelConfig -> SnsChannelConfig -> Bool
$c/= :: SnsChannelConfig -> SnsChannelConfig -> Bool
== :: SnsChannelConfig -> SnsChannelConfig -> Bool
$c== :: SnsChannelConfig -> SnsChannelConfig -> Bool
Prelude.Eq, ReadPrec [SnsChannelConfig]
ReadPrec SnsChannelConfig
Int -> ReadS SnsChannelConfig
ReadS [SnsChannelConfig]
(Int -> ReadS SnsChannelConfig)
-> ReadS [SnsChannelConfig]
-> ReadPrec SnsChannelConfig
-> ReadPrec [SnsChannelConfig]
-> Read SnsChannelConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnsChannelConfig]
$creadListPrec :: ReadPrec [SnsChannelConfig]
readPrec :: ReadPrec SnsChannelConfig
$creadPrec :: ReadPrec SnsChannelConfig
readList :: ReadS [SnsChannelConfig]
$creadList :: ReadS [SnsChannelConfig]
readsPrec :: Int -> ReadS SnsChannelConfig
$creadsPrec :: Int -> ReadS SnsChannelConfig
Prelude.Read, Int -> SnsChannelConfig -> ShowS
[SnsChannelConfig] -> ShowS
SnsChannelConfig -> String
(Int -> SnsChannelConfig -> ShowS)
-> (SnsChannelConfig -> String)
-> ([SnsChannelConfig] -> ShowS)
-> Show SnsChannelConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnsChannelConfig] -> ShowS
$cshowList :: [SnsChannelConfig] -> ShowS
show :: SnsChannelConfig -> String
$cshow :: SnsChannelConfig -> String
showsPrec :: Int -> SnsChannelConfig -> ShowS
$cshowsPrec :: Int -> SnsChannelConfig -> ShowS
Prelude.Show, (forall x. SnsChannelConfig -> Rep SnsChannelConfig x)
-> (forall x. Rep SnsChannelConfig x -> SnsChannelConfig)
-> Generic SnsChannelConfig
forall x. Rep SnsChannelConfig x -> SnsChannelConfig
forall x. SnsChannelConfig -> Rep SnsChannelConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnsChannelConfig x -> SnsChannelConfig
$cfrom :: forall x. SnsChannelConfig -> Rep SnsChannelConfig x
Prelude.Generic)

-- |
-- Create a value of 'SnsChannelConfig' 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', 'snsChannelConfig_topicArn' - The Amazon Resource Name (ARN) of an Amazon Simple Notification Service
-- topic.
newSnsChannelConfig ::
  SnsChannelConfig
newSnsChannelConfig :: SnsChannelConfig
newSnsChannelConfig =
  SnsChannelConfig' :: Maybe Text -> SnsChannelConfig
SnsChannelConfig' {$sel:topicArn:SnsChannelConfig' :: Maybe Text
topicArn = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The Amazon Resource Name (ARN) of an Amazon Simple Notification Service
-- topic.
snsChannelConfig_topicArn :: Lens.Lens' SnsChannelConfig (Prelude.Maybe Prelude.Text)
snsChannelConfig_topicArn :: (Maybe Text -> f (Maybe Text))
-> SnsChannelConfig -> f SnsChannelConfig
snsChannelConfig_topicArn = (SnsChannelConfig -> Maybe Text)
-> (SnsChannelConfig -> Maybe Text -> SnsChannelConfig)
-> Lens SnsChannelConfig SnsChannelConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnsChannelConfig' {Maybe Text
topicArn :: Maybe Text
$sel:topicArn:SnsChannelConfig' :: SnsChannelConfig -> Maybe Text
topicArn} -> Maybe Text
topicArn) (\s :: SnsChannelConfig
s@SnsChannelConfig' {} Maybe Text
a -> SnsChannelConfig
s {$sel:topicArn:SnsChannelConfig' :: Maybe Text
topicArn = Maybe Text
a} :: SnsChannelConfig)

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

instance Prelude.NFData SnsChannelConfig

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