cancelSteps method

Future<CancelStepsOutput> cancelSteps({
  1. required String clusterId,
  2. required List<String> stepIds,
  3. StepCancellationOption? stepCancellationOption,
})

Cancels a pending step or steps in a running cluster. Available only in Amazon EMR versions 4.8.0 and later, excluding version 5.0.0. A maximum of 256 steps are allowed in each CancelSteps request. CancelSteps is idempotent but asynchronous; it does not guarantee that a step will be canceled, even if the request is successfully submitted. You can only cancel steps that are in a PENDING state.

May throw InternalServerError. May throw InvalidRequestException.

Parameter clusterId : The ClusterID for the specified steps that will be canceled. Use RunJobFlow and ListClusters to get ClusterIDs.

Parameter stepIds : The list of StepIDs to cancel. Use ListSteps to get steps and their states for the specified cluster.

Parameter stepCancellationOption : The option to choose to cancel RUNNING steps. By default, the value is SEND_INTERRUPT.

Implementation

Future<CancelStepsOutput> cancelSteps({
  required String clusterId,
  required List<String> stepIds,
  StepCancellationOption? stepCancellationOption,
}) async {
  ArgumentError.checkNotNull(clusterId, 'clusterId');
  _s.validateStringLength(
    'clusterId',
    clusterId,
    0,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(stepIds, 'stepIds');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'ElasticMapReduce.CancelSteps'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ClusterId': clusterId,
      'StepIds': stepIds,
      if (stepCancellationOption != null)
        'StepCancellationOption': stepCancellationOption.toValue(),
    },
  );

  return CancelStepsOutput.fromJson(jsonResponse.body);
}