mistralai 1.9.1__py3-none-any.whl → 1.9.2__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.
- mistralai/_version.py +2 -2
- mistralai/accesses.py +672 -0
- mistralai/beta.py +4 -0
- mistralai/documents.py +2136 -0
- mistralai/files.py +2 -2
- mistralai/libraries.py +1041 -0
- mistralai/models/__init__.py +232 -8
- mistralai/models/basemodelcard.py +5 -2
- mistralai/models/conversationevents.py +6 -0
- mistralai/models/conversationhistory.py +4 -4
- mistralai/models/documentout.py +105 -0
- mistralai/models/documenttextcontent.py +13 -0
- mistralai/models/documentupdatein.py +44 -0
- mistralai/models/entitytype.py +9 -0
- mistralai/models/file.py +33 -0
- mistralai/models/files_api_routes_upload_fileop.py +2 -27
- mistralai/models/ftmodelcard.py +5 -3
- mistralai/models/inputentries.py +4 -4
- mistralai/models/libraries_delete_v1op.py +16 -0
- mistralai/models/libraries_documents_delete_v1op.py +21 -0
- mistralai/models/libraries_documents_get_extracted_text_signed_url_v1op.py +21 -0
- mistralai/models/libraries_documents_get_signed_url_v1op.py +21 -0
- mistralai/models/libraries_documents_get_status_v1op.py +21 -0
- mistralai/models/libraries_documents_get_text_content_v1op.py +21 -0
- mistralai/models/libraries_documents_get_v1op.py +21 -0
- mistralai/models/libraries_documents_list_v1op.py +78 -0
- mistralai/models/libraries_documents_reprocess_v1op.py +21 -0
- mistralai/models/libraries_documents_update_v1op.py +28 -0
- mistralai/models/libraries_documents_upload_v1op.py +56 -0
- mistralai/models/libraries_get_v1op.py +16 -0
- mistralai/models/libraries_share_create_v1op.py +22 -0
- mistralai/models/libraries_share_delete_v1op.py +23 -0
- mistralai/models/libraries_share_list_v1op.py +16 -0
- mistralai/models/libraries_update_v1op.py +23 -0
- mistralai/models/libraryin.py +50 -0
- mistralai/models/libraryinupdate.py +47 -0
- mistralai/models/libraryout.py +107 -0
- mistralai/models/listdocumentout.py +19 -0
- mistralai/models/listlibraryout.py +15 -0
- mistralai/models/listsharingout.py +15 -0
- mistralai/models/messageinputentry.py +14 -4
- mistralai/models/paginationinfo.py +25 -0
- mistralai/models/processingstatusout.py +16 -0
- mistralai/models/shareenum.py +8 -0
- mistralai/models/sharingdelete.py +26 -0
- mistralai/models/sharingin.py +30 -0
- mistralai/models/sharingout.py +59 -0
- mistralai/models/ssetypes.py +1 -0
- mistralai/models/toolexecutiondeltaevent.py +34 -0
- mistralai/models/toolexecutionentry.py +3 -0
- mistralai/models/toolexecutionstartedevent.py +3 -0
- mistralai/models/toolreferencechunk.py +7 -4
- {mistralai-1.9.1.dist-info → mistralai-1.9.2.dist-info}/METADATA +29 -2
- {mistralai-1.9.1.dist-info → mistralai-1.9.2.dist-info}/RECORD +56 -19
- {mistralai-1.9.1.dist-info → mistralai-1.9.2.dist-info}/LICENSE +0 -0
- {mistralai-1.9.1.dist-info → mistralai-1.9.2.dist-info}/WHEEL +0 -0
mistralai/documents.py
ADDED
|
@@ -0,0 +1,2136 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from mistralai import models, utils
|
|
5
|
+
from mistralai._hooks import HookContext
|
|
6
|
+
from mistralai.types import OptionalNullable, UNSET
|
|
7
|
+
from mistralai.utils import get_security_from_env
|
|
8
|
+
from typing import Any, Mapping, Optional, Union
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Documents(BaseSDK):
|
|
12
|
+
def list(
|
|
13
|
+
self,
|
|
14
|
+
*,
|
|
15
|
+
library_id: str,
|
|
16
|
+
search: OptionalNullable[str] = UNSET,
|
|
17
|
+
page_size: Optional[int] = 100,
|
|
18
|
+
page: Optional[int] = 0,
|
|
19
|
+
sort_by: Optional[str] = "created_at",
|
|
20
|
+
sort_order: Optional[str] = "desc",
|
|
21
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
22
|
+
server_url: Optional[str] = None,
|
|
23
|
+
timeout_ms: Optional[int] = None,
|
|
24
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
25
|
+
) -> models.ListDocumentOut:
|
|
26
|
+
r"""List document in a given library.
|
|
27
|
+
|
|
28
|
+
Given a library, lists the document that have been uploaded to that library.
|
|
29
|
+
|
|
30
|
+
:param library_id:
|
|
31
|
+
:param search:
|
|
32
|
+
:param page_size:
|
|
33
|
+
:param page:
|
|
34
|
+
:param sort_by:
|
|
35
|
+
:param sort_order:
|
|
36
|
+
:param retries: Override the default retry configuration for this method
|
|
37
|
+
:param server_url: Override the default server URL for this method
|
|
38
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
39
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
40
|
+
"""
|
|
41
|
+
base_url = None
|
|
42
|
+
url_variables = None
|
|
43
|
+
if timeout_ms is None:
|
|
44
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
45
|
+
|
|
46
|
+
if server_url is not None:
|
|
47
|
+
base_url = server_url
|
|
48
|
+
else:
|
|
49
|
+
base_url = self._get_url(base_url, url_variables)
|
|
50
|
+
|
|
51
|
+
request = models.LibrariesDocumentsListV1Request(
|
|
52
|
+
library_id=library_id,
|
|
53
|
+
search=search,
|
|
54
|
+
page_size=page_size,
|
|
55
|
+
page=page,
|
|
56
|
+
sort_by=sort_by,
|
|
57
|
+
sort_order=sort_order,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
req = self._build_request(
|
|
61
|
+
method="GET",
|
|
62
|
+
path="/v1/libraries/{library_id}/documents",
|
|
63
|
+
base_url=base_url,
|
|
64
|
+
url_variables=url_variables,
|
|
65
|
+
request=request,
|
|
66
|
+
request_body_required=False,
|
|
67
|
+
request_has_path_params=True,
|
|
68
|
+
request_has_query_params=True,
|
|
69
|
+
user_agent_header="user-agent",
|
|
70
|
+
accept_header_value="application/json",
|
|
71
|
+
http_headers=http_headers,
|
|
72
|
+
security=self.sdk_configuration.security,
|
|
73
|
+
timeout_ms=timeout_ms,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
if retries == UNSET:
|
|
77
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
78
|
+
retries = self.sdk_configuration.retry_config
|
|
79
|
+
|
|
80
|
+
retry_config = None
|
|
81
|
+
if isinstance(retries, utils.RetryConfig):
|
|
82
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
83
|
+
|
|
84
|
+
http_res = self.do_request(
|
|
85
|
+
hook_ctx=HookContext(
|
|
86
|
+
config=self.sdk_configuration,
|
|
87
|
+
base_url=base_url or "",
|
|
88
|
+
operation_id="libraries_documents_list_v1",
|
|
89
|
+
oauth2_scopes=[],
|
|
90
|
+
security_source=get_security_from_env(
|
|
91
|
+
self.sdk_configuration.security, models.Security
|
|
92
|
+
),
|
|
93
|
+
),
|
|
94
|
+
request=req,
|
|
95
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
96
|
+
retry_config=retry_config,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
response_data: Any = None
|
|
100
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
101
|
+
return utils.unmarshal_json(http_res.text, models.ListDocumentOut)
|
|
102
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
103
|
+
response_data = utils.unmarshal_json(
|
|
104
|
+
http_res.text, models.HTTPValidationErrorData
|
|
105
|
+
)
|
|
106
|
+
raise models.HTTPValidationError(data=response_data)
|
|
107
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
108
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
109
|
+
raise models.SDKError(
|
|
110
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
111
|
+
)
|
|
112
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
113
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
114
|
+
raise models.SDKError(
|
|
115
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
content_type = http_res.headers.get("Content-Type")
|
|
119
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
120
|
+
raise models.SDKError(
|
|
121
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
122
|
+
http_res.status_code,
|
|
123
|
+
http_res_text,
|
|
124
|
+
http_res,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
async def list_async(
|
|
128
|
+
self,
|
|
129
|
+
*,
|
|
130
|
+
library_id: str,
|
|
131
|
+
search: OptionalNullable[str] = UNSET,
|
|
132
|
+
page_size: Optional[int] = 100,
|
|
133
|
+
page: Optional[int] = 0,
|
|
134
|
+
sort_by: Optional[str] = "created_at",
|
|
135
|
+
sort_order: Optional[str] = "desc",
|
|
136
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
137
|
+
server_url: Optional[str] = None,
|
|
138
|
+
timeout_ms: Optional[int] = None,
|
|
139
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
140
|
+
) -> models.ListDocumentOut:
|
|
141
|
+
r"""List document in a given library.
|
|
142
|
+
|
|
143
|
+
Given a library, lists the document that have been uploaded to that library.
|
|
144
|
+
|
|
145
|
+
:param library_id:
|
|
146
|
+
:param search:
|
|
147
|
+
:param page_size:
|
|
148
|
+
:param page:
|
|
149
|
+
:param sort_by:
|
|
150
|
+
:param sort_order:
|
|
151
|
+
:param retries: Override the default retry configuration for this method
|
|
152
|
+
:param server_url: Override the default server URL for this method
|
|
153
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
154
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
155
|
+
"""
|
|
156
|
+
base_url = None
|
|
157
|
+
url_variables = None
|
|
158
|
+
if timeout_ms is None:
|
|
159
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
160
|
+
|
|
161
|
+
if server_url is not None:
|
|
162
|
+
base_url = server_url
|
|
163
|
+
else:
|
|
164
|
+
base_url = self._get_url(base_url, url_variables)
|
|
165
|
+
|
|
166
|
+
request = models.LibrariesDocumentsListV1Request(
|
|
167
|
+
library_id=library_id,
|
|
168
|
+
search=search,
|
|
169
|
+
page_size=page_size,
|
|
170
|
+
page=page,
|
|
171
|
+
sort_by=sort_by,
|
|
172
|
+
sort_order=sort_order,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
req = self._build_request_async(
|
|
176
|
+
method="GET",
|
|
177
|
+
path="/v1/libraries/{library_id}/documents",
|
|
178
|
+
base_url=base_url,
|
|
179
|
+
url_variables=url_variables,
|
|
180
|
+
request=request,
|
|
181
|
+
request_body_required=False,
|
|
182
|
+
request_has_path_params=True,
|
|
183
|
+
request_has_query_params=True,
|
|
184
|
+
user_agent_header="user-agent",
|
|
185
|
+
accept_header_value="application/json",
|
|
186
|
+
http_headers=http_headers,
|
|
187
|
+
security=self.sdk_configuration.security,
|
|
188
|
+
timeout_ms=timeout_ms,
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
if retries == UNSET:
|
|
192
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
193
|
+
retries = self.sdk_configuration.retry_config
|
|
194
|
+
|
|
195
|
+
retry_config = None
|
|
196
|
+
if isinstance(retries, utils.RetryConfig):
|
|
197
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
198
|
+
|
|
199
|
+
http_res = await self.do_request_async(
|
|
200
|
+
hook_ctx=HookContext(
|
|
201
|
+
config=self.sdk_configuration,
|
|
202
|
+
base_url=base_url or "",
|
|
203
|
+
operation_id="libraries_documents_list_v1",
|
|
204
|
+
oauth2_scopes=[],
|
|
205
|
+
security_source=get_security_from_env(
|
|
206
|
+
self.sdk_configuration.security, models.Security
|
|
207
|
+
),
|
|
208
|
+
),
|
|
209
|
+
request=req,
|
|
210
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
211
|
+
retry_config=retry_config,
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
response_data: Any = None
|
|
215
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
216
|
+
return utils.unmarshal_json(http_res.text, models.ListDocumentOut)
|
|
217
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
218
|
+
response_data = utils.unmarshal_json(
|
|
219
|
+
http_res.text, models.HTTPValidationErrorData
|
|
220
|
+
)
|
|
221
|
+
raise models.HTTPValidationError(data=response_data)
|
|
222
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
223
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
224
|
+
raise models.SDKError(
|
|
225
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
226
|
+
)
|
|
227
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
228
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
229
|
+
raise models.SDKError(
|
|
230
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
content_type = http_res.headers.get("Content-Type")
|
|
234
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
235
|
+
raise models.SDKError(
|
|
236
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
237
|
+
http_res.status_code,
|
|
238
|
+
http_res_text,
|
|
239
|
+
http_res,
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
def upload(
|
|
243
|
+
self,
|
|
244
|
+
*,
|
|
245
|
+
library_id: str,
|
|
246
|
+
file: Union[models.File, models.FileTypedDict],
|
|
247
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
248
|
+
server_url: Optional[str] = None,
|
|
249
|
+
timeout_ms: Optional[int] = None,
|
|
250
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
251
|
+
) -> models.DocumentOut:
|
|
252
|
+
r"""Upload a new document.
|
|
253
|
+
|
|
254
|
+
Given a library, upload a new document to that library. It is queued for processing, it status will change it has been processed. The processing has to be completed in order be discoverable for the library search
|
|
255
|
+
|
|
256
|
+
:param library_id:
|
|
257
|
+
:param file: The File object (not file name) to be uploaded. To upload a file and specify a custom file name you should format your request as such: ```bash file=@path/to/your/file.jsonl;filename=custom_name.jsonl ``` Otherwise, you can just keep the original file name: ```bash file=@path/to/your/file.jsonl ```
|
|
258
|
+
:param retries: Override the default retry configuration for this method
|
|
259
|
+
:param server_url: Override the default server URL for this method
|
|
260
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
261
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
262
|
+
"""
|
|
263
|
+
base_url = None
|
|
264
|
+
url_variables = None
|
|
265
|
+
if timeout_ms is None:
|
|
266
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
267
|
+
|
|
268
|
+
if server_url is not None:
|
|
269
|
+
base_url = server_url
|
|
270
|
+
else:
|
|
271
|
+
base_url = self._get_url(base_url, url_variables)
|
|
272
|
+
|
|
273
|
+
request = models.LibrariesDocumentsUploadV1Request(
|
|
274
|
+
library_id=library_id,
|
|
275
|
+
request_body=models.LibrariesDocumentsUploadV1DocumentUpload(
|
|
276
|
+
file=utils.get_pydantic_model(file, models.File),
|
|
277
|
+
),
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
req = self._build_request(
|
|
281
|
+
method="POST",
|
|
282
|
+
path="/v1/libraries/{library_id}/documents",
|
|
283
|
+
base_url=base_url,
|
|
284
|
+
url_variables=url_variables,
|
|
285
|
+
request=request,
|
|
286
|
+
request_body_required=True,
|
|
287
|
+
request_has_path_params=True,
|
|
288
|
+
request_has_query_params=True,
|
|
289
|
+
user_agent_header="user-agent",
|
|
290
|
+
accept_header_value="application/json",
|
|
291
|
+
http_headers=http_headers,
|
|
292
|
+
security=self.sdk_configuration.security,
|
|
293
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
294
|
+
request.request_body,
|
|
295
|
+
False,
|
|
296
|
+
False,
|
|
297
|
+
"multipart",
|
|
298
|
+
models.LibrariesDocumentsUploadV1DocumentUpload,
|
|
299
|
+
),
|
|
300
|
+
timeout_ms=timeout_ms,
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
if retries == UNSET:
|
|
304
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
305
|
+
retries = self.sdk_configuration.retry_config
|
|
306
|
+
|
|
307
|
+
retry_config = None
|
|
308
|
+
if isinstance(retries, utils.RetryConfig):
|
|
309
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
310
|
+
|
|
311
|
+
http_res = self.do_request(
|
|
312
|
+
hook_ctx=HookContext(
|
|
313
|
+
config=self.sdk_configuration,
|
|
314
|
+
base_url=base_url or "",
|
|
315
|
+
operation_id="libraries_documents_upload_v1",
|
|
316
|
+
oauth2_scopes=[],
|
|
317
|
+
security_source=get_security_from_env(
|
|
318
|
+
self.sdk_configuration.security, models.Security
|
|
319
|
+
),
|
|
320
|
+
),
|
|
321
|
+
request=req,
|
|
322
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
323
|
+
retry_config=retry_config,
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
response_data: Any = None
|
|
327
|
+
if utils.match_response(http_res, ["200", "201"], "application/json"):
|
|
328
|
+
return utils.unmarshal_json(http_res.text, models.DocumentOut)
|
|
329
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
330
|
+
response_data = utils.unmarshal_json(
|
|
331
|
+
http_res.text, models.HTTPValidationErrorData
|
|
332
|
+
)
|
|
333
|
+
raise models.HTTPValidationError(data=response_data)
|
|
334
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
335
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
336
|
+
raise models.SDKError(
|
|
337
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
338
|
+
)
|
|
339
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
340
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
341
|
+
raise models.SDKError(
|
|
342
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
content_type = http_res.headers.get("Content-Type")
|
|
346
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
347
|
+
raise models.SDKError(
|
|
348
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
349
|
+
http_res.status_code,
|
|
350
|
+
http_res_text,
|
|
351
|
+
http_res,
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
async def upload_async(
|
|
355
|
+
self,
|
|
356
|
+
*,
|
|
357
|
+
library_id: str,
|
|
358
|
+
file: Union[models.File, models.FileTypedDict],
|
|
359
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
360
|
+
server_url: Optional[str] = None,
|
|
361
|
+
timeout_ms: Optional[int] = None,
|
|
362
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
363
|
+
) -> models.DocumentOut:
|
|
364
|
+
r"""Upload a new document.
|
|
365
|
+
|
|
366
|
+
Given a library, upload a new document to that library. It is queued for processing, it status will change it has been processed. The processing has to be completed in order be discoverable for the library search
|
|
367
|
+
|
|
368
|
+
:param library_id:
|
|
369
|
+
:param file: The File object (not file name) to be uploaded. To upload a file and specify a custom file name you should format your request as such: ```bash file=@path/to/your/file.jsonl;filename=custom_name.jsonl ``` Otherwise, you can just keep the original file name: ```bash file=@path/to/your/file.jsonl ```
|
|
370
|
+
:param retries: Override the default retry configuration for this method
|
|
371
|
+
:param server_url: Override the default server URL for this method
|
|
372
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
373
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
374
|
+
"""
|
|
375
|
+
base_url = None
|
|
376
|
+
url_variables = None
|
|
377
|
+
if timeout_ms is None:
|
|
378
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
379
|
+
|
|
380
|
+
if server_url is not None:
|
|
381
|
+
base_url = server_url
|
|
382
|
+
else:
|
|
383
|
+
base_url = self._get_url(base_url, url_variables)
|
|
384
|
+
|
|
385
|
+
request = models.LibrariesDocumentsUploadV1Request(
|
|
386
|
+
library_id=library_id,
|
|
387
|
+
request_body=models.LibrariesDocumentsUploadV1DocumentUpload(
|
|
388
|
+
file=utils.get_pydantic_model(file, models.File),
|
|
389
|
+
),
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
req = self._build_request_async(
|
|
393
|
+
method="POST",
|
|
394
|
+
path="/v1/libraries/{library_id}/documents",
|
|
395
|
+
base_url=base_url,
|
|
396
|
+
url_variables=url_variables,
|
|
397
|
+
request=request,
|
|
398
|
+
request_body_required=True,
|
|
399
|
+
request_has_path_params=True,
|
|
400
|
+
request_has_query_params=True,
|
|
401
|
+
user_agent_header="user-agent",
|
|
402
|
+
accept_header_value="application/json",
|
|
403
|
+
http_headers=http_headers,
|
|
404
|
+
security=self.sdk_configuration.security,
|
|
405
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
406
|
+
request.request_body,
|
|
407
|
+
False,
|
|
408
|
+
False,
|
|
409
|
+
"multipart",
|
|
410
|
+
models.LibrariesDocumentsUploadV1DocumentUpload,
|
|
411
|
+
),
|
|
412
|
+
timeout_ms=timeout_ms,
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
if retries == UNSET:
|
|
416
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
417
|
+
retries = self.sdk_configuration.retry_config
|
|
418
|
+
|
|
419
|
+
retry_config = None
|
|
420
|
+
if isinstance(retries, utils.RetryConfig):
|
|
421
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
422
|
+
|
|
423
|
+
http_res = await self.do_request_async(
|
|
424
|
+
hook_ctx=HookContext(
|
|
425
|
+
config=self.sdk_configuration,
|
|
426
|
+
base_url=base_url or "",
|
|
427
|
+
operation_id="libraries_documents_upload_v1",
|
|
428
|
+
oauth2_scopes=[],
|
|
429
|
+
security_source=get_security_from_env(
|
|
430
|
+
self.sdk_configuration.security, models.Security
|
|
431
|
+
),
|
|
432
|
+
),
|
|
433
|
+
request=req,
|
|
434
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
435
|
+
retry_config=retry_config,
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
response_data: Any = None
|
|
439
|
+
if utils.match_response(http_res, ["200", "201"], "application/json"):
|
|
440
|
+
return utils.unmarshal_json(http_res.text, models.DocumentOut)
|
|
441
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
442
|
+
response_data = utils.unmarshal_json(
|
|
443
|
+
http_res.text, models.HTTPValidationErrorData
|
|
444
|
+
)
|
|
445
|
+
raise models.HTTPValidationError(data=response_data)
|
|
446
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
447
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
448
|
+
raise models.SDKError(
|
|
449
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
450
|
+
)
|
|
451
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
452
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
453
|
+
raise models.SDKError(
|
|
454
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
content_type = http_res.headers.get("Content-Type")
|
|
458
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
459
|
+
raise models.SDKError(
|
|
460
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
461
|
+
http_res.status_code,
|
|
462
|
+
http_res_text,
|
|
463
|
+
http_res,
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
def get(
|
|
467
|
+
self,
|
|
468
|
+
*,
|
|
469
|
+
library_id: str,
|
|
470
|
+
document_id: str,
|
|
471
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
472
|
+
server_url: Optional[str] = None,
|
|
473
|
+
timeout_ms: Optional[int] = None,
|
|
474
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
475
|
+
) -> models.DocumentOut:
|
|
476
|
+
r"""Retrieve the metadata of a specific document.
|
|
477
|
+
|
|
478
|
+
Given a library and a document in this library, you can retrieve the metadata of that document.
|
|
479
|
+
|
|
480
|
+
:param library_id:
|
|
481
|
+
:param document_id:
|
|
482
|
+
:param retries: Override the default retry configuration for this method
|
|
483
|
+
:param server_url: Override the default server URL for this method
|
|
484
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
485
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
486
|
+
"""
|
|
487
|
+
base_url = None
|
|
488
|
+
url_variables = None
|
|
489
|
+
if timeout_ms is None:
|
|
490
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
491
|
+
|
|
492
|
+
if server_url is not None:
|
|
493
|
+
base_url = server_url
|
|
494
|
+
else:
|
|
495
|
+
base_url = self._get_url(base_url, url_variables)
|
|
496
|
+
|
|
497
|
+
request = models.LibrariesDocumentsGetV1Request(
|
|
498
|
+
library_id=library_id,
|
|
499
|
+
document_id=document_id,
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
req = self._build_request(
|
|
503
|
+
method="GET",
|
|
504
|
+
path="/v1/libraries/{library_id}/documents/{document_id}",
|
|
505
|
+
base_url=base_url,
|
|
506
|
+
url_variables=url_variables,
|
|
507
|
+
request=request,
|
|
508
|
+
request_body_required=False,
|
|
509
|
+
request_has_path_params=True,
|
|
510
|
+
request_has_query_params=True,
|
|
511
|
+
user_agent_header="user-agent",
|
|
512
|
+
accept_header_value="application/json",
|
|
513
|
+
http_headers=http_headers,
|
|
514
|
+
security=self.sdk_configuration.security,
|
|
515
|
+
timeout_ms=timeout_ms,
|
|
516
|
+
)
|
|
517
|
+
|
|
518
|
+
if retries == UNSET:
|
|
519
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
520
|
+
retries = self.sdk_configuration.retry_config
|
|
521
|
+
|
|
522
|
+
retry_config = None
|
|
523
|
+
if isinstance(retries, utils.RetryConfig):
|
|
524
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
525
|
+
|
|
526
|
+
http_res = self.do_request(
|
|
527
|
+
hook_ctx=HookContext(
|
|
528
|
+
config=self.sdk_configuration,
|
|
529
|
+
base_url=base_url or "",
|
|
530
|
+
operation_id="libraries_documents_get_v1",
|
|
531
|
+
oauth2_scopes=[],
|
|
532
|
+
security_source=get_security_from_env(
|
|
533
|
+
self.sdk_configuration.security, models.Security
|
|
534
|
+
),
|
|
535
|
+
),
|
|
536
|
+
request=req,
|
|
537
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
538
|
+
retry_config=retry_config,
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
response_data: Any = None
|
|
542
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
543
|
+
return utils.unmarshal_json(http_res.text, models.DocumentOut)
|
|
544
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
545
|
+
response_data = utils.unmarshal_json(
|
|
546
|
+
http_res.text, models.HTTPValidationErrorData
|
|
547
|
+
)
|
|
548
|
+
raise models.HTTPValidationError(data=response_data)
|
|
549
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
550
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
551
|
+
raise models.SDKError(
|
|
552
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
553
|
+
)
|
|
554
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
555
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
556
|
+
raise models.SDKError(
|
|
557
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
558
|
+
)
|
|
559
|
+
|
|
560
|
+
content_type = http_res.headers.get("Content-Type")
|
|
561
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
562
|
+
raise models.SDKError(
|
|
563
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
564
|
+
http_res.status_code,
|
|
565
|
+
http_res_text,
|
|
566
|
+
http_res,
|
|
567
|
+
)
|
|
568
|
+
|
|
569
|
+
async def get_async(
|
|
570
|
+
self,
|
|
571
|
+
*,
|
|
572
|
+
library_id: str,
|
|
573
|
+
document_id: str,
|
|
574
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
575
|
+
server_url: Optional[str] = None,
|
|
576
|
+
timeout_ms: Optional[int] = None,
|
|
577
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
578
|
+
) -> models.DocumentOut:
|
|
579
|
+
r"""Retrieve the metadata of a specific document.
|
|
580
|
+
|
|
581
|
+
Given a library and a document in this library, you can retrieve the metadata of that document.
|
|
582
|
+
|
|
583
|
+
:param library_id:
|
|
584
|
+
:param document_id:
|
|
585
|
+
:param retries: Override the default retry configuration for this method
|
|
586
|
+
:param server_url: Override the default server URL for this method
|
|
587
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
588
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
589
|
+
"""
|
|
590
|
+
base_url = None
|
|
591
|
+
url_variables = None
|
|
592
|
+
if timeout_ms is None:
|
|
593
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
594
|
+
|
|
595
|
+
if server_url is not None:
|
|
596
|
+
base_url = server_url
|
|
597
|
+
else:
|
|
598
|
+
base_url = self._get_url(base_url, url_variables)
|
|
599
|
+
|
|
600
|
+
request = models.LibrariesDocumentsGetV1Request(
|
|
601
|
+
library_id=library_id,
|
|
602
|
+
document_id=document_id,
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
req = self._build_request_async(
|
|
606
|
+
method="GET",
|
|
607
|
+
path="/v1/libraries/{library_id}/documents/{document_id}",
|
|
608
|
+
base_url=base_url,
|
|
609
|
+
url_variables=url_variables,
|
|
610
|
+
request=request,
|
|
611
|
+
request_body_required=False,
|
|
612
|
+
request_has_path_params=True,
|
|
613
|
+
request_has_query_params=True,
|
|
614
|
+
user_agent_header="user-agent",
|
|
615
|
+
accept_header_value="application/json",
|
|
616
|
+
http_headers=http_headers,
|
|
617
|
+
security=self.sdk_configuration.security,
|
|
618
|
+
timeout_ms=timeout_ms,
|
|
619
|
+
)
|
|
620
|
+
|
|
621
|
+
if retries == UNSET:
|
|
622
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
623
|
+
retries = self.sdk_configuration.retry_config
|
|
624
|
+
|
|
625
|
+
retry_config = None
|
|
626
|
+
if isinstance(retries, utils.RetryConfig):
|
|
627
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
628
|
+
|
|
629
|
+
http_res = await self.do_request_async(
|
|
630
|
+
hook_ctx=HookContext(
|
|
631
|
+
config=self.sdk_configuration,
|
|
632
|
+
base_url=base_url or "",
|
|
633
|
+
operation_id="libraries_documents_get_v1",
|
|
634
|
+
oauth2_scopes=[],
|
|
635
|
+
security_source=get_security_from_env(
|
|
636
|
+
self.sdk_configuration.security, models.Security
|
|
637
|
+
),
|
|
638
|
+
),
|
|
639
|
+
request=req,
|
|
640
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
641
|
+
retry_config=retry_config,
|
|
642
|
+
)
|
|
643
|
+
|
|
644
|
+
response_data: Any = None
|
|
645
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
646
|
+
return utils.unmarshal_json(http_res.text, models.DocumentOut)
|
|
647
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
648
|
+
response_data = utils.unmarshal_json(
|
|
649
|
+
http_res.text, models.HTTPValidationErrorData
|
|
650
|
+
)
|
|
651
|
+
raise models.HTTPValidationError(data=response_data)
|
|
652
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
653
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
654
|
+
raise models.SDKError(
|
|
655
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
656
|
+
)
|
|
657
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
658
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
659
|
+
raise models.SDKError(
|
|
660
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
661
|
+
)
|
|
662
|
+
|
|
663
|
+
content_type = http_res.headers.get("Content-Type")
|
|
664
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
665
|
+
raise models.SDKError(
|
|
666
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
667
|
+
http_res.status_code,
|
|
668
|
+
http_res_text,
|
|
669
|
+
http_res,
|
|
670
|
+
)
|
|
671
|
+
|
|
672
|
+
def update(
|
|
673
|
+
self,
|
|
674
|
+
*,
|
|
675
|
+
library_id: str,
|
|
676
|
+
document_id: str,
|
|
677
|
+
name: OptionalNullable[str] = UNSET,
|
|
678
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
679
|
+
server_url: Optional[str] = None,
|
|
680
|
+
timeout_ms: Optional[int] = None,
|
|
681
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
682
|
+
) -> models.DocumentOut:
|
|
683
|
+
r"""Update the metadata of a specific document.
|
|
684
|
+
|
|
685
|
+
Given a library and a document in that library, update the name of that document.
|
|
686
|
+
|
|
687
|
+
:param library_id:
|
|
688
|
+
:param document_id:
|
|
689
|
+
:param name:
|
|
690
|
+
:param retries: Override the default retry configuration for this method
|
|
691
|
+
:param server_url: Override the default server URL for this method
|
|
692
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
693
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
694
|
+
"""
|
|
695
|
+
base_url = None
|
|
696
|
+
url_variables = None
|
|
697
|
+
if timeout_ms is None:
|
|
698
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
699
|
+
|
|
700
|
+
if server_url is not None:
|
|
701
|
+
base_url = server_url
|
|
702
|
+
else:
|
|
703
|
+
base_url = self._get_url(base_url, url_variables)
|
|
704
|
+
|
|
705
|
+
request = models.LibrariesDocumentsUpdateV1Request(
|
|
706
|
+
library_id=library_id,
|
|
707
|
+
document_id=document_id,
|
|
708
|
+
document_update_in=models.DocumentUpdateIn(
|
|
709
|
+
name=name,
|
|
710
|
+
),
|
|
711
|
+
)
|
|
712
|
+
|
|
713
|
+
req = self._build_request(
|
|
714
|
+
method="PUT",
|
|
715
|
+
path="/v1/libraries/{library_id}/documents/{document_id}",
|
|
716
|
+
base_url=base_url,
|
|
717
|
+
url_variables=url_variables,
|
|
718
|
+
request=request,
|
|
719
|
+
request_body_required=True,
|
|
720
|
+
request_has_path_params=True,
|
|
721
|
+
request_has_query_params=True,
|
|
722
|
+
user_agent_header="user-agent",
|
|
723
|
+
accept_header_value="application/json",
|
|
724
|
+
http_headers=http_headers,
|
|
725
|
+
security=self.sdk_configuration.security,
|
|
726
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
727
|
+
request.document_update_in,
|
|
728
|
+
False,
|
|
729
|
+
False,
|
|
730
|
+
"json",
|
|
731
|
+
models.DocumentUpdateIn,
|
|
732
|
+
),
|
|
733
|
+
timeout_ms=timeout_ms,
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
if retries == UNSET:
|
|
737
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
738
|
+
retries = self.sdk_configuration.retry_config
|
|
739
|
+
|
|
740
|
+
retry_config = None
|
|
741
|
+
if isinstance(retries, utils.RetryConfig):
|
|
742
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
743
|
+
|
|
744
|
+
http_res = self.do_request(
|
|
745
|
+
hook_ctx=HookContext(
|
|
746
|
+
config=self.sdk_configuration,
|
|
747
|
+
base_url=base_url or "",
|
|
748
|
+
operation_id="libraries_documents_update_v1",
|
|
749
|
+
oauth2_scopes=[],
|
|
750
|
+
security_source=get_security_from_env(
|
|
751
|
+
self.sdk_configuration.security, models.Security
|
|
752
|
+
),
|
|
753
|
+
),
|
|
754
|
+
request=req,
|
|
755
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
756
|
+
retry_config=retry_config,
|
|
757
|
+
)
|
|
758
|
+
|
|
759
|
+
response_data: Any = None
|
|
760
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
761
|
+
return utils.unmarshal_json(http_res.text, models.DocumentOut)
|
|
762
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
763
|
+
response_data = utils.unmarshal_json(
|
|
764
|
+
http_res.text, models.HTTPValidationErrorData
|
|
765
|
+
)
|
|
766
|
+
raise models.HTTPValidationError(data=response_data)
|
|
767
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
768
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
769
|
+
raise models.SDKError(
|
|
770
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
771
|
+
)
|
|
772
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
773
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
774
|
+
raise models.SDKError(
|
|
775
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
776
|
+
)
|
|
777
|
+
|
|
778
|
+
content_type = http_res.headers.get("Content-Type")
|
|
779
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
780
|
+
raise models.SDKError(
|
|
781
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
782
|
+
http_res.status_code,
|
|
783
|
+
http_res_text,
|
|
784
|
+
http_res,
|
|
785
|
+
)
|
|
786
|
+
|
|
787
|
+
async def update_async(
|
|
788
|
+
self,
|
|
789
|
+
*,
|
|
790
|
+
library_id: str,
|
|
791
|
+
document_id: str,
|
|
792
|
+
name: OptionalNullable[str] = UNSET,
|
|
793
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
794
|
+
server_url: Optional[str] = None,
|
|
795
|
+
timeout_ms: Optional[int] = None,
|
|
796
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
797
|
+
) -> models.DocumentOut:
|
|
798
|
+
r"""Update the metadata of a specific document.
|
|
799
|
+
|
|
800
|
+
Given a library and a document in that library, update the name of that document.
|
|
801
|
+
|
|
802
|
+
:param library_id:
|
|
803
|
+
:param document_id:
|
|
804
|
+
:param name:
|
|
805
|
+
:param retries: Override the default retry configuration for this method
|
|
806
|
+
:param server_url: Override the default server URL for this method
|
|
807
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
808
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
809
|
+
"""
|
|
810
|
+
base_url = None
|
|
811
|
+
url_variables = None
|
|
812
|
+
if timeout_ms is None:
|
|
813
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
814
|
+
|
|
815
|
+
if server_url is not None:
|
|
816
|
+
base_url = server_url
|
|
817
|
+
else:
|
|
818
|
+
base_url = self._get_url(base_url, url_variables)
|
|
819
|
+
|
|
820
|
+
request = models.LibrariesDocumentsUpdateV1Request(
|
|
821
|
+
library_id=library_id,
|
|
822
|
+
document_id=document_id,
|
|
823
|
+
document_update_in=models.DocumentUpdateIn(
|
|
824
|
+
name=name,
|
|
825
|
+
),
|
|
826
|
+
)
|
|
827
|
+
|
|
828
|
+
req = self._build_request_async(
|
|
829
|
+
method="PUT",
|
|
830
|
+
path="/v1/libraries/{library_id}/documents/{document_id}",
|
|
831
|
+
base_url=base_url,
|
|
832
|
+
url_variables=url_variables,
|
|
833
|
+
request=request,
|
|
834
|
+
request_body_required=True,
|
|
835
|
+
request_has_path_params=True,
|
|
836
|
+
request_has_query_params=True,
|
|
837
|
+
user_agent_header="user-agent",
|
|
838
|
+
accept_header_value="application/json",
|
|
839
|
+
http_headers=http_headers,
|
|
840
|
+
security=self.sdk_configuration.security,
|
|
841
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
842
|
+
request.document_update_in,
|
|
843
|
+
False,
|
|
844
|
+
False,
|
|
845
|
+
"json",
|
|
846
|
+
models.DocumentUpdateIn,
|
|
847
|
+
),
|
|
848
|
+
timeout_ms=timeout_ms,
|
|
849
|
+
)
|
|
850
|
+
|
|
851
|
+
if retries == UNSET:
|
|
852
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
853
|
+
retries = self.sdk_configuration.retry_config
|
|
854
|
+
|
|
855
|
+
retry_config = None
|
|
856
|
+
if isinstance(retries, utils.RetryConfig):
|
|
857
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
858
|
+
|
|
859
|
+
http_res = await self.do_request_async(
|
|
860
|
+
hook_ctx=HookContext(
|
|
861
|
+
config=self.sdk_configuration,
|
|
862
|
+
base_url=base_url or "",
|
|
863
|
+
operation_id="libraries_documents_update_v1",
|
|
864
|
+
oauth2_scopes=[],
|
|
865
|
+
security_source=get_security_from_env(
|
|
866
|
+
self.sdk_configuration.security, models.Security
|
|
867
|
+
),
|
|
868
|
+
),
|
|
869
|
+
request=req,
|
|
870
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
871
|
+
retry_config=retry_config,
|
|
872
|
+
)
|
|
873
|
+
|
|
874
|
+
response_data: Any = None
|
|
875
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
876
|
+
return utils.unmarshal_json(http_res.text, models.DocumentOut)
|
|
877
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
878
|
+
response_data = utils.unmarshal_json(
|
|
879
|
+
http_res.text, models.HTTPValidationErrorData
|
|
880
|
+
)
|
|
881
|
+
raise models.HTTPValidationError(data=response_data)
|
|
882
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
883
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
884
|
+
raise models.SDKError(
|
|
885
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
886
|
+
)
|
|
887
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
888
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
889
|
+
raise models.SDKError(
|
|
890
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
891
|
+
)
|
|
892
|
+
|
|
893
|
+
content_type = http_res.headers.get("Content-Type")
|
|
894
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
895
|
+
raise models.SDKError(
|
|
896
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
897
|
+
http_res.status_code,
|
|
898
|
+
http_res_text,
|
|
899
|
+
http_res,
|
|
900
|
+
)
|
|
901
|
+
|
|
902
|
+
def delete(
|
|
903
|
+
self,
|
|
904
|
+
*,
|
|
905
|
+
library_id: str,
|
|
906
|
+
document_id: str,
|
|
907
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
908
|
+
server_url: Optional[str] = None,
|
|
909
|
+
timeout_ms: Optional[int] = None,
|
|
910
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
911
|
+
):
|
|
912
|
+
r"""Delete a document.
|
|
913
|
+
|
|
914
|
+
Given a library and a document in that library, delete that document. The document will be deleted from the library and the search index.
|
|
915
|
+
|
|
916
|
+
:param library_id:
|
|
917
|
+
:param document_id:
|
|
918
|
+
:param retries: Override the default retry configuration for this method
|
|
919
|
+
:param server_url: Override the default server URL for this method
|
|
920
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
921
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
922
|
+
"""
|
|
923
|
+
base_url = None
|
|
924
|
+
url_variables = None
|
|
925
|
+
if timeout_ms is None:
|
|
926
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
927
|
+
|
|
928
|
+
if server_url is not None:
|
|
929
|
+
base_url = server_url
|
|
930
|
+
else:
|
|
931
|
+
base_url = self._get_url(base_url, url_variables)
|
|
932
|
+
|
|
933
|
+
request = models.LibrariesDocumentsDeleteV1Request(
|
|
934
|
+
library_id=library_id,
|
|
935
|
+
document_id=document_id,
|
|
936
|
+
)
|
|
937
|
+
|
|
938
|
+
req = self._build_request(
|
|
939
|
+
method="DELETE",
|
|
940
|
+
path="/v1/libraries/{library_id}/documents/{document_id}",
|
|
941
|
+
base_url=base_url,
|
|
942
|
+
url_variables=url_variables,
|
|
943
|
+
request=request,
|
|
944
|
+
request_body_required=False,
|
|
945
|
+
request_has_path_params=True,
|
|
946
|
+
request_has_query_params=True,
|
|
947
|
+
user_agent_header="user-agent",
|
|
948
|
+
accept_header_value="application/json",
|
|
949
|
+
http_headers=http_headers,
|
|
950
|
+
security=self.sdk_configuration.security,
|
|
951
|
+
timeout_ms=timeout_ms,
|
|
952
|
+
)
|
|
953
|
+
|
|
954
|
+
if retries == UNSET:
|
|
955
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
956
|
+
retries = self.sdk_configuration.retry_config
|
|
957
|
+
|
|
958
|
+
retry_config = None
|
|
959
|
+
if isinstance(retries, utils.RetryConfig):
|
|
960
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
961
|
+
|
|
962
|
+
http_res = self.do_request(
|
|
963
|
+
hook_ctx=HookContext(
|
|
964
|
+
config=self.sdk_configuration,
|
|
965
|
+
base_url=base_url or "",
|
|
966
|
+
operation_id="libraries_documents_delete_v1",
|
|
967
|
+
oauth2_scopes=[],
|
|
968
|
+
security_source=get_security_from_env(
|
|
969
|
+
self.sdk_configuration.security, models.Security
|
|
970
|
+
),
|
|
971
|
+
),
|
|
972
|
+
request=req,
|
|
973
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
974
|
+
retry_config=retry_config,
|
|
975
|
+
)
|
|
976
|
+
|
|
977
|
+
response_data: Any = None
|
|
978
|
+
if utils.match_response(http_res, "204", "*"):
|
|
979
|
+
return
|
|
980
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
981
|
+
response_data = utils.unmarshal_json(
|
|
982
|
+
http_res.text, models.HTTPValidationErrorData
|
|
983
|
+
)
|
|
984
|
+
raise models.HTTPValidationError(data=response_data)
|
|
985
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
986
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
987
|
+
raise models.SDKError(
|
|
988
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
989
|
+
)
|
|
990
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
991
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
992
|
+
raise models.SDKError(
|
|
993
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
994
|
+
)
|
|
995
|
+
|
|
996
|
+
content_type = http_res.headers.get("Content-Type")
|
|
997
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
998
|
+
raise models.SDKError(
|
|
999
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1000
|
+
http_res.status_code,
|
|
1001
|
+
http_res_text,
|
|
1002
|
+
http_res,
|
|
1003
|
+
)
|
|
1004
|
+
|
|
1005
|
+
async def delete_async(
|
|
1006
|
+
self,
|
|
1007
|
+
*,
|
|
1008
|
+
library_id: str,
|
|
1009
|
+
document_id: str,
|
|
1010
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1011
|
+
server_url: Optional[str] = None,
|
|
1012
|
+
timeout_ms: Optional[int] = None,
|
|
1013
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1014
|
+
):
|
|
1015
|
+
r"""Delete a document.
|
|
1016
|
+
|
|
1017
|
+
Given a library and a document in that library, delete that document. The document will be deleted from the library and the search index.
|
|
1018
|
+
|
|
1019
|
+
:param library_id:
|
|
1020
|
+
:param document_id:
|
|
1021
|
+
:param retries: Override the default retry configuration for this method
|
|
1022
|
+
:param server_url: Override the default server URL for this method
|
|
1023
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1024
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1025
|
+
"""
|
|
1026
|
+
base_url = None
|
|
1027
|
+
url_variables = None
|
|
1028
|
+
if timeout_ms is None:
|
|
1029
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1030
|
+
|
|
1031
|
+
if server_url is not None:
|
|
1032
|
+
base_url = server_url
|
|
1033
|
+
else:
|
|
1034
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1035
|
+
|
|
1036
|
+
request = models.LibrariesDocumentsDeleteV1Request(
|
|
1037
|
+
library_id=library_id,
|
|
1038
|
+
document_id=document_id,
|
|
1039
|
+
)
|
|
1040
|
+
|
|
1041
|
+
req = self._build_request_async(
|
|
1042
|
+
method="DELETE",
|
|
1043
|
+
path="/v1/libraries/{library_id}/documents/{document_id}",
|
|
1044
|
+
base_url=base_url,
|
|
1045
|
+
url_variables=url_variables,
|
|
1046
|
+
request=request,
|
|
1047
|
+
request_body_required=False,
|
|
1048
|
+
request_has_path_params=True,
|
|
1049
|
+
request_has_query_params=True,
|
|
1050
|
+
user_agent_header="user-agent",
|
|
1051
|
+
accept_header_value="application/json",
|
|
1052
|
+
http_headers=http_headers,
|
|
1053
|
+
security=self.sdk_configuration.security,
|
|
1054
|
+
timeout_ms=timeout_ms,
|
|
1055
|
+
)
|
|
1056
|
+
|
|
1057
|
+
if retries == UNSET:
|
|
1058
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1059
|
+
retries = self.sdk_configuration.retry_config
|
|
1060
|
+
|
|
1061
|
+
retry_config = None
|
|
1062
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1063
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1064
|
+
|
|
1065
|
+
http_res = await self.do_request_async(
|
|
1066
|
+
hook_ctx=HookContext(
|
|
1067
|
+
config=self.sdk_configuration,
|
|
1068
|
+
base_url=base_url or "",
|
|
1069
|
+
operation_id="libraries_documents_delete_v1",
|
|
1070
|
+
oauth2_scopes=[],
|
|
1071
|
+
security_source=get_security_from_env(
|
|
1072
|
+
self.sdk_configuration.security, models.Security
|
|
1073
|
+
),
|
|
1074
|
+
),
|
|
1075
|
+
request=req,
|
|
1076
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1077
|
+
retry_config=retry_config,
|
|
1078
|
+
)
|
|
1079
|
+
|
|
1080
|
+
response_data: Any = None
|
|
1081
|
+
if utils.match_response(http_res, "204", "*"):
|
|
1082
|
+
return
|
|
1083
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1084
|
+
response_data = utils.unmarshal_json(
|
|
1085
|
+
http_res.text, models.HTTPValidationErrorData
|
|
1086
|
+
)
|
|
1087
|
+
raise models.HTTPValidationError(data=response_data)
|
|
1088
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1089
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1090
|
+
raise models.SDKError(
|
|
1091
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1092
|
+
)
|
|
1093
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1094
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1095
|
+
raise models.SDKError(
|
|
1096
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1097
|
+
)
|
|
1098
|
+
|
|
1099
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1100
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1101
|
+
raise models.SDKError(
|
|
1102
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1103
|
+
http_res.status_code,
|
|
1104
|
+
http_res_text,
|
|
1105
|
+
http_res,
|
|
1106
|
+
)
|
|
1107
|
+
|
|
1108
|
+
def text_content(
|
|
1109
|
+
self,
|
|
1110
|
+
*,
|
|
1111
|
+
library_id: str,
|
|
1112
|
+
document_id: str,
|
|
1113
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1114
|
+
server_url: Optional[str] = None,
|
|
1115
|
+
timeout_ms: Optional[int] = None,
|
|
1116
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1117
|
+
) -> models.DocumentTextContent:
|
|
1118
|
+
r"""Retrieve the text content of a specific document.
|
|
1119
|
+
|
|
1120
|
+
Given a library and a document in that library, you can retrieve the text content of that document if it exists. For documents like pdf, docx and pptx the text content results from our processing using Mistral OCR.
|
|
1121
|
+
|
|
1122
|
+
:param library_id:
|
|
1123
|
+
:param document_id:
|
|
1124
|
+
:param retries: Override the default retry configuration for this method
|
|
1125
|
+
:param server_url: Override the default server URL for this method
|
|
1126
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1127
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1128
|
+
"""
|
|
1129
|
+
base_url = None
|
|
1130
|
+
url_variables = None
|
|
1131
|
+
if timeout_ms is None:
|
|
1132
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1133
|
+
|
|
1134
|
+
if server_url is not None:
|
|
1135
|
+
base_url = server_url
|
|
1136
|
+
else:
|
|
1137
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1138
|
+
|
|
1139
|
+
request = models.LibrariesDocumentsGetTextContentV1Request(
|
|
1140
|
+
library_id=library_id,
|
|
1141
|
+
document_id=document_id,
|
|
1142
|
+
)
|
|
1143
|
+
|
|
1144
|
+
req = self._build_request(
|
|
1145
|
+
method="GET",
|
|
1146
|
+
path="/v1/libraries/{library_id}/documents/{document_id}/text_content",
|
|
1147
|
+
base_url=base_url,
|
|
1148
|
+
url_variables=url_variables,
|
|
1149
|
+
request=request,
|
|
1150
|
+
request_body_required=False,
|
|
1151
|
+
request_has_path_params=True,
|
|
1152
|
+
request_has_query_params=True,
|
|
1153
|
+
user_agent_header="user-agent",
|
|
1154
|
+
accept_header_value="application/json",
|
|
1155
|
+
http_headers=http_headers,
|
|
1156
|
+
security=self.sdk_configuration.security,
|
|
1157
|
+
timeout_ms=timeout_ms,
|
|
1158
|
+
)
|
|
1159
|
+
|
|
1160
|
+
if retries == UNSET:
|
|
1161
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1162
|
+
retries = self.sdk_configuration.retry_config
|
|
1163
|
+
|
|
1164
|
+
retry_config = None
|
|
1165
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1166
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1167
|
+
|
|
1168
|
+
http_res = self.do_request(
|
|
1169
|
+
hook_ctx=HookContext(
|
|
1170
|
+
config=self.sdk_configuration,
|
|
1171
|
+
base_url=base_url or "",
|
|
1172
|
+
operation_id="libraries_documents_get_text_content_v1",
|
|
1173
|
+
oauth2_scopes=[],
|
|
1174
|
+
security_source=get_security_from_env(
|
|
1175
|
+
self.sdk_configuration.security, models.Security
|
|
1176
|
+
),
|
|
1177
|
+
),
|
|
1178
|
+
request=req,
|
|
1179
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1180
|
+
retry_config=retry_config,
|
|
1181
|
+
)
|
|
1182
|
+
|
|
1183
|
+
response_data: Any = None
|
|
1184
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1185
|
+
return utils.unmarshal_json(http_res.text, models.DocumentTextContent)
|
|
1186
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1187
|
+
response_data = utils.unmarshal_json(
|
|
1188
|
+
http_res.text, models.HTTPValidationErrorData
|
|
1189
|
+
)
|
|
1190
|
+
raise models.HTTPValidationError(data=response_data)
|
|
1191
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1192
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1193
|
+
raise models.SDKError(
|
|
1194
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1195
|
+
)
|
|
1196
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1197
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1198
|
+
raise models.SDKError(
|
|
1199
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1200
|
+
)
|
|
1201
|
+
|
|
1202
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1203
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1204
|
+
raise models.SDKError(
|
|
1205
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1206
|
+
http_res.status_code,
|
|
1207
|
+
http_res_text,
|
|
1208
|
+
http_res,
|
|
1209
|
+
)
|
|
1210
|
+
|
|
1211
|
+
async def text_content_async(
|
|
1212
|
+
self,
|
|
1213
|
+
*,
|
|
1214
|
+
library_id: str,
|
|
1215
|
+
document_id: str,
|
|
1216
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1217
|
+
server_url: Optional[str] = None,
|
|
1218
|
+
timeout_ms: Optional[int] = None,
|
|
1219
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1220
|
+
) -> models.DocumentTextContent:
|
|
1221
|
+
r"""Retrieve the text content of a specific document.
|
|
1222
|
+
|
|
1223
|
+
Given a library and a document in that library, you can retrieve the text content of that document if it exists. For documents like pdf, docx and pptx the text content results from our processing using Mistral OCR.
|
|
1224
|
+
|
|
1225
|
+
:param library_id:
|
|
1226
|
+
:param document_id:
|
|
1227
|
+
:param retries: Override the default retry configuration for this method
|
|
1228
|
+
:param server_url: Override the default server URL for this method
|
|
1229
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1230
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1231
|
+
"""
|
|
1232
|
+
base_url = None
|
|
1233
|
+
url_variables = None
|
|
1234
|
+
if timeout_ms is None:
|
|
1235
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1236
|
+
|
|
1237
|
+
if server_url is not None:
|
|
1238
|
+
base_url = server_url
|
|
1239
|
+
else:
|
|
1240
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1241
|
+
|
|
1242
|
+
request = models.LibrariesDocumentsGetTextContentV1Request(
|
|
1243
|
+
library_id=library_id,
|
|
1244
|
+
document_id=document_id,
|
|
1245
|
+
)
|
|
1246
|
+
|
|
1247
|
+
req = self._build_request_async(
|
|
1248
|
+
method="GET",
|
|
1249
|
+
path="/v1/libraries/{library_id}/documents/{document_id}/text_content",
|
|
1250
|
+
base_url=base_url,
|
|
1251
|
+
url_variables=url_variables,
|
|
1252
|
+
request=request,
|
|
1253
|
+
request_body_required=False,
|
|
1254
|
+
request_has_path_params=True,
|
|
1255
|
+
request_has_query_params=True,
|
|
1256
|
+
user_agent_header="user-agent",
|
|
1257
|
+
accept_header_value="application/json",
|
|
1258
|
+
http_headers=http_headers,
|
|
1259
|
+
security=self.sdk_configuration.security,
|
|
1260
|
+
timeout_ms=timeout_ms,
|
|
1261
|
+
)
|
|
1262
|
+
|
|
1263
|
+
if retries == UNSET:
|
|
1264
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1265
|
+
retries = self.sdk_configuration.retry_config
|
|
1266
|
+
|
|
1267
|
+
retry_config = None
|
|
1268
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1269
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1270
|
+
|
|
1271
|
+
http_res = await self.do_request_async(
|
|
1272
|
+
hook_ctx=HookContext(
|
|
1273
|
+
config=self.sdk_configuration,
|
|
1274
|
+
base_url=base_url or "",
|
|
1275
|
+
operation_id="libraries_documents_get_text_content_v1",
|
|
1276
|
+
oauth2_scopes=[],
|
|
1277
|
+
security_source=get_security_from_env(
|
|
1278
|
+
self.sdk_configuration.security, models.Security
|
|
1279
|
+
),
|
|
1280
|
+
),
|
|
1281
|
+
request=req,
|
|
1282
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1283
|
+
retry_config=retry_config,
|
|
1284
|
+
)
|
|
1285
|
+
|
|
1286
|
+
response_data: Any = None
|
|
1287
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1288
|
+
return utils.unmarshal_json(http_res.text, models.DocumentTextContent)
|
|
1289
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1290
|
+
response_data = utils.unmarshal_json(
|
|
1291
|
+
http_res.text, models.HTTPValidationErrorData
|
|
1292
|
+
)
|
|
1293
|
+
raise models.HTTPValidationError(data=response_data)
|
|
1294
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1295
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1296
|
+
raise models.SDKError(
|
|
1297
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1298
|
+
)
|
|
1299
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1300
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1301
|
+
raise models.SDKError(
|
|
1302
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1303
|
+
)
|
|
1304
|
+
|
|
1305
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1306
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1307
|
+
raise models.SDKError(
|
|
1308
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1309
|
+
http_res.status_code,
|
|
1310
|
+
http_res_text,
|
|
1311
|
+
http_res,
|
|
1312
|
+
)
|
|
1313
|
+
|
|
1314
|
+
def status(
|
|
1315
|
+
self,
|
|
1316
|
+
*,
|
|
1317
|
+
library_id: str,
|
|
1318
|
+
document_id: str,
|
|
1319
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1320
|
+
server_url: Optional[str] = None,
|
|
1321
|
+
timeout_ms: Optional[int] = None,
|
|
1322
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1323
|
+
) -> models.ProcessingStatusOut:
|
|
1324
|
+
r"""Retrieve the processing status of a specific document.
|
|
1325
|
+
|
|
1326
|
+
Given a library and a document in that library, retrieve the processing status of that document.
|
|
1327
|
+
|
|
1328
|
+
:param library_id:
|
|
1329
|
+
:param document_id:
|
|
1330
|
+
:param retries: Override the default retry configuration for this method
|
|
1331
|
+
:param server_url: Override the default server URL for this method
|
|
1332
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1333
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1334
|
+
"""
|
|
1335
|
+
base_url = None
|
|
1336
|
+
url_variables = None
|
|
1337
|
+
if timeout_ms is None:
|
|
1338
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1339
|
+
|
|
1340
|
+
if server_url is not None:
|
|
1341
|
+
base_url = server_url
|
|
1342
|
+
else:
|
|
1343
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1344
|
+
|
|
1345
|
+
request = models.LibrariesDocumentsGetStatusV1Request(
|
|
1346
|
+
library_id=library_id,
|
|
1347
|
+
document_id=document_id,
|
|
1348
|
+
)
|
|
1349
|
+
|
|
1350
|
+
req = self._build_request(
|
|
1351
|
+
method="GET",
|
|
1352
|
+
path="/v1/libraries/{library_id}/documents/{document_id}/status",
|
|
1353
|
+
base_url=base_url,
|
|
1354
|
+
url_variables=url_variables,
|
|
1355
|
+
request=request,
|
|
1356
|
+
request_body_required=False,
|
|
1357
|
+
request_has_path_params=True,
|
|
1358
|
+
request_has_query_params=True,
|
|
1359
|
+
user_agent_header="user-agent",
|
|
1360
|
+
accept_header_value="application/json",
|
|
1361
|
+
http_headers=http_headers,
|
|
1362
|
+
security=self.sdk_configuration.security,
|
|
1363
|
+
timeout_ms=timeout_ms,
|
|
1364
|
+
)
|
|
1365
|
+
|
|
1366
|
+
if retries == UNSET:
|
|
1367
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1368
|
+
retries = self.sdk_configuration.retry_config
|
|
1369
|
+
|
|
1370
|
+
retry_config = None
|
|
1371
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1372
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1373
|
+
|
|
1374
|
+
http_res = self.do_request(
|
|
1375
|
+
hook_ctx=HookContext(
|
|
1376
|
+
config=self.sdk_configuration,
|
|
1377
|
+
base_url=base_url or "",
|
|
1378
|
+
operation_id="libraries_documents_get_status_v1",
|
|
1379
|
+
oauth2_scopes=[],
|
|
1380
|
+
security_source=get_security_from_env(
|
|
1381
|
+
self.sdk_configuration.security, models.Security
|
|
1382
|
+
),
|
|
1383
|
+
),
|
|
1384
|
+
request=req,
|
|
1385
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1386
|
+
retry_config=retry_config,
|
|
1387
|
+
)
|
|
1388
|
+
|
|
1389
|
+
response_data: Any = None
|
|
1390
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1391
|
+
return utils.unmarshal_json(http_res.text, models.ProcessingStatusOut)
|
|
1392
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1393
|
+
response_data = utils.unmarshal_json(
|
|
1394
|
+
http_res.text, models.HTTPValidationErrorData
|
|
1395
|
+
)
|
|
1396
|
+
raise models.HTTPValidationError(data=response_data)
|
|
1397
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1398
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1399
|
+
raise models.SDKError(
|
|
1400
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1401
|
+
)
|
|
1402
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1403
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1404
|
+
raise models.SDKError(
|
|
1405
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1406
|
+
)
|
|
1407
|
+
|
|
1408
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1409
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1410
|
+
raise models.SDKError(
|
|
1411
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1412
|
+
http_res.status_code,
|
|
1413
|
+
http_res_text,
|
|
1414
|
+
http_res,
|
|
1415
|
+
)
|
|
1416
|
+
|
|
1417
|
+
async def status_async(
|
|
1418
|
+
self,
|
|
1419
|
+
*,
|
|
1420
|
+
library_id: str,
|
|
1421
|
+
document_id: str,
|
|
1422
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1423
|
+
server_url: Optional[str] = None,
|
|
1424
|
+
timeout_ms: Optional[int] = None,
|
|
1425
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1426
|
+
) -> models.ProcessingStatusOut:
|
|
1427
|
+
r"""Retrieve the processing status of a specific document.
|
|
1428
|
+
|
|
1429
|
+
Given a library and a document in that library, retrieve the processing status of that document.
|
|
1430
|
+
|
|
1431
|
+
:param library_id:
|
|
1432
|
+
:param document_id:
|
|
1433
|
+
:param retries: Override the default retry configuration for this method
|
|
1434
|
+
:param server_url: Override the default server URL for this method
|
|
1435
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1436
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1437
|
+
"""
|
|
1438
|
+
base_url = None
|
|
1439
|
+
url_variables = None
|
|
1440
|
+
if timeout_ms is None:
|
|
1441
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1442
|
+
|
|
1443
|
+
if server_url is not None:
|
|
1444
|
+
base_url = server_url
|
|
1445
|
+
else:
|
|
1446
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1447
|
+
|
|
1448
|
+
request = models.LibrariesDocumentsGetStatusV1Request(
|
|
1449
|
+
library_id=library_id,
|
|
1450
|
+
document_id=document_id,
|
|
1451
|
+
)
|
|
1452
|
+
|
|
1453
|
+
req = self._build_request_async(
|
|
1454
|
+
method="GET",
|
|
1455
|
+
path="/v1/libraries/{library_id}/documents/{document_id}/status",
|
|
1456
|
+
base_url=base_url,
|
|
1457
|
+
url_variables=url_variables,
|
|
1458
|
+
request=request,
|
|
1459
|
+
request_body_required=False,
|
|
1460
|
+
request_has_path_params=True,
|
|
1461
|
+
request_has_query_params=True,
|
|
1462
|
+
user_agent_header="user-agent",
|
|
1463
|
+
accept_header_value="application/json",
|
|
1464
|
+
http_headers=http_headers,
|
|
1465
|
+
security=self.sdk_configuration.security,
|
|
1466
|
+
timeout_ms=timeout_ms,
|
|
1467
|
+
)
|
|
1468
|
+
|
|
1469
|
+
if retries == UNSET:
|
|
1470
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1471
|
+
retries = self.sdk_configuration.retry_config
|
|
1472
|
+
|
|
1473
|
+
retry_config = None
|
|
1474
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1475
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1476
|
+
|
|
1477
|
+
http_res = await self.do_request_async(
|
|
1478
|
+
hook_ctx=HookContext(
|
|
1479
|
+
config=self.sdk_configuration,
|
|
1480
|
+
base_url=base_url or "",
|
|
1481
|
+
operation_id="libraries_documents_get_status_v1",
|
|
1482
|
+
oauth2_scopes=[],
|
|
1483
|
+
security_source=get_security_from_env(
|
|
1484
|
+
self.sdk_configuration.security, models.Security
|
|
1485
|
+
),
|
|
1486
|
+
),
|
|
1487
|
+
request=req,
|
|
1488
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1489
|
+
retry_config=retry_config,
|
|
1490
|
+
)
|
|
1491
|
+
|
|
1492
|
+
response_data: Any = None
|
|
1493
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1494
|
+
return utils.unmarshal_json(http_res.text, models.ProcessingStatusOut)
|
|
1495
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1496
|
+
response_data = utils.unmarshal_json(
|
|
1497
|
+
http_res.text, models.HTTPValidationErrorData
|
|
1498
|
+
)
|
|
1499
|
+
raise models.HTTPValidationError(data=response_data)
|
|
1500
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1501
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1502
|
+
raise models.SDKError(
|
|
1503
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1504
|
+
)
|
|
1505
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1506
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1507
|
+
raise models.SDKError(
|
|
1508
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1509
|
+
)
|
|
1510
|
+
|
|
1511
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1512
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1513
|
+
raise models.SDKError(
|
|
1514
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1515
|
+
http_res.status_code,
|
|
1516
|
+
http_res_text,
|
|
1517
|
+
http_res,
|
|
1518
|
+
)
|
|
1519
|
+
|
|
1520
|
+
def get_signed_url(
|
|
1521
|
+
self,
|
|
1522
|
+
*,
|
|
1523
|
+
library_id: str,
|
|
1524
|
+
document_id: str,
|
|
1525
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1526
|
+
server_url: Optional[str] = None,
|
|
1527
|
+
timeout_ms: Optional[int] = None,
|
|
1528
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1529
|
+
) -> str:
|
|
1530
|
+
r"""Retrieve the signed URL of a specific document.
|
|
1531
|
+
|
|
1532
|
+
Given a library and a document in that library, retrieve the signed URL of a specific document.The url will expire after 30 minutes and can be accessed by anyone with the link.
|
|
1533
|
+
|
|
1534
|
+
:param library_id:
|
|
1535
|
+
:param document_id:
|
|
1536
|
+
:param retries: Override the default retry configuration for this method
|
|
1537
|
+
:param server_url: Override the default server URL for this method
|
|
1538
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1539
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1540
|
+
"""
|
|
1541
|
+
base_url = None
|
|
1542
|
+
url_variables = None
|
|
1543
|
+
if timeout_ms is None:
|
|
1544
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1545
|
+
|
|
1546
|
+
if server_url is not None:
|
|
1547
|
+
base_url = server_url
|
|
1548
|
+
else:
|
|
1549
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1550
|
+
|
|
1551
|
+
request = models.LibrariesDocumentsGetSignedURLV1Request(
|
|
1552
|
+
library_id=library_id,
|
|
1553
|
+
document_id=document_id,
|
|
1554
|
+
)
|
|
1555
|
+
|
|
1556
|
+
req = self._build_request(
|
|
1557
|
+
method="GET",
|
|
1558
|
+
path="/v1/libraries/{library_id}/documents/{document_id}/signed-url",
|
|
1559
|
+
base_url=base_url,
|
|
1560
|
+
url_variables=url_variables,
|
|
1561
|
+
request=request,
|
|
1562
|
+
request_body_required=False,
|
|
1563
|
+
request_has_path_params=True,
|
|
1564
|
+
request_has_query_params=True,
|
|
1565
|
+
user_agent_header="user-agent",
|
|
1566
|
+
accept_header_value="application/json",
|
|
1567
|
+
http_headers=http_headers,
|
|
1568
|
+
security=self.sdk_configuration.security,
|
|
1569
|
+
timeout_ms=timeout_ms,
|
|
1570
|
+
)
|
|
1571
|
+
|
|
1572
|
+
if retries == UNSET:
|
|
1573
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1574
|
+
retries = self.sdk_configuration.retry_config
|
|
1575
|
+
|
|
1576
|
+
retry_config = None
|
|
1577
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1578
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1579
|
+
|
|
1580
|
+
http_res = self.do_request(
|
|
1581
|
+
hook_ctx=HookContext(
|
|
1582
|
+
config=self.sdk_configuration,
|
|
1583
|
+
base_url=base_url or "",
|
|
1584
|
+
operation_id="libraries_documents_get_signed_url_v1",
|
|
1585
|
+
oauth2_scopes=[],
|
|
1586
|
+
security_source=get_security_from_env(
|
|
1587
|
+
self.sdk_configuration.security, models.Security
|
|
1588
|
+
),
|
|
1589
|
+
),
|
|
1590
|
+
request=req,
|
|
1591
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1592
|
+
retry_config=retry_config,
|
|
1593
|
+
)
|
|
1594
|
+
|
|
1595
|
+
response_data: Any = None
|
|
1596
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1597
|
+
return utils.unmarshal_json(http_res.text, str)
|
|
1598
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1599
|
+
response_data = utils.unmarshal_json(
|
|
1600
|
+
http_res.text, models.HTTPValidationErrorData
|
|
1601
|
+
)
|
|
1602
|
+
raise models.HTTPValidationError(data=response_data)
|
|
1603
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1604
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1605
|
+
raise models.SDKError(
|
|
1606
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1607
|
+
)
|
|
1608
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1609
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1610
|
+
raise models.SDKError(
|
|
1611
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1612
|
+
)
|
|
1613
|
+
|
|
1614
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1615
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1616
|
+
raise models.SDKError(
|
|
1617
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1618
|
+
http_res.status_code,
|
|
1619
|
+
http_res_text,
|
|
1620
|
+
http_res,
|
|
1621
|
+
)
|
|
1622
|
+
|
|
1623
|
+
async def get_signed_url_async(
|
|
1624
|
+
self,
|
|
1625
|
+
*,
|
|
1626
|
+
library_id: str,
|
|
1627
|
+
document_id: str,
|
|
1628
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1629
|
+
server_url: Optional[str] = None,
|
|
1630
|
+
timeout_ms: Optional[int] = None,
|
|
1631
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1632
|
+
) -> str:
|
|
1633
|
+
r"""Retrieve the signed URL of a specific document.
|
|
1634
|
+
|
|
1635
|
+
Given a library and a document in that library, retrieve the signed URL of a specific document.The url will expire after 30 minutes and can be accessed by anyone with the link.
|
|
1636
|
+
|
|
1637
|
+
:param library_id:
|
|
1638
|
+
:param document_id:
|
|
1639
|
+
:param retries: Override the default retry configuration for this method
|
|
1640
|
+
:param server_url: Override the default server URL for this method
|
|
1641
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1642
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1643
|
+
"""
|
|
1644
|
+
base_url = None
|
|
1645
|
+
url_variables = None
|
|
1646
|
+
if timeout_ms is None:
|
|
1647
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1648
|
+
|
|
1649
|
+
if server_url is not None:
|
|
1650
|
+
base_url = server_url
|
|
1651
|
+
else:
|
|
1652
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1653
|
+
|
|
1654
|
+
request = models.LibrariesDocumentsGetSignedURLV1Request(
|
|
1655
|
+
library_id=library_id,
|
|
1656
|
+
document_id=document_id,
|
|
1657
|
+
)
|
|
1658
|
+
|
|
1659
|
+
req = self._build_request_async(
|
|
1660
|
+
method="GET",
|
|
1661
|
+
path="/v1/libraries/{library_id}/documents/{document_id}/signed-url",
|
|
1662
|
+
base_url=base_url,
|
|
1663
|
+
url_variables=url_variables,
|
|
1664
|
+
request=request,
|
|
1665
|
+
request_body_required=False,
|
|
1666
|
+
request_has_path_params=True,
|
|
1667
|
+
request_has_query_params=True,
|
|
1668
|
+
user_agent_header="user-agent",
|
|
1669
|
+
accept_header_value="application/json",
|
|
1670
|
+
http_headers=http_headers,
|
|
1671
|
+
security=self.sdk_configuration.security,
|
|
1672
|
+
timeout_ms=timeout_ms,
|
|
1673
|
+
)
|
|
1674
|
+
|
|
1675
|
+
if retries == UNSET:
|
|
1676
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1677
|
+
retries = self.sdk_configuration.retry_config
|
|
1678
|
+
|
|
1679
|
+
retry_config = None
|
|
1680
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1681
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1682
|
+
|
|
1683
|
+
http_res = await self.do_request_async(
|
|
1684
|
+
hook_ctx=HookContext(
|
|
1685
|
+
config=self.sdk_configuration,
|
|
1686
|
+
base_url=base_url or "",
|
|
1687
|
+
operation_id="libraries_documents_get_signed_url_v1",
|
|
1688
|
+
oauth2_scopes=[],
|
|
1689
|
+
security_source=get_security_from_env(
|
|
1690
|
+
self.sdk_configuration.security, models.Security
|
|
1691
|
+
),
|
|
1692
|
+
),
|
|
1693
|
+
request=req,
|
|
1694
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1695
|
+
retry_config=retry_config,
|
|
1696
|
+
)
|
|
1697
|
+
|
|
1698
|
+
response_data: Any = None
|
|
1699
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1700
|
+
return utils.unmarshal_json(http_res.text, str)
|
|
1701
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1702
|
+
response_data = utils.unmarshal_json(
|
|
1703
|
+
http_res.text, models.HTTPValidationErrorData
|
|
1704
|
+
)
|
|
1705
|
+
raise models.HTTPValidationError(data=response_data)
|
|
1706
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1707
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1708
|
+
raise models.SDKError(
|
|
1709
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1710
|
+
)
|
|
1711
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1712
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1713
|
+
raise models.SDKError(
|
|
1714
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1715
|
+
)
|
|
1716
|
+
|
|
1717
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1718
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1719
|
+
raise models.SDKError(
|
|
1720
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1721
|
+
http_res.status_code,
|
|
1722
|
+
http_res_text,
|
|
1723
|
+
http_res,
|
|
1724
|
+
)
|
|
1725
|
+
|
|
1726
|
+
def extracted_text_signed_url(
|
|
1727
|
+
self,
|
|
1728
|
+
*,
|
|
1729
|
+
library_id: str,
|
|
1730
|
+
document_id: str,
|
|
1731
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1732
|
+
server_url: Optional[str] = None,
|
|
1733
|
+
timeout_ms: Optional[int] = None,
|
|
1734
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1735
|
+
) -> str:
|
|
1736
|
+
r"""Retrieve the signed URL of text extracted from a given document.
|
|
1737
|
+
|
|
1738
|
+
Given a library and a document in that library, retrieve the signed URL of text extracted. For documents that are sent to the OCR this returns the result of the OCR queries.
|
|
1739
|
+
|
|
1740
|
+
:param library_id:
|
|
1741
|
+
:param document_id:
|
|
1742
|
+
:param retries: Override the default retry configuration for this method
|
|
1743
|
+
:param server_url: Override the default server URL for this method
|
|
1744
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1745
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1746
|
+
"""
|
|
1747
|
+
base_url = None
|
|
1748
|
+
url_variables = None
|
|
1749
|
+
if timeout_ms is None:
|
|
1750
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1751
|
+
|
|
1752
|
+
if server_url is not None:
|
|
1753
|
+
base_url = server_url
|
|
1754
|
+
else:
|
|
1755
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1756
|
+
|
|
1757
|
+
request = models.LibrariesDocumentsGetExtractedTextSignedURLV1Request(
|
|
1758
|
+
library_id=library_id,
|
|
1759
|
+
document_id=document_id,
|
|
1760
|
+
)
|
|
1761
|
+
|
|
1762
|
+
req = self._build_request(
|
|
1763
|
+
method="GET",
|
|
1764
|
+
path="/v1/libraries/{library_id}/documents/{document_id}/extracted-text-signed-url",
|
|
1765
|
+
base_url=base_url,
|
|
1766
|
+
url_variables=url_variables,
|
|
1767
|
+
request=request,
|
|
1768
|
+
request_body_required=False,
|
|
1769
|
+
request_has_path_params=True,
|
|
1770
|
+
request_has_query_params=True,
|
|
1771
|
+
user_agent_header="user-agent",
|
|
1772
|
+
accept_header_value="application/json",
|
|
1773
|
+
http_headers=http_headers,
|
|
1774
|
+
security=self.sdk_configuration.security,
|
|
1775
|
+
timeout_ms=timeout_ms,
|
|
1776
|
+
)
|
|
1777
|
+
|
|
1778
|
+
if retries == UNSET:
|
|
1779
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1780
|
+
retries = self.sdk_configuration.retry_config
|
|
1781
|
+
|
|
1782
|
+
retry_config = None
|
|
1783
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1784
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1785
|
+
|
|
1786
|
+
http_res = self.do_request(
|
|
1787
|
+
hook_ctx=HookContext(
|
|
1788
|
+
config=self.sdk_configuration,
|
|
1789
|
+
base_url=base_url or "",
|
|
1790
|
+
operation_id="libraries_documents_get_extracted_text_signed_url_v1",
|
|
1791
|
+
oauth2_scopes=[],
|
|
1792
|
+
security_source=get_security_from_env(
|
|
1793
|
+
self.sdk_configuration.security, models.Security
|
|
1794
|
+
),
|
|
1795
|
+
),
|
|
1796
|
+
request=req,
|
|
1797
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1798
|
+
retry_config=retry_config,
|
|
1799
|
+
)
|
|
1800
|
+
|
|
1801
|
+
response_data: Any = None
|
|
1802
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1803
|
+
return utils.unmarshal_json(http_res.text, str)
|
|
1804
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1805
|
+
response_data = utils.unmarshal_json(
|
|
1806
|
+
http_res.text, models.HTTPValidationErrorData
|
|
1807
|
+
)
|
|
1808
|
+
raise models.HTTPValidationError(data=response_data)
|
|
1809
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1810
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1811
|
+
raise models.SDKError(
|
|
1812
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1813
|
+
)
|
|
1814
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1815
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1816
|
+
raise models.SDKError(
|
|
1817
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1818
|
+
)
|
|
1819
|
+
|
|
1820
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1821
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1822
|
+
raise models.SDKError(
|
|
1823
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1824
|
+
http_res.status_code,
|
|
1825
|
+
http_res_text,
|
|
1826
|
+
http_res,
|
|
1827
|
+
)
|
|
1828
|
+
|
|
1829
|
+
async def extracted_text_signed_url_async(
|
|
1830
|
+
self,
|
|
1831
|
+
*,
|
|
1832
|
+
library_id: str,
|
|
1833
|
+
document_id: str,
|
|
1834
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1835
|
+
server_url: Optional[str] = None,
|
|
1836
|
+
timeout_ms: Optional[int] = None,
|
|
1837
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1838
|
+
) -> str:
|
|
1839
|
+
r"""Retrieve the signed URL of text extracted from a given document.
|
|
1840
|
+
|
|
1841
|
+
Given a library and a document in that library, retrieve the signed URL of text extracted. For documents that are sent to the OCR this returns the result of the OCR queries.
|
|
1842
|
+
|
|
1843
|
+
:param library_id:
|
|
1844
|
+
:param document_id:
|
|
1845
|
+
:param retries: Override the default retry configuration for this method
|
|
1846
|
+
:param server_url: Override the default server URL for this method
|
|
1847
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1848
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1849
|
+
"""
|
|
1850
|
+
base_url = None
|
|
1851
|
+
url_variables = None
|
|
1852
|
+
if timeout_ms is None:
|
|
1853
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1854
|
+
|
|
1855
|
+
if server_url is not None:
|
|
1856
|
+
base_url = server_url
|
|
1857
|
+
else:
|
|
1858
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1859
|
+
|
|
1860
|
+
request = models.LibrariesDocumentsGetExtractedTextSignedURLV1Request(
|
|
1861
|
+
library_id=library_id,
|
|
1862
|
+
document_id=document_id,
|
|
1863
|
+
)
|
|
1864
|
+
|
|
1865
|
+
req = self._build_request_async(
|
|
1866
|
+
method="GET",
|
|
1867
|
+
path="/v1/libraries/{library_id}/documents/{document_id}/extracted-text-signed-url",
|
|
1868
|
+
base_url=base_url,
|
|
1869
|
+
url_variables=url_variables,
|
|
1870
|
+
request=request,
|
|
1871
|
+
request_body_required=False,
|
|
1872
|
+
request_has_path_params=True,
|
|
1873
|
+
request_has_query_params=True,
|
|
1874
|
+
user_agent_header="user-agent",
|
|
1875
|
+
accept_header_value="application/json",
|
|
1876
|
+
http_headers=http_headers,
|
|
1877
|
+
security=self.sdk_configuration.security,
|
|
1878
|
+
timeout_ms=timeout_ms,
|
|
1879
|
+
)
|
|
1880
|
+
|
|
1881
|
+
if retries == UNSET:
|
|
1882
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1883
|
+
retries = self.sdk_configuration.retry_config
|
|
1884
|
+
|
|
1885
|
+
retry_config = None
|
|
1886
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1887
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1888
|
+
|
|
1889
|
+
http_res = await self.do_request_async(
|
|
1890
|
+
hook_ctx=HookContext(
|
|
1891
|
+
config=self.sdk_configuration,
|
|
1892
|
+
base_url=base_url or "",
|
|
1893
|
+
operation_id="libraries_documents_get_extracted_text_signed_url_v1",
|
|
1894
|
+
oauth2_scopes=[],
|
|
1895
|
+
security_source=get_security_from_env(
|
|
1896
|
+
self.sdk_configuration.security, models.Security
|
|
1897
|
+
),
|
|
1898
|
+
),
|
|
1899
|
+
request=req,
|
|
1900
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1901
|
+
retry_config=retry_config,
|
|
1902
|
+
)
|
|
1903
|
+
|
|
1904
|
+
response_data: Any = None
|
|
1905
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1906
|
+
return utils.unmarshal_json(http_res.text, str)
|
|
1907
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1908
|
+
response_data = utils.unmarshal_json(
|
|
1909
|
+
http_res.text, models.HTTPValidationErrorData
|
|
1910
|
+
)
|
|
1911
|
+
raise models.HTTPValidationError(data=response_data)
|
|
1912
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1913
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1914
|
+
raise models.SDKError(
|
|
1915
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1916
|
+
)
|
|
1917
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1918
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1919
|
+
raise models.SDKError(
|
|
1920
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1921
|
+
)
|
|
1922
|
+
|
|
1923
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1924
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1925
|
+
raise models.SDKError(
|
|
1926
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1927
|
+
http_res.status_code,
|
|
1928
|
+
http_res_text,
|
|
1929
|
+
http_res,
|
|
1930
|
+
)
|
|
1931
|
+
|
|
1932
|
+
def reprocess(
|
|
1933
|
+
self,
|
|
1934
|
+
*,
|
|
1935
|
+
library_id: str,
|
|
1936
|
+
document_id: str,
|
|
1937
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1938
|
+
server_url: Optional[str] = None,
|
|
1939
|
+
timeout_ms: Optional[int] = None,
|
|
1940
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1941
|
+
):
|
|
1942
|
+
r"""Reprocess a document.
|
|
1943
|
+
|
|
1944
|
+
Given a library and a document in that library, reprocess that document, it will be billed again.
|
|
1945
|
+
|
|
1946
|
+
:param library_id:
|
|
1947
|
+
:param document_id:
|
|
1948
|
+
:param retries: Override the default retry configuration for this method
|
|
1949
|
+
:param server_url: Override the default server URL for this method
|
|
1950
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1951
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1952
|
+
"""
|
|
1953
|
+
base_url = None
|
|
1954
|
+
url_variables = None
|
|
1955
|
+
if timeout_ms is None:
|
|
1956
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1957
|
+
|
|
1958
|
+
if server_url is not None:
|
|
1959
|
+
base_url = server_url
|
|
1960
|
+
else:
|
|
1961
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1962
|
+
|
|
1963
|
+
request = models.LibrariesDocumentsReprocessV1Request(
|
|
1964
|
+
library_id=library_id,
|
|
1965
|
+
document_id=document_id,
|
|
1966
|
+
)
|
|
1967
|
+
|
|
1968
|
+
req = self._build_request(
|
|
1969
|
+
method="POST",
|
|
1970
|
+
path="/v1/libraries/{library_id}/documents/{document_id}/reprocess",
|
|
1971
|
+
base_url=base_url,
|
|
1972
|
+
url_variables=url_variables,
|
|
1973
|
+
request=request,
|
|
1974
|
+
request_body_required=False,
|
|
1975
|
+
request_has_path_params=True,
|
|
1976
|
+
request_has_query_params=True,
|
|
1977
|
+
user_agent_header="user-agent",
|
|
1978
|
+
accept_header_value="application/json",
|
|
1979
|
+
http_headers=http_headers,
|
|
1980
|
+
security=self.sdk_configuration.security,
|
|
1981
|
+
timeout_ms=timeout_ms,
|
|
1982
|
+
)
|
|
1983
|
+
|
|
1984
|
+
if retries == UNSET:
|
|
1985
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1986
|
+
retries = self.sdk_configuration.retry_config
|
|
1987
|
+
|
|
1988
|
+
retry_config = None
|
|
1989
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1990
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1991
|
+
|
|
1992
|
+
http_res = self.do_request(
|
|
1993
|
+
hook_ctx=HookContext(
|
|
1994
|
+
config=self.sdk_configuration,
|
|
1995
|
+
base_url=base_url or "",
|
|
1996
|
+
operation_id="libraries_documents_reprocess_v1",
|
|
1997
|
+
oauth2_scopes=[],
|
|
1998
|
+
security_source=get_security_from_env(
|
|
1999
|
+
self.sdk_configuration.security, models.Security
|
|
2000
|
+
),
|
|
2001
|
+
),
|
|
2002
|
+
request=req,
|
|
2003
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2004
|
+
retry_config=retry_config,
|
|
2005
|
+
)
|
|
2006
|
+
|
|
2007
|
+
response_data: Any = None
|
|
2008
|
+
if utils.match_response(http_res, "204", "*"):
|
|
2009
|
+
return
|
|
2010
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2011
|
+
response_data = utils.unmarshal_json(
|
|
2012
|
+
http_res.text, models.HTTPValidationErrorData
|
|
2013
|
+
)
|
|
2014
|
+
raise models.HTTPValidationError(data=response_data)
|
|
2015
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2016
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2017
|
+
raise models.SDKError(
|
|
2018
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2019
|
+
)
|
|
2020
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2021
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2022
|
+
raise models.SDKError(
|
|
2023
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2024
|
+
)
|
|
2025
|
+
|
|
2026
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2027
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2028
|
+
raise models.SDKError(
|
|
2029
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2030
|
+
http_res.status_code,
|
|
2031
|
+
http_res_text,
|
|
2032
|
+
http_res,
|
|
2033
|
+
)
|
|
2034
|
+
|
|
2035
|
+
async def reprocess_async(
|
|
2036
|
+
self,
|
|
2037
|
+
*,
|
|
2038
|
+
library_id: str,
|
|
2039
|
+
document_id: str,
|
|
2040
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2041
|
+
server_url: Optional[str] = None,
|
|
2042
|
+
timeout_ms: Optional[int] = None,
|
|
2043
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
2044
|
+
):
|
|
2045
|
+
r"""Reprocess a document.
|
|
2046
|
+
|
|
2047
|
+
Given a library and a document in that library, reprocess that document, it will be billed again.
|
|
2048
|
+
|
|
2049
|
+
:param library_id:
|
|
2050
|
+
:param document_id:
|
|
2051
|
+
:param retries: Override the default retry configuration for this method
|
|
2052
|
+
:param server_url: Override the default server URL for this method
|
|
2053
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
2054
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
2055
|
+
"""
|
|
2056
|
+
base_url = None
|
|
2057
|
+
url_variables = None
|
|
2058
|
+
if timeout_ms is None:
|
|
2059
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
2060
|
+
|
|
2061
|
+
if server_url is not None:
|
|
2062
|
+
base_url = server_url
|
|
2063
|
+
else:
|
|
2064
|
+
base_url = self._get_url(base_url, url_variables)
|
|
2065
|
+
|
|
2066
|
+
request = models.LibrariesDocumentsReprocessV1Request(
|
|
2067
|
+
library_id=library_id,
|
|
2068
|
+
document_id=document_id,
|
|
2069
|
+
)
|
|
2070
|
+
|
|
2071
|
+
req = self._build_request_async(
|
|
2072
|
+
method="POST",
|
|
2073
|
+
path="/v1/libraries/{library_id}/documents/{document_id}/reprocess",
|
|
2074
|
+
base_url=base_url,
|
|
2075
|
+
url_variables=url_variables,
|
|
2076
|
+
request=request,
|
|
2077
|
+
request_body_required=False,
|
|
2078
|
+
request_has_path_params=True,
|
|
2079
|
+
request_has_query_params=True,
|
|
2080
|
+
user_agent_header="user-agent",
|
|
2081
|
+
accept_header_value="application/json",
|
|
2082
|
+
http_headers=http_headers,
|
|
2083
|
+
security=self.sdk_configuration.security,
|
|
2084
|
+
timeout_ms=timeout_ms,
|
|
2085
|
+
)
|
|
2086
|
+
|
|
2087
|
+
if retries == UNSET:
|
|
2088
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2089
|
+
retries = self.sdk_configuration.retry_config
|
|
2090
|
+
|
|
2091
|
+
retry_config = None
|
|
2092
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2093
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2094
|
+
|
|
2095
|
+
http_res = await self.do_request_async(
|
|
2096
|
+
hook_ctx=HookContext(
|
|
2097
|
+
config=self.sdk_configuration,
|
|
2098
|
+
base_url=base_url or "",
|
|
2099
|
+
operation_id="libraries_documents_reprocess_v1",
|
|
2100
|
+
oauth2_scopes=[],
|
|
2101
|
+
security_source=get_security_from_env(
|
|
2102
|
+
self.sdk_configuration.security, models.Security
|
|
2103
|
+
),
|
|
2104
|
+
),
|
|
2105
|
+
request=req,
|
|
2106
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2107
|
+
retry_config=retry_config,
|
|
2108
|
+
)
|
|
2109
|
+
|
|
2110
|
+
response_data: Any = None
|
|
2111
|
+
if utils.match_response(http_res, "204", "*"):
|
|
2112
|
+
return
|
|
2113
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2114
|
+
response_data = utils.unmarshal_json(
|
|
2115
|
+
http_res.text, models.HTTPValidationErrorData
|
|
2116
|
+
)
|
|
2117
|
+
raise models.HTTPValidationError(data=response_data)
|
|
2118
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2119
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2120
|
+
raise models.SDKError(
|
|
2121
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2122
|
+
)
|
|
2123
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2124
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2125
|
+
raise models.SDKError(
|
|
2126
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2127
|
+
)
|
|
2128
|
+
|
|
2129
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2130
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2131
|
+
raise models.SDKError(
|
|
2132
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2133
|
+
http_res.status_code,
|
|
2134
|
+
http_res_text,
|
|
2135
|
+
http_res,
|
|
2136
|
+
)
|