unstructured-transform-client 0.18.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. unstructured_transform_client/__init__.py +28 -0
  2. unstructured_transform_client/_client.py +420 -0
  3. unstructured_transform_client/_files.py +72 -0
  4. unstructured_transform_client/_generated/__init__.py +100 -0
  5. unstructured_transform_client/_generated/api/__init__.py +8 -0
  6. unstructured_transform_client/_generated/api/extract_api.py +351 -0
  7. unstructured_transform_client/_generated/api/jobs_api.py +1212 -0
  8. unstructured_transform_client/_generated/api/parse_api.py +461 -0
  9. unstructured_transform_client/_generated/api/upload_api.py +868 -0
  10. unstructured_transform_client/_generated/api_client.py +833 -0
  11. unstructured_transform_client/_generated/api_response.py +21 -0
  12. unstructured_transform_client/_generated/configuration.py +688 -0
  13. unstructured_transform_client/_generated/exceptions.py +218 -0
  14. unstructured_transform_client/_generated/models/__init__.py +39 -0
  15. unstructured_transform_client/_generated/models/citation.py +95 -0
  16. unstructured_transform_client/_generated/models/document_metadata.py +93 -0
  17. unstructured_transform_client/_generated/models/element.py +103 -0
  18. unstructured_transform_client/_generated/models/element_metadata.py +107 -0
  19. unstructured_transform_client/_generated/models/error.py +91 -0
  20. unstructured_transform_client/_generated/models/error_code.py +58 -0
  21. unstructured_transform_client/_generated/models/extract_request.py +92 -0
  22. unstructured_transform_client/_generated/models/extraction_result.py +107 -0
  23. unstructured_transform_client/_generated/models/field_metadata.py +92 -0
  24. unstructured_transform_client/_generated/models/job_accepted.py +134 -0
  25. unstructured_transform_client/_generated/models/job_operation.py +37 -0
  26. unstructured_transform_client/_generated/models/job_page.py +102 -0
  27. unstructured_transform_client/_generated/models/job_result.py +130 -0
  28. unstructured_transform_client/_generated/models/job_result_state.py +38 -0
  29. unstructured_transform_client/_generated/models/job_status.py +41 -0
  30. unstructured_transform_client/_generated/models/job_summary.py +141 -0
  31. unstructured_transform_client/_generated/models/locator.py +99 -0
  32. unstructured_transform_client/_generated/models/output_format.py +37 -0
  33. unstructured_transform_client/_generated/models/parse_result.py +173 -0
  34. unstructured_transform_client/_generated/models/source_file.py +115 -0
  35. unstructured_transform_client/_generated/models/transform_status.py +38 -0
  36. unstructured_transform_client/_generated/models/transform_warning.py +90 -0
  37. unstructured_transform_client/_generated/models/upload_result.py +93 -0
  38. unstructured_transform_client/_generated/py.typed +0 -0
  39. unstructured_transform_client/_generated/rest.py +334 -0
  40. unstructured_transform_client/_host_headers.py +129 -0
  41. unstructured_transform_client/_multipart.py +100 -0
  42. unstructured_transform_client/_retry.py +205 -0
  43. unstructured_transform_client/_sse.py +187 -0
  44. unstructured_transform_client/_version.py +17 -0
  45. unstructured_transform_client-0.18.17.dist-info/METADATA +201 -0
  46. unstructured_transform_client-0.18.17.dist-info/RECORD +48 -0
  47. unstructured_transform_client-0.18.17.dist-info/WHEEL +4 -0
  48. unstructured_transform_client-0.18.17.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,351 @@
