{-# 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.Transcribe.GetTranscriptionJob
-- 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)
--
-- Returns information about a transcription job. To see the status of the
-- job, check the @TranscriptionJobStatus@ field. If the status is
-- @COMPLETED@, the job is finished and you can find the results at the
-- location specified in the @TranscriptFileUri@ field. If you enable
-- content redaction, the redacted transcript appears in
-- @RedactedTranscriptFileUri@.
module Amazonka.Transcribe.GetTranscriptionJob
  ( -- * Creating a Request
    GetTranscriptionJob (..),
    newGetTranscriptionJob,

    -- * Request Lenses
    getTranscriptionJob_transcriptionJobName,

    -- * Destructuring the Response
    GetTranscriptionJobResponse (..),
    newGetTranscriptionJobResponse,

    -- * Response Lenses
    getTranscriptionJobResponse_transcriptionJob,
    getTranscriptionJobResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Transcribe.Types

-- | /See:/ 'newGetTranscriptionJob' smart constructor.
data GetTranscriptionJob = GetTranscriptionJob'
  { -- | The name of the job.
    GetTranscriptionJob -> Text
transcriptionJobName :: Prelude.Text
  }
  deriving (GetTranscriptionJob -> GetTranscriptionJob -> Bool
(GetTranscriptionJob -> GetTranscriptionJob -> Bool)
-> (GetTranscriptionJob -> GetTranscriptionJob -> Bool)
-> Eq GetTranscriptionJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTranscriptionJob -> GetTranscriptionJob -> Bool
$c/= :: GetTranscriptionJob -> GetTranscriptionJob -> Bool
== :: GetTranscriptionJob -> GetTranscriptionJob -> Bool
$c== :: GetTranscriptionJob -> GetTranscriptionJob -> Bool
Prelude.Eq, ReadPrec [GetTranscriptionJob]
ReadPrec GetTranscriptionJob
Int -> ReadS GetTranscriptionJob
ReadS [GetTranscriptionJob]
(Int -> ReadS GetTranscriptionJob)
-> ReadS [GetTranscriptionJob]
-> ReadPrec GetTranscriptionJob
-> ReadPrec [GetTranscriptionJob]
-> Read GetTranscriptionJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTranscriptionJob]
$creadListPrec :: ReadPrec [GetTranscriptionJob]
readPrec :: ReadPrec GetTranscriptionJob
$creadPrec :: ReadPrec GetTranscriptionJob
readList :: ReadS [GetTranscriptionJob]
$creadList :: ReadS [GetTranscriptionJob]
readsPrec :: Int -> ReadS GetTranscriptionJob
$creadsPrec :: Int -> ReadS GetTranscriptionJob
Prelude.Read, Int -> GetTranscriptionJob -> ShowS
[GetTranscriptionJob] -> ShowS
GetTranscriptionJob -> String
(Int -> GetTranscriptionJob -> ShowS)
-> (GetTranscriptionJob -> String)
-> ([GetTranscriptionJob] -> ShowS)
-> Show GetTranscriptionJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTranscriptionJob] -> ShowS
$cshowList :: [GetTranscriptionJob] -> ShowS
show :: GetTranscriptionJob -> String
$cshow :: GetTranscriptionJob -> String
showsPrec :: Int -> GetTranscriptionJob -> ShowS
$cshowsPrec :: Int -> GetTranscriptionJob -> ShowS
Prelude.Show, (forall x. GetTranscriptionJob -> Rep GetTranscriptionJob x)
-> (forall x. Rep GetTranscriptionJob x -> GetTranscriptionJob)
-> Generic GetTranscriptionJob
forall x. Rep GetTranscriptionJob x -> GetTranscriptionJob
forall x. GetTranscriptionJob -> Rep GetTranscriptionJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTranscriptionJob x -> GetTranscriptionJob
$cfrom :: forall x. GetTranscriptionJob -> Rep GetTranscriptionJob x
Prelude.Generic)

-- |
-- Create a value of 'GetTranscriptionJob' 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:
--
-- 'transcriptionJobName', 'getTranscriptionJob_transcriptionJobName' - The name of the job.
newGetTranscriptionJob ::
  -- | 'transcriptionJobName'
  Prelude.Text ->
  GetTranscriptionJob
newGetTranscriptionJob :: Text -> GetTranscriptionJob
newGetTranscriptionJob Text
pTranscriptionJobName_ =
  GetTranscriptionJob' :: Text -> GetTranscriptionJob
GetTranscriptionJob'
    { $sel:transcriptionJobName:GetTranscriptionJob' :: Text
transcriptionJobName =
        Text
pTranscriptionJobName_
    }

-- | The name of the job.
getTranscriptionJob_transcriptionJobName :: Lens.Lens' GetTranscriptionJob Prelude.Text
getTranscriptionJob_transcriptionJobName :: (Text -> f Text) -> GetTranscriptionJob -> f GetTranscriptionJob
getTranscriptionJob_transcriptionJobName = (GetTranscriptionJob -> Text)
-> (GetTranscriptionJob -> Text -> GetTranscriptionJob)
-> Lens GetTranscriptionJob GetTranscriptionJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTranscriptionJob' {Text
transcriptionJobName :: Text
$sel:transcriptionJobName:GetTranscriptionJob' :: GetTranscriptionJob -> Text
transcriptionJobName} -> Text
transcriptionJobName) (\s :: GetTranscriptionJob
s@GetTranscriptionJob' {} Text
a -> GetTranscriptionJob
s {$sel:transcriptionJobName:GetTranscriptionJob' :: Text
transcriptionJobName = Text
a} :: GetTranscriptionJob)

instance Core.AWSRequest GetTranscriptionJob where
  type
    AWSResponse GetTranscriptionJob =
      GetTranscriptionJobResponse
  request :: GetTranscriptionJob -> Request GetTranscriptionJob
request = Service -> GetTranscriptionJob -> Request GetTranscriptionJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetTranscriptionJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetTranscriptionJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetTranscriptionJob))
-> Logger
-> Service
-> Proxy GetTranscriptionJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetTranscriptionJob)))
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 TranscriptionJob -> Int -> GetTranscriptionJobResponse
GetTranscriptionJobResponse'
            (Maybe TranscriptionJob -> Int -> GetTranscriptionJobResponse)
-> Either String (Maybe TranscriptionJob)
-> Either String (Int -> GetTranscriptionJobResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe TranscriptionJob)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TranscriptionJob")
            Either String (Int -> GetTranscriptionJobResponse)
-> Either String Int -> Either String GetTranscriptionJobResponse
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 GetTranscriptionJob

instance Prelude.NFData GetTranscriptionJob

instance Core.ToHeaders GetTranscriptionJob where
  toHeaders :: GetTranscriptionJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetTranscriptionJob -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Transcribe.GetTranscriptionJob" ::
                          Prelude.ByteString
                      ),
            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.ToJSON GetTranscriptionJob where
  toJSON :: GetTranscriptionJob -> Value
toJSON GetTranscriptionJob' {Text
transcriptionJobName :: Text
$sel:transcriptionJobName:GetTranscriptionJob' :: GetTranscriptionJob -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"TranscriptionJobName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
transcriptionJobName
              )
          ]
      )

instance Core.ToPath GetTranscriptionJob where
  toPath :: GetTranscriptionJob -> ByteString
toPath = ByteString -> GetTranscriptionJob -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newGetTranscriptionJobResponse' smart constructor.
data GetTranscriptionJobResponse = GetTranscriptionJobResponse'
  { -- | An object that contains the results of the transcription job.
    GetTranscriptionJobResponse -> Maybe TranscriptionJob
transcriptionJob :: Prelude.Maybe TranscriptionJob,
    -- | The response's http status code.
    GetTranscriptionJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetTranscriptionJobResponse -> GetTranscriptionJobResponse -> Bool
(GetTranscriptionJobResponse
 -> GetTranscriptionJobResponse -> Bool)
-> (GetTranscriptionJobResponse
    -> GetTranscriptionJobResponse -> Bool)
-> Eq GetTranscriptionJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTranscriptionJobResponse -> GetTranscriptionJobResponse -> Bool
$c/= :: GetTranscriptionJobResponse -> GetTranscriptionJobResponse -> Bool
== :: GetTranscriptionJobResponse -> GetTranscriptionJobResponse -> Bool
$c== :: GetTranscriptionJobResponse -> GetTranscriptionJobResponse -> Bool
Prelude.Eq, ReadPrec [GetTranscriptionJobResponse]
ReadPrec GetTranscriptionJobResponse
Int -> ReadS GetTranscriptionJobResponse
ReadS [GetTranscriptionJobResponse]
(Int -> ReadS GetTranscriptionJobResponse)
-> ReadS [GetTranscriptionJobResponse]
-> ReadPrec GetTranscriptionJobResponse
-> ReadPrec [GetTranscriptionJobResponse]
-> Read GetTranscriptionJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTranscriptionJobResponse]
$creadListPrec :: ReadPrec [GetTranscriptionJobResponse]
readPrec :: ReadPrec GetTranscriptionJobResponse
$creadPrec :: ReadPrec GetTranscriptionJobResponse
readList :: ReadS [GetTranscriptionJobResponse]
$creadList :: ReadS [GetTranscriptionJobResponse]
readsPrec :: Int -> ReadS GetTranscriptionJobResponse
$creadsPrec :: Int -> ReadS GetTranscriptionJobResponse
Prelude.Read, Int -> GetTranscriptionJobResponse -> ShowS
[GetTranscriptionJobResponse] -> ShowS
GetTranscriptionJobResponse -> String
(Int -> GetTranscriptionJobResponse -> ShowS)
-> (GetTranscriptionJobResponse -> String)
-> ([GetTranscriptionJobResponse] -> ShowS)
-> Show GetTranscriptionJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTranscriptionJobResponse] -> ShowS
$cshowList :: [GetTranscriptionJobResponse] -> ShowS
show :: GetTranscriptionJobResponse -> String
$cshow :: GetTranscriptionJobResponse -> String
showsPrec :: Int -> GetTranscriptionJobResponse -> ShowS
$cshowsPrec :: Int -> GetTranscriptionJobResponse -> ShowS
Prelude.Show, (forall x.
 GetTranscriptionJobResponse -> Rep GetTranscriptionJobResponse x)
