Skip to main content

Update File ID

Description

The update_file_id function updates the FileID associated with a specific video clip record. This operation uses a JSON Patch-style request to make a partial update on the clip metadata.

Function Signature:

def update_file_id(ws_config: WebServiceConfig, video_clip_id: int, file_id: int) -> tuple[int, str]:

Parameters

  • ws_config (WebServiceConfig): Configuration object for the web service.
  • video_clip_id (int): The ID of the video clip to be updated.
  • file_id (int): The new file ID to associate with the video clip.

Returns

  • tuple[int, str]: A tuple with:
    • int: The HTTP response code from the server.
    • str: The HTTP response body, which may contain status or error messages.

Example Usage

ws_config = WebServiceConfig(base_url="https://api.actionstreamer.com")
video_clip_id = 1001
file_id = 2002

response_code, response_string = update_file_id(ws_config, video_clip_id, file_id)
print(response_code, response_string)

Behavior

  • Constructs a list of patch operations to update the FileID.
  • Converts the patch list to JSON format.
  • Sends a PATCH request to v1/videoclip/{video_clip_id} with the patch body.
  • Returns the web service response indicating the result of the operation.

Error Handling

  • On exception:
    • Sets response_code to -1.
    • Generates a response_string indicating the line number of the failure.
    • Prints debugging information to the console.