mixpeek 0.21.8__py3-none-any.whl → 0.22.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. mixpeek/_hooks/types.py +7 -0
  2. mixpeek/_version.py +3 -3
  3. mixpeek/basesdk.py +12 -20
  4. mixpeek/bucketobjects.py +19 -37
  5. mixpeek/buckets.py +19 -31
  6. mixpeek/clusters.py +2 -0
  7. mixpeek/collectioncache.py +6 -0
  8. mixpeek/collections.py +13 -19
  9. mixpeek/features.py +4 -0
  10. mixpeek/health.py +2 -0
  11. mixpeek/httpclient.py +6 -16
  12. mixpeek/models/__init__.py +744 -596
  13. mixpeek/models/blobmodel.py +3 -11
  14. mixpeek/models/bucketcreaterequest.py +3 -11
  15. mixpeek/models/bucketresponse.py +3 -11
  16. mixpeek/models/bucketschemafield_input.py +6 -22
  17. mixpeek/models/bucketschemafield_output.py +6 -22
  18. mixpeek/models/bucketschemafieldbase.py +81 -0
  19. mixpeek/models/bucketschemafieldtype.py +1 -0
  20. mixpeek/models/bucketupdaterequest.py +3 -10
  21. mixpeek/models/collectionmodel.py +3 -11
  22. mixpeek/models/createblobrequest.py +3 -11
  23. mixpeek/models/createcollectionrequest.py +3 -11
  24. mixpeek/models/createnamespacerequest.py +9 -9
  25. mixpeek/models/createobjectrequest.py +3 -11
  26. mixpeek/models/createretrieverrequest.py +3 -11
  27. mixpeek/models/errordetail.py +3 -10
  28. mixpeek/models/featureextractorconfig.py +3 -11
  29. mixpeek/models/featureextractordefinition.py +26 -46
  30. mixpeek/models/interactionresponse.py +3 -11
  31. mixpeek/models/internal/__init__.py +35 -1
  32. mixpeek/models/logicaloperator_input.py +30 -36
  33. mixpeek/models/logicaloperator_output.py +39 -45
  34. mixpeek/models/logicaloperatorbase_input.py +74 -0
  35. mixpeek/models/logicaloperatorbase_output.py +74 -0
  36. mixpeek/models/namespaceresponse.py +17 -6
  37. mixpeek/models/namespacestatus.py +10 -0
  38. mixpeek/models/objectresponse.py +3 -11
  39. mixpeek/models/organizationmodel.py +3 -11
  40. mixpeek/models/retrieverbinding.py +3 -10
  41. mixpeek/models/retrievermodel.py +3 -11
  42. mixpeek/models/retrieverqueryrequest.py +3 -11
  43. mixpeek/models/retrieverschemafield_input.py +6 -26
  44. mixpeek/models/retrieverschemafield_output.py +6 -26
  45. mixpeek/models/searchinteraction.py +3 -11
  46. mixpeek/models/stageconfig_input.py +8 -16
  47. mixpeek/models/stageconfig_output.py +8 -16
  48. mixpeek/models/stagedefinition.py +28 -17
  49. mixpeek/models/stageresponse.py +3 -11
  50. mixpeek/models/updateobjectrequest.py +3 -11
  51. mixpeek/models/usermodel_input.py +3 -11
  52. mixpeek/models/usermodel_output.py +3 -11
  53. mixpeek/namespaces.py +28 -22
  54. mixpeek/organizationnotifications.py +2 -0
  55. mixpeek/organizations.py +13 -13
  56. mixpeek/organizationsusage.py +2 -0
  57. mixpeek/research.py +2 -0
  58. mixpeek/retrieverinteractions.py +13 -19
  59. mixpeek/retrievers.py +15 -33
  60. mixpeek/retrieverstages.py +2 -0
  61. mixpeek/sdk.py +94 -65
  62. mixpeek/sdkconfiguration.py +0 -7
  63. mixpeek/tasks.py +6 -0
  64. mixpeek/taxonomies.py +2 -0
  65. mixpeek/users.py +6 -0
  66. mixpeek/utils/__init__.py +131 -45
  67. mixpeek/utils/datetimes.py +23 -0
  68. mixpeek/utils/serializers.py +32 -3
  69. {mixpeek-0.21.8.dist-info → mixpeek-0.22.0.dist-info}/METADATA +3 -15
  70. {mixpeek-0.21.8.dist-info → mixpeek-0.22.0.dist-info}/RECORD +71 -77
  71. {mixpeek-0.21.8.dist-info → mixpeek-0.22.0.dist-info}/WHEEL +1 -1
  72. mixpeek/collectiondocuments.py +0 -1564
  73. mixpeek/models/batch_delete_documents_v1_collections_collection_identifier_documents_batch_deleteop.py +0 -75
  74. mixpeek/models/batch_update_documents_v1_collections_collection_identifier_documents_batch_putop.py +0 -84
  75. mixpeek/models/delete_document_v1_collections_collection_identifier_documents_document_id_deleteop.py +0 -70
  76. mixpeek/models/documentlistresponse.py +0 -56
  77. mixpeek/models/documentresponse.py +0 -87
  78. mixpeek/models/documentupdate.py +0 -60
  79. mixpeek/models/genericsuccessresponse.py +0 -17
  80. mixpeek/models/get_document_v1_collections_collection_identifier_documents_document_id_getop.py +0 -70
  81. mixpeek/models/list_documents_v1_collections_collection_identifier_documents_getop.py +0 -114
  82. mixpeek/models/update_document_v1_collections_collection_identifier_documents_document_id_putop.py +0 -83
