{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
$c== :: UpdateTemplate -> UpdateTemplate -> Bool
== :: UpdateTemplate -> UpdateTemplate -> Bool
$c/= :: UpdateTemplate -> UpdateTemplate -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS UpdateTemplate
readsPrec :: Int -> ReadS UpdateTemplate
$creadList :: ReadS [UpdateTemplate]
readList :: ReadS [UpdateTemplate]
$creadPrec :: ReadPrec UpdateTemplate
readPrec :: ReadPrec UpdateTemplate
$creadListPrec :: ReadPrec [UpdateTemplate]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> UpdateTemplate -> ShowS
showsPrec :: Int -> UpdateTemplate -> ShowS
$cshow :: UpdateTemplate -> String
show :: UpdateTemplate -> String
$cshowList :: [UpdateTemplate] -> ShowS
showList :: [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
$cfrom :: forall x. UpdateTemplate -> Rep UpdateTemplate x
from :: forall x. UpdateTemplate -> Rep UpdateTemplate x
$cto :: forall x. Rep UpdateTemplate x -> UpdateTemplate
to :: forall x. Rep UpdateTemplate x -> UpdateTemplate
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' {$sel:template:UpdateTemplate' :: Template
template = Template
pTemplate_}

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

instance Core.AWSRequest UpdateTemplate where
  type
    AWSResponse UpdateTemplate =
      UpdateTemplateResponse
  request :: (Service -> Service) -> UpdateTemplate -> Request UpdateTemplate
request Service -> Service
overrides =
    Service -> UpdateTemplate -> Request UpdateTemplate
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTemplate)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse UpdateTemplate))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTemplate)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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 a. a -> Either String a
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 where
  hashWithSalt :: Int -> UpdateTemplate -> Int
hashWithSalt Int
_salt UpdateTemplate' {Template
$sel:template:UpdateTemplate' :: UpdateTemplate -> Template
template :: Template
..} =
    Int
_salt Int -> Template -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Template
template

instance Prelude.NFData UpdateTemplate where
  rnf :: UpdateTemplate -> ()
rnf UpdateTemplate' {Template
$sel:template:UpdateTemplate' :: UpdateTemplate -> Template
template :: Template
..} = Template -> ()
forall a. NFData a => a -> ()
Prelude.rnf Template
template

instance Data.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 Data.ToPath UpdateTemplate where
  toPath :: UpdateTemplate -> ByteString
toPath = ByteString -> UpdateTemplate -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery UpdateTemplate where
  toQuery :: UpdateTemplate -> QueryString
toQuery UpdateTemplate' {Template
$sel:template:UpdateTemplate' :: UpdateTemplate -> Template
template :: Template
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"UpdateTemplate" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"Template" ByteString -> Template -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: 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
$c== :: UpdateTemplateResponse -> UpdateTemplateResponse -> Bool
== :: UpdateTemplateResponse -> UpdateTemplateResponse -> Bool
$c/= :: UpdateTemplateResponse -> UpdateTemplateResponse -> Bool
/= :: 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
$creadsPrec :: Int -> ReadS UpdateTemplateResponse
readsPrec :: Int -> ReadS UpdateTemplateResponse
$creadList :: ReadS [UpdateTemplateResponse]
readList :: ReadS [UpdateTemplateResponse]
$creadPrec :: ReadPrec UpdateTemplateResponse
readPrec :: ReadPrec UpdateTemplateResponse
$creadListPrec :: ReadPrec [UpdateTemplateResponse]
readListPrec :: ReadPrec [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
$cshowsPrec :: Int -> UpdateTemplateResponse -> ShowS
showsPrec :: Int -> UpdateTemplateResponse -> ShowS
$cshow :: UpdateTemplateResponse -> String
show :: UpdateTemplateResponse -> String
$cshowList :: [UpdateTemplateResponse] -> ShowS
showList :: [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
$cfrom :: forall x. UpdateTemplateResponse -> Rep UpdateTemplateResponse x
from :: forall x. UpdateTemplateResponse -> Rep UpdateTemplateResponse x
$cto :: forall x. Rep UpdateTemplateResponse x -> UpdateTemplateResponse
to :: forall x. Rep UpdateTemplateResponse x -> UpdateTemplateResponse
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' {$sel:httpStatus:UpdateTemplateResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData UpdateTemplateResponse where
  rnf :: UpdateTemplateResponse -> ()
rnf UpdateTemplateResponse' {Int
$sel:httpStatus:UpdateTemplateResponse' :: UpdateTemplateResponse -> Int
httpStatus :: Int
..} =
    Int -> ()
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus