{-# 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.AutoScaling.Types.NotificationConfiguration
-- 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.AutoScaling.Types.NotificationConfiguration where

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

-- | Describes a notification.
--
-- /See:/ 'newNotificationConfiguration' smart constructor.
data NotificationConfiguration = NotificationConfiguration'
  { -- | The Amazon Resource Name (ARN) of the Amazon Simple Notification Service
    -- (Amazon SNS) topic.
    NotificationConfiguration -> Maybe Text
topicARN :: Prelude.Maybe Prelude.Text,
    -- | The name of the Auto Scaling group.
    NotificationConfiguration -> Maybe Text
autoScalingGroupName :: Prelude.Maybe Prelude.Text,
    -- | One of the following event notification types:
    --
    -- -   @autoscaling:EC2_INSTANCE_LAUNCH@
    --
    -- -   @autoscaling:EC2_INSTANCE_LAUNCH_ERROR@
    --
    -- -   @autoscaling:EC2_INSTANCE_TERMINATE@
    --
    -- -   @autoscaling:EC2_INSTANCE_TERMINATE_ERROR@
    --
    -- -   @autoscaling:TEST_NOTIFICATION@
    NotificationConfiguration -> Maybe Text
notificationType :: Prelude.Maybe Prelude.Text
  }
  deriving (NotificationConfiguration -> NotificationConfiguration -> Bool
(NotificationConfiguration -> NotificationConfiguration -> Bool)
-> (NotificationConfiguration -> NotificationConfiguration -> Bool)
-> Eq NotificationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotificationConfiguration -> NotificationConfiguration -> Bool
$c/= :: NotificationConfiguration -> NotificationConfiguration -> Bool
== :: NotificationConfiguration -> NotificationConfiguration -> Bool
$c== :: NotificationConfiguration -> NotificationConfiguration -> Bool
Prelude.Eq, ReadPrec [NotificationConfiguration]
ReadPrec NotificationConfiguration
Int -> ReadS NotificationConfiguration
ReadS [NotificationConfiguration]
(Int -> ReadS NotificationConfiguration)
-> ReadS [NotificationConfiguration]
-> ReadPrec NotificationConfiguration
-> ReadPrec [NotificationConfiguration]
-> Read NotificationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotificationConfiguration]
$creadListPrec :: ReadPrec [NotificationConfiguration]
readPrec :: ReadPrec NotificationConfiguration
$creadPrec :: ReadPrec NotificationConfiguration
readList :: ReadS [NotificationConfiguration]
$creadList :: ReadS [NotificationConfiguration]
readsPrec :: Int -> ReadS NotificationConfiguration
$creadsPrec :: Int -> ReadS NotificationConfiguration
Prelude.Read, Int -> NotificationConfiguration -> ShowS
[NotificationConfiguration] -> ShowS
NotificationConfiguration -> String
(Int -> NotificationConfiguration -> ShowS)
-> (NotificationConfiguration -> String)
-> ([NotificationConfiguration] -> ShowS)
-> Show NotificationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotificationConfiguration] -> ShowS
$cshowList :: [NotificationConfiguration] -> ShowS
show :: NotificationConfiguration -> String
$cshow :: NotificationConfiguration -> String
showsPrec :: Int -> NotificationConfiguration -> ShowS
$cshowsPrec :: Int -> NotificationConfiguration -> ShowS
Prelude.Show, (forall x.
 NotificationConfiguration -> Rep NotificationConfiguration x)
-> (forall x.
    Rep NotificationConfiguration x -> NotificationConfiguration)
-> Generic NotificationConfiguration
forall x.
Rep NotificationConfiguration x -> NotificationConfiguration
forall x.
NotificationConfiguration -> Rep NotificationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NotificationConfiguration x -> NotificationConfiguration
$cfrom :: forall x.
NotificationConfiguration -> Rep NotificationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'NotificationConfiguration' 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', 'notificationConfiguration_topicARN' - The Amazon Resource Name (ARN) of the Amazon Simple Notification Service
-- (Amazon SNS) topic.
--
-- 'autoScalingGroupName', 'notificationConfiguration_autoScalingGroupName' - The name of the Auto Scaling group.
--
-- 'notificationType', 'notificationConfiguration_notificationType' - One of the following event notification types:
--
-- -   @autoscaling:EC2_INSTANCE_LAUNCH@
--
-- -   @autoscaling:EC2_INSTANCE_LAUNCH_ERROR@
--
-- -   @autoscaling:EC2_INSTANCE_TERMINATE@
--
-- -   @autoscaling:EC2_INSTANCE_TERMINATE_ERROR@
--
-- -   @autoscaling:TEST_NOTIFICATION@
newNotificationConfiguration ::
  NotificationConfiguration
