{-# 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.IoTJobsData.UpdateJobExecution
-- 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)
--
-- Updates the status of a job execution.
module Amazonka.IoTJobsData.UpdateJobExecution
  ( -- * Creating a Request
    UpdateJobExecution (..),
    newUpdateJobExecution,

    -- * Request Lenses
    updateJobExecution_includeJobDocument,
    updateJobExecution_stepTimeoutInMinutes,
    updateJobExecution_statusDetails,
    updateJobExecution_executionNumber,
    updateJobExecution_expectedVersion,
    updateJobExecution_includeJobExecutionState,
    updateJobExecution_jobId,
    updateJobExecution_thingName,
    updateJobExecution_status,

    -- * Destructuring the Response
    UpdateJobExecutionResponse (..),
    newUpdateJobExecutionResponse,

    -- * Response Lenses
    updateJobExecutionResponse_jobDocument,
    updateJobExecutionResponse_executionState,
    updateJobExecutionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTJobsData.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:/ 'newUpdateJobExecution' smart constructor.
data UpdateJobExecution = UpdateJobExecution'
  { -- | Optional. When set to true, the response contains the job document. The
    -- default is false.
    UpdateJobExecution -> Maybe Bool
includeJobDocument :: Prelude.Maybe Prelude.Bool,
    -- | Specifies the amount of time this device has to finish execution of this
    -- job. If the job execution status is not set to a terminal state before
    -- this timer expires, or before the timer is reset (by again calling
    -- @UpdateJobExecution@, setting the status to @IN_PROGRESS@ and specifying
    -- a new timeout value in this field) the job execution status will be
    -- automatically set to @TIMED_OUT@. Note that setting or resetting this
    -- timeout has no effect on that job execution timeout which may have been
    -- specified when the job was created (@CreateJob@ using field
    -- @timeoutConfig@).
    UpdateJobExecution -> Maybe Integer
stepTimeoutInMinutes :: Prelude.Maybe Prelude.Integer,
    -- | Optional. A collection of name\/value pairs that describe the status of
    -- the job execution. If not specified, the statusDetails are unchanged.
    UpdateJobExecution -> Maybe (HashMap Text Text)
statusDetails :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Optional. A number that identifies a particular job execution on a
    -- particular device.
    UpdateJobExecution -> Maybe Integer
executionNumber :: Prelude.Maybe Prelude.Integer,
    -- | Optional. The expected current version of the job execution. Each time
    -- you update the job execution, its version is incremented. If the version
    -- of the job execution stored in Jobs does not match, the update is
    -- rejected with a VersionMismatch error, and an ErrorResponse that
    -- contains the current job execution status data is returned. (This makes
    -- it unnecessary to perform a separate DescribeJobExecution request in
    -- order to obtain the job execution status data.)
    UpdateJobExecution -> Maybe Integer
expectedVersion :: Prelude.Maybe Prelude.Integer,
    -- | Optional. When included and set to true, the response contains the
    -- JobExecutionState data. The default is false.
    UpdateJobExecution -> Maybe Bool
includeJobExecutionState :: Prelude.Maybe Prelude.Bool,
    -- | The unique identifier assigned to this job when it was created.
    UpdateJobExecution -> Text
jobId :: Prelude.Text,
    -- | The name of the thing associated with the device.
    UpdateJobExecution -> Text
thingName :: Prelude.Text,
    -- | The new status for the job execution (IN_PROGRESS, FAILED, SUCCESS, or
    -- REJECTED). This must be specified on every update.
    UpdateJobExecution -> JobExecutionStatus
status :: JobExecutionStatus
  }
  deriving (UpdateJobExecution -> UpdateJobExecution -> Bool
(UpdateJobExecution -> UpdateJobExecution -> Bool)
-> (UpdateJobExecution -> UpdateJobExecution -> Bool)
-> Eq UpdateJobExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateJobExecution -> UpdateJobExecution -> Bool
$c/= :: UpdateJobExecution -> UpdateJobExecution -> Bool
== :: UpdateJobExecution -> UpdateJobExecution -> Bool
$c== :: UpdateJobExecution -> UpdateJobExecution -> Bool
Prelude.Eq, ReadPrec [UpdateJobExecution]
ReadPrec UpdateJobExecution
Int -> ReadS UpdateJobExecution
ReadS [UpdateJobExecution]
(Int -> ReadS UpdateJobExecution)
-> ReadS [UpdateJobExecution]
-> ReadPrec UpdateJobExecution
-> ReadPrec [UpdateJobExecution]
-> Read UpdateJobExecution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateJobExecution]
$creadListPrec :: ReadPrec [UpdateJobExecution]
readPrec :: ReadPrec UpdateJobExecution
$creadPrec :: ReadPrec UpdateJobExecution
readList :: ReadS [UpdateJobExecution]
$creadList :: ReadS [UpdateJobExecution]
readsPrec :: Int -> ReadS UpdateJobExecution
$creadsPrec :: Int -> ReadS UpdateJobExecution
Prelude.Read, Int -> UpdateJobExecution -> ShowS
[UpdateJobExecution] -> ShowS
UpdateJobExecution -> String
(Int -> UpdateJobExecution -> ShowS)
-> (UpdateJobExecution -> String)
-> ([UpdateJobExecution] -> ShowS)
-> Show UpdateJobExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateJobExecution] -> ShowS
$cshowList :: [UpdateJobExecution] -> ShowS
show :: UpdateJobExecution -> String
$cshow :: UpdateJobExecution -> String
showsPrec :: Int -> UpdateJobExecution -> ShowS
$cshowsPrec :: Int -> UpdateJobExecution -> ShowS
Prelude.Show, (forall x. UpdateJobExecution -> Rep UpdateJobExecution x)
-> (forall x. Rep UpdateJobExecution x -> UpdateJobExecution)
-> Generic UpdateJobExecution
forall x. Rep UpdateJobExecution x -> UpdateJobExecution
forall x. UpdateJobExecution -> Rep UpdateJobExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateJobExecution x -> UpdateJobExecution
$cfrom :: forall x. UpdateJobExecution -> Rep UpdateJobExecution x
Prelude.Generic)

-- |
-- Create a value of 'UpdateJobExecution' 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:
--
-- 'includeJobDocument', 'updateJobExecution_includeJobDocument' - Optional. When set to true, the response contains the job document. The
-- default is false.
--
-- 'stepTimeoutInMinutes', 'updateJobExecution_stepTimeoutInMinutes' - Specifies the amount of time this device has to finish execution of this
-- job. If the job execution status is not set to a terminal state before
-- this timer expires, or before the timer is reset (by again calling
-- @UpdateJobExecution@, setting the status to @IN_PROGRESS@ and specifying
-- a new timeout value in this field) the job execution status will be
-- automatically set to @TIMED_OUT@. Note that setting or resetting this
-- timeout has no effect on that job execution timeout which may have been
-- specified when the job was created (@CreateJob@ using field
-- @timeoutConfig@).
--
-- 'statusDetails', 'updateJobExecution_statusDetails' - Optional. A collection of name\/value pairs that describe the status of
-- the job execution. If not specified, the statusDetails are unchanged.
--
-- 'executionNumber', 'updateJobExecution_executionNumber' - Optional. A number that identifies a particular job execution on a
-- particular device.
--
-- 'expectedVersion', 'updateJobExecution_expectedVersion' - Optional. The expected current version of the job execution. Each time
-- you update the job execution, its version is incremented. If the version
-- of the job execution stored in Jobs does not match, the update is
-- rejected with a VersionMismatch error, and an ErrorResponse that
-- contains the current job execution status data is returned. (This makes
-- it unnecessary to perform a separate DescribeJobExecution request in
-- order to obtain the job execution status data.)
--
-- 'includeJobExecutionState', 'updateJobExecution_includeJobExecutionState' - Optional. When included and set to true, the response contains the
-- JobExecutionState data. The default is false.
--
-- 'jobId', 'updateJobExecution_jobId' - The unique identifier assigned to this job when it was created.
--
-- 'thingName', 'updateJobExecution_thingName' - The name of the thing associated with the device.
--
-- 'status', 'updateJobExecution_status' - The new status for the job execution (IN_PROGRESS, FAILED, SUCCESS, or
-- REJECTED). This must be specified on every update.
newUpdateJobExecution ::
  -- | 'jobId'
  Prelude.Text ->
  -- | 'thingName'
  Prelude.Text ->
  -- | 'status'
  JobExecutionStatus ->
  UpdateJobExecution
newUpdateJobExecution :: Text -> Text -> JobExecutionStatus -> UpdateJobExecution
newUpdateJobExecution Text
pJobId_ Text
pThingName_ JobExecutionStatus
pStatus_ =
  UpdateJobExecution' :: Maybe Bool
-> Maybe Integer
-> Maybe (HashMap Text Text)
-> Maybe Integer
-> Maybe Integer
-> Maybe Bool
-> Text
-> Text
-> JobExecutionStatus
-> UpdateJobExecution
UpdateJobExecution'
    { $sel:includeJobDocument:UpdateJobExecution' :: Maybe Bool
includeJobDocument =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:stepTimeoutInMinutes:UpdateJobExecution' :: Maybe Integer
stepTimeoutInMinutes = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:statusDetails:UpdateJobExecution' :: Maybe (HashMap Text Text)
statusDetails = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:executionNumber:UpdateJobExecution' :: Maybe Integer
executionNumber = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:expectedVersion:UpdateJobExecution' :: Maybe Integer
expectedVersion = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:includeJobExecutionState:UpdateJobExecution' :: Maybe Bool
includeJobExecutionState = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:jobId:UpdateJobExecution' :: Text
jobId = Text
pJobId_,
      $sel:thingName:UpdateJobExecution' :: Text
thingName = Text
pThingName_,
      $sel:status:UpdateJobExecution' :: JobExecutionStatus
status = JobExecutionStatus
pStatus_
    }

-- | Optional. When set to true, the response contains the job document. The
-- default is false.
updateJobExecution_includeJobDocument :: Lens.Lens' UpdateJobExecution (Prelude.Maybe Prelude.Bool)
updateJobExecution_includeJobDocument :: (Maybe Bool -> f (Maybe Bool))
-> UpdateJobExecution -> f UpdateJobExecution
updateJobExecution_includeJobDocument = (UpdateJobExecution -> Maybe Bool)
-> (UpdateJobExecution -> Maybe Bool -> UpdateJobExecution)
-> Lens
     UpdateJobExecution UpdateJobExecution (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJobExecution' {Maybe Bool
includeJobDocument :: Maybe Bool
$sel:includeJobDocument:UpdateJobExecution' :: UpdateJobExecution -> Maybe Bool
includeJobDocument} -> Maybe Bool
includeJobDocument) (\s :: UpdateJobExecution
s@UpdateJobExecution' {} Maybe Bool
a -> UpdateJobExecution
s {$sel:includeJobDocument:UpdateJobExecution' :: Maybe Bool
includeJobDocument = Maybe Bool
a} :: UpdateJobExecution)

-- | Specifies the amount of time this device has to finish execution of this
-- job. If the job execution status is not set to a terminal state before
-- this timer expires, or before the timer is reset (by again calling
-- @UpdateJobExecution@, setting the status to @IN_PROGRESS@ and specifying
-- a new timeout value in this field) the job execution status will be
-- automatically set to @TIMED_OUT@. Note that setting or resetting this
-- timeout has no effect on that job execution timeout which may have been
-- specified when the job was created (@CreateJob@ using field
-- @timeoutConfig@).
updateJobExecution_stepTimeoutInMinutes :: Lens.Lens' UpdateJobExecution (Prelude.Maybe Prelude.Integer)
updateJobExecution_stepTimeoutInMinutes :: (Maybe Integer -> f (Maybe Integer))
-> UpdateJobExecution -> f UpdateJobExecution
updateJobExecution_stepTimeoutInMinutes = (UpdateJobExecution -> Maybe Integer)
-> (UpdateJobExecution -> Maybe Integer -> UpdateJobExecution)
-> Lens
     UpdateJobExecution
     UpdateJobExecution
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJobExecution' {Maybe Integer
stepTimeoutInMinutes :: Maybe Integer
$sel:stepTimeoutInMinutes:UpdateJobExecution' :: UpdateJobExecution -> Maybe Integer
stepTimeoutInMinutes} -> Maybe Integer
stepTimeoutInMinutes) (\s :: UpdateJobExecution
s@UpdateJobExecution' {} Maybe Integer
a -> UpdateJobExecution
s {$sel:stepTimeoutInMinutes:UpdateJobExecution' :: Maybe Integer
stepTimeoutInMinutes = Maybe Integer
a} :: UpdateJobExecution)

