diff --git a/src/unstract/api_deployments/client.py b/src/unstract/api_deployments/client.py index 575feef..9757066 100644 --- a/src/unstract/api_deployments/client.py +++ b/src/unstract/api_deployments/client.py @@ -10,6 +10,7 @@ import logging import ntpath import os +import json from urllib.parse import urlparse import requests @@ -99,11 +100,12 @@ def __save_base_url(self, full_url: str): self.base_url = parsed_url.scheme + "://" + parsed_url.netloc self.logger.debug("Base URL: " + self.base_url) - def structure_file(self, file_paths: list[str]) -> dict: + def structure_file(self, file_paths: list[str], custom_data: dict = None) -> dict: """Invokes the API deployed on the Unstract platform. Args: file_paths (list[str]): The file path to the file to be uploaded. + custom_data (dict, optional): Custom data to send with the request. Returns: dict: The response from the API. @@ -116,6 +118,10 @@ def structure_file(self, file_paths: list[str]) -> dict: } data = {"timeout": self.api_timeout, "include_metadata": self.include_metadata} + # Add custom_data if provided + if custom_data is not None: + data["custom_data"] = json.dumps(custom_data) if isinstance(custom_data, dict) else custom_data + self.logger.debug("Custom data added to request") files = [] @@ -271,4 +277,4 @@ def check_execution_status(self, status_check_api_endpoint: str) -> dict: ): obj_to_return["pending"] = True - return obj_to_return + return obj_to_return \ No newline at end of file