{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:defaultValue:MetricTransformation' :: Maybe Double
defaultValue =
forall a. Maybe a
Prelude.Nothing,
$sel:dimensions:MetricTransformation' :: Maybe (HashMap Text Text)
dimensions = forall a. Maybe a
Prelude.Nothing,
$sel:unit:MetricTransformation' :: Maybe StandardUnit
unit = 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 :: Lens' MetricTransformation (Maybe Double)
metricTransformation_defaultValue = 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 :: Lens' MetricTransformation (Maybe (HashMap Text Text))
metricTransformation_dimensions = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' MetricTransformation (Maybe StandardUnit)
metricTransformation_unit = 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 :: Lens' MetricTransformation Text
metricTransformation_metricName = 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 :: Lens' MetricTransformation Text
metricTransformation_metricNamespace = 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 :: Lens' MetricTransformation Text
metricTransformation_metricValue = 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 Data.FromJSON MetricTransformation where
parseJSON :: Value -> Parser MetricTransformation
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"MetricTransformation"
( \Object
x ->
Maybe Double
-> Maybe (HashMap Text Text)
-> Maybe StandardUnit
-> Text
-> Text
-> Text
-> MetricTransformation
MetricTransformation'
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
"defaultValue")
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
"dimensions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
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")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"metricName")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"metricNamespace")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"metricValue")
)
instance Prelude.Hashable MetricTransformation where
hashWithSalt :: Int -> MetricTransformation -> Int
hashWithSalt Int
_salt 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
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
defaultValue
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
dimensions
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StandardUnit
unit
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
metricName
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
metricNamespace
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
metricValue
instance Prelude.NFData MetricTransformation where
rnf :: MetricTransformation -> ()
rnf 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
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
defaultValue
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
dimensions
seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Text
metricName
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
metricNamespace
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
metricValue
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"defaultValue" 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 Double
defaultValue,
(Key
"dimensions" 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 (HashMap Text Text)
dimensions,
(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 StandardUnit
unit,
forall a. a -> Maybe a
Prelude.Just (Key
"metricName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
metricName),
forall a. a -> Maybe a
Prelude.Just
(Key
"metricNamespace" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
metricNamespace),
forall a. a -> Maybe a
Prelude.Just (Key
"metricValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
metricValue)
]
)