-- | Optional. A collection of name\/value pairs that describe the status of
-- the job execution. If not specified, the statusDetails are unchanged.
updateJobExecution_statusDetails :: Lens.Lens' UpdateJobExecution (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
updateJobExecution_statusDetails :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> UpdateJobExecution -> f UpdateJobExecution
updateJobExecution_statusDetails = (UpdateJobExecution -> Maybe (HashMap Text Text))
-> (UpdateJobExecution
    -> Maybe (HashMap Text Text) -> UpdateJobExecution)
-> Lens
     UpdateJobExecution
     UpdateJobExecution
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJobExecution' {Maybe (HashMap Text Text)
statusDetails :: Maybe (HashMap Text Text)
$sel:statusDetails:UpdateJobExecution' :: UpdateJobExecution -> Maybe (HashMap Text Text)
statusDetails} -> Maybe (HashMap Text Text)
statusDetails) (\s :: UpdateJobExecution
s@UpdateJobExecution' {} Maybe (HashMap Text Text)
a -> UpdateJobExecution
s {$sel:statusDetails:UpdateJobExecution' :: Maybe (HashMap Text Text)
statusDetails = Maybe (HashMap Text Text)
a} :: UpdateJobExecution) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> UpdateJobExecution -> f UpdateJobExecution)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> UpdateJobExecution
-> f UpdateJobExecution
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Optional. A number that identifies a particular job execution on a
-- particular device.
updateJobExecution_executionNumber :: Lens.Lens' UpdateJobExecution (Prelude.Maybe Prelude.Integer)
updateJobExecution_executionNumber :: (Maybe Integer -> f (Maybe Integer))
-> UpdateJobExecution -> f UpdateJobExecution
updateJobExecution_executionNumber = (UpdateJobExecution -> Maybe Integer)
-> (UpdateJobExecution -> Maybe Integer -> UpdateJobExecution)
-> Lens
     UpdateJobExecution
     UpdateJobExecution
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJobExecution' {Maybe Integer
executionNumber :: Maybe Integer
$sel:executionNumber:UpdateJobExecution' :: UpdateJobExecution -> Maybe Integer
executionNumber} -> Maybe Integer
executionNumber) (\s :: UpdateJobExecution
s@UpdateJobExecution' {} Maybe Integer
a -> UpdateJobExecution
s {$sel:executionNumber:UpdateJobExecution' :: Maybe Integer
executionNumber = Maybe Integer
a} :: UpdateJobExecution)

-- | Optional. The expected current version of the job execution. Each time
-- you update the job execution, its version is incremented. If the version
-- of the job execution stored in Jobs does not match, the update is
-- rejected with a VersionMismatch error, and an ErrorResponse that
-- contains the current job execution status data is returned. (This makes
-- it unnecessary to perform a separate DescribeJobExecution request in
-- order to obtain the job execution status data.)
updateJobExecution_expectedVersion :: Lens.Lens' UpdateJobExecution (Prelude.Maybe Prelude.Integer)
updateJobExecution_expectedVersion :: (Maybe Integer -> f (Maybe Integer))
-> UpdateJobExecution -> f UpdateJobExecution
updateJobExecution_expectedVersion = (UpdateJobExecution -> Maybe Integer)
-> (UpdateJobExecution -> Maybe Integer -> UpdateJobExecution)
-> Lens
     UpdateJobExecution
     UpdateJobExecution
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJobExecution' {Maybe Integer
expectedVersion :: Maybe Integer
$sel:expectedVersion:UpdateJobExecution' :: UpdateJobExecution -> Maybe Integer
expectedVersion} -> Maybe Integer
expectedVersion) (\s :: UpdateJobExecution
s@UpdateJobExecution' {} Maybe Integer
a -> UpdateJobExecution
s {$sel:expectedVersion:UpdateJobExecution' :: Maybe Integer
expectedVersion = Maybe Integer
a} :: UpdateJobExecution)

