cancelCommand method

Future<void> cancelCommand({
  1. required String commandId,
  2. List<String>? instanceIds,
})

Attempts to cancel the command specified by the Command ID. There is no guarantee that the command will be terminated and the underlying process stopped.

May throw InternalServerError. May throw InvalidCommandId. May throw InvalidInstanceId. May throw DuplicateInstanceId.

Parameter commandId : The ID of the command you want to cancel.

Parameter instanceIds : (Optional) A list of instance IDs on which you want to cancel the command. If not provided, the command is canceled on every instance on which it was requested.

Implementation

Future<void> cancelCommand({
  required String commandId,
  List<String>? instanceIds,
}) async {
  ArgumentError.checkNotNull(commandId, 'commandId');
  _s.validateStringLength(
    'commandId',
    commandId,
    36,
    36,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.CancelCommand'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'CommandId': commandId,
      if (instanceIds != null) 'InstanceIds': instanceIds,
    },
  );
}