cancelJob method

Future<CancelJobResponse> cancelJob({
  1. required String jobId,
  2. String? comment,
  3. bool? force,
  4. String? reasonCode,
})

Cancels a job.

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

Parameter jobId : The unique identifier you assigned to this job when it was created.

Parameter comment : An optional comment string describing why the job was canceled.

Parameter force : (Optional) If true job executions with status "IN_PROGRESS" and "QUEUED" are canceled, otherwise only job executions with status "QUEUED" are canceled. The default is false.

Canceling a job which is "IN_PROGRESS", will cause a device which is executing the job to be unable to update the job execution status. Use caution and ensure that each device executing a job which is canceled is able to recover to a valid state.

Parameter reasonCode : (Optional)A reason code string that explains why the job was canceled.

Implementation

Future<CancelJobResponse> cancelJob({
  required String jobId,
  String? comment,
  bool? force,
  String? reasonCode,
}) async {
  ArgumentError.checkNotNull(jobId, 'jobId');
  _s.validateStringLength(
    'jobId',
    jobId,
    1,
    64,
    isRequired: true,
  );
  _s.validateStringLength(
    'comment',
    comment,
    0,
    2028,
  );
  _s.validateStringLength(
    'reasonCode',
    reasonCode,
    0,
    128,
  );
  final $query = <String, List<String>>{
    if (force != null) 'force': [force.toString()],
  };
  final $payload = <String, dynamic>{
    if (comment != null) 'comment': comment,
    if (reasonCode != null) 'reasonCode': reasonCode,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/jobs/${Uri.encodeComponent(jobId)}/cancel',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return CancelJobResponse.fromJson(response);
}