{-# 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-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)
--
-- 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.Lens as Lens
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
(GetJobTemplate -> GetJobTemplate -> Bool)
-> (GetJobTemplate -> GetJobTemplate -> Bool) -> Eq GetJobTemplate
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]
(Int -> ReadS GetJobTemplate)
-> ReadS [GetJobTemplate]
-> ReadPrec GetJobTemplate
-> ReadPrec [GetJobTemplate]
-> Read 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
(Int -> GetJobTemplate -> ShowS)
-> (GetJobTemplate -> String)
-> ([GetJobTemplate] -> ShowS)
-> Show GetJobTemplate
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. GetJobTemplate -> Rep GetJobTemplate x)
-> (forall x. Rep GetJobTemplate x -> GetJobTemplate)
-> Generic GetJobTemplate
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' :: Text -> GetJobTemplate
GetJobTemplate' {$sel:name:GetJobTemplate' :: Text
name = Text
pName_}

-- | The name of the job template.
getJobTemplate_name :: Lens.Lens' GetJobTemplate Prelude.Text
getJobTemplate_name :: (Text -> f Text) -> GetJobTemplate -> f GetJobTemplate
getJobTemplate_name = (GetJobTemplate -> Text)
-> (GetJobTemplate -> Text -> GetJobTemplate)
-> Lens GetJobTemplate GetJobTemplate Text Text
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 :: GetJobTemplate -> Request GetJobTemplate
request = Service -> GetJobTemplate -> Request GetJobTemplate
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetJobTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetJobTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetJobTemplate))
-> Logger
-> Service
-> Proxy GetJobTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetJobTemplate)))
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 JobTemplate -> Int -> GetJobTemplateResponse
GetJobTemplateResponse'
            (Maybe JobTemplate -> Int -> GetJobTemplateResponse)
-> Either String (Maybe JobTemplate)
-> Either String (Int -> GetJobTemplateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe JobTemplate)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"jobTemplate")
            Either String (Int -> GetJobTemplateResponse)
-> Either String Int -> Either String GetJobTemplateResponse
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 GetJobTemplate

instance Prelude.NFData GetJobTemplate

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

instance Core.ToQuery GetJobTemplate where
  toQuery :: GetJobTemplate -> QueryString
toQuery = QueryString -> GetJobTemplate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetJobTemplateResponse -> GetJobTemplateResponse -> Bool)
-> (GetJobTemplateResponse -> GetJobTemplateResponse -> Bool)
-> Eq GetJobTemplateResponse
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]
(Int -> ReadS GetJobTemplateResponse)
-> ReadS [GetJobTemplateResponse]
-> ReadPrec GetJobTemplateResponse
-> ReadPrec [GetJobTemplateResponse]
-> Read 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
(Int -> GetJobTemplateResponse -> ShowS)
-> (GetJobTemplateResponse -> String)
-> ([GetJobTemplateResponse] -> ShowS)
-> Show GetJobTemplateResponse
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. GetJobTemplateResponse -> Rep GetJobTemplateResponse x)
-> (forall x.
    Rep GetJobTemplateResponse x -> GetJobTemplateResponse)
-> Generic GetJobTemplateResponse
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' :: Maybe JobTemplate -> Int -> GetJobTemplateResponse
GetJobTemplateResponse'
    { $sel:jobTemplate:GetJobTemplateResponse' :: Maybe JobTemplate
jobTemplate =
        Maybe 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 :: (Maybe JobTemplate -> f (Maybe JobTemplate))
-> GetJobTemplateResponse -> f GetJobTemplateResponse
getJobTemplateResponse_jobTemplate = (GetJobTemplateResponse -> Maybe JobTemplate)
-> (GetJobTemplateResponse
    -> Maybe JobTemplate -> GetJobTemplateResponse)
-> Lens
     GetJobTemplateResponse
     GetJobTemplateResponse
     (Maybe JobTemplate)
     (Maybe 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 :: (Int -> f Int)
-> GetJobTemplateResponse -> f GetJobTemplateResponse
getJobTemplateResponse_httpStatus = (GetJobTemplateResponse -> Int)
-> (GetJobTemplateResponse -> Int -> GetJobTemplateResponse)
-> Lens GetJobTemplateResponse GetJobTemplateResponse Int Int
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