{-# 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.ElasticTranscoder.ReadJob
-- 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)
--
-- The ReadJob operation returns detailed information about a job.
module Amazonka.ElasticTranscoder.ReadJob
  ( -- * Creating a Request
    ReadJob (..),
    newReadJob,

    -- * Request Lenses
    readJob_id,

    -- * Destructuring the Response
    ReadJobResponse (..),
    newReadJobResponse,

    -- * Response Lenses
    readJobResponse_httpStatus,
    readJobResponse_job,
  )
where

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

-- | The @ReadJobRequest@ structure.
--
-- /See:/ 'newReadJob' smart constructor.
data ReadJob = ReadJob'
  { -- | The identifier of the job for which you want to get detailed
    -- information.
    ReadJob -> Text
id :: Prelude.Text
  }
  deriving (ReadJob -> ReadJob -> Bool
(ReadJob -> ReadJob -> Bool)
-> (ReadJob -> ReadJob -> Bool) -> Eq ReadJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReadJob -> ReadJob -> Bool
$c/= :: ReadJob -> ReadJob -> Bool
== :: ReadJob -> ReadJob -> Bool
$c== :: ReadJob -> ReadJob -> Bool
Prelude.Eq, ReadPrec [ReadJob]
ReadPrec ReadJob
Int -> ReadS ReadJob
ReadS [ReadJob]
(Int -> ReadS ReadJob)
-> ReadS [ReadJob]
-> ReadPrec ReadJob
-> ReadPrec [ReadJob]
-> Read ReadJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReadJob]
$creadListPrec :: ReadPrec [ReadJob]
readPrec :: ReadPrec ReadJob
$creadPrec :: ReadPrec ReadJob
readList :: ReadS [ReadJob]
$creadList :: ReadS [ReadJob]
readsPrec :: Int -> ReadS ReadJob
$creadsPrec :: Int -> ReadS ReadJob
Prelude.Read, Int -> ReadJob -> ShowS
[ReadJob] -> ShowS
ReadJob -> String
(Int -> ReadJob -> ShowS)
-> (ReadJob -> String) -> ([ReadJob] -> ShowS) -> Show ReadJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReadJob] -> ShowS
$cshowList :: [ReadJob] -> ShowS
show :: ReadJob -> String
$cshow :: ReadJob -> String
showsPrec :: Int -> ReadJob -> ShowS
$cshowsPrec :: Int -> ReadJob -> ShowS
Prelude.Show, (forall x. ReadJob -> Rep ReadJob x)
-> (forall x. Rep ReadJob x -> ReadJob) -> Generic ReadJob
forall x. Rep ReadJob x -> ReadJob
forall x. ReadJob -> Rep ReadJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReadJob x -> ReadJob
$cfrom :: forall x. ReadJob -> Rep ReadJob x
Prelude.Generic)

-- |
-- Create a value of 'ReadJob' 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:
--
-- 'id', 'readJob_id' - The identifier of the job for which you want to get detailed
-- information.
newReadJob ::
  -- | 'id'
  Prelude.Text ->
  ReadJob
newReadJob :: Text -> ReadJob
newReadJob Text
pId_ = ReadJob' :: Text -> ReadJob
ReadJob' {$sel:id:ReadJob' :: Text
id = Text
pId_}

-- | The identifier of the job for which you want to get detailed
-- information.
readJob_id :: Lens.Lens' ReadJob Prelude.Text
readJob_id :: (Text -> f Text) -> ReadJob -> f ReadJob
readJob_id = (ReadJob -> Text)
-> (ReadJob -> Text -> ReadJob) -> Lens ReadJob ReadJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReadJob' {Text
id :: Text
$sel:id:ReadJob' :: ReadJob -> Text
id} -> Text
id) (\s :: ReadJob
s@ReadJob' {} Text
a -> ReadJob
s {$sel:id:ReadJob' :: Text
id = Text
a} :: ReadJob)

instance Core.AWSRequest ReadJob where
  type AWSResponse ReadJob = ReadJobResponse
  request :: ReadJob -> Request ReadJob
request = Service -> ReadJob -> Request ReadJob
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ReadJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ReadJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ReadJob))
-> Logger
-> Service
-> Proxy ReadJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ReadJob)))
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 ->
          Int -> Job -> ReadJobResponse
ReadJobResponse'
            (Int -> Job -> ReadJobResponse)
-> Either String Int -> Either String (Job -> ReadJobResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (Job -> ReadJobResponse)
-> Either String Job -> Either String ReadJobResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Job
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Job")
      )

