{-# 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.Polly.GetSpeechSynthesisTask
-- 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 a specific SpeechSynthesisTask object based on its TaskID.
-- This object contains information about the given speech synthesis task,
-- including the status of the task, and a link to the S3 bucket containing
-- the output of the task.
module Amazonka.Polly.GetSpeechSynthesisTask
  ( -- * Creating a Request
    GetSpeechSynthesisTask (..),
    newGetSpeechSynthesisTask,

    -- * Request Lenses
    getSpeechSynthesisTask_taskId,

    -- * Destructuring the Response
    GetSpeechSynthesisTaskResponse (..),
    newGetSpeechSynthesisTaskResponse,

    -- * Response Lenses
    getSpeechSynthesisTaskResponse_synthesisTask,
    getSpeechSynthesisTaskResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Polly.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetSpeechSynthesisTask' smart constructor.
data GetSpeechSynthesisTask = GetSpeechSynthesisTask'
  { -- | The Amazon Polly generated identifier for a speech synthesis task.
    GetSpeechSynthesisTask -> Text
taskId :: Prelude.Text
  }
  deriving (GetSpeechSynthesisTask -> GetSpeechSynthesisTask -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSpeechSynthesisTask -> GetSpeechSynthesisTask -> Bool
$c/= :: GetSpeechSynthesisTask -> GetSpeechSynthesisTask -> Bool
== :: GetSpeechSynthesisTask -> GetSpeechSynthesisTask -> Bool
$c== :: GetSpeechSynthesisTask -> GetSpeechSynthesisTask -> Bool
Prelude.Eq, ReadPrec [GetSpeechSynthesisTask]
ReadPrec GetSpeechSynthesisTask
Int -> ReadS GetSpeechSynthesisTask
ReadS [GetSpeechSynthesisTask]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSpeechSynthesisTask]
$creadListPrec :: ReadPrec [GetSpeechSynthesisTask]
readPrec :: ReadPrec GetSpeechSynthesisTask
$creadPrec :: ReadPrec GetSpeechSynthesisTask
readList :: ReadS [GetSpeechSynthesisTask]
$creadList :: ReadS [GetSpeechSynthesisTask]
readsPrec :: Int -> ReadS GetSpeechSynthesisTask
$creadsPrec :: Int -> ReadS GetSpeechSynthesisTask
Prelude.Read, Int -> GetSpeechSynthesisTask -> ShowS
[GetSpeechSynthesisTask] -> ShowS
GetSpeechSynthesisTask -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSpeechSynthesisTask] -> ShowS
$cshowList :: [GetSpeechSynthesisTask] -> ShowS
show :: GetSpeechSynthesisTask -> String
$cshow :: GetSpeechSynthesisTask -> String
showsPrec :: Int -> GetSpeechSynthesisTask -> ShowS
$cshowsPrec :: Int -> GetSpeechSynthesisTask -> ShowS
Prelude.Show, forall x. Rep GetSpeechSynthesisTask x -> GetSpeechSynthesisTask
forall x. GetSpeechSynthesisTask -> Rep GetSpeechSynthesisTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSpeechSynthesisTask x -> GetSpeechSynthesisTask
$cfrom :: forall x. GetSpeechSynthesisTask -> Rep GetSpeechSynthesisTask x
Prelude.Generic)

-- |
-- Create a value of 'GetSpeechSynthesisTask' 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:
--
-- 'taskId', 'getSpeechSynthesisTask_taskId' - The Amazon Polly generated identifier for a speech synthesis task.
newGetSpeechSynthesisTask ::
  -- | 'taskId'
  Prelude.Text ->
  GetSpeechSynthesisTask
newGetSpeechSynthesisTask :: Text -> GetSpeechSynthesisTask
newGetSpeechSynthesisTask Text
pTaskId_ =
  GetSpeechSynthesisTask' {$sel:taskId:GetSpeechSynthesisTask' :: Text
taskId = Text
pTaskId_}

