{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticTranscoder.Types
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
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]
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
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. 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' {$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 :: Lens' ReadJob Text
readJob_id = 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 :: (Service -> Service) -> ReadJob -> Request ReadJob
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 ReadJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ReadJob)))
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 ->
          Int -> Job -> ReadJobResponse
ReadJobResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"Job")
      )

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

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

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

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

instance Data.ToQuery ReadJob where
  toQuery :: ReadJob -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $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 :: Lens' ReadJobResponse Int
readJobResponse_httpStatus = 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 :: Lens' ReadJobResponse Job
readJobResponse_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 where
  rnf :: ReadJobResponse -> ()
rnf ReadJobResponse' {Int
Job
job :: Job
httpStatus :: Int
$sel:job:ReadJobResponse' :: ReadJobResponse -> Job
$sel:httpStatus:ReadJobResponse' :: ReadJobResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Job
job