{-# 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTEvents.Types.EmailContent
import Amazonka.IoTEvents.Types.EmailRecipients
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
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]
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
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. 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'
{ $sel:content:EmailConfiguration' :: Maybe EmailContent
content = 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 :: Lens' EmailConfiguration (Maybe EmailContent)
emailConfiguration_content = 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 :: Lens' EmailConfiguration Text
emailConfiguration_from = 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 :: Lens' EmailConfiguration EmailRecipients
emailConfiguration_recipients = 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 Data.FromJSON EmailConfiguration where
parseJSON :: Value -> Parser EmailConfiguration
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"EmailConfiguration"
( \Object
x ->
Maybe EmailContent -> Text -> EmailRecipients -> EmailConfiguration
EmailConfiguration'
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
"content")
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
"from")
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
"recipients")
)
instance Prelude.Hashable EmailConfiguration where
hashWithSalt :: Int -> EmailConfiguration -> Int
hashWithSalt Int
_salt 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
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EmailContent
content
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
from
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EmailRecipients
recipients
instance Prelude.NFData EmailConfiguration where
rnf :: EmailConfiguration -> ()
rnf 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
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe EmailContent
content
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
from
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EmailRecipients
recipients
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"content" 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 EmailContent
content,
forall a. a -> Maybe a
Prelude.Just (Key
"from" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
from),
forall a. a -> Maybe a
Prelude.Just (Key
"recipients" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= EmailRecipients
recipients)
]
)