-- | The Amazon Polly generated identifier for a speech synthesis task.
getSpeechSynthesisTask_taskId :: Lens.Lens' GetSpeechSynthesisTask Prelude.Text
getSpeechSynthesisTask_taskId :: Lens' GetSpeechSynthesisTask Text
getSpeechSynthesisTask_taskId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSpeechSynthesisTask' {Text
taskId :: Text
$sel:taskId:GetSpeechSynthesisTask' :: GetSpeechSynthesisTask -> Text
taskId} -> Text
taskId) (\s :: GetSpeechSynthesisTask
s@GetSpeechSynthesisTask' {} Text
a -> GetSpeechSynthesisTask
s {$sel:taskId:GetSpeechSynthesisTask' :: Text
taskId = Text
a} :: GetSpeechSynthesisTask)

instance Core.AWSRequest GetSpeechSynthesisTask where
  type
    AWSResponse GetSpeechSynthesisTask =
      GetSpeechSynthesisTaskResponse
  request :: (Service -> Service)
-> GetSpeechSynthesisTask -> Request GetSpeechSynthesisTask
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 GetSpeechSynthesisTask
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetSpeechSynthesisTask)))
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 ->
          Maybe SynthesisTask -> Int -> GetSpeechSynthesisTaskResponse
GetSpeechSynthesisTaskResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"SynthesisTask")
            forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable GetSpeechSynthesisTask where
  hashWithSalt :: Int -> GetSpeechSynthesisTask -> Int
hashWithSalt Int
_salt GetSpeechSynthesisTask' {Text
taskId :: Text
$sel:taskId:GetSpeechSynthesisTask' :: GetSpeechSynthesisTask -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
taskId

instance Prelude.NFData GetSpeechSynthesisTask where
  rnf :: GetSpeechSynthesisTask -> ()
rnf GetSpeechSynthesisTask' {Text
taskId :: Text
$sel:taskId:GetSpeechSynthesisTask' :: GetSpeechSynthesisTask -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
taskId

instance Data.ToHeaders GetSpeechSynthesisTask where
  toHeaders :: GetSpeechSynthesisTask -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath GetSpeechSynthesisTask where
  toPath :: GetSpeechSynthesisTask -> ByteString
toPath GetSpeechSynthesisTask' {Text
taskId :: Text
$sel:taskId:GetSpeechSynthesisTask' :: GetSpeechSynthesisTask -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/synthesisTasks/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
taskId]

instance Data.ToQuery GetSpeechSynthesisTask where
  toQuery :: GetSpeechSynthesisTask -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetSpeechSynthesisTaskResponse' smart constructor.
data GetSpeechSynthesisTaskResponse = GetSpeechSynthesisTaskResponse'
  { -- | SynthesisTask object that provides information from the requested task,
    -- including output format, creation time, task status, and so on.
    GetSpeechSynthesisTaskResponse -> Maybe SynthesisTask
synthesisTask :: Prelude.Maybe SynthesisTask,
    -- | The response's http status code.
    GetSpeechSynthesisTaskResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSpeechSynthesisTaskResponse
-> GetSpeechSynthesisTaskResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSpeechSynthesisTaskResponse
-> GetSpeechSynthesisTaskResponse -> Bool
$c/= :: GetSpeechSynthesisTaskResponse
-> GetSpeechSynthesisTaskResponse -> Bool
== :: GetSpeechSynthesisTaskResponse
-> GetSpeechSynthesisTaskResponse -> Bool
$c== :: GetSpeechSynthesisTaskResponse
-> GetSpeechSynthesisTaskResponse -> Bool
Prelude.Eq, ReadPrec [GetSpeechSynthesisTaskResponse]
ReadPrec GetSpeechSynthesisTaskResponse
Int -> ReadS GetSpeechSynthesisTaskResponse
ReadS [GetSpeechSynthesisTaskResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSpeechSynthesisTaskResponse]
$creadListPrec :: ReadPrec [GetSpeechSynthesisTaskResponse]
readPrec :: ReadPrec GetSpeechSynthesisTaskResponse
$creadPrec :: ReadPrec GetSpeechSynthesisTaskResponse
readList :: ReadS [GetSpeechSynthesisTaskResponse]
$creadList :: ReadS [GetSpeechSynthesisTaskResponse]
readsPrec :: Int -> ReadS GetSpeechSynthesisTaskResponse
$creadsPrec :: Int -> ReadS GetSpeechSynthesisTaskResponse
Prelude.Read, Int -> GetSpeechSynthesisTaskResponse -> ShowS
[GetSpeechSynthesisTaskResponse] -> ShowS
GetSpeechSynthesisTaskResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSpeechSynthesisTaskResponse] -> ShowS
$cshowList :: [GetSpeechSynthesisTaskResponse] -> ShowS
show :: GetSpeechSynthesisTaskResponse -> String
$cshow :: GetSpeechSynthesisTaskResponse -> String
showsPrec :: Int -> GetSpeechSynthesisTaskResponse -> ShowS
$cshowsPrec :: Int -> GetSpeechSynthesisTaskResponse -> ShowS
Prelude.Show, forall x.
Rep GetSpeechSynthesisTaskResponse x
-> GetSpeechSynthesisTaskResponse
forall x.
GetSpeechSynthesisTaskResponse
-> Rep GetSpeechSynthesisTaskResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetSpeechSynthesisTaskResponse x
-> GetSpeechSynthesisTaskResponse
$cfrom :: forall x.
GetSpeechSynthesisTaskResponse
-> Rep GetSpeechSynthesisTaskResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSpeechSynthesisTaskResponse' 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:
--
-- 'synthesisTask', 'getSpeechSynthesisTaskResponse_synthesisTask' - SynthesisTask object that provides information from the requested task,
-- including output format, creation time, task status, and so on.
--
-- 'httpStatus', 'getSpeechSynthesisTaskResponse_httpStatus' - The response's http status code.
newGetSpeechSynthesisTaskResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSpeechSynthesisTaskResponse
newGetSpeechSynthesisTaskResponse :: Int -> GetSpeechSynthesisTaskResponse
newGetSpeechSynthesisTaskResponse Int
pHttpStatus_ =
  GetSpeechSynthesisTaskResponse'
    { $sel:synthesisTask:GetSpeechSynthesisTaskResponse' :: Maybe SynthesisTask
synthesisTask =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSpeechSynthesisTaskResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | SynthesisTask object that provides information from the requested task,
-- including output format, creation time, task status, and so on.
getSpeechSynthesisTaskResponse_synthesisTask :: Lens.Lens' GetSpeechSynthesisTaskResponse (Prelude.Maybe SynthesisTask)
getSpeechSynthesisTaskResponse_synthesisTask :: Lens' GetSpeechSynthesisTaskResponse (Maybe SynthesisTask)
getSpeechSynthesisTaskResponse_synthesisTask = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSpeechSynthesisTaskResponse' {Maybe SynthesisTask
synthesisTask :: Maybe SynthesisTask
$sel:synthesisTask:GetSpeechSynthesisTaskResponse' :: GetSpeechSynthesisTaskResponse -> Maybe SynthesisTask
synthesisTask} -> Maybe SynthesisTask
synthesisTask) (\s :: GetSpeechSynthesisTaskResponse
s@GetSpeechSynthesisTaskResponse' {} Maybe SynthesisTask
a -> GetSpeechSynthesisTaskResponse
s {$sel:synthesisTask:GetSpeechSynthesisTaskResponse' :: Maybe SynthesisTask
synthesisTask = Maybe SynthesisTask
a} :: GetSpeechSynthesisTaskResponse)

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

instance
  Prelude.NFData
    GetSpeechSynthesisTaskResponse
  where
  rnf :: GetSpeechSynthesisTaskResponse -> ()
rnf GetSpeechSynthesisTaskResponse' {Int
Maybe SynthesisTask
httpStatus :: Int
synthesisTask :: Maybe SynthesisTask
$sel:httpStatus:GetSpeechSynthesisTaskResponse' :: GetSpeechSynthesisTaskResponse -> Int
$sel:synthesisTask:GetSpeechSynthesisTaskResponse' :: GetSpeechSynthesisTaskResponse -> Maybe SynthesisTask
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SynthesisTask
synthesisTask
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus