{-# 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.GetJobTemplate
-- 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 job template.
module Amazonka.MediaConvert.GetJobTemplate
  ( -- * Creating a Request
    GetJobTemplate (..),
    newGetJobTemplate,

    -- * Request Lenses
    getJobTemplate_name,

    -- * Destructuring the Response
    GetJobTemplateResponse (..),
    newGetJobTemplateResponse,

    -- * Response Lenses
    getJobTemplateResponse_jobTemplate,
    getJobTemplateResponse_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:/ 'newGetJobTemplate' smart constructor.
data GetJobTemplate = GetJobTemplate'
  { -- | The name of the job template.
    GetJobTemplate -> Text
name :: Prelude.Text
  }
  deriving (GetJobTemplate -> GetJobTemplate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetJobTemplate -> GetJobTemplate -> Bool
$c/= :: GetJobTemplate -> GetJobTemplate -> Bool
== :: GetJobTemplate -> GetJobTemplate -> Bool
$c== :: GetJobTemplate -> GetJobTemplate -> Bool
Prelude.Eq, ReadPrec [GetJobTemplate]
ReadPrec GetJobTemplate
Int -> ReadS GetJobTemplate
ReadS [GetJobTemplate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetJobTemplate]
$creadListPrec :: ReadPrec [GetJobTemplate]
readPrec :: ReadPrec GetJobTemplate
$creadPrec :: ReadPrec GetJobTemplate
readList :: ReadS [GetJobTemplate]
$creadList :: ReadS [GetJobTemplate]
readsPrec :: Int -> ReadS GetJobTemplate
$creadsPrec :: Int -> ReadS GetJobTemplate
Prelude.Read, Int -> GetJobTemplate -> ShowS
[GetJobTemplate] -> ShowS
GetJobTemplate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetJobTemplate] -> ShowS
$cshowList :: [GetJobTemplate] -> ShowS
show :: GetJobTemplate -> String
$cshow :: GetJobTemplate -> String
showsPrec :: Int -> GetJobTemplate -> ShowS
$cshowsPrec :: Int -> GetJobTemplate -> ShowS
Prelude.Show, forall x. Rep GetJobTemplate x -> GetJobTemplate
forall x. GetJobTemplate -> Rep GetJobTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetJobTemplate x -> GetJobTemplate
$cfrom :: forall x. GetJobTemplate -> Rep GetJobTemplate x
Prelude.Generic)

-- |
-- Create a value of 'GetJobTemplate' 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:
--
-- 'name', 'getJobTemplate_name' - The name of the job template.
newGetJobTemplate ::
  -- | 'name'
  Prelude.Text ->
  GetJobTemplate
newGetJobTemplate :: Text -> GetJobTemplate
newGetJobTemplate Text
pName_ =
  GetJobTemplate' {$sel:name:GetJobTemplate' :: Text
name = Text
pName_}

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

instance Core.AWSRequest GetJobTemplate where
  type
    AWSResponse GetJobTemplate =
      GetJobTemplateResponse
  request :: (Service -> Service) -> GetJobTemplate -> Request GetJobTemplate
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 GetJobTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetJobTemplate)))
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 JobTemplate -> Int -> GetJobTemplateResponse
GetJobTemplateResponse'
            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
"jobTemplate")
            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 GetJobTemplate where
  hashWithSalt :: Int -> GetJobTemplate -> Int
hashWithSalt Int
_salt GetJobTemplate' {Text
name :: Text
$sel:name:GetJobTemplate' :: GetJobTemplate -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

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

instance Data.ToHeaders GetJobTemplate where
  toHeaders :: GetJobTemplate -> 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 GetJobTemplate where
  toPath :: GetJobTemplate -> ByteString
toPath GetJobTemplate' {Text
name :: Text
$sel:name:GetJobTemplate' :: GetJobTemplate -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2017-08-29/jobTemplates/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
name]

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

