{-# 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.CloudWatchLogs.Types.MetricTransformation where
import Amazonka.CloudWatchLogs.Types.StandardUnit
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data MetricTransformation = MetricTransformation'
{
MetricTransformation -> Maybe Double
defaultValue :: Prelude.Maybe Prelude.Double,
MetricTransformation -> Maybe (HashMap Text Text)
dimensions :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
MetricTransformation -> Maybe StandardUnit
unit :: Prelude.Maybe StandardUnit,
MetricTransformation -> Text
metricName :: Prelude.Text,
MetricTransformation -> Text
metricNamespace :: Prelude.Text,
MetricTransformation -> Text
metricValue :: Prelude.Text
}
deriving (MetricTransformation -> MetricTransformation -> Bool
(MetricTransformation -> MetricTransformation -> Bool)
-> (MetricTransformation -> MetricTransformation -> Bool)
-> Eq MetricTransformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricTransformation -> MetricTransformation -> Bool
$c/= :: MetricTransformation -> MetricTransformation -> Bool
== :: MetricTransformation -> MetricTransformation -> Bool
$c== :: MetricTransformation -> MetricTransformation -> Bool
Prelude.Eq, ReadPrec [MetricTransformation]
ReadPrec MetricTransformation
Int -> ReadS MetricTransformation
ReadS [MetricTransformation]
(Int -> ReadS MetricTransformation)
-> ReadS [MetricTransformation]
-> ReadPrec MetricTransformation
-> ReadPrec [MetricTransformation]
-> Read MetricTransformation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricTransformation]
$creadListPrec :: ReadPrec [MetricTransformation]
readPrec :: ReadPrec MetricTransformation
$creadPrec :: ReadPrec MetricTransformation
readList :: ReadS [MetricTransformation]
$creadList :: ReadS [MetricTransformation]
readsPrec :: Int -> ReadS MetricTransformation
$creadsPrec :: Int -> ReadS MetricTransformation
Prelude.Read, Int -> MetricTransformation -> ShowS
[MetricTransformation] -> ShowS
MetricTransformation -> String
(Int -> MetricTransformation -> ShowS)
-> (MetricTransformation -> String)
-> ([MetricTransformation] -> ShowS)
-> Show MetricTransformation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricTransformation] -> ShowS
$cshowList :: [MetricTransformation] -> ShowS
show :: MetricTransformation -> String
$cshow :: MetricTransformation -> String
showsPrec :: Int -> MetricTransformation -> ShowS
$cshowsPrec :: Int -> MetricTransformation -> ShowS
Prelude.Show, (forall x. MetricTransformation -> Rep MetricTransformation x)
-> (forall x. Rep MetricTransformation x -> MetricTransformation)
-> Generic MetricTransformation
forall x. Rep MetricTransformation x -> MetricTransformation
forall x. MetricTransformation -> Rep MetricTransformation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricTransformation x -> MetricTransformation
$cfrom :: forall x. MetricTransformation -> Rep MetricTransformation x
Prelude.Generic)
newMetricTransformation ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
MetricTransformation
newMetricTransformation :: Text -> Text -> Text -> MetricTransformation
newMetricTransformation
Text
pMetricName_
Text
pMetricNamespace_
Text
pMetricValue_ =
MetricTransformation' :: Maybe Double
-> Maybe (HashMap Text Text)
-> Maybe StandardUnit
-> Text
-> Text
-> Text
-> MetricTransformation
MetricTransformation'
{ $sel:defaultValue:MetricTransformation' :: Maybe Double
defaultValue =
Maybe Double
forall a. Maybe a
Prelude.Nothing,
$sel:dimensions:MetricTransformation' :: Maybe (HashMap Text Text)
dimensions = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:unit:MetricTransformation' :: Maybe StandardUnit
unit = Maybe StandardUnit
forall a. Maybe a
Prelude.Nothing,
$sel:metricName:MetricTransformation' :: Text
metricName = Text
pMetricName_,
$sel:metricNamespace:MetricTransformation' :: Text
metricNamespace = Text
pMetricNamespace_,
$sel:metricValue:MetricTransformation' :: Text
metricValue = Text
pMetricValue_
}
metricTransformation_defaultValue :: Lens.Lens' MetricTransformation (Prelude.Maybe Prelude.Double)
metricTransformation_defaultValue :: (Maybe Double -> f (Maybe Double))
-> MetricTransformation -> f MetricTransformation
metricTransformation_defaultValue = (MetricTransformation -> Maybe Double)
-> (MetricTransformation -> Maybe Double -> MetricTransformation)
-> Lens
MetricTransformation
MetricTransformation
(Maybe Double)
(Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricTransformation' {Maybe Double
defaultValue :: Maybe Double
$sel:defaultValue:MetricTransformation' :: MetricTransformation -> Maybe Double
defaultValue} -> Maybe Double
defaultValue) (\s :: MetricTransformation
s@MetricTransformation' {} Maybe Double
a -> MetricTransformation
s {$sel:defaultValue:MetricTransformation' :: Maybe Double
defaultValue = Maybe Double
a} :: MetricTransformation)
metricTransformation_dimensions :: Lens.Lens' MetricTransformation (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
metricTransformation_dimensions :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> MetricTransformation -> f MetricTransformation
metricTransformation_dimensions = (MetricTransformation -> Maybe (HashMap Text Text))
-> (MetricTransformation
-> Maybe (HashMap Text Text) -> MetricTransformation)
-> Lens
MetricTransformation
MetricTransformation
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricTransformation' {Maybe (HashMap Text Text)
dimensions :: Maybe (HashMap Text Text)
$sel:dimensions:MetricTransformation' :: MetricTransformation -> Maybe (HashMap Text Text)
dimensions} -> Maybe (HashMap Text Text)
dimensions) (\s :: MetricTransformation
s@MetricTransformation' {} Maybe (HashMap Text Text)
a -> MetricTransformation
s {$sel:dimensions:MetricTransformation' :: Maybe (HashMap Text Text)
dimensions = Maybe (HashMap Text Text)
a} :: MetricTransformation) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> MetricTransformation -> f MetricTransformation)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> MetricTransformation
-> f MetricTransformation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
metricTransformation_unit :: Lens.Lens' MetricTransformation (Prelude.Maybe StandardUnit)
metricTransformation_unit :: (Maybe StandardUnit -> f (Maybe StandardUnit))
-> MetricTransformation -> f MetricTransformation
metricTransformation_unit = (MetricTransformation -> Maybe StandardUnit)
-> (MetricTransformation
-> Maybe StandardUnit -> MetricTransformation)
-> Lens
MetricTransformation
MetricTransformation
(Maybe StandardUnit)
(Maybe StandardUnit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricTransformation' {Maybe StandardUnit
unit :: Maybe StandardUnit
$sel:unit:MetricTransformation' :: MetricTransformation -> Maybe StandardUnit
unit} -> Maybe StandardUnit
unit) (\s :: MetricTransformation
s@MetricTransformation' {} Maybe StandardUnit
a -> MetricTransformation
s {$sel:unit:MetricTransformation' :: Maybe StandardUnit
unit = Maybe StandardUnit
a} :: MetricTransformation)
metricTransformation_metricName :: Lens.Lens' MetricTransformation Prelude.Text
metricTransformation_metricName :: (Text -> f Text) -> MetricTransformation -> f MetricTransformation
metricTransformation_metricName = (MetricTransformation -> Text)
-> (MetricTransformation -> Text -> MetricTransformation)
-> Lens MetricTransformation MetricTransformation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricTransformation' {Text
metricName :: Text
$sel:metricName:MetricTransformation' :: MetricTransformation -> Text
metricName} -> Text
metricName) (\s :: MetricTransformation
s@MetricTransformation' {} Text
a -> MetricTransformation
s {$sel:metricName:MetricTransformation' :: Text
metricName = Text
a} :: MetricTransformation)
metricTransformation_metricNamespace :: Lens.Lens' MetricTransformation Prelude.Text
metricTransformation_metricNamespace :: (Text -> f Text) -> MetricTransformation -> f MetricTransformation
metricTransformation_metricNamespace = (MetricTransformation -> Text)
-> (MetricTransformation -> Text -> MetricTransformation)
-> Lens MetricTransformation MetricTransformation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricTransformation' {Text
metricNamespace :: Text
$sel:metricNamespace:MetricTransformation' :: MetricTransformation -> Text
metricNamespace} -> Text
metricNamespace) (\s :: MetricTransformation
s@MetricTransformation' {} Text
a -> MetricTransformation
s {$sel:metricNamespace:MetricTransformation' :: Text
metricNamespace = Text
a} :: MetricTransformation)
metricTransformation_metricValue :: Lens.Lens' MetricTransformation Prelude.Text
metricTransformation_metricValue :: (Text -> f Text) -> MetricTransformation -> f MetricTransformation
metricTransformation_metricValue = (MetricTransformation -> Text)
-> (MetricTransformation -> Text -> MetricTransformation)
-> Lens MetricTransformation MetricTransformation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricTransformation' {Text
metricValue :: Text
$sel:metricValue:MetricTransformation' :: MetricTransformation -> Text
metricValue} -> Text
metricValue) (\s :: MetricTransformation
s@MetricTransformation' {} Text
a -> MetricTransformation
s {$sel:metricValue:MetricTransformation' :: Text
metricValue = Text
a} :: MetricTransformation)
instance Core.FromJSON MetricTransformation where
parseJSON :: Value -> Parser MetricTransformation
parseJSON =
String
-> (Object -> Parser MetricTransformation)
-> Value
-> Parser MetricTransformation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"MetricTransformation"
( \Object
x ->
Maybe Double
-> Maybe (HashMap Text Text)
-> Maybe StandardUnit
-> Text
-> Text
-> Text
-> MetricTransformation
MetricTransformation'
(Maybe Double
-> Maybe (HashMap Text Text)
-> Maybe StandardUnit
-> Text
-> Text
-> Text
-> MetricTransformation)
-> Parser (Maybe Double)
-> Parser
(Maybe (HashMap Text Text)
-> Maybe StandardUnit
-> Text
-> Text
-> Text
-> MetricTransformation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"defaultValue")
Parser
(Maybe (HashMap Text Text)
-> Maybe StandardUnit
-> Text
-> Text
-> Text
-> MetricTransformation)
-> Parser (Maybe (HashMap Text Text))
-> Parser
(Maybe StandardUnit
-> Text -> Text -> Text -> MetricTransformation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dimensions" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
Parser
(Maybe StandardUnit
-> Text -> Text -> Text -> MetricTransformation)
-> Parser (Maybe StandardUnit)
-> Parser (Text -> Text -> Text -> MetricTransformation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StandardUnit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"unit")
Parser (Text -> Text -> Text -> MetricTransformation)
-> Parser Text -> Parser (Text -> Text -> MetricTransformation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"metricName")
Parser (Text -> Text -> MetricTransformation)
-> Parser Text -> Parser (Text -> MetricTransformation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"metricNamespace")
Parser (Text -> MetricTransformation)
-> Parser Text -> Parser MetricTransformation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"metricValue")
)
instance Prelude.Hashable MetricTransformation
instance Prelude.NFData MetricTransformation
instance Core.ToJSON MetricTransformation where
toJSON :: MetricTransformation -> Value
toJSON MetricTransformation' {Maybe Double
Maybe (HashMap Text Text)
Maybe StandardUnit
Text
metricValue :: Text
metricNamespace :: Text
metricName :: Text
unit :: Maybe StandardUnit
dimensions :: Maybe (HashMap Text Text)
defaultValue :: Maybe Double
$sel:metricValue:MetricTransformation' :: MetricTransformation -> Text
$sel:metricNamespace:MetricTransformation' :: MetricTransformation -> Text
$sel:metricName:MetricTransformation' :: MetricTransformation -> Text
$sel:unit:MetricTransformation' :: MetricTransformation -> Maybe StandardUnit
$sel:dimensions:MetricTransformation' :: MetricTransformation -> Maybe (HashMap Text Text)
$sel:defaultValue:MetricTransformation' :: MetricTransformation -> Maybe Double
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"defaultValue" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
defaultValue,
(Text
"dimensions" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
dimensions,
(Text
"unit" Text -> StandardUnit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (StandardUnit -> Pair) -> Maybe StandardUnit -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StandardUnit
unit,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"metricName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
metricName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"metricNamespace" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
metricNamespace),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"metricValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
metricValue)
]
)