{-# 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.SSM.Types.NotificationConfig
-- 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.SSM.Types.NotificationConfig 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
import Amazonka.SSM.Types.NotificationEvent
import Amazonka.SSM.Types.NotificationType

-- | Configurations for sending notifications.
--
-- /See:/ 'newNotificationConfig' smart constructor.
data NotificationConfig = NotificationConfig'
  { -- | An Amazon Resource Name (ARN) for an Amazon Simple Notification Service
    -- (Amazon SNS) topic. Run Command pushes notifications about command
    -- status changes to this topic.
    NotificationConfig -> Maybe Text
notificationArn :: Prelude.Maybe Prelude.Text,
    -- | The different events for which you can receive notifications. To learn
    -- more about these events, see
    -- <https://docs.aws.amazon.com/systems-manager/latest/userguide/monitoring-sns-notifications.html Monitoring Systems Manager status changes using Amazon SNS notifications>
    -- in the /Amazon Web Services Systems Manager User Guide/.
    NotificationConfig -> Maybe [NotificationEvent]
notificationEvents :: Prelude.Maybe [NotificationEvent],
    -- | The type of notification.
    --
    -- -   @Command@: Receive notification when the status of a command
    --     changes.
    --
    -- -   @Invocation@: For commands sent to multiple managed nodes, receive
    --     notification on a per-node basis when the status of a command
    --     changes.
    NotificationConfig -> Maybe NotificationType
notificationType :: Prelude.Maybe NotificationType
  }
  deriving (NotificationConfig -> NotificationConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotificationConfig -> NotificationConfig -> Bool
$c/= :: NotificationConfig -> NotificationConfig -> Bool
== :: NotificationConfig -> NotificationConfig -> Bool
$c== :: NotificationConfig -> NotificationConfig -> Bool
Prelude.Eq, ReadPrec [NotificationConfig]
ReadPrec NotificationConfig
Int -> ReadS NotificationConfig
ReadS [NotificationConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotificationConfig]
$creadListPrec :: ReadPrec [NotificationConfig]
readPrec :: ReadPrec NotificationConfig
$creadPrec :: ReadPrec NotificationConfig
readList :: ReadS [NotificationConfig]
$creadList :: ReadS [NotificationConfig]
readsPrec :: Int -> ReadS NotificationConfig
$creadsPrec :: Int -> ReadS NotificationConfig
Prelude.Read, Int -> NotificationConfig -> ShowS
[NotificationConfig] -> ShowS
NotificationConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotificationConfig] -> ShowS
$cshowList :: [NotificationConfig] -> ShowS
show :: NotificationConfig -> String
$cshow :: NotificationConfig -> String
showsPrec :: Int -> NotificationConfig -> ShowS
$cshowsPrec :: Int -> NotificationConfig -> ShowS
Prelude.Show, forall x. Rep NotificationConfig x -> NotificationConfig
forall x. NotificationConfig -> Rep NotificationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NotificationConfig x -> NotificationConfig
$cfrom :: forall x. NotificationConfig -> Rep NotificationConfig x
Prelude.Generic)

-- |
-- Create a value of 'NotificationConfig' 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:
--
-- 'notificationArn', 'notificationConfig_notificationArn' - An Amazon Resource Name (ARN) for an Amazon Simple Notification Service
-- (Amazon SNS) topic. Run Command pushes notifications about command
-- status changes to this topic.
--
-- 'notificationEvents', 'notificationConfig_notificationEvents' - The different events for which you can receive notifications. To learn
-- more about these events, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/monitoring-sns-notifications.html Monitoring Systems Manager status changes using Amazon SNS notifications>
-- in the /Amazon Web Services Systems Manager User Guide/.
--
-- 'notificationType', 'notificationConfig_notificationType' - The type of notification.
--
-- -   @Command@: Receive notification when the status of a command
--     changes.
--
-- -   @Invocation@: For commands sent to multiple managed nodes, receive
--     notification on a per-node basis when the status of a command
--     changes.
newNotificationConfig ::
  NotificationConfig
newNotificationConfig :: NotificationConfig
newNotificationConfig =
  NotificationConfig'
    { $sel:notificationArn:NotificationConfig' :: Maybe Text
notificationArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:notificationEvents:NotificationConfig' :: Maybe [NotificationEvent]
notificationEvents = forall a. Maybe a
Prelude.Nothing,
      $sel:notificationType:NotificationConfig' :: Maybe NotificationType
notificationType = forall a. Maybe a
Prelude.Nothing
    }

-- | An Amazon Resource Name (ARN) for an Amazon Simple Notification Service
-- (Amazon SNS) topic. Run Command pushes notifications about command
-- status changes to this topic.
notificationConfig_notificationArn :: Lens.Lens' NotificationConfig (Prelude.Maybe Prelude.Text)
notificationConfig_notificationArn :: Lens' NotificationConfig (Maybe Text)
notificationConfig_notificationArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationConfig' {Maybe Text
notificationArn :: Maybe Text
$sel:notificationArn:NotificationConfig' :: NotificationConfig -> Maybe Text
notificationArn} -> Maybe Text
notificationArn) (\s :: NotificationConfig
s@NotificationConfig' {} Maybe Text
a -> NotificationConfig
s {$sel:notificationArn:NotificationConfig' :: Maybe Text
notificationArn = Maybe Text
a} :: NotificationConfig)