-- | Optional. When included and set to true, the response contains the
-- JobExecutionState data. The default is false.
updateJobExecution_includeJobExecutionState :: Lens.Lens' UpdateJobExecution (Prelude.Maybe Prelude.Bool)
updateJobExecution_includeJobExecutionState :: (Maybe Bool -> f (Maybe Bool))
-> UpdateJobExecution -> f UpdateJobExecution
updateJobExecution_includeJobExecutionState = (UpdateJobExecution -> Maybe Bool)
-> (UpdateJobExecution -> Maybe Bool -> UpdateJobExecution)
-> Lens
     UpdateJobExecution UpdateJobExecution (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJobExecution' {Maybe Bool
includeJobExecutionState :: Maybe Bool
$sel:includeJobExecutionState:UpdateJobExecution' :: UpdateJobExecution -> Maybe Bool
includeJobExecutionState} -> Maybe Bool
includeJobExecutionState) (\s :: UpdateJobExecution
s@UpdateJobExecution' {} Maybe Bool
a -> UpdateJobExecution
s {$sel:includeJobExecutionState:UpdateJobExecution' :: Maybe Bool
includeJobExecutionState = Maybe Bool
a} :: UpdateJobExecution)

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

-- | The name of the thing associated with the device.
updateJobExecution_thingName :: Lens.Lens' UpdateJobExecution Prelude.Text
updateJobExecution_thingName :: (Text -> f Text) -> UpdateJobExecution -> f UpdateJobExecution
updateJobExecution_thingName = (UpdateJobExecution -> Text)
-> (UpdateJobExecution -> Text -> UpdateJobExecution)
-> Lens UpdateJobExecution UpdateJobExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJobExecution' {Text
thingName :: Text
$sel:thingName:UpdateJobExecution' :: UpdateJobExecution -> Text
thingName} -> Text
thingName) (\s :: UpdateJobExecution
s@UpdateJobExecution' {} Text
a -> UpdateJobExecution
s {$sel:thingName:UpdateJobExecution' :: Text
thingName = Text
a} :: UpdateJobExecution)

-- | The new status for the job execution (IN_PROGRESS, FAILED, SUCCESS, or
-- REJECTED). This must be specified on every update.
updateJobExecution_status :: Lens.Lens' UpdateJobExecution JobExecutionStatus
updateJobExecution_status :: (JobExecutionStatus -> f JobExecutionStatus)
-> UpdateJobExecution -> f UpdateJobExecution
updateJobExecution_status = (UpdateJobExecution -> JobExecutionStatus)
-> (UpdateJobExecution -> JobExecutionStatus -> UpdateJobExecution)
-> Lens
     UpdateJobExecution
     UpdateJobExecution
     JobExecutionStatus
     JobExecutionStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJobExecution' {JobExecutionStatus
status :: JobExecutionStatus
$sel:status:UpdateJobExecution' :: UpdateJobExecution -> JobExecutionStatus
status} -> JobExecutionStatus
status) (\s :: UpdateJobExecution
s@UpdateJobExecution' {} JobExecutionStatus
a -> UpdateJobExecution
s {$sel:status:UpdateJobExecution' :: JobExecutionStatus
status = JobExecutionStatus
a} :: UpdateJobExecution)

instance Core.AWSRequest UpdateJobExecution where
  type
    AWSResponse UpdateJobExecution =
      UpdateJobExecutionResponse
  request :: UpdateJobExecution -> Request UpdateJobExecution
