Skip to content

list_queries async

list_queries(
    event_data_store: EventDataStoreArn,
    *,
    config_overrides: Optional[AsyncCloudTrailClientConfig] = None,
    next_token: Optional[PaginationToken] = None,
    max_results: Optional[ListQueriesMaxResultsCount] = None,
    start_time: Optional[Date] = None,
    end_time: Optional[Date] = None,
    query_status: Optional[QueryStatus] = None,
) -> ListQueriesResponse

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.

Returns a list of queries and query statuses for the past seven days. You must specify an ARN value for EventDataStore. Optionally, to shorten the list of results, you can specify a time range, formatted as timestamps, by adding StartTime and EndTime parameters, and a QueryStatus value. Valid values for QueryStatus include QUEUED, RUNNING, FINISHED, FAILED, TIMED_OUT, or CANCELLED.

Parameters:

  • event_data_store (EventDataStoreArn) –

    The ARN (or the ID suffix of the ARN) of an event data store on which queries were run.

  • next_token (Optional[PaginationToken], default: None ) –

    A token you can use to get the next page of results.

  • max_results (Optional[ListQueriesMaxResultsCount], default: None ) –

    The maximum number of queries to show on a page.

  • start_time (Optional[Date], default: None ) –

    Use with EndTime to bound a ListQueries request, and limit its results to only those queries run within a specified time period.

  • end_time (Optional[Date], default: None ) –

    Use with StartTime to bound a ListQueries request, and limit its results to only those queries run within a specified time period.

  • query_status (Optional[QueryStatus], default: None ) –

    The status of queries that you want to return in results. Valid values for QueryStatus include QUEUED, RUNNING, FINISHED, FAILED, TIMED_OUT, or CANCELLED.

Raises:

Source code in docs_src/capo_cloudtrail/_services/async_cloud_trail.py
async def list_queries(
    self,
    event_data_store: "capo_cloudtrail.types.event_data_store_arn.EventDataStoreArn",
    *,
    config_overrides: Optional[AsyncCloudTrailClientConfig] = None,
    next_token: Optional[
        "capo_cloudtrail.types.pagination_token.PaginationToken"
    ] = None,
    max_results: Optional[
        "capo_cloudtrail.types.list_queries_max_results_count.ListQueriesMaxResultsCount"
    ] = None,
    start_time: Optional["capo_cloudtrail.types.date.Date"] = None,
    end_time: Optional["capo_cloudtrail.types.date.Date"] = None,
    query_status: Optional["capo_cloudtrail.types.query_status.QueryStatus"] = None,
) -> "capo_cloudtrail.types.list_queries_response.ListQueriesResponse":
    """<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>Returns a list of queries and query statuses for the past seven days. You must specify an ARN value for <code>EventDataStore</code>. Optionally, to shorten the list of results, you can specify a time range, formatted as timestamps, by adding <code>StartTime</code> and <code>EndTime</code> parameters, and a <code>QueryStatus</code> value. Valid values for <code>QueryStatus</code> include <code>QUEUED</code>, <code>RUNNING</code>, <code>FINISHED</code>, <code>FAILED</code>, <code>TIMED_OUT</code>, or <code>CANCELLED</code>.</p>

    Args:
        event_data_store: <p>The ARN (or the ID suffix of the ARN) of an event data store on which queries were run.</p>
        next_token: <p>A token you can use to get the next page of results.</p>
        max_results: <p>The maximum number of queries to show on a page.</p>
        start_time: <p>Use with <code>EndTime</code> to bound a <code>ListQueries</code> request, and limit its results to only those queries run within a specified time period.</p>
        end_time: <p>Use with <code>StartTime</code> to bound a <code>ListQueries</code> request, and limit its results to only those queries run within a specified time period.</p>
        query_status: <p>The status of queries that you want to return in results. Valid values for <code>QueryStatus</code> include <code>QUEUED</code>, <code>RUNNING</code>, <code>FINISHED</code>, <code>FAILED</code>, <code>TIMED_OUT</code>, or <code>CANCELLED</code>.</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.inactive_event_data_store_exception.InactiveEventDataStoreException: <p>The event data store is inactive.</p>
        capo_cloudtrail.errors.invalid_date_range_exception.InvalidDateRangeException: <p>A date range for the query was specified that is not valid. Be sure that the start time is chronologically before the end time. For more information about writing a query, see <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/query-create-edit-query.html">Create or edit a query</a> in the <i>CloudTrail User Guide</i>.</p>
        capo_cloudtrail.errors.invalid_max_results_exception.InvalidMaxResultsException: <p>This exception is thrown if the limit specified is not valid.</p>
        capo_cloudtrail.errors.invalid_next_token_exception.InvalidNextTokenException: <p>A token that is not valid, or a token that was previously used in a request with different parameters. This exception is thrown if the token is not valid.</p>
        capo_cloudtrail.errors.invalid_parameter_exception.InvalidParameterException: <p>The request includes a parameter that is not valid.</p>
        capo_cloudtrail.errors.invalid_query_status_exception.InvalidQueryStatusException: <p>The query status is not valid for the operation.</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.list_queries_request.ListQueriesRequest]",
    ) -> AsyncOperationResponse[
        "capo_cloudtrail.types.list_queries_response.ListQueriesResponse"
    ]:
        import capo_cloudtrail._operations.cloud_trail_20131101.list_queries

        (
            output,
            http_response,
        ) = await capo_cloudtrail._operations.cloud_trail_20131101.list_queries.async_list_queries(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListQueries")
    )
    input_: capo_cloudtrail.types.list_queries_request.ListQueriesRequest = {
        "event_data_store": event_data_store
    }
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if start_time is not None:
        input_["start_time"] = start_time
    if end_time is not None:
        input_["end_time"] = end_time
    if query_status is not None:
        input_["query_status"] = query_status

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output