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