{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.SESV2.CreateEmailTemplate
(
CreateEmailTemplate (..),
newCreateEmailTemplate,
createEmailTemplate_templateName,
createEmailTemplate_templateContent,
CreateEmailTemplateResponse (..),
newCreateEmailTemplateResponse,
createEmailTemplateResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SESV2.Types
data CreateEmailTemplate = CreateEmailTemplate'
{
CreateEmailTemplate -> Text
templateName :: Prelude.Text,
CreateEmailTemplate -> EmailTemplateContent
templateContent :: EmailTemplateContent
}
deriving (CreateEmailTemplate -> CreateEmailTemplate -> Bool
(CreateEmailTemplate -> CreateEmailTemplate -> Bool)
-> (CreateEmailTemplate -> CreateEmailTemplate -> Bool)
-> Eq CreateEmailTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateEmailTemplate -> CreateEmailTemplate -> Bool
$c/= :: CreateEmailTemplate -> CreateEmailTemplate -> Bool
== :: CreateEmailTemplate -> CreateEmailTemplate -> Bool
$c== :: CreateEmailTemplate -> CreateEmailTemplate -> Bool
Prelude.Eq, ReadPrec [CreateEmailTemplate]
ReadPrec CreateEmailTemplate
Int -> ReadS CreateEmailTemplate
ReadS [CreateEmailTemplate]
(Int -> ReadS CreateEmailTemplate)
-> ReadS [CreateEmailTemplate]
-> ReadPrec CreateEmailTemplate
-> ReadPrec [CreateEmailTemplate]
-> Read CreateEmailTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateEmailTemplate]
$creadListPrec :: ReadPrec [CreateEmailTemplate]
readPrec :: ReadPrec CreateEmailTemplate
$creadPrec :: ReadPrec CreateEmailTemplate
readList :: ReadS [CreateEmailTemplate]
$creadList :: ReadS [CreateEmailTemplate]
readsPrec :: Int -> ReadS CreateEmailTemplate
$creadsPrec :: Int -> ReadS CreateEmailTemplate
Prelude.Read, Int -> CreateEmailTemplate -> ShowS
[CreateEmailTemplate] -> ShowS
CreateEmailTemplate -> String
(Int -> CreateEmailTemplate -> ShowS)
-> (CreateEmailTemplate -> String)
-> ([CreateEmailTemplate] -> ShowS)
-> Show CreateEmailTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateEmailTemplate] -> ShowS
$cshowList :: [CreateEmailTemplate] -> ShowS
show :: CreateEmailTemplate -> String
$cshow :: CreateEmailTemplate -> String
showsPrec :: Int -> CreateEmailTemplate -> ShowS
$cshowsPrec :: Int -> CreateEmailTemplate -> ShowS
Prelude.Show, (forall x. CreateEmailTemplate -> Rep CreateEmailTemplate x)
-> (forall x. Rep CreateEmailTemplate x -> CreateEmailTemplate)
-> Generic CreateEmailTemplate
forall x. Rep CreateEmailTemplate x -> CreateEmailTemplate
forall x. CreateEmailTemplate -> Rep CreateEmailTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateEmailTemplate x -> CreateEmailTemplate
$cfrom :: forall x. CreateEmailTemplate -> Rep CreateEmailTemplate x
Prelude.Generic)
newCreateEmailTemplate ::
Prelude.Text ->
EmailTemplateContent ->
CreateEmailTemplate
newCreateEmailTemplate :: Text -> EmailTemplateContent -> CreateEmailTemplate
newCreateEmailTemplate
Text
pTemplateName_
EmailTemplateContent
pTemplateContent_ =
CreateEmailTemplate' :: Text -> EmailTemplateContent -> CreateEmailTemplate
CreateEmailTemplate'
{ $sel:templateName:CreateEmailTemplate' :: Text
templateName = Text
pTemplateName_,
$sel:templateContent:CreateEmailTemplate' :: EmailTemplateContent
templateContent = EmailTemplateContent
pTemplateContent_
}
createEmailTemplate_templateName :: Lens.Lens' CreateEmailTemplate Prelude.Text
createEmailTemplate_templateName :: (Text -> f Text) -> CreateEmailTemplate -> f CreateEmailTemplate
createEmailTemplate_templateName = (CreateEmailTemplate -> Text)
-> (CreateEmailTemplate -> Text -> CreateEmailTemplate)
-> Lens CreateEmailTemplate CreateEmailTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEmailTemplate' {Text
templateName :: Text
$sel:templateName:CreateEmailTemplate' :: CreateEmailTemplate -> Text
templateName} -> Text
templateName) (\s :: CreateEmailTemplate
s@CreateEmailTemplate' {} Text
a -> CreateEmailTemplate
s {$sel:templateName:CreateEmailTemplate' :: Text
templateName = Text
a} :: CreateEmailTemplate)
createEmailTemplate_templateContent :: Lens.Lens' CreateEmailTemplate EmailTemplateContent
createEmailTemplate_templateContent :: (EmailTemplateContent -> f EmailTemplateContent)
-> CreateEmailTemplate -> f CreateEmailTemplate
createEmailTemplate_templateContent = (CreateEmailTemplate -> EmailTemplateContent)
-> (CreateEmailTemplate
-> EmailTemplateContent -> CreateEmailTemplate)
-> Lens
CreateEmailTemplate
CreateEmailTemplate
EmailTemplateContent
EmailTemplateContent
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEmailTemplate' {EmailTemplateContent
templateContent :: EmailTemplateContent
$sel:templateContent:CreateEmailTemplate' :: CreateEmailTemplate -> EmailTemplateContent
templateContent} -> EmailTemplateContent
templateContent) (\s :: CreateEmailTemplate
s@CreateEmailTemplate' {} EmailTemplateContent
a -> CreateEmailTemplate
s {$sel:templateContent:CreateEmailTemplate' :: EmailTemplateContent
templateContent = EmailTemplateContent
a} :: CreateEmailTemplate)
instance Core.AWSRequest CreateEmailTemplate where
type
AWSResponse CreateEmailTemplate =
CreateEmailTemplateResponse
request :: CreateEmailTemplate -> Request CreateEmailTemplate
request = Service -> CreateEmailTemplate -> Request CreateEmailTemplate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateEmailTemplate
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateEmailTemplate)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse CreateEmailTemplate))
-> Logger
-> Service
-> Proxy CreateEmailTemplate
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateEmailTemplate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> CreateEmailTemplateResponse
CreateEmailTemplateResponse'
(Int -> CreateEmailTemplateResponse)
-> Either String Int -> Either String CreateEmailTemplateResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateEmailTemplate
instance Prelude.NFData CreateEmailTemplate
instance Core.ToHeaders CreateEmailTemplate where
toHeaders :: CreateEmailTemplate -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateEmailTemplate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateEmailTemplate where
toJSON :: CreateEmailTemplate -> Value
toJSON CreateEmailTemplate' {Text
EmailTemplateContent
templateContent :: EmailTemplateContent
templateName :: Text
$sel:templateContent:CreateEmailTemplate' :: CreateEmailTemplate -> EmailTemplateContent
$sel:templateName:CreateEmailTemplate' :: CreateEmailTemplate -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TemplateName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
templateName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"TemplateContent" Text -> EmailTemplateContent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EmailTemplateContent
templateContent)
]
)
instance Core.ToPath CreateEmailTemplate where
toPath :: CreateEmailTemplate -> ByteString
toPath = ByteString -> CreateEmailTemplate -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v2/email/templates"
instance Core.ToQuery CreateEmailTemplate where
toQuery :: CreateEmailTemplate -> QueryString
toQuery = QueryString -> CreateEmailTemplate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateEmailTemplateResponse = CreateEmailTemplateResponse'
{
CreateEmailTemplateResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateEmailTemplateResponse -> CreateEmailTemplateResponse -> Bool
(CreateEmailTemplateResponse
-> CreateEmailTemplateResponse -> Bool)
-> (CreateEmailTemplateResponse
-> CreateEmailTemplateResponse -> Bool)
-> Eq CreateEmailTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateEmailTemplateResponse -> CreateEmailTemplateResponse -> Bool
$c/= :: CreateEmailTemplateResponse -> CreateEmailTemplateResponse -> Bool
== :: CreateEmailTemplateResponse -> CreateEmailTemplateResponse -> Bool
$c== :: CreateEmailTemplateResponse -> CreateEmailTemplateResponse -> Bool
Prelude.Eq, ReadPrec [CreateEmailTemplateResponse]
ReadPrec CreateEmailTemplateResponse
Int -> ReadS CreateEmailTemplateResponse
ReadS [CreateEmailTemplateResponse]
(Int -> ReadS CreateEmailTemplateResponse)
-> ReadS [CreateEmailTemplateResponse]
-> ReadPrec CreateEmailTemplateResponse
-> ReadPrec [CreateEmailTemplateResponse]
-> Read CreateEmailTemplateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateEmailTemplateResponse]
$creadListPrec :: ReadPrec [CreateEmailTemplateResponse]
readPrec :: ReadPrec CreateEmailTemplateResponse
$creadPrec :: ReadPrec CreateEmailTemplateResponse
readList :: ReadS [CreateEmailTemplateResponse]
$creadList :: ReadS [CreateEmailTemplateResponse]
readsPrec :: Int -> ReadS CreateEmailTemplateResponse
$creadsPrec :: Int -> ReadS CreateEmailTemplateResponse
Prelude.Read, Int -> CreateEmailTemplateResponse -> ShowS
[CreateEmailTemplateResponse] -> ShowS
CreateEmailTemplateResponse -> String
(Int -> CreateEmailTemplateResponse -> ShowS)
-> (CreateEmailTemplateResponse -> String)
-> ([CreateEmailTemplateResponse] -> ShowS)
-> Show CreateEmailTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateEmailTemplateResponse] -> ShowS
$cshowList :: [CreateEmailTemplateResponse] -> ShowS
show :: CreateEmailTemplateResponse -> String
$cshow :: CreateEmailTemplateResponse -> String
showsPrec :: Int -> CreateEmailTemplateResponse -> ShowS
$cshowsPrec :: Int -> CreateEmailTemplateResponse -> ShowS
Prelude.Show, (forall x.
CreateEmailTemplateResponse -> Rep CreateEmailTemplateResponse x)
-> (forall x.
Rep CreateEmailTemplateResponse x -> CreateEmailTemplateResponse)
-> Generic CreateEmailTemplateResponse
forall x.
Rep CreateEmailTemplateResponse x -> CreateEmailTemplateResponse
forall x.
CreateEmailTemplateResponse -> Rep CreateEmailTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateEmailTemplateResponse x -> CreateEmailTemplateResponse
$cfrom :: forall x.
CreateEmailTemplateResponse -> Rep CreateEmailTemplateResponse x
Prelude.Generic)
newCreateEmailTemplateResponse ::
Prelude.Int ->
CreateEmailTemplateResponse
newCreateEmailTemplateResponse :: Int -> CreateEmailTemplateResponse
newCreateEmailTemplateResponse Int
pHttpStatus_ =
CreateEmailTemplateResponse' :: Int -> CreateEmailTemplateResponse
CreateEmailTemplateResponse'
{ $sel:httpStatus:CreateEmailTemplateResponse' :: Int
httpStatus =
Int
pHttpStatus_
}
createEmailTemplateResponse_httpStatus :: Lens.Lens' CreateEmailTemplateResponse Prelude.Int
createEmailTemplateResponse_httpStatus :: (Int -> f Int)
-> CreateEmailTemplateResponse -> f CreateEmailTemplateResponse
createEmailTemplateResponse_httpStatus = (CreateEmailTemplateResponse -> Int)
-> (CreateEmailTemplateResponse
-> Int -> CreateEmailTemplateResponse)
-> Lens
CreateEmailTemplateResponse CreateEmailTemplateResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEmailTemplateResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateEmailTemplateResponse' :: CreateEmailTemplateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateEmailTemplateResponse
s@CreateEmailTemplateResponse' {} Int
a -> CreateEmailTemplateResponse
s {$sel:httpStatus:CreateEmailTemplateResponse' :: Int
httpStatus = Int
a} :: CreateEmailTemplateResponse)
instance Prelude.NFData CreateEmailTemplateResponse