{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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:/ '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
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]
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
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. 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'
    { $sel:version:GetVoiceTemplate' :: Maybe Text
version = 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 :: Lens' GetVoiceTemplate (Maybe Text)
getVoiceTemplate_version = 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 :: Lens' GetVoiceTemplate Text
getVoiceTemplate_templateName = 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 :: (Service -> Service)
-> GetVoiceTemplate -> Request GetVoiceTemplate
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetVoiceTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetVoiceTemplate)))
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 -> VoiceTemplateResponse -> GetVoiceTemplateResponse
GetVoiceTemplateResponse'
            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 GetVoiceTemplate where
  hashWithSalt :: Int -> GetVoiceTemplate -> Int
hashWithSalt Int
_salt GetVoiceTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:GetVoiceTemplate' :: GetVoiceTemplate -> Text
$sel:version:GetVoiceTemplate' :: GetVoiceTemplate -> 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 GetVoiceTemplate where
  rnf :: GetVoiceTemplate -> ()
rnf GetVoiceTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:GetVoiceTemplate' :: GetVoiceTemplate -> Text
$sel:version:GetVoiceTemplate' :: GetVoiceTemplate -> 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 GetVoiceTemplate where
  toHeaders :: GetVoiceTemplate -> 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 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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/templates/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
templateName, ByteString
"/voice"]

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"version" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: 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
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]
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
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.
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'
      { $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 :: Lens' GetVoiceTemplateResponse Int
getVoiceTemplateResponse_httpStatus = 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 :: Lens' GetVoiceTemplateResponse VoiceTemplateResponse
getVoiceTemplateResponse_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 where
  rnf :: GetVoiceTemplateResponse -> ()
rnf GetVoiceTemplateResponse' {Int
VoiceTemplateResponse
voiceTemplateResponse :: VoiceTemplateResponse
httpStatus :: Int
$sel:voiceTemplateResponse:GetVoiceTemplateResponse' :: GetVoiceTemplateResponse -> VoiceTemplateResponse
$sel:httpStatus:GetVoiceTemplateResponse' :: GetVoiceTemplateResponse -> 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 VoiceTemplateResponse
voiceTemplateResponse