{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SES.UpdateTemplate
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates an email template. Email templates enable you to send
-- personalized email to one or more destinations in a single API
-- operation. For more information, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-personalized-email-api.html Amazon SES Developer Guide>.
--
-- You can execute this operation no more than once per second.
module Amazonka.SES.UpdateTemplate
  ( -- * Creating a Request
    UpdateTemplate (..),
    newUpdateTemplate,

    -- * Request Lenses
    updateTemplate_template,

    -- * Destructuring the Response
    UpdateTemplateResponse (..),
    newUpdateTemplateResponse,

    -- * Response Lenses
    updateTemplateResponse_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.SES.Types

-- | /See:/ 'newUpdateTemplate' smart constructor.
data UpdateTemplate = UpdateTemplate'
  { UpdateTemplate -> Template
template :: Template
  }
  deriving (UpdateTemplate -> UpdateTemplate -> Bool
(UpdateTemplate -> UpdateTemplate -> Bool)
-> (UpdateTemplate -> UpdateTemplate -> Bool) -> Eq UpdateTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTemplate -> UpdateTemplate -> Bool
$c/= :: UpdateTemplate -> UpdateTemplate -> Bool
== :: UpdateTemplate -> UpdateTemplate -> Bool
$c== :: UpdateTemplate -> UpdateTemplate -> Bool
Prelude.Eq, ReadPrec [UpdateTemplate]
ReadPrec UpdateTemplate
Int -> ReadS UpdateTemplate
ReadS [UpdateTemplate]
(Int -> ReadS UpdateTemplate)
-> ReadS [UpdateTemplate]
-> ReadPrec UpdateTemplate
-> ReadPrec [UpdateTemplate]
-> Read UpdateTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTemplate]
$creadListPrec :: ReadPrec [UpdateTemplate]
readPrec :: ReadPrec UpdateTemplate
$creadPrec :: ReadPrec UpdateTemplate
readList :: ReadS [UpdateTemplate]
$creadList :: ReadS [UpdateTemplate]
readsPrec :: Int -> ReadS UpdateTemplate
$creadsPrec :: Int -> ReadS UpdateTemplate
Prelude.Read, Int -> UpdateTemplate -> ShowS
[UpdateTemplate] -> ShowS
UpdateTemplate -> String
(Int -> UpdateTemplate -> ShowS)
-> (UpdateTemplate -> String)
-> ([UpdateTemplate] -> ShowS)
-> Show UpdateTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTemplate] -> ShowS
$cshowList :: [UpdateTemplate] -> ShowS
show :: UpdateTemplate -> String
$cshow :: UpdateTemplate -> String
showsPrec :: Int -> UpdateTemplate -> ShowS
$cshowsPrec :: Int -> UpdateTemplate -> ShowS
Prelude.Show, (forall x. UpdateTemplate -> Rep UpdateTemplate x)
-> (forall x. Rep UpdateTemplate x -> UpdateTemplate)
-> Generic UpdateTemplate
forall x. Rep UpdateTemplate x -> UpdateTemplate
forall x. UpdateTemplate -> Rep UpdateTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateTemplate x -> UpdateTemplate
$cfrom :: forall x. UpdateTemplate -> Rep UpdateTemplate x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTemplate' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'template', 'updateTemplate_template' - Undocumented member.
newUpdateTemplate ::
  -- | 'template'
  Template ->
  UpdateTemplate
newUpdateTemplate :: Template -> UpdateTemplate
newUpdateTemplate Template
pTemplate_ =
  UpdateTemplate' :: Template -> UpdateTemplate
UpdateTemplate' {$sel:template:UpdateTemplate' :: Template
template = Template
pTemplate_}

-- | Undocumented member.
updateTemplate_template :: Lens.Lens' UpdateTemplate Template
updateTemplate_template :: (Template -> f Template) -> UpdateTemplate -> f UpdateTemplate
updateTemplate_template = (UpdateTemplate -> Template)
-> (UpdateTemplate -> Template -> UpdateTemplate)
-> Lens UpdateTemplate UpdateTemplate Template Template
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTemplate' {Template
template :: Template
$sel:template:UpdateTemplate' :: UpdateTemplate -> Template
template} -> Template
template) (\s :: UpdateTemplate
s@UpdateTemplate' {} Template
a -> UpdateTemplate
s {$sel:template:UpdateTemplate' :: Template
template = Template
a} :: UpdateTemplate)

instance Core.AWSRequest UpdateTemplate where
  type
    AWSResponse UpdateTemplate =
      UpdateTemplateResponse
  request :: UpdateTemplate -> Request UpdateTemplate
request = Service -> UpdateTemplate -> Request UpdateTemplate
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTemplate)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse UpdateTemplate))
-> Logger
-> Service
-> Proxy UpdateTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTemplate)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"UpdateTemplateResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> UpdateTemplateResponse
UpdateTemplateResponse'
            (Int -> UpdateTemplateResponse)
-> Either String Int -> Either String UpdateTemplateResponse
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 UpdateTemplate

