{-# 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.SESV2.DeleteEmailTemplate
-- 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)
--
-- Deletes an email template.
--
-- You can execute this operation no more than once per second.
module Amazonka.SESV2.DeleteEmailTemplate
  ( -- * Creating a Request
    DeleteEmailTemplate (..),
    newDeleteEmailTemplate,

    -- * Request Lenses
    deleteEmailTemplate_templateName,

    -- * Destructuring the Response
    DeleteEmailTemplateResponse (..),
    newDeleteEmailTemplateResponse,

    -- * Response Lenses
    deleteEmailTemplateResponse_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

-- | Represents a request to delete an email template. For more information,
-- see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-personalized-email-api.html Amazon SES Developer Guide>.
--
-- /See:/ 'newDeleteEmailTemplate' smart constructor.
data DeleteEmailTemplate = DeleteEmailTemplate'
  { -- | The name of the template to be deleted.
    DeleteEmailTemplate -> Text
templateName :: Prelude.Text
  }
  deriving (DeleteEmailTemplate -> DeleteEmailTemplate -> Bool
(DeleteEmailTemplate -> DeleteEmailTemplate -> Bool)
-> (DeleteEmailTemplate -> DeleteEmailTemplate -> Bool)
-> Eq DeleteEmailTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEmailTemplate -> DeleteEmailTemplate -> Bool
$c/= :: DeleteEmailTemplate -> DeleteEmailTemplate -> Bool
== :: DeleteEmailTemplate -> DeleteEmailTemplate -> Bool
$c== :: DeleteEmailTemplate -> DeleteEmailTemplate -> Bool
Prelude.Eq, ReadPrec [DeleteEmailTemplate]
ReadPrec DeleteEmailTemplate
Int -> ReadS DeleteEmailTemplate
ReadS [DeleteEmailTemplate]
(Int -> ReadS DeleteEmailTemplate)
-> ReadS [DeleteEmailTemplate]
-> ReadPrec DeleteEmailTemplate
-> ReadPrec [DeleteEmailTemplate]
-> Read DeleteEmailTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteEmailTemplate]
$creadListPrec :: ReadPrec [DeleteEmailTemplate]
readPrec :: ReadPrec DeleteEmailTemplate
$creadPrec :: ReadPrec DeleteEmailTemplate
readList :: ReadS [DeleteEmailTemplate]
$creadList :: ReadS [DeleteEmailTemplate]
readsPrec :: Int -> ReadS DeleteEmailTemplate
$creadsPrec :: Int -> ReadS DeleteEmailTemplate
Prelude.Read, Int -> DeleteEmailTemplate -> ShowS
[DeleteEmailTemplate] -> ShowS
DeleteEmailTemplate -> String
(Int -> DeleteEmailTemplate -> ShowS)
-> (DeleteEmailTemplate -> String)
-> ([DeleteEmailTemplate] -> ShowS)
-> Show DeleteEmailTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEmailTemplate] -> ShowS
$cshowList :: [DeleteEmailTemplate] -> ShowS
show :: DeleteEmailTemplate -> String
$cshow :: DeleteEmailTemplate -> String
showsPrec :: Int -> DeleteEmailTemplate -> ShowS
$cshowsPrec :: Int -> DeleteEmailTemplate -> ShowS
Prelude.Show, (forall x. DeleteEmailTemplate -> Rep DeleteEmailTemplate x)
-> (forall x. Rep DeleteEmailTemplate x -> DeleteEmailTemplate)
-> Generic DeleteEmailTemplate
forall x. Rep DeleteEmailTemplate x -> DeleteEmailTemplate
forall x. DeleteEmailTemplate -> Rep DeleteEmailTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteEmailTemplate x -> DeleteEmailTemplate
$cfrom :: forall x. DeleteEmailTemplate -> Rep DeleteEmailTemplate x
Prelude.Generic)

-- |
-- Create a value of 'DeleteEmailTemplate' 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:
--
-- 'templateName', 'deleteEmailTemplate_templateName' - The name of the template to be deleted.
newDeleteEmailTemplate ::
  -- | 'templateName'
  Prelude.Text ->
  DeleteEmailTemplate
newDeleteEmailTemplate :: Text -> DeleteEmailTemplate
newDeleteEmailTemplate Text
pTemplateName_ =
  DeleteEmailTemplate' :: Text -> DeleteEmailTemplate
DeleteEmailTemplate' {$sel:templateName:DeleteEmailTemplate' :: Text
templateName = Text
pTemplateName_}

-- | The name of the template to be deleted.
deleteEmailTemplate_templateName :: Lens.Lens' DeleteEmailTemplate Prelude.Text
deleteEmailTemplate_templateName :: (Text -> f Text) -> DeleteEmailTemplate -> f DeleteEmailTemplate
deleteEmailTemplate_templateName = (DeleteEmailTemplate -> Text)
-> (DeleteEmailTemplate -> Text -> DeleteEmailTemplate)
-> Lens DeleteEmailTemplate DeleteEmailTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEmailTemplate' {Text
templateName :: Text
$sel:templateName:DeleteEmailTemplate' :: DeleteEmailTemplate -> Text
templateName} -> Text
templateName) (\s :: DeleteEmailTemplate
s@DeleteEmailTemplate' {} Text
a -> DeleteEmailTemplate
s {$sel:templateName:DeleteEmailTemplate' :: Text
templateName = Text
a} :: DeleteEmailTemplate)

instance Core.AWSRequest DeleteEmailTemplate where
  type
    AWSResponse DeleteEmailTemplate =
      DeleteEmailTemplateResponse
  request :: DeleteEmailTemplate -> Request DeleteEmailTemplate
request = Service -> DeleteEmailTemplate -> Request DeleteEmailTemplate
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteEmailTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEmailTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteEmailTemplate))
-> Logger
-> Service
-> Proxy DeleteEmailTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEmailTemplate)))
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 -> DeleteEmailTemplateResponse
DeleteEmailTemplateResponse'
            (Int -> DeleteEmailTemplateResponse)
-> Either String Int -> Either String DeleteEmailTemplateResponse
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 DeleteEmailTemplate

instance Prelude.NFData DeleteEmailTemplate

instance Core.ToHeaders DeleteEmailTemplate where
  toHeaders :: DeleteEmailTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteEmailTemplate -> 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.ToPath DeleteEmailTemplate where
  toPath :: DeleteEmailTemplate -> ByteString
toPath DeleteEmailTemplate' {Text
templateName :: Text
$sel:templateName:DeleteEmailTemplate' :: DeleteEmailTemplate -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v2/email/templates/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
templateName]

instance Core.ToQuery DeleteEmailTemplate where
  toQuery :: DeleteEmailTemplate -> QueryString
toQuery = QueryString -> DeleteEmailTemplate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | If the action is successful, the service sends back an HTTP 200 response
-- with an empty HTTP body.
--
-- /See:/ 'newDeleteEmailTemplateResponse' smart constructor.
data DeleteEmailTemplateResponse = DeleteEmailTemplateResponse'
  { -- | The response's http status code.
    DeleteEmailTemplateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteEmailTemplateResponse -> DeleteEmailTemplateResponse -> Bool
(DeleteEmailTemplateResponse
 -> DeleteEmailTemplateResponse -> Bool)
-> (DeleteEmailTemplateResponse
    -> DeleteEmailTemplateResponse -> Bool)
-> Eq DeleteEmailTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEmailTemplateResponse -> DeleteEmailTemplateResponse -> Bool
$c/= :: DeleteEmailTemplateResponse -> DeleteEmailTemplateResponse -> Bool
== :: DeleteEmailTemplateResponse -> DeleteEmailTemplateResponse -> Bool
$c== :: DeleteEmailTemplateResponse -> DeleteEmailTemplateResponse -> Bool
Prelude.Eq, ReadPrec [DeleteEmailTemplateResponse]
ReadPrec DeleteEmailTemplateResponse
Int -> ReadS DeleteEmailTemplateResponse
ReadS [DeleteEmailTemplateResponse]
(Int -> ReadS DeleteEmailTemplateResponse)
-> ReadS [DeleteEmailTemplateResponse]
-> ReadPrec DeleteEmailTemplateResponse
-> ReadPrec [DeleteEmailTemplateResponse]
-> Read DeleteEmailTemplateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteEmailTemplateResponse]
$creadListPrec :: ReadPrec [DeleteEmailTemplateResponse]
readPrec :: ReadPrec DeleteEmailTemplateResponse
$creadPrec :: ReadPrec DeleteEmailTemplateResponse
readList :: ReadS [DeleteEmailTemplateResponse]
$creadList :: ReadS [DeleteEmailTemplateResponse]
readsPrec :: Int -> ReadS DeleteEmailTemplateResponse
$creadsPrec :: Int -> ReadS DeleteEmailTemplateResponse
Prelude.Read, Int -> DeleteEmailTemplateResponse -> ShowS
[DeleteEmailTemplateResponse] -> ShowS
DeleteEmailTemplateResponse -> String
(Int -> DeleteEmailTemplateResponse -> ShowS)
-> (DeleteEmailTemplateResponse -> String)
-> ([DeleteEmailTemplateResponse] -> ShowS)
-> Show DeleteEmailTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEmailTemplateResponse] -> ShowS
$cshowList :: [DeleteEmailTemplateResponse] -> ShowS
show :: DeleteEmailTemplateResponse -> String
$cshow :: DeleteEmailTemplateResponse -> String
showsPrec :: Int -> DeleteEmailTemplateResponse -> ShowS
$cshowsPrec :: Int -> DeleteEmailTemplateResponse -> ShowS
Prelude.Show, (forall x.
 DeleteEmailTemplateResponse -> Rep DeleteEmailTemplateResponse x)
-> (forall x.
    Rep DeleteEmailTemplateResponse x -> DeleteEmailTemplateResponse)
-> Generic DeleteEmailTemplateResponse
forall x.
Rep DeleteEmailTemplateResponse x -> DeleteEmailTemplateResponse
forall x.
DeleteEmailTemplateResponse -> Rep DeleteEmailTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteEmailTemplateResponse x -> DeleteEmailTemplateResponse
$cfrom :: forall x.
DeleteEmailTemplateResponse -> Rep DeleteEmailTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteEmailTemplateResponse' 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', 'deleteEmailTemplateResponse_httpStatus' - The response's http status code.
newDeleteEmailTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteEmailTemplateResponse
newDeleteEmailTemplateResponse :: Int -> DeleteEmailTemplateResponse
newDeleteEmailTemplateResponse Int
pHttpStatus_ =
  DeleteEmailTemplateResponse' :: Int -> DeleteEmailTemplateResponse
DeleteEmailTemplateResponse'
    { $sel:httpStatus:DeleteEmailTemplateResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeleteEmailTemplateResponse