{-# 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.IoT.GetJobDocument
-- 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)
--
-- Gets a job document.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions GetJobDocument>
-- action.
module Amazonka.IoT.GetJobDocument
  ( -- * Creating a Request
    GetJobDocument (..),
    newGetJobDocument,

    -- * Request Lenses
    getJobDocument_jobId,

    -- * Destructuring the Response
    GetJobDocumentResponse (..),
    newGetJobDocumentResponse,

    -- * Response Lenses
    getJobDocumentResponse_document,
    getJobDocumentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.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

-- | /See:/ 'newGetJobDocument' smart constructor.
data GetJobDocument = GetJobDocument'
  { -- | The unique identifier you assigned to this job when it was created.
    GetJobDocument -> Text
jobId :: Prelude.Text
  }
  deriving (GetJobDocument -> GetJobDocument -> Bool
(GetJobDocument -> GetJobDocument -> Bool)
-> (GetJobDocument -> GetJobDocument -> Bool) -> Eq GetJobDocument
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetJobDocument -> GetJobDocument -> Bool
$c/= :: GetJobDocument -> GetJobDocument -> Bool
== :: GetJobDocument -> GetJobDocument -> Bool
$c== :: GetJobDocument -> GetJobDocument -> Bool
Prelude.Eq, ReadPrec [GetJobDocument]
ReadPrec GetJobDocument
Int -> ReadS GetJobDocument
ReadS [GetJobDocument]
(Int -> ReadS GetJobDocument)
-> ReadS [GetJobDocument]
-> ReadPrec GetJobDocument
-> ReadPrec [GetJobDocument]
-> Read GetJobDocument
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetJobDocument]
$creadListPrec :: ReadPrec [GetJobDocument]
readPrec :: ReadPrec GetJobDocument
$creadPrec :: ReadPrec GetJobDocument
readList :: ReadS [GetJobDocument]
$creadList :: ReadS [GetJobDocument]
readsPrec :: Int -> ReadS GetJobDocument
$creadsPrec :: Int -> ReadS GetJobDocument
Prelude.Read, Int -> GetJobDocument -> ShowS
[GetJobDocument] -> ShowS
GetJobDocument -> String
(Int -> GetJobDocument -> ShowS)
-> (GetJobDocument -> String)
-> ([GetJobDocument] -> ShowS)
-> Show GetJobDocument
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetJobDocument] -> ShowS
$cshowList :: [GetJobDocument] -> ShowS
show :: GetJobDocument -> String
$cshow :: GetJobDocument -> String
showsPrec :: Int -> GetJobDocument -> ShowS
$cshowsPrec :: Int -> GetJobDocument -> ShowS
Prelude.Show, (forall x. GetJobDocument -> Rep GetJobDocument x)
-> (forall x. Rep GetJobDocument x -> GetJobDocument)
-> Generic GetJobDocument
forall x. Rep GetJobDocument x -> GetJobDocument
forall x. GetJobDocument -> Rep GetJobDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetJobDocument x -> GetJobDocument
$cfrom :: forall x. GetJobDocument -> Rep GetJobDocument x
Prelude.Generic)

-- |
-- Create a value of 'GetJobDocument' 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:
--
-- 'jobId', 'getJobDocument_jobId' - The unique identifier you assigned to this job when it was created.
newGetJobDocument ::
  -- | 'jobId'
  Prelude.Text ->
  GetJobDocument
newGetJobDocument :: Text -> GetJobDocument
newGetJobDocument Text
pJobId_ =
  GetJobDocument' :: Text -> GetJobDocument
GetJobDocument' {$sel:jobId:GetJobDocument' :: Text
jobId = Text
pJobId_}

-- | The unique identifier you assigned to this job when it was created.
getJobDocument_jobId :: Lens.Lens' GetJobDocument Prelude.Text
getJobDocument_jobId :: (Text -> f Text) -> GetJobDocument -> f GetJobDocument
getJobDocument_jobId = (GetJobDocument -> Text)
-> (GetJobDocument -> Text -> GetJobDocument)
-> Lens GetJobDocument GetJobDocument Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetJobDocument' {Text
jobId :: Text
$sel:jobId:GetJobDocument' :: GetJobDocument -> Text
jobId} -> Text
jobId) (\s :: GetJobDocument
s@GetJobDocument' {} Text
a -> GetJobDocument
s {$sel:jobId:GetJobDocument' :: Text
jobId = Text
a} :: GetJobDocument)

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

instance Prelude.NFData GetJobDocument

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

instance Core.ToPath GetJobDocument where
  toPath :: GetJobDocument -> ByteString
toPath GetJobDocument' {Text
jobId :: Text
$sel:jobId:GetJobDocument' :: GetJobDocument -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/jobs/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
jobId, ByteString
"/job-document"]

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

-- | /See:/ 'newGetJobDocumentResponse' smart constructor.
data GetJobDocumentResponse = GetJobDocumentResponse'
  { -- | The job document content.
    GetJobDocumentResponse -> Maybe Text
document :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetJobDocumentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetJobDocumentResponse -> GetJobDocumentResponse -> Bool
(GetJobDocumentResponse -> GetJobDocumentResponse -> Bool)
-> (GetJobDocumentResponse -> GetJobDocumentResponse -> Bool)
-> Eq GetJobDocumentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetJobDocumentResponse -> GetJobDocumentResponse -> Bool
$c/= :: GetJobDocumentResponse -> GetJobDocumentResponse -> Bool
== :: GetJobDocumentResponse -> GetJobDocumentResponse -> Bool
$c== :: GetJobDocumentResponse -> GetJobDocumentResponse -> Bool
Prelude.Eq, ReadPrec [GetJobDocumentResponse]
ReadPrec GetJobDocumentResponse
Int -> ReadS GetJobDocumentResponse
ReadS [GetJobDocumentResponse]
(Int -> ReadS GetJobDocumentResponse)
-> ReadS [GetJobDocumentResponse]
-> ReadPrec GetJobDocumentResponse
-> ReadPrec [GetJobDocumentResponse]
-> Read GetJobDocumentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetJobDocumentResponse]
$creadListPrec :: ReadPrec [GetJobDocumentResponse]
readPrec :: ReadPrec GetJobDocumentResponse
$creadPrec :: ReadPrec GetJobDocumentResponse
readList :: ReadS [GetJobDocumentResponse]
$creadList :: ReadS [GetJobDocumentResponse]
readsPrec :: Int -> ReadS GetJobDocumentResponse
$creadsPrec :: Int -> ReadS GetJobDocumentResponse
Prelude.Read, Int -> GetJobDocumentResponse -> ShowS
[GetJobDocumentResponse] -> ShowS
GetJobDocumentResponse -> String
(Int -> GetJobDocumentResponse -> ShowS)
-> (GetJobDocumentResponse -> String)
-> ([GetJobDocumentResponse] -> ShowS)
-> Show GetJobDocumentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetJobDocumentResponse] -> ShowS
$cshowList :: [GetJobDocumentResponse] -> ShowS
show :: GetJobDocumentResponse -> String
$cshow :: GetJobDocumentResponse -> String
showsPrec :: Int -> GetJobDocumentResponse -> ShowS
$cshowsPrec :: Int -> GetJobDocumentResponse -> ShowS
Prelude.Show, (forall x. GetJobDocumentResponse -> Rep GetJobDocumentResponse x)
-> (forall x.
    Rep GetJobDocumentResponse x -> GetJobDocumentResponse)
-> Generic GetJobDocumentResponse
forall x. Rep GetJobDocumentResponse x -> GetJobDocumentResponse
forall x. GetJobDocumentResponse -> Rep GetJobDocumentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetJobDocumentResponse x -> GetJobDocumentResponse
$cfrom :: forall x. GetJobDocumentResponse -> Rep GetJobDocumentResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetJobDocumentResponse' 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:
--
-- 'document', 'getJobDocumentResponse_document' - The job document content.
--
-- 'httpStatus', 'getJobDocumentResponse_httpStatus' - The response's http status code.
newGetJobDocumentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetJobDocumentResponse
newGetJobDocumentResponse :: Int -> GetJobDocumentResponse
newGetJobDocumentResponse Int
pHttpStatus_ =
  GetJobDocumentResponse' :: Maybe Text -> Int -> GetJobDocumentResponse
GetJobDocumentResponse'
    { $sel:document:GetJobDocumentResponse' :: Maybe Text
document = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetJobDocumentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The job document content.
getJobDocumentResponse_document :: Lens.Lens' GetJobDocumentResponse (Prelude.Maybe Prelude.Text)
getJobDocumentResponse_document :: (Maybe Text -> f (Maybe Text))
-> GetJobDocumentResponse -> f GetJobDocumentResponse
getJobDocumentResponse_document = (GetJobDocumentResponse -> Maybe Text)
-> (GetJobDocumentResponse -> Maybe Text -> GetJobDocumentResponse)
-> Lens
     GetJobDocumentResponse
     GetJobDocumentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetJobDocumentResponse' {Maybe Text
document :: Maybe Text
$sel:document:GetJobDocumentResponse' :: GetJobDocumentResponse -> Maybe Text
document} -> Maybe Text
document) (\s :: GetJobDocumentResponse
s@GetJobDocumentResponse' {} Maybe Text
a -> GetJobDocumentResponse
s {$sel:document:GetJobDocumentResponse' :: Maybe Text
document = Maybe Text
a} :: GetJobDocumentResponse)

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

instance Prelude.NFData GetJobDocumentResponse