1
1
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
3
3
from .basesdk import BaseSDK
4
+ from enum import Enum
4
5
from typing import Any , Dict , List , Optional , Union , cast
5
6
from unstructured_client import utils
6
7
from unstructured_client ._hooks import HookContext
7
8
from unstructured_client .models import errors , operations , shared
8
9
from unstructured_client .types import BaseModel , OptionalNullable , UNSET
9
10
10
11
12
+ class PartitionAcceptEnum (str , Enum ):
13
+ APPLICATION_JSON = "application/json"
14
+ TEXT_CSV = "text/csv"
15
+
16
+
11
17
class General (BaseSDK ):
12
18
def partition (
13
19
self ,
@@ -18,6 +24,7 @@ def partition(
18
24
retries : OptionalNullable [utils .RetryConfig ] = UNSET ,
19
25
server_url : Optional [str ] = None ,
20
26
timeout_ms : Optional [int ] = None ,
27
+ accept_header_override : Optional [PartitionAcceptEnum ] = None ,
21
28
) -> operations .PartitionResponse :
22
29
r"""Summary
23
30
@@ -27,6 +34,7 @@ def partition(
27
34
:param retries: Override the default retry configuration for this method
28
35
:param server_url: Override the default server URL for this method
29
36
: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
30
38
"""
31
39
base_url = None
32
40
url_variables = None
@@ -50,7 +58,9 @@ def partition(
50
58
request_has_path_params = False ,
51
59
request_has_query_params = True ,
52
60
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" ,
54
64
security = self .sdk_configuration .security ,
55
65
get_serialized_body = lambda : utils .serialize_request_body (
56
66
request .partition_parameters ,
@@ -95,6 +105,13 @@ def partition(
95
105
content_type = http_res .headers .get ("Content-Type" ) or "" ,
96
106
raw_response = http_res ,
97
107
)
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
+ )
98
115
if utils .match_response (http_res , "422" , "application/json" ):
99
116
data = utils .unmarshal_json (http_res .text , errors .HTTPValidationErrorData )
100
117
raise errors .HTTPValidationError (data = data )
@@ -125,6 +142,7 @@ async def partition_async(
125
142
retries : OptionalNullable [utils .RetryConfig ] = UNSET ,
126
143
server_url : Optional [str ] = None ,
127
144
timeout_ms : Optional [int ] = None ,
145
+ accept_header_override : Optional [PartitionAcceptEnum ] = None ,
128
146
) -> operations .PartitionResponse :
129
147
r"""Summary
130
148
@@ -134,6 +152,7 @@ async def partition_async(
134
152
:param retries: Override the default retry configuration for this method
135
153
:param server_url: Override the default server URL for this method
136
154
: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
137
156
"""
138
157
base_url = None
139
158
url_variables = None
@@ -157,7 +176,9 @@ async def partition_async(
157
176
request_has_path_params = False ,
158
177
request_has_query_params = True ,
159
178
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" ,
161
182
security = self .sdk_configuration .security ,
162
183
get_serialized_body = lambda : utils .serialize_request_body (
163
184
request .partition_parameters ,
@@ -202,6 +223,13 @@ async def partition_async(
202
223
content_type = http_res .headers .get ("Content-Type" ) or "" ,
203
224
raw_response = http_res ,
204
225
)
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
+ )
205
233
if utils .match_response (http_res , "422" , "application/json" ):
206
234
data = utils .unmarshal_json (http_res .text , errors .HTTPValidationErrorData )
207
235
raise errors .HTTPValidationError (data = data )
0 commit comments