request = Service -> UpdateJobExecution -> Request UpdateJobExecution
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateJobExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateJobExecution)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateJobExecution))
-> Logger
-> Service
-> Proxy UpdateJobExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateJobExecution)))
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
-> Maybe JobExecutionState -> Int -> UpdateJobExecutionResponse
UpdateJobExecutionResponse'
            (Maybe Text
 -> Maybe JobExecutionState -> Int -> UpdateJobExecutionResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe JobExecutionState -> Int -> UpdateJobExecutionResponse)
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
"jobDocument")
            Either
  String
  (Maybe JobExecutionState -> Int -> UpdateJobExecutionResponse)
-> Either String (Maybe JobExecutionState)
-> Either String (Int -> UpdateJobExecutionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe JobExecutionState)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"executionState")
            Either String (Int -> UpdateJobExecutionResponse)
-> Either String Int -> Either String UpdateJobExecutionResponse
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 UpdateJobExecution

instance Prelude.NFData UpdateJobExecution

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

instance Core.ToJSON UpdateJobExecution where
  toJSON :: UpdateJobExecution -> Value
toJSON UpdateJobExecution' {Maybe Bool
Maybe Integer
Maybe (HashMap Text Text)
Text
JobExecutionStatus
status :: JobExecutionStatus
thingName :: Text
jobId :: Text
includeJobExecutionState :: Maybe Bool
expectedVersion :: Maybe Integer
executionNumber :: Maybe Integer
statusDetails :: Maybe (HashMap Text Text)
stepTimeoutInMinutes :: Maybe Integer
includeJobDocument :: Maybe Bool
$sel:status:UpdateJobExecution' :: UpdateJobExecution -> JobExecutionStatus
$sel:thingName:UpdateJobExecution' :: UpdateJobExecution -> Text
$sel:jobId:UpdateJobExecution' :: UpdateJobExecution -> Text
$sel:includeJobExecutionState:UpdateJobExecution' :: UpdateJobExecution -> Maybe Bool
$sel:expectedVersion:UpdateJobExecution' :: UpdateJobExecution -> Maybe Integer
$sel:executionNumber:UpdateJobExecution' :: UpdateJobExecution -> Maybe Integer
$sel:statusDetails:UpdateJobExecution' :: UpdateJobExecution -> Maybe (HashMap Text Text)
$sel:stepTimeoutInMinutes:UpdateJobExecution' :: UpdateJobExecution -> Maybe Integer
$sel:includeJobDocument:UpdateJobExecution' :: UpdateJobExecution -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"includeJobDocument" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeJobDocument,
            (Text
"stepTimeoutInMinutes" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
stepTimeoutInMinutes,
            (Text
"statusDetails" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
statusDetails,
            (Text
"executionNumber" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
executionNumber,
            (Text
"expectedVersion" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
expectedVersion,
            (Text
"includeJobExecutionState" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeJobExecutionState,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"status" Text -> JobExecutionStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= JobExecutionStatus
status)
          ]
      )

instance Core.ToPath UpdateJobExecution where
  toPath :: UpdateJobExecution -> ByteString
toPath UpdateJobExecution' {Maybe Bool
Maybe Integer
Maybe (HashMap Text Text)
Text
JobExecutionStatus
status :: JobExecutionStatus
thingName :: Text
jobId :: Text
includeJobExecutionState :: Maybe Bool
expectedVersion :: Maybe Integer
executionNumber :: Maybe Integer
statusDetails :: Maybe (HashMap Text Text)
stepTimeoutInMinutes :: Maybe Integer
includeJobDocument :: Maybe Bool
$sel:status:UpdateJobExecution' :: UpdateJobExecution -> JobExecutionStatus
$sel:thingName:UpdateJobExecution' :: UpdateJobExecution -> Text
$sel:jobId:UpdateJobExecution' :: UpdateJobExecution -> Text
$sel:includeJobExecutionState:UpdateJobExecution' :: UpdateJobExecution -> Maybe Bool
$sel:expectedVersion:UpdateJobExecution' :: UpdateJobExecution -> Maybe Integer
$sel:executionNumber:UpdateJobExecution' :: UpdateJobExecution -> Maybe Integer
$sel:statusDetails:UpdateJobExecution' :: UpdateJobExecution -> Maybe (HashMap Text Text)
$sel:stepTimeoutInMinutes:UpdateJobExecution' :: UpdateJobExecution -> Maybe Integer
$sel:includeJobDocument:UpdateJobExecution' :: UpdateJobExecution -> Maybe Bool
..} =
    [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 UpdateJobExecution where
  toQuery :: UpdateJobExecution -> QueryString
toQuery = QueryString -> UpdateJobExecution -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateJobExecutionResponse' smart constructor.
data UpdateJobExecutionResponse = UpdateJobExecutionResponse'
  { -- | The contents of the Job Documents.
    UpdateJobExecutionResponse -> Maybe Text
jobDocument :: Prelude.Maybe Prelude.Text,
    -- | A JobExecutionState object.
    UpdateJobExecutionResponse -> Maybe JobExecutionState
executionState :: Prelude.Maybe JobExecutionState,
    -- | The response's http status code.
    UpdateJobExecutionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateJobExecutionResponse -> UpdateJobExecutionResponse -> Bool
(UpdateJobExecutionResponse -> UpdateJobExecutionResponse -> Bool)
-> (UpdateJobExecutionResponse
    -> UpdateJobExecutionResponse -> Bool)
-> Eq UpdateJobExecutionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateJobExecutionResponse -> UpdateJobExecutionResponse -> Bool
$c/= :: UpdateJobExecutionResponse -> UpdateJobExecutionResponse -> Bool
== :: UpdateJobExecutionResponse -> UpdateJobExecutionResponse -> Bool
$c== :: UpdateJobExecutionResponse -> UpdateJobExecutionResponse -> Bool
Prelude.Eq, ReadPrec [UpdateJobExecutionResponse]
ReadPrec UpdateJobExecutionResponse
Int -> ReadS UpdateJobExecutionResponse
ReadS [UpdateJobExecutionResponse]
(Int -> ReadS UpdateJobExecutionResponse)
-> ReadS [UpdateJobExecutionResponse]
-> ReadPrec UpdateJobExecutionResponse
-> ReadPrec [UpdateJobExecutionResponse]
-> Read UpdateJobExecutionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateJobExecutionResponse]
$creadListPrec :: ReadPrec [UpdateJobExecutionResponse]
readPrec :: ReadPrec UpdateJobExecutionResponse
$creadPrec :: ReadPrec UpdateJobExecutionResponse
readList :: ReadS [UpdateJobExecutionResponse]
$creadList :: ReadS [UpdateJobExecutionResponse]
readsPrec :: Int -> ReadS UpdateJobExecutionResponse
$creadsPrec :: Int -> ReadS UpdateJobExecutionResponse
Prelude.Read, Int -> UpdateJobExecutionResponse -> ShowS
[UpdateJobExecutionResponse] -> ShowS
UpdateJobExecutionResponse -> String
(Int -> UpdateJobExecutionResponse -> ShowS)
-> (UpdateJobExecutionResponse -> String)
-> ([UpdateJobExecutionResponse] -> ShowS)
-> Show UpdateJobExecutionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateJobExecutionResponse] -> ShowS
$cshowList :: [UpdateJobExecutionResponse] -> ShowS
show :: UpdateJobExecutionResponse -> String
$cshow :: UpdateJobExecutionResponse -> String
showsPrec :: Int -> UpdateJobExecutionResponse -> ShowS
$cshowsPrec :: Int -> UpdateJobExecutionResponse -> ShowS
Prelude.Show, (forall x.
 UpdateJobExecutionResponse -> Rep UpdateJobExecutionResponse x)
-> (forall x.
    Rep UpdateJobExecutionResponse x -> UpdateJobExecutionResponse)
-> Generic UpdateJobExecutionResponse
forall x.
Rep UpdateJobExecutionResponse x -> UpdateJobExecutionResponse
forall x.
UpdateJobExecutionResponse -> Rep UpdateJobExecutionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateJobExecutionResponse x -> UpdateJobExecutionResponse
$cfrom :: forall x.
UpdateJobExecutionResponse -> Rep UpdateJobExecutionResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateJobExecutionResponse' 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:
--
-- 'jobDocument', 'updateJobExecutionResponse_jobDocument' - The contents of the Job Documents.
--
-- 'executionState', 'updateJobExecutionResponse_executionState' - A JobExecutionState object.
--
-- 'httpStatus', 'updateJobExecutionResponse_httpStatus' - The response's http status code.
newUpdateJobExecutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateJobExecutionResponse
newUpdateJobExecutionResponse :: Int -> UpdateJobExecutionResponse
newUpdateJobExecutionResponse Int
pHttpStatus_ =
  UpdateJobExecutionResponse' :: Maybe Text
-> Maybe JobExecutionState -> Int -> UpdateJobExecutionResponse
UpdateJobExecutionResponse'
    { $sel:jobDocument:UpdateJobExecutionResponse' :: Maybe Text
jobDocument =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:executionState:UpdateJobExecutionResponse' :: Maybe JobExecutionState
executionState = Maybe JobExecutionState
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateJobExecutionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The contents of the Job Documents.
updateJobExecutionResponse_jobDocument :: Lens.Lens' UpdateJobExecutionResponse (Prelude.Maybe Prelude.Text)
updateJobExecutionResponse_jobDocument :: (Maybe Text -> f (Maybe Text))
-> UpdateJobExecutionResponse -> f UpdateJobExecutionResponse
updateJobExecutionResponse_jobDocument = (UpdateJobExecutionResponse -> Maybe Text)
-> (UpdateJobExecutionResponse
    -> Maybe Text -> UpdateJobExecutionResponse)
-> Lens
     UpdateJobExecutionResponse
     UpdateJobExecutionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJobExecutionResponse' {Maybe Text
jobDocument :: Maybe Text
$sel:jobDocument:UpdateJobExecutionResponse' :: UpdateJobExecutionResponse -> Maybe Text
jobDocument} -> Maybe Text
jobDocument) (\s :: UpdateJobExecutionResponse
s@UpdateJobExecutionResponse' {} Maybe Text
a -> UpdateJobExecutionResponse
s {$sel:jobDocument:UpdateJobExecutionResponse' :: Maybe Text
jobDocument = Maybe Text
a} :: UpdateJobExecutionResponse)

