Skip to content

update_function async

update_function(
    id: FunctionId,
    *,
    config_overrides: Optional[AsyncElementalInferenceClientConfig] = None,
    name: Optional[ResourceName] = None,
    target: Optional[FunctionTarget] = None,
    request_expression: Optional[JsonataExpression] = None,
    response_expression: Optional[JsonataExpression] = None,
    description: Optional[FunctionDescription] = None,
    event_bridge_delivery: Optional[EventBridgeDeliveryMode] = None,
) -> UpdateFunctionResponse

Updates a function. Include only the parameters that you want to change; parameters that you don't include aren't affected. Elemental Inference validates the updated expressions in the same way as CreateFunction.

While a feed references the function, you can change only its expressions and its description, and you can set eventBridgeDelivery to DISABLED but not to ENABLED. The request expression must keep referencing the same media context, as reported in contextTypes. Changing an expression changes the behavior of every feed that references the function.

Parameters:

  • id (FunctionId) –

    The ID of the function.

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

    A new name for the function. You can't change the name while the function is referenced by a feed.

  • target (Optional[FunctionTarget], default: None ) –

    A new target for the function. You can't change the target while the function is referenced by a feed.

  • request_expression (Optional[JsonataExpression], default: None ) –

    A new request expression for the function. Elemental Inference derives contextTypes again from the new expression. While a feed references the function, the new expression must reference the same media context as the current one.

  • response_expression (Optional[JsonataExpression], default: None ) –

    A new response expression for the function. To remove the response expression, specify an empty string. A function with a Bedrock target and eventBridgeDelivery set to ENABLED must keep a response expression.

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

    A new description for the function.

  • event_bridge_delivery (Optional[EventBridgeDeliveryMode], default: None ) –

    Specifies whether Elemental Inference also sends this function's marked results to Amazon EventBridge, as described for CreateFunction. If you omit this parameter, the current value is kept. While a feed references the function, you can change this value to DISABLED, but not to ENABLED.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

  • ConflictException –

    The request could not be completed due to a conflict.

  • InternalServerErrorException –

    An internal server error occurred. This is a temporary condition and the request can be retried. If the problem persists, contact AWS Support.

  • ResourceNotFoundException –

    The resource specified in the action doesn't exist.

  • TooManyRequestException –

    The request was denied due to request throttling. Too many requests have been made within a given time period. Reduce the frequency of requests and use exponential backoff when retrying.

  • ValidationException –

    The input fails to satisfy the constraints specified by the service. Check the error message for details about which parameter or field is invalid and correct the request before retrying.

  • UnknownServiceError –

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

Source code in docs_src/capo_elementalinference/_services/async_elemental_inference.py
async def update_function(
    self,
    id: "capo_elementalinference.types.function_id.FunctionId",
    *,
    config_overrides: Optional[AsyncElementalInferenceClientConfig] = None,
    name: Optional[
        "capo_elementalinference.types.resource_name.ResourceName"
    ] = None,
    target: Optional[
        "capo_elementalinference.types.function_target.FunctionTarget"
    ] = None,
    request_expression: Optional[
        "capo_elementalinference.types.jsonata_expression.JsonataExpression"
    ] = None,
    response_expression: Optional[
        "capo_elementalinference.types.jsonata_expression.JsonataExpression"
    ] = None,
    description: Optional[
        "capo_elementalinference.types.function_description.FunctionDescription"
    ] = None,
    event_bridge_delivery: Optional[
        "capo_elementalinference.types.event_bridge_delivery_mode.EventBridgeDeliveryMode"
    ] = None,
) -> (
    "capo_elementalinference.types.update_function_response.UpdateFunctionResponse"
):
    """<p>Updates a function. Include only the parameters that you want to change; parameters that you don't include aren't affected. Elemental Inference validates the updated expressions in the same way as CreateFunction. </p> <p>While a feed references the function, you can change only its expressions and its description, and you can set eventBridgeDelivery to DISABLED but not to ENABLED. The request expression must keep referencing the same media context, as reported in contextTypes. Changing an expression changes the behavior of every feed that references the function. </p>

    Args:
        id: <p>The ID of the function.</p>
        name: <p>A new name for the function. You can't change the name while the function is referenced by a feed. </p>
        target: <p>A new target for the function. You can't change the target while the function is referenced by a feed. </p>
        request_expression: <p>A new request expression for the function. Elemental Inference derives contextTypes again from the new expression. While a feed references the function, the new expression must reference the same media context as the current one. </p>
        response_expression: <p>A new response expression for the function. To remove the response expression, specify an empty string. A function with a Bedrock target and eventBridgeDelivery set to ENABLED must keep a response expression. </p>
        description: <p>A new description for the function.</p>
        event_bridge_delivery: <p>Specifies whether Elemental Inference also sends this function's marked results to Amazon EventBridge, as described for CreateFunction. If you omit this parameter, the current value is kept. While a feed references the function, you can change this value to DISABLED, but not to ENABLED. </p>

    Raises:
        capo_elementalinference.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_elementalinference.errors.conflict_exception.ConflictException: <p>The request could not be completed due to a conflict.</p>
        capo_elementalinference.errors.internal_server_error_exception.InternalServerErrorException: <p>An internal server error occurred. This is a temporary condition and the request can be retried. If the problem persists, contact AWS Support. </p>
        capo_elementalinference.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the action doesn't exist.</p>
        capo_elementalinference.errors.too_many_request_exception.TooManyRequestException: <p>The request was denied due to request throttling. Too many requests have been made within a given time period. Reduce the frequency of requests and use exponential backoff when retrying. </p>
        capo_elementalinference.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service. Check the error message for details about which parameter or field is invalid and correct the request before retrying. </p>
        capo_elementalinference.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_elementalinference.types.update_function_request.UpdateFunctionRequest]",
    ) -> AsyncOperationResponse[
        "capo_elementalinference.types.update_function_response.UpdateFunctionResponse"
    ]:
        import capo_elementalinference._operations.elemental_inference.update_function

        (
            output,
            http_response,
        ) = await capo_elementalinference._operations.elemental_inference.update_function.async_update_function(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_elementalinference.types.update_function_request.UpdateFunctionRequest",
    ) -> dict[str, Any]:
        import capo_elementalinference.types.update_function_request

        return (
            capo_elementalinference.types.update_function_request.redact_sensitive(
                input_
            )
        )

    def _redact_output(
        output: "capo_elementalinference.types.update_function_response.UpdateFunctionResponse",
    ) -> dict[str, Any]:
        import capo_elementalinference.types.update_function_response

        return (
            capo_elementalinference.types.update_function_response.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "UpdateFunction",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_elementalinference.types.update_function_request.UpdateFunctionRequest = {
        "id": id
    }
    if name is not None:
        input_["name"] = name
    if target is not None:
        input_["target"] = target
    if request_expression is not None:
        input_["request_expression"] = request_expression
    if response_expression is not None:
        input_["response_expression"] = response_expression
    if description is not None:
        input_["description"] = description
    if event_bridge_delivery is not None:
        input_["event_bridge_delivery"] = event_bridge_delivery

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