{-# 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.MediaConvert.GetJob
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieve the JSON for a specific completed transcoding job.
module Amazonka.MediaConvert.GetJob
  ( -- * Creating a Request
    GetJob (..),
    newGetJob,

    -- * Request Lenses
    getJob_id,

    -- * Destructuring the Response
    GetJobResponse (..),
    newGetJobResponse,

    -- * Response Lenses
    getJobResponse_job,
    getJobResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaConvert.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'GetJob' 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', 'getJob_id' - the job ID of the job.
newGetJob ::
  -- | 'id'
  Prelude.Text ->
  GetJob
newGetJob :: Text -> GetJob
newGetJob Text
pId_ = GetJob' {$sel:id:GetJob' :: Text
id = Text
pId_}

-- | the job ID of the job.
getJob_id :: Lens.Lens' GetJob Prelude.Text
getJob_id :: Lens' GetJob Text
getJob_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetJob' {Text
id :: Text
$sel:id:GetJob' :: GetJob -> Text
id} -> Text
id) (\s :: GetJob
s@GetJob' {} Text
a -> GetJob
s {$sel:id:GetJob' :: Text
id = Text
a} :: GetJob)

instance Core.AWSRequest GetJob where
  type AWSResponse GetJob = GetJobResponse
  request :: (Service -> Service) -> GetJob -> Request GetJob
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 GetJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetJob)))
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 ->
          Maybe Job -> Int -> GetJobResponse
GetJobResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"job")
            forall (f :: * -> *) a b. Applicative f => 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))
      )

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

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

instance Data.ToHeaders GetJob where
  toHeaders :: GetJob -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetJob where
  toPath :: GetJob -> ByteString
toPath GetJob' {Text
id :: Text
$sel:id:GetJob' :: GetJob -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/2017-08-29/jobs/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id]

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

-- | /See:/ 'newGetJobResponse' smart constructor.
data GetJobResponse = GetJobResponse'
  { -- | Each job converts an input file into an output file or files. For more
    -- information, see the User Guide at
    -- https:\/\/docs.aws.amazon.com\/mediaconvert\/latest\/ug\/what-is.html
    GetJobResponse -> Maybe Job
job :: Prelude.Maybe Job,
    -- | The response's http status code.
    GetJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetJobResponse -> GetJobResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetJobResponse -> GetJobResponse -> Bool
$c/= :: GetJobResponse -> GetJobResponse -> Bool
== :: GetJobResponse -> GetJobResponse -> Bool
$c== :: GetJobResponse -> GetJobResponse -> Bool
Prelude.Eq, ReadPrec [GetJobResponse]
ReadPrec GetJobResponse
Int -> ReadS GetJobResponse
ReadS [GetJobResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetJobResponse]
$creadListPrec :: ReadPrec [GetJobResponse]
readPrec :: ReadPrec GetJobResponse
$creadPrec :: ReadPrec GetJobResponse
readList :: ReadS [GetJobResponse]
$creadList :: ReadS [GetJobResponse]
readsPrec :: Int -> ReadS GetJobResponse
$creadsPrec :: Int -> ReadS GetJobResponse
Prelude.Read, Int -> GetJobResponse -> ShowS
[GetJobResponse] -> ShowS
GetJobResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetJobResponse] -> ShowS
$cshowList :: [GetJobResponse] -> ShowS
show :: GetJobResponse -> String
$cshow :: GetJobResponse -> String
showsPrec :: Int -> GetJobResponse -> ShowS
$cshowsPrec :: Int -> GetJobResponse -> ShowS
Prelude.Show, forall x. Rep GetJobResponse x -> GetJobResponse
forall x. GetJobResponse -> Rep GetJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetJobResponse x -> GetJobResponse
$cfrom :: forall x. GetJobResponse -> Rep GetJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetJobResponse' 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:
--
-- 'job', 'getJobResponse_job' - Each job converts an input file into an output file or files. For more
-- information, see the User Guide at
-- https:\/\/docs.aws.amazon.com\/mediaconvert\/latest\/ug\/what-is.html
--
-- 'httpStatus', 'getJobResponse_httpStatus' - The response's http status code.
newGetJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetJobResponse
newGetJobResponse :: Int -> GetJobResponse
newGetJobResponse Int
pHttpStatus_ =
  GetJobResponse'
    { $sel:job:GetJobResponse' :: Maybe Job
job = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Each job converts an input file into an output file or files. For more
-- information, see the User Guide at
-- https:\/\/docs.aws.amazon.com\/mediaconvert\/latest\/ug\/what-is.html
getJobResponse_job :: Lens.Lens' GetJobResponse (Prelude.Maybe Job)
getJobResponse_job :: Lens' GetJobResponse (Maybe Job)
getJobResponse_job = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetJobResponse' {Maybe Job
job :: Maybe Job
$sel:job:GetJobResponse' :: GetJobResponse -> Maybe Job
job} -> Maybe Job
job) (\s :: GetJobResponse
s@GetJobResponse' {} Maybe Job
a -> GetJobResponse
s {$sel:job:GetJobResponse' :: Maybe Job
job = Maybe Job
a} :: GetJobResponse)

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

instance Prelude.NFData GetJobResponse where
  rnf :: GetJobResponse -> ()
rnf GetJobResponse' {Int
Maybe Job
httpStatus :: Int
job :: Maybe Job
$sel:httpStatus:GetJobResponse' :: GetJobResponse -> Int
$sel:job:GetJobResponse' :: GetJobResponse -> Maybe Job
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Job
job
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus