{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
data Notification = Notification'
{
Notification -> Maybe NotificationState
notificationState :: Prelude.Maybe NotificationState,
Notification -> Maybe ThresholdType
thresholdType :: Prelude.Maybe ThresholdType,
Notification -> NotificationType
notificationType :: NotificationType,
Notification -> ComparisonOperator
comparisonOperator :: ComparisonOperator,
Notification -> Double
threshold :: Prelude.Double
}
deriving (Notification -> Notification -> Bool
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]
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
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. 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'
{ $sel:notificationState:Notification' :: Maybe NotificationState
notificationState = forall a. Maybe a
Prelude.Nothing,
$sel:thresholdType:Notification' :: Maybe ThresholdType
thresholdType = 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_notificationState :: Lens.Lens' Notification (Prelude.Maybe NotificationState)
notification_notificationState :: Lens' Notification (Maybe NotificationState)
notification_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_thresholdType :: Lens.Lens' Notification (Prelude.Maybe ThresholdType)
notification_thresholdType :: Lens' Notification (Maybe ThresholdType)
notification_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_notificationType :: Lens.Lens' Notification NotificationType
notification_notificationType :: Lens' Notification NotificationType
notification_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 :: Lens' Notification ComparisonOperator
notification_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 :: Lens' Notification Double
notification_threshold = 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 Data.FromJSON Notification where
parseJSON :: Value -> Parser Notification
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Notification"
( \Object
x ->
Maybe NotificationState
-> Maybe ThresholdType
-> NotificationType
-> ComparisonOperator
-> Double
-> Notification
Notification'
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
"NotificationState")
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
"ThresholdType")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"NotificationType")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ComparisonOperator")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Threshold")
)
instance Prelude.Hashable Notification where
hashWithSalt :: Int -> Notification -> Int
hashWithSalt Int
_salt Notification' {Double
Maybe NotificationState
Maybe ThresholdType
ComparisonOperator
NotificationType
threshold :: Double
comparisonOperator :: ComparisonOperator
notificationType :: NotificationType
thresholdType :: Maybe ThresholdType
notificationState :: Maybe NotificationState
$sel:threshold:Notification' :: Notification -> Double
$sel:comparisonOperator:Notification' :: Notification -> ComparisonOperator
$sel:notificationType:Notification' :: Notification -> NotificationType
$sel:thresholdType:Notification' :: Notification -> Maybe ThresholdType
$sel:notificationState:Notification' :: Notification -> Maybe NotificationState
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NotificationState
notificationState
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ThresholdType
thresholdType
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NotificationType
notificationType
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ComparisonOperator
comparisonOperator
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
threshold
instance Prelude.NFData Notification where
rnf :: Notification -> ()
rnf Notification' {Double
Maybe NotificationState
Maybe ThresholdType
ComparisonOperator
NotificationType
threshold :: Double
comparisonOperator :: ComparisonOperator
notificationType :: NotificationType
thresholdType :: Maybe ThresholdType
notificationState :: Maybe NotificationState
$sel:threshold:Notification' :: Notification -> Double
$sel:comparisonOperator:Notification' :: Notification -> ComparisonOperator
$sel:notificationType:Notification' :: Notification -> NotificationType
$sel:thresholdType:Notification' :: Notification -> Maybe ThresholdType
$sel:notificationState:Notification' :: Notification -> Maybe NotificationState
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe NotificationState
notificationState
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ThresholdType
thresholdType
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NotificationType
notificationType
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ComparisonOperator
comparisonOperator
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
threshold
instance Data.ToJSON Notification where
toJSON :: Notification -> Value
toJSON Notification' {Double
Maybe NotificationState
Maybe ThresholdType
ComparisonOperator
NotificationType
threshold :: Double
comparisonOperator :: ComparisonOperator
notificationType :: NotificationType
thresholdType :: Maybe ThresholdType
notificationState :: Maybe NotificationState
$sel:threshold:Notification' :: Notification -> Double
$sel:comparisonOperator:Notification' :: Notification -> ComparisonOperator
$sel:notificationType:Notification' :: Notification -> NotificationType
$sel:thresholdType:Notification' :: Notification -> Maybe ThresholdType
$sel:notificationState:Notification' :: Notification -> Maybe NotificationState
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"NotificationState" 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 NotificationState
notificationState,
(Key
"ThresholdType" 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 ThresholdType
thresholdType,
forall a. a -> Maybe a
Prelude.Just
(Key
"NotificationType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NotificationType
notificationType),
forall a. a -> Maybe a
Prelude.Just
(Key
"ComparisonOperator" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ComparisonOperator
comparisonOperator),
forall a. a -> Maybe a
Prelude.Just (Key
"Threshold" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
threshold)
]
)