createOTAUpdate method
- required List<
OTAUpdateFile> files, - required String otaUpdateId,
- required String roleArn,
- required List<
String> targets, - Map<
String, String> ? additionalParameters, - AwsJobAbortConfig? awsJobAbortConfig,
- AwsJobExecutionsRolloutConfig? awsJobExecutionsRolloutConfig,
- AwsJobPresignedUrlConfig? awsJobPresignedUrlConfig,
- AwsJobTimeoutConfig? awsJobTimeoutConfig,
- String? description,
- List<
Protocol> ? protocols, - List<
Tag> ? tags, - TargetSelection? targetSelection,
Creates an IoT OTA update on a target group of things or groups.
Requires permission to access the CreateOTAUpdate action.
May throw InternalFailureException.
May throw InvalidRequestException.
May throw LimitExceededException.
May throw ResourceAlreadyExistsException.
May throw ResourceNotFoundException.
May throw ServiceUnavailableException.
May throw ThrottlingException.
May throw UnauthorizedException.
Parameter files :
The files to be streamed by the OTA update.
Parameter otaUpdateId :
The ID of the OTA update to be created.
Parameter roleArn :
The IAM role that grants Amazon Web Services IoT Core access to the Amazon
S3, IoT jobs and Amazon Web Services Code Signing resources to create an
OTA update job.
Parameter targets :
The devices targeted to receive OTA updates.
Parameter additionalParameters :
A list of additional OTA update parameters, which are name-value pairs.
They won't be sent to devices as a part of the Job document.
Parameter awsJobAbortConfig :
The criteria that determine when and how a job abort takes place.
Parameter awsJobExecutionsRolloutConfig :
Configuration for the rollout of OTA updates.
Parameter awsJobPresignedUrlConfig :
Configuration information for pre-signed URLs.
Parameter awsJobTimeoutConfig :
Specifies the amount of time each device has to finish its execution of
the job. A 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 timer expires, it will be automatically
set to TIMED_OUT.
Parameter description :
The description of the OTA update.
Parameter protocols :
The protocol used to transfer the OTA update image. Valid values are
[HTTP], [MQTT], [HTTP, MQTT]. When both HTTP and MQTT are specified,
the target device can choose the protocol.
Parameter tags :
Metadata which can be used to manage updates.
Parameter targetSelection :
Specifies whether the update will continue to run (CONTINUOUS), or will be
complete after all the things specified as targets have completed the
update (SNAPSHOT). If continuous, the update may also be run on a thing
when a change is detected in a target. For example, an update will run on
a thing when the thing is added to a target group, even after the update
was completed by all things originally in the group. Valid values:
CONTINUOUS | SNAPSHOT.
Implementation
Future<CreateOTAUpdateResponse> createOTAUpdate({
required List<OTAUpdateFile> files,
required String otaUpdateId,
required String roleArn,
required List<String> targets,
Map<String, String>? additionalParameters,
AwsJobAbortConfig? awsJobAbortConfig,
AwsJobExecutionsRolloutConfig? awsJobExecutionsRolloutConfig,
AwsJobPresignedUrlConfig? awsJobPresignedUrlConfig,
AwsJobTimeoutConfig? awsJobTimeoutConfig,
String? description,
List<Protocol>? protocols,
List<Tag>? tags,
TargetSelection? targetSelection,
}) async {
final $payload = <String, dynamic>{
'files': files,
'roleArn': roleArn,
'targets': targets,
if (additionalParameters != null)
'additionalParameters': additionalParameters,
if (awsJobAbortConfig != null) 'awsJobAbortConfig': awsJobAbortConfig,
if (awsJobExecutionsRolloutConfig != null)
'awsJobExecutionsRolloutConfig': awsJobExecutionsRolloutConfig,
if (awsJobPresignedUrlConfig != null)
'awsJobPresignedUrlConfig': awsJobPresignedUrlConfig,
if (awsJobTimeoutConfig != null)
'awsJobTimeoutConfig': awsJobTimeoutConfig,
if (description != null) 'description': description,
if (protocols != null)
'protocols': protocols.map((e) => e.value).toList(),
if (tags != null) 'tags': tags,
if (targetSelection != null) 'targetSelection': targetSelection.value,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/otaUpdates/${Uri.encodeComponent(otaUpdateId)}',
exceptionFnMap: _exceptionFns,
);
return CreateOTAUpdateResponse.fromJson(response);
}