Amazon IoT Jobs SDK release examples using Amazon CLI - Amazon Command Line Interface
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

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 and cross-service examples.

Scenarios are code examples that show you how to accomplish a specific task by calling multiple functions within the same service.

Each example includes a link to GitHub, 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-name MotionSensor1 \ --endpoint-url https://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.

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-url https://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.

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-url https://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.

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-name MotionSensor1 \ --status REMOVED \ --endpoint-url https://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.