{-# 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.DeleteSmsTemplate
-- 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 SMS
-- channel.
module Amazonka.Pinpoint.DeleteSmsTemplate
  ( -- * Creating a Request
    DeleteSmsTemplate (..),
    newDeleteSmsTemplate,

    -- * Request Lenses
    deleteSmsTemplate_version,
    deleteSmsTemplate_templateName,

    -- * Destructuring the Response
    DeleteSmsTemplateResponse (..),
    newDeleteSmsTemplateResponse,

    -- * Response Lenses
    deleteSmsTemplateResponse_httpStatus,
    deleteSmsTemplateResponse_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:/ 'newDeleteSmsTemplate' smart constructor.
data DeleteSmsTemplate = DeleteSmsTemplate'
  { -- | 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.
    DeleteSmsTemplate -> 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.
    DeleteSmsTemplate -> Text
templateName :: Prelude.Text
  }
  deriving (DeleteSmsTemplate -> DeleteSmsTemplate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSmsTemplate -> DeleteSmsTemplate -> Bool
$c/= :: DeleteSmsTemplate -> DeleteSmsTemplate -> Bool
== :: DeleteSmsTemplate -> DeleteSmsTemplate -> Bool
$c== :: DeleteSmsTemplate -> DeleteSmsTemplate -> Bool
Prelude.Eq, ReadPrec [DeleteSmsTemplate]
ReadPrec DeleteSmsTemplate
Int -> ReadS DeleteSmsTemplate
ReadS [DeleteSmsTemplate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteSmsTemplate]
$creadListPrec :: ReadPrec [DeleteSmsTemplate]
readPrec :: ReadPrec DeleteSmsTemplate
$creadPrec :: ReadPrec DeleteSmsTemplate
readList :: ReadS [DeleteSmsTemplate]
$creadList :: ReadS [DeleteSmsTemplate]
readsPrec :: Int -> ReadS DeleteSmsTemplate
$creadsPrec :: Int -> ReadS DeleteSmsTemplate
Prelude.Read, Int -> DeleteSmsTemplate -> ShowS
[DeleteSmsTemplate] -> ShowS
DeleteSmsTemplate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSmsTemplate] -> ShowS
$cshowList :: [DeleteSmsTemplate] -> ShowS
show :: DeleteSmsTemplate -> String
$cshow :: DeleteSmsTemplate -> String
showsPrec :: Int -> DeleteSmsTemplate -> ShowS
$cshowsPrec :: Int -> DeleteSmsTemplate -> ShowS
Prelude.Show, forall x. Rep DeleteSmsTemplate x -> DeleteSmsTemplate
forall x. DeleteSmsTemplate -> Rep DeleteSmsTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteSmsTemplate x -> DeleteSmsTemplate
$cfrom :: forall x. DeleteSmsTemplate -> Rep DeleteSmsTemplate x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSmsTemplate' 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', 'deleteSmsTemplate_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', 'deleteSmsTemplate_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.
newDeleteSmsTemplate ::
  -- | 'templateName'
  Prelude.Text ->
  DeleteSmsTemplate
newDeleteSmsTemplate :: Text -> DeleteSmsTemplate
newDeleteSmsTemplate Text
pTemplateName_ =
  DeleteSmsTemplate'
    { $sel:version:DeleteSmsTemplate' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing,
      $sel:templateName:DeleteSmsTemplate' :: 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.
deleteSmsTemplate_version :: Lens.Lens' DeleteSmsTemplate (Prelude.Maybe Prelude.Text)
deleteSmsTemplate_version :: Lens' DeleteSmsTemplate (Maybe Text)
deleteSmsTemplate_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSmsTemplate' {Maybe Text
version :: Maybe Text
$sel:version:DeleteSmsTemplate' :: DeleteSmsTemplate -> Maybe Text
version} -> Maybe Text
version) (\s :: DeleteSmsTemplate
s@DeleteSmsTemplate' {} Maybe Text
a -> DeleteSmsTemplate
s {$sel:version:DeleteSmsTemplate' :: Maybe Text
version = Maybe Text
a} :: DeleteSmsTemplate)

-- | 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.
deleteSmsTemplate_templateName :: Lens.Lens' DeleteSmsTemplate Prelude.Text
deleteSmsTemplate_templateName :: Lens' DeleteSmsTemplate Text
deleteSmsTemplate_templateName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSmsTemplate' {Text
templateName :: Text
$sel:templateName:DeleteSmsTemplate' :: DeleteSmsTemplate -> Text
templateName} -> Text
templateName) (\s :: DeleteSmsTemplate
s@DeleteSmsTemplate' {} Text
a -> DeleteSmsTemplate
s {$sel:templateName:DeleteSmsTemplate' :: Text
templateName = Text
a} :: DeleteSmsTemplate)

instance Core.AWSRequest DeleteSmsTemplate where
  type
    AWSResponse DeleteSmsTemplate =
      DeleteSmsTemplateResponse
  request :: (Service -> Service)
-> DeleteSmsTemplate -> Request DeleteSmsTemplate
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 DeleteSmsTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteSmsTemplate)))
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 -> DeleteSmsTemplateResponse
DeleteSmsTemplateResponse'
            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 DeleteSmsTemplate where
  hashWithSalt :: Int -> DeleteSmsTemplate -> Int
hashWithSalt Int
_salt DeleteSmsTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteSmsTemplate' :: DeleteSmsTemplate -> Text
$sel:version:DeleteSmsTemplate' :: DeleteSmsTemplate -> 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 DeleteSmsTemplate where
  rnf :: DeleteSmsTemplate -> ()
rnf DeleteSmsTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteSmsTemplate' :: DeleteSmsTemplate -> Text
$sel:version:DeleteSmsTemplate' :: DeleteSmsTemplate -> 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 DeleteSmsTemplate where
  toHeaders :: DeleteSmsTemplate -> 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 DeleteSmsTemplate where
  toPath :: DeleteSmsTemplate -> ByteString
toPath DeleteSmsTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteSmsTemplate' :: DeleteSmsTemplate -> Text
$sel:version:DeleteSmsTemplate' :: DeleteSmsTemplate -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/templates/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
templateName, ByteString
"/sms"]

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

-- | /See:/ 'newDeleteSmsTemplateResponse' smart constructor.
data DeleteSmsTemplateResponse = DeleteSmsTemplateResponse'
  { -- | The response's http status code.
    DeleteSmsTemplateResponse -> Int
httpStatus :: Prelude.Int,
    DeleteSmsTemplateResponse -> MessageBody
messageBody :: MessageBody
  }
  deriving (DeleteSmsTemplateResponse -> DeleteSmsTemplateResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSmsTemplateResponse -> DeleteSmsTemplateResponse -> Bool
$c/= :: DeleteSmsTemplateResponse -> DeleteSmsTemplateResponse -> Bool
== :: DeleteSmsTemplateResponse -> DeleteSmsTemplateResponse -> Bool
$c== :: DeleteSmsTemplateResponse -> DeleteSmsTemplateResponse -> Bool
Prelude.Eq, ReadPrec [DeleteSmsTemplateResponse]
ReadPrec DeleteSmsTemplateResponse
Int -> ReadS DeleteSmsTemplateResponse
ReadS [DeleteSmsTemplateResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteSmsTemplateResponse]
$creadListPrec :: ReadPrec [DeleteSmsTemplateResponse]
readPrec :: ReadPrec DeleteSmsTemplateResponse
$creadPrec :: ReadPrec DeleteSmsTemplateResponse
readList :: ReadS [DeleteSmsTemplateResponse]
$creadList :: ReadS [DeleteSmsTemplateResponse]
readsPrec :: Int -> ReadS DeleteSmsTemplateResponse
$creadsPrec :: Int -> ReadS DeleteSmsTemplateResponse
Prelude.Read, Int -> DeleteSmsTemplateResponse -> ShowS
[DeleteSmsTemplateResponse] -> ShowS
DeleteSmsTemplateResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSmsTemplateResponse] -> ShowS
$cshowList :: [DeleteSmsTemplateResponse] -> ShowS
show :: DeleteSmsTemplateResponse -> String
$cshow :: DeleteSmsTemplateResponse -> String
showsPrec :: Int -> DeleteSmsTemplateResponse -> ShowS
$cshowsPrec :: Int -> DeleteSmsTemplateResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteSmsTemplateResponse x -> DeleteSmsTemplateResponse
forall x.
DeleteSmsTemplateResponse -> Rep DeleteSmsTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteSmsTemplateResponse x -> DeleteSmsTemplateResponse
$cfrom :: forall x.
DeleteSmsTemplateResponse -> Rep DeleteSmsTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSmsTemplateResponse' 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', 'deleteSmsTemplateResponse_httpStatus' - The response's http status code.
--
-- 'messageBody', 'deleteSmsTemplateResponse_messageBody' - Undocumented member.
newDeleteSmsTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'messageBody'
  MessageBody ->
  DeleteSmsTemplateResponse
newDeleteSmsTemplateResponse :: Int -> MessageBody -> DeleteSmsTemplateResponse
newDeleteSmsTemplateResponse
  Int
pHttpStatus_
  MessageBody
pMessageBody_ =
    DeleteSmsTemplateResponse'
      { $sel:httpStatus:DeleteSmsTemplateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:messageBody:DeleteSmsTemplateResponse' :: MessageBody
messageBody = MessageBody
pMessageBody_
      }

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

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

instance Prelude.NFData DeleteSmsTemplateResponse where
  rnf :: DeleteSmsTemplateResponse -> ()
rnf DeleteSmsTemplateResponse' {Int
MessageBody
messageBody :: MessageBody
httpStatus :: Int
$sel:messageBody:DeleteSmsTemplateResponse' :: DeleteSmsTemplateResponse -> MessageBody
$sel:httpStatus:DeleteSmsTemplateResponse' :: DeleteSmsTemplateResponse -> 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