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