createOTAUpdate method

Future<CreateOTAUpdateResponse> createOTAUpdate({
  1. required List<OTAUpdateFile> files,
  2. required String otaUpdateId,
  3. required String roleArn,
  4. required List<String> targets,
  5. Map<String, String>? additionalParameters,
  6. AwsJobAbortConfig? awsJobAbortConfig,
  7. AwsJobExecutionsRolloutConfig? awsJobExecutionsRolloutConfig,
  8. AwsJobPresignedUrlConfig? awsJobPresignedUrlConfig,
  9. AwsJobTimeoutConfig? awsJobTimeoutConfig,
  10. String? description,
  11. List<Protocol>? protocols,
  12. List<Tag>? tags,
  13. TargetSelection? targetSelection,
})

Creates an AWS IoT OTAUpdate on a target group of things or groups.

May throw InvalidRequestException. May throw LimitExceededException. May throw ResourceNotFoundException. May throw ResourceAlreadyExistsException. May throw ThrottlingException. May throw UnauthorizedException. May throw InternalFailureException. May throw ServiceUnavailableException.

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 AWS IoT access to the Amazon S3, AWS IoT jobs and AWS 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.

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 {
  ArgumentError.checkNotNull(files, 'files');
  ArgumentError.checkNotNull(otaUpdateId, 'otaUpdateId');
  _s.validateStringLength(
    'otaUpdateId',
    otaUpdateId,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(roleArn, 'roleArn');
  _s.validateStringLength(
    'roleArn',
    roleArn,
    20,
    2048,
    isRequired: true,
  );
  ArgumentError.checkNotNull(targets, 'targets');
  _s.validateStringLength(
    'description',
    description,
    0,
    2028,
  );
  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.toValue()).toList(),
    if (tags != null) 'tags': tags,
    if (targetSelection != null) 'targetSelection': targetSelection.toValue(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/otaUpdates/${Uri.encodeComponent(otaUpdateId)}',
    exceptionFnMap: _exceptionFns,
  );
  return CreateOTAUpdateResponse.fromJson(response);
}