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

    -- * Request Lenses
    describeJobExecution_executionNumber,
    describeJobExecution_jobId,
    describeJobExecution_thingName,

    -- * Destructuring the Response
    DescribeJobExecutionResponse (..),
    newDescribeJobExecutionResponse,

    -- * Response Lenses
    describeJobExecutionResponse_execution,
    describeJobExecutionResponse_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:/ 'newDescribeJobExecution' smart constructor.
data DescribeJobExecution = DescribeJobExecution'
  { -- | A string (consisting of the digits \"0\" through \"9\" which is used to
    -- specify a particular job execution on a particular device.
    DescribeJobExecution -> Maybe Integer
executionNumber :: Prelude.Maybe Prelude.Integer,
    -- | The unique identifier you assigned to this job when it was created.
    DescribeJobExecution -> Text
jobId :: Prelude.Text,
    -- | The name of the thing on which the job execution is running.
    DescribeJobExecution -> Text
thingName :: Prelude.Text
  }
  deriving (DescribeJobExecution -> DescribeJobExecution -> Bool
(DescribeJobExecution -> DescribeJobExecution -> Bool)
-> (DescribeJobExecution -> DescribeJobExecution -> Bool)
-> Eq DescribeJobExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeJobExecution -> DescribeJobExecution -> Bool
$c/= :: DescribeJobExecution -> DescribeJobExecution -> Bool
== :: DescribeJobExecution -> DescribeJobExecution -> Bool
$c== :: DescribeJobExecution -> DescribeJobExecution -> Bool
Prelude.Eq, ReadPrec [DescribeJobExecution]
ReadPrec DescribeJobExecution
Int -> ReadS DescribeJobExecution
ReadS [DescribeJobExecution]
(Int -> ReadS DescribeJobExecution)
-> ReadS [DescribeJobExecution]
-> ReadPrec DescribeJobExecution
-> ReadPrec [DescribeJobExecution]
-> Read DescribeJobExecution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeJobExecution]
$creadListPrec :: ReadPrec [DescribeJobExecution]
readPrec :: ReadPrec DescribeJobExecution
$creadPrec :: ReadPrec DescribeJobExecution
readList :: ReadS [DescribeJobExecution]
$creadList :: ReadS [DescribeJobExecution]
readsPrec :: Int -> ReadS DescribeJobExecution
$creadsPrec :: Int -> ReadS DescribeJobExecution
Prelude.Read, Int -> DescribeJobExecution -> ShowS
[DescribeJobExecution] -> ShowS
DescribeJobExecution -> String
(Int -> DescribeJobExecution -> ShowS)
-> (DescribeJobExecution -> String)
-> ([DescribeJobExecution] -> ShowS)
-> Show DescribeJobExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeJobExecution] -> ShowS
$cshowList :: [DescribeJobExecution] -> ShowS
show :: DescribeJobExecution -> String
$cshow :: DescribeJobExecution -> String
showsPrec :: Int -> DescribeJobExecution -> ShowS
$cshowsPrec :: Int -> DescribeJobExecution -> ShowS
Prelude.Show, (forall x. DescribeJobExecution -> Rep DescribeJobExecution x)
-> (forall x. Rep DescribeJobExecution x -> DescribeJobExecution)
-> Generic DescribeJobExecution
forall x. Rep DescribeJobExecution x -> DescribeJobExecution
forall x. DescribeJobExecution -> Rep DescribeJobExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeJobExecution x -> DescribeJobExecution
$cfrom :: forall x. DescribeJobExecution -> Rep DescribeJobExecution x
Prelude.Generic)

-- |
-- Create a value of 'DescribeJobExecution' 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:
--
-- 'executionNumber', 'describeJobExecution_executionNumber' - A string (consisting of the digits \"0\" through \"9\" which is used to
-- specify a particular job execution on a particular device.
--
-- 'jobId', 'describeJobExecution_jobId' - The unique identifier you assigned to this job when it was created.
--
-- 'thingName', 'describeJobExecution_thingName' - The name of the thing on which the job execution is running.
newDescribeJobExecution ::
  -- | 'jobId'
  Prelude.Text ->
  -- | 'thingName'
  Prelude.Text ->
  DescribeJobExecution
newDescribeJobExecution :: Text -> Text -> DescribeJobExecution
newDescribeJobExecution Text
pJobId_ Text
pThingName_ =
  DescribeJobExecution' :: Maybe Integer -> Text -> Text -> DescribeJobExecution
DescribeJobExecution'
    { $sel:executionNumber:DescribeJobExecution' :: Maybe Integer
executionNumber =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:jobId:DescribeJobExecution' :: Text
jobId = Text
pJobId_,
      $sel:thingName:DescribeJobExecution' :: Text
thingName = Text
pThingName_
    }

-- | A string (consisting of the digits \"0\" through \"9\" which is used to
-- specify a particular job execution on a particular device.
describeJobExecution_executionNumber :: Lens.Lens' DescribeJobExecution (Prelude.Maybe Prelude.Integer)
describeJobExecution_executionNumber :: (Maybe Integer -> f (Maybe Integer))
-> DescribeJobExecution -> f DescribeJobExecution
describeJobExecution_executionNumber = (DescribeJobExecution -> Maybe Integer)
-> (DescribeJobExecution -> Maybe Integer -> DescribeJobExecution)
-> Lens
     DescribeJobExecution
     DescribeJobExecution
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeJobExecution' {Maybe Integer
executionNumber :: Maybe Integer
$sel:executionNumber:DescribeJobExecution' :: DescribeJobExecution -> Maybe Integer
executionNumber} -> Maybe Integer
executionNumber) (\s :: DescribeJobExecution
s@DescribeJobExecution' {} Maybe Integer
a -> DescribeJobExecution
s {$sel:executionNumber:DescribeJobExecution' :: Maybe Integer
executionNumber = Maybe Integer
a} :: DescribeJobExecution)

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

-- | The name of the thing on which the job execution is running.
describeJobExecution_thingName :: Lens.Lens' DescribeJobExecution Prelude.Text
describeJobExecution_thingName :: (Text -> f Text) -> DescribeJobExecution -> f DescribeJobExecution
describeJobExecution_thingName = (DescribeJobExecution -> Text)
-> (DescribeJobExecution -> Text -> DescribeJobExecution)
-> Lens DescribeJobExecution DescribeJobExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeJobExecution' {Text
thingName :: Text
$sel:thingName:DescribeJobExecution' :: DescribeJobExecution -> Text
thingName} -> Text
thingName) (\s :: DescribeJobExecution
s@DescribeJobExecution' {} Text
a -> DescribeJobExecution
s {$sel:thingName:DescribeJobExecution' :: Text
thingName = Text
a} :: DescribeJobExecution)

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

instance Prelude.NFData DescribeJobExecution

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

instance Core.ToPath DescribeJobExecution where
  toPath :: DescribeJobExecution -> ByteString
toPath DescribeJobExecution' {Maybe Integer
Text
thingName :: Text
jobId :: Text
executionNumber :: Maybe Integer
$sel:thingName:DescribeJobExecution' :: DescribeJobExecution -> Text
$sel:jobId:DescribeJobExecution' :: DescribeJobExecution -> Text
$sel:executionNumber:DescribeJobExecution' :: DescribeJobExecution -> Maybe Integer
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/things/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
thingName,
        ByteString
"/jobs/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
jobId
      ]

instance Core.ToQuery DescribeJobExecution where
  toQuery :: DescribeJobExecution -> QueryString
toQuery DescribeJobExecution' {Maybe Integer
Text
thingName :: Text
jobId :: Text
executionNumber :: Maybe Integer
$sel:thingName:DescribeJobExecution' :: DescribeJobExecution -> Text
$sel:jobId:DescribeJobExecution' :: DescribeJobExecution -> Text
$sel:executionNumber:DescribeJobExecution' :: DescribeJobExecution -> Maybe Integer
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"executionNumber" ByteString -> Maybe Integer -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Integer
executionNumber]

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

-- |
-- Create a value of 'DescribeJobExecutionResponse' 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:
--
-- 'execution', 'describeJobExecutionResponse_execution' - Information about the job execution.
--
-- 'httpStatus', 'describeJobExecutionResponse_httpStatus' - The response's http status code.
newDescribeJobExecutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeJobExecutionResponse
newDescribeJobExecutionResponse :: Int -> DescribeJobExecutionResponse
newDescribeJobExecutionResponse Int
pHttpStatus_ =
  DescribeJobExecutionResponse' :: Maybe JobExecution -> Int -> DescribeJobExecutionResponse
DescribeJobExecutionResponse'
    { $sel:execution:DescribeJobExecutionResponse' :: Maybe JobExecution
execution =
        Maybe JobExecution
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeJobExecutionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the job execution.
describeJobExecutionResponse_execution :: Lens.Lens' DescribeJobExecutionResponse (Prelude.Maybe JobExecution)
describeJobExecutionResponse_execution :: (Maybe JobExecution -> f (Maybe JobExecution))
-> DescribeJobExecutionResponse -> f DescribeJobExecutionResponse
describeJobExecutionResponse_execution = (DescribeJobExecutionResponse -> Maybe JobExecution)
-> (DescribeJobExecutionResponse
    -> Maybe JobExecution -> DescribeJobExecutionResponse)
-> Lens
     DescribeJobExecutionResponse
     DescribeJobExecutionResponse
     (Maybe JobExecution)
     (Maybe JobExecution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeJobExecutionResponse' {Maybe JobExecution
execution :: Maybe JobExecution
$sel:execution:DescribeJobExecutionResponse' :: DescribeJobExecutionResponse -> Maybe JobExecution
execution} -> Maybe JobExecution
execution) (\s :: DescribeJobExecutionResponse
s@DescribeJobExecutionResponse' {} Maybe JobExecution
a -> DescribeJobExecutionResponse
s {$sel:execution:DescribeJobExecutionResponse' :: Maybe JobExecution
execution = Maybe JobExecution
a} :: DescribeJobExecutionResponse)

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

instance Prelude.NFData DescribeJobExecutionResponse