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 ,
@@ -88,13 +98,21 @@ def partition(
8898 data : Any = None
8999 if utils .match_response (http_res , "200" , "application/json" ):
90100 return operations .PartitionResponse (
91- elements = utils .unmarshal_json (
101+ two_hundred_application_json_elements = utils .unmarshal_json (
92102 http_res .text , Optional [List [Dict [str , Any ]]]
93103 ),
94104 status_code = http_res .status_code ,
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+ http_res_bytes = utils .stream_to_bytes (http_res )
110+ return operations .PartitionResponse (
111+ body = http_res_bytes ,
112+ status_code = http_res .status_code ,
113+ content_type = http_res .headers .get ("Content-Type" ) or "" ,
114+ raw_response = http_res ,
115+ )
98116 if utils .match_response (http_res , "422" , "application/json" ):
99117 data = utils .unmarshal_json (http_res .text , errors .HTTPValidationErrorData )
100118 raise errors .HTTPValidationError (data = data )
@@ -125,6 +143,7 @@ async def partition_async(
125143 retries : OptionalNullable [utils .RetryConfig ] = UNSET ,
126144 server_url : Optional [str ] = None ,
127145 timeout_ms : Optional [int ] = None ,
146+ accept_header_override : Optional [PartitionAcceptEnum ] = None ,
128147 ) -> operations .PartitionResponse :
129148 r"""Summary
130149
@@ -134,6 +153,7 @@ async def partition_async(
134153 :param retries: Override the default retry configuration for this method
135154 :param server_url: Override the default server URL for this method
136155 :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
156+ :param accept_header_override: Override the default accept header for this method
137157 """
138158 base_url = None
139159 url_variables = None
@@ -157,7 +177,9 @@ async def partition_async(
157177 request_has_path_params = False ,
158178 request_has_query_params = True ,
159179 user_agent_header = "user-agent" ,
160- accept_header_value = "application/json" ,
180+ accept_header_value = accept_header_override .value
181+ if accept_header_override is not None
182+ else "application/json;q=1, text/csv;q=0" ,
161183 security = self .sdk_configuration .security ,
162184 get_serialized_body = lambda : utils .serialize_request_body (
163185 request .partition_parameters ,
@@ -195,13 +217,21 @@ async def partition_async(
195217 data : Any = None
196218 if utils .match_response (http_res , "200" , "application/json" ):
197219 return operations .PartitionResponse (
198- elements = utils .unmarshal_json (
220+ two_hundred_application_json_elements = utils .unmarshal_json (
199221 http_res .text , Optional [List [Dict [str , Any ]]]
200222 ),
201223 status_code = http_res .status_code ,
202224 content_type = http_res .headers .get ("Content-Type" ) or "" ,
203225 raw_response = http_res ,
204226 )
227+ if utils .match_response (http_res , "200" , "text/csv" ):
228+ http_res_bytes = await utils .stream_to_bytes_async (http_res )
229+ return operations .PartitionResponse (
230+ body = http_res_bytes ,
231+ status_code = http_res .status_code ,
232+ content_type = http_res .headers .get ("Content-Type" ) or "" ,
233+ raw_response = http_res ,
234+ )
205235 if utils .match_response (http_res , "422" , "application/json" ):
206236 data = utils .unmarshal_json (http_res .text , errors .HTTPValidationErrorData )
207237 raise errors .HTTPValidationError (data = data )
0 commit comments