Table of Contents
A low-level client representing AWS IoT Jobs Data Plane
AWS IoT Jobs is a service that allows you to define a set of jobs — remote operations that are sent to and executed on one or more devices connected to AWS IoT. For example, you can define a job that instructs a set of devices to download and install application or firmware updates, reboot, rotate certificates, or perform remote troubleshooting operations.
To create a job, you make a job document which is a description of the remote operations to be performed, and you specify a list of targets that should perform the operations. The targets can be individual things, thing groups or both.
AWS IoT Jobs sends a message to inform the targets that a job is available. The target starts the execution of the job by downloading the job document, performing the operations it specifies, and reporting its progress to AWS IoT. The Jobs service provides commands to track the progress of a job on a specific target and for all the targets of the job
client = session.create_client('iot-jobs-data')
These are the available methods:
Check if an operation can be paginated.
Gets details of a job execution.
See also: AWS API Documentation
Request Syntax
response = client.describe_job_execution(
jobId='string',
thingName='string',
includeJobDocument=True|False,
executionNumber=123
)
[REQUIRED]
The unique identifier assigned to this job when it was created.
[REQUIRED]
The thing name associated with the device the job execution is running on.
dict
Response Syntax
{
'execution': {
'jobId': 'string',
'thingName': 'string',
'status': 'QUEUED'|'IN_PROGRESS'|'SUCCEEDED'|'FAILED'|'TIMED_OUT'|'REJECTED'|'REMOVED'|'CANCELED',
'statusDetails': {
'string': 'string'
},
'queuedAt': 123,
'startedAt': 123,
'lastUpdatedAt': 123,
'approximateSecondsBeforeTimedOut': 123,
'versionNumber': 123,
'executionNumber': 123,
'jobDocument': 'string'
}
}
Response Structure
(dict) --
execution (dict) --
Contains data about a job execution.
jobId (string) --
The unique identifier you assigned to this job when it was created.
thingName (string) --
The name of the thing that is executing the job.
status (string) --
The status of the job execution. Can be one of: "QUEUED", "IN_PROGRESS", "FAILED", "SUCCESS", "CANCELED", "REJECTED", or "REMOVED".
statusDetails (dict) --
A collection of name/value pairs that describe the status of the job execution.
queuedAt (integer) --
The time, in milliseconds since the epoch, when the job execution was enqueued.
startedAt (integer) --
The time, in milliseconds since the epoch, when the job execution was started.
lastUpdatedAt (integer) --
The time, in milliseconds since the epoch, when the job execution was last updated.
approximateSecondsBeforeTimedOut (integer) --
The estimated number of seconds that remain before the job execution status will be changed to TIMED_OUT .
versionNumber (integer) --
The version of the job execution. Job execution versions are incremented each time they are updated by a device.
executionNumber (integer) --
A number that identifies a particular job execution on a particular device. It can be used later in commands that return or update job execution information.
jobDocument (string) --
The content of the job document.
Exceptions
Generate a presigned url given a client, its method, and arguments
The presigned url
Create a paginator for an operation.
Gets the list of all jobs for a thing that are not in a terminal status.
See also: AWS API Documentation
Request Syntax
response = client.get_pending_job_executions(
thingName='string'
)
[REQUIRED]
The name of the thing that is executing the job.
{
'inProgressJobs': [
{
'jobId': 'string',
'queuedAt': 123,
'startedAt': 123,
'lastUpdatedAt': 123,
'versionNumber': 123,
'executionNumber': 123
},
],
'queuedJobs': [
{
'jobId': 'string',
'queuedAt': 123,
'startedAt': 123,
'lastUpdatedAt': 123,
'versionNumber': 123,
'executionNumber': 123
},
]
}
Response Structure
A list of JobExecutionSummary objects with status IN_PROGRESS.
Contains a subset of information about a job execution.
The unique identifier you assigned to this job when it was created.
The time, in milliseconds since the epoch, when the job execution was enqueued.
The time, in milliseconds since the epoch, when the job execution started.
The time, in milliseconds since the epoch, when the job execution was last updated.
The version of the job execution. Job execution versions are incremented each time AWS IoT Jobs receives an update from a device.
A number that identifies a particular job execution on a particular device.
A list of JobExecutionSummary objects with status QUEUED.
Contains a subset of information about a job execution.
The unique identifier you assigned to this job when it was created.
The time, in milliseconds since the epoch, when the job execution was enqueued.
The time, in milliseconds since the epoch, when the job execution started.
The time, in milliseconds since the epoch, when the job execution was last updated.
The version of the job execution. Job execution versions are incremented each time AWS IoT Jobs receives an update from a device.
A number that identifies a particular job execution on a particular device.
Exceptions
Returns an object that can wait for some condition.
Gets and starts the next pending (status IN_PROGRESS or QUEUED) job execution for a thing.
See also: AWS API Documentation
Request Syntax
response = client.start_next_pending_job_execution(
thingName='string',
statusDetails={
'string': 'string'
},
stepTimeoutInMinutes=123
)
[REQUIRED]
The name of the thing associated with the device.
A collection of name/value pairs that describe the status of the job execution. If not specified, the statusDetails are unchanged.
dict
Response Syntax
{
'execution': {
'jobId': 'string',
'thingName': 'string',
'status': 'QUEUED'|'IN_PROGRESS'|'SUCCEEDED'|'FAILED'|'TIMED_OUT'|'REJECTED'|'REMOVED'|'CANCELED',
'statusDetails': {
'string': 'string'
},
'queuedAt': 123,
'startedAt': 123,
'lastUpdatedAt': 123,
'approximateSecondsBeforeTimedOut': 123,
'versionNumber': 123,
'executionNumber': 123,
'jobDocument': 'string'
}
}
Response Structure
(dict) --
execution (dict) --
A JobExecution object.
jobId (string) --
The unique identifier you assigned to this job when it was created.
thingName (string) --
The name of the thing that is executing the job.
status (string) --
The status of the job execution. Can be one of: "QUEUED", "IN_PROGRESS", "FAILED", "SUCCESS", "CANCELED", "REJECTED", or "REMOVED".
statusDetails (dict) --
A collection of name/value pairs that describe the status of the job execution.
queuedAt (integer) --
The time, in milliseconds since the epoch, when the job execution was enqueued.
startedAt (integer) --
The time, in milliseconds since the epoch, when the job execution was started.
lastUpdatedAt (integer) --
The time, in milliseconds since the epoch, when the job execution was last updated.
approximateSecondsBeforeTimedOut (integer) --
The estimated number of seconds that remain before the job execution status will be changed to TIMED_OUT .
versionNumber (integer) --
The version of the job execution. Job execution versions are incremented each time they are updated by a device.
executionNumber (integer) --
A number that identifies a particular job execution on a particular device. It can be used later in commands that return or update job execution information.
jobDocument (string) --
The content of the job document.
Exceptions
Updates the status of a job execution.
See also: AWS API Documentation
Request Syntax
response = client.update_job_execution(
jobId='string',
thingName='string',
status='QUEUED'|'IN_PROGRESS'|'SUCCEEDED'|'FAILED'|'TIMED_OUT'|'REJECTED'|'REMOVED'|'CANCELED',
statusDetails={
'string': 'string'
},
stepTimeoutInMinutes=123,
expectedVersion=123,
includeJobExecutionState=True|False,
includeJobDocument=True|False,
executionNumber=123
)
[REQUIRED]
The unique identifier assigned to this job when it was created.
[REQUIRED]
The name of the thing associated with the device.
[REQUIRED]
The new status for the job execution (IN_PROGRESS, FAILED, SUCCESS, or REJECTED). This must be specified on every update.
Optional. A collection of name/value pairs that describe the status of the job execution. If not specified, the statusDetails are unchanged.
dict
Response Syntax
{
'executionState': {
'status': 'QUEUED'|'IN_PROGRESS'|'SUCCEEDED'|'FAILED'|'TIMED_OUT'|'REJECTED'|'REMOVED'|'CANCELED',
'statusDetails': {
'string': 'string'
},
'versionNumber': 123
},
'jobDocument': 'string'
}
Response Structure
(dict) --
executionState (dict) --
A JobExecutionState object.
status (string) --
The status of the job execution. Can be one of: "QUEUED", "IN_PROGRESS", "FAILED", "SUCCESS", "CANCELED", "REJECTED", or "REMOVED".
statusDetails (dict) --
A collection of name/value pairs that describe the status of the job execution.
versionNumber (integer) --
The version of the job execution. Job execution versions are incremented each time they are updated by a device.
jobDocument (string) --
The contents of the Job Documents.
Exceptions
Client exceptions are available on a client instance via the exceptions property. For more detailed instructions and examples on the exact usage of client exceptions, see the error handling user guide.
The available client exceptions are:
The certificate is invalid.
Example
try:
...
except client.exceptions.CertificateValidationException as e:
print(e.response)
The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) --
The certificate is invalid.
message (string) --
Additional information about the exception.
Error (dict) -- Normalized access to common exception attributes.
The contents of the request were invalid. For example, this code is returned when an UpdateJobExecution request contains invalid status details. The message contains details about the error.
Example
try:
...
except client.exceptions.InvalidRequestException as e:
print(e.response)
The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) --
The contents of the request were invalid. For example, this code is returned when an UpdateJobExecution request contains invalid status details. The message contains details about the error.
message (string) --
The message for the exception.
Error (dict) -- Normalized access to common exception attributes.
An update attempted to change the job execution to a state that is invalid because of the job execution's current state (for example, an attempt to change a request in state SUCCESS to state IN_PROGRESS). In this case, the body of the error message also contains the executionState field.
Example
try:
...
except client.exceptions.InvalidStateTransitionException as e:
print(e.response)
The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) --
An update attempted to change the job execution to a state that is invalid because of the job execution's current state (for example, an attempt to change a request in state SUCCESS to state IN_PROGRESS). In this case, the body of the error message also contains the executionState field.
The specified resource does not exist.
Example
try:
...
except client.exceptions.ResourceNotFoundException as e:
print(e.response)
The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) --
The specified resource does not exist.
message (string) --
The message for the exception.
Error (dict) -- Normalized access to common exception attributes.
The service is temporarily unavailable.
Example
try:
...
except client.exceptions.ServiceUnavailableException as e:
print(e.response)
The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) --
The service is temporarily unavailable.
message (string) --
The message for the exception.
Error (dict) -- Normalized access to common exception attributes.
The job is in a terminal state.
Example
try:
...
except client.exceptions.TerminalStateException as e:
print(e.response)
The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) --
The job is in a terminal state.
The rate exceeds the limit.
Example
try:
...
except client.exceptions.ThrottlingException as e:
print(e.response)
The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'message': 'string',
'payload': b'bytes',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) --
The rate exceeds the limit.
message (string) --
The message associated with the exception.
payload (bytes) --
The payload associated with the exception.
Error (dict) -- Normalized access to common exception attributes.
The available paginators are: