Skip to content

list_guardrails async

list_guardrails(
    *,
    config_overrides: Optional[AsyncBedrockClientConfig] = None,
    guardrail_identifier: Optional[GuardrailIdentifier] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[PaginationToken] = None,
) -> ListGuardrailsResponse

Lists details about all the guardrails in an account. To list the DRAFT version of all your guardrails, don't specify the guardrailIdentifier field. To list all versions of a guardrail, specify the ARN of the guardrail in the guardrailIdentifier field.

You can set the maximum number of results to return in a response in the maxResults field. If there are more results than the number you set, the response returns a nextToken that you can send in another ListGuardrails request to see the next batch of results.

Parameters:

  • guardrail_identifier (Optional[GuardrailIdentifier], default: None ) –

    The unique identifier of the guardrail. This can be an ID or the ARN.

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

    The maximum number of results to return in the response.

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

    If there are more results than were returned in the response, the response returns a nextToken that you can send in another ListGuardrails request to see the next batch of results.

Raises:

Source code in docs_src/capo_bedrock/_services/async_bedrock.py
async def list_guardrails(
    self,
    *,
    config_overrides: Optional[AsyncBedrockClientConfig] = None,
    guardrail_identifier: Optional[
        "capo_bedrock.types.guardrail_identifier.GuardrailIdentifier"
    ] = None,
    max_results: Optional["capo_bedrock.types.max_results.MaxResults"] = None,
    next_token: Optional[
        "capo_bedrock.types.pagination_token.PaginationToken"
    ] = None,
) -> "capo_bedrock.types.list_guardrails_response.ListGuardrailsResponse":
    """<p>Lists details about all the guardrails in an account. To list the <code>DRAFT</code> version of all your guardrails, don't specify the <code>guardrailIdentifier</code> field. To list all versions of a guardrail, specify the ARN of the guardrail in the <code>guardrailIdentifier</code> field.</p> <p>You can set the maximum number of results to return in a response in the <code>maxResults</code> field. If there are more results than the number you set, the response returns a <code>nextToken</code> that you can send in another <code>ListGuardrails</code> request to see the next batch of results.</p>

    Args:
        guardrail_identifier: <p>The unique identifier of the guardrail. This can be an ID or the ARN.</p>
        max_results: <p>The maximum number of results to return in the response.</p>
        next_token: <p>If there are more results than were returned in the response, the response returns a <code>nextToken</code> that you can send in another <code>ListGuardrails</code> request to see the next batch of results.</p>

    Raises:
        capo_bedrock.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because of missing access permissions.</p>
        capo_bedrock.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
        capo_bedrock.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.</p>
        capo_bedrock.errors.throttling_exception.ThrottlingException: <p>The number of requests exceeds the limit. Resubmit your request later.</p>
        capo_bedrock.errors.validation_exception.ValidationException: <p>Input validation failed. Check your request parameters and retry the request.</p>
        capo_bedrock.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_bedrock.types.list_guardrails_request.ListGuardrailsRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock.types.list_guardrails_response.ListGuardrailsResponse"
    ]:
        import capo_bedrock._operations.amazon_bedrock_control_plane_service.list_guardrails

        (
            output,
            http_response,
        ) = await capo_bedrock._operations.amazon_bedrock_control_plane_service.list_guardrails.async_list_guardrails(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_bedrock.types.list_guardrails_response.ListGuardrailsResponse",
    ) -> dict[str, Any]:
        import capo_bedrock.types.list_guardrails_response

        return capo_bedrock.types.list_guardrails_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ListGuardrails", redact_output=_redact_output),
    )
    input_: capo_bedrock.types.list_guardrails_request.ListGuardrailsRequest = {}
    if guardrail_identifier is not None:
        input_["guardrail_identifier"] = guardrail_identifier
    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