instance Prelude.NFData UpdateTemplate

instance Core.ToHeaders UpdateTemplate where
  toHeaders :: UpdateTemplate -> ResponseHeaders
toHeaders = ResponseHeaders -> UpdateTemplate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath UpdateTemplate where
  toPath :: UpdateTemplate -> ByteString
toPath = ByteString -> UpdateTemplate -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery UpdateTemplate where
  toQuery :: UpdateTemplate -> QueryString
toQuery UpdateTemplate' {Template
template :: Template
$sel:template:UpdateTemplate' :: UpdateTemplate -> Template
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"UpdateTemplate" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"Template" ByteString -> Template -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Template
template
      ]

-- | /See:/ 'newUpdateTemplateResponse' smart constructor.
data UpdateTemplateResponse = UpdateTemplateResponse'
  { -- | The response's http status code.
    UpdateTemplateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateTemplateResponse -> UpdateTemplateResponse -> Bool
(UpdateTemplateResponse -> UpdateTemplateResponse -> Bool)
-> (UpdateTemplateResponse -> UpdateTemplateResponse -> Bool)
-> Eq UpdateTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTemplateResponse -> UpdateTemplateResponse -> Bool
$c/= :: UpdateTemplateResponse -> UpdateTemplateResponse -> Bool
== :: UpdateTemplateResponse -> UpdateTemplateResponse -> Bool
$c== :: UpdateTemplateResponse -> UpdateTemplateResponse -> Bool
Prelude.Eq, ReadPrec [UpdateTemplateResponse]
ReadPrec UpdateTemplateResponse
Int -> ReadS UpdateTemplateResponse
ReadS [UpdateTemplateResponse]
(Int -> ReadS UpdateTemplateResponse)
-> ReadS [UpdateTemplateResponse]
-> ReadPrec UpdateTemplateResponse
-> ReadPrec [UpdateTemplateResponse]
-> Read UpdateTemplateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTemplateResponse]
$creadListPrec :: ReadPrec [UpdateTemplateResponse]
readPrec :: ReadPrec UpdateTemplateResponse
$creadPrec :: ReadPrec UpdateTemplateResponse
readList :: ReadS [UpdateTemplateResponse]
$creadList :: ReadS [UpdateTemplateResponse]
readsPrec :: Int -> ReadS UpdateTemplateResponse
$creadsPrec :: Int -> ReadS UpdateTemplateResponse
Prelude.Read, Int -> UpdateTemplateResponse -> ShowS
[UpdateTemplateResponse] -> ShowS
UpdateTemplateResponse -> String
(Int -> UpdateTemplateResponse -> ShowS)
-> (UpdateTemplateResponse -> String)
-> ([UpdateTemplateResponse] -> ShowS)
-> Show UpdateTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTemplateResponse] -> ShowS
$cshowList :: [UpdateTemplateResponse] -> ShowS
show :: UpdateTemplateResponse -> String
$cshow :: UpdateTemplateResponse -> String
showsPrec :: Int -> UpdateTemplateResponse -> ShowS
$cshowsPrec :: Int -> UpdateTemplateResponse -> ShowS
Prelude.Show, (forall x. UpdateTemplateResponse -> Rep UpdateTemplateResponse x)
-> (forall x.
    Rep UpdateTemplateResponse x -> UpdateTemplateResponse)
-> Generic UpdateTemplateResponse
forall x. Rep UpdateTemplateResponse x -> UpdateTemplateResponse
forall x. UpdateTemplateResponse -> Rep UpdateTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateTemplateResponse x -> UpdateTemplateResponse
$cfrom :: forall x. UpdateTemplateResponse -> Rep UpdateTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTemplateResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'updateTemplateResponse_httpStatus' - The response's http status code.
newUpdateTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateTemplateResponse
newUpdateTemplateResponse :: Int -> UpdateTemplateResponse
newUpdateTemplateResponse Int
pHttpStatus_ =
  UpdateTemplateResponse' :: Int -> UpdateTemplateResponse
UpdateTemplateResponse' {$sel:httpStatus:UpdateTemplateResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
updateTemplateResponse_httpStatus :: Lens.Lens' UpdateTemplateResponse Prelude.Int
updateTemplateResponse_httpStatus :: (Int -> f Int)
-> UpdateTemplateResponse -> f UpdateTemplateResponse
updateTemplateResponse_httpStatus = (UpdateTemplateResponse -> Int)
-> (UpdateTemplateResponse -> Int -> UpdateTemplateResponse)
-> Lens UpdateTemplateResponse UpdateTemplateResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTemplateResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateTemplateResponse' :: UpdateTemplateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateTemplateResponse
s@UpdateTemplateResponse' {} Int
a -> UpdateTemplateResponse
s {$sel:httpStatus:UpdateTemplateResponse' :: Int
httpStatus = Int
a} :: UpdateTemplateResponse)

instance Prelude.NFData UpdateTemplateResponse