{-# 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.CloudWatch.Types.MetricStat where
import Amazonka.CloudWatch.Types.Metric
import Amazonka.CloudWatch.Types.StandardUnit
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 MetricStat = MetricStat'
{
MetricStat -> Maybe StandardUnit
unit :: Prelude.Maybe StandardUnit,
MetricStat -> Metric
metric :: Metric,
MetricStat -> Natural
period :: Prelude.Natural,
MetricStat -> Text
stat :: Prelude.Text
}
deriving (MetricStat -> MetricStat -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricStat -> MetricStat -> Bool
$c/= :: MetricStat -> MetricStat -> Bool
== :: MetricStat -> MetricStat -> Bool
$c== :: MetricStat -> MetricStat -> Bool
Prelude.Eq, ReadPrec [MetricStat]
ReadPrec MetricStat
Int -> ReadS MetricStat
ReadS [MetricStat]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricStat]
$creadListPrec :: ReadPrec [MetricStat]
readPrec :: ReadPrec MetricStat
$creadPrec :: ReadPrec MetricStat
readList :: ReadS [MetricStat]
$creadList :: ReadS [MetricStat]
readsPrec :: Int -> ReadS MetricStat
$creadsPrec :: Int -> ReadS MetricStat
Prelude.Read, Int -> MetricStat -> ShowS
[MetricStat] -> ShowS
MetricStat -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricStat] -> ShowS
$cshowList :: [MetricStat] -> ShowS
show :: MetricStat -> String
$cshow :: MetricStat -> String
showsPrec :: Int -> MetricStat -> ShowS
$cshowsPrec :: Int -> MetricStat -> ShowS
Prelude.Show, forall x. Rep MetricStat x -> MetricStat
forall x. MetricStat -> Rep MetricStat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricStat x -> MetricStat
$cfrom :: forall x. MetricStat -> Rep MetricStat x
Prelude.Generic)
newMetricStat ::
Metric ->
Prelude.Natural ->
Prelude.Text ->
MetricStat
newMetricStat :: Metric -> Natural -> Text -> MetricStat
newMetricStat Metric
pMetric_ Natural
pPeriod_ Text
pStat_ =
MetricStat'
{ $sel:unit:MetricStat' :: Maybe StandardUnit
unit = forall a. Maybe a
Prelude.Nothing,
$sel:metric:MetricStat' :: Metric
metric = Metric
pMetric_,
$sel:period:MetricStat' :: Natural
period = Natural
pPeriod_,
$sel:stat:MetricStat' :: Text
stat = Text
pStat_
}
metricStat_unit :: Lens.Lens' MetricStat (Prelude.Maybe StandardUnit)
metricStat_unit :: Lens' MetricStat (Maybe StandardUnit)
metricStat_unit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricStat' {Maybe StandardUnit
unit :: Maybe StandardUnit
$sel:unit:MetricStat' :: MetricStat -> Maybe StandardUnit
unit} -> Maybe StandardUnit
unit) (\s :: MetricStat
s@MetricStat' {} Maybe StandardUnit
a -> MetricStat
s {$sel:unit:MetricStat' :: Maybe StandardUnit
unit = Maybe StandardUnit
a} :: MetricStat)
metricStat_metric :: Lens.Lens' MetricStat Metric
metricStat_metric :: Lens' MetricStat Metric
metricStat_metric = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricStat' {Metric
metric :: Metric
$sel:metric:MetricStat' :: MetricStat -> Metric
metric} -> Metric
metric) (\s :: MetricStat
s@MetricStat' {} Metric
a -> MetricStat
s {$sel:metric:MetricStat' :: Metric
metric = Metric
a} :: MetricStat)
metricStat_period :: Lens.Lens' MetricStat Prelude.Natural
metricStat_period :: Lens' MetricStat Natural
metricStat_period = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricStat' {Natural
period :: Natural
$sel:period:MetricStat' :: MetricStat -> Natural
period} -> Natural
period) (\s :: MetricStat
s@MetricStat' {} Natural
a -> MetricStat
s {$sel:period:MetricStat' :: Natural
period = Natural
a} :: MetricStat)
metricStat_stat :: Lens.Lens' MetricStat Prelude.Text
metricStat_stat :: Lens' MetricStat Text
metricStat_stat = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricStat' {Text
stat :: Text
$sel:stat:MetricStat' :: MetricStat -> Text
stat} -> Text
stat) (\s :: MetricStat
s@MetricStat' {} Text
a -> MetricStat
s {$sel:stat:MetricStat' :: Text
stat = Text
a} :: MetricStat)
instance Data.FromXML MetricStat where
parseXML :: [Node] -> Either String MetricStat
parseXML [Node]
x =
Maybe StandardUnit -> Metric -> Natural -> Text -> MetricStat
MetricStat'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Unit")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Metric")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Period")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Stat")
instance Prelude.Hashable MetricStat where
hashWithSalt :: Int -> MetricStat -> Int
hashWithSalt Int
_salt MetricStat' {Natural
Maybe StandardUnit
Text
Metric
stat :: Text
period :: Natural
metric :: Metric
unit :: Maybe StandardUnit
$sel:stat:MetricStat' :: MetricStat -> Text
$sel:period:MetricStat' :: MetricStat -> Natural
$sel:metric:MetricStat' :: MetricStat -> Metric
$sel:unit:MetricStat' :: MetricStat -> Maybe StandardUnit
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StandardUnit
unit
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Metric
metric
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
period
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stat
instance Prelude.NFData MetricStat where
rnf :: MetricStat -> ()
rnf MetricStat' {Natural
Maybe StandardUnit
Text
Metric
stat :: Text
period :: Natural
metric :: Metric
unit :: Maybe StandardUnit
$sel:stat:MetricStat' :: MetricStat -> Text
$sel:period:MetricStat' :: MetricStat -> Natural
$sel:metric:MetricStat' :: MetricStat -> Metric
$sel:unit:MetricStat' :: MetricStat -> Maybe StandardUnit
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe StandardUnit
unit
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Metric
metric
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
period
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
stat
instance Data.ToQuery MetricStat where
toQuery :: MetricStat -> QueryString
toQuery MetricStat' {Natural
Maybe StandardUnit
Text
Metric
stat :: Text
period :: Natural
metric :: Metric
unit :: Maybe StandardUnit
$sel:stat:MetricStat' :: MetricStat -> Text
$sel:period:MetricStat' :: MetricStat -> Natural
$sel:metric:MetricStat' :: MetricStat -> Metric
$sel:unit:MetricStat' :: MetricStat -> Maybe StandardUnit
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Unit" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe StandardUnit
unit,
ByteString
"Metric" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Metric
metric,
ByteString
"Period" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Natural
period,
ByteString
"Stat" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
stat
]