lambdadb 0.1.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.
Potentially problematic release.
This version of lambdadb might be problematic. Click here for more details.
- lambdadb/__init__.py +17 -0
- lambdadb/_hooks/__init__.py +5 -0
- lambdadb/_hooks/registration.py +13 -0
- lambdadb/_hooks/sdkhooks.py +76 -0
- lambdadb/_hooks/types.py +106 -0
- lambdadb/_version.py +15 -0
- lambdadb/basesdk.py +358 -0
- lambdadb/collections.py +1630 -0
- lambdadb/docs.py +1328 -0
- lambdadb/errors/__init__.py +74 -0
- lambdadb/errors/apierror.py +22 -0
- lambdadb/errors/badrequest_error.py +20 -0
- lambdadb/errors/internalservererror.py +20 -0
- lambdadb/errors/resourcealreadyexists_error.py +20 -0
- lambdadb/errors/resourcenotfound_error.py +20 -0
- lambdadb/errors/toomanyrequests_error.py +20 -0
- lambdadb/errors/unauthenticated_error.py +20 -0
- lambdadb/httpclient.py +126 -0
- lambdadb/models/__init__.py +420 -0
- lambdadb/models/bulkupsertdocsop.py +59 -0
- lambdadb/models/collectionresponse.py +64 -0
- lambdadb/models/createcollectionop.py +64 -0
- lambdadb/models/createprojectop.py +39 -0
- lambdadb/models/deletecollectionop.py +43 -0
- lambdadb/models/deletedocsop.py +88 -0
- lambdadb/models/deleteprojectop.py +52 -0
- lambdadb/models/fetchdocsop.py +102 -0
- lambdadb/models/getbulkupsertdocsop.py +82 -0
- lambdadb/models/getcollectionop.py +30 -0
- lambdadb/models/getprojectop.py +39 -0
- lambdadb/models/indexconfigs_union.py +95 -0
- lambdadb/models/listcollectionsop.py +35 -0
- lambdadb/models/listprojectsop.py +38 -0
- lambdadb/models/projectresponse.py +38 -0
- lambdadb/models/querycollectionop.py +152 -0
- lambdadb/models/security.py +25 -0
- lambdadb/models/status.py +12 -0
- lambdadb/models/updatecollectionop.py +48 -0
- lambdadb/models/updateprojectop.py +58 -0
- lambdadb/models/upsertdocsop.py +67 -0
- lambdadb/projects.py +1228 -0
- lambdadb/py.typed +1 -0
- lambdadb/sdk.py +170 -0
- lambdadb/sdkconfiguration.py +56 -0
- lambdadb/types/__init__.py +21 -0
- lambdadb/types/basemodel.py +39 -0
- lambdadb/utils/__init__.py +187 -0
- lambdadb/utils/annotations.py +55 -0
- lambdadb/utils/datetimes.py +23 -0
- lambdadb/utils/enums.py +74 -0
- lambdadb/utils/eventstreaming.py +238 -0
- lambdadb/utils/forms.py +202 -0
- lambdadb/utils/headers.py +136 -0
- lambdadb/utils/logger.py +27 -0
- lambdadb/utils/metadata.py +118 -0
- lambdadb/utils/queryparams.py +205 -0
- lambdadb/utils/requestbodies.py +66 -0
- lambdadb/utils/retries.py +217 -0
- lambdadb/utils/security.py +192 -0
- lambdadb/utils/serializers.py +248 -0
- lambdadb/utils/url.py +155 -0
- lambdadb/utils/values.py +137 -0
- lambdadb-0.1.2.dist-info/LICENSE +201 -0
- lambdadb-0.1.2.dist-info/METADATA +514 -0
- lambdadb-0.1.2.dist-info/RECORD +66 -0
- lambdadb-0.1.2.dist-info/WHEEL +4 -0
lambdadb/docs.py
ADDED
|
@@ -0,0 +1,1328 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from lambdadb import errors, models, utils
|
|
5
|
+
from lambdadb._hooks import HookContext
|
|
6
|
+
from lambdadb.types import OptionalNullable, UNSET
|
|
7
|
+
from lambdadb.utils import get_security_from_env
|
|
8
|
+
from typing import Any, List, Mapping, Optional, Union
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Docs(BaseSDK):
|
|
12
|
+
def upsert(
|
|
13
|
+
self,
|
|
14
|
+
*,
|
|
15
|
+
project_name: str,
|
|
16
|
+
collection_name: str,
|
|
17
|
+
docs: Union[List[models.UpsertDocsDoc], List[models.UpsertDocsDocTypedDict]],
|
|
18
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
19
|
+
server_url: Optional[str] = None,
|
|
20
|
+
timeout_ms: Optional[int] = None,
|
|
21
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
22
|
+
) -> models.UpsertDocsResponse:
|
|
23
|
+
r"""Upsert documents into an collection. Note that the maximum supported payload size is 6MB.
|
|
24
|
+
|
|
25
|
+
:param project_name: Project name.
|
|
26
|
+
:param collection_name: Collection name.
|
|
27
|
+
:param docs: A list of documents to upsert.
|
|
28
|
+
:param retries: Override the default retry configuration for this method
|
|
29
|
+
:param server_url: Override the default server URL for this method
|
|
30
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
31
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
32
|
+
"""
|
|
33
|
+
base_url = None
|
|
34
|
+
url_variables = None
|
|
35
|
+
if timeout_ms is None:
|
|
36
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
37
|
+
|
|
38
|
+
if server_url is not None:
|
|
39
|
+
base_url = server_url
|
|
40
|
+
else:
|
|
41
|
+
base_url = self._get_url(base_url, url_variables)
|
|
42
|
+
|
|
43
|
+
request = models.UpsertDocsRequest(
|
|
44
|
+
project_name=project_name,
|
|
45
|
+
collection_name=collection_name,
|
|
46
|
+
request_body=models.UpsertDocsRequestBody(
|
|
47
|
+
docs=utils.get_pydantic_model(docs, List[models.UpsertDocsDoc]),
|
|
48
|
+
),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
req = self._build_request(
|
|
52
|
+
method="POST",
|
|
53
|
+
path="/projects/{projectName}/collections/{collectionName}/docs/upsert",
|
|
54
|
+
base_url=base_url,
|
|
55
|
+
url_variables=url_variables,
|
|
56
|
+
request=request,
|
|
57
|
+
request_body_required=True,
|
|
58
|
+
request_has_path_params=True,
|
|
59
|
+
request_has_query_params=True,
|
|
60
|
+
user_agent_header="user-agent",
|
|
61
|
+
accept_header_value="application/json",
|
|
62
|
+
http_headers=http_headers,
|
|
63
|
+
security=self.sdk_configuration.security,
|
|
64
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
65
|
+
request.request_body, False, False, "json", models.UpsertDocsRequestBody
|
|
66
|
+
),
|
|
67
|
+
timeout_ms=timeout_ms,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
if retries == UNSET:
|
|
71
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
72
|
+
retries = self.sdk_configuration.retry_config
|
|
73
|
+
else:
|
|
74
|
+
retries = utils.RetryConfig(
|
|
75
|
+
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
retry_config = None
|
|
79
|
+
if isinstance(retries, utils.RetryConfig):
|
|
80
|
+
retry_config = (retries, ["429", "5XX"])
|
|
81
|
+
|
|
82
|
+
http_res = self.do_request(
|
|
83
|
+
hook_ctx=HookContext(
|
|
84
|
+
base_url=base_url or "",
|
|
85
|
+
operation_id="upsertDocs",
|
|
86
|
+
oauth2_scopes=[],
|
|
87
|
+
security_source=get_security_from_env(
|
|
88
|
+
self.sdk_configuration.security, models.Security
|
|
89
|
+
),
|
|
90
|
+
),
|
|
91
|
+
request=req,
|
|
92
|
+
error_status_codes=["400", "401", "404", "429", "4XX", "500", "5XX"],
|
|
93
|
+
retry_config=retry_config,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
response_data: Any = None
|
|
97
|
+
if utils.match_response(http_res, "202", "application/json"):
|
|
98
|
+
return utils.unmarshal_json(http_res.text, models.UpsertDocsResponse)
|
|
99
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
100
|
+
response_data = utils.unmarshal_json(
|
|
101
|
+
http_res.text, errors.BadRequestErrorData
|
|
102
|
+
)
|
|
103
|
+
raise errors.BadRequestError(data=response_data)
|
|
104
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
105
|
+
response_data = utils.unmarshal_json(
|
|
106
|
+
http_res.text, errors.UnauthenticatedErrorData
|
|
107
|
+
)
|
|
108
|
+
raise errors.UnauthenticatedError(data=response_data)
|
|
109
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
110
|
+
response_data = utils.unmarshal_json(
|
|
111
|
+
http_res.text, errors.ResourceNotFoundErrorData
|
|
112
|
+
)
|
|
113
|
+
raise errors.ResourceNotFoundError(data=response_data)
|
|
114
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
115
|
+
response_data = utils.unmarshal_json(
|
|
116
|
+
http_res.text, errors.TooManyRequestsErrorData
|
|
117
|
+
)
|
|
118
|
+
raise errors.TooManyRequestsError(data=response_data)
|
|
119
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
120
|
+
response_data = utils.unmarshal_json(
|
|
121
|
+
http_res.text, errors.InternalServerErrorData
|
|
122
|
+
)
|
|
123
|
+
raise errors.InternalServerError(data=response_data)
|
|
124
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
125
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
126
|
+
raise errors.APIError(
|
|
127
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
128
|
+
)
|
|
129
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
130
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
131
|
+
raise errors.APIError(
|
|
132
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
content_type = http_res.headers.get("Content-Type")
|
|
136
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
137
|
+
raise errors.APIError(
|
|
138
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
139
|
+
http_res.status_code,
|
|
140
|
+
http_res_text,
|
|
141
|
+
http_res,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
async def upsert_async(
|
|
145
|
+
self,
|
|
146
|
+
*,
|
|
147
|
+
project_name: str,
|
|
148
|
+
collection_name: str,
|
|
149
|
+
docs: Union[List[models.UpsertDocsDoc], List[models.UpsertDocsDocTypedDict]],
|
|
150
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
151
|
+
server_url: Optional[str] = None,
|
|
152
|
+
timeout_ms: Optional[int] = None,
|
|
153
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
154
|
+
) -> models.UpsertDocsResponse:
|
|
155
|
+
r"""Upsert documents into an collection. Note that the maximum supported payload size is 6MB.
|
|
156
|
+
|
|
157
|
+
:param project_name: Project name.
|
|
158
|
+
:param collection_name: Collection name.
|
|
159
|
+
:param docs: A list of documents to upsert.
|
|
160
|
+
:param retries: Override the default retry configuration for this method
|
|
161
|
+
:param server_url: Override the default server URL for this method
|
|
162
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
163
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
164
|
+
"""
|
|
165
|
+
base_url = None
|
|
166
|
+
url_variables = None
|
|
167
|
+
if timeout_ms is None:
|
|
168
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
169
|
+
|
|
170
|
+
if server_url is not None:
|
|
171
|
+
base_url = server_url
|
|
172
|
+
else:
|
|
173
|
+
base_url = self._get_url(base_url, url_variables)
|
|
174
|
+
|
|
175
|
+
request = models.UpsertDocsRequest(
|
|
176
|
+
project_name=project_name,
|
|
177
|
+
collection_name=collection_name,
|
|
178
|
+
request_body=models.UpsertDocsRequestBody(
|
|
179
|
+
docs=utils.get_pydantic_model(docs, List[models.UpsertDocsDoc]),
|
|
180
|
+
),
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
req = self._build_request_async(
|
|
184
|
+
method="POST",
|
|
185
|
+
path="/projects/{projectName}/collections/{collectionName}/docs/upsert",
|
|
186
|
+
base_url=base_url,
|
|
187
|
+
url_variables=url_variables,
|
|
188
|
+
request=request,
|
|
189
|
+
request_body_required=True,
|
|
190
|
+
request_has_path_params=True,
|
|
191
|
+
request_has_query_params=True,
|
|
192
|
+
user_agent_header="user-agent",
|
|
193
|
+
accept_header_value="application/json",
|
|
194
|
+
http_headers=http_headers,
|
|
195
|
+
security=self.sdk_configuration.security,
|
|
196
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
197
|
+
request.request_body, False, False, "json", models.UpsertDocsRequestBody
|
|
198
|
+
),
|
|
199
|
+
timeout_ms=timeout_ms,
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
if retries == UNSET:
|
|
203
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
204
|
+
retries = self.sdk_configuration.retry_config
|
|
205
|
+
else:
|
|
206
|
+
retries = utils.RetryConfig(
|
|
207
|
+
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
retry_config = None
|
|
211
|
+
if isinstance(retries, utils.RetryConfig):
|
|
212
|
+
retry_config = (retries, ["429", "5XX"])
|
|
213
|
+
|
|
214
|
+
http_res = await self.do_request_async(
|
|
215
|
+
hook_ctx=HookContext(
|
|
216
|
+
base_url=base_url or "",
|
|
217
|
+
operation_id="upsertDocs",
|
|
218
|
+
oauth2_scopes=[],
|
|
219
|
+
security_source=get_security_from_env(
|
|
220
|
+
self.sdk_configuration.security, models.Security
|
|
221
|
+
),
|
|
222
|
+
),
|
|
223
|
+
request=req,
|
|
224
|
+
error_status_codes=["400", "401", "404", "429", "4XX", "500", "5XX"],
|
|
225
|
+
retry_config=retry_config,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
response_data: Any = None
|
|
229
|
+
if utils.match_response(http_res, "202", "application/json"):
|
|
230
|
+
return utils.unmarshal_json(http_res.text, models.UpsertDocsResponse)
|
|
231
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
232
|
+
response_data = utils.unmarshal_json(
|
|
233
|
+
http_res.text, errors.BadRequestErrorData
|
|
234
|
+
)
|
|
235
|
+
raise errors.BadRequestError(data=response_data)
|
|
236
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
237
|
+
response_data = utils.unmarshal_json(
|
|
238
|
+
http_res.text, errors.UnauthenticatedErrorData
|
|
239
|
+
)
|
|
240
|
+
raise errors.UnauthenticatedError(data=response_data)
|
|
241
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
242
|
+
response_data = utils.unmarshal_json(
|
|
243
|
+
http_res.text, errors.ResourceNotFoundErrorData
|
|
244
|
+
)
|
|
245
|
+
raise errors.ResourceNotFoundError(data=response_data)
|
|
246
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
247
|
+
response_data = utils.unmarshal_json(
|
|
248
|
+
http_res.text, errors.TooManyRequestsErrorData
|
|
249
|
+
)
|
|
250
|
+
raise errors.TooManyRequestsError(data=response_data)
|
|
251
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
252
|
+
response_data = utils.unmarshal_json(
|
|
253
|
+
http_res.text, errors.InternalServerErrorData
|
|
254
|
+
)
|
|
255
|
+
raise errors.InternalServerError(data=response_data)
|
|
256
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
257
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
258
|
+
raise errors.APIError(
|
|
259
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
260
|
+
)
|
|
261
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
262
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
263
|
+
raise errors.APIError(
|
|
264
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
content_type = http_res.headers.get("Content-Type")
|
|
268
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
269
|
+
raise errors.APIError(
|
|
270
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
271
|
+
http_res.status_code,
|
|
272
|
+
http_res_text,
|
|
273
|
+
http_res,
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
def get_bulk_upsert(
|
|
277
|
+
self,
|
|
278
|
+
*,
|
|
279
|
+
project_name: str,
|
|
280
|
+
collection_name: str,
|
|
281
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
282
|
+
server_url: Optional[str] = None,
|
|
283
|
+
timeout_ms: Optional[int] = None,
|
|
284
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
285
|
+
) -> models.GetBulkUpsertDocsResponse:
|
|
286
|
+
r"""Request required info to upload documents.
|
|
287
|
+
|
|
288
|
+
:param project_name: Project name.
|
|
289
|
+
:param collection_name: Collection name.
|
|
290
|
+
:param retries: Override the default retry configuration for this method
|
|
291
|
+
:param server_url: Override the default server URL for this method
|
|
292
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
293
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
294
|
+
"""
|
|
295
|
+
base_url = None
|
|
296
|
+
url_variables = None
|
|
297
|
+
if timeout_ms is None:
|
|
298
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
299
|
+
|
|
300
|
+
if server_url is not None:
|
|
301
|
+
base_url = server_url
|
|
302
|
+
else:
|
|
303
|
+
base_url = self._get_url(base_url, url_variables)
|
|
304
|
+
|
|
305
|
+
request = models.GetBulkUpsertDocsRequest(
|
|
306
|
+
project_name=project_name,
|
|
307
|
+
collection_name=collection_name,
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
req = self._build_request(
|
|
311
|
+
method="GET",
|
|
312
|
+
path="/projects/{projectName}/collections/{collectionName}/docs/bulk-upsert",
|
|
313
|
+
base_url=base_url,
|
|
314
|
+
url_variables=url_variables,
|
|
315
|
+
request=request,
|
|
316
|
+
request_body_required=False,
|
|
317
|
+
request_has_path_params=True,
|
|
318
|
+
request_has_query_params=True,
|
|
319
|
+
user_agent_header="user-agent",
|
|
320
|
+
accept_header_value="application/json",
|
|
321
|
+
http_headers=http_headers,
|
|
322
|
+
security=self.sdk_configuration.security,
|
|
323
|
+
timeout_ms=timeout_ms,
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
if retries == UNSET:
|
|
327
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
328
|
+
retries = self.sdk_configuration.retry_config
|
|
329
|
+
else:
|
|
330
|
+
retries = utils.RetryConfig(
|
|
331
|
+
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
retry_config = None
|
|
335
|
+
if isinstance(retries, utils.RetryConfig):
|
|
336
|
+
retry_config = (retries, ["429", "5XX"])
|
|
337
|
+
|
|
338
|
+
http_res = self.do_request(
|
|
339
|
+
hook_ctx=HookContext(
|
|
340
|
+
base_url=base_url or "",
|
|
341
|
+
operation_id="getBulkUpsertDocs",
|
|
342
|
+
oauth2_scopes=[],
|
|
343
|
+
security_source=get_security_from_env(
|
|
344
|
+
self.sdk_configuration.security, models.Security
|
|
345
|
+
),
|
|
346
|
+
),
|
|
347
|
+
request=req,
|
|
348
|
+
error_status_codes=["401", "404", "429", "4XX", "500", "5XX"],
|
|
349
|
+
retry_config=retry_config,
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
response_data: Any = None
|
|
353
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
354
|
+
return utils.unmarshal_json(http_res.text, models.GetBulkUpsertDocsResponse)
|
|
355
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
356
|
+
response_data = utils.unmarshal_json(
|
|
357
|
+
http_res.text, errors.UnauthenticatedErrorData
|
|
358
|
+
)
|
|
359
|
+
raise errors.UnauthenticatedError(data=response_data)
|
|
360
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
361
|
+
response_data = utils.unmarshal_json(
|
|
362
|
+
http_res.text, errors.ResourceNotFoundErrorData
|
|
363
|
+
)
|
|
364
|
+
raise errors.ResourceNotFoundError(data=response_data)
|
|
365
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
366
|
+
response_data = utils.unmarshal_json(
|
|
367
|
+
http_res.text, errors.TooManyRequestsErrorData
|
|
368
|
+
)
|
|
369
|
+
raise errors.TooManyRequestsError(data=response_data)
|
|
370
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
371
|
+
response_data = utils.unmarshal_json(
|
|
372
|
+
http_res.text, errors.InternalServerErrorData
|
|
373
|
+
)
|
|
374
|
+
raise errors.InternalServerError(data=response_data)
|
|
375
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
376
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
377
|
+
raise errors.APIError(
|
|
378
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
379
|
+
)
|
|
380
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
381
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
382
|
+
raise errors.APIError(
|
|
383
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
content_type = http_res.headers.get("Content-Type")
|
|
387
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
388
|
+
raise errors.APIError(
|
|
389
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
390
|
+
http_res.status_code,
|
|
391
|
+
http_res_text,
|
|
392
|
+
http_res,
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
async def get_bulk_upsert_async(
|
|
396
|
+
self,
|
|
397
|
+
*,
|
|
398
|
+
project_name: str,
|
|
399
|
+
collection_name: str,
|
|
400
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
401
|
+
server_url: Optional[str] = None,
|
|
402
|
+
timeout_ms: Optional[int] = None,
|
|
403
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
404
|
+
) -> models.GetBulkUpsertDocsResponse:
|
|
405
|
+
r"""Request required info to upload documents.
|
|
406
|
+
|
|
407
|
+
:param project_name: Project name.
|
|
408
|
+
:param collection_name: Collection name.
|
|
409
|
+
:param retries: Override the default retry configuration for this method
|
|
410
|
+
:param server_url: Override the default server URL for this method
|
|
411
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
412
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
413
|
+
"""
|
|
414
|
+
base_url = None
|
|
415
|
+
url_variables = None
|
|
416
|
+
if timeout_ms is None:
|
|
417
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
418
|
+
|
|
419
|
+
if server_url is not None:
|
|
420
|
+
base_url = server_url
|
|
421
|
+
else:
|
|
422
|
+
base_url = self._get_url(base_url, url_variables)
|
|
423
|
+
|
|
424
|
+
request = models.GetBulkUpsertDocsRequest(
|
|
425
|
+
project_name=project_name,
|
|
426
|
+
collection_name=collection_name,
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
req = self._build_request_async(
|
|
430
|
+
method="GET",
|
|
431
|
+
path="/projects/{projectName}/collections/{collectionName}/docs/bulk-upsert",
|
|
432
|
+
base_url=base_url,
|
|
433
|
+
url_variables=url_variables,
|
|
434
|
+
request=request,
|
|
435
|
+
request_body_required=False,
|
|
436
|
+
request_has_path_params=True,
|
|
437
|
+
request_has_query_params=True,
|
|
438
|
+
user_agent_header="user-agent",
|
|
439
|
+
accept_header_value="application/json",
|
|
440
|
+
http_headers=http_headers,
|
|
441
|
+
security=self.sdk_configuration.security,
|
|
442
|
+
timeout_ms=timeout_ms,
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
if retries == UNSET:
|
|
446
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
447
|
+
retries = self.sdk_configuration.retry_config
|
|
448
|
+
else:
|
|
449
|
+
retries = utils.RetryConfig(
|
|
450
|
+
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
retry_config = None
|
|
454
|
+
if isinstance(retries, utils.RetryConfig):
|
|
455
|
+
retry_config = (retries, ["429", "5XX"])
|
|
456
|
+
|
|
457
|
+
http_res = await self.do_request_async(
|
|
458
|
+
hook_ctx=HookContext(
|
|
459
|
+
base_url=base_url or "",
|
|
460
|
+
operation_id="getBulkUpsertDocs",
|
|
461
|
+
oauth2_scopes=[],
|
|
462
|
+
security_source=get_security_from_env(
|
|
463
|
+
self.sdk_configuration.security, models.Security
|
|
464
|
+
),
|
|
465
|
+
),
|
|
466
|
+
request=req,
|
|
467
|
+
error_status_codes=["401", "404", "429", "4XX", "500", "5XX"],
|
|
468
|
+
retry_config=retry_config,
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
response_data: Any = None
|
|
472
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
473
|
+
return utils.unmarshal_json(http_res.text, models.GetBulkUpsertDocsResponse)
|
|
474
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
475
|
+
response_data = utils.unmarshal_json(
|
|
476
|
+
http_res.text, errors.UnauthenticatedErrorData
|
|
477
|
+
)
|
|
478
|
+
raise errors.UnauthenticatedError(data=response_data)
|
|
479
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
480
|
+
response_data = utils.unmarshal_json(
|
|
481
|
+
http_res.text, errors.ResourceNotFoundErrorData
|
|
482
|
+
)
|
|
483
|
+
raise errors.ResourceNotFoundError(data=response_data)
|
|
484
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
485
|
+
response_data = utils.unmarshal_json(
|
|
486
|
+
http_res.text, errors.TooManyRequestsErrorData
|
|
487
|
+
)
|
|
488
|
+
raise errors.TooManyRequestsError(data=response_data)
|
|
489
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
490
|
+
response_data = utils.unmarshal_json(
|
|
491
|
+
http_res.text, errors.InternalServerErrorData
|
|
492
|
+
)
|
|
493
|
+
raise errors.InternalServerError(data=response_data)
|
|
494
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
495
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
496
|
+
raise errors.APIError(
|
|
497
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
498
|
+
)
|
|
499
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
500
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
501
|
+
raise errors.APIError(
|
|
502
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
content_type = http_res.headers.get("Content-Type")
|
|
506
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
507
|
+
raise errors.APIError(
|
|
508
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
509
|
+
http_res.status_code,
|
|
510
|
+
http_res_text,
|
|
511
|
+
http_res,
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
def bulk_upsert(
|
|
515
|
+
self,
|
|
516
|
+
*,
|
|
517
|
+
project_name: str,
|
|
518
|
+
collection_name: str,
|
|
519
|
+
object_key: str,
|
|
520
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
521
|
+
server_url: Optional[str] = None,
|
|
522
|
+
timeout_ms: Optional[int] = None,
|
|
523
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
524
|
+
) -> models.BulkUpsertDocsResponse:
|
|
525
|
+
r"""Bulk upsert documents into an collection. Note that the maximum supported object size is 200MB.
|
|
526
|
+
|
|
527
|
+
:param project_name: Project name.
|
|
528
|
+
:param collection_name: Collection name.
|
|
529
|
+
:param object_key: Object key uploaded based on bulk upsert info.
|
|
530
|
+
:param retries: Override the default retry configuration for this method
|
|
531
|
+
:param server_url: Override the default server URL for this method
|
|
532
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
533
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
534
|
+
"""
|
|
535
|
+
base_url = None
|
|
536
|
+
url_variables = None
|
|
537
|
+
if timeout_ms is None:
|
|
538
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
539
|
+
|
|
540
|
+
if server_url is not None:
|
|
541
|
+
base_url = server_url
|
|
542
|
+
else:
|
|
543
|
+
base_url = self._get_url(base_url, url_variables)
|
|
544
|
+
|
|
545
|
+
request = models.BulkUpsertDocsRequest(
|
|
546
|
+
project_name=project_name,
|
|
547
|
+
collection_name=collection_name,
|
|
548
|
+
request_body=models.BulkUpsertDocsRequestBody(
|
|
549
|
+
object_key=object_key,
|
|
550
|
+
),
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
req = self._build_request(
|
|
554
|
+
method="POST",
|
|
555
|
+
path="/projects/{projectName}/collections/{collectionName}/docs/bulk-upsert",
|
|
556
|
+
base_url=base_url,
|
|
557
|
+
url_variables=url_variables,
|
|
558
|
+
request=request,
|
|
559
|
+
request_body_required=True,
|
|
560
|
+
request_has_path_params=True,
|
|
561
|
+
request_has_query_params=True,
|
|
562
|
+
user_agent_header="user-agent",
|
|
563
|
+
accept_header_value="application/json",
|
|
564
|
+
http_headers=http_headers,
|
|
565
|
+
security=self.sdk_configuration.security,
|
|
566
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
567
|
+
request.request_body,
|
|
568
|
+
False,
|
|
569
|
+
False,
|
|
570
|
+
"json",
|
|
571
|
+
models.BulkUpsertDocsRequestBody,
|
|
572
|
+
),
|
|
573
|
+
timeout_ms=timeout_ms,
|
|
574
|
+
)
|
|
575
|
+
|
|
576
|
+
if retries == UNSET:
|
|
577
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
578
|
+
retries = self.sdk_configuration.retry_config
|
|
579
|
+
else:
|
|
580
|
+
retries = utils.RetryConfig(
|
|
581
|
+
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
|
582
|
+
)
|
|
583
|
+
|
|
584
|
+
retry_config = None
|
|
585
|
+
if isinstance(retries, utils.RetryConfig):
|
|
586
|
+
retry_config = (retries, ["429", "5XX"])
|
|
587
|
+
|
|
588
|
+
http_res = self.do_request(
|
|
589
|
+
hook_ctx=HookContext(
|
|
590
|
+
base_url=base_url or "",
|
|
591
|
+
operation_id="bulkUpsertDocs",
|
|
592
|
+
oauth2_scopes=[],
|
|
593
|
+
security_source=get_security_from_env(
|
|
594
|
+
self.sdk_configuration.security, models.Security
|
|
595
|
+
),
|
|
596
|
+
),
|
|
597
|
+
request=req,
|
|
598
|
+
error_status_codes=["400", "401", "404", "429", "4XX", "500", "5XX"],
|
|
599
|
+
retry_config=retry_config,
|
|
600
|
+
)
|
|
601
|
+
|
|
602
|
+
response_data: Any = None
|
|
603
|
+
if utils.match_response(http_res, "202", "application/json"):
|
|
604
|
+
return utils.unmarshal_json(http_res.text, models.BulkUpsertDocsResponse)
|
|
605
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
606
|
+
response_data = utils.unmarshal_json(
|
|
607
|
+
http_res.text, errors.BadRequestErrorData
|
|
608
|
+
)
|
|
609
|
+
raise errors.BadRequestError(data=response_data)
|
|
610
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
611
|
+
response_data = utils.unmarshal_json(
|
|
612
|
+
http_res.text, errors.UnauthenticatedErrorData
|
|
613
|
+
)
|
|
614
|
+
raise errors.UnauthenticatedError(data=response_data)
|
|
615
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
616
|
+
response_data = utils.unmarshal_json(
|
|
617
|
+
http_res.text, errors.ResourceNotFoundErrorData
|
|
618
|
+
)
|
|
619
|
+
raise errors.ResourceNotFoundError(data=response_data)
|
|
620
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
621
|
+
response_data = utils.unmarshal_json(
|
|
622
|
+
http_res.text, errors.TooManyRequestsErrorData
|
|
623
|
+
)
|
|
624
|
+
raise errors.TooManyRequestsError(data=response_data)
|
|
625
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
626
|
+
response_data = utils.unmarshal_json(
|
|
627
|
+
http_res.text, errors.InternalServerErrorData
|
|
628
|
+
)
|
|
629
|
+
raise errors.InternalServerError(data=response_data)
|
|
630
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
631
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
632
|
+
raise errors.APIError(
|
|
633
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
634
|
+
)
|
|
635
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
636
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
637
|
+
raise errors.APIError(
|
|
638
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
639
|
+
)
|
|
640
|
+
|
|
641
|
+
content_type = http_res.headers.get("Content-Type")
|
|
642
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
643
|
+
raise errors.APIError(
|
|
644
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
645
|
+
http_res.status_code,
|
|
646
|
+
http_res_text,
|
|
647
|
+
http_res,
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
async def bulk_upsert_async(
|
|
651
|
+
self,
|
|
652
|
+
*,
|
|
653
|
+
project_name: str,
|
|
654
|
+
collection_name: str,
|
|
655
|
+
object_key: str,
|
|
656
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
657
|
+
server_url: Optional[str] = None,
|
|
658
|
+
timeout_ms: Optional[int] = None,
|
|
659
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
660
|
+
) -> models.BulkUpsertDocsResponse:
|
|
661
|
+
r"""Bulk upsert documents into an collection. Note that the maximum supported object size is 200MB.
|
|
662
|
+
|
|
663
|
+
:param project_name: Project name.
|
|
664
|
+
:param collection_name: Collection name.
|
|
665
|
+
:param object_key: Object key uploaded based on bulk upsert info.
|
|
666
|
+
:param retries: Override the default retry configuration for this method
|
|
667
|
+
:param server_url: Override the default server URL for this method
|
|
668
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
669
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
670
|
+
"""
|
|
671
|
+
base_url = None
|
|
672
|
+
url_variables = None
|
|
673
|
+
if timeout_ms is None:
|
|
674
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
675
|
+
|
|
676
|
+
if server_url is not None:
|
|
677
|
+
base_url = server_url
|
|
678
|
+
else:
|
|
679
|
+
base_url = self._get_url(base_url, url_variables)
|
|
680
|
+
|
|
681
|
+
request = models.BulkUpsertDocsRequest(
|
|
682
|
+
project_name=project_name,
|
|
683
|
+
collection_name=collection_name,
|
|
684
|
+
request_body=models.BulkUpsertDocsRequestBody(
|
|
685
|
+
object_key=object_key,
|
|
686
|
+
),
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
req = self._build_request_async(
|
|
690
|
+
method="POST",
|
|
691
|
+
path="/projects/{projectName}/collections/{collectionName}/docs/bulk-upsert",
|
|
692
|
+
base_url=base_url,
|
|
693
|
+
url_variables=url_variables,
|
|
694
|
+
request=request,
|
|
695
|
+
request_body_required=True,
|
|
696
|
+
request_has_path_params=True,
|
|
697
|
+
request_has_query_params=True,
|
|
698
|
+
user_agent_header="user-agent",
|
|
699
|
+
accept_header_value="application/json",
|
|
700
|
+
http_headers=http_headers,
|
|
701
|
+
security=self.sdk_configuration.security,
|
|
702
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
703
|
+
request.request_body,
|
|
704
|
+
False,
|
|
705
|
+
False,
|
|
706
|
+
"json",
|
|
707
|
+
models.BulkUpsertDocsRequestBody,
|
|
708
|
+
),
|
|
709
|
+
timeout_ms=timeout_ms,
|
|
710
|
+
)
|
|
711
|
+
|
|
712
|
+
if retries == UNSET:
|
|
713
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
714
|
+
retries = self.sdk_configuration.retry_config
|
|
715
|
+
else:
|
|
716
|
+
retries = utils.RetryConfig(
|
|
717
|
+
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
|
718
|
+
)
|
|
719
|
+
|
|
720
|
+
retry_config = None
|
|
721
|
+
if isinstance(retries, utils.RetryConfig):
|
|
722
|
+
retry_config = (retries, ["429", "5XX"])
|
|
723
|
+
|
|
724
|
+
http_res = await self.do_request_async(
|
|
725
|
+
hook_ctx=HookContext(
|
|
726
|
+
base_url=base_url or "",
|
|
727
|
+
operation_id="bulkUpsertDocs",
|
|
728
|
+
oauth2_scopes=[],
|
|
729
|
+
security_source=get_security_from_env(
|
|
730
|
+
self.sdk_configuration.security, models.Security
|
|
731
|
+
),
|
|
732
|
+
),
|
|
733
|
+
request=req,
|
|
734
|
+
error_status_codes=["400", "401", "404", "429", "4XX", "500", "5XX"],
|
|
735
|
+
retry_config=retry_config,
|
|
736
|
+
)
|
|
737
|
+
|
|
738
|
+
response_data: Any = None
|
|
739
|
+
if utils.match_response(http_res, "202", "application/json"):
|
|
740
|
+
return utils.unmarshal_json(http_res.text, models.BulkUpsertDocsResponse)
|
|
741
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
742
|
+
response_data = utils.unmarshal_json(
|
|
743
|
+
http_res.text, errors.BadRequestErrorData
|
|
744
|
+
)
|
|
745
|
+
raise errors.BadRequestError(data=response_data)
|
|
746
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
747
|
+
response_data = utils.unmarshal_json(
|
|
748
|
+
http_res.text, errors.UnauthenticatedErrorData
|
|
749
|
+
)
|
|
750
|
+
raise errors.UnauthenticatedError(data=response_data)
|
|
751
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
752
|
+
response_data = utils.unmarshal_json(
|
|
753
|
+
http_res.text, errors.ResourceNotFoundErrorData
|
|
754
|
+
)
|
|
755
|
+
raise errors.ResourceNotFoundError(data=response_data)
|
|
756
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
757
|
+
response_data = utils.unmarshal_json(
|
|
758
|
+
http_res.text, errors.TooManyRequestsErrorData
|
|
759
|
+
)
|
|
760
|
+
raise errors.TooManyRequestsError(data=response_data)
|
|
761
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
762
|
+
response_data = utils.unmarshal_json(
|
|
763
|
+
http_res.text, errors.InternalServerErrorData
|
|
764
|
+
)
|
|
765
|
+
raise errors.InternalServerError(data=response_data)
|
|
766
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
767
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
768
|
+
raise errors.APIError(
|
|
769
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
770
|
+
)
|
|
771
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
772
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
773
|
+
raise errors.APIError(
|
|
774
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
775
|
+
)
|
|
776
|
+
|
|
777
|
+
content_type = http_res.headers.get("Content-Type")
|
|
778
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
779
|
+
raise errors.APIError(
|
|
780
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
781
|
+
http_res.status_code,
|
|
782
|
+
http_res_text,
|
|
783
|
+
http_res,
|
|
784
|
+
)
|
|
785
|
+
|
|
786
|
+
def delete(
|
|
787
|
+
self,
|
|
788
|
+
*,
|
|
789
|
+
project_name: str,
|
|
790
|
+
collection_name: str,
|
|
791
|
+
request_body: Union[
|
|
792
|
+
models.DeleteDocsRequestBody, models.DeleteDocsRequestBodyTypedDict
|
|
793
|
+
],
|
|
794
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
795
|
+
server_url: Optional[str] = None,
|
|
796
|
+
timeout_ms: Optional[int] = None,
|
|
797
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
798
|
+
) -> models.DeleteDocsResponse:
|
|
799
|
+
r"""Delete documents by document IDs or query filter from an collection.
|
|
800
|
+
|
|
801
|
+
:param project_name: Project name.
|
|
802
|
+
:param collection_name: Collection name.
|
|
803
|
+
:param request_body:
|
|
804
|
+
:param retries: Override the default retry configuration for this method
|
|
805
|
+
:param server_url: Override the default server URL for this method
|
|
806
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
807
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
808
|
+
"""
|
|
809
|
+
base_url = None
|
|
810
|
+
url_variables = None
|
|
811
|
+
if timeout_ms is None:
|
|
812
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
813
|
+
|
|
814
|
+
if server_url is not None:
|
|
815
|
+
base_url = server_url
|
|
816
|
+
else:
|
|
817
|
+
base_url = self._get_url(base_url, url_variables)
|
|
818
|
+
|
|
819
|
+
request = models.DeleteDocsRequest(
|
|
820
|
+
project_name=project_name,
|
|
821
|
+
collection_name=collection_name,
|
|
822
|
+
request_body=utils.get_pydantic_model(
|
|
823
|
+
request_body, models.DeleteDocsRequestBody
|
|
824
|
+
),
|
|
825
|
+
)
|
|
826
|
+
|
|
827
|
+
req = self._build_request(
|
|
828
|
+
method="POST",
|
|
829
|
+
path="/projects/{projectName}/collections/{collectionName}/docs/delete",
|
|
830
|
+
base_url=base_url,
|
|
831
|
+
url_variables=url_variables,
|
|
832
|
+
request=request,
|
|
833
|
+
request_body_required=True,
|
|
834
|
+
request_has_path_params=True,
|
|
835
|
+
request_has_query_params=True,
|
|
836
|
+
user_agent_header="user-agent",
|
|
837
|
+
accept_header_value="application/json",
|
|
838
|
+
http_headers=http_headers,
|
|
839
|
+
security=self.sdk_configuration.security,
|
|
840
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
841
|
+
request.request_body, False, False, "json", models.DeleteDocsRequestBody
|
|
842
|
+
),
|
|
843
|
+
timeout_ms=timeout_ms,
|
|
844
|
+
)
|
|
845
|
+
|
|
846
|
+
if retries == UNSET:
|
|
847
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
848
|
+
retries = self.sdk_configuration.retry_config
|
|
849
|
+
else:
|
|
850
|
+
retries = utils.RetryConfig(
|
|
851
|
+
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
|
852
|
+
)
|
|
853
|
+
|
|
854
|
+
retry_config = None
|
|
855
|
+
if isinstance(retries, utils.RetryConfig):
|
|
856
|
+
retry_config = (retries, ["429", "5XX"])
|
|
857
|
+
|
|
858
|
+
http_res = self.do_request(
|
|
859
|
+
hook_ctx=HookContext(
|
|
860
|
+
base_url=base_url or "",
|
|
861
|
+
operation_id="deleteDocs",
|
|
862
|
+
oauth2_scopes=[],
|
|
863
|
+
security_source=get_security_from_env(
|
|
864
|
+
self.sdk_configuration.security, models.Security
|
|
865
|
+
),
|
|
866
|
+
),
|
|
867
|
+
request=req,
|
|
868
|
+
error_status_codes=["400", "401", "404", "429", "4XX", "500", "5XX"],
|
|
869
|
+
retry_config=retry_config,
|
|
870
|
+
)
|
|
871
|
+
|
|
872
|
+
response_data: Any = None
|
|
873
|
+
if utils.match_response(http_res, "202", "application/json"):
|
|
874
|
+
return utils.unmarshal_json(http_res.text, models.DeleteDocsResponse)
|
|
875
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
876
|
+
response_data = utils.unmarshal_json(
|
|
877
|
+
http_res.text, errors.BadRequestErrorData
|
|
878
|
+
)
|
|
879
|
+
raise errors.BadRequestError(data=response_data)
|
|
880
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
881
|
+
response_data = utils.unmarshal_json(
|
|
882
|
+
http_res.text, errors.UnauthenticatedErrorData
|
|
883
|
+
)
|
|
884
|
+
raise errors.UnauthenticatedError(data=response_data)
|
|
885
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
886
|
+
response_data = utils.unmarshal_json(
|
|
887
|
+
http_res.text, errors.ResourceNotFoundErrorData
|
|
888
|
+
)
|
|
889
|
+
raise errors.ResourceNotFoundError(data=response_data)
|
|
890
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
891
|
+
response_data = utils.unmarshal_json(
|
|
892
|
+
http_res.text, errors.TooManyRequestsErrorData
|
|
893
|
+
)
|
|
894
|
+
raise errors.TooManyRequestsError(data=response_data)
|
|
895
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
896
|
+
response_data = utils.unmarshal_json(
|
|
897
|
+
http_res.text, errors.InternalServerErrorData
|
|
898
|
+
)
|
|
899
|
+
raise errors.InternalServerError(data=response_data)
|
|
900
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
901
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
902
|
+
raise errors.APIError(
|
|
903
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
904
|
+
)
|
|
905
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
906
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
907
|
+
raise errors.APIError(
|
|
908
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
909
|
+
)
|
|
910
|
+
|
|
911
|
+
content_type = http_res.headers.get("Content-Type")
|
|
912
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
913
|
+
raise errors.APIError(
|
|
914
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
915
|
+
http_res.status_code,
|
|
916
|
+
http_res_text,
|
|
917
|
+
http_res,
|
|
918
|
+
)
|
|
919
|
+
|
|
920
|
+
async def delete_async(
|
|
921
|
+
self,
|
|
922
|
+
*,
|
|
923
|
+
project_name: str,
|
|
924
|
+
collection_name: str,
|
|
925
|
+
request_body: Union[
|
|
926
|
+
models.DeleteDocsRequestBody, models.DeleteDocsRequestBodyTypedDict
|
|
927
|
+
],
|
|
928
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
929
|
+
server_url: Optional[str] = None,
|
|
930
|
+
timeout_ms: Optional[int] = None,
|
|
931
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
932
|
+
) -> models.DeleteDocsResponse:
|
|
933
|
+
r"""Delete documents by document IDs or query filter from an collection.
|
|
934
|
+
|
|
935
|
+
:param project_name: Project name.
|
|
936
|
+
:param collection_name: Collection name.
|
|
937
|
+
:param request_body:
|
|
938
|
+
:param retries: Override the default retry configuration for this method
|
|
939
|
+
:param server_url: Override the default server URL for this method
|
|
940
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
941
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
942
|
+
"""
|
|
943
|
+
base_url = None
|
|
944
|
+
url_variables = None
|
|
945
|
+
if timeout_ms is None:
|
|
946
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
947
|
+
|
|
948
|
+
if server_url is not None:
|
|
949
|
+
base_url = server_url
|
|
950
|
+
else:
|
|
951
|
+
base_url = self._get_url(base_url, url_variables)
|
|
952
|
+
|
|
953
|
+
request = models.DeleteDocsRequest(
|
|
954
|
+
project_name=project_name,
|
|
955
|
+
collection_name=collection_name,
|
|
956
|
+
request_body=utils.get_pydantic_model(
|
|
957
|
+
request_body, models.DeleteDocsRequestBody
|
|
958
|
+
),
|
|
959
|
+
)
|
|
960
|
+
|
|
961
|
+
req = self._build_request_async(
|
|
962
|
+
method="POST",
|
|
963
|
+
path="/projects/{projectName}/collections/{collectionName}/docs/delete",
|
|
964
|
+
base_url=base_url,
|
|
965
|
+
url_variables=url_variables,
|
|
966
|
+
request=request,
|
|
967
|
+
request_body_required=True,
|
|
968
|
+
request_has_path_params=True,
|
|
969
|
+
request_has_query_params=True,
|
|
970
|
+
user_agent_header="user-agent",
|
|
971
|
+
accept_header_value="application/json",
|
|
972
|
+
http_headers=http_headers,
|
|
973
|
+
security=self.sdk_configuration.security,
|
|
974
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
975
|
+
request.request_body, False, False, "json", models.DeleteDocsRequestBody
|
|
976
|
+
),
|
|
977
|
+
timeout_ms=timeout_ms,
|
|
978
|
+
)
|
|
979
|
+
|
|
980
|
+
if retries == UNSET:
|
|
981
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
982
|
+
retries = self.sdk_configuration.retry_config
|
|
983
|
+
else:
|
|
984
|
+
retries = utils.RetryConfig(
|
|
985
|
+
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
|
986
|
+
)
|
|
987
|
+
|
|
988
|
+
retry_config = None
|
|
989
|
+
if isinstance(retries, utils.RetryConfig):
|
|
990
|
+
retry_config = (retries, ["429", "5XX"])
|
|
991
|
+
|
|
992
|
+
http_res = await self.do_request_async(
|
|
993
|
+
hook_ctx=HookContext(
|
|
994
|
+
base_url=base_url or "",
|
|
995
|
+
operation_id="deleteDocs",
|
|
996
|
+
oauth2_scopes=[],
|
|
997
|
+
security_source=get_security_from_env(
|
|
998
|
+
self.sdk_configuration.security, models.Security
|
|
999
|
+
),
|
|
1000
|
+
),
|
|
1001
|
+
request=req,
|
|
1002
|
+
error_status_codes=["400", "401", "404", "429", "4XX", "500", "5XX"],
|
|
1003
|
+
retry_config=retry_config,
|
|
1004
|
+
)
|
|
1005
|
+
|
|
1006
|
+
response_data: Any = None
|
|
1007
|
+
if utils.match_response(http_res, "202", "application/json"):
|
|
1008
|
+
return utils.unmarshal_json(http_res.text, models.DeleteDocsResponse)
|
|
1009
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
1010
|
+
response_data = utils.unmarshal_json(
|
|
1011
|
+
http_res.text, errors.BadRequestErrorData
|
|
1012
|
+
)
|
|
1013
|
+
raise errors.BadRequestError(data=response_data)
|
|
1014
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
1015
|
+
response_data = utils.unmarshal_json(
|
|
1016
|
+
http_res.text, errors.UnauthenticatedErrorData
|
|
1017
|
+
)
|
|
1018
|
+
raise errors.UnauthenticatedError(data=response_data)
|
|
1019
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
1020
|
+
response_data = utils.unmarshal_json(
|
|
1021
|
+
http_res.text, errors.ResourceNotFoundErrorData
|
|
1022
|
+
)
|
|
1023
|
+
raise errors.ResourceNotFoundError(data=response_data)
|
|
1024
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
1025
|
+
response_data = utils.unmarshal_json(
|
|
1026
|
+
http_res.text, errors.TooManyRequestsErrorData
|
|
1027
|
+
)
|
|
1028
|
+
raise errors.TooManyRequestsError(data=response_data)
|
|
1029
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
1030
|
+
response_data = utils.unmarshal_json(
|
|
1031
|
+
http_res.text, errors.InternalServerErrorData
|
|
1032
|
+
)
|
|
1033
|
+
raise errors.InternalServerError(data=response_data)
|
|
1034
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1035
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1036
|
+
raise errors.APIError(
|
|
1037
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1038
|
+
)
|
|
1039
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1040
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1041
|
+
raise errors.APIError(
|
|
1042
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1043
|
+
)
|
|
1044
|
+
|
|
1045
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1046
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1047
|
+
raise errors.APIError(
|
|
1048
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1049
|
+
http_res.status_code,
|
|
1050
|
+
http_res_text,
|
|
1051
|
+
http_res,
|
|
1052
|
+
)
|
|
1053
|
+
|
|
1054
|
+
def fetch(
|
|
1055
|
+
self,
|
|
1056
|
+
*,
|
|
1057
|
+
project_name: str,
|
|
1058
|
+
collection_name: str,
|
|
1059
|
+
ids: List[str],
|
|
1060
|
+
consistent_read: Optional[bool] = False,
|
|
1061
|
+
include_vectors: Optional[bool] = False,
|
|
1062
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1063
|
+
server_url: Optional[str] = None,
|
|
1064
|
+
timeout_ms: Optional[int] = None,
|
|
1065
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1066
|
+
) -> models.FetchDocsResponse:
|
|
1067
|
+
r"""Lookup and return documents by document IDs from an collection.
|
|
1068
|
+
|
|
1069
|
+
:param project_name: Project name.
|
|
1070
|
+
:param collection_name: Collection name.
|
|
1071
|
+
:param ids: A list of document IDs to fetch. Note that the maximum number of document IDs is 1000.
|
|
1072
|
+
:param consistent_read: If your application requires a strongly consistent read, set consistentRead to true. Although a strongly consistent read might take more time than an eventually consistent read, it always returns the last updated value.
|
|
1073
|
+
:param include_vectors: If your application need to include vector values in the response, set includeVectors to true.
|
|
1074
|
+
:param retries: Override the default retry configuration for this method
|
|
1075
|
+
:param server_url: Override the default server URL for this method
|
|
1076
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1077
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1078
|
+
"""
|
|
1079
|
+
base_url = None
|
|
1080
|
+
url_variables = None
|
|
1081
|
+
if timeout_ms is None:
|
|
1082
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1083
|
+
|
|
1084
|
+
if server_url is not None:
|
|
1085
|
+
base_url = server_url
|
|
1086
|
+
else:
|
|
1087
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1088
|
+
|
|
1089
|
+
request = models.FetchDocsRequest(
|
|
1090
|
+
project_name=project_name,
|
|
1091
|
+
collection_name=collection_name,
|
|
1092
|
+
request_body=models.FetchDocsRequestBody(
|
|
1093
|
+
ids=ids,
|
|
1094
|
+
consistent_read=consistent_read,
|
|
1095
|
+
include_vectors=include_vectors,
|
|
1096
|
+
),
|
|
1097
|
+
)
|
|
1098
|
+
|
|
1099
|
+
req = self._build_request(
|
|
1100
|
+
method="POST",
|
|
1101
|
+
path="/projects/{projectName}/collections/{collectionName}/docs/fetch",
|
|
1102
|
+
base_url=base_url,
|
|
1103
|
+
url_variables=url_variables,
|
|
1104
|
+
request=request,
|
|
1105
|
+
request_body_required=True,
|
|
1106
|
+
request_has_path_params=True,
|
|
1107
|
+
request_has_query_params=True,
|
|
1108
|
+
user_agent_header="user-agent",
|
|
1109
|
+
accept_header_value="application/json",
|
|
1110
|
+
http_headers=http_headers,
|
|
1111
|
+
security=self.sdk_configuration.security,
|
|
1112
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1113
|
+
request.request_body, False, False, "json", models.FetchDocsRequestBody
|
|
1114
|
+
),
|
|
1115
|
+
timeout_ms=timeout_ms,
|
|
1116
|
+
)
|
|
1117
|
+
|
|
1118
|
+
if retries == UNSET:
|
|
1119
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1120
|
+
retries = self.sdk_configuration.retry_config
|
|
1121
|
+
else:
|
|
1122
|
+
retries = utils.RetryConfig(
|
|
1123
|
+
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
|
1124
|
+
)
|
|
1125
|
+
|
|
1126
|
+
retry_config = None
|
|
1127
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1128
|
+
retry_config = (retries, ["429", "5XX"])
|
|
1129
|
+
|
|
1130
|
+
http_res = self.do_request(
|
|
1131
|
+
hook_ctx=HookContext(
|
|
1132
|
+
base_url=base_url or "",
|
|
1133
|
+
operation_id="fetchDocs",
|
|
1134
|
+
oauth2_scopes=[],
|
|
1135
|
+
security_source=get_security_from_env(
|
|
1136
|
+
self.sdk_configuration.security, models.Security
|
|
1137
|
+
),
|
|
1138
|
+
),
|
|
1139
|
+
request=req,
|
|
1140
|
+
error_status_codes=["400", "401", "404", "429", "4XX", "500", "5XX"],
|
|
1141
|
+
retry_config=retry_config,
|
|
1142
|
+
)
|
|
1143
|
+
|
|
1144
|
+
response_data: Any = None
|
|
1145
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1146
|
+
return utils.unmarshal_json(http_res.text, models.FetchDocsResponse)
|
|
1147
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
1148
|
+
response_data = utils.unmarshal_json(
|
|
1149
|
+
http_res.text, errors.BadRequestErrorData
|
|
1150
|
+
)
|
|
1151
|
+
raise errors.BadRequestError(data=response_data)
|
|
1152
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
1153
|
+
response_data = utils.unmarshal_json(
|
|
1154
|
+
http_res.text, errors.UnauthenticatedErrorData
|
|
1155
|
+
)
|
|
1156
|
+
raise errors.UnauthenticatedError(data=response_data)
|
|
1157
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
1158
|
+
response_data = utils.unmarshal_json(
|
|
1159
|
+
http_res.text, errors.ResourceNotFoundErrorData
|
|
1160
|
+
)
|
|
1161
|
+
raise errors.ResourceNotFoundError(data=response_data)
|
|
1162
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
1163
|
+
response_data = utils.unmarshal_json(
|
|
1164
|
+
http_res.text, errors.TooManyRequestsErrorData
|
|
1165
|
+
)
|
|
1166
|
+
raise errors.TooManyRequestsError(data=response_data)
|
|
1167
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
1168
|
+
response_data = utils.unmarshal_json(
|
|
1169
|
+
http_res.text, errors.InternalServerErrorData
|
|
1170
|
+
)
|
|
1171
|
+
raise errors.InternalServerError(data=response_data)
|
|
1172
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1173
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1174
|
+
raise errors.APIError(
|
|
1175
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1176
|
+
)
|
|
1177
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1178
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1179
|
+
raise errors.APIError(
|
|
1180
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1181
|
+
)
|
|
1182
|
+
|
|
1183
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1184
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1185
|
+
raise errors.APIError(
|
|
1186
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1187
|
+
http_res.status_code,
|
|
1188
|
+
http_res_text,
|
|
1189
|
+
http_res,
|
|
1190
|
+
)
|
|
1191
|
+
|
|
1192
|
+
async def fetch_async(
|
|
1193
|
+
self,
|
|
1194
|
+
*,
|
|
1195
|
+
project_name: str,
|
|
1196
|
+
collection_name: str,
|
|
1197
|
+
ids: List[str],
|
|
1198
|
+
consistent_read: Optional[bool] = False,
|
|
1199
|
+
include_vectors: Optional[bool] = False,
|
|
1200
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1201
|
+
server_url: Optional[str] = None,
|
|
1202
|
+
timeout_ms: Optional[int] = None,
|
|
1203
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1204
|
+
) -> models.FetchDocsResponse:
|
|
1205
|
+
r"""Lookup and return documents by document IDs from an collection.
|
|
1206
|
+
|
|
1207
|
+
:param project_name: Project name.
|
|
1208
|
+
:param collection_name: Collection name.
|
|
1209
|
+
:param ids: A list of document IDs to fetch. Note that the maximum number of document IDs is 1000.
|
|
1210
|
+
:param consistent_read: If your application requires a strongly consistent read, set consistentRead to true. Although a strongly consistent read might take more time than an eventually consistent read, it always returns the last updated value.
|
|
1211
|
+
:param include_vectors: If your application need to include vector values in the response, set includeVectors to true.
|
|
1212
|
+
:param retries: Override the default retry configuration for this method
|
|
1213
|
+
:param server_url: Override the default server URL for this method
|
|
1214
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1215
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1216
|
+
"""
|
|
1217
|
+
base_url = None
|
|
1218
|
+
url_variables = None
|
|
1219
|
+
if timeout_ms is None:
|
|
1220
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1221
|
+
|
|
1222
|
+
if server_url is not None:
|
|
1223
|
+
base_url = server_url
|
|
1224
|
+
else:
|
|
1225
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1226
|
+
|
|
1227
|
+
request = models.FetchDocsRequest(
|
|
1228
|
+
project_name=project_name,
|
|
1229
|
+
collection_name=collection_name,
|
|
1230
|
+
request_body=models.FetchDocsRequestBody(
|
|
1231
|
+
ids=ids,
|
|
1232
|
+
consistent_read=consistent_read,
|
|
1233
|
+
include_vectors=include_vectors,
|
|
1234
|
+
),
|
|
1235
|
+
)
|
|
1236
|
+
|
|
1237
|
+
req = self._build_request_async(
|
|
1238
|
+
method="POST",
|
|
1239
|
+
path="/projects/{projectName}/collections/{collectionName}/docs/fetch",
|
|
1240
|
+
base_url=base_url,
|
|
1241
|
+
url_variables=url_variables,
|
|
1242
|
+
request=request,
|
|
1243
|
+
request_body_required=True,
|
|
1244
|
+
request_has_path_params=True,
|
|
1245
|
+
request_has_query_params=True,
|
|
1246
|
+
user_agent_header="user-agent",
|
|
1247
|
+
accept_header_value="application/json",
|
|
1248
|
+
http_headers=http_headers,
|
|
1249
|
+
security=self.sdk_configuration.security,
|
|
1250
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1251
|
+
request.request_body, False, False, "json", models.FetchDocsRequestBody
|
|
1252
|
+
),
|
|
1253
|
+
timeout_ms=timeout_ms,
|
|
1254
|
+
)
|
|
1255
|
+
|
|
1256
|
+
if retries == UNSET:
|
|
1257
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1258
|
+
retries = self.sdk_configuration.retry_config
|
|
1259
|
+
else:
|
|
1260
|
+
retries = utils.RetryConfig(
|
|
1261
|
+
"backoff", utils.BackoffStrategy(500, 60000, 1.5, 3600000), True
|
|
1262
|
+
)
|
|
1263
|
+
|
|
1264
|
+
retry_config = None
|
|
1265
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1266
|
+
retry_config = (retries, ["429", "5XX"])
|
|
1267
|
+
|
|
1268
|
+
http_res = await self.do_request_async(
|
|
1269
|
+
hook_ctx=HookContext(
|
|
1270
|
+
base_url=base_url or "",
|
|
1271
|
+
operation_id="fetchDocs",
|
|
1272
|
+
oauth2_scopes=[],
|
|
1273
|
+
security_source=get_security_from_env(
|
|
1274
|
+
self.sdk_configuration.security, models.Security
|
|
1275
|
+
),
|
|
1276
|
+
),
|
|
1277
|
+
request=req,
|
|
1278
|
+
error_status_codes=["400", "401", "404", "429", "4XX", "500", "5XX"],
|
|
1279
|
+
retry_config=retry_config,
|
|
1280
|
+
)
|
|
1281
|
+
|
|
1282
|
+
response_data: Any = None
|
|
1283
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1284
|
+
return utils.unmarshal_json(http_res.text, models.FetchDocsResponse)
|
|
1285
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
1286
|
+
response_data = utils.unmarshal_json(
|
|
1287
|
+
http_res.text, errors.BadRequestErrorData
|
|
1288
|
+
)
|
|
1289
|
+
raise errors.BadRequestError(data=response_data)
|
|
1290
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
1291
|
+
response_data = utils.unmarshal_json(
|
|
1292
|
+
http_res.text, errors.UnauthenticatedErrorData
|
|
1293
|
+
)
|
|
1294
|
+
raise errors.UnauthenticatedError(data=response_data)
|
|
1295
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
1296
|
+
response_data = utils.unmarshal_json(
|
|
1297
|
+
http_res.text, errors.ResourceNotFoundErrorData
|
|
1298
|
+
)
|
|
1299
|
+
raise errors.ResourceNotFoundError(data=response_data)
|
|
1300
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
1301
|
+
response_data = utils.unmarshal_json(
|
|
1302
|
+
http_res.text, errors.TooManyRequestsErrorData
|
|
1303
|
+
)
|
|
1304
|
+
raise errors.TooManyRequestsError(data=response_data)
|
|
1305
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
1306
|
+
response_data = utils.unmarshal_json(
|
|
1307
|
+
http_res.text, errors.InternalServerErrorData
|
|
1308
|
+
)
|
|
1309
|
+
raise errors.InternalServerError(data=response_data)
|
|
1310
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1311
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1312
|
+
raise errors.APIError(
|
|
1313
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1314
|
+
)
|
|
1315
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1316
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1317
|
+
raise errors.APIError(
|
|
1318
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1319
|
+
)
|
|
1320
|
+
|
|
1321
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1322
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1323
|
+
raise errors.APIError(
|
|
1324
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1325
|
+
http_res.status_code,
|
|
1326
|
+
http_res_text,
|
|
1327
|
+
http_res,
|
|
1328
|
+
)
|