{-# 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.ActionThreshold where
import Amazonka.Budgets.Types.ThresholdType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data ActionThreshold = ActionThreshold'
{ ActionThreshold -> Double
actionThresholdValue :: Prelude.Double,
ActionThreshold -> ThresholdType
actionThresholdType :: ThresholdType
}
deriving (ActionThreshold -> ActionThreshold -> Bool
(ActionThreshold -> ActionThreshold -> Bool)
-> (ActionThreshold -> ActionThreshold -> Bool)
-> Eq ActionThreshold
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionThreshold -> ActionThreshold -> Bool
$c/= :: ActionThreshold -> ActionThreshold -> Bool
== :: ActionThreshold -> ActionThreshold -> Bool
$c== :: ActionThreshold -> ActionThreshold -> Bool
Prelude.Eq, ReadPrec [ActionThreshold]
ReadPrec ActionThreshold
Int -> ReadS ActionThreshold
ReadS [ActionThreshold]
(Int -> ReadS ActionThreshold)
-> ReadS [ActionThreshold]
-> ReadPrec ActionThreshold
-> ReadPrec [ActionThreshold]
-> Read ActionThreshold
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActionThreshold]
$creadListPrec :: ReadPrec [ActionThreshold]
readPrec :: ReadPrec ActionThreshold
$creadPrec :: ReadPrec ActionThreshold
readList :: ReadS [ActionThreshold]
$creadList :: ReadS [ActionThreshold]
readsPrec :: Int -> ReadS ActionThreshold
$creadsPrec :: Int -> ReadS ActionThreshold
Prelude.Read, Int -> ActionThreshold -> ShowS
[ActionThreshold] -> ShowS
ActionThreshold -> String
(Int -> ActionThreshold -> ShowS)
-> (ActionThreshold -> String)
-> ([ActionThreshold] -> ShowS)
-> Show ActionThreshold
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActionThreshold] -> ShowS
$cshowList :: [ActionThreshold] -> ShowS
show :: ActionThreshold -> String
$cshow :: ActionThreshold -> String
showsPrec :: Int -> ActionThreshold -> ShowS
$cshowsPrec :: Int -> ActionThreshold -> ShowS
Prelude.Show, (forall x. ActionThreshold -> Rep ActionThreshold x)
-> (forall x. Rep ActionThreshold x -> ActionThreshold)
-> Generic ActionThreshold
forall x. Rep ActionThreshold x -> ActionThreshold
forall x. ActionThreshold -> Rep ActionThreshold x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActionThreshold x -> ActionThreshold
$cfrom :: forall x. ActionThreshold -> Rep ActionThreshold x
Prelude.Generic)
newActionThreshold ::
Prelude.Double ->
ThresholdType ->
ActionThreshold
newActionThreshold :: Double -> ThresholdType -> ActionThreshold
newActionThreshold
Double
pActionThresholdValue_
ThresholdType
pActionThresholdType_ =
ActionThreshold' :: Double -> ThresholdType -> ActionThreshold
ActionThreshold'
{ $sel:actionThresholdValue:ActionThreshold' :: Double
actionThresholdValue =
Double
pActionThresholdValue_,
$sel:actionThresholdType:ActionThreshold' :: ThresholdType
actionThresholdType = ThresholdType
pActionThresholdType_
}
actionThreshold_actionThresholdValue :: Lens.Lens' ActionThreshold Prelude.Double
actionThreshold_actionThresholdValue :: (Double -> f Double) -> ActionThreshold -> f ActionThreshold
actionThreshold_actionThresholdValue = (ActionThreshold -> Double)
-> (ActionThreshold -> Double -> ActionThreshold)
-> Lens ActionThreshold ActionThreshold Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionThreshold' {Double
actionThresholdValue :: Double
$sel:actionThresholdValue:ActionThreshold' :: ActionThreshold -> Double
actionThresholdValue} -> Double
actionThresholdValue) (\s :: ActionThreshold
s@ActionThreshold' {} Double
a -> ActionThreshold
s {$sel:actionThresholdValue:ActionThreshold' :: Double
actionThresholdValue = Double
a} :: ActionThreshold)
actionThreshold_actionThresholdType :: Lens.Lens' ActionThreshold ThresholdType
actionThreshold_actionThresholdType :: (ThresholdType -> f ThresholdType)
-> ActionThreshold -> f ActionThreshold
actionThreshold_actionThresholdType = (ActionThreshold -> ThresholdType)
-> (ActionThreshold -> ThresholdType -> ActionThreshold)
-> Lens ActionThreshold ActionThreshold ThresholdType ThresholdType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionThreshold' {ThresholdType
actionThresholdType :: ThresholdType
$sel:actionThresholdType:ActionThreshold' :: ActionThreshold -> ThresholdType
actionThresholdType} -> ThresholdType
actionThresholdType) (\s :: ActionThreshold
s@ActionThreshold' {} ThresholdType
a -> ActionThreshold
s {$sel:actionThresholdType:ActionThreshold' :: ThresholdType
actionThresholdType = ThresholdType
a} :: ActionThreshold)
instance Core.FromJSON ActionThreshold where
parseJSON :: Value -> Parser ActionThreshold
parseJSON =
String
-> (Object -> Parser ActionThreshold)
-> Value
-> Parser ActionThreshold
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"ActionThreshold"
( \Object
x ->
Double -> ThresholdType -> ActionThreshold
ActionThreshold'
(Double -> ThresholdType -> ActionThreshold)
-> Parser Double -> Parser (ThresholdType -> ActionThreshold)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ActionThresholdValue")
Parser (ThresholdType -> ActionThreshold)
-> Parser ThresholdType -> Parser ActionThreshold
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ThresholdType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ActionThresholdType")
)
instance Prelude.Hashable ActionThreshold
instance Prelude.NFData ActionThreshold
instance Core.ToJSON ActionThreshold where
toJSON :: ActionThreshold -> Value
toJSON ActionThreshold' {Double
ThresholdType
actionThresholdType :: ThresholdType
actionThresholdValue :: Double
$sel:actionThresholdType:ActionThreshold' :: ActionThreshold -> ThresholdType
$sel:actionThresholdValue:ActionThreshold' :: ActionThreshold -> Double
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"ActionThresholdValue"
Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
actionThresholdValue
),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ActionThresholdType" Text -> ThresholdType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ThresholdType
actionThresholdType)
]
)