{-# 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.GetVoiceTemplate
-- 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)
--
-- Retrieves the content and settings of a message template for messages
-- that are sent through the voice channel.
module Amazonka.Pinpoint.GetVoiceTemplate
  ( -- * Creating a Request
    GetVoiceTemplate (..),
    newGetVoiceTemplate,

    -- * Request Lenses
    getVoiceTemplate_version,
    getVoiceTemplate_templateName,

    -- * Destructuring the Response
    GetVoiceTemplateResponse (..),
    newGetVoiceTemplateResponse,

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

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

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

instance Core.AWSRequest GetVoiceTemplate where
  type
    AWSResponse GetVoiceTemplate =
      GetVoiceTemplateResponse
  request :: GetVoiceTemplate -> Request GetVoiceTemplate
request = Service -> GetVoiceTemplate -> Request GetVoiceTemplate
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetVoiceTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetVoiceTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetVoiceTemplate))
-> Logger
-> Service
-> Proxy GetVoiceTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetVoiceTemplate)))
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 -> VoiceTemplateResponse -> GetVoiceTemplateResponse
GetVoiceTemplateResponse'
            (Int -> VoiceTemplateResponse -> GetVoiceTemplateResponse)
-> Either String Int
-> Either
     String (VoiceTemplateResponse -> GetVoiceTemplateResponse)
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 (VoiceTemplateResponse -> GetVoiceTemplateResponse)
-> Either String VoiceTemplateResponse
-> Either String GetVoiceTemplateResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String VoiceTemplateResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable GetVoiceTemplate

instance Prelude.NFData GetVoiceTemplate

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

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

-- |
-- Create a value of 'GetVoiceTemplateResponse' 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', 'getVoiceTemplateResponse_httpStatus' - The response's http status code.
--
-- 'voiceTemplateResponse', 'getVoiceTemplateResponse_voiceTemplateResponse' - Undocumented member.
newGetVoiceTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'voiceTemplateResponse'
  VoiceTemplateResponse ->
  GetVoiceTemplateResponse
newGetVoiceTemplateResponse :: Int -> VoiceTemplateResponse -> GetVoiceTemplateResponse
newGetVoiceTemplateResponse
  Int
pHttpStatus_
  VoiceTemplateResponse
pVoiceTemplateResponse_ =
    GetVoiceTemplateResponse' :: Int -> VoiceTemplateResponse -> GetVoiceTemplateResponse
GetVoiceTemplateResponse'
      { $sel:httpStatus:GetVoiceTemplateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:voiceTemplateResponse:GetVoiceTemplateResponse' :: VoiceTemplateResponse
voiceTemplateResponse = VoiceTemplateResponse
pVoiceTemplateResponse_
      }

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

-- | Undocumented member.
getVoiceTemplateResponse_voiceTemplateResponse :: Lens.Lens' GetVoiceTemplateResponse VoiceTemplateResponse
getVoiceTemplateResponse_voiceTemplateResponse :: (VoiceTemplateResponse -> f VoiceTemplateResponse)
-> GetVoiceTemplateResponse -> f GetVoiceTemplateResponse
getVoiceTemplateResponse_voiceTemplateResponse = (GetVoiceTemplateResponse -> VoiceTemplateResponse)
-> (GetVoiceTemplateResponse
    -> VoiceTemplateResponse -> GetVoiceTemplateResponse)
-> Lens
     GetVoiceTemplateResponse
     GetVoiceTemplateResponse
     VoiceTemplateResponse
     VoiceTemplateResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVoiceTemplateResponse' {VoiceTemplateResponse
voiceTemplateResponse :: VoiceTemplateResponse
$sel:voiceTemplateResponse:GetVoiceTemplateResponse' :: GetVoiceTemplateResponse -> VoiceTemplateResponse
voiceTemplateResponse} -> VoiceTemplateResponse
voiceTemplateResponse) (\s :: GetVoiceTemplateResponse
s@GetVoiceTemplateResponse' {} VoiceTemplateResponse
a -> GetVoiceTemplateResponse
s {$sel:voiceTemplateResponse:GetVoiceTemplateResponse' :: VoiceTemplateResponse
voiceTemplateResponse = VoiceTemplateResponse
a} :: GetVoiceTemplateResponse)

instance Prelude.NFData GetVoiceTemplateResponse