Skip to content

lookup_events async

lookup_events(
    *,
    config_overrides: Optional[AsyncCloudTrailClientConfig] = None,
    lookup_attributes: Optional[LookupAttributesList] = None,
    start_time: Optional[Date] = None,
    end_time: Optional[Date] = None,
    event_category: Optional[EventCategory] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[NextToken] = None,
) -> LookupEventsResponse

Looks up management events or CloudTrail Insights events that are captured by CloudTrail. You can look up events that occurred in a Region within the last 90 days.

LookupEvents returns recent Insights events for trails that enable Insights. To view Insights events for an event data store, you can run queries on your Insights event data store, and you can also view the Lake dashboard for Insights.

Lookup supports the following attributes for management events:

  • Amazon Web Services access key

  • Event ID

  • Event name

  • Event source

  • Read only

  • Resource name

  • Resource type

  • User name

Lookup supports the following attributes for Insights events:

  • Event ID

  • Event name

  • Event source

All attributes are optional. The default number of results returned is 50, with a maximum of 50 possible. The response includes a token that you can use to get the next page of results.

The rate of lookup requests is limited to two per second, per account, per Region. If this limit is exceeded, a throttling error occurs.

Parameters:

  • lookup_attributes (Optional[LookupAttributesList], default: None ) –

    Contains a list of lookup attributes. Currently the list can contain only one item.

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

    Specifies that only events that occur after or at the specified time are returned. If the specified start time is after the specified end time, an error is returned.

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

    Specifies that only events that occur before or at the specified time are returned. If the specified end time is before the specified start time, an error is returned.

  • event_category (Optional[EventCategory], default: None ) –

    Specifies the event category. If you do not specify an event category, events of the category are not returned in the response. For example, if you do not specify insight as the value of EventCategory, no Insights events are returned.

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

    The number of events to return. Possible values are 1 through 50. The default is 50.

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

    The token to use to get the next page of results after a previous API call. This token must be passed in with the same parameters that were specified in the original call. For example, if the original call specified an AttributeKey of 'Username' with a value of 'root', the call with NextToken should include those same parameters.

Raises:

Source code in docs_src/capo_cloudtrail/_services/async_cloud_trail.py
async def lookup_events(
    self,
    *,
    config_overrides: Optional[AsyncCloudTrailClientConfig] = None,
    lookup_attributes: Optional[
        "capo_cloudtrail.types.lookup_attributes_list.LookupAttributesList"
    ] = None,
    start_time: Optional["capo_cloudtrail.types.date.Date"] = None,
    end_time: Optional["capo_cloudtrail.types.date.Date"] = None,
    event_category: Optional[
        "capo_cloudtrail.types.event_category.EventCategory"
    ] = None,
    max_results: Optional["capo_cloudtrail.types.max_results.MaxResults"] = None,
    next_token: Optional["capo_cloudtrail.types.next_token.NextToken"] = None,
) -> "capo_cloudtrail.types.lookup_events_response.LookupEventsResponse":
    """<p>Looks up <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-concepts.html#cloudtrail-concepts-management-events">management events</a> or <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-concepts.html#cloudtrail-concepts-insights-events">CloudTrail Insights events</a> that are captured by CloudTrail. You can look up events that occurred in a Region within the last 90 days.</p> <note> <p> <code>LookupEvents</code> returns recent Insights events for trails that enable Insights. To view Insights events for an event data store, you can run queries on your Insights event data store, and you can also view the Lake dashboard for Insights.</p> </note> <p>Lookup supports the following attributes for management events:</p> <ul> <li> <p>Amazon Web Services access key</p> </li> <li> <p>Event ID</p> </li> <li> <p>Event name</p> </li> <li> <p>Event source</p> </li> <li> <p>Read only</p> </li> <li> <p>Resource name</p> </li> <li> <p>Resource type</p> </li> <li> <p>User name</p> </li> </ul> <p>Lookup supports the following attributes for Insights events:</p> <ul> <li> <p>Event ID</p> </li> <li> <p>Event name</p> </li> <li> <p>Event source</p> </li> </ul> <p>All attributes are optional. The default number of results returned is 50, with a maximum of 50 possible. The response includes a token that you can use to get the next page of results.</p> <important> <p>The rate of lookup requests is limited to two per second, per account, per Region. If this limit is exceeded, a throttling error occurs.</p> </important>

    Args:
        lookup_attributes: <p>Contains a list of lookup attributes. Currently the list can contain only one item.</p>
        start_time: <p>Specifies that only events that occur after or at the specified time are returned. If the specified start time is after the specified end time, an error is returned.</p>
        end_time: <p>Specifies that only events that occur before or at the specified time are returned. If the specified end time is before the specified start time, an error is returned.</p>
        event_category: <p>Specifies the event category. If you do not specify an event category, events of the category are not returned in the response. For example, if you do not specify <code>insight</code> as the value of <code>EventCategory</code>, no Insights events are returned.</p>
        max_results: <p>The number of events to return. Possible values are 1 through 50. The default is 50.</p>
        next_token: <p>The token to use to get the next page of results after a previous API call. This token must be passed in with the same parameters that were specified in the original call. For example, if the original call specified an AttributeKey of 'Username' with a value of 'root', the call with NextToken should include those same parameters.</p>

    Raises:
        capo_cloudtrail.errors.invalid_event_category_exception.InvalidEventCategoryException: <p>Occurs if an event category that is not valid is specified as a value of <code>EventCategory</code>.</p>
        capo_cloudtrail.errors.invalid_lookup_attributes_exception.InvalidLookupAttributesException: <p>Occurs when a lookup attribute is specified that is not valid.</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_time_range_exception.InvalidTimeRangeException: <p>Occurs if the timestamp values are not valid. Either the start time occurs after the end time, or the time range is outside the range of possible values.</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.lookup_events_request.LookupEventsRequest]",
    ) -> AsyncOperationResponse[
        "capo_cloudtrail.types.lookup_events_response.LookupEventsResponse"
    ]:
        import capo_cloudtrail._operations.cloud_trail_20131101.lookup_events

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("LookupEvents")
    )
    input_: capo_cloudtrail.types.lookup_events_request.LookupEventsRequest = {}
    if lookup_attributes is not None:
        input_["lookup_attributes"] = lookup_attributes
    if start_time is not None:
        input_["start_time"] = start_time
    if end_time is not None:
        input_["end_time"] = end_time
    if event_category is not None:
        input_["event_category"] = event_category
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

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