Skip to content

start_resource_activities_query async

start_resource_activities_query(
    environment_arn: EnvironmentArn,
    project: ProjectName,
    actor_arn: ResourceArn,
    *,
    config_overrides: Optional[AsyncAssuranceClientConfig] = None,
    start_time: Optional[datetime] = None,
    end_time: Optional[datetime] = None,
    aggregation_levels: Optional[ActivityAggregationLevelList] = None,
    filters: Optional[ResourceActivitiesFilterList] = None,
) -> StartResourceActivitiesQueryOutput

Starts a query of the AWS API calls that an artificial intelligence (AI) agent on Amazon Bedrock AgentCore Runtime made. Use the results to audit which resources the agent touched in your account. Returns a query ID. To check the status of the query and get its results, call GetResourceActivitiesQueryResults.

The agent runtime that you query must be in your AWS account.

Parameters:

  • environment_arn (EnvironmentArn) –

    The ARN of the environment to query in.

  • project (ProjectName) –

    The project to query in.

  • actor_arn (ResourceArn) –

    The ARN of the agent runtime whose activity to query. The agent runtime must be in your AWS account.

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

    The start of the time range to query, inclusive. The default is 24 hours before the request.

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

    The end of the time range to query, exclusive. The default is the time of the request.

  • aggregation_levels (Optional[ActivityAggregationLevelList], default: None ) –

    The ways to group the results. By default, the results include every grouping. Valid values:

    • ACTION – Call counts for each AWS service and API action.

    • RESOURCE – Call counts for each resource.

    • SESSION – The agent sessions in the time range.

  • filters (Optional[ResourceActivitiesFilterList], default: None ) –

    The filters to apply to the results. A result must match every filter. Within one filter, a result must match at least one of the values. If you don't specify any filters, the query returns all activity in the time range.

Raises:

Source code in docs_src/capo_assurance/_services/async_assurance.py
async def start_resource_activities_query(
    self,
    environment_arn: "capo_assurance.types.environment_arn.EnvironmentArn",
    project: "capo_assurance.types.project_name.ProjectName",
    actor_arn: "capo_assurance.types.resource_arn.ResourceArn",
    *,
    config_overrides: Optional[AsyncAssuranceClientConfig] = None,
    start_time: Optional[datetime.datetime] = None,
    end_time: Optional[datetime.datetime] = None,
    aggregation_levels: Optional[
        "capo_assurance.types.activity_aggregation_level_list.ActivityAggregationLevelList"
    ] = None,
    filters: Optional[
        "capo_assurance.types.resource_activities_filter_list.ResourceActivitiesFilterList"
    ] = None,
) -> "capo_assurance.types.start_resource_activities_query_output.StartResourceActivitiesQueryOutput":
    """<p>Starts a query of the AWS API calls that an artificial intelligence (AI) agent on Amazon Bedrock AgentCore Runtime made. Use the results to audit which resources the agent touched in your account. Returns a query ID. To check the status of the query and get its results, call <code>GetResourceActivitiesQueryResults</code>.</p> <p>The agent runtime that you query must be in your AWS account.</p>

    Args:
        environment_arn: <p>The ARN of the environment to query in.</p>
        project: <p>The project to query in.</p>
        actor_arn: <p>The ARN of the agent runtime whose activity to query. The agent runtime must be in your AWS account.</p>
        start_time: <p>The start of the time range to query, inclusive. The default is 24 hours before the request.</p>
        end_time: <p>The end of the time range to query, exclusive. The default is the time of the request.</p>
        aggregation_levels: <p>The ways to group the results. By default, the results include every grouping. Valid values:</p> <ul> <li> <p> <code>ACTION</code> – Call counts for each AWS service and API action.</p> </li> <li> <p> <code>RESOURCE</code> – Call counts for each resource.</p> </li> <li> <p> <code>SESSION</code> – The agent sessions in the time range.</p> </li> </ul>
        filters: <p>The filters to apply to the results. A result must match every filter. Within one filter, a result must match at least one of the values. If you don't specify any filters, the query returns all activity in the time range.</p>

    Raises:
        capo_assurance.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action. This error occurs when the request is unauthenticated, or is authenticated but lacks permission to invoke the operation.</p>
        capo_assurance.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred.</p>
        capo_assurance.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource was not found.</p>
        capo_assurance.errors.throttling_exception.ThrottlingException: <p>The request was throttled.</p>
        capo_assurance.errors.validation_exception.ValidationException: <p>The request failed validation.</p>
        capo_assurance.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_assurance.types.start_resource_activities_query_input.StartResourceActivitiesQueryInput]",
    ) -> AsyncOperationResponse[
        "capo_assurance.types.start_resource_activities_query_output.StartResourceActivitiesQueryOutput"
    ]:
        import capo_assurance._operations.assurance.start_resource_activities_query

        (
            output,
            http_response,
        ) = await capo_assurance._operations.assurance.start_resource_activities_query.async_start_resource_activities_query(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StartResourceActivitiesQuery")
    )
    input_: capo_assurance.types.start_resource_activities_query_input.StartResourceActivitiesQueryInput = {
        "environment_arn": environment_arn,
        "project": project,
        "actor_arn": actor_arn,
    }
    if start_time is not None:
        input_["start_time"] = start_time
    if end_time is not None:
        input_["end_time"] = end_time
    if aggregation_levels is not None:
        input_["aggregation_levels"] = aggregation_levels
    if filters is not None:
        input_["filters"] = filters

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