{-# 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
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]
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
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. 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' {$sel:template:UpdateTemplate' :: Template
template = Template
pTemplate_}

-- | Undocumented member.
updateTemplate_template :: Lens.Lens' UpdateTemplate Template
updateTemplate_template :: Lens' UpdateTemplate Template
updateTemplate_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 :: (Service -> Service) -> UpdateTemplate -> Request UpdateTemplate
request Service -> Service
overrides =
    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 =
    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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateTemplate where
  hashWithSalt :: Int -> UpdateTemplate -> Int
hashWithSalt Int
_salt UpdateTemplate' {Template
template :: Template
$sel:template:UpdateTemplate' :: UpdateTemplate -> Template
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Template
template

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

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

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

instance Data.ToQuery UpdateTemplate where
  toQuery :: UpdateTemplate -> QueryString
toQuery UpdateTemplate' {Template
template :: Template
$sel:template:UpdateTemplate' :: UpdateTemplate -> Template
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"UpdateTemplate" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"Template" 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
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]
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
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. 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' {$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 = 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 where
  rnf :: UpdateTemplateResponse -> ()
rnf UpdateTemplateResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateTemplateResponse' :: UpdateTemplateResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus