{-# 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.DeleteInAppTemplate
-- 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 sent using the in-app message
-- channel.
module Amazonka.Pinpoint.DeleteInAppTemplate
  ( -- * Creating a Request
    DeleteInAppTemplate (..),
    newDeleteInAppTemplate,

    -- * Request Lenses
    deleteInAppTemplate_version,
    deleteInAppTemplate_templateName,

    -- * Destructuring the Response
    DeleteInAppTemplateResponse (..),
    newDeleteInAppTemplateResponse,

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

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

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

instance Core.AWSRequest DeleteInAppTemplate where
  type
    AWSResponse DeleteInAppTemplate =
      DeleteInAppTemplateResponse
  request :: DeleteInAppTemplate -> Request DeleteInAppTemplate
request = Service -> DeleteInAppTemplate -> Request DeleteInAppTemplate
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteInAppTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInAppTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteInAppTemplate))
-> Logger
-> Service
-> Proxy DeleteInAppTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInAppTemplate)))
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 -> DeleteInAppTemplateResponse
DeleteInAppTemplateResponse'
            (Int -> MessageBody -> DeleteInAppTemplateResponse)
-> Either String Int
-> Either String (MessageBody -> DeleteInAppTemplateResponse)
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 -> DeleteInAppTemplateResponse)
-> Either String MessageBody
-> Either String DeleteInAppTemplateResponse
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 DeleteInAppTemplate

instance Prelude.NFData DeleteInAppTemplate

instance Core.ToHeaders DeleteInAppTemplate where
  toHeaders :: DeleteInAppTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteInAppTemplate -> 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 DeleteInAppTemplate where
  toPath :: DeleteInAppTemplate -> ByteString
toPath DeleteInAppTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteInAppTemplate' :: DeleteInAppTemplate -> Text
$sel:version:DeleteInAppTemplate' :: DeleteInAppTemplate -> 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
"/inapp"]

instance Core.ToQuery DeleteInAppTemplate where
  toQuery :: DeleteInAppTemplate -> QueryString
toQuery DeleteInAppTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteInAppTemplate' :: DeleteInAppTemplate -> Text
$sel:version:DeleteInAppTemplate' :: DeleteInAppTemplate -> 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:/ 'newDeleteInAppTemplateResponse' smart constructor.
data DeleteInAppTemplateResponse = DeleteInAppTemplateResponse'
  { -- | The response's http status code.
    DeleteInAppTemplateResponse -> Int
httpStatus :: Prelude.Int,
    DeleteInAppTemplateResponse -> MessageBody
messageBody :: MessageBody
  }
  deriving (DeleteInAppTemplateResponse -> DeleteInAppTemplateResponse -> Bool
(DeleteInAppTemplateResponse
 -> DeleteInAppTemplateResponse -> Bool)
-> (DeleteInAppTemplateResponse
    -> DeleteInAppTemplateResponse -> Bool)
-> Eq DeleteInAppTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteInAppTemplateResponse -> DeleteInAppTemplateResponse -> Bool
$c/= :: DeleteInAppTemplateResponse -> DeleteInAppTemplateResponse -> Bool
== :: DeleteInAppTemplateResponse -> DeleteInAppTemplateResponse -> Bool
$c== :: DeleteInAppTemplateResponse -> DeleteInAppTemplateResponse -> Bool
Prelude.Eq, ReadPrec [DeleteInAppTemplateResponse]
ReadPrec DeleteInAppTemplateResponse
Int -> ReadS DeleteInAppTemplateResponse
ReadS [DeleteInAppTemplateResponse]
(Int -> ReadS DeleteInAppTemplateResponse)
-> ReadS [DeleteInAppTemplateResponse]
-> ReadPrec DeleteInAppTemplateResponse
-> ReadPrec [DeleteInAppTemplateResponse]
-> Read DeleteInAppTemplateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteInAppTemplateResponse]
$creadListPrec :: ReadPrec [DeleteInAppTemplateResponse]
readPrec :: ReadPrec DeleteInAppTemplateResponse
$creadPrec :: ReadPrec DeleteInAppTemplateResponse
readList :: ReadS [DeleteInAppTemplateResponse]
$creadList :: ReadS [DeleteInAppTemplateResponse]
readsPrec :: Int -> ReadS DeleteInAppTemplateResponse
$creadsPrec :: Int -> ReadS DeleteInAppTemplateResponse
Prelude.Read, Int -> DeleteInAppTemplateResponse -> ShowS
[DeleteInAppTemplateResponse] -> ShowS
DeleteInAppTemplateResponse -> String
(Int -> DeleteInAppTemplateResponse -> ShowS)
-> (DeleteInAppTemplateResponse -> String)
-> ([DeleteInAppTemplateResponse] -> ShowS)
-> Show DeleteInAppTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteInAppTemplateResponse] -> ShowS
$cshowList :: [DeleteInAppTemplateResponse] -> ShowS
show :: DeleteInAppTemplateResponse -> String
$cshow :: DeleteInAppTemplateResponse -> String
showsPrec :: Int -> DeleteInAppTemplateResponse -> ShowS
$cshowsPrec :: Int -> DeleteInAppTemplateResponse -> ShowS
Prelude.Show, (forall x.
 DeleteInAppTemplateResponse -> Rep DeleteInAppTemplateResponse x)
-> (forall x.
    Rep DeleteInAppTemplateResponse x -> DeleteInAppTemplateResponse)
-> Generic DeleteInAppTemplateResponse
forall x.
Rep DeleteInAppTemplateResponse x -> DeleteInAppTemplateResponse
forall x.
DeleteInAppTemplateResponse -> Rep DeleteInAppTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteInAppTemplateResponse x -> DeleteInAppTemplateResponse
$cfrom :: forall x.
DeleteInAppTemplateResponse -> Rep DeleteInAppTemplateResponse x
Prelude.Generic)

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

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

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

instance Prelude.NFData DeleteInAppTemplateResponse