deleteJobExecution method

Future<void> deleteJobExecution({
  1. required int executionNumber,
  2. required String jobId,
  3. required String thingName,
  4. bool? force,
  5. String? namespaceId,
})

Deletes a job execution.

May throw InvalidRequestException. May throw InvalidStateTransitionException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ServiceUnavailableException.

Parameter executionNumber : The ID of the job execution to be deleted. The executionNumber refers to the execution of a particular job on a particular device.

Note that once a job execution is deleted, the executionNumber may be reused by IoT, so be sure you get and use the correct value here.

Parameter jobId : The ID of the job whose execution on a particular device will be deleted.

Parameter thingName : The name of the thing whose job execution will be deleted.

Parameter force : (Optional) When true, you can delete a job execution which is "IN_PROGRESS". Otherwise, you can only delete a job execution which is in a terminal state ("SUCCEEDED", "FAILED", "REJECTED", "REMOVED" or "CANCELED") or an exception will occur. The default is false.

Parameter namespaceId : The namespace used to indicate that a job is a customer-managed job.

When you specify a value for this parameter, AWS 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/

Implementation

Future<void> deleteJobExecution({
  required int executionNumber,
  required String jobId,
  required String thingName,
  bool? force,
  String? namespaceId,
}) async {
  ArgumentError.checkNotNull(executionNumber, 'executionNumber');
  ArgumentError.checkNotNull(jobId, 'jobId');
  _s.validateStringLength(
    'jobId',
    jobId,
    1,
    64,
    isRequired: true,
  );
  ArgumentError.checkNotNull(thingName, 'thingName');
  _s.validateStringLength(
    'thingName',
    thingName,
    1,
    128,
    isRequired: true,
  );
  _s.validateStringLength(
    'namespaceId',
    namespaceId,
    1,
    64,
  );
  final $query = <String, List<String>>{
    if (force != null) 'force': [force.toString()],
    if (namespaceId != null) 'namespaceId': [namespaceId],
  };
  await _protocol.send(
    payload: null,
    method: 'DELETE',
    requestUri:
        '/things/${Uri.encodeComponent(thingName)}/jobs/${Uri.encodeComponent(jobId)}/executionNumber/${Uri.encodeComponent(executionNumber.toString())}',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
}