Skip to content

update_ai_guardrail async

update_ai_guardrail(
    assistant_id: UuidOrArn,
    ai_guardrail_id: UuidOrArnOrEitherWithQualifier,
    visibility_status: VisibilityStatus,
    blocked_input_messaging: AIGuardrailBlockedMessaging,
    blocked_outputs_messaging: AIGuardrailBlockedMessaging,
    *,
    config_overrides: Optional[AsyncQConnectClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    description: Optional[AIGuardrailDescription] = None,
    topic_policy_config: Optional[AIGuardrailTopicPolicyConfig] = None,
    content_policy_config: Optional[AIGuardrailContentPolicyConfig] = None,
    word_policy_config: Optional[AIGuardrailWordPolicyConfig] = None,
    sensitive_information_policy_config: Optional[
        AIGuardrailSensitiveInformationPolicyConfig
    ] = None,
    contextual_grounding_policy_config: Optional[
        AIGuardrailContextualGroundingPolicyConfig
    ] = None,
) -> UpdateAIGuardrailResponse

Updates an AI Guardrail.

Parameters:

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

  • ConflictException –

    The request could not be processed because of conflict in the current state of the resource. For example, if you're using a Create API (such as CreateAssistant) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.

  • ResourceNotFoundException –

    The specified resource does not exist.

  • ThrottlingException –

    The throttling limit has been exceeded.

  • UnauthorizedException –

    You do not have permission to perform this action.

  • ValidationException –

    The input fails to satisfy the constraints specified by a service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_qconnect/_services/async_q_connect.py
async def update_ai_guardrail(
    self,
    assistant_id: "capo_qconnect.types.uuid_or_arn.UuidOrArn",
    ai_guardrail_id: "capo_qconnect.types.uuid_or_arn_or_either_with_qualifier.UuidOrArnOrEitherWithQualifier",
    visibility_status: "capo_qconnect.types.visibility_status.VisibilityStatus",
    blocked_input_messaging: "capo_qconnect.types.ai_guardrail_blocked_messaging.AIGuardrailBlockedMessaging",
    blocked_outputs_messaging: "capo_qconnect.types.ai_guardrail_blocked_messaging.AIGuardrailBlockedMessaging",
    *,
    config_overrides: Optional[AsyncQConnectClientConfig] = None,
    client_token: Optional["capo_qconnect.types.client_token.ClientToken"] = None,
    description: Optional[
        "capo_qconnect.types.ai_guardrail_description.AIGuardrailDescription"
    ] = None,
    topic_policy_config: Optional[
        "capo_qconnect.types.ai_guardrail_topic_policy_config.AIGuardrailTopicPolicyConfig"
    ] = None,
    content_policy_config: Optional[
        "capo_qconnect.types.ai_guardrail_content_policy_config.AIGuardrailContentPolicyConfig"
    ] = None,
    word_policy_config: Optional[
        "capo_qconnect.types.ai_guardrail_word_policy_config.AIGuardrailWordPolicyConfig"
    ] = None,
    sensitive_information_policy_config: Optional[
        "capo_qconnect.types.ai_guardrail_sensitive_information_policy_config.AIGuardrailSensitiveInformationPolicyConfig"
    ] = None,
    contextual_grounding_policy_config: Optional[
        "capo_qconnect.types.ai_guardrail_contextual_grounding_policy_config.AIGuardrailContextualGroundingPolicyConfig"
    ] = None,
) -> "capo_qconnect.types.update_ai_guardrail_response.UpdateAIGuardrailResponse":
    """<p>Updates an AI Guardrail.</p>

    Args:
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see <a href="http://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/">Making retries safe with idempotent APIs</a>..</p>
        assistant_id: <p>The identifier of the Amazon Q in Connect assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
        ai_guardrail_id: <p>The identifier of the Amazon Q in Connect AI Guardrail.</p>
        visibility_status: <p>The visibility status of the Amazon Q in Connect AI Guardrail.</p>
        blocked_input_messaging: <p>The message to return when the AI Guardrail blocks a prompt.</p>
        blocked_outputs_messaging: <p>The message to return when the AI Guardrail blocks a model response.</p>
        description: <p>A description of the AI Guardrail.</p>
        topic_policy_config: <p>The topic policies to configure for the AI Guardrail.</p>
        content_policy_config: <p>The content filter policies to configure for the AI Guardrail.</p>
        word_policy_config: <p>The word policy you configure for the AI Guardrail.</p>
        sensitive_information_policy_config: <p>The sensitive information policy to configure for the AI Guardrail.</p>
        contextual_grounding_policy_config: <p>The contextual grounding policy configuration used to create an AI Guardrail.</p>

    Raises:
        capo_qconnect.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_qconnect.errors.conflict_exception.ConflictException: <p>The request could not be processed because of conflict in the current state of the resource. For example, if you're using a <code>Create</code> API (such as <code>CreateAssistant</code>) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.</p>
        capo_qconnect.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_qconnect.errors.throttling_exception.ThrottlingException: <p>The throttling limit has been exceeded.</p>
        capo_qconnect.errors.unauthorized_exception.UnauthorizedException: <p>You do not have permission to perform this action.</p>
        capo_qconnect.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by a service.</p>
        capo_qconnect.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_qconnect.types.update_ai_guardrail_request.UpdateAIGuardrailRequest]",
    ) -> AsyncOperationResponse[
        "capo_qconnect.types.update_ai_guardrail_response.UpdateAIGuardrailResponse"
    ]:
        import capo_qconnect._operations.wisdom_service.update_ai_guardrail

        (
            output,
            http_response,
        ) = await capo_qconnect._operations.wisdom_service.update_ai_guardrail.async_update_ai_guardrail(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_qconnect.types.update_ai_guardrail_request.UpdateAIGuardrailRequest",
    ) -> dict[str, Any]:
        import capo_qconnect.types.update_ai_guardrail_request

        return capo_qconnect.types.update_ai_guardrail_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_qconnect.types.update_ai_guardrail_response.UpdateAIGuardrailResponse",
    ) -> dict[str, Any]:
        import capo_qconnect.types.update_ai_guardrail_response

        return capo_qconnect.types.update_ai_guardrail_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "UpdateAIGuardrail",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_qconnect.types.update_ai_guardrail_request.UpdateAIGuardrailRequest = {
        "assistant_id": assistant_id,
        "ai_guardrail_id": ai_guardrail_id,
        "visibility_status": visibility_status,
        "blocked_input_messaging": blocked_input_messaging,
        "blocked_outputs_messaging": blocked_outputs_messaging,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    if topic_policy_config is not None:
        input_["topic_policy_config"] = topic_policy_config
    if content_policy_config is not None:
        input_["content_policy_config"] = content_policy_config
    if word_policy_config is not None:
        input_["word_policy_config"] = word_policy_config
    if sensitive_information_policy_config is not None:
        input_["sensitive_information_policy_config"] = (
            sensitive_information_policy_config
        )
    if contextual_grounding_policy_config is not None:
        input_["contextual_grounding_policy_config"] = (
            contextual_grounding_policy_config
        )

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