Skip to main content

Add Patch Operation

Description

The add_patch_operation function adds a new patch operation to a list of operations. Each patch operation represents a field update (e.g., for use in a PATCH API call).

Function Signature:

def add_patch_operation(operations: list, field_name: str, value: str | int) -> list:

Parameters

  • operations (list): A list to which the new patch operation will be added.
  • field_name (str): The name of the field being patched.
  • value (str | int): The new value to apply to the field.

Returns

  • list: The updated list of patch operations.

Example Usage

operations = []
operations = add_patch_operation(operations, "firmwareVersion", "1.2.3")

Behavior

  • Instantiates a new PatchOperation with the provided field_name and value.
  • Appends the operation to the provided list of operations.
  • Returns the updated list.

Error Handling

  • This function assumes valid input and does not implement internal exception handling.
  • It relies on the correctness of the PatchOperation class and type safety provided by the calling context.