{-# 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-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 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.Lens as Lens
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
(GetSpeechSynthesisTask -> GetSpeechSynthesisTask -> Bool)
-> (GetSpeechSynthesisTask -> GetSpeechSynthesisTask -> Bool)
-> Eq GetSpeechSynthesisTask
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]
(Int -> ReadS GetSpeechSynthesisTask)
-> ReadS [GetSpeechSynthesisTask]
-> ReadPrec GetSpeechSynthesisTask
-> ReadPrec [GetSpeechSynthesisTask]
-> Read 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
(Int -> GetSpeechSynthesisTask -> ShowS)
-> (GetSpeechSynthesisTask -> String)
-> ([GetSpeechSynthesisTask] -> ShowS)
-> Show GetSpeechSynthesisTask
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. GetSpeechSynthesisTask -> Rep GetSpeechSynthesisTask x)
-> (forall x.
    Rep GetSpeechSynthesisTask x -> GetSpeechSynthesisTask)
-> Generic GetSpeechSynthesisTask
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' :: Text -> GetSpeechSynthesisTask
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 :: (Text -> f Text)
-> GetSpeechSynthesisTask -> f GetSpeechSynthesisTask
getSpeechSynthesisTask_taskId = (GetSpeechSynthesisTask -> Text)
-> (GetSpeechSynthesisTask -> Text -> GetSpeechSynthesisTask)
-> Lens GetSpeechSynthesisTask GetSpeechSynthesisTask Text Text
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 :: GetSpeechSynthesisTask -> Request GetSpeechSynthesisTask
request = Service -> GetSpeechSynthesisTask -> Request GetSpeechSynthesisTask
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetSpeechSynthesisTask
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetSpeechSynthesisTask)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetSpeechSynthesisTask))
-> Logger
-> Service
-> Proxy GetSpeechSynthesisTask
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetSpeechSynthesisTask)))
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 ->
          Maybe SynthesisTask -> Int -> GetSpeechSynthesisTaskResponse
GetSpeechSynthesisTaskResponse'
            (Maybe SynthesisTask -> Int -> GetSpeechSynthesisTaskResponse)
-> Either String (Maybe SynthesisTask)
-> Either String (Int -> GetSpeechSynthesisTaskResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe SynthesisTask)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"SynthesisTask")
            Either String (Int -> GetSpeechSynthesisTaskResponse)
-> Either String Int
-> Either String GetSpeechSynthesisTaskResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable GetSpeechSynthesisTask

instance Prelude.NFData GetSpeechSynthesisTask

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

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

instance Core.ToQuery GetSpeechSynthesisTask where
  toQuery :: GetSpeechSynthesisTask -> QueryString
toQuery = QueryString -> GetSpeechSynthesisTask -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetSpeechSynthesisTaskResponse
 -> GetSpeechSynthesisTaskResponse -> Bool)
-> (GetSpeechSynthesisTaskResponse
    -> GetSpeechSynthesisTaskResponse -> Bool)
-> Eq GetSpeechSynthesisTaskResponse
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]
(Int -> ReadS GetSpeechSynthesisTaskResponse)
-> ReadS [GetSpeechSynthesisTaskResponse]
-> ReadPrec GetSpeechSynthesisTaskResponse
-> ReadPrec [GetSpeechSynthesisTaskResponse]
-> Read 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
(Int -> GetSpeechSynthesisTaskResponse -> ShowS)
-> (GetSpeechSynthesisTaskResponse -> String)
-> ([GetSpeechSynthesisTaskResponse] -> ShowS)
-> Show GetSpeechSynthesisTaskResponse
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.
 GetSpeechSynthesisTaskResponse
 -> Rep GetSpeechSynthesisTaskResponse x)
-> (forall x.
    Rep GetSpeechSynthesisTaskResponse x
    -> GetSpeechSynthesisTaskResponse)
-> Generic GetSpeechSynthesisTaskResponse
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' :: Maybe SynthesisTask -> Int -> GetSpeechSynthesisTaskResponse
GetSpeechSynthesisTaskResponse'
    { $sel:synthesisTask:GetSpeechSynthesisTaskResponse' :: Maybe SynthesisTask
synthesisTask =
        Maybe 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 :: (Maybe SynthesisTask -> f (Maybe SynthesisTask))
-> GetSpeechSynthesisTaskResponse
-> f GetSpeechSynthesisTaskResponse
getSpeechSynthesisTaskResponse_synthesisTask = (GetSpeechSynthesisTaskResponse -> Maybe SynthesisTask)
-> (GetSpeechSynthesisTaskResponse
    -> Maybe SynthesisTask -> GetSpeechSynthesisTaskResponse)
-> Lens
     GetSpeechSynthesisTaskResponse
     GetSpeechSynthesisTaskResponse
     (Maybe SynthesisTask)
     (Maybe 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 :: (Int -> f Int)
-> GetSpeechSynthesisTaskResponse
-> f GetSpeechSynthesisTaskResponse
getSpeechSynthesisTaskResponse_httpStatus = (GetSpeechSynthesisTaskResponse -> Int)
-> (GetSpeechSynthesisTaskResponse
    -> Int -> GetSpeechSynthesisTaskResponse)
-> Lens
     GetSpeechSynthesisTaskResponse
     GetSpeechSynthesisTaskResponse
     Int
     Int
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