{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:version:DeleteEmailTemplate' :: Maybe Text
version = 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 :: Lens' DeleteEmailTemplate (Maybe Text)
deleteEmailTemplate_version = 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 :: Lens' DeleteEmailTemplate Text
deleteEmailTemplate_templateName = 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 :: (Service -> Service)
-> DeleteEmailTemplate -> Request DeleteEmailTemplate
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteEmailTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEmailTemplate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> MessageBody -> DeleteEmailTemplateResponse
DeleteEmailTemplateResponse'
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)
      )

instance Prelude.Hashable DeleteEmailTemplate where
  hashWithSalt :: Int -> DeleteEmailTemplate -> Int
hashWithSalt Int
_salt DeleteEmailTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteEmailTemplate' :: DeleteEmailTemplate -> Text
$sel:version:DeleteEmailTemplate' :: DeleteEmailTemplate -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
version
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
templateName

instance Prelude.NFData DeleteEmailTemplate where
  rnf :: DeleteEmailTemplate -> ()
rnf DeleteEmailTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteEmailTemplate' :: DeleteEmailTemplate -> Text
$sel:version:DeleteEmailTemplate' :: DeleteEmailTemplate -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
version
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
templateName

instance Data.ToHeaders DeleteEmailTemplate where
  toHeaders :: DeleteEmailTemplate -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/templates/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
templateName, ByteString
"/email"]

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"version" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: 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
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]
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
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.
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'
      { $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 :: Lens' DeleteEmailTemplateResponse Int
deleteEmailTemplateResponse_httpStatus = 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 :: Lens' DeleteEmailTemplateResponse MessageBody
deleteEmailTemplateResponse_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 where
  rnf :: DeleteEmailTemplateResponse -> ()
rnf DeleteEmailTemplateResponse' {Int
MessageBody
messageBody :: MessageBody
httpStatus :: Int
$sel:messageBody:DeleteEmailTemplateResponse' :: DeleteEmailTemplateResponse -> MessageBody
$sel:httpStatus:DeleteEmailTemplateResponse' :: DeleteEmailTemplateResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MessageBody
messageBody