11"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
22
33from .basesdk import BaseSDK
4+ from enum import Enum
45from typing import Any , Dict , List , Optional , Union , cast
56from unstructured_client import utils
67from unstructured_client ._hooks import HookContext
78from unstructured_client .models import errors , operations , shared
89from unstructured_client .types import BaseModel , OptionalNullable , UNSET
910
1011
12+ class PartitionAcceptEnum (str , Enum ):
13+ APPLICATION_JSON = "application/json"
14+ TEXT_CSV = "text/csv"
15+
16+
1117class General (BaseSDK ):
1218 def partition (
1319 self ,
@@ -18,6 +24,7 @@ def partition(
1824 retries : OptionalNullable [utils .RetryConfig ] = UNSET ,
1925 server_url : Optional [str ] = None ,
2026 timeout_ms : Optional [int ] = None ,
27+ accept_header_override : Optional [PartitionAcceptEnum ] = None ,
2128 ) -> operations .PartitionResponse :
2229 r"""Summary
2330
@@ -27,6 +34,7 @@ def partition(
2734 :param retries: Override the default retry configuration for this method
2835 :param server_url: Override the default server URL for this method
2936 :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
37+ :param accept_header_override: Override the default accept header for this method
3038 """
3139 base_url = None
3240 url_variables = None
@@ -50,7 +58,9 @@ def partition(
5058 request_has_path_params = False ,
5159 request_has_query_params = True ,
5260 user_agent_header = "user-agent" ,
53- accept_header_value = "application/json" ,
61+ accept_header_value = accept_header_override .value
62+ if accept_header_override is not None
63+ else "application/json;q=1, text/csv;q=0" ,
5464 security = self .sdk_configuration .security ,
5565 get_serialized_body = lambda : utils .serialize_request_body (
5666 request .partition_parameters ,
@@ -95,6 +105,13 @@ def partition(
95105 content_type = http_res .headers .get ("Content-Type" ) or "" ,
96106 raw_response = http_res ,
97107 )
108+ if utils .match_response (http_res , "200" , "text/csv" ):
109+ return operations .PartitionResponse (
110+ csv_elements = http_res .text ,
111+ status_code = http_res .status_code ,
112+ content_type = http_res .headers .get ("Content-Type" ) or "" ,
113+ raw_response = http_res ,
114+ )
98115 if utils .match_response (http_res , "422" , "application/json" ):
99116 data = utils .unmarshal_json (http_res .text , errors .HTTPValidationErrorData )
100117 raise errors .HTTPValidationError (data = data )
@@ -125,6 +142,7 @@ async def partition_async(
125142 retries : OptionalNullable [utils .RetryConfig ] = UNSET ,
126143 server_url : Optional [str ] = None ,
127144 timeout_ms : Optional [int ] = None ,
145+ accept_header_override : Optional [PartitionAcceptEnum ] = None ,
128146 ) -> operations .PartitionResponse :
129147 r"""Summary
130148
@@ -134,6 +152,7 @@ async def partition_async(
134152 :param retries: Override the default retry configuration for this method
135153 :param server_url: Override the default server URL for this method
136154 :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
155+ :param accept_header_override: Override the default accept header for this method
137156 """
138157 base_url = None
139158 url_variables = None
@@ -157,7 +176,9 @@ async def partition_async(
157176 request_has_path_params = False ,
158177 request_has_query_params = True ,
159178 user_agent_header = "user-agent" ,
160- accept_header_value = "application/json" ,
179+ accept_header_value = accept_header_override .value
180+ if accept_header_override is not None
181+ else "application/json;q=1, text/csv;q=0" ,
161182 security = self .sdk_configuration .security ,
162183 get_serialized_body = lambda : utils .serialize_request_body (
163184 request .partition_parameters ,
@@ -202,6 +223,13 @@ async def partition_async(
202223 content_type = http_res .headers .get ("Content-Type" ) or "" ,
203224 raw_response = http_res ,
204225 )
226+ if utils .match_response (http_res , "200" , "text/csv" ):
227+ return operations .PartitionResponse (
228+ csv_elements = http_res .text ,
229+ status_code = http_res .status_code ,
230+ content_type = http_res .headers .get ("Content-Type" ) or "" ,
231+ raw_response = http_res ,
232+ )
205233 if utils .match_response (http_res , "422" , "application/json" ):
206234 data = utils .unmarshal_json (http_res .text , errors .HTTPValidationErrorData )
207235 raise errors .HTTPValidationError (data = data )
0 commit comments