Skip to content

update_ab_test

update_ab_test(
    ab_test_id: ABTestId,
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    name: Optional[ABTestName] = None,
    description: Optional[ABTestDescription] = None,
    variants: Optional[VariantList] = None,
    gateway_filter: Optional[GatewayFilter] = None,
    evaluation_config: Optional[ABTestEvaluationConfig] = None,
    role_arn: Optional[RoleArn] = None,
    execution_status: Optional[ABTestExecutionStatus] = None,
) -> UpdateABTestResponse

Updates an A/B test's configuration, including variants, traffic allocation, evaluation settings, or execution status.

Parameters:

  • ab_test_id (ABTestId) –

    The unique identifier of the A/B test to update.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, the service ignores the request, but does not return an error.

  • name (Optional[ABTestName], default: None ) –

    The updated name of the A/B test.

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

    The updated description of the A/B test.

  • variants (Optional[VariantList], default: None ) –

    The updated list of variants.

  • gateway_filter (Optional[GatewayFilter], default: None ) –

    The updated gateway filter.

  • evaluation_config (Optional[ABTestEvaluationConfig], default: None ) –

    The updated evaluation configuration.

  • role_arn (Optional[RoleArn], default: None ) –

    The updated IAM role ARN.

  • execution_status (Optional[ABTestExecutionStatus], default: None ) –

    The updated execution status to enable or disable the A/B test.

Raises:

  • AccessDeniedException –

    The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.

  • ConflictException –

    The exception that occurs when the request conflicts with the current state of the resource. This can happen when trying to modify a resource that is currently being modified by another request, or when trying to create a resource that already exists.

  • InternalServerException –

    The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.

  • ResourceNotFoundException –

    The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.

  • ServiceQuotaExceededException –

    The exception that occurs when the request would cause a service quota to be exceeded. Review your service quotas and either reduce your request rate or request a quota increase.

  • ThrottlingException –

    The exception that occurs when the request was denied due to request throttling. This happens when you exceed the allowed request rate for an operation. Reduce the frequency of requests or implement exponential backoff retry logic in your application.

  • UnauthorizedException –

    This exception is thrown when the JWT bearer token is invalid or not found for OAuth bearer token based access

  • ValidationException –

    The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.

  • UnknownServiceError –

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

Source code in docs_src/capo_bedrock_agentcore/_services/bedrock_agent_core.py
def update_ab_test(
    self,
    ab_test_id: "capo_bedrock_agentcore.types.ab_test_id.ABTestId",
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    client_token: Optional[
        "capo_bedrock_agentcore.types.client_token.ClientToken"
    ] = None,
    name: Optional["capo_bedrock_agentcore.types.ab_test_name.ABTestName"] = None,
    description: Optional[
        "capo_bedrock_agentcore.types.ab_test_description.ABTestDescription"
    ] = None,
    variants: Optional[
        "capo_bedrock_agentcore.types.variant_list.VariantList"
    ] = None,
    gateway_filter: Optional[
        "capo_bedrock_agentcore.types.gateway_filter.GatewayFilter"
    ] = None,
    evaluation_config: Optional[
        "capo_bedrock_agentcore.types.ab_test_evaluation_config.ABTestEvaluationConfig"
    ] = None,
    role_arn: Optional["capo_bedrock_agentcore.types.role_arn.RoleArn"] = None,
    execution_status: Optional[
        "capo_bedrock_agentcore.types.ab_test_execution_status.ABTestExecutionStatus"
    ] = None,
) -> "capo_bedrock_agentcore.types.update_ab_test_response.UpdateABTestResponse":
    """<p>Updates an A/B test's configuration, including variants, traffic allocation, evaluation settings, or execution status.</p>

    Args:
        ab_test_id: <p>The unique identifier of the A/B test to update.</p>
        client_token: <p>A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, the service ignores the request, but does not return an error.</p>
        name: <p>The updated name of the A/B test.</p>
        description: <p>The updated description of the A/B test.</p>
        variants: <p>The updated list of variants.</p>
        gateway_filter: <p>The updated gateway filter.</p>
        evaluation_config: <p>The updated evaluation configuration.</p>
        role_arn: <p>The updated IAM role ARN.</p>
        execution_status: <p>The updated execution status to enable or disable the A/B test.</p>

    Raises:
        capo_bedrock_agentcore.errors.access_denied_exception.AccessDeniedException: <p>The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.</p>
        capo_bedrock_agentcore.errors.conflict_exception.ConflictException: <p>The exception that occurs when the request conflicts with the current state of the resource. This can happen when trying to modify a resource that is currently being modified by another request, or when trying to create a resource that already exists.</p>
        capo_bedrock_agentcore.errors.internal_server_exception.InternalServerException: <p>The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.</p>
        capo_bedrock_agentcore.errors.resource_not_found_exception.ResourceNotFoundException: <p>The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.</p>
        capo_bedrock_agentcore.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The exception that occurs when the request would cause a service quota to be exceeded. Review your service quotas and either reduce your request rate or request a quota increase.</p>
        capo_bedrock_agentcore.errors.throttling_exception.ThrottlingException: <p>The exception that occurs when the request was denied due to request throttling. This happens when you exceed the allowed request rate for an operation. Reduce the frequency of requests or implement exponential backoff retry logic in your application.</p>
        capo_bedrock_agentcore.errors.unauthorized_exception.UnauthorizedException: <p>This exception is thrown when the JWT bearer token is invalid or not found for OAuth bearer token based access</p>
        capo_bedrock_agentcore.errors.validation_exception.ValidationException: <p>The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.</p>
        capo_bedrock_agentcore.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock_agentcore.types.update_ab_test_request.UpdateABTestRequest]",
    ) -> OperationResponse[
        "capo_bedrock_agentcore.types.update_ab_test_response.UpdateABTestResponse"
    ]:
        import capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.update_ab_test

        output, http_response = (
            capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.update_ab_test.update_ab_test(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateABTest")
    )
    input_: capo_bedrock_agentcore.types.update_ab_test_request.UpdateABTestRequest = {
        "ab_test_id": ab_test_id
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if variants is not None:
        input_["variants"] = variants
    if gateway_filter is not None:
        input_["gateway_filter"] = gateway_filter
    if evaluation_config is not None:
        input_["evaluation_config"] = evaluation_config
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if execution_status is not None:
        input_["execution_status"] = execution_status

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output