startQuery method

Future<StartQueryResponse> startQuery({
  1. String? deliveryS3Uri,
  2. String? eventDataStoreOwnerAccountId,
  3. String? queryAlias,
  4. List<String>? queryParameters,
  5. String? queryStatement,
})

Starts a CloudTrail Lake query. Use the QueryStatement parameter to provide your SQL query, enclosed in single quotation marks. Use the optional DeliveryS3Uri parameter to deliver the query results to an S3 bucket.

StartQuery requires you specify either the QueryStatement parameter, or a QueryAlias and any QueryParameters. In the current release, the QueryAlias and QueryParameters parameters are used only for the queries that populate the CloudTrail Lake dashboards.

May throw EventDataStoreARNInvalidException. May throw EventDataStoreNotFoundException. May throw InactiveEventDataStoreException. May throw InsufficientEncryptionPolicyException. May throw InsufficientS3BucketPolicyException. May throw InvalidParameterException. May throw InvalidQueryStatementException. May throw InvalidS3BucketNameException. May throw InvalidS3PrefixException. May throw MaxConcurrentQueriesException. May throw NoManagementAccountSLRExistsException. May throw OperationNotPermittedException. May throw S3BucketDoesNotExistException. May throw UnsupportedOperationException.

Parameter deliveryS3Uri : The URI for the S3 bucket where CloudTrail delivers the query results.

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

Parameter queryAlias : The alias that identifies a query template.

Parameter queryParameters : The query parameters for the specified QueryAlias.

Parameter queryStatement : The SQL code of your query.

Implementation

Future<StartQueryResponse> startQuery({
  String? deliveryS3Uri,
  String? eventDataStoreOwnerAccountId,
  String? queryAlias,
  List<String>? queryParameters,
  String? queryStatement,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CloudTrail_20131101.StartQuery'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (deliveryS3Uri != null) 'DeliveryS3Uri': deliveryS3Uri,
      if (eventDataStoreOwnerAccountId != null)
        'EventDataStoreOwnerAccountId': eventDataStoreOwnerAccountId,
      if (queryAlias != null) 'QueryAlias': queryAlias,
      if (queryParameters != null) 'QueryParameters': queryParameters,
      if (queryStatement != null) 'QueryStatement': queryStatement,
    },
  );

  return StartQueryResponse.fromJson(jsonResponse.body);
}