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