{-# 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-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 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.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:/ '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
(DeleteSmsTemplate -> DeleteSmsTemplate -> Bool)
-> (DeleteSmsTemplate -> DeleteSmsTemplate -> Bool)
-> Eq DeleteSmsTemplate
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]
(Int -> ReadS DeleteSmsTemplate)
-> ReadS [DeleteSmsTemplate]
-> ReadPrec DeleteSmsTemplate
-> ReadPrec [DeleteSmsTemplate]
-> Read 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
(Int -> DeleteSmsTemplate -> ShowS)
-> (DeleteSmsTemplate -> String)
-> ([DeleteSmsTemplate] -> ShowS)
-> Show DeleteSmsTemplate
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. DeleteSmsTemplate -> Rep DeleteSmsTemplate x)
-> (forall x. Rep DeleteSmsTemplate x -> DeleteSmsTemplate)
-> Generic DeleteSmsTemplate
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' :: Maybe Text -> Text -> DeleteSmsTemplate
DeleteSmsTemplate'
    { $sel:version:DeleteSmsTemplate' :: Maybe Text
version = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteSmsTemplate -> f DeleteSmsTemplate
deleteSmsTemplate_version = (DeleteSmsTemplate -> Maybe Text)
-> (DeleteSmsTemplate -> Maybe Text -> DeleteSmsTemplate)
-> Lens
     DeleteSmsTemplate DeleteSmsTemplate (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> DeleteSmsTemplate -> f DeleteSmsTemplate
deleteSmsTemplate_templateName = (DeleteSmsTemplate -> Text)
-> (DeleteSmsTemplate -> Text -> DeleteSmsTemplate)
-> Lens DeleteSmsTemplate DeleteSmsTemplate Text Text
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 :: DeleteSmsTemplate -> Request DeleteSmsTemplate
request = Service -> DeleteSmsTemplate -> Request DeleteSmsTemplate
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteSmsTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteSmsTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteSmsTemplate))
-> Logger
-> Service
-> Proxy DeleteSmsTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteSmsTemplate)))
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 -> DeleteSmsTemplateResponse
DeleteSmsTemplateResponse'
            (Int -> MessageBody -> DeleteSmsTemplateResponse)
-> Either String Int
-> Either String (MessageBody -> DeleteSmsTemplateResponse)
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 -> DeleteSmsTemplateResponse)
-> Either String MessageBody
-> Either String DeleteSmsTemplateResponse
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 DeleteSmsTemplate

instance Prelude.NFData DeleteSmsTemplate

instance Core.ToHeaders DeleteSmsTemplate where
  toHeaders :: DeleteSmsTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteSmsTemplate -> 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 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
..} =
    [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
"/sms"]

instance Core.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
..} =
    [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:/ '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
(DeleteSmsTemplateResponse -> DeleteSmsTemplateResponse -> Bool)
-> (DeleteSmsTemplateResponse -> DeleteSmsTemplateResponse -> Bool)
-> Eq DeleteSmsTemplateResponse
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]
(Int -> ReadS DeleteSmsTemplateResponse)
-> ReadS [DeleteSmsTemplateResponse]
-> ReadPrec DeleteSmsTemplateResponse
-> ReadPrec [DeleteSmsTemplateResponse]
-> Read 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
(Int -> DeleteSmsTemplateResponse -> ShowS)
-> (DeleteSmsTemplateResponse -> String)
-> ([DeleteSmsTemplateResponse] -> ShowS)
-> Show DeleteSmsTemplateResponse
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.
 DeleteSmsTemplateResponse -> Rep DeleteSmsTemplateResponse x)
-> (forall x.
    Rep DeleteSmsTemplateResponse x -> DeleteSmsTemplateResponse)
-> Generic DeleteSmsTemplateResponse
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' :: Int -> MessageBody -> DeleteSmsTemplateResponse
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 :: (Int -> f Int)
-> DeleteSmsTemplateResponse -> f DeleteSmsTemplateResponse
deleteSmsTemplateResponse_httpStatus = (DeleteSmsTemplateResponse -> Int)
-> (DeleteSmsTemplateResponse -> Int -> DeleteSmsTemplateResponse)
-> Lens DeleteSmsTemplateResponse DeleteSmsTemplateResponse Int Int
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 :: (MessageBody -> f MessageBody)
-> DeleteSmsTemplateResponse -> f DeleteSmsTemplateResponse
deleteSmsTemplateResponse_messageBody = (DeleteSmsTemplateResponse -> MessageBody)
-> (DeleteSmsTemplateResponse
    -> MessageBody -> DeleteSmsTemplateResponse)
-> Lens
     DeleteSmsTemplateResponse
     DeleteSmsTemplateResponse
     MessageBody
     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