{-# 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.ECS.Types.KeyValuePair where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data KeyValuePair = KeyValuePair'
{
KeyValuePair -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
KeyValuePair -> Maybe Text
name :: Prelude.Maybe Prelude.Text
}
deriving (KeyValuePair -> KeyValuePair -> Bool
(KeyValuePair -> KeyValuePair -> Bool)
-> (KeyValuePair -> KeyValuePair -> Bool) -> Eq KeyValuePair
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeyValuePair -> KeyValuePair -> Bool
$c/= :: KeyValuePair -> KeyValuePair -> Bool
== :: KeyValuePair -> KeyValuePair -> Bool
$c== :: KeyValuePair -> KeyValuePair -> Bool
Prelude.Eq, ReadPrec [KeyValuePair]
ReadPrec KeyValuePair
Int -> ReadS KeyValuePair
ReadS [KeyValuePair]
(Int -> ReadS KeyValuePair)
-> ReadS [KeyValuePair]
-> ReadPrec KeyValuePair
-> ReadPrec [KeyValuePair]
-> Read KeyValuePair
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KeyValuePair]
$creadListPrec :: ReadPrec [KeyValuePair]
readPrec :: ReadPrec KeyValuePair
$creadPrec :: ReadPrec KeyValuePair
readList :: ReadS [KeyValuePair]
$creadList :: ReadS [KeyValuePair]
readsPrec :: Int -> ReadS KeyValuePair
$creadsPrec :: Int -> ReadS KeyValuePair
Prelude.Read, Int -> KeyValuePair -> ShowS
[KeyValuePair] -> ShowS
KeyValuePair -> String
(Int -> KeyValuePair -> ShowS)
-> (KeyValuePair -> String)
-> ([KeyValuePair] -> ShowS)
-> Show KeyValuePair
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeyValuePair] -> ShowS
$cshowList :: [KeyValuePair] -> ShowS
show :: KeyValuePair -> String
$cshow :: KeyValuePair -> String
showsPrec :: Int -> KeyValuePair -> ShowS
$cshowsPrec :: Int -> KeyValuePair -> ShowS
Prelude.Show, (forall x. KeyValuePair -> Rep KeyValuePair x)
-> (forall x. Rep KeyValuePair x -> KeyValuePair)
-> Generic KeyValuePair
forall x. Rep KeyValuePair x -> KeyValuePair
forall x. KeyValuePair -> Rep KeyValuePair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KeyValuePair x -> KeyValuePair
$cfrom :: forall x. KeyValuePair -> Rep KeyValuePair x
Prelude.Generic)
newKeyValuePair ::
KeyValuePair
newKeyValuePair :: KeyValuePair
newKeyValuePair =
KeyValuePair' :: Maybe Text -> Maybe Text -> KeyValuePair
KeyValuePair'
{ $sel:value:KeyValuePair' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:KeyValuePair' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
keyValuePair_value :: Lens.Lens' KeyValuePair (Prelude.Maybe Prelude.Text)
keyValuePair_value :: (Maybe Text -> f (Maybe Text)) -> KeyValuePair -> f KeyValuePair
keyValuePair_value = (KeyValuePair -> Maybe Text)
-> (KeyValuePair -> Maybe Text -> KeyValuePair)
-> Lens KeyValuePair KeyValuePair (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyValuePair' {Maybe Text
value :: Maybe Text
$sel:value:KeyValuePair' :: KeyValuePair -> Maybe Text
value} -> Maybe Text
value) (\s :: KeyValuePair
s@KeyValuePair' {} Maybe Text
a -> KeyValuePair
s {$sel:value:KeyValuePair' :: Maybe Text
value = Maybe Text
a} :: KeyValuePair)
keyValuePair_name :: Lens.Lens' KeyValuePair (Prelude.Maybe Prelude.Text)
keyValuePair_name :: (Maybe Text -> f (Maybe Text)) -> KeyValuePair -> f KeyValuePair
keyValuePair_name = (KeyValuePair -> Maybe Text)
-> (KeyValuePair -> Maybe Text -> KeyValuePair)
-> Lens KeyValuePair KeyValuePair (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeyValuePair' {Maybe Text
name :: Maybe Text
$sel:name:KeyValuePair' :: KeyValuePair -> Maybe Text
name} -> Maybe Text
name) (\s :: KeyValuePair
s@KeyValuePair' {} Maybe Text
a -> KeyValuePair
s {$sel:name:KeyValuePair' :: Maybe Text
name = Maybe Text
a} :: KeyValuePair)
instance Core.FromJSON KeyValuePair where
parseJSON :: Value -> Parser KeyValuePair
parseJSON =
String
-> (Object -> Parser KeyValuePair) -> Value -> Parser KeyValuePair
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"KeyValuePair"
( \Object
x ->
Maybe Text -> Maybe Text -> KeyValuePair
KeyValuePair'
(Maybe Text -> Maybe Text -> KeyValuePair)
-> Parser (Maybe Text) -> Parser (Maybe Text -> KeyValuePair)
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 -> KeyValuePair)
-> Parser (Maybe Text) -> Parser KeyValuePair
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
"name")
)
instance Prelude.Hashable KeyValuePair
instance Prelude.NFData KeyValuePair
instance Core.ToJSON KeyValuePair where
toJSON :: KeyValuePair -> Value
toJSON KeyValuePair' {Maybe Text
name :: Maybe Text
value :: Maybe Text
$sel:name:KeyValuePair' :: KeyValuePair -> Maybe Text
$sel:value:KeyValuePair' :: KeyValuePair -> 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
"name" 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
name
]
)