-- | /See:/ 'newGetJobTemplateResponse' smart constructor.
data GetJobTemplateResponse = GetJobTemplateResponse'
  { -- | A job template is a pre-made set of encoding instructions that you can
    -- use to quickly create a job.
    GetJobTemplateResponse -> Maybe JobTemplate
jobTemplate :: Prelude.Maybe JobTemplate,
    -- | The response's http status code.
    GetJobTemplateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetJobTemplateResponse -> GetJobTemplateResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetJobTemplateResponse -> GetJobTemplateResponse -> Bool
$c/= :: GetJobTemplateResponse -> GetJobTemplateResponse -> Bool
== :: GetJobTemplateResponse -> GetJobTemplateResponse -> Bool
$c== :: GetJobTemplateResponse -> GetJobTemplateResponse -> Bool
Prelude.Eq, ReadPrec [GetJobTemplateResponse]
ReadPrec GetJobTemplateResponse
Int -> ReadS GetJobTemplateResponse
ReadS [GetJobTemplateResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetJobTemplateResponse]
$creadListPrec :: ReadPrec [GetJobTemplateResponse]
readPrec :: ReadPrec GetJobTemplateResponse
$creadPrec :: ReadPrec GetJobTemplateResponse
readList :: ReadS [GetJobTemplateResponse]
$creadList :: ReadS [GetJobTemplateResponse]
readsPrec :: Int -> ReadS GetJobTemplateResponse
$creadsPrec :: Int -> ReadS GetJobTemplateResponse
Prelude.Read, Int -> GetJobTemplateResponse -> ShowS
[GetJobTemplateResponse] -> ShowS
GetJobTemplateResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetJobTemplateResponse] -> ShowS
$cshowList :: [GetJobTemplateResponse] -> ShowS
show :: GetJobTemplateResponse -> String
$cshow :: GetJobTemplateResponse -> String
showsPrec :: Int -> GetJobTemplateResponse -> ShowS
$cshowsPrec :: Int -> GetJobTemplateResponse -> ShowS
Prelude.Show, forall x. Rep GetJobTemplateResponse x -> GetJobTemplateResponse
forall x. GetJobTemplateResponse -> Rep GetJobTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetJobTemplateResponse x -> GetJobTemplateResponse
$cfrom :: forall x. GetJobTemplateResponse -> Rep GetJobTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetJobTemplateResponse' 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:
--
-- 'jobTemplate', 'getJobTemplateResponse_jobTemplate' - A job template is a pre-made set of encoding instructions that you can
-- use to quickly create a job.
--
-- 'httpStatus', 'getJobTemplateResponse_httpStatus' - The response's http status code.
newGetJobTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetJobTemplateResponse
newGetJobTemplateResponse :: Int -> GetJobTemplateResponse
newGetJobTemplateResponse Int
pHttpStatus_ =
  GetJobTemplateResponse'
    { $sel:jobTemplate:GetJobTemplateResponse' :: Maybe JobTemplate
jobTemplate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetJobTemplateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A job template is a pre-made set of encoding instructions that you can
-- use to quickly create a job.
getJobTemplateResponse_jobTemplate :: Lens.Lens' GetJobTemplateResponse (Prelude.Maybe JobTemplate)
getJobTemplateResponse_jobTemplate :: Lens' GetJobTemplateResponse (Maybe JobTemplate)
getJobTemplateResponse_jobTemplate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetJobTemplateResponse' {Maybe JobTemplate
jobTemplate :: Maybe JobTemplate
$sel:jobTemplate:GetJobTemplateResponse' :: GetJobTemplateResponse -> Maybe JobTemplate
jobTemplate} -> Maybe JobTemplate
jobTemplate) (\s :: GetJobTemplateResponse
s@GetJobTemplateResponse' {} Maybe JobTemplate
a -> GetJobTemplateResponse
s {$sel:jobTemplate:GetJobTemplateResponse' :: Maybe JobTemplate
jobTemplate = Maybe JobTemplate
a} :: GetJobTemplateResponse)

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

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