createJob method
- required String jobId,
- required List<
String> targets, - AbortConfig? abortConfig,
- String? description,
- List<
String> ? destinationPackageVersions, - String? document,
- Map<
String, String> ? documentParameters, - String? documentSource,
- JobExecutionsRetryConfig? jobExecutionsRetryConfig,
- JobExecutionsRolloutConfig? jobExecutionsRolloutConfig,
- String? jobTemplateArn,
- String? namespaceId,
- PresignedUrlConfig? presignedUrlConfig,
- SchedulingConfig? schedulingConfig,
- List<
Tag> ? tags, - TargetSelection? targetSelection,
- TimeoutConfig? timeoutConfig,
Creates a job.
Requires permission to access the CreateJob action.
May throw InvalidRequestException.
May throw LimitExceededException.
May throw ResourceAlreadyExistsException.
May throw ResourceNotFoundException.
May throw ServiceUnavailableException.
May throw ThrottlingException.
Parameter jobId :
A job identifier which must be unique for your account. We recommend using
a UUID. Alpha-numeric characters, "-" and "_" are valid for use here.
Parameter targets :
A list of things and thing groups to which the job should be sent.
Parameter abortConfig :
Allows you to create the criteria to abort a job.
Parameter description :
A short text description of the job.
Parameter destinationPackageVersions :
The package version Amazon Resource Names (ARNs) that are installed on the
device when the job successfully completes. The package version must be in
either the Published or Deprecated state when the job deploys. For more
information, see Package
version lifecycle.
Note:The following Length Constraints relates to a single ARN. Up to 25 package version ARNs are allowed.
Parameter document :
The job document. Required if you don't specify a value for
documentSource.
Parameter documentParameters :
Parameters of an Amazon Web Services managed template that you can specify
to create the job document.
Parameter documentSource :
An S3 link, or S3 object URL, to the job document. The link is an Amazon
S3 object URL and is required if you don't specify a value for
document.
For example, --document-source
https://s3.region-code.amazonaws.com/example-firmware/device-firmware.1.0
For more information, see Methods for accessing a bucket.
Parameter jobExecutionsRetryConfig :
Allows you to create the criteria to retry a job.
Parameter jobExecutionsRolloutConfig :
Allows you to create a staged rollout of the job.
Parameter jobTemplateArn :
The ARN of the job template used to create the job.
Parameter namespaceId :
The namespace used to indicate that a job is a customer-managed job.
When you specify a value for this parameter, Amazon Web Services IoT Core sends jobs notifications to MQTT topics that contain the value in the following format.
$aws/things/THING_NAME/jobs/JOB_ID/notify-namespace-NAMESPACE_ID/
Parameter presignedUrlConfig :
Configuration information for pre-signed S3 URLs.
Parameter schedulingConfig :
The configuration that allows you to schedule a job for a future date and
time in addition to specifying the end behavior for each job execution.
Parameter tags :
Metadata which can be used to manage the job.
Parameter targetSelection :
Specifies whether the job will continue to run (CONTINUOUS), or will be
complete after all those things specified as targets have completed the
job (SNAPSHOT). If continuous, the job may also be run on a thing when a
change is detected in a target. For example, a job will run on a thing
when the thing is added to a target group, even after the job was
completed by all things originally in the group.
Parameter timeoutConfig :
Specifies the amount of time each device has to finish its execution of
the job. The timer is started when the job execution status is set to
IN_PROGRESS. If the job execution status is not set to
another terminal state before the time expires, it will be automatically
set to TIMED_OUT.
Implementation
Future<CreateJobResponse> createJob({
required String jobId,
required List<String> targets,
AbortConfig? abortConfig,
String? description,
List<String>? destinationPackageVersions,
String? document,
Map<String, String>? documentParameters,
String? documentSource,
JobExecutionsRetryConfig? jobExecutionsRetryConfig,
JobExecutionsRolloutConfig? jobExecutionsRolloutConfig,
String? jobTemplateArn,
String? namespaceId,
PresignedUrlConfig? presignedUrlConfig,
SchedulingConfig? schedulingConfig,
List<Tag>? tags,
TargetSelection? targetSelection,
TimeoutConfig? timeoutConfig,
}) async {
final $payload = <String, dynamic>{
'targets': targets,
if (abortConfig != null) 'abortConfig': abortConfig,
if (description != null) 'description': description,
if (destinationPackageVersions != null)
'destinationPackageVersions': destinationPackageVersions,
if (document != null) 'document': document,
if (documentParameters != null) 'documentParameters': documentParameters,
if (documentSource != null) 'documentSource': documentSource,
if (jobExecutionsRetryConfig != null)
'jobExecutionsRetryConfig': jobExecutionsRetryConfig,
if (jobExecutionsRolloutConfig != null)
'jobExecutionsRolloutConfig': jobExecutionsRolloutConfig,
if (jobTemplateArn != null) 'jobTemplateArn': jobTemplateArn,
if (namespaceId != null) 'namespaceId': namespaceId,
if (presignedUrlConfig != null) 'presignedUrlConfig': presignedUrlConfig,
if (schedulingConfig != null) 'schedulingConfig': schedulingConfig,
if (tags != null) 'tags': tags,
if (targetSelection != null) 'targetSelection': targetSelection.value,
if (timeoutConfig != null) 'timeoutConfig': timeoutConfig,
};
final response = await _protocol.send(
payload: $payload,
method: 'PUT',
requestUri: '/jobs/${Uri.encodeComponent(jobId)}',
exceptionFnMap: _exceptionFns,
);
return CreateJobResponse.fromJson(response);
}