{-# 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.SSMIncidents.Types.NotificationTargetItem
-- 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.SSMIncidents.Types.NotificationTargetItem where

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

-- | The SNS targets that are notified when updates are made to an incident.
--
-- /See:/ 'newNotificationTargetItem' smart constructor.
data NotificationTargetItem = NotificationTargetItem'
  { -- | The Amazon Resource Name (ARN) of the SNS topic.
    NotificationTargetItem -> Maybe Text
snsTopicArn :: Prelude.Maybe Prelude.Text
  }
  deriving (NotificationTargetItem -> NotificationTargetItem -> Bool
(NotificationTargetItem -> NotificationTargetItem -> Bool)
-> (NotificationTargetItem -> NotificationTargetItem -> Bool)
-> Eq NotificationTargetItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotificationTargetItem -> NotificationTargetItem -> Bool
$c/= :: NotificationTargetItem -> NotificationTargetItem -> Bool
== :: NotificationTargetItem -> NotificationTargetItem -> Bool
$c== :: NotificationTargetItem -> NotificationTargetItem -> Bool
Prelude.Eq, ReadPrec [NotificationTargetItem]
ReadPrec NotificationTargetItem
Int -> ReadS NotificationTargetItem
ReadS [NotificationTargetItem]
(Int -> ReadS NotificationTargetItem)
-> ReadS [NotificationTargetItem]
-> ReadPrec NotificationTargetItem
-> ReadPrec [NotificationTargetItem]
-> Read NotificationTargetItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotificationTargetItem]
$creadListPrec :: ReadPrec [NotificationTargetItem]
readPrec :: ReadPrec NotificationTargetItem
$creadPrec :: ReadPrec NotificationTargetItem
readList :: ReadS [NotificationTargetItem]
$creadList :: ReadS [NotificationTargetItem]
readsPrec :: Int -> ReadS NotificationTargetItem
$creadsPrec :: Int -> ReadS NotificationTargetItem
Prelude.Read, Int -> NotificationTargetItem -> ShowS
[NotificationTargetItem] -> ShowS
NotificationTargetItem -> String
(Int -> NotificationTargetItem -> ShowS)
-> (NotificationTargetItem -> String)
-> ([NotificationTargetItem] -> ShowS)
-> Show NotificationTargetItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotificationTargetItem] -> ShowS
$cshowList :: [NotificationTargetItem] -> ShowS
show :: NotificationTargetItem -> String
$cshow :: NotificationTargetItem -> String
showsPrec :: Int -> NotificationTargetItem -> ShowS
$cshowsPrec :: Int -> NotificationTargetItem -> ShowS
Prelude.Show, (forall x. NotificationTargetItem -> Rep NotificationTargetItem x)
-> (forall x.
    Rep NotificationTargetItem x -> NotificationTargetItem)
-> Generic NotificationTargetItem
forall x. Rep NotificationTargetItem x -> NotificationTargetItem
forall x. NotificationTargetItem -> Rep NotificationTargetItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NotificationTargetItem x -> NotificationTargetItem
$cfrom :: forall x. NotificationTargetItem -> Rep NotificationTargetItem x
Prelude.Generic)

-- |
-- Create a value of 'NotificationTargetItem' 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:
--
-- 'snsTopicArn', 'notificationTargetItem_snsTopicArn' - The Amazon Resource Name (ARN) of the SNS topic.
newNotificationTargetItem ::
  NotificationTargetItem
newNotificationTargetItem :: NotificationTargetItem
newNotificationTargetItem =
  NotificationTargetItem' :: Maybe Text -> NotificationTargetItem
NotificationTargetItem'
    { $sel:snsTopicArn:NotificationTargetItem' :: Maybe Text
snsTopicArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the SNS topic.
notificationTargetItem_snsTopicArn :: Lens.Lens' NotificationTargetItem (Prelude.Maybe Prelude.Text)
notificationTargetItem_snsTopicArn :: (Maybe Text -> f (Maybe Text))
-> NotificationTargetItem -> f NotificationTargetItem
notificationTargetItem_snsTopicArn = (NotificationTargetItem -> Maybe Text)
-> (NotificationTargetItem -> Maybe Text -> NotificationTargetItem)
-> Lens
     NotificationTargetItem
     NotificationTargetItem
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationTargetItem' {Maybe Text
snsTopicArn :: Maybe Text
$sel:snsTopicArn:NotificationTargetItem' :: NotificationTargetItem -> Maybe Text
snsTopicArn} -> Maybe Text
snsTopicArn) (\s :: NotificationTargetItem
s@NotificationTargetItem' {} Maybe Text
a -> NotificationTargetItem
s {$sel:snsTopicArn:NotificationTargetItem' :: Maybe Text
snsTopicArn = Maybe Text
a} :: NotificationTargetItem)

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

instance Prelude.Hashable NotificationTargetItem

instance Prelude.NFData NotificationTargetItem

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