createOtaTask method

Future<CreateOtaTaskResponse> createOtaTask({
  1. required OtaType otaType,
  2. required String s3Url,
  3. String? clientToken,
  4. String? description,
  5. OtaMechanism? otaMechanism,
  6. OtaTaskSchedulingConfig? otaSchedulingConfig,
  7. String? otaTargetQueryString,
  8. OtaTaskExecutionRetryConfig? otaTaskExecutionRetryConfig,
  9. OtaProtocol? protocol,
  10. Map<String, String>? tags,
  11. List<String>? target,
  12. String? taskConfigurationId,
})

Create an over-the-air (OTA) task to target a device.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw UnauthorizedException. May throw ValidationException.

Parameter otaType : The frequency type for the over-the-air (OTA) task.

Parameter s3Url : The URL to the Amazon S3 bucket where the over-the-air (OTA) task is stored.

Parameter clientToken : An idempotency token. If you retry a request that completed successfully initially using the same client token and parameters, then the retry attempt will succeed without performing any further actions.

Parameter description : The description of the over-the-air (OTA) task.

Parameter otaMechanism : The deployment mechanism for the over-the-air (OTA) task.

Parameter otaTargetQueryString : The query string to add things to the thing group.

Parameter protocol : The connection protocol the over-the-air (OTA) task uses to update the device.

Parameter tags : A set of key/value pairs that are used to manage the over-the-air (OTA) task.

Parameter target : The device targeted for the over-the-air (OTA) task.

Parameter taskConfigurationId : The identifier for the over-the-air (OTA) task configuration.

Implementation

Future<CreateOtaTaskResponse> createOtaTask({
  required OtaType otaType,
  required String s3Url,
  String? clientToken,
  String? description,
  OtaMechanism? otaMechanism,
  OtaTaskSchedulingConfig? otaSchedulingConfig,
  String? otaTargetQueryString,
  OtaTaskExecutionRetryConfig? otaTaskExecutionRetryConfig,
  OtaProtocol? protocol,
  Map<String, String>? tags,
  List<String>? target,
  String? taskConfigurationId,
}) async {
  final $payload = <String, dynamic>{
    'OtaType': otaType.value,
    'S3Url': s3Url,
    'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (description != null) 'Description': description,
    if (otaMechanism != null) 'OtaMechanism': otaMechanism.value,
    if (otaSchedulingConfig != null)
      'OtaSchedulingConfig': otaSchedulingConfig,
    if (otaTargetQueryString != null)
      'OtaTargetQueryString': otaTargetQueryString,
    if (otaTaskExecutionRetryConfig != null)
      'OtaTaskExecutionRetryConfig': otaTaskExecutionRetryConfig,
    if (protocol != null) 'Protocol': protocol.value,
    if (tags != null) 'Tags': tags,
    if (target != null) 'Target': target,
    if (taskConfigurationId != null)
      'TaskConfigurationId': taskConfigurationId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/ota-tasks',
    exceptionFnMap: _exceptionFns,
  );
  return CreateOtaTaskResponse.fromJson(response);
}