-> (forall x.
    Rep GetTranscriptionJobResponse x -> GetTranscriptionJobResponse)
-> Generic GetTranscriptionJobResponse
forall x.
Rep GetTranscriptionJobResponse x -> GetTranscriptionJobResponse
forall x.
GetTranscriptionJobResponse -> Rep GetTranscriptionJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetTranscriptionJobResponse x -> GetTranscriptionJobResponse
$cfrom :: forall x.
GetTranscriptionJobResponse -> Rep GetTranscriptionJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetTranscriptionJobResponse' 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:
--
-- 'transcriptionJob', 'getTranscriptionJobResponse_transcriptionJob' - An object that contains the results of the transcription job.
--
-- 'httpStatus', 'getTranscriptionJobResponse_httpStatus' - The response's http status code.
newGetTranscriptionJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetTranscriptionJobResponse
newGetTranscriptionJobResponse :: Int -> GetTranscriptionJobResponse
newGetTranscriptionJobResponse Int
pHttpStatus_ =
  GetTranscriptionJobResponse' :: Maybe TranscriptionJob -> Int -> GetTranscriptionJobResponse
GetTranscriptionJobResponse'
    { $sel:transcriptionJob:GetTranscriptionJobResponse' :: Maybe TranscriptionJob
transcriptionJob =
        Maybe TranscriptionJob
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetTranscriptionJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that contains the results of the transcription job.
getTranscriptionJobResponse_transcriptionJob :: Lens.Lens' GetTranscriptionJobResponse (Prelude.Maybe TranscriptionJob)
getTranscriptionJobResponse_transcriptionJob :: (Maybe TranscriptionJob -> f (Maybe TranscriptionJob))
-> GetTranscriptionJobResponse -> f GetTranscriptionJobResponse
getTranscriptionJobResponse_transcriptionJob = (GetTranscriptionJobResponse -> Maybe TranscriptionJob)
-> (GetTranscriptionJobResponse
    -> Maybe TranscriptionJob -> GetTranscriptionJobResponse)
-> Lens
     GetTranscriptionJobResponse
     GetTranscriptionJobResponse
     (Maybe TranscriptionJob)
     (Maybe TranscriptionJob)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTranscriptionJobResponse' {Maybe TranscriptionJob
transcriptionJob :: Maybe TranscriptionJob
$sel:transcriptionJob:GetTranscriptionJobResponse' :: GetTranscriptionJobResponse -> Maybe TranscriptionJob
transcriptionJob} -> Maybe TranscriptionJob
transcriptionJob) (\s :: GetTranscriptionJobResponse
s@GetTranscriptionJobResponse' {} Maybe TranscriptionJob
a -> GetTranscriptionJobResponse
s {$sel:transcriptionJob:GetTranscriptionJobResponse' :: Maybe TranscriptionJob
transcriptionJob = Maybe TranscriptionJob
a} :: GetTranscriptionJobResponse)

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

instance Prelude.NFData GetTranscriptionJobResponse