{-# 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.Translate.DescribeTextTranslationJob
-- 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)
--
-- Gets the properties associated with an asycnhronous batch translation
-- job including name, ID, status, source and target languages,
-- input\/output S3 buckets, and so on.
module Amazonka.Translate.DescribeTextTranslationJob
  ( -- * Creating a Request
    DescribeTextTranslationJob (..),
    newDescribeTextTranslationJob,

    -- * Request Lenses
    describeTextTranslationJob_jobId,

    -- * Destructuring the Response
    DescribeTextTranslationJobResponse (..),
    newDescribeTextTranslationJobResponse,

    -- * Response Lenses
    describeTextTranslationJobResponse_textTranslationJobProperties,
    describeTextTranslationJobResponse_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.Translate.Types

-- | /See:/ 'newDescribeTextTranslationJob' smart constructor.
data DescribeTextTranslationJob = DescribeTextTranslationJob'
  { -- | The identifier that Amazon Translate generated for the job. The
    -- StartTextTranslationJob operation returns this identifier in its
    -- response.
    DescribeTextTranslationJob -> Text
jobId :: Prelude.Text
  }
  deriving (DescribeTextTranslationJob -> DescribeTextTranslationJob -> Bool
(DescribeTextTranslationJob -> DescribeTextTranslationJob -> Bool)
-> (DescribeTextTranslationJob
    -> DescribeTextTranslationJob -> Bool)
-> Eq DescribeTextTranslationJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTextTranslationJob -> DescribeTextTranslationJob -> Bool
$c/= :: DescribeTextTranslationJob -> DescribeTextTranslationJob -> Bool
== :: DescribeTextTranslationJob -> DescribeTextTranslationJob -> Bool
$c== :: DescribeTextTranslationJob -> DescribeTextTranslationJob -> Bool
Prelude.Eq, ReadPrec [DescribeTextTranslationJob]
ReadPrec DescribeTextTranslationJob
Int -> ReadS DescribeTextTranslationJob
ReadS [DescribeTextTranslationJob]
(Int -> ReadS DescribeTextTranslationJob)
-> ReadS [DescribeTextTranslationJob]
-> ReadPrec DescribeTextTranslationJob
-> ReadPrec [DescribeTextTranslationJob]
-> Read DescribeTextTranslationJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTextTranslationJob]
$creadListPrec :: ReadPrec [DescribeTextTranslationJob]
readPrec :: ReadPrec DescribeTextTranslationJob
$creadPrec :: ReadPrec DescribeTextTranslationJob
readList :: ReadS [DescribeTextTranslationJob]
$creadList :: ReadS [DescribeTextTranslationJob]
readsPrec :: Int -> ReadS DescribeTextTranslationJob
$creadsPrec :: Int -> ReadS DescribeTextTranslationJob
Prelude.Read, Int -> DescribeTextTranslationJob -> ShowS
[DescribeTextTranslationJob] -> ShowS
DescribeTextTranslationJob -> String
(Int -> DescribeTextTranslationJob -> ShowS)
-> (DescribeTextTranslationJob -> String)
-> ([DescribeTextTranslationJob] -> ShowS)
-> Show DescribeTextTranslationJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTextTranslationJob] -> ShowS
$cshowList :: [DescribeTextTranslationJob] -> ShowS
show :: DescribeTextTranslationJob -> String
$cshow :: DescribeTextTranslationJob -> String
showsPrec :: Int -> DescribeTextTranslationJob -> ShowS
$cshowsPrec :: Int -> DescribeTextTranslationJob -> ShowS
Prelude.Show, (forall x.
 DescribeTextTranslationJob -> Rep DescribeTextTranslationJob x)
-> (forall x.
    Rep DescribeTextTranslationJob x -> DescribeTextTranslationJob)
-> Generic DescribeTextTranslationJob
forall x.
Rep DescribeTextTranslationJob x -> DescribeTextTranslationJob
forall x.
DescribeTextTranslationJob -> Rep DescribeTextTranslationJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeTextTranslationJob x -> DescribeTextTranslationJob
$cfrom :: forall x.
DescribeTextTranslationJob -> Rep DescribeTextTranslationJob x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTextTranslationJob' 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:
--
-- 'jobId', 'describeTextTranslationJob_jobId' - The identifier that Amazon Translate generated for the job. The
-- StartTextTranslationJob operation returns this identifier in its
-- response.
newDescribeTextTranslationJob ::
  -- | 'jobId'
  Prelude.Text ->
  DescribeTextTranslationJob
newDescribeTextTranslationJob :: Text -> DescribeTextTranslationJob
newDescribeTextTranslationJob Text
pJobId_ =
  DescribeTextTranslationJob' :: Text -> DescribeTextTranslationJob
DescribeTextTranslationJob' {$sel:jobId:DescribeTextTranslationJob' :: Text
jobId = Text
pJobId_}

-- | The identifier that Amazon Translate generated for the job. The
-- StartTextTranslationJob operation returns this identifier in its
-- response.
describeTextTranslationJob_jobId :: Lens.Lens' DescribeTextTranslationJob Prelude.Text
describeTextTranslationJob_jobId :: (Text -> f Text)
-> DescribeTextTranslationJob -> f DescribeTextTranslationJob
describeTextTranslationJob_jobId = (DescribeTextTranslationJob -> Text)
-> (DescribeTextTranslationJob
    -> Text -> DescribeTextTranslationJob)
-> Lens
     DescribeTextTranslationJob DescribeTextTranslationJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTextTranslationJob' {Text
jobId :: Text
$sel:jobId:DescribeTextTranslationJob' :: DescribeTextTranslationJob -> Text
jobId} -> Text
jobId) (\s :: DescribeTextTranslationJob
s@DescribeTextTranslationJob' {} Text
a -> DescribeTextTranslationJob
s {$sel:jobId:DescribeTextTranslationJob' :: Text
jobId = Text
a} :: DescribeTextTranslationJob)

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

instance Prelude.NFData DescribeTextTranslationJob

instance Core.ToHeaders DescribeTextTranslationJob where
  toHeaders :: DescribeTextTranslationJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeTextTranslationJob -> 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
"AWSShineFrontendService_20170701.DescribeTextTranslationJob" ::
                          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 DescribeTextTranslationJob where
  toJSON :: DescribeTextTranslationJob -> Value
toJSON DescribeTextTranslationJob' {Text
jobId :: Text
$sel:jobId:DescribeTextTranslationJob' :: DescribeTextTranslationJob -> 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
"JobId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
jobId)]
      )

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

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

-- | /See:/ 'newDescribeTextTranslationJobResponse' smart constructor.
data DescribeTextTranslationJobResponse = DescribeTextTranslationJobResponse'
  { -- | An object that contains the properties associated with an asynchronous
    -- batch translation job.
    DescribeTextTranslationJobResponse
-> Maybe TextTranslationJobProperties
textTranslationJobProperties :: Prelude.Maybe TextTranslationJobProperties,
    -- | The response's http status code.
    DescribeTextTranslationJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeTextTranslationJobResponse
-> DescribeTextTranslationJobResponse -> Bool
(DescribeTextTranslationJobResponse
 -> DescribeTextTranslationJobResponse -> Bool)
-> (DescribeTextTranslationJobResponse
    -> DescribeTextTranslationJobResponse -> Bool)
-> Eq DescribeTextTranslationJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTextTranslationJobResponse
-> DescribeTextTranslationJobResponse -> Bool
$c/= :: DescribeTextTranslationJobResponse
-> DescribeTextTranslationJobResponse -> Bool
== :: DescribeTextTranslationJobResponse
-> DescribeTextTranslationJobResponse -> Bool
$c== :: DescribeTextTranslationJobResponse
-> DescribeTextTranslationJobResponse -> Bool
Prelude.Eq, ReadPrec [DescribeTextTranslationJobResponse]
ReadPrec DescribeTextTranslationJobResponse
Int -> ReadS DescribeTextTranslationJobResponse
ReadS [DescribeTextTranslationJobResponse]
(Int -> ReadS DescribeTextTranslationJobResponse)
-> ReadS [DescribeTextTranslationJobResponse]
-> ReadPrec DescribeTextTranslationJobResponse
-> ReadPrec [DescribeTextTranslationJobResponse]
-> Read DescribeTextTranslationJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTextTranslationJobResponse]
$creadListPrec :: ReadPrec [DescribeTextTranslationJobResponse]
readPrec :: ReadPrec DescribeTextTranslationJobResponse
$creadPrec :: ReadPrec DescribeTextTranslationJobResponse
readList :: ReadS [DescribeTextTranslationJobResponse]
$creadList :: ReadS [DescribeTextTranslationJobResponse]
readsPrec :: Int -> ReadS DescribeTextTranslationJobResponse
$creadsPrec :: Int -> ReadS DescribeTextTranslationJobResponse
Prelude.Read, Int -> DescribeTextTranslationJobResponse -> ShowS
[DescribeTextTranslationJobResponse] -> ShowS
DescribeTextTranslationJobResponse -> String
(Int -> DescribeTextTranslationJobResponse -> ShowS)
-> (DescribeTextTranslationJobResponse -> String)
-> ([DescribeTextTranslationJobResponse] -> ShowS)
-> Show DescribeTextTranslationJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTextTranslationJobResponse] -> ShowS
$cshowList :: [DescribeTextTranslationJobResponse] -> ShowS
show :: DescribeTextTranslationJobResponse -> String
$cshow :: DescribeTextTranslationJobResponse -> String
showsPrec :: Int -> DescribeTextTranslationJobResponse -> ShowS
$cshowsPrec :: Int -> DescribeTextTranslationJobResponse -> ShowS
Prelude.Show, (forall x.
 DescribeTextTranslationJobResponse
 -> Rep DescribeTextTranslationJobResponse x)
