{-# 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 #-}
module Amazonka.Budgets.Types.Notification where
import Amazonka.Budgets.Types.ComparisonOperator
import Amazonka.Budgets.Types.NotificationState
import Amazonka.Budgets.Types.NotificationType
import Amazonka.Budgets.Types.ThresholdType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Notification = Notification'
{
Notification -> Maybe ThresholdType
thresholdType :: Prelude.Maybe ThresholdType,
Notification -> Maybe NotificationState
notificationState :: Prelude.Maybe NotificationState,
Notification -> NotificationType
notificationType :: NotificationType,
Notification -> ComparisonOperator
comparisonOperator :: ComparisonOperator,
Notification -> Double
threshold :: Prelude.Double
}
deriving (Notification -> Notification -> Bool
(Notification -> Notification -> Bool)
-> (Notification -> Notification -> Bool) -> Eq Notification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Notification -> Notification -> Bool
$c/= :: Notification -> Notification -> Bool
== :: Notification -> Notification -> Bool
$c== :: Notification -> Notification -> Bool
Prelude.Eq, ReadPrec [Notification]
ReadPrec Notification
Int -> ReadS Notification
ReadS [Notification]
(Int -> ReadS Notification)
-> ReadS [Notification]
-> ReadPrec Notification
-> ReadPrec [Notification]
-> Read Notification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Notification]
$creadListPrec :: ReadPrec [Notification]
readPrec :: ReadPrec Notification
$creadPrec :: ReadPrec Notification
readList :: ReadS [Notification]
$creadList :: ReadS [Notification]
readsPrec :: Int -> ReadS Notification
$creadsPrec :: Int -> ReadS Notification
Prelude.Read, Int -> Notification -> ShowS
[Notification] -> ShowS
Notification -> String
(Int -> Notification -> ShowS)
-> (Notification -> String)
-> ([Notification] -> ShowS)
-> Show Notification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Notification] -> ShowS
$cshowList :: [Notification] -> ShowS
show :: Notification -> String
$cshow :: Notification -> String
showsPrec :: Int -> Notification -> ShowS
$cshowsPrec :: Int -> Notification -> ShowS
Prelude.Show, (forall x. Notification -> Rep Notification x)
-> (forall x. Rep Notification x -> Notification)
-> Generic Notification
forall x. Rep Notification x -> Notification
forall x. Notification -> Rep Notification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Notification x -> Notification
$cfrom :: forall x. Notification -> Rep Notification x
Prelude.Generic)
newNotification ::
NotificationType ->
ComparisonOperator ->
Prelude.Double ->
Notification
newNotification :: NotificationType -> ComparisonOperator -> Double -> Notification
newNotification
NotificationType
pNotificationType_
ComparisonOperator
pComparisonOperator_
Double
pThreshold_ =
Notification' :: Maybe ThresholdType
-> Maybe NotificationState
-> NotificationType
-> ComparisonOperator
-> Double
-> Notification
Notification'
{ $sel:thresholdType:Notification' :: Maybe ThresholdType
thresholdType = Maybe ThresholdType
forall a. Maybe a
Prelude.Nothing,
$sel:notificationState:Notification' :: Maybe NotificationState
notificationState = Maybe NotificationState
forall a. Maybe a
Prelude.Nothing,
$sel:notificationType:Notification' :: NotificationType
notificationType = NotificationType
pNotificationType_,
$sel:comparisonOperator:Notification' :: ComparisonOperator
comparisonOperator = ComparisonOperator
pComparisonOperator_,
$sel:threshold:Notification' :: Double
threshold = Double
pThreshold_
}
notification_thresholdType :: Lens.Lens' Notification (Prelude.Maybe ThresholdType)
notification_thresholdType :: (Maybe ThresholdType -> f (Maybe ThresholdType))
-> Notification -> f Notification
notification_thresholdType = (Notification -> Maybe ThresholdType)
-> (Notification -> Maybe ThresholdType -> Notification)
-> Lens
Notification
Notification
(Maybe ThresholdType)
(Maybe ThresholdType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Notification' {Maybe ThresholdType
thresholdType :: Maybe ThresholdType
$sel:thresholdType:Notification' :: Notification -> Maybe ThresholdType
thresholdType} -> Maybe ThresholdType
thresholdType) (\s :: Notification
s@Notification' {} Maybe ThresholdType
a -> Notification
s {$sel:thresholdType:Notification' :: Maybe ThresholdType
thresholdType = Maybe ThresholdType
a} :: Notification)
notification_notificationState :: Lens.Lens' Notification (Prelude.Maybe NotificationState)
notification_notificationState :: (Maybe NotificationState -> f (Maybe NotificationState))
-> Notification -> f Notification
notification_notificationState = (Notification -> Maybe NotificationState)
-> (Notification -> Maybe NotificationState -> Notification)
-> Lens
Notification
Notification
(Maybe NotificationState)
(Maybe NotificationState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Notification' {Maybe NotificationState
notificationState :: Maybe NotificationState
$sel:notificationState:Notification' :: Notification -> Maybe NotificationState
notificationState} -> Maybe NotificationState
notificationState) (\s :: Notification
s@Notification' {} Maybe NotificationState
a -> Notification
s {$sel:notificationState:Notification' :: Maybe NotificationState
notificationState = Maybe NotificationState
a} :: Notification)
notification_notificationType :: Lens.Lens' Notification NotificationType
notification_notificationType :: (NotificationType -> f NotificationType)
-> Notification -> f Notification
notification_notificationType = (Notification -> NotificationType)
-> (Notification -> NotificationType -> Notification)
-> Lens Notification Notification NotificationType NotificationType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Notification' {NotificationType
notificationType :: NotificationType
$sel:notificationType:Notification' :: Notification -> NotificationType
notificationType} -> NotificationType
notificationType) (\s :: Notification
s@Notification' {} NotificationType
a -> Notification
s {$sel:notificationType:Notification' :: NotificationType
notificationType = NotificationType
a} :: Notification)
notification_comparisonOperator :: Lens.Lens' Notification ComparisonOperator
notification_comparisonOperator :: (ComparisonOperator -> f ComparisonOperator)
-> Notification -> f Notification
notification_comparisonOperator = (Notification -> ComparisonOperator)
-> (Notification -> ComparisonOperator -> Notification)
-> Lens
Notification Notification ComparisonOperator ComparisonOperator
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Notification' {ComparisonOperator
comparisonOperator :: ComparisonOperator
$sel:comparisonOperator:Notification' :: Notification -> ComparisonOperator
comparisonOperator} -> ComparisonOperator
comparisonOperator) (\s :: Notification
s@Notification' {} ComparisonOperator
a -> Notification
s {$sel:comparisonOperator:Notification' :: ComparisonOperator
comparisonOperator = ComparisonOperator
a} :: Notification)
notification_threshold :: Lens.Lens' Notification Prelude.Double
notification_threshold :: (Double -> f Double) -> Notification -> f Notification
notification_threshold = (Notification -> Double)
-> (Notification -> Double -> Notification)
-> Lens Notification Notification Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Notification' {Double
threshold :: Double
$sel:threshold:Notification' :: Notification -> Double
threshold} -> Double
threshold) (\s :: Notification
s@Notification' {} Double
a -> Notification
s {$sel:threshold:Notification' :: Double
threshold = Double
a} :: Notification)
instance Core.FromJSON Notification where
parseJSON :: Value -> Parser Notification
parseJSON =
String
-> (Object -> Parser Notification) -> Value -> Parser Notification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Notification"
( \Object
x ->
Maybe ThresholdType
-> Maybe NotificationState
-> NotificationType
-> ComparisonOperator
-> Double
-> Notification
Notification'
(Maybe ThresholdType
-> Maybe NotificationState
-> NotificationType
-> ComparisonOperator
-> Double
-> Notification)
-> Parser (Maybe ThresholdType)
-> Parser
(Maybe NotificationState
-> NotificationType
-> ComparisonOperator
-> Double
-> Notification)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ThresholdType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ThresholdType")
Parser
(Maybe NotificationState
-> NotificationType
-> ComparisonOperator
-> Double
-> Notification)
-> Parser (Maybe NotificationState)
-> Parser
(NotificationType -> ComparisonOperator -> Double -> Notification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NotificationState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NotificationState")
Parser
(NotificationType -> ComparisonOperator -> Double -> Notification)
-> Parser NotificationType
-> Parser (ComparisonOperator -> Double -> Notification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser NotificationType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"NotificationType")
Parser (ComparisonOperator -> Double -> Notification)
-> Parser ComparisonOperator -> Parser (Double -> Notification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ComparisonOperator
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ComparisonOperator")
Parser (Double -> Notification)
-> Parser Double -> Parser Notification
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Threshold")
)
instance Prelude.Hashable Notification
instance Prelude.NFData Notification
instance Core.ToJSON Notification where
toJSON :: Notification -> Value
toJSON Notification' {Double
Maybe NotificationState
Maybe ThresholdType
ComparisonOperator
NotificationType
threshold :: Double
comparisonOperator :: ComparisonOperator
notificationType :: NotificationType
notificationState :: Maybe NotificationState
thresholdType :: Maybe ThresholdType
$sel:threshold:Notification' :: Notification -> Double
$sel:comparisonOperator:Notification' :: Notification -> ComparisonOperator
$sel:notificationType:Notification' :: Notification -> NotificationType
$sel:notificationState:Notification' :: Notification -> Maybe NotificationState
$sel:thresholdType:Notification' :: Notification -> Maybe ThresholdType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ThresholdType" Text -> ThresholdType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ThresholdType -> Pair) -> Maybe ThresholdType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ThresholdType
thresholdType,
(Text
"NotificationState" Text -> NotificationState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(NotificationState -> Pair)
-> Maybe NotificationState -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NotificationState
notificationState,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"NotificationType" Text -> NotificationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NotificationType
notificationType),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ComparisonOperator" Text -> ComparisonOperator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ComparisonOperator
comparisonOperator),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Threshold" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
threshold)
]
)