{-# 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.Lens as Lens
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
(MetricStat -> MetricStat -> Bool)
-> (MetricStat -> MetricStat -> Bool) -> Eq MetricStat
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]
(Int -> ReadS MetricStat)
-> ReadS [MetricStat]
-> ReadPrec MetricStat
-> ReadPrec [MetricStat]
-> Read 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
(Int -> MetricStat -> ShowS)
-> (MetricStat -> String)
-> ([MetricStat] -> ShowS)
-> Show MetricStat
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. MetricStat -> Rep MetricStat x)
-> (forall x. Rep MetricStat x -> MetricStat) -> Generic MetricStat
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' :: Maybe StandardUnit -> Metric -> Natural -> Text -> MetricStat
MetricStat'
{ $sel:unit:MetricStat' :: Maybe StandardUnit
unit = Maybe StandardUnit
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 :: (Maybe StandardUnit -> f (Maybe StandardUnit))
-> MetricStat -> f MetricStat
metricStat_unit = (MetricStat -> Maybe StandardUnit)
-> (MetricStat -> Maybe StandardUnit -> MetricStat)
-> Lens
MetricStat MetricStat (Maybe StandardUnit) (Maybe StandardUnit)
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 :: (Metric -> f Metric) -> MetricStat -> f MetricStat
metricStat_metric = (MetricStat -> Metric)
-> (MetricStat -> Metric -> MetricStat)
-> Lens MetricStat MetricStat Metric 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 :: (Natural -> f Natural) -> MetricStat -> f MetricStat
metricStat_period = (MetricStat -> Natural)
-> (MetricStat -> Natural -> MetricStat)
-> Lens MetricStat MetricStat Natural Natural
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 :: (Text -> f Text) -> MetricStat -> f MetricStat
metricStat_stat = (MetricStat -> Text)
-> (MetricStat -> Text -> MetricStat)
-> Lens MetricStat MetricStat Text Text
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 Core.FromXML MetricStat where
parseXML :: [Node] -> Either String MetricStat
parseXML [Node]
x =
Maybe StandardUnit -> Metric -> Natural -> Text -> MetricStat
MetricStat'
(Maybe StandardUnit -> Metric -> Natural -> Text -> MetricStat)
-> Either String (Maybe StandardUnit)
-> Either String (Metric -> Natural -> Text -> MetricStat)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe StandardUnit)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Unit")
Either String (Metric -> Natural -> Text -> MetricStat)
-> Either String Metric
-> Either String (Natural -> Text -> MetricStat)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Metric
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Metric")
Either String (Natural -> Text -> MetricStat)
-> Either String Natural -> Either String (Text -> MetricStat)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Natural
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Period")
Either String (Text -> MetricStat)
-> Either String Text -> Either String MetricStat
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Stat")
instance Prelude.Hashable MetricStat
instance Prelude.NFData MetricStat
instance Core.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
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Unit" ByteString -> Maybe StandardUnit -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe StandardUnit
unit,
ByteString
"Metric" ByteString -> Metric -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Metric
metric,
ByteString
"Period" ByteString -> Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Natural
period,
ByteString
"Stat" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
stat
]