-> (forall x.
    Rep DescribeTextTranslationJobResponse x
    -> DescribeTextTranslationJobResponse)
-> Generic DescribeTextTranslationJobResponse
forall x.
Rep DescribeTextTranslationJobResponse x
-> DescribeTextTranslationJobResponse
forall x.
DescribeTextTranslationJobResponse
-> Rep DescribeTextTranslationJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeTextTranslationJobResponse x
-> DescribeTextTranslationJobResponse
$cfrom :: forall x.
DescribeTextTranslationJobResponse
-> Rep DescribeTextTranslationJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTextTranslationJobResponse' 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:
--
-- 'textTranslationJobProperties', 'describeTextTranslationJobResponse_textTranslationJobProperties' - An object that contains the properties associated with an asynchronous
-- batch translation job.
--
-- 'httpStatus', 'describeTextTranslationJobResponse_httpStatus' - The response's http status code.
newDescribeTextTranslationJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeTextTranslationJobResponse
newDescribeTextTranslationJobResponse :: Int -> DescribeTextTranslationJobResponse
newDescribeTextTranslationJobResponse Int
pHttpStatus_ =
  DescribeTextTranslationJobResponse' :: Maybe TextTranslationJobProperties
-> Int -> DescribeTextTranslationJobResponse
DescribeTextTranslationJobResponse'
    { $sel:textTranslationJobProperties:DescribeTextTranslationJobResponse' :: Maybe TextTranslationJobProperties
textTranslationJobProperties =
        Maybe TextTranslationJobProperties
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeTextTranslationJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that contains the properties associated with an asynchronous
-- batch translation job.
describeTextTranslationJobResponse_textTranslationJobProperties :: Lens.Lens' DescribeTextTranslationJobResponse (Prelude.Maybe TextTranslationJobProperties)
describeTextTranslationJobResponse_textTranslationJobProperties :: (Maybe TextTranslationJobProperties
 -> f (Maybe TextTranslationJobProperties))
-> DescribeTextTranslationJobResponse
-> f DescribeTextTranslationJobResponse
describeTextTranslationJobResponse_textTranslationJobProperties = (DescribeTextTranslationJobResponse
 -> Maybe TextTranslationJobProperties)
-> (DescribeTextTranslationJobResponse
    -> Maybe TextTranslationJobProperties
    -> DescribeTextTranslationJobResponse)
-> Lens
     DescribeTextTranslationJobResponse
     DescribeTextTranslationJobResponse
     (Maybe TextTranslationJobProperties)
     (Maybe TextTranslationJobProperties)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTextTranslationJobResponse' {Maybe TextTranslationJobProperties
textTranslationJobProperties :: Maybe TextTranslationJobProperties
$sel:textTranslationJobProperties:DescribeTextTranslationJobResponse' :: DescribeTextTranslationJobResponse
-> Maybe TextTranslationJobProperties
textTranslationJobProperties} -> Maybe TextTranslationJobProperties
textTranslationJobProperties) (\s :: DescribeTextTranslationJobResponse
s@DescribeTextTranslationJobResponse' {} Maybe TextTranslationJobProperties
a -> DescribeTextTranslationJobResponse
s {$sel:textTranslationJobProperties:DescribeTextTranslationJobResponse' :: Maybe TextTranslationJobProperties
textTranslationJobProperties = Maybe TextTranslationJobProperties
a} :: DescribeTextTranslationJobResponse)

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

instance
  Prelude.NFData
    DescribeTextTranslationJobResponse