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