@@ -1,1564 +0,0 @@
1
- """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
-
3
- from .basesdk import BaseSDK
4
- from mixpeek import models, utils
5
- from mixpeek._hooks import HookContext
6
- from mixpeek.types import Nullable, OptionalNullable, UNSET
7
- from mixpeek.utils import get_security_from_env
8
- from typing import Any, Dict, List, Mapping, Optional, Union
9
-
10
-
11
- class CollectionDocuments(BaseSDK):
12
- def get(
13
- self,
14
- *,
15
- collection_identifier: str,
16
- document_id: str,
17
- x_namespace: OptionalNullable[str] = UNSET,
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.DocumentResponse:
23
- r"""Get Document
24
-
25
- Get a document by ID.
26
-
27
-
28
- **Requirements:**
29
- - Required permissions: read
30
-
31
- :param collection_identifier: The ID of the collection
32
- :param document_id: The ID of the document to retrieve
33
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
34
- :param retries: Override the default retry configuration for this method
35
- :param server_url: Override the default server URL for this method
36
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
37
- :param http_headers: Additional headers to set or replace on requests.
38
- """
39
- base_url = None
40
- url_variables = None
41
- if timeout_ms is None:
42
- timeout_ms = self.sdk_configuration.timeout_ms
43
-
44
- if server_url is not None:
45
- base_url = server_url
46
- else:
47
- base_url = self._get_url(base_url, url_variables)
48
-
49
- request = models.GetDocumentV1CollectionsCollectionIdentifierDocumentsDocumentIDGetRequest(
50
- collection_identifier=collection_identifier,
51
- document_id=document_id,
52
- x_namespace=x_namespace,
53
- )
54
-
55
- req = self._build_request(
56
- method="GET",
57
- path="/v1/collections/{collection_identifier}/documents/{document_id}",
58
- base_url=base_url,
59
- url_variables=url_variables,
60
- request=request,
61
- request_body_required=False,
62
- request_has_path_params=True,
63
- request_has_query_params=True,
64
- user_agent_header="user-agent",
65
- accept_header_value="application/json",
66
- http_headers=http_headers,
67
- security=self.sdk_configuration.security,
68
- timeout_ms=timeout_ms,
69
- )
70
-
71
- if retries == UNSET:
72
- if self.sdk_configuration.retry_config is not UNSET:
73
- retries = self.sdk_configuration.retry_config
74
-
75
- retry_config = None
76
- if isinstance(retries, utils.RetryConfig):
77
- retry_config = (retries, ["429", "500", "502", "503", "504"])
78
-
79
- http_res = self.do_request(
80
- hook_ctx=HookContext(
81
- base_url=base_url or "",
82
- operation_id="get_document_v1_collections__collection_identifier__documents__document_id__get",
83
- oauth2_scopes=[],
84
- security_source=get_security_from_env(
85
- self.sdk_configuration.security, models.Security
86
- ),
87
- ),
88
- request=req,
89
- error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
90
- retry_config=retry_config,
91
- )
92
-
93
- response_data: Any = None
94
- if utils.match_response(http_res, "200", "application/json"):
95
- return utils.unmarshal_json(http_res.text, models.DocumentResponse)
96
- if utils.match_response(
97
- http_res, ["400", "401", "403", "404"], "application/json"
98
- ):
99
- response_data = utils.unmarshal_json(
100
- http_res.text, models.ErrorResponseData
101
- )
102
- raise models.ErrorResponse(data=response_data)
103
- if utils.match_response(http_res, "422", "application/json"):
104
- response_data = utils.unmarshal_json(
105
- http_res.text, models.HTTPValidationErrorData
106
- )
107
- raise models.HTTPValidationError(data=response_data)
108
- if utils.match_response(http_res, "500", "application/json"):
109
- response_data = utils.unmarshal_json(
110
- http_res.text, models.ErrorResponseData
111
- )
112
- raise models.ErrorResponse(data=response_data)
113
- if utils.match_response(http_res, "4XX", "*"):
114
- http_res_text = utils.stream_to_text(http_res)
115
- raise models.APIError(
116
- "API error occurred", http_res.status_code, http_res_text, http_res
117
- )
118
- if utils.match_response(http_res, "5XX", "*"):
119
- http_res_text = utils.stream_to_text(http_res)
120
- raise models.APIError(
121
- "API error occurred", http_res.status_code, http_res_text, http_res
122
- )
123
-
124
- content_type = http_res.headers.get("Content-Type")
125
- http_res_text = utils.stream_to_text(http_res)
126
- raise models.APIError(
127
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
128
- http_res.status_code,
129
- http_res_text,
130
- http_res,
131
- )
132
-
133
- async def get_async(
134
- self,
135
- *,
136
- collection_identifier: str,
137
- document_id: str,
138
- x_namespace: OptionalNullable[str] = UNSET,
139
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
140
- server_url: Optional[str] = None,
141
- timeout_ms: Optional[int] = None,
142
- http_headers: Optional[Mapping[str, str]] = None,
143
- ) -> models.DocumentResponse:
144
- r"""Get Document
145
-
146
- Get a document by ID.
147
-
148
-
149
- **Requirements:**
150
- - Required permissions: read
151
-
152
- :param collection_identifier: The ID of the collection
153
- :param document_id: The ID of the document to retrieve
154
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
155
- :param retries: Override the default retry configuration for this method
156
- :param server_url: Override the default server URL for this method
157
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
158
- :param http_headers: Additional headers to set or replace on requests.
159
- """
160
- base_url = None
161
- url_variables = None
162
- if timeout_ms is None:
163
- timeout_ms = self.sdk_configuration.timeout_ms
164
-
165
- if server_url is not None:
166
- base_url = server_url
167
- else:
168
- base_url = self._get_url(base_url, url_variables)
169
-
170
- request = models.GetDocumentV1CollectionsCollectionIdentifierDocumentsDocumentIDGetRequest(
171
- collection_identifier=collection_identifier,
172
- document_id=document_id,
173
- x_namespace=x_namespace,
174
- )
175
-
176
- req = self._build_request_async(
177
- method="GET",
178
- path="/v1/collections/{collection_identifier}/documents/{document_id}",
179
- base_url=base_url,
180
- url_variables=url_variables,
181
- request=request,
182
- request_body_required=False,
183
- request_has_path_params=True,
184
- request_has_query_params=True,
185
- user_agent_header="user-agent",
186
- accept_header_value="application/json",
187
- http_headers=http_headers,
188
- security=self.sdk_configuration.security,
189
- timeout_ms=timeout_ms,
190
- )
191
-
192
- if retries == UNSET:
193
- if self.sdk_configuration.retry_config is not UNSET:
194
- retries = self.sdk_configuration.retry_config
195
-
196
- retry_config = None
197
- if isinstance(retries, utils.RetryConfig):
198
- retry_config = (retries, ["429", "500", "502", "503", "504"])
199
-
200
- http_res = await self.do_request_async(
201
- hook_ctx=HookContext(
202
- base_url=base_url or "",
203
- operation_id="get_document_v1_collections__collection_identifier__documents__document_id__get",
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=["400", "401", "403", "404", "422", "4XX", "500", "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.DocumentResponse)
217
- if utils.match_response(
218
- http_res, ["400", "401", "403", "404"], "application/json"
219
- ):
220
- response_data = utils.unmarshal_json(
221
- http_res.text, models.ErrorResponseData
222
- )
223
- raise models.ErrorResponse(data=response_data)
224
- if utils.match_response(http_res, "422", "application/json"):
225
- response_data = utils.unmarshal_json(
226
- http_res.text, models.HTTPValidationErrorData
227
- )
228
- raise models.HTTPValidationError(data=response_data)
229
- if utils.match_response(http_res, "500", "application/json"):
230
- response_data = utils.unmarshal_json(
231
- http_res.text, models.ErrorResponseData
232
- )
233
- raise models.ErrorResponse(data=response_data)
234
- if utils.match_response(http_res, "4XX", "*"):
235
- http_res_text = await utils.stream_to_text_async(http_res)
236
- raise models.APIError(
237
- "API error occurred", http_res.status_code, http_res_text, http_res
238
- )
239
- if utils.match_response(http_res, "5XX", "*"):
240
- http_res_text = await utils.stream_to_text_async(http_res)
241
- raise models.APIError(
242
- "API error occurred", http_res.status_code, http_res_text, http_res
243
- )
244
-
245
- content_type = http_res.headers.get("Content-Type")
246
- http_res_text = await utils.stream_to_text_async(http_res)
247
- raise models.APIError(
248
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
249
- http_res.status_code,
250
- http_res_text,
251
- http_res,
252
- )
253
-
254
- def update(
255
- self,
256
- *,
257
- collection_identifier: str,
258
- document_id: str,
259
- x_namespace: OptionalNullable[str] = UNSET,
260
- metadata: OptionalNullable[
261
- Union[models.DocumentUpdateMetadata, models.DocumentUpdateMetadataTypedDict]
262
- ] = UNSET,
263
- vectors: OptionalNullable[Dict[str, List[float]]] = UNSET,
264
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
265
- server_url: Optional[str] = None,
266
- timeout_ms: Optional[int] = None,
267
- http_headers: Optional[Mapping[str, str]] = None,
268
- ) -> models.DocumentResponse:
269
- r"""Update Document
270
-
271
- Update an existing document.
272
-
273
-
274
- **Requirements:**
275
- - Required permissions: write
276
-
277
- :param collection_identifier: The ID of the collection
278
- :param document_id: The ID of the document to update
279
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
280
- :param metadata:
281
- :param vectors:
282
- :param retries: Override the default retry configuration for this method
283
- :param server_url: Override the default server URL for this method
284
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
285
- :param http_headers: Additional headers to set or replace on requests.
286
- """
287
- base_url = None
288
- url_variables = None
289
- if timeout_ms is None:
290
- timeout_ms = self.sdk_configuration.timeout_ms
291
-
292
- if server_url is not None:
293
- base_url = server_url
294
- else:
295
- base_url = self._get_url(base_url, url_variables)
296
-
297
- request = models.UpdateDocumentV1CollectionsCollectionIdentifierDocumentsDocumentIDPutRequest(
298
- collection_identifier=collection_identifier,
299
- document_id=document_id,
300
- x_namespace=x_namespace,
301
- document_update=models.DocumentUpdate(
302
- metadata=utils.get_pydantic_model(
303
- metadata, OptionalNullable[models.DocumentUpdateMetadata]
304
- ),
305
- vectors=vectors,
306
- ),
307
- )
308
-
309
- req = self._build_request(
310
- method="PUT",
311
- path="/v1/collections/{collection_identifier}/documents/{document_id}",
312
- base_url=base_url,
313
- url_variables=url_variables,
314
- request=request,
315
- request_body_required=False,
316
- request_has_path_params=True,
317
- request_has_query_params=True,
318
- user_agent_header="user-agent",
319
- accept_header_value="application/json",
320
- http_headers=http_headers,
321
- security=self.sdk_configuration.security,
322
- get_serialized_body=lambda: utils.serialize_request_body(
323
- request.document_update,
324
- False,
325
- True,
326
- "json",
327
- Optional[models.DocumentUpdate],
328
- ),
329
- timeout_ms=timeout_ms,
330
- )
331
-
332
- if retries == UNSET:
333
- if self.sdk_configuration.retry_config is not UNSET:
334
- retries = self.sdk_configuration.retry_config
335
-
336
- retry_config = None
337
- if isinstance(retries, utils.RetryConfig):
338
- retry_config = (retries, ["429", "500", "502", "503", "504"])
339
-
340
- http_res = self.do_request(
341
- hook_ctx=HookContext(
342
- base_url=base_url or "",
343
- operation_id="update_document_v1_collections__collection_identifier__documents__document_id__put",
344
- oauth2_scopes=[],
345
- security_source=get_security_from_env(
346
- self.sdk_configuration.security, models.Security
347
- ),
348
- ),
349
- request=req,
350
- error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
351
- retry_config=retry_config,
352
- )
353
-
354
- response_data: Any = None
355
- if utils.match_response(http_res, "200", "application/json"):
356
- return utils.unmarshal_json(http_res.text, models.DocumentResponse)
357
- if utils.match_response(
358
- http_res, ["400", "401", "403", "404"], "application/json"
359
- ):
360
- response_data = utils.unmarshal_json(
361
- http_res.text, models.ErrorResponseData
362
- )
363
- raise models.ErrorResponse(data=response_data)
364
- if utils.match_response(http_res, "422", "application/json"):
365
- response_data = utils.unmarshal_json(
366
- http_res.text, models.HTTPValidationErrorData
367
- )
368
- raise models.HTTPValidationError(data=response_data)
369
- if utils.match_response(http_res, "500", "application/json"):
370
- response_data = utils.unmarshal_json(
371
- http_res.text, models.ErrorResponseData
372
- )
373
- raise models.ErrorResponse(data=response_data)
374
- if utils.match_response(http_res, "4XX", "*"):
375
- http_res_text = utils.stream_to_text(http_res)
376
- raise models.APIError(
377
- "API error occurred", http_res.status_code, http_res_text, http_res
378
- )
379
- if utils.match_response(http_res, "5XX", "*"):
380
- http_res_text = utils.stream_to_text(http_res)
381
- raise models.APIError(
382
- "API error occurred", http_res.status_code, http_res_text, http_res
383
- )
384
-
385
- content_type = http_res.headers.get("Content-Type")
386
- http_res_text = utils.stream_to_text(http_res)
387
- raise models.APIError(
388
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
389
- http_res.status_code,
390
- http_res_text,
391
- http_res,
392
- )
393
-
394
- async def update_async(
395
- self,
396
- *,
397
- collection_identifier: str,
398
- document_id: str,
399
- x_namespace: OptionalNullable[str] = UNSET,
400
- metadata: OptionalNullable[
401
- Union[models.DocumentUpdateMetadata, models.DocumentUpdateMetadataTypedDict]
402
- ] = UNSET,
403
- vectors: OptionalNullable[Dict[str, List[float]]] = UNSET,
404
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
405
- server_url: Optional[str] = None,
406
- timeout_ms: Optional[int] = None,
407
- http_headers: Optional[Mapping[str, str]] = None,
408
- ) -> models.DocumentResponse:
409
- r"""Update Document
410
-
411
- Update an existing document.
412
-
413
-
414
- **Requirements:**
415
- - Required permissions: write
416
-
417
- :param collection_identifier: The ID of the collection
418
- :param document_id: The ID of the document to update
419
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
420
- :param metadata:
421
- :param vectors:
422
- :param retries: Override the default retry configuration for this method
423
- :param server_url: Override the default server URL for this method
424
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
425
- :param http_headers: Additional headers to set or replace on requests.
426
- """
427
- base_url = None
428
- url_variables = None
429
- if timeout_ms is None:
430
- timeout_ms = self.sdk_configuration.timeout_ms
431
-
432
- if server_url is not None:
433
- base_url = server_url
434
- else:
435
- base_url = self._get_url(base_url, url_variables)
436
-
437
- request = models.UpdateDocumentV1CollectionsCollectionIdentifierDocumentsDocumentIDPutRequest(
438
- collection_identifier=collection_identifier,
439
- document_id=document_id,
440
- x_namespace=x_namespace,
441
- document_update=models.DocumentUpdate(
442
- metadata=utils.get_pydantic_model(
443
- metadata, OptionalNullable[models.DocumentUpdateMetadata]
444
- ),
445
- vectors=vectors,
446
- ),
447
- )
448
-
449
- req = self._build_request_async(
450
- method="PUT",
451
- path="/v1/collections/{collection_identifier}/documents/{document_id}",
452
- base_url=base_url,
453
- url_variables=url_variables,
454
- request=request,
455
- request_body_required=False,
456
- request_has_path_params=True,
457
- request_has_query_params=True,
458
- user_agent_header="user-agent",
459
- accept_header_value="application/json",
460
- http_headers=http_headers,
461
- security=self.sdk_configuration.security,
462
- get_serialized_body=lambda: utils.serialize_request_body(
463
- request.document_update,
464
- False,
465
- True,
466
- "json",
467
- Optional[models.DocumentUpdate],
468
- ),
469
- timeout_ms=timeout_ms,
470
- )
471
-
472
- if retries == UNSET:
473
- if self.sdk_configuration.retry_config is not UNSET:
474
- retries = self.sdk_configuration.retry_config
475
-
476
- retry_config = None
477
- if isinstance(retries, utils.RetryConfig):
478
- retry_config = (retries, ["429", "500", "502", "503", "504"])
479
-
480
- http_res = await self.do_request_async(
481
- hook_ctx=HookContext(
482
- base_url=base_url or "",
483
- operation_id="update_document_v1_collections__collection_identifier__documents__document_id__put",
484
- oauth2_scopes=[],
485
- security_source=get_security_from_env(
486
- self.sdk_configuration.security, models.Security
487
- ),
488
- ),
489
- request=req,
490
- error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
491
- retry_config=retry_config,
492
- )
493
-
494
- response_data: Any = None
495
- if utils.match_response(http_res, "200", "application/json"):
496
- return utils.unmarshal_json(http_res.text, models.DocumentResponse)
497
- if utils.match_response(
498
- http_res, ["400", "401", "403", "404"], "application/json"
499
- ):
500
- response_data = utils.unmarshal_json(
501
- http_res.text, models.ErrorResponseData
502
- )
503
- raise models.ErrorResponse(data=response_data)
504
- if utils.match_response(http_res, "422", "application/json"):
505
- response_data = utils.unmarshal_json(
506
- http_res.text, models.HTTPValidationErrorData
507
- )
508
- raise models.HTTPValidationError(data=response_data)
509
- if utils.match_response(http_res, "500", "application/json"):
510
- response_data = utils.unmarshal_json(
511
- http_res.text, models.ErrorResponseData
512
- )
513
- raise models.ErrorResponse(data=response_data)
514
- if utils.match_response(http_res, "4XX", "*"):
515
- http_res_text = await utils.stream_to_text_async(http_res)
516
- raise models.APIError(
517
- "API error occurred", http_res.status_code, http_res_text, http_res
518
- )
519
- if utils.match_response(http_res, "5XX", "*"):
520
- http_res_text = await utils.stream_to_text_async(http_res)
521
- raise models.APIError(
522
- "API error occurred", http_res.status_code, http_res_text, http_res
523
- )
524
-
525
- content_type = http_res.headers.get("Content-Type")
526
- http_res_text = await utils.stream_to_text_async(http_res)
527
- raise models.APIError(
528
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
529
- http_res.status_code,
530
- http_res_text,
531
- http_res,
532
- )
533
-
534
- def delete(
535
- self,
536
- *,
537
- collection_identifier: str,
538
- document_id: str,
539
- x_namespace: OptionalNullable[str] = UNSET,
540
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
541
- server_url: Optional[str] = None,
542
- timeout_ms: Optional[int] = None,
543
- http_headers: Optional[Mapping[str, str]] = None,
544
- ) -> models.GenericSuccessResponse:
545
- r"""Delete Document
546
-
547
- Delete a document.
548
-
549
-
550
- **Requirements:**
551
- - Required permissions: write
552
-
553
- :param collection_identifier: The ID of the collection
554
- :param document_id: The ID of the document to delete
555
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
556
- :param retries: Override the default retry configuration for this method
557
- :param server_url: Override the default server URL for this method
558
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
559
- :param http_headers: Additional headers to set or replace on requests.
560
- """
561
- base_url = None
562
- url_variables = None
563
- if timeout_ms is None:
564
- timeout_ms = self.sdk_configuration.timeout_ms
565
-
566
- if server_url is not None:
567
- base_url = server_url
568
- else:
569
- base_url = self._get_url(base_url, url_variables)
570
-
571
- request = models.DeleteDocumentV1CollectionsCollectionIdentifierDocumentsDocumentIDDeleteRequest(
572
- collection_identifier=collection_identifier,
573
- document_id=document_id,
574
- x_namespace=x_namespace,
575
- )
576
-
577
- req = self._build_request(
578
- method="DELETE",
579
- path="/v1/collections/{collection_identifier}/documents/{document_id}",
580
- base_url=base_url,
581
- url_variables=url_variables,
582
- request=request,
583
- request_body_required=False,
584
- request_has_path_params=True,
585
- request_has_query_params=True,
586
- user_agent_header="user-agent",
587
- accept_header_value="application/json",
588
- http_headers=http_headers,
589
- security=self.sdk_configuration.security,
590
- timeout_ms=timeout_ms,
591
- )
592
-
593
- if retries == UNSET:
594
- if self.sdk_configuration.retry_config is not UNSET:
595
- retries = self.sdk_configuration.retry_config
596
-
597
- retry_config = None
598
- if isinstance(retries, utils.RetryConfig):
599
- retry_config = (retries, ["429", "500", "502", "503", "504"])
600
-
601
- http_res = self.do_request(
602
- hook_ctx=HookContext(
603
- base_url=base_url or "",
604
- operation_id="delete_document_v1_collections__collection_identifier__documents__document_id__delete",
605
- oauth2_scopes=[],
606
- security_source=get_security_from_env(
607
- self.sdk_configuration.security, models.Security
608
- ),
609
- ),
610
- request=req,
611
- error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
612
- retry_config=retry_config,
613
- )
614
-
615
- response_data: Any = None
616
- if utils.match_response(http_res, "200", "application/json"):
617
- return utils.unmarshal_json(http_res.text, models.GenericSuccessResponse)
618
- if utils.match_response(
619
- http_res, ["400", "401", "403", "404"], "application/json"
620
- ):
621
- response_data = utils.unmarshal_json(
622
- http_res.text, models.ErrorResponseData
623
- )
624
- raise models.ErrorResponse(data=response_data)
625
- if utils.match_response(http_res, "422", "application/json"):
626
- response_data = utils.unmarshal_json(
627
- http_res.text, models.HTTPValidationErrorData
628
- )
629
- raise models.HTTPValidationError(data=response_data)
630
- if utils.match_response(http_res, "500", "application/json"):
631
- response_data = utils.unmarshal_json(
632
- http_res.text, models.ErrorResponseData
633
- )
634
- raise models.ErrorResponse(data=response_data)
635
- if utils.match_response(http_res, "4XX", "*"):
636
- http_res_text = utils.stream_to_text(http_res)
637
- raise models.APIError(
638
- "API error occurred", http_res.status_code, http_res_text, http_res
639
- )
640
- if utils.match_response(http_res, "5XX", "*"):
641
- http_res_text = utils.stream_to_text(http_res)
642
- raise models.APIError(
643
- "API error occurred", http_res.status_code, http_res_text, http_res
644
- )
645
-
646
- content_type = http_res.headers.get("Content-Type")
647
- http_res_text = utils.stream_to_text(http_res)
648
- raise models.APIError(
649
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
650
- http_res.status_code,
651
- http_res_text,
652
- http_res,
653
- )
654
-
655
- async def delete_async(
656
- self,
657
- *,
658
- collection_identifier: str,
659
- document_id: str,
660
- x_namespace: OptionalNullable[str] = UNSET,
661
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
662
- server_url: Optional[str] = None,
663
- timeout_ms: Optional[int] = None,
664
- http_headers: Optional[Mapping[str, str]] = None,
665
- ) -> models.GenericSuccessResponse:
666
- r"""Delete Document
667
-
668
- Delete a document.
669
-
670
-
671
- **Requirements:**
672
- - Required permissions: write
673
-
674
- :param collection_identifier: The ID of the collection
675
- :param document_id: The ID of the document to delete
676
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
677
- :param retries: Override the default retry configuration for this method
678
- :param server_url: Override the default server URL for this method
679
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
680
- :param http_headers: Additional headers to set or replace on requests.
681
- """
682
- base_url = None
683
- url_variables = None
684
- if timeout_ms is None:
685
- timeout_ms = self.sdk_configuration.timeout_ms
686
-
687
- if server_url is not None:
688
- base_url = server_url
689
- else:
690
- base_url = self._get_url(base_url, url_variables)
691
-
692
- request = models.DeleteDocumentV1CollectionsCollectionIdentifierDocumentsDocumentIDDeleteRequest(
693
- collection_identifier=collection_identifier,
694
- document_id=document_id,
695
- x_namespace=x_namespace,
696
- )
697
-
698
- req = self._build_request_async(
699
- method="DELETE",
700
- path="/v1/collections/{collection_identifier}/documents/{document_id}",
701
- base_url=base_url,
702
- url_variables=url_variables,
703
- request=request,
704
- request_body_required=False,
705
- request_has_path_params=True,
706
- request_has_query_params=True,
707
- user_agent_header="user-agent",
708
- accept_header_value="application/json",
709
- http_headers=http_headers,
710
- security=self.sdk_configuration.security,
711
- timeout_ms=timeout_ms,
712
- )
713
-
714
- if retries == UNSET:
715
- if self.sdk_configuration.retry_config is not UNSET:
716
- retries = self.sdk_configuration.retry_config
717
-
718
- retry_config = None
719
- if isinstance(retries, utils.RetryConfig):
720
- retry_config = (retries, ["429", "500", "502", "503", "504"])
721
-
722
- http_res = await self.do_request_async(
723
- hook_ctx=HookContext(
724
- base_url=base_url or "",
725
- operation_id="delete_document_v1_collections__collection_identifier__documents__document_id__delete",
726
- oauth2_scopes=[],
727
- security_source=get_security_from_env(
728
- self.sdk_configuration.security, models.Security
729
- ),
730
- ),
731
- request=req,
732
- error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
733
- retry_config=retry_config,
734
- )
735
-
736
- response_data: Any = None
737
- if utils.match_response(http_res, "200", "application/json"):
738
- return utils.unmarshal_json(http_res.text, models.GenericSuccessResponse)
739
- if utils.match_response(
740
- http_res, ["400", "401", "403", "404"], "application/json"
741
- ):
742
- response_data = utils.unmarshal_json(
743
- http_res.text, models.ErrorResponseData
744
- )
745
- raise models.ErrorResponse(data=response_data)
746
- if utils.match_response(http_res, "422", "application/json"):
747
- response_data = utils.unmarshal_json(
748
- http_res.text, models.HTTPValidationErrorData
749
- )
750
- raise models.HTTPValidationError(data=response_data)
751
- if utils.match_response(http_res, "500", "application/json"):
752
- response_data = utils.unmarshal_json(
753
- http_res.text, models.ErrorResponseData
754
- )
755
- raise models.ErrorResponse(data=response_data)
756
- if utils.match_response(http_res, "4XX", "*"):
757
- http_res_text = await utils.stream_to_text_async(http_res)
758
- raise models.APIError(
759
- "API error occurred", http_res.status_code, http_res_text, http_res
760
- )
761
- if utils.match_response(http_res, "5XX", "*"):
762
- http_res_text = await utils.stream_to_text_async(http_res)
763
- raise models.APIError(
764
- "API error occurred", http_res.status_code, http_res_text, http_res
765
- )
766
-
767
- content_type = http_res.headers.get("Content-Type")
768
- http_res_text = await utils.stream_to_text_async(http_res)
769
- raise models.APIError(
770
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
771
- http_res.status_code,
772
- http_res_text,
773
- http_res,
774
- )
775
-
776
- def list(
777
- self,
778
- *,
779
- collection_identifier: str,
780
- limit: Optional[int] = 10,
781
- offset_id: OptionalNullable[str] = UNSET,
782
- sort: OptionalNullable[str] = UNSET,
783
- filters: OptionalNullable[str] = UNSET,
784
- select: OptionalNullable[str] = UNSET,
785
- x_namespace: OptionalNullable[str] = UNSET,
786
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
787
- server_url: Optional[str] = None,
788
- timeout_ms: Optional[int] = None,
789
- http_headers: Optional[Mapping[str, str]] = None,
790
- ) -> models.DocumentListResponse:
791
- r"""List Documents
792
-
793
- List documents with pagination and filtering.
794
-
795
-
796
- **Requirements:**
797
- - Required permissions: read
798
-
799
- :param collection_identifier: The ID of the collection
800
- :param limit: Number of documents to return per page
801
- :param offset_id: ID of the document to start pagination from
802
- :param sort: Field to sort by
803
- :param filters: Filter criteria
804
- :param select: Fields to select
805
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
806
- :param retries: Override the default retry configuration for this method
807
- :param server_url: Override the default server URL for this method
808
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
809
- :param http_headers: Additional headers to set or replace on requests.
810
- """
811
- base_url = None
812
- url_variables = None
813
- if timeout_ms is None:
814
- timeout_ms = self.sdk_configuration.timeout_ms
815
-
816
- if server_url is not None:
817
- base_url = server_url
818
- else:
819
- base_url = self._get_url(base_url, url_variables)
820
-
821
- request = (
822
- models.ListDocumentsV1CollectionsCollectionIdentifierDocumentsGetRequest(
823
- collection_identifier=collection_identifier,
824
- limit=limit,
825
- offset_id=offset_id,
826
- sort=sort,
827
- filters=filters,
828
- select=select,
829
- x_namespace=x_namespace,
830
- )
831
- )
832
-
833
- req = self._build_request(
834
- method="GET",
835
- path="/v1/collections/{collection_identifier}/documents",
836
- base_url=base_url,
837
- url_variables=url_variables,
838
- request=request,
839
- request_body_required=False,
840
- request_has_path_params=True,
841
- request_has_query_params=True,
842
- user_agent_header="user-agent",
843
- accept_header_value="application/json",
844
- http_headers=http_headers,
845
- security=self.sdk_configuration.security,
846
- timeout_ms=timeout_ms,
847
- )
848
-
849
- if retries == UNSET:
850
- if self.sdk_configuration.retry_config is not UNSET:
851
- retries = self.sdk_configuration.retry_config
852
-
853
- retry_config = None
854
- if isinstance(retries, utils.RetryConfig):
855
- retry_config = (retries, ["429", "500", "502", "503", "504"])
856
-
857
- http_res = self.do_request(
858
- hook_ctx=HookContext(
859
- base_url=base_url or "",
860
- operation_id="list_documents_v1_collections__collection_identifier__documents_get",
861
- oauth2_scopes=[],
862
- security_source=get_security_from_env(
863
- self.sdk_configuration.security, models.Security
864
- ),
865
- ),
866
- request=req,
867
- error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
868
- retry_config=retry_config,
869
- )
870
-
871
- response_data: Any = None
872
- if utils.match_response(http_res, "200", "application/json"):
873
- return utils.unmarshal_json(http_res.text, models.DocumentListResponse)
874
- if utils.match_response(
875
- http_res, ["400", "401", "403", "404"], "application/json"
876
- ):
877
- response_data = utils.unmarshal_json(
878
- http_res.text, models.ErrorResponseData
879
- )
880
- raise models.ErrorResponse(data=response_data)
881
- if utils.match_response(http_res, "422", "application/json"):
882
- response_data = utils.unmarshal_json(
883
- http_res.text, models.HTTPValidationErrorData
884
- )
885
- raise models.HTTPValidationError(data=response_data)
886
- if utils.match_response(http_res, "500", "application/json"):
887
- response_data = utils.unmarshal_json(
888
- http_res.text, models.ErrorResponseData
889
- )
890
- raise models.ErrorResponse(data=response_data)
891
- if utils.match_response(http_res, "4XX", "*"):
892
- http_res_text = utils.stream_to_text(http_res)
893
- raise models.APIError(
894
- "API error occurred", http_res.status_code, http_res_text, http_res
895
- )
896
- if utils.match_response(http_res, "5XX", "*"):
897
- http_res_text = utils.stream_to_text(http_res)
898
- raise models.APIError(
899
- "API error occurred", http_res.status_code, http_res_text, http_res
900
- )
901
-
902
- content_type = http_res.headers.get("Content-Type")
903
- http_res_text = utils.stream_to_text(http_res)
904
- raise models.APIError(
905
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
906
- http_res.status_code,
907
- http_res_text,
908
- http_res,
909
- )
910
-
911
- async def list_async(
912
- self,
913
- *,
914
- collection_identifier: str,
915
- limit: Optional[int] = 10,
916
- offset_id: OptionalNullable[str] = UNSET,
917
- sort: OptionalNullable[str] = UNSET,
918
- filters: OptionalNullable[str] = UNSET,
919
- select: OptionalNullable[str] = UNSET,
920
- x_namespace: OptionalNullable[str] = UNSET,
921
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
922
- server_url: Optional[str] = None,
923
- timeout_ms: Optional[int] = None,
924
- http_headers: Optional[Mapping[str, str]] = None,
925
- ) -> models.DocumentListResponse:
926
- r"""List Documents
927
-
928
- List documents with pagination and filtering.
929
-
930
-
931
- **Requirements:**
932
- - Required permissions: read
933
-
934
- :param collection_identifier: The ID of the collection
935
- :param limit: Number of documents to return per page
936
- :param offset_id: ID of the document to start pagination from
937
- :param sort: Field to sort by
938
- :param filters: Filter criteria
939
- :param select: Fields to select
940
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
941
- :param retries: Override the default retry configuration for this method
942
- :param server_url: Override the default server URL for this method
943
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
944
- :param http_headers: Additional headers to set or replace on requests.
945
- """
946
- base_url = None
947
- url_variables = None
948
- if timeout_ms is None:
949
- timeout_ms = self.sdk_configuration.timeout_ms
950
-
951
- if server_url is not None:
952
- base_url = server_url
953
- else:
954
- base_url = self._get_url(base_url, url_variables)
955
-
956
- request = (
957
- models.ListDocumentsV1CollectionsCollectionIdentifierDocumentsGetRequest(
958
- collection_identifier=collection_identifier,
959
- limit=limit,
960
- offset_id=offset_id,
961
- sort=sort,
962
- filters=filters,
963
- select=select,
964
- x_namespace=x_namespace,
965
- )
966
- )
967
-
968
- req = self._build_request_async(
969
- method="GET",
970
- path="/v1/collections/{collection_identifier}/documents",
971
- base_url=base_url,
972
- url_variables=url_variables,
973
- request=request,
974
- request_body_required=False,
975
- request_has_path_params=True,
976
- request_has_query_params=True,
977
- user_agent_header="user-agent",
978
- accept_header_value="application/json",
979
- http_headers=http_headers,
980
- security=self.sdk_configuration.security,
981
- timeout_ms=timeout_ms,
982
- )
983
-
984
- if retries == UNSET:
985
- if self.sdk_configuration.retry_config is not UNSET:
986
- retries = self.sdk_configuration.retry_config
987
-
988
- retry_config = None
989
- if isinstance(retries, utils.RetryConfig):
990
- retry_config = (retries, ["429", "500", "502", "503", "504"])
991
-
992
- http_res = await self.do_request_async(
993
- hook_ctx=HookContext(
994
- base_url=base_url or "",
995
- operation_id="list_documents_v1_collections__collection_identifier__documents_get",
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", "403", "404", "422", "4XX", "500", "5XX"],
1003
- retry_config=retry_config,
1004
- )
1005
-
1006
- response_data: Any = None
1007
- if utils.match_response(http_res, "200", "application/json"):
1008
- return utils.unmarshal_json(http_res.text, models.DocumentListResponse)
1009
- if utils.match_response(
1010
- http_res, ["400", "401", "403", "404"], "application/json"
1011
- ):
1012
- response_data = utils.unmarshal_json(
1013
- http_res.text, models.ErrorResponseData
1014
- )
1015
- raise models.ErrorResponse(data=response_data)
1016
- if utils.match_response(http_res, "422", "application/json"):
1017
- response_data = utils.unmarshal_json(
1018
- http_res.text, models.HTTPValidationErrorData
1019
- )
1020
- raise models.HTTPValidationError(data=response_data)
1021
- if utils.match_response(http_res, "500", "application/json"):
1022
- response_data = utils.unmarshal_json(
1023
- http_res.text, models.ErrorResponseData
1024
- )
1025
- raise models.ErrorResponse(data=response_data)
1026
- if utils.match_response(http_res, "4XX", "*"):
1027
- http_res_text = await utils.stream_to_text_async(http_res)
1028
- raise models.APIError(
1029
- "API error occurred", http_res.status_code, http_res_text, http_res
1030
- )
1031
- if utils.match_response(http_res, "5XX", "*"):
1032
- http_res_text = await utils.stream_to_text_async(http_res)
1033
- raise models.APIError(
1034
- "API error occurred", http_res.status_code, http_res_text, http_res
1035
- )
1036
-
1037
- content_type = http_res.headers.get("Content-Type")
1038
- http_res_text = await utils.stream_to_text_async(http_res)
1039
- raise models.APIError(
1040
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1041
- http_res.status_code,
1042
- http_res_text,
1043
- http_res,
1044
- )
1045
-
1046
- def batch_update(
1047
- self,
1048
- *,
1049
- collection_identifier: str,
1050
- x_namespace: OptionalNullable[str] = UNSET,
1051
- request_body: Optional[
1052
- Union[
1053
- List[List[models.RequestBody]], List[List[models.RequestBodyTypedDict]]
1054
- ]
1055
- ] = None,
1056
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
1057
- server_url: Optional[str] = None,
1058
- timeout_ms: Optional[int] = None,
1059
- http_headers: Optional[Mapping[str, str]] = None,
1060
- ) -> List[Nullable[models.DocumentResponse]]:
1061
- r"""Batch Update Documents
1062
-
1063
- Update multiple documents in a batch.
1064
-
1065
-
1066
- **Requirements:**
1067
- - Required permissions: write
1068
-
1069
- :param collection_identifier: The ID of the collection
1070
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
1071
- :param request_body:
1072
- :param retries: Override the default retry configuration for this method
1073
- :param server_url: Override the default server URL for this method
1074
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1075
- :param http_headers: Additional headers to set or replace on requests.
1076
- """
1077
- base_url = None
1078
- url_variables = None
1079
- if timeout_ms is None:
1080
- timeout_ms = self.sdk_configuration.timeout_ms
1081
-
1082
- if server_url is not None:
1083
- base_url = server_url
1084
- else:
1085
- base_url = self._get_url(base_url, url_variables)
1086
-
1087
- request = models.BatchUpdateDocumentsV1CollectionsCollectionIdentifierDocumentsBatchPutRequest(
1088
- collection_identifier=collection_identifier,
1089
- x_namespace=x_namespace,
1090
- request_body=utils.get_pydantic_model(
1091
- request_body, Optional[List[List[models.RequestBody]]]
1092
- ),
1093
- )
1094
-
1095
- req = self._build_request(
1096
- method="PUT",
1097
- path="/v1/collections/{collection_identifier}/documents/batch",
1098
- base_url=base_url,
1099
- url_variables=url_variables,
1100
- request=request,
1101
- request_body_required=False,
1102
- request_has_path_params=True,
1103
- request_has_query_params=True,
1104
- user_agent_header="user-agent",
1105
- accept_header_value="application/json",
1106
- http_headers=http_headers,
1107
- security=self.sdk_configuration.security,
1108
- get_serialized_body=lambda: utils.serialize_request_body(
1109
- request.request_body,
1110
- False,
1111
- True,
1112
- "json",
1113
- Optional[List[List[models.RequestBody]]],
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
-
1122
- retry_config = None
1123
- if isinstance(retries, utils.RetryConfig):
1124
- retry_config = (retries, ["429", "500", "502", "503", "504"])
1125
-
1126
- http_res = self.do_request(
1127
- hook_ctx=HookContext(
1128
- base_url=base_url or "",
1129
- operation_id="batch_update_documents_v1_collections__collection_identifier__documents_batch_put",
1130
- oauth2_scopes=[],
1131
- security_source=get_security_from_env(
1132
- self.sdk_configuration.security, models.Security
1133
- ),
1134
- ),
1135
- request=req,
1136
- error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
1137
- retry_config=retry_config,
1138
- )
1139
-
1140
- response_data: Any = None
1141
- if utils.match_response(http_res, "200", "application/json"):
1142
- return utils.unmarshal_json(
1143
- http_res.text, List[Nullable[models.DocumentResponse]]
1144
- )
1145
- if utils.match_response(
1146
- http_res, ["400", "401", "403", "404"], "application/json"
1147
- ):
1148
- response_data = utils.unmarshal_json(
1149
- http_res.text, models.ErrorResponseData
1150
- )
1151
- raise models.ErrorResponse(data=response_data)
1152
- if utils.match_response(http_res, "422", "application/json"):
1153
- response_data = utils.unmarshal_json(
1154
- http_res.text, models.HTTPValidationErrorData
1155
- )
1156
- raise models.HTTPValidationError(data=response_data)
1157
- if utils.match_response(http_res, "500", "application/json"):
1158
- response_data = utils.unmarshal_json(
1159
- http_res.text, models.ErrorResponseData
1160
- )
1161
- raise models.ErrorResponse(data=response_data)
1162
- if utils.match_response(http_res, "4XX", "*"):
1163
- http_res_text = utils.stream_to_text(http_res)
1164
- raise models.APIError(
1165
- "API error occurred", http_res.status_code, http_res_text, http_res
1166
- )
1167
- if utils.match_response(http_res, "5XX", "*"):
1168
- http_res_text = utils.stream_to_text(http_res)
1169
- raise models.APIError(
1170
- "API error occurred", http_res.status_code, http_res_text, http_res
1171
- )
1172
-
1173
- content_type = http_res.headers.get("Content-Type")
1174
- http_res_text = utils.stream_to_text(http_res)
1175
- raise models.APIError(
1176
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1177
- http_res.status_code,
1178
- http_res_text,
1179
- http_res,
1180
- )
1181
-
1182
- async def batch_update_async(
1183
- self,
1184
- *,
1185
- collection_identifier: str,
1186
- x_namespace: OptionalNullable[str] = UNSET,
1187
- request_body: Optional[
1188
- Union[
1189
- List[List[models.RequestBody]], List[List[models.RequestBodyTypedDict]]
1190
- ]
1191
- ] = None,
1192
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
1193
- server_url: Optional[str] = None,
1194
- timeout_ms: Optional[int] = None,
1195
- http_headers: Optional[Mapping[str, str]] = None,
1196
- ) -> List[Nullable[models.DocumentResponse]]:
1197
- r"""Batch Update Documents
1198
-
1199
- Update multiple documents in a batch.
1200
-
1201
-
1202
- **Requirements:**
1203
- - Required permissions: write
1204
-
1205
- :param collection_identifier: The ID of the collection
1206
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
1207
- :param request_body:
1208
- :param retries: Override the default retry configuration for this method
1209
- :param server_url: Override the default server URL for this method
1210
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1211
- :param http_headers: Additional headers to set or replace on requests.
1212
- """
1213
- base_url = None
1214
- url_variables = None
1215
- if timeout_ms is None:
1216
- timeout_ms = self.sdk_configuration.timeout_ms
1217
-
1218
- if server_url is not None:
1219
- base_url = server_url
1220
- else:
1221
- base_url = self._get_url(base_url, url_variables)
1222
-
1223
- request = models.BatchUpdateDocumentsV1CollectionsCollectionIdentifierDocumentsBatchPutRequest(
1224
- collection_identifier=collection_identifier,
1225
- x_namespace=x_namespace,
1226
- request_body=utils.get_pydantic_model(
1227
- request_body, Optional[List[List[models.RequestBody]]]
1228
- ),
1229
- )
1230
-
1231
- req = self._build_request_async(
1232
- method="PUT",
1233
- path="/v1/collections/{collection_identifier}/documents/batch",
1234
- base_url=base_url,
1235
- url_variables=url_variables,
1236
- request=request,
1237
- request_body_required=False,
1238
- request_has_path_params=True,
1239
- request_has_query_params=True,
1240
- user_agent_header="user-agent",
1241
- accept_header_value="application/json",
1242
- http_headers=http_headers,
1243
- security=self.sdk_configuration.security,
1244
- get_serialized_body=lambda: utils.serialize_request_body(
1245
- request.request_body,
1246
- False,
1247
- True,
1248
- "json",
1249
- Optional[List[List[models.RequestBody]]],
1250
- ),
1251
- timeout_ms=timeout_ms,
1252
- )
1253
-
1254
- if retries == UNSET:
1255
- if self.sdk_configuration.retry_config is not UNSET:
1256
- retries = self.sdk_configuration.retry_config
1257
-
1258
- retry_config = None
1259
- if isinstance(retries, utils.RetryConfig):
1260
- retry_config = (retries, ["429", "500", "502", "503", "504"])
1261
-
1262
- http_res = await self.do_request_async(
1263
- hook_ctx=HookContext(
1264
- base_url=base_url or "",
1265
- operation_id="batch_update_documents_v1_collections__collection_identifier__documents_batch_put",
1266
- oauth2_scopes=[],
1267
- security_source=get_security_from_env(
1268
- self.sdk_configuration.security, models.Security
1269
- ),
1270
- ),
1271
- request=req,
1272
- error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
1273
- retry_config=retry_config,
1274
- )
1275
-
1276
- response_data: Any = None
1277
- if utils.match_response(http_res, "200", "application/json"):
1278
- return utils.unmarshal_json(
1279
- http_res.text, List[Nullable[models.DocumentResponse]]
1280
- )
1281
- if utils.match_response(
1282
- http_res, ["400", "401", "403", "404"], "application/json"
1283
- ):
1284
- response_data = utils.unmarshal_json(
1285
- http_res.text, models.ErrorResponseData
1286
- )
1287
- raise models.ErrorResponse(data=response_data)
1288
- if utils.match_response(http_res, "422", "application/json"):
1289
- response_data = utils.unmarshal_json(
1290
- http_res.text, models.HTTPValidationErrorData
1291
- )
1292
- raise models.HTTPValidationError(data=response_data)
1293
- if utils.match_response(http_res, "500", "application/json"):
1294
- response_data = utils.unmarshal_json(
1295
- http_res.text, models.ErrorResponseData
1296
- )
1297
- raise models.ErrorResponse(data=response_data)
1298
- if utils.match_response(http_res, "4XX", "*"):
1299
- http_res_text = await utils.stream_to_text_async(http_res)
1300
- raise models.APIError(
1301
- "API error occurred", http_res.status_code, http_res_text, http_res
1302
- )
1303
- if utils.match_response(http_res, "5XX", "*"):
1304
- http_res_text = await utils.stream_to_text_async(http_res)
1305
- raise models.APIError(
1306
- "API error occurred", http_res.status_code, http_res_text, http_res
1307
- )
1308
-
1309
- content_type = http_res.headers.get("Content-Type")
1310
- http_res_text = await utils.stream_to_text_async(http_res)
1311
- raise models.APIError(
1312
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1313
- http_res.status_code,
1314
- http_res_text,
1315
- http_res,
1316
- )
1317
-
1318
- def batch_delete(
1319
- self,
1320
- *,
1321
- collection_identifier: str,
1322
- x_namespace: OptionalNullable[str] = UNSET,
1323
- request_body: Optional[List[str]] = None,
1324
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
1325
- server_url: Optional[str] = None,
1326
- timeout_ms: Optional[int] = None,
1327
- http_headers: Optional[Mapping[str, str]] = None,
1328
- ) -> Any:
1329
- r"""Batch Delete Documents
1330
-
1331
- Delete multiple documents in a batch.
1332
-
1333
-
1334
- **Requirements:**
1335
- - Required permissions: write
1336
-
1337
- :param collection_identifier: The ID of the collection
1338
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
1339
- :param request_body:
1340
- :param retries: Override the default retry configuration for this method
1341
- :param server_url: Override the default server URL for this method
1342
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1343
- :param http_headers: Additional headers to set or replace on requests.
1344
- """
1345
- base_url = None
1346
- url_variables = None
1347
- if timeout_ms is None:
1348
- timeout_ms = self.sdk_configuration.timeout_ms
1349
-
1350
- if server_url is not None:
1351
- base_url = server_url
1352
- else:
1353
- base_url = self._get_url(base_url, url_variables)
1354
-
1355
- request = models.BatchDeleteDocumentsV1CollectionsCollectionIdentifierDocumentsBatchDeleteRequest(
1356
- collection_identifier=collection_identifier,
1357
- x_namespace=x_namespace,
1358
- request_body=request_body,
1359
- )
1360
-
1361
- req = self._build_request(
1362
- method="DELETE",
1363
- path="/v1/collections/{collection_identifier}/documents/batch",
1364
- base_url=base_url,
1365
- url_variables=url_variables,
1366
- request=request,
1367
- request_body_required=False,
1368
- request_has_path_params=True,
1369
- request_has_query_params=True,
1370
- user_agent_header="user-agent",
1371
- accept_header_value="application/json",
1372
- http_headers=http_headers,
1373
- security=self.sdk_configuration.security,
1374
- get_serialized_body=lambda: utils.serialize_request_body(
1375
- request.request_body, False, True, "json", Optional[List[str]]
1376
- ),
1377
- timeout_ms=timeout_ms,
1378
- )
1379
-
1380
- if retries == UNSET:
1381
- if self.sdk_configuration.retry_config is not UNSET:
1382
- retries = self.sdk_configuration.retry_config
1383
-
1384
- retry_config = None
1385
- if isinstance(retries, utils.RetryConfig):
1386
- retry_config = (retries, ["429", "500", "502", "503", "504"])
1387
-
1388
- http_res = self.do_request(
1389
- hook_ctx=HookContext(
1390
- base_url=base_url or "",
1391
- operation_id="batch_delete_documents_v1_collections__collection_identifier__documents_batch_delete",
1392
- oauth2_scopes=[],
1393
- security_source=get_security_from_env(
1394
- self.sdk_configuration.security, models.Security
1395
- ),
1396
- ),
1397
- request=req,
1398
- error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
1399
- retry_config=retry_config,
1400
- )
1401
-
1402
- response_data: Any = None
1403
- if utils.match_response(http_res, "200", "application/json"):
1404
- return utils.unmarshal_json(http_res.text, Any)
1405
- if utils.match_response(
1406
- http_res, ["400", "401", "403", "404"], "application/json"
1407
- ):
1408
- response_data = utils.unmarshal_json(
1409
- http_res.text, models.ErrorResponseData
1410
- )
1411
- raise models.ErrorResponse(data=response_data)
1412
- if utils.match_response(http_res, "422", "application/json"):
1413
- response_data = utils.unmarshal_json(
1414
- http_res.text, models.HTTPValidationErrorData
1415
- )
1416
- raise models.HTTPValidationError(data=response_data)
1417
- if utils.match_response(http_res, "500", "application/json"):
1418
- response_data = utils.unmarshal_json(
1419
- http_res.text, models.ErrorResponseData
1420
- )
1421
- raise models.ErrorResponse(data=response_data)
1422
- if utils.match_response(http_res, "4XX", "*"):
1423
- http_res_text = utils.stream_to_text(http_res)
1424
- raise models.APIError(
1425
- "API error occurred", http_res.status_code, http_res_text, http_res
1426
- )
1427
- if utils.match_response(http_res, "5XX", "*"):
1428
- http_res_text = utils.stream_to_text(http_res)
1429
- raise models.APIError(
1430
- "API error occurred", http_res.status_code, http_res_text, http_res
1431
- )
1432
-
1433
- content_type = http_res.headers.get("Content-Type")
1434
- http_res_text = utils.stream_to_text(http_res)
1435
- raise models.APIError(
1436
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1437
- http_res.status_code,
1438
- http_res_text,
1439
- http_res,
1440
- )
1441
-
1442
- async def batch_delete_async(
1443
- self,
1444
- *,
1445
- collection_identifier: str,
1446
- x_namespace: OptionalNullable[str] = UNSET,
1447
- request_body: Optional[List[str]] = None,
1448
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
1449
- server_url: Optional[str] = None,
1450
- timeout_ms: Optional[int] = None,
1451
- http_headers: Optional[Mapping[str, str]] = None,
1452
- ) -> Any:
1453
- r"""Batch Delete Documents
1454
-
1455
- Delete multiple documents in a batch.
1456
-
1457
-
1458
- **Requirements:**
1459
- - Required permissions: write
1460
-
1461
- :param collection_identifier: The ID of the collection
1462
- :param x_namespace: Optional namespace for data isolation. This can be a namespace name or namespace ID. Example: 'netflix_prod' or 'ns_1234567890'. To create a namespace, use the /namespaces endpoint.
1463
- :param request_body:
1464
- :param retries: Override the default retry configuration for this method
1465
- :param server_url: Override the default server URL for this method
1466
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1467
- :param http_headers: Additional headers to set or replace on requests.
1468
- """
1469
- base_url = None
1470
- url_variables = None
1471
- if timeout_ms is None:
1472
- timeout_ms = self.sdk_configuration.timeout_ms
1473
-
1474
- if server_url is not None:
1475
- base_url = server_url
1476
- else:
1477
- base_url = self._get_url(base_url, url_variables)
1478
-
1479
- request = models.BatchDeleteDocumentsV1CollectionsCollectionIdentifierDocumentsBatchDeleteRequest(
1480
- collection_identifier=collection_identifier,
1481
- x_namespace=x_namespace,
1482
- request_body=request_body,
1483
- )
1484
-
1485
- req = self._build_request_async(
1486
- method="DELETE",
1487
- path="/v1/collections/{collection_identifier}/documents/batch",
1488
- base_url=base_url,
1489
- url_variables=url_variables,
1490
- request=request,
1491
- request_body_required=False,
1492
- request_has_path_params=True,
1493
- request_has_query_params=True,
1494
- user_agent_header="user-agent",
1495
- accept_header_value="application/json",
1496
- http_headers=http_headers,
1497
- security=self.sdk_configuration.security,
1498
- get_serialized_body=lambda: utils.serialize_request_body(
1499
- request.request_body, False, True, "json", Optional[List[str]]
1500
- ),
1501
- timeout_ms=timeout_ms,
1502
- )
1503
-
1504
- if retries == UNSET:
1505
- if self.sdk_configuration.retry_config is not UNSET:
1506
- retries = self.sdk_configuration.retry_config
1507
-
1508
- retry_config = None
1509
- if isinstance(retries, utils.RetryConfig):
1510
- retry_config = (retries, ["429", "500", "502", "503", "504"])
1511
-
1512
- http_res = await self.do_request_async(
1513
- hook_ctx=HookContext(
1514
- base_url=base_url or "",
1515
- operation_id="batch_delete_documents_v1_collections__collection_identifier__documents_batch_delete",
1516
- oauth2_scopes=[],
1517
- security_source=get_security_from_env(
1518
- self.sdk_configuration.security, models.Security
1519
- ),
1520
- ),
1521
- request=req,
1522
- error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
1523
- retry_config=retry_config,
1524
- )
1525
-
1526
- response_data: Any = None
1527
- if utils.match_response(http_res, "200", "application/json"):
1528
- return utils.unmarshal_json(http_res.text, Any)
1529
- if utils.match_response(
1530
- http_res, ["400", "401", "403", "404"], "application/json"
1531
- ):
1532
- response_data = utils.unmarshal_json(
1533
- http_res.text, models.ErrorResponseData
1534
- )
1535
- raise models.ErrorResponse(data=response_data)
1536
- if utils.match_response(http_res, "422", "application/json"):
1537
- response_data = utils.unmarshal_json(
1538
- http_res.text, models.HTTPValidationErrorData
1539
- )
1540
- raise models.HTTPValidationError(data=response_data)
1541
- if utils.match_response(http_res, "500", "application/json"):
1542
- response_data = utils.unmarshal_json(
1543
- http_res.text, models.ErrorResponseData
1544
- )
1545
- raise models.ErrorResponse(data=response_data)
1546
- if utils.match_response(http_res, "4XX", "*"):
1547
- http_res_text = await utils.stream_to_text_async(http_res)
1548
- raise models.APIError(
1549
- "API error occurred", http_res.status_code, http_res_text, http_res
1550
- )
1551
- if utils.match_response(http_res, "5XX", "*"):
1552
- http_res_text = await utils.stream_to_text_async(http_res)
1553
- raise models.APIError(
1554
- "API error occurred", http_res.status_code, http_res_text, http_res
1555
- )
1556
-
1557
- content_type = http_res.headers.get("Content-Type")
1558
- http_res_text = await utils.stream_to_text_async(http_res)
1559
- raise models.APIError(
1560
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1561
- http_res.status_code,
1562
- http_res_text,
1563
- http_res,
1564
- )