{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:name:CurrentMetric' :: Maybe CurrentMetricName
name = forall a. Maybe a
Prelude.Nothing,
$sel:unit:CurrentMetric' :: Maybe Unit
unit = forall a. Maybe a
Prelude.Nothing
}
currentMetric_name :: Lens.Lens' CurrentMetric (Prelude.Maybe CurrentMetricName)
currentMetric_name :: Lens' CurrentMetric (Maybe CurrentMetricName)
currentMetric_name = 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 :: Lens' CurrentMetric (Maybe Unit)
currentMetric_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 Data.FromJSON CurrentMetric where
parseJSON :: Value -> Parser CurrentMetric
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"CurrentMetric"
( \Object
x ->
Maybe CurrentMetricName -> Maybe Unit -> CurrentMetric
CurrentMetric'
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
"Name")
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
"Unit")
)
instance Prelude.Hashable CurrentMetric where
hashWithSalt :: Int -> CurrentMetric -> Int
hashWithSalt Int
_salt CurrentMetric' {Maybe CurrentMetricName
Maybe Unit
unit :: Maybe Unit
name :: Maybe CurrentMetricName
$sel:unit:CurrentMetric' :: CurrentMetric -> Maybe Unit
$sel:name:CurrentMetric' :: CurrentMetric -> Maybe CurrentMetricName
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CurrentMetricName
name
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Unit
unit
instance Prelude.NFData CurrentMetric where
rnf :: CurrentMetric -> ()
rnf CurrentMetric' {Maybe CurrentMetricName
Maybe Unit
unit :: Maybe Unit
name :: Maybe CurrentMetricName
$sel:unit:CurrentMetric' :: CurrentMetric -> Maybe Unit
$sel:name:CurrentMetric' :: CurrentMetric -> Maybe CurrentMetricName
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe CurrentMetricName
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Unit
unit
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Name" 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 CurrentMetricName
name,
(Key
"Unit" 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 Unit
unit
]
)