newNotificationConfiguration :: NotificationConfiguration
newNotificationConfiguration =
  NotificationConfiguration' :: Maybe Text -> Maybe Text -> Maybe Text -> NotificationConfiguration
NotificationConfiguration'
    { $sel:topicARN:NotificationConfiguration' :: Maybe Text
topicARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:autoScalingGroupName:NotificationConfiguration' :: Maybe Text
autoScalingGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:notificationType:NotificationConfiguration' :: Maybe Text
notificationType = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The name of the Auto Scaling group.
notificationConfiguration_autoScalingGroupName :: Lens.Lens' NotificationConfiguration (Prelude.Maybe Prelude.Text)
notificationConfiguration_autoScalingGroupName :: (Maybe Text -> f (Maybe Text))
-> NotificationConfiguration -> f NotificationConfiguration
notificationConfiguration_autoScalingGroupName = (NotificationConfiguration -> Maybe Text)
-> (NotificationConfiguration
    -> Maybe Text -> NotificationConfiguration)
-> Lens
     NotificationConfiguration
     NotificationConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationConfiguration' {Maybe Text
autoScalingGroupName :: Maybe Text
$sel:autoScalingGroupName:NotificationConfiguration' :: NotificationConfiguration -> Maybe Text
autoScalingGroupName} -> Maybe Text
autoScalingGroupName) (\s :: NotificationConfiguration
s@NotificationConfiguration' {} Maybe Text
a -> NotificationConfiguration
s {$sel:autoScalingGroupName:NotificationConfiguration' :: Maybe Text
autoScalingGroupName = Maybe Text
a} :: NotificationConfiguration)

-- | One of the following event notification types:
--
-- -   @autoscaling:EC2_INSTANCE_LAUNCH@
--
-- -   @autoscaling:EC2_INSTANCE_LAUNCH_ERROR@
--
-- -   @autoscaling:EC2_INSTANCE_TERMINATE@
--
-- -   @autoscaling:EC2_INSTANCE_TERMINATE_ERROR@
--
-- -   @autoscaling:TEST_NOTIFICATION@
notificationConfiguration_notificationType :: Lens.Lens' NotificationConfiguration (Prelude.Maybe Prelude.Text)
notificationConfiguration_notificationType :: (Maybe Text -> f (Maybe Text))
-> NotificationConfiguration -> f NotificationConfiguration
notificationConfiguration_notificationType = (NotificationConfiguration -> Maybe Text)
-> (NotificationConfiguration
    -> Maybe Text -> NotificationConfiguration)
-> Lens
     NotificationConfiguration
     NotificationConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationConfiguration' {Maybe Text
notificationType :: Maybe Text
$sel:notificationType:NotificationConfiguration' :: NotificationConfiguration -> Maybe Text
notificationType} -> Maybe Text
notificationType) (\s :: NotificationConfiguration
s@NotificationConfiguration' {} Maybe Text
a -> NotificationConfiguration
s {$sel:notificationType:NotificationConfiguration' :: Maybe Text
notificationType = Maybe Text
a} :: NotificationConfiguration)

instance Core.FromXML NotificationConfiguration where
  parseXML :: [Node] -> Either String NotificationConfiguration
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe Text -> NotificationConfiguration
NotificationConfiguration'
      (Maybe Text
 -> Maybe Text -> Maybe Text -> NotificationConfiguration)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> NotificationConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TopicARN")
      Either
  String (Maybe Text -> Maybe Text -> NotificationConfiguration)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> NotificationConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AutoScalingGroupName")
      Either String (Maybe Text -> NotificationConfiguration)
-> Either String (Maybe Text)
-> Either String NotificationConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"NotificationType")

instance Prelude.Hashable NotificationConfiguration

instance Prelude.NFData NotificationConfiguration