1
+ """
2
+ Unstructured Transform API
3
+
4
+ One document in, the parsed document back. A single call takes a document and returns structured output — no job graph, no strategy selection, no model provider setup, and no polling loop. An optional schema switches the request from parse-only to parse-then-extract.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
8
+
9
+ Do not edit the class manually.
10
+ """ # noqa: E501
11
+
12
+
13
+ import warnings
14
+ from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
15
+ from typing import Any, Dict, List, Optional, Tuple, Union
16
+ from typing_extensions import Annotated
17
+
18
+ from pydantic import Field, StrictStr
19
+ from typing import Optional
20
+ from typing_extensions import Annotated
21
+ from unstructured_transform_client._generated.models.extract_request import ExtractRequest
22
+ from unstructured_transform_client._generated.models.parse_result import ParseResult
23
+
24
+ from unstructured_transform_client._generated.api_client import ApiClient, RequestSerialized
25
+ from unstructured_transform_client._generated.api_response import ApiResponse
26
+ from unstructured_transform_client._generated.rest import RESTResponseType
27
+
28
+
29
+ class ExtractApi:
30
+ """NOTE: This class is auto generated by OpenAPI Generator
31
+ Ref: https://openapi-generator.tech
32
+
33
+ Do not edit the class manually.
34
+ """
35
+
36
+ def __init__(self, api_client=None) -> None:
37
+ if api_client is None:
38
+ api_client = ApiClient.get_default()
39
+ self.api_client = api_client
40
+
41
+
42
+ @validate_call
43
+ def extract_run(
44
+ self,
45
+ extract_request: ExtractRequest,
46
+ prefer: Annotated[Optional[StrictStr], Field(description="Wait up to this many seconds for completed extraction.")] = None,
47
+ _request_timeout: Union[
48
+ None,
49
+ Annotated[StrictFloat, Field(gt=0)],
50
+ Tuple[
51
+ Annotated[StrictFloat, Field(gt=0)],
52
+ Annotated[StrictFloat, Field(gt=0)]
53
+ ]
54
+ ] = None,
55
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
56
+ _content_type: Optional[StrictStr] = None,
57
+ _headers: Optional[Dict[StrictStr, Any]] = None,
58
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
59
+ ) -> ParseResult:
60
+ """Extract fields from a parse or document
61
+
62
+ Takes either a parse ID or a document and a schema, then returns the fields. A multipart input is limited to 50 MB and to the supported extensions: bmp, docx, heic, jpeg, jpg, pdf, png, pptx, tiff.
63
+
64
+ :param extract_request: (required)
65
+ :type extract_request: ExtractRequest
66
+ :param prefer: Wait up to this many seconds for completed extraction.
67
+ :type prefer: str
68
+ :param _request_timeout: timeout setting for this request. If one
69
+ number provided, it will be total request
70
+ timeout. It can also be a pair (tuple) of
71
+ (connection, read) timeouts.
72
+ :type _request_timeout: int, tuple(int, int), optional
73
+ :param _request_auth: set to override the auth_settings for an a single
74
+ request; this effectively ignores the
75
+ authentication in the spec for a single request.
76
+ :type _request_auth: dict, optional
77
+ :param _content_type: force content-type for the request.
78
+ :type _content_type: str, Optional
79
+ :param _headers: set to override the headers for a single
80
+ request; this effectively ignores the headers
81
+ in the spec for a single request.
82
+ :type _headers: dict, optional
83
+ :param _host_index: set to override the host_index for a single
84
+ request; this effectively ignores the host_index
85
+ in the spec for a single request.
86
+ :type _host_index: int, optional
87
+ :return: Returns the result object.
88
+ """ # noqa: E501
89
+
90
+ _param = self._extract_run_serialize(
91
+ extract_request=extract_request,
92
+ prefer=prefer,
93
+ _request_auth=_request_auth,
94
+ _content_type=_content_type,
95
+ _headers=_headers,
96
+ _host_index=_host_index
97
+ )
98
+
99
+ _response_types_map: Dict[str, Optional[str]] = {
100
+ '200': "ParseResult",
101
+ '202': "JobAccepted",
102
+ '400': "Error",
103
+ '401': "Error",
104
+ '404': "Error",
105
+ '409': "Error",
106
+ '413': "Error",
107
+ '415': "Error",
108
+ }
109
+ response_data = self.api_client.call_api(
110
+ *_param,
111
+ _request_timeout=_request_timeout
112
+ )
113
+ response_data.read()
114
+ return self.api_client.response_deserialize(
115
+ response_data=response_data,
116
+ response_types_map=_response_types_map,
117
+ ).data
118
+
119
+
120
+ @validate_call
121
+ def extract_run_with_http_info(
122
+ self,
123
+ extract_request: ExtractRequest,
124
+ prefer: Annotated[Optional[StrictStr], Field(description="Wait up to this many seconds for completed extraction.")] = None,
125
+ _request_timeout: Union[
126
+ None,
127
+ Annotated[StrictFloat, Field(gt=0)],
128
+ Tuple[
129
+ Annotated[StrictFloat, Field(gt=0)],
130
+ Annotated[StrictFloat, Field(gt=0)]
131
+ ]
132
+ ] = None,
133
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
134
+ _content_type: Optional[StrictStr] = None,
135
+ _headers: Optional[Dict[StrictStr, Any]] = None,
136
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
137
+ ) -> ApiResponse[ParseResult]:
138
+ """Extract fields from a parse or document
139
+
140
+ Takes either a parse ID or a document and a schema, then returns the fields. A multipart input is limited to 50 MB and to the supported extensions: bmp, docx, heic, jpeg, jpg, pdf, png, pptx, tiff.
141
+
142
+ :param extract_request: (required)
143
+ :type extract_request: ExtractRequest
144
+ :param prefer: Wait up to this many seconds for completed extraction.
145
+ :type prefer: str
146
+ :param _request_timeout: timeout setting for this request. If one
147
+ number provided, it will be total request
148
+ timeout. It can also be a pair (tuple) of
149
+ (connection, read) timeouts.
150
+ :type _request_timeout: int, tuple(int, int), optional
151
+ :param _request_auth: set to override the auth_settings for an a single
152
+ request; this effectively ignores the
153
+ authentication in the spec for a single request.
154
+ :type _request_auth: dict, optional
155
+ :param _content_type: force content-type for the request.
156
+ :type _content_type: str, Optional
157
+ :param _headers: set to override the headers for a single
158
+ request; this effectively ignores the headers
159
+ in the spec for a single request.
160
+ :type _headers: dict, optional
161
+ :param _host_index: set to override the host_index for a single
162
+ request; this effectively ignores the host_index
163
+ in the spec for a single request.
164
+ :type _host_index: int, optional
165
+ :return: Returns the result object.
166
+ """ # noqa: E501
167
+
168
+ _param = self._extract_run_serialize(
169
+ extract_request=extract_request,
170
+ prefer=prefer,
171
+ _request_auth=_request_auth,
172
+ _content_type=_content_type,
173
+ _headers=_headers,
174
+ _host_index=_host_index
175
+ )
176
+
177
+ _response_types_map: Dict[str, Optional[str]] = {
178
+ '200': "ParseResult",
179
+ '202': "JobAccepted",
180
+ '400': "Error",
181
+ '401': "Error",
182
+ '404': "Error",
183
+ '409': "Error",
184
+ '413': "Error",
185
+ '415': "Error",
186
+ }
187
+ response_data = self.api_client.call_api(
188
+ *_param,
189
+ _request_timeout=_request_timeout
190
+ )
191
+ response_data.read()
192
+ return self.api_client.response_deserialize(
193
+ response_data=response_data,
194
+ response_types_map=_response_types_map,
195
+ )
196
+
197
+
198
+ @validate_call
199
+ def extract_run_without_preload_content(
200
+ self,
201
+ extract_request: ExtractRequest,
202
+ prefer: Annotated[Optional[StrictStr], Field(description="Wait up to this many seconds for completed extraction.")] = None,
203
+ _request_timeout: Union[
204
+ None,
205
+ Annotated[StrictFloat, Field(gt=0)],
206
+ Tuple[
207
+ Annotated[StrictFloat, Field(gt=0)],
208
+ Annotated[StrictFloat, Field(gt=0)]
209
+ ]
210
+ ] = None,
211
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
212
+ _content_type: Optional[StrictStr] = None,
213
+ _headers: Optional[Dict[StrictStr, Any]] = None,
214
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
215
+ ) -> RESTResponseType:
216
+ """Extract fields from a parse or document
217
+
218
+ Takes either a parse ID or a document and a schema, then returns the fields. A multipart input is limited to 50 MB and to the supported extensions: bmp, docx, heic, jpeg, jpg, pdf, png, pptx, tiff.
219
+
220
+ :param extract_request: (required)
221
+ :type extract_request: ExtractRequest
222
+ :param prefer: Wait up to this many seconds for completed extraction.
223
+ :type prefer: str
224
+ :param _request_timeout: timeout setting for this request. If one
225
+ number provided, it will be total request
226
+ timeout. It can also be a pair (tuple) of
227
+ (connection, read) timeouts.
228
+ :type _request_timeout: int, tuple(int, int), optional
229
+ :param _request_auth: set to override the auth_settings for an a single
230
+ request; this effectively ignores the
231
+ authentication in the spec for a single request.
232
+ :type _request_auth: dict, optional
233
+ :param _content_type: force content-type for the request.
234
+ :type _content_type: str, Optional
235
+ :param _headers: set to override the headers for a single
236
+ request; this effectively ignores the headers
237
+ in the spec for a single request.
238
+ :type _headers: dict, optional
239
+ :param _host_index: set to override the host_index for a single
240
+ request; this effectively ignores the host_index
241
+ in the spec for a single request.
242
+ :type _host_index: int, optional
243
+ :return: Returns the result object.
244
+ """ # noqa: E501
245
+
246
+ _param = self._extract_run_serialize(
247
+ extract_request=extract_request,
248
+ prefer=prefer,
249
+ _request_auth=_request_auth,
250
+ _content_type=_content_type,
251
+ _headers=_headers,
252
+ _host_index=_host_index
253
+ )
254
+
255
+ _response_types_map: Dict[str, Optional[str]] = {
256
+ '200': "ParseResult",
257
+ '202': "JobAccepted",
258
+ '400': "Error",
259
+ '401': "Error",
260
+ '404': "Error",
261
+ '409': "Error",
262
+ '413': "Error",
263
+ '415': "Error",
264
+ }
265
+ response_data = self.api_client.call_api(
266
+ *_param,
267
+ _request_timeout=_request_timeout
268
+ )
269
+ return response_data.response
270
+
271
+
272
+ def _extract_run_serialize(
273
+ self,
274
+ extract_request,
275
+ prefer,
276
+ _request_auth,
277
+ _content_type,
278
+ _headers,
279
+ _host_index,
280
+ ) -> RequestSerialized:
281
+
282
+ _host = None
283
+
284
+ _collection_formats: Dict[str, str] = {
285
+ }
286
+
287
+ _path_params: Dict[str, str] = {}
288
+ _query_params: List[Tuple[str, str]] = []
289
+ _header_params: Dict[str, Optional[str]] = _headers or {}
290
+ _form_params: List[Tuple[str, str]] = []
291
+ _files: Dict[
292
+ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
293
+ ] = {}
294
+ _body_params: Optional[bytes] = None
295
+
296
+ # process the path parameters
297
+ # process the query parameters
298
+ # process the header parameters
299
+ if prefer is not None:
300
+ _header_params['Prefer'] = prefer
301
+ # process the form parameters
302
+ # process the body parameter
303
+ if extract_request is not None:
304
+ _body_params = extract_request
305
+
306
+
307
+ # set the HTTP header `Accept`
308
+ if 'Accept' not in _header_params:
309
+ _header_params['Accept'] = self.api_client.select_header_accept(
310
+ [
311
+ 'application/json'
312
+ ]
313
+ )
314
+
315
+ # set the HTTP header `Content-Type`
316
+ if _content_type:
317
+ _header_params['Content-Type'] = _content_type
318
+ else:
319
+ _default_content_type = (
320
+ self.api_client.select_header_content_type(
321
+ [
322
+ 'application/json',
323
+ 'multipart/form-data'
324
+ ]
325
+ )
326
+ )
327
+ if _default_content_type is not None:
328
+ _header_params['Content-Type'] = _default_content_type
329
+
330
+ # authentication setting
331
+ _auth_settings: List[str] = [
332
+ 'ApiKeyAuth',
333
+ 'BearerAuth'
334
+ ]
335
+
336
+ return self.api_client.param_serialize(
337
+ method='POST',
338
+ resource_path='/api/v2/extract',
339
+ path_params=_path_params,
340
+ query_params=_query_params,
341
+ header_params=_header_params,
342
+ body=_body_params,
343
+ post_params=_form_params,
344
+ files=_files,
345
+ auth_settings=_auth_settings,
346
+ collection_formats=_collection_formats,
347
+ _host=_host,
348
+ _request_auth=_request_auth
349
+ )
350
+
351
+