cancelQuery method

Future<CancelQueryResponse> cancelQuery({
  1. required String queryId,
  2. String? eventDataStore,
  3. String? eventDataStoreOwnerAccountId,
})

Cancels a query if the query is not in a terminated state, such as CANCELLED, FAILED, TIMED_OUT, or FINISHED. You must specify an ARN value for EventDataStore. The ID of the query that you want to cancel is also required. When you run CancelQuery, the query status might show as CANCELLED even if the operation is not yet finished.

May throw ConflictException. May throw EventDataStoreARNInvalidException. May throw EventDataStoreNotFoundException. May throw InactiveEventDataStoreException. May throw InactiveQueryException. May throw InvalidParameterException. May throw NoManagementAccountSLRExistsException. May throw OperationNotPermittedException. May throw QueryIdNotFoundException. May throw UnsupportedOperationException.

Parameter queryId : The ID of the query that you want to cancel. The QueryId comes from the response of a StartQuery operation.

Parameter eventDataStore : The ARN (or the ID suffix of the ARN) of an event data store on which the specified query is running.

Parameter eventDataStoreOwnerAccountId : The account ID of the event data store owner.

Implementation

Future<CancelQueryResponse> cancelQuery({
  required String queryId,
  String? eventDataStore,
  String? eventDataStoreOwnerAccountId,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CloudTrail_20131101.CancelQuery'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'QueryId': queryId,
      if (eventDataStore != null) 'EventDataStore': eventDataStore,
      if (eventDataStoreOwnerAccountId != null)
        'EventDataStoreOwnerAccountId': eventDataStoreOwnerAccountId,
    },
  );

  return CancelQueryResponse.fromJson(jsonResponse.body);
}