-- | The different events for which you can receive notifications. To learn
-- more about these events, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/monitoring-sns-notifications.html Monitoring Systems Manager status changes using Amazon SNS notifications>
-- in the /Amazon Web Services Systems Manager User Guide/.
notificationConfig_notificationEvents :: Lens.Lens' NotificationConfig (Prelude.Maybe [NotificationEvent])
notificationConfig_notificationEvents :: Lens' NotificationConfig (Maybe [NotificationEvent])
notificationConfig_notificationEvents = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationConfig' {Maybe [NotificationEvent]
notificationEvents :: Maybe [NotificationEvent]
$sel:notificationEvents:NotificationConfig' :: NotificationConfig -> Maybe [NotificationEvent]
notificationEvents} -> Maybe [NotificationEvent]
notificationEvents) (\s :: NotificationConfig
s@NotificationConfig' {} Maybe [NotificationEvent]
a -> NotificationConfig
s {$sel:notificationEvents:NotificationConfig' :: Maybe [NotificationEvent]
notificationEvents = Maybe [NotificationEvent]
a} :: NotificationConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of notification.
--
-- -   @Command@: Receive notification when the status of a command
--     changes.
--
-- -   @Invocation@: For commands sent to multiple managed nodes, receive
--     notification on a per-node basis when the status of a command
--     changes.
notificationConfig_notificationType :: Lens.Lens' NotificationConfig (Prelude.Maybe NotificationType)
notificationConfig_notificationType :: Lens' NotificationConfig (Maybe NotificationType)
notificationConfig_notificationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationConfig' {Maybe NotificationType
notificationType :: Maybe NotificationType
$sel:notificationType:NotificationConfig' :: NotificationConfig -> Maybe NotificationType
notificationType} -> Maybe NotificationType
notificationType) (\s :: NotificationConfig
s@NotificationConfig' {} Maybe NotificationType
a -> NotificationConfig
s {$sel:notificationType:NotificationConfig' :: Maybe NotificationType
notificationType = Maybe NotificationType
a} :: NotificationConfig)

instance Data.FromJSON NotificationConfig where
  parseJSON :: Value -> Parser NotificationConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NotificationConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe [NotificationEvent]
-> Maybe NotificationType
-> NotificationConfig
NotificationConfig'
            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
"NotificationArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NotificationEvents"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NotificationType")
      )

instance Prelude.Hashable NotificationConfig where
  hashWithSalt :: Int -> NotificationConfig -> Int
hashWithSalt Int
_salt NotificationConfig' {Maybe [NotificationEvent]
Maybe Text
Maybe NotificationType
notificationType :: Maybe NotificationType
notificationEvents :: Maybe [NotificationEvent]
notificationArn :: Maybe Text
$sel:notificationType:NotificationConfig' :: NotificationConfig -> Maybe NotificationType
$sel:notificationEvents:NotificationConfig' :: NotificationConfig -> Maybe [NotificationEvent]
$sel:notificationArn:NotificationConfig' :: NotificationConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
notificationArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [NotificationEvent]
notificationEvents
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NotificationType
notificationType

instance Prelude.NFData NotificationConfig where
  rnf :: NotificationConfig -> ()
rnf NotificationConfig' {Maybe [NotificationEvent]
Maybe Text
Maybe NotificationType
notificationType :: Maybe NotificationType
notificationEvents :: Maybe [NotificationEvent]
notificationArn :: Maybe Text
$sel:notificationType:NotificationConfig' :: NotificationConfig -> Maybe NotificationType
$sel:notificationEvents:NotificationConfig' :: NotificationConfig -> Maybe [NotificationEvent]
$sel:notificationArn:NotificationConfig' :: NotificationConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
notificationArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [NotificationEvent]
notificationEvents
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NotificationType
notificationType

instance Data.ToJSON NotificationConfig where
  toJSON :: NotificationConfig -> Value
toJSON NotificationConfig' {Maybe [NotificationEvent]
Maybe Text
Maybe NotificationType
notificationType :: Maybe NotificationType
notificationEvents :: Maybe [NotificationEvent]
notificationArn :: Maybe Text
$sel:notificationType:NotificationConfig' :: NotificationConfig -> Maybe NotificationType
$sel:notificationEvents:NotificationConfig' :: NotificationConfig -> Maybe [NotificationEvent]
$sel:notificationArn:NotificationConfig' :: NotificationConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"NotificationArn" 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
notificationArn,
            (Key
"NotificationEvents" 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 [NotificationEvent]
notificationEvents,
            (Key
"NotificationType" 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 NotificationType
notificationType
          ]
      )