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

instance Prelude.NFData DeletePushTemplate

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

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