-- | A JobExecutionState object.
updateJobExecutionResponse_executionState :: Lens.Lens' UpdateJobExecutionResponse (Prelude.Maybe JobExecutionState)
updateJobExecutionResponse_executionState :: (Maybe JobExecutionState -> f (Maybe JobExecutionState))
-> UpdateJobExecutionResponse -> f UpdateJobExecutionResponse
updateJobExecutionResponse_executionState = (UpdateJobExecutionResponse -> Maybe JobExecutionState)
-> (UpdateJobExecutionResponse
    -> Maybe JobExecutionState -> UpdateJobExecutionResponse)
-> Lens
     UpdateJobExecutionResponse
     UpdateJobExecutionResponse
     (Maybe JobExecutionState)
     (Maybe JobExecutionState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJobExecutionResponse' {Maybe JobExecutionState
executionState :: Maybe JobExecutionState
$sel:executionState:UpdateJobExecutionResponse' :: UpdateJobExecutionResponse -> Maybe JobExecutionState
executionState} -> Maybe JobExecutionState
executionState) (\s :: UpdateJobExecutionResponse
s@UpdateJobExecutionResponse' {} Maybe JobExecutionState
a -> UpdateJobExecutionResponse
s {$sel:executionState:UpdateJobExecutionResponse' :: Maybe JobExecutionState
executionState = Maybe JobExecutionState
a} :: UpdateJobExecutionResponse)

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

instance Prelude.NFData UpdateJobExecutionResponse