This documentation is for Version 1 of the AWS CLI only. For documentation related to Version 2 of the AWS CLI, see the Version 2 User Guide.
AWS IoT Jobs SDK release examples using AWS CLI
The following code examples show you how to perform actions and implement common scenarios by using the AWS Command Line Interface with AWS IoT Jobs SDK release.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use describe-job-execution
.
- AWS CLI
-
To get the details of a job execution
The following
describe-job-execution
example retrieves the details of the latest execution of the specified job and thing.aws iot-jobs-data describe-job-execution \ --job-id
SampleJob
\ --thing-nameMotionSensor1
\ --endpoint-urlhttps://1234567890abcd.jobs.iot.us-west-2.amazonaws.com
Output:
{ "execution": { "approximateSecondsBeforeTimedOut": 88, "executionNumber": 2939653338, "jobId": "SampleJob", "lastUpdatedAt": 1567701875.743, "queuedAt": 1567701902.444, "status": "QUEUED", "thingName": "MotionSensor1 ", "versionNumber": 3 } }
For more information, see Devices and Jobs in the AWS IoT Developer Guide.
-
For API details, see DescribeJobExecution
in AWS CLI Command Reference.
-
The following code example shows how to use get-pending-job-executions
.
- AWS CLI
-
To get a list of all jobs that are not in a terminal status for a thing
The following
get-pending-job-executions
example displays a list of all jobs that aren't in a terminal state for the specified thing.aws iot-jobs-data get-pending-job-executions \ --thing-name
MotionSensor1
--endpoint-urlhttps://1234567890abcd.jobs.iot.us-west-2.amazonaws.com
Output:
{ "inProgressJobs": [ ], "queuedJobs": [ { "executionNumber": 2939653338, "jobId": "SampleJob", "lastUpdatedAt": 1567701875.743, "queuedAt": 1567701902.444, "versionNumber": 3 } ] }
For more information, see Devices and Jobs in the AWS IoT Developer Guide.
-
For API details, see GetPendingJobExecutions
in AWS CLI Command Reference.
-
The following code example shows how to use start-next-pending-job-execution
.
- AWS CLI
-
To get and start the next pending job execution for a thing
The following
start-next-pending-job-execution
example retrieves and starts the next job execution whose status is IN_PROGRESS or QUEUED for the specified thing.aws iot-jobs-data start-next-pending-job-execution \ --thing-name
MotionSensor1
--endpoint-urlhttps://1234567890abcd.jobs.iot.us-west-2.amazonaws.com
Output:
{ "execution": { "approximateSecondsBeforeTimedOut": 88, "executionNumber": 2939653338, "jobId": "SampleJob", "lastUpdatedAt": 1567714853.743, "queuedAt": 1567701902.444, "startedAt": 1567714871.690, "status": "IN_PROGRESS", "thingName": "MotionSensor1 ", "versionNumber": 3 } }
For more information, see Devices and Jobs in the AWS IoT Developer Guide.
-
For API details, see StartNextPendingJobExecution
in AWS CLI Command Reference.
-
The following code example shows how to use update-job-execution
.
- AWS CLI
-
To update the status of a job execution
The following
update-job-execution
example updates the status of the specified job and thing.aws iot-jobs-data update-job-execution \ --job-id
SampleJob
\ --thing-nameMotionSensor1
\ --statusREMOVED
\ --endpoint-urlhttps://1234567890abcd.jobs.iot.us-west-2.amazonaws.com
Output:
{ "executionState": { "status": "REMOVED", "versionNumber": 3 }, }
For more information, see Devices and Jobs in the AWS IoT Developer Guide.
-
For API details, see UpdateJobExecution
in AWS CLI Command Reference.
-