{-# 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.EMR.Types.MetricDimension where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data MetricDimension = MetricDimension'
{
MetricDimension -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
MetricDimension -> Maybe Text
key :: Prelude.Maybe Prelude.Text
}
deriving (MetricDimension -> MetricDimension -> Bool
(MetricDimension -> MetricDimension -> Bool)
-> (MetricDimension -> MetricDimension -> Bool)
-> Eq MetricDimension
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricDimension -> MetricDimension -> Bool
$c/= :: MetricDimension -> MetricDimension -> Bool
== :: MetricDimension -> MetricDimension -> Bool
$c== :: MetricDimension -> MetricDimension -> Bool
Prelude.Eq, ReadPrec [MetricDimension]
ReadPrec MetricDimension
Int -> ReadS MetricDimension
ReadS [MetricDimension]
(Int -> ReadS MetricDimension)
-> ReadS [MetricDimension]
-> ReadPrec MetricDimension
-> ReadPrec [MetricDimension]
-> Read MetricDimension
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricDimension]
$creadListPrec :: ReadPrec [MetricDimension]
readPrec :: ReadPrec MetricDimension
$creadPrec :: ReadPrec MetricDimension
readList :: ReadS [MetricDimension]
$creadList :: ReadS [MetricDimension]
readsPrec :: Int -> ReadS MetricDimension
$creadsPrec :: Int -> ReadS MetricDimension
Prelude.Read, Int -> MetricDimension -> ShowS
[MetricDimension] -> ShowS
MetricDimension -> String
(Int -> MetricDimension -> ShowS)
-> (MetricDimension -> String)
-> ([MetricDimension] -> ShowS)
-> Show MetricDimension
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricDimension] -> ShowS
$cshowList :: [MetricDimension] -> ShowS
show :: MetricDimension -> String
$cshow :: MetricDimension -> String
showsPrec :: Int -> MetricDimension -> ShowS
$cshowsPrec :: Int -> MetricDimension -> ShowS
Prelude.Show, (forall x. MetricDimension -> Rep MetricDimension x)
-> (forall x. Rep MetricDimension x -> MetricDimension)
-> Generic MetricDimension
forall x. Rep MetricDimension x -> MetricDimension
forall x. MetricDimension -> Rep MetricDimension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricDimension x -> MetricDimension
$cfrom :: forall x. MetricDimension -> Rep MetricDimension x
Prelude.Generic)
newMetricDimension ::
MetricDimension
newMetricDimension :: MetricDimension
newMetricDimension =
MetricDimension' :: Maybe Text -> Maybe Text -> MetricDimension
MetricDimension'
{ $sel:value:MetricDimension' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:key:MetricDimension' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
metricDimension_value :: Lens.Lens' MetricDimension (Prelude.Maybe Prelude.Text)
metricDimension_value :: (Maybe Text -> f (Maybe Text))
-> MetricDimension -> f MetricDimension
metricDimension_value = (MetricDimension -> Maybe Text)
-> (MetricDimension -> Maybe Text -> MetricDimension)
-> Lens MetricDimension MetricDimension (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDimension' {Maybe Text
value :: Maybe Text
$sel:value:MetricDimension' :: MetricDimension -> Maybe Text
value} -> Maybe Text
value) (\s :: MetricDimension
s@MetricDimension' {} Maybe Text
a -> MetricDimension
s {$sel:value:MetricDimension' :: Maybe Text
value = Maybe Text
a} :: MetricDimension)
metricDimension_key :: Lens.Lens' MetricDimension (Prelude.Maybe Prelude.Text)
metricDimension_key :: (Maybe Text -> f (Maybe Text))
-> MetricDimension -> f MetricDimension
metricDimension_key = (MetricDimension -> Maybe Text)
-> (MetricDimension -> Maybe Text -> MetricDimension)
-> Lens MetricDimension MetricDimension (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDimension' {Maybe Text
key :: Maybe Text
$sel:key:MetricDimension' :: MetricDimension -> Maybe Text
key} -> Maybe Text
key) (\s :: MetricDimension
s@MetricDimension' {} Maybe Text
a -> MetricDimension
s {$sel:key:MetricDimension' :: Maybe Text
key = Maybe Text
a} :: MetricDimension)
instance Core.FromJSON MetricDimension where
parseJSON :: Value -> Parser MetricDimension
parseJSON =
String
-> (Object -> Parser MetricDimension)
-> Value
-> Parser MetricDimension
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"MetricDimension"
( \Object
x ->
Maybe Text -> Maybe Text -> MetricDimension
MetricDimension'
(Maybe Text -> Maybe Text -> MetricDimension)
-> Parser (Maybe Text) -> Parser (Maybe Text -> MetricDimension)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Value") Parser (Maybe Text -> MetricDimension)
-> Parser (Maybe Text) -> Parser MetricDimension
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Key")
)
instance Prelude.Hashable MetricDimension
instance Prelude.NFData MetricDimension
instance Core.ToJSON MetricDimension where
toJSON :: MetricDimension -> Value
toJSON MetricDimension' {Maybe Text
key :: Maybe Text
value :: Maybe Text
$sel:key:MetricDimension' :: MetricDimension -> Maybe Text
$sel:value:MetricDimension' :: MetricDimension -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
value,
(Text
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
key
]
)