{-# 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.DeletePushTemplate
-- 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 a push
-- notification channel.
module Amazonka.Pinpoint.DeletePushTemplate
  ( -- * Creating a Request
    DeletePushTemplate (..),
    newDeletePushTemplate,

    -- * Request Lenses
    deletePushTemplate_version,
    deletePushTemplate_templateName,

    -- * Destructuring the Response
    DeletePushTemplateResponse (..),
    newDeletePushTemplateResponse,

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

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

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

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

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

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

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

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

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

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