CloudTrail Lake will no longer be open to new customers starting May 31, 2026. If you would like to use CloudTrail Lake, sign up prior to that date. Existing customers can continue to use the service as normal. For more information, see CloudTrail Lake availability change.
Generates a query from a natural language prompt. This operation uses generative artificial intelligence (generative AI) to produce a ready-to-use SQL query from the prompt.
The prompt can be a question or a statement about the event data in your event data store. For example, you can enter prompts like "What are my top errors in the past month?" and “Give me a list of users that used SNS.”
The prompt must be in English. For information about limitations, permissions, and supported Regions, see Create CloudTrail Lake queries from natural language prompts in the CloudTrail user guide.
Do not include any personally identifying, confidential, or sensitive information in your prompts.
This feature uses generative AI large language models (LLMs); we recommend double-checking the LLM response.
Parameters:
-
event_data_stores
(EventDataStoreList)
–
The ARN (or ID suffix of the ARN) of the event data store that you want to query. You can only specify one event data store.
-
prompt
(Prompt)
–
The prompt that you want to use to generate the query. The prompt must be in English. For example prompts, see Example prompts in the CloudTrail user guide.
Raises:
Source code in docs_src/capo_cloudtrail/_services/async_cloud_trail.py
| async def generate_query(
self,
event_data_stores: "capo_cloudtrail.types.event_data_store_list.EventDataStoreList",
prompt: "capo_cloudtrail.types.prompt.Prompt",
*,
config_overrides: Optional[AsyncCloudTrailClientConfig] = None,
) -> "capo_cloudtrail.types.generate_query_response.GenerateQueryResponse":
"""<important> <p>CloudTrail Lake will no longer be open to new customers starting May 31, 2026. If you would like to use CloudTrail Lake, sign up prior to that date. Existing customers can continue to use the service as normal. For more information, see <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake-service-availability-change.html">CloudTrail Lake availability change</a>.</p> </important> <p> Generates a query from a natural language prompt. This operation uses generative artificial intelligence (generative AI) to produce a ready-to-use SQL query from the prompt. </p> <p>The prompt can be a question or a statement about the event data in your event data store. For example, you can enter prompts like "What are my top errors in the past month?" and “Give me a list of users that used SNS.”</p> <p>The prompt must be in English. For information about limitations, permissions, and supported Regions, see <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/lake-query-generator.html">Create CloudTrail Lake queries from natural language prompts</a> in the <i>CloudTrail </i> user guide.</p> <note> <p>Do not include any personally identifying, confidential, or sensitive information in your prompts.</p> <p>This feature uses generative AI large language models (LLMs); we recommend double-checking the LLM response.</p> </note>
Args:
event_data_stores: <p> The ARN (or ID suffix of the ARN) of the event data store that you want to query. You can only specify one event data store. </p>
prompt: <p> The prompt that you want to use to generate the query. The prompt must be in English. For example prompts, see <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/lake-query-generator.html#lake-query-generator-examples">Example prompts</a> in the <i>CloudTrail </i> user guide. </p>
Raises:
capo_cloudtrail.errors.event_data_store_arn_invalid_exception.EventDataStoreARNInvalidException: <p>The specified event data store ARN is not valid or does not map to an event data store in your account.</p>
capo_cloudtrail.errors.event_data_store_not_found_exception.EventDataStoreNotFoundException: <p>The specified event data store was not found.</p>
capo_cloudtrail.errors.generate_response_exception.GenerateResponseException: <p> This exception is thrown when a valid query could not be generated for the provided prompt. </p>
capo_cloudtrail.errors.inactive_event_data_store_exception.InactiveEventDataStoreException: <p>The event data store is inactive.</p>
capo_cloudtrail.errors.invalid_parameter_exception.InvalidParameterException: <p>The request includes a parameter that is not valid.</p>
capo_cloudtrail.errors.no_management_account_slr_exists_exception.NoManagementAccountSLRExistsException: <p> This exception is thrown when the management account does not have a service-linked role. </p>
capo_cloudtrail.errors.operation_not_permitted_exception.OperationNotPermittedException: <p>This exception is thrown when the requested operation is not permitted.</p>
capo_cloudtrail.errors.unsupported_operation_exception.UnsupportedOperationException: <p>This exception is thrown when the requested operation is not supported.</p>
capo_cloudtrail.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_cloudtrail.types.generate_query_request.GenerateQueryRequest]",
) -> AsyncOperationResponse[
"capo_cloudtrail.types.generate_query_response.GenerateQueryResponse"
]:
import capo_cloudtrail._operations.cloud_trail_20131101.generate_query
(
output,
http_response,
) = await capo_cloudtrail._operations.cloud_trail_20131101.generate_query.async_generate_query(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("GenerateQuery")
)
input_: capo_cloudtrail.types.generate_query_request.GenerateQueryRequest = {
"event_data_stores": event_data_stores,
"prompt": prompt,
}
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|