{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SSMIncidents.Types.NotificationTargetItem 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

-- | 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
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]
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
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. 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'
    { $sel:snsTopicArn:NotificationTargetItem' :: Maybe Text
snsTopicArn =
        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 :: Lens' NotificationTargetItem (Maybe Text)
notificationTargetItem_snsTopicArn = 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 Data.FromJSON NotificationTargetItem where
  parseJSON :: Value -> Parser NotificationTargetItem
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NotificationTargetItem"
      ( \Object
x ->
          Maybe Text -> NotificationTargetItem
NotificationTargetItem'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"snsTopicArn")
      )

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

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

instance Data.ToJSON NotificationTargetItem where
  toJSON :: NotificationTargetItem -> Value
toJSON NotificationTargetItem' {Maybe Text
snsTopicArn :: Maybe Text
$sel:snsTopicArn:NotificationTargetItem' :: NotificationTargetItem -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"snsTopicArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
snsTopicArn]
      )