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