This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.
Amazon IoT Jobs SDK release examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with Amazon 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
.
- Amazon 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 Amazon IoT Developer Guide. -
For API details, see DescribeJobExecution
in Amazon CLI Command Reference.
-
The following code example shows how to use get-pending-job-executions
.
- Amazon 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 Amazon IoT Developer Guide. -
For API details, see GetPendingJobExecutions
in Amazon CLI Command Reference.
-
The following code example shows how to use start-next-pending-job-execution
.
- Amazon 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 Amazon IoT Developer Guide. -
For API details, see StartNextPendingJobExecution
in Amazon CLI Command Reference.
-
The following code example shows how to use update-job-execution
.
- Amazon 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 Amazon IoT Developer Guide. -
For API details, see UpdateJobExecution
in Amazon CLI Command Reference.
-