Skip to content

create_guardrail_version async

create_guardrail_version(
    guardrail_identifier: GuardrailIdentifier,
    *,
    config_overrides: Optional[AsyncBedrockClientConfig] = None,
    description: Optional[GuardrailDescription] = None,
    client_request_token: Optional[IdempotencyToken] = None,
) -> CreateGuardrailVersionResponse

Creates a version of the guardrail. Use this API to create a snapshot of the guardrail when you are satisfied with a configuration, or to compare the configuration with another version.

Parameters:

  • guardrail_identifier (GuardrailIdentifier) –

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

  • description (Optional[GuardrailDescription], default: None ) –

    A description of the guardrail version.

  • client_request_token (Optional[IdempotencyToken], default: None ) –

    A unique, case-sensitive identifier to ensure that the API request completes no more than once. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see Ensuring idempotency in the Amazon S3 User Guide.

Raises:

Source code in docs_src/capo_bedrock/_services/async_bedrock.py
async def create_guardrail_version(
    self,
    guardrail_identifier: "capo_bedrock.types.guardrail_identifier.GuardrailIdentifier",
    *,
    config_overrides: Optional[AsyncBedrockClientConfig] = None,
    description: Optional[
        "capo_bedrock.types.guardrail_description.GuardrailDescription"
    ] = None,
    client_request_token: Optional[
        "capo_bedrock.types.idempotency_token.IdempotencyToken"
    ] = None,
) -> "capo_bedrock.types.create_guardrail_version_response.CreateGuardrailVersionResponse":
    """<p>Creates a version of the guardrail. Use this API to create a snapshot of the guardrail when you are satisfied with a configuration, or to compare the configuration with another version.</p>

    Args:
        guardrail_identifier: <p>The unique identifier of the guardrail. This can be an ID or the ARN.</p>
        description: <p>A description of the guardrail version.</p>
        client_request_token: <p>A unique, case-sensitive identifier to ensure that the API request completes no more than once. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a> in the <i>Amazon S3 User Guide</i>.</p>

    Raises:
        capo_bedrock.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because of missing access permissions.</p>
        capo_bedrock.errors.conflict_exception.ConflictException: <p>Error occurred because of a conflict while performing an operation.</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.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The number of requests exceeds the service quota. Resubmit your request later.</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.create_guardrail_version_request.CreateGuardrailVersionRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock.types.create_guardrail_version_response.CreateGuardrailVersionResponse"
    ]:
        import capo_bedrock._operations.amazon_bedrock_control_plane_service.create_guardrail_version

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

    def _redact_input(
        input_: "capo_bedrock.types.create_guardrail_version_request.CreateGuardrailVersionRequest",
    ) -> dict[str, Any]:
        import capo_bedrock.types.create_guardrail_version_request

        return capo_bedrock.types.create_guardrail_version_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateGuardrailVersion", redact_input=_redact_input),
    )
    input_: capo_bedrock.types.create_guardrail_version_request.CreateGuardrailVersionRequest = {
        "guardrail_identifier": guardrail_identifier
    }
    if description is not None:
        input_["description"] = description
    if client_request_token is None:
        client_request_token = str(uuid.uuid4())
    input_["client_request_token"] = client_request_token

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