instance Prelude.Hashable ReadJob

instance Prelude.NFData ReadJob

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

instance Core.ToPath ReadJob where
  toPath :: ReadJob -> ByteString
toPath ReadJob' {Text
id :: Text
$sel:id:ReadJob' :: ReadJob -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/2012-09-25/jobs/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id]

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

-- | The @ReadJobResponse@ structure.
--
-- /See:/ 'newReadJobResponse' smart constructor.
data ReadJobResponse = ReadJobResponse'
  { -- | The response's http status code.
    ReadJobResponse -> Int
httpStatus :: Prelude.Int,
    -- | A section of the response body that provides information about the job.
    ReadJobResponse -> Job
job :: Job
  }
  deriving (ReadJobResponse -> ReadJobResponse -> Bool
(ReadJobResponse -> ReadJobResponse -> Bool)
-> (ReadJobResponse -> ReadJobResponse -> Bool)
-> Eq ReadJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReadJobResponse -> ReadJobResponse -> Bool
$c/= :: ReadJobResponse -> ReadJobResponse -> Bool
== :: ReadJobResponse -> ReadJobResponse -> Bool
$c== :: ReadJobResponse -> ReadJobResponse -> Bool
Prelude.Eq, ReadPrec [ReadJobResponse]
ReadPrec ReadJobResponse
Int -> ReadS ReadJobResponse
ReadS [ReadJobResponse]
(Int -> ReadS ReadJobResponse)
-> ReadS [ReadJobResponse]
-> ReadPrec ReadJobResponse
-> ReadPrec [ReadJobResponse]
-> Read ReadJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReadJobResponse]
$creadListPrec :: ReadPrec [ReadJobResponse]
readPrec :: ReadPrec ReadJobResponse
$creadPrec :: ReadPrec ReadJobResponse
readList :: ReadS [ReadJobResponse]
$creadList :: ReadS [ReadJobResponse]
readsPrec :: Int -> ReadS ReadJobResponse
$creadsPrec :: Int -> ReadS ReadJobResponse
Prelude.Read, Int -> ReadJobResponse -> ShowS
[ReadJobResponse] -> ShowS
ReadJobResponse -> String
(Int -> ReadJobResponse -> ShowS)
-> (ReadJobResponse -> String)
-> ([ReadJobResponse] -> ShowS)
-> Show ReadJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReadJobResponse] -> ShowS
$cshowList :: [ReadJobResponse] -> ShowS
show :: ReadJobResponse -> String
$cshow :: ReadJobResponse -> String
showsPrec :: Int -> ReadJobResponse -> ShowS
$cshowsPrec :: Int -> ReadJobResponse -> ShowS
Prelude.Show, (forall x. ReadJobResponse -> Rep ReadJobResponse x)
-> (forall x. Rep ReadJobResponse x -> ReadJobResponse)
-> Generic ReadJobResponse
forall x. Rep ReadJobResponse x -> ReadJobResponse
forall x. ReadJobResponse -> Rep ReadJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReadJobResponse x -> ReadJobResponse
$cfrom :: forall x. ReadJobResponse -> Rep ReadJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'ReadJobResponse' 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', 'readJobResponse_httpStatus' - The response's http status code.
--
-- 'job', 'readJobResponse_job' - A section of the response body that provides information about the job.
newReadJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'job'
  Job ->
  ReadJobResponse
newReadJobResponse :: Int -> Job -> ReadJobResponse
newReadJobResponse Int
pHttpStatus_ Job
pJob_ =
  ReadJobResponse' :: Int -> Job -> ReadJobResponse
ReadJobResponse'
    { $sel:httpStatus:ReadJobResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:job:ReadJobResponse' :: Job
job = Job
pJob_
    }

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

-- | A section of the response body that provides information about the job.
readJobResponse_job :: Lens.Lens' ReadJobResponse Job
readJobResponse_job :: (Job -> f Job) -> ReadJobResponse -> f ReadJobResponse
readJobResponse_job = (ReadJobResponse -> Job)
-> (ReadJobResponse -> Job -> ReadJobResponse)
-> Lens ReadJobResponse ReadJobResponse Job Job
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReadJobResponse' {Job
job :: Job
$sel:job:ReadJobResponse' :: ReadJobResponse -> Job
job} -> Job
job) (\s :: ReadJobResponse
s@ReadJobResponse' {} Job
a -> ReadJobResponse
s {$sel:job:ReadJobResponse' :: Job
job = Job
a} :: ReadJobResponse)

instance Prelude.NFData ReadJobResponse