{-# 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.Pinpoint.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 a message template for messages that were sent through the email
-- channel.
module Amazonka.Pinpoint.DeleteEmailTemplate
  ( -- * Creating a Request
    DeleteEmailTemplate (..),
    newDeleteEmailTemplate,

    -- * Request Lenses
    deleteEmailTemplate_version,
    deleteEmailTemplate_templateName,

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

    -- * Response Lenses
    deleteEmailTemplateResponse_httpStatus,
    deleteEmailTemplateResponse_messageBody,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteEmailTemplate' smart constructor.
data DeleteEmailTemplate = DeleteEmailTemplate'
  { -- | The unique identifier for the version of the message template to update,
    -- retrieve information about, or delete. To retrieve identifiers and other
    -- information for all the versions of a template, use the Template
    -- Versions resource.
    --
    -- If specified, this value must match the identifier for an existing
    -- template version. If specified for an update operation, this value must
    -- match the identifier for the latest existing version of the template.
    -- This restriction helps ensure that race conditions don\'t occur.
    --
    -- If you don\'t specify a value for this parameter, Amazon Pinpoint does
    -- the following:
    --
    -- -   For a get operation, retrieves information about the active version
    --     of the template.
    --
    -- -   For an update operation, saves the updates to (overwrites) the
    --     latest existing version of the template, if the create-new-version
    --     parameter isn\'t used or is set to false.
    --
    -- -   For a delete operation, deletes the template, including all versions
    --     of the template.
    DeleteEmailTemplate -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | The name of the message template. A template name must start with an
    -- alphanumeric character and can contain a maximum of 128 characters. The
    -- characters can be alphanumeric characters, underscores (_), or hyphens
    -- (-). Template names are case sensitive.
    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:
--
-- 'version', 'deleteEmailTemplate_version' - The unique identifier for the version of the message template to update,
-- retrieve information about, or delete. To retrieve identifiers and other
-- information for all the versions of a template, use the Template
-- Versions resource.
--
-- If specified, this value must match the identifier for an existing
-- template version. If specified for an update operation, this value must
-- match the identifier for the latest existing version of the template.
-- This restriction helps ensure that race conditions don\'t occur.
--
-- If you don\'t specify a value for this parameter, Amazon Pinpoint does
-- the following:
--
-- -   For a get operation, retrieves information about the active version
--     of the template.
--
-- -   For an update operation, saves the updates to (overwrites) the
--     latest existing version of the template, if the create-new-version
--     parameter isn\'t used or is set to false.
--
-- -   For a delete operation, deletes the template, including all versions
--     of the template.
--
-- 'templateName', 'deleteEmailTemplate_templateName' - The name of the message template. A template name must start with an
-- alphanumeric character and can contain a maximum of 128 characters. The
-- characters can be alphanumeric characters, underscores (_), or hyphens
-- (-). Template names are case sensitive.
newDeleteEmailTemplate ::
  -- | 'templateName'
  Prelude.Text ->
  DeleteEmailTemplate
newDeleteEmailTemplate :: Text -> DeleteEmailTemplate
newDeleteEmailTemplate Text
pTemplateName_ =
  DeleteEmailTemplate' :: Maybe Text -> Text -> DeleteEmailTemplate
DeleteEmailTemplate'
    { $sel:version:DeleteEmailTemplate' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:templateName:DeleteEmailTemplate' :: Text
templateName = Text
pTemplateName_
    }

-- | The unique identifier for the version of the message template to update,
-- retrieve information about, or delete. To retrieve identifiers and other
-- information for all the versions of a template, use the Template
-- Versions resource.
--
-- If specified, this value must match the identifier for an existing
-- template version. If specified for an update operation, this value must
-- match the identifier for the latest existing version of the template.
-- This restriction helps ensure that race conditions don\'t occur.
--
-- If you don\'t specify a value for this parameter, Amazon Pinpoint does
-- the following:
--
-- -   For a get operation, retrieves information about the active version
--     of the template.
--
-- -   For an update operation, saves the updates to (overwrites) the
--     latest existing version of the template, if the create-new-version
--     parameter isn\'t used or is set to false.
--
-- -   For a delete operation, deletes the template, including all versions
--     of the template.
deleteEmailTemplate_version :: Lens.Lens' DeleteEmailTemplate (Prelude.Maybe Prelude.Text)
deleteEmailTemplate_version :: (Maybe Text -> f (Maybe Text))
-> DeleteEmailTemplate -> f DeleteEmailTemplate
deleteEmailTemplate_version = (DeleteEmailTemplate -> Maybe Text)
-> (DeleteEmailTemplate -> Maybe Text -> DeleteEmailTemplate)
-> Lens
     DeleteEmailTemplate DeleteEmailTemplate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEmailTemplate' {Maybe Text
version :: Maybe Text
$sel:version:DeleteEmailTemplate' :: DeleteEmailTemplate -> Maybe Text
version} -> Maybe Text
version) (\s :: DeleteEmailTemplate
s@DeleteEmailTemplate' {} Maybe Text
a -> DeleteEmailTemplate
s {$sel:version:DeleteEmailTemplate' :: Maybe Text
version = Maybe Text
a} :: DeleteEmailTemplate)

-- | The name of the message template. A template name must start with an
-- alphanumeric character and can contain a maximum of 128 characters. The
-- characters can be alphanumeric characters, underscores (_), or hyphens
-- (-). Template names are case sensitive.
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
 -> Object
 -> Either String (AWSResponse DeleteEmailTemplate))
-> Logger
-> Service
-> Proxy DeleteEmailTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEmailTemplate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> MessageBody -> DeleteEmailTemplateResponse
DeleteEmailTemplateResponse'
            (Int -> MessageBody -> DeleteEmailTemplateResponse)
-> Either String Int
-> Either String (MessageBody -> 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))
            Either String (MessageBody -> DeleteEmailTemplateResponse)
-> Either String MessageBody
-> Either String DeleteEmailTemplateResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String MessageBody
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

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' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteEmailTemplate' :: DeleteEmailTemplate -> Text
$sel:version:DeleteEmailTemplate' :: DeleteEmailTemplate -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/templates/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
templateName, ByteString
"/email"]

instance Core.ToQuery DeleteEmailTemplate where
  toQuery :: DeleteEmailTemplate -> QueryString
toQuery DeleteEmailTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteEmailTemplate' :: DeleteEmailTemplate -> Text
$sel:version:DeleteEmailTemplate' :: DeleteEmailTemplate -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"version" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
version]

-- | /See:/ 'newDeleteEmailTemplateResponse' smart constructor.
data DeleteEmailTemplateResponse = DeleteEmailTemplateResponse'
  { -- | The response's http status code.
    DeleteEmailTemplateResponse -> Int
httpStatus :: Prelude.Int,
    DeleteEmailTemplateResponse -> MessageBody
messageBody :: MessageBody
  }
  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.
--
-- 'messageBody', 'deleteEmailTemplateResponse_messageBody' - Undocumented member.
newDeleteEmailTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'messageBody'
  MessageBody ->
  DeleteEmailTemplateResponse
newDeleteEmailTemplateResponse :: Int -> MessageBody -> DeleteEmailTemplateResponse
newDeleteEmailTemplateResponse
  Int
pHttpStatus_
  MessageBody
pMessageBody_ =
    DeleteEmailTemplateResponse' :: Int -> MessageBody -> DeleteEmailTemplateResponse
DeleteEmailTemplateResponse'
      { $sel:httpStatus:DeleteEmailTemplateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:messageBody:DeleteEmailTemplateResponse' :: MessageBody
messageBody = MessageBody
pMessageBody_
      }

-- | 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)

-- | Undocumented member.
deleteEmailTemplateResponse_messageBody :: Lens.Lens' DeleteEmailTemplateResponse MessageBody
deleteEmailTemplateResponse_messageBody :: (MessageBody -> f MessageBody)
-> DeleteEmailTemplateResponse -> f DeleteEmailTemplateResponse
deleteEmailTemplateResponse_messageBody = (DeleteEmailTemplateResponse -> MessageBody)
-> (DeleteEmailTemplateResponse
    -> MessageBody -> DeleteEmailTemplateResponse)
-> Lens
     DeleteEmailTemplateResponse
     DeleteEmailTemplateResponse
     MessageBody
     MessageBody
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEmailTemplateResponse' {MessageBody
messageBody :: MessageBody
$sel:messageBody:DeleteEmailTemplateResponse' :: DeleteEmailTemplateResponse -> MessageBody
messageBody} -> MessageBody
messageBody) (\s :: DeleteEmailTemplateResponse
s@DeleteEmailTemplateResponse' {} MessageBody
a -> DeleteEmailTemplateResponse
s {$sel:messageBody:DeleteEmailTemplateResponse' :: MessageBody
messageBody = MessageBody
a} :: DeleteEmailTemplateResponse)

instance Prelude.NFData DeleteEmailTemplateResponse