Skip to content

list_policies async

list_policies(
    policy_engine_id: ResourceId,
    *,
    config_overrides: Optional[AsyncBedrockAgentCoreControlClientConfig] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[MaxResults] = None,
    target_resource_scope: Optional[BedrockAgentcoreResourceArn] = None,
) -> ListPoliciesResponse

Retrieves a list of policies within the AgentCore Policy engine. This operation supports pagination and filtering to help administrators manage and discover policies across policy engines. Results can be filtered by policy engine or resource associations.

Parameters:

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

    A pagination token returned from a previous ListPolicies call. Use this token to retrieve the next page of results when the response is paginated.

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

    The maximum number of policies to return in a single response. If not specified, the default is 10 policies per page, with a maximum of 100 per page.

  • policy_engine_id (ResourceId) –

    The identifier of the policy engine whose policies to retrieve.

  • target_resource_scope (Optional[BedrockAgentcoreResourceArn], default: None ) –

    Optional filter to list policies that apply to a specific resource scope or resource type. This helps narrow down policy results to those relevant for particular Amazon Web Services resources, agent tools, or operational contexts within the policy engine ecosystem.

Raises:

Source code in docs_src/capo_bedrock_agentcore_control/_services/async_bedrock_agent_core_control.py
async def list_policies(
    self,
    policy_engine_id: "capo_bedrock_agentcore_control.types.resource_id.ResourceId",
    *,
    config_overrides: Optional[AsyncBedrockAgentCoreControlClientConfig] = None,
    next_token: Optional[
        "capo_bedrock_agentcore_control.types.next_token.NextToken"
    ] = None,
    max_results: Optional[
        "capo_bedrock_agentcore_control.types.max_results.MaxResults"
    ] = None,
    target_resource_scope: Optional[
        "capo_bedrock_agentcore_control.types.bedrock_agentcore_resource_arn.BedrockAgentcoreResourceArn"
    ] = None,
) -> "capo_bedrock_agentcore_control.types.list_policies_response.ListPoliciesResponse":
    """<p>Retrieves a list of policies within the AgentCore Policy engine. This operation supports pagination and filtering to help administrators manage and discover policies across policy engines. Results can be filtered by policy engine or resource associations.</p>

    Args:
        next_token: <p>A pagination token returned from a previous <a href="https://docs.aws.amazon.com/bedrock-agentcore-control/latest/APIReference/API_ListPolicies.html">ListPolicies</a> call. Use this token to retrieve the next page of results when the response is paginated.</p>
        max_results: <p>The maximum number of policies to return in a single response. If not specified, the default is 10 policies per page, with a maximum of 100 per page.</p>
        policy_engine_id: <p>The identifier of the policy engine whose policies to retrieve.</p>
        target_resource_scope: <p>Optional filter to list policies that apply to a specific resource scope or resource type. This helps narrow down policy results to those relevant for particular Amazon Web Services resources, agent tools, or operational contexts within the policy engine ecosystem.</p>

    Raises:
        capo_bedrock_agentcore_control.errors.access_denied_exception.AccessDeniedException: <p>This exception is thrown when a request is denied per access permissions</p>
        capo_bedrock_agentcore_control.errors.internal_server_exception.InternalServerException: <p>This exception is thrown if there was an unexpected error during processing of request</p>
        capo_bedrock_agentcore_control.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when a resource referenced by the operation does not exist</p>
        capo_bedrock_agentcore_control.errors.throttling_exception.ThrottlingException: <p>This exception is thrown when the number of requests exceeds the limit</p>
        capo_bedrock_agentcore_control.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service.</p>
        capo_bedrock_agentcore_control.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_bedrock_agentcore_control.types.list_policies_request.ListPoliciesRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock_agentcore_control.types.list_policies_response.ListPoliciesResponse"
    ]:
        import capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.list_policies

        (
            output,
            http_response,
        ) = await capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.list_policies.async_list_policies(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_bedrock_agentcore_control.types.list_policies_response.ListPoliciesResponse",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore_control.types.list_policies_response

        return capo_bedrock_agentcore_control.types.list_policies_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ListPolicies", redact_output=_redact_output),
    )
    input_: capo_bedrock_agentcore_control.types.list_policies_request.ListPoliciesRequest = {
        "policy_engine_id": policy_engine_id
    }
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if target_resource_scope is not None:
        input_["target_resource_scope"] = target_resource_scope

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