groundx 2.0.11__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 (80) hide show
  1. groundx/__init__.py +107 -0
  2. groundx/buckets/__init__.py +2 -0
  3. groundx/buckets/client.py +761 -0
  4. groundx/client.py +160 -0
  5. groundx/core/__init__.py +47 -0
  6. groundx/core/api_error.py +15 -0
  7. groundx/core/client_wrapper.py +54 -0
  8. groundx/core/datetime_utils.py +28 -0
  9. groundx/core/file.py +67 -0
  10. groundx/core/http_client.py +499 -0
  11. groundx/core/jsonable_encoder.py +101 -0
  12. groundx/core/pydantic_utilities.py +296 -0
  13. groundx/core/query_encoder.py +58 -0
  14. groundx/core/remove_none_from_dict.py +11 -0
  15. groundx/core/request_options.py +35 -0
  16. groundx/core/serialization.py +272 -0
  17. groundx/customer/__init__.py +2 -0
  18. groundx/customer/client.py +112 -0
  19. groundx/documents/__init__.py +5 -0
  20. groundx/documents/client.py +1544 -0
  21. groundx/documents/types/__init__.py +6 -0
  22. groundx/documents/types/document_remote_ingest_request_documents_item.py +45 -0
  23. groundx/documents/types/website_crawl_request_websites_item.py +46 -0
  24. groundx/environment.py +7 -0
  25. groundx/errors/__init__.py +6 -0
  26. groundx/errors/bad_request_error.py +9 -0
  27. groundx/errors/unauthorized_error.py +9 -0
  28. groundx/groups/__init__.py +2 -0
  29. groundx/groups/client.py +1098 -0
  30. groundx/health/__init__.py +2 -0
  31. groundx/health/client.py +236 -0
  32. groundx/py.typed +0 -0
  33. groundx/search/__init__.py +5 -0
  34. groundx/search/client.py +489 -0
  35. groundx/search/types/__init__.py +5 -0
  36. groundx/search/types/search_content_request_id.py +5 -0
  37. groundx/types/__init__.py +83 -0
  38. groundx/types/bounding_box_detail.py +54 -0
  39. groundx/types/bucket_detail.py +46 -0
  40. groundx/types/bucket_list_response.py +20 -0
  41. groundx/types/bucket_response.py +20 -0
  42. groundx/types/bucket_update_detail.py +22 -0
  43. groundx/types/bucket_update_response.py +20 -0
  44. groundx/types/customer_detail.py +39 -0
  45. groundx/types/customer_response.py +20 -0
  46. groundx/types/document_detail.py +62 -0
  47. groundx/types/document_list_response.py +23 -0
  48. groundx/types/document_lookup_response.py +32 -0
  49. groundx/types/document_response.py +20 -0
  50. groundx/types/document_type.py +7 -0
  51. groundx/types/group_detail.py +52 -0
  52. groundx/types/group_list_response.py +20 -0
  53. groundx/types/group_response.py +20 -0
  54. groundx/types/health_response.py +20 -0
  55. groundx/types/health_response_health.py +20 -0
  56. groundx/types/health_service.py +36 -0
  57. groundx/types/health_service_status.py +5 -0
  58. groundx/types/ingest_response.py +20 -0
  59. groundx/types/ingest_response_ingest.py +23 -0
  60. groundx/types/message_response.py +19 -0
  61. groundx/types/meter_detail.py +40 -0
  62. groundx/types/process_status_response.py +20 -0
  63. groundx/types/process_status_response_ingest.py +26 -0
  64. groundx/types/process_status_response_ingest_progress.py +26 -0
  65. groundx/types/process_status_response_ingest_progress_cancelled.py +21 -0
  66. groundx/types/process_status_response_ingest_progress_complete.py +21 -0
  67. groundx/types/process_status_response_ingest_progress_errors.py +21 -0
  68. groundx/types/process_status_response_ingest_progress_processing.py +21 -0
  69. groundx/types/processing_status.py +5 -0
  70. groundx/types/search_response.py +20 -0
  71. groundx/types/search_response_search.py +59 -0
  72. groundx/types/search_result_item.py +96 -0
  73. groundx/types/sort.py +5 -0
  74. groundx/types/sort_order.py +5 -0
  75. groundx/types/subscription_detail.py +24 -0
  76. groundx/types/subscription_detail_meters.py +23 -0
  77. groundx/version.py +3 -0
  78. groundx-2.0.11.dist-info/METADATA +177 -0
  79. groundx-2.0.11.dist-info/RECORD +80 -0
  80. groundx-2.0.11.dist-info/WHEEL +4 -0
@@ -0,0 +1,1544 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ..core.client_wrapper import SyncClientWrapper
5
+ from .types.document_remote_ingest_request_documents_item import DocumentRemoteIngestRequestDocumentsItem
6
+ from ..core.request_options import RequestOptions
7
+ from ..types.ingest_response import IngestResponse
8
+ from ..core.serialization import convert_and_respect_annotation_metadata
9
+ from ..core.pydantic_utilities import parse_obj_as
10
+ from ..errors.bad_request_error import BadRequestError
11
+ from ..errors.unauthorized_error import UnauthorizedError
12
+ from json.decoder import JSONDecodeError
13
+ from ..core.api_error import ApiError
14
+ from .types.website_crawl_request_websites_item import WebsiteCrawlRequestWebsitesItem
15
+ from ..types.process_status_response import ProcessStatusResponse
16
+ from ..core.jsonable_encoder import jsonable_encoder
17
+ from ..types.sort import Sort
18
+ from ..types.sort_order import SortOrder
19
+ from ..types.processing_status import ProcessingStatus
20
+ from ..types.document_lookup_response import DocumentLookupResponse
21
+ from ..types.document_list_response import DocumentListResponse
22
+ from ..types.document_response import DocumentResponse
23
+ from ..core.client_wrapper import AsyncClientWrapper
24
+
25
+ # this is used as the default value for optional parameters
26
+ OMIT = typing.cast(typing.Any, ...)
27
+
28
+
29
+ class DocumentsClient:
30
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
31
+ self._client_wrapper = client_wrapper
32
+
33
+ def ingest_remote(
34
+ self,
35
+ *,
36
+ documents: typing.Sequence[DocumentRemoteIngestRequestDocumentsItem],
37
+ request_options: typing.Optional[RequestOptions] = None,
38
+ ) -> IngestResponse:
39
+ """
40
+ Ingest documents hosted on public URLs to a GroundX bucket.
41
+
42
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
43
+
44
+ Parameters
45
+ ----------
46
+ documents : typing.Sequence[DocumentRemoteIngestRequestDocumentsItem]
47
+
48
+ request_options : typing.Optional[RequestOptions]
49
+ Request-specific configuration.
50
+
51
+ Returns
52
+ -------
53
+ IngestResponse
54
+ Documents successfully uploaded
55
+
56
+ Examples
57
+ --------
58
+ from groundx import GroundX
59
+ from groundx.documents import DocumentRemoteIngestRequestDocumentsItem
60
+
61
+ client = GroundX(
62
+ api_key="YOUR_API_KEY",
63
+ )
64
+ client.documents.ingest_remote(
65
+ documents=[
66
+ DocumentRemoteIngestRequestDocumentsItem(
67
+ bucket_id=1234,
68
+ source_url="https://my.source.url.com/file.txt",
69
+ )
70
+ ],
71
+ )
72
+ """
73
+ _response = self._client_wrapper.httpx_client.request(
74
+ "v1/ingest/documents/remote",
75
+ method="POST",
76
+ json={
77
+ "documents": convert_and_respect_annotation_metadata(
78
+ object_=documents,
79
+ annotation=typing.Sequence[DocumentRemoteIngestRequestDocumentsItem],
80
+ direction="write",
81
+ ),
82
+ },
83
+ headers={
84
+ "content-type": "application/json",
85
+ },
86
+ request_options=request_options,
87
+ omit=OMIT,
88
+ )
89
+ try:
90
+ if 200 <= _response.status_code < 300:
91
+ return typing.cast(
92
+ IngestResponse,
93
+ parse_obj_as(
94
+ type_=IngestResponse, # type: ignore
95
+ object_=_response.json(),
96
+ ),
97
+ )
98
+ if _response.status_code == 400:
99
+ raise BadRequestError(
100
+ typing.cast(
101
+ typing.Optional[typing.Any],
102
+ parse_obj_as(
103
+ type_=typing.Optional[typing.Any], # type: ignore
104
+ object_=_response.json(),
105
+ ),
106
+ )
107
+ )
108
+ if _response.status_code == 401:
109
+ raise UnauthorizedError(
110
+ typing.cast(
111
+ typing.Optional[typing.Any],
112
+ parse_obj_as(
113
+ type_=typing.Optional[typing.Any], # type: ignore
114
+ object_=_response.json(),
115
+ ),
116
+ )
117
+ )
118
+ _response_json = _response.json()
119
+ except JSONDecodeError:
120
+ raise ApiError(status_code=_response.status_code, body=_response.text)
121
+ raise ApiError(status_code=_response.status_code, body=_response_json)
122
+
123
+ def ingest_local(self, *, request_options: typing.Optional[RequestOptions] = None) -> IngestResponse:
124
+ """
125
+ Upload documents hosted on a local file system for ingestion into a GroundX bucket.
126
+
127
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
128
+
129
+ Parameters
130
+ ----------
131
+ request_options : typing.Optional[RequestOptions]
132
+ Request-specific configuration.
133
+
134
+ Returns
135
+ -------
136
+ IngestResponse
137
+ Documents successfully uploaded
138
+
139
+ Examples
140
+ --------
141
+ from groundx import GroundX
142
+
143
+ client = GroundX(
144
+ api_key="YOUR_API_KEY",
145
+ )
146
+ client.documents.ingest_local()
147
+ """
148
+ _response = self._client_wrapper.httpx_client.request(
149
+ "v1/ingest/documents/local",
150
+ method="POST",
151
+ data={},
152
+ files={},
153
+ request_options=request_options,
154
+ omit=OMIT,
155
+ )
156
+ try:
157
+ if 200 <= _response.status_code < 300:
158
+ return typing.cast(
159
+ IngestResponse,
160
+ parse_obj_as(
161
+ type_=IngestResponse, # type: ignore
162
+ object_=_response.json(),
163
+ ),
164
+ )
165
+ if _response.status_code == 400:
166
+ raise BadRequestError(
167
+ typing.cast(
168
+ typing.Optional[typing.Any],
169
+ parse_obj_as(
170
+ type_=typing.Optional[typing.Any], # type: ignore
171
+ object_=_response.json(),
172
+ ),
173
+ )
174
+ )
175
+ if _response.status_code == 401:
176
+ raise UnauthorizedError(
177
+ typing.cast(
178
+ typing.Optional[typing.Any],
179
+ parse_obj_as(
180
+ type_=typing.Optional[typing.Any], # type: ignore
181
+ object_=_response.json(),
182
+ ),
183
+ )
184
+ )
185
+ _response_json = _response.json()
186
+ except JSONDecodeError:
187
+ raise ApiError(status_code=_response.status_code, body=_response.text)
188
+ raise ApiError(status_code=_response.status_code, body=_response_json)
189
+
190
+ def crawl_website(
191
+ self,
192
+ *,
193
+ websites: typing.Sequence[WebsiteCrawlRequestWebsitesItem],
194
+ request_options: typing.Optional[RequestOptions] = None,
195
+ ) -> IngestResponse:
196
+ """
197
+ Upload the content of a publicly accessible website for ingestion into a GroundX bucket. This is done by following links within a specified URL, recursively, up to a specified depth or number of pages.
198
+
199
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
200
+
201
+ Parameters
202
+ ----------
203
+ websites : typing.Sequence[WebsiteCrawlRequestWebsitesItem]
204
+
205
+ request_options : typing.Optional[RequestOptions]
206
+ Request-specific configuration.
207
+
208
+ Returns
209
+ -------
210
+ IngestResponse
211
+ Website successfully queued
212
+
213
+ Examples
214
+ --------
215
+ from groundx import GroundX
216
+ from groundx.documents import WebsiteCrawlRequestWebsitesItem
217
+
218
+ client = GroundX(
219
+ api_key="YOUR_API_KEY",
220
+ )
221
+ client.documents.crawl_website(
222
+ websites=[
223
+ WebsiteCrawlRequestWebsitesItem(
224
+ bucket_id=123,
225
+ source_url="https://my.website.com",
226
+ )
227
+ ],
228
+ )
229
+ """
230
+ _response = self._client_wrapper.httpx_client.request(
231
+ "v1/ingest/documents/website",
232
+ method="POST",
233
+ json={
234
+ "websites": convert_and_respect_annotation_metadata(
235
+ object_=websites, annotation=typing.Sequence[WebsiteCrawlRequestWebsitesItem], direction="write"
236
+ ),
237
+ },
238
+ headers={
239
+ "content-type": "application/json",
240
+ },
241
+ request_options=request_options,
242
+ omit=OMIT,
243
+ )
244
+ try:
245
+ if 200 <= _response.status_code < 300:
246
+ return typing.cast(
247
+ IngestResponse,
248
+ parse_obj_as(
249
+ type_=IngestResponse, # type: ignore
250
+ object_=_response.json(),
251
+ ),
252
+ )
253
+ if _response.status_code == 400:
254
+ raise BadRequestError(
255
+ typing.cast(
256
+ typing.Optional[typing.Any],
257
+ parse_obj_as(
258
+ type_=typing.Optional[typing.Any], # type: ignore
259
+ object_=_response.json(),
260
+ ),
261
+ )
262
+ )
263
+ if _response.status_code == 401:
264
+ raise UnauthorizedError(
265
+ typing.cast(
266
+ typing.Optional[typing.Any],
267
+ parse_obj_as(
268
+ type_=typing.Optional[typing.Any], # type: ignore
269
+ object_=_response.json(),
270
+ ),
271
+ )
272
+ )
273
+ _response_json = _response.json()
274
+ except JSONDecodeError:
275
+ raise ApiError(status_code=_response.status_code, body=_response.text)
276
+ raise ApiError(status_code=_response.status_code, body=_response_json)
277
+
278
+ def get_processing_status_by_id(
279
+ self, process_id: str, *, request_options: typing.Optional[RequestOptions] = None
280
+ ) -> ProcessStatusResponse:
281
+ """
282
+ Get the current status of an ingest, initiated with documents.ingest_remote, documents.ingest_local, or documents.crawl_website, by specifying the processId (the processId is included in the response of the documents.ingest functions).
283
+
284
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
285
+
286
+ Parameters
287
+ ----------
288
+ process_id : str
289
+ the processId for the ingest process being checked
290
+
291
+ request_options : typing.Optional[RequestOptions]
292
+ Request-specific configuration.
293
+
294
+ Returns
295
+ -------
296
+ ProcessStatusResponse
297
+ Look up success
298
+
299
+ Examples
300
+ --------
301
+ from groundx import GroundX
302
+
303
+ client = GroundX(
304
+ api_key="YOUR_API_KEY",
305
+ )
306
+ client.documents.get_processing_status_by_id(
307
+ process_id="processId",
308
+ )
309
+ """
310
+ _response = self._client_wrapper.httpx_client.request(
311
+ f"v1/ingest/{jsonable_encoder(process_id)}",
312
+ method="GET",
313
+ request_options=request_options,
314
+ )
315
+ try:
316
+ if 200 <= _response.status_code < 300:
317
+ return typing.cast(
318
+ ProcessStatusResponse,
319
+ parse_obj_as(
320
+ type_=ProcessStatusResponse, # type: ignore
321
+ object_=_response.json(),
322
+ ),
323
+ )
324
+ if _response.status_code == 400:
325
+ raise BadRequestError(
326
+ typing.cast(
327
+ typing.Optional[typing.Any],
328
+ parse_obj_as(
329
+ type_=typing.Optional[typing.Any], # type: ignore
330
+ object_=_response.json(),
331
+ ),
332
+ )
333
+ )
334
+ if _response.status_code == 401:
335
+ raise UnauthorizedError(
336
+ typing.cast(
337
+ typing.Optional[typing.Any],
338
+ parse_obj_as(
339
+ type_=typing.Optional[typing.Any], # type: ignore
340
+ object_=_response.json(),
341
+ ),
342
+ )
343
+ )
344
+ _response_json = _response.json()
345
+ except JSONDecodeError:
346
+ raise ApiError(status_code=_response.status_code, body=_response.text)
347
+ raise ApiError(status_code=_response.status_code, body=_response_json)
348
+
349
+ def lookup(
350
+ self,
351
+ id: int,
352
+ *,
353
+ n: typing.Optional[int] = None,
354
+ filter: typing.Optional[str] = None,
355
+ sort: typing.Optional[Sort] = None,
356
+ sort_order: typing.Optional[SortOrder] = None,
357
+ status: typing.Optional[ProcessingStatus] = None,
358
+ next_token: typing.Optional[str] = None,
359
+ request_options: typing.Optional[RequestOptions] = None,
360
+ ) -> DocumentLookupResponse:
361
+ """
362
+ lookup the document(s) associated with a processId, bucketId, groupId, or projectId.
363
+
364
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
365
+
366
+ Parameters
367
+ ----------
368
+ id : int
369
+ a processId, bucketId, groupId, or projectId
370
+
371
+ n : typing.Optional[int]
372
+ The maximum number of returned documents. Accepts 1-100 with a default of 20.
373
+
374
+ filter : typing.Optional[str]
375
+ Only documents with names that contain the filter string will be returned in the results.
376
+
377
+ sort : typing.Optional[Sort]
378
+ The document attribute that will be used to sort the results.
379
+
380
+ sort_order : typing.Optional[SortOrder]
381
+ The order in which to sort the results. A value for sort must also be set.
382
+
383
+ status : typing.Optional[ProcessingStatus]
384
+ A status filter on the get documents query. If this value is set, then only documents with this status will be returned in the results.
385
+
386
+ next_token : typing.Optional[str]
387
+ A token for pagination. If the number of documents for a given query is larger than n, the response will include a "nextToken" value. That token can be included in this field to retrieve the next batch of n documents.
388
+
389
+ request_options : typing.Optional[RequestOptions]
390
+ Request-specific configuration.
391
+
392
+ Returns
393
+ -------
394
+ DocumentLookupResponse
395
+ Look up success
396
+
397
+ Examples
398
+ --------
399
+ from groundx import GroundX
400
+
401
+ client = GroundX(
402
+ api_key="YOUR_API_KEY",
403
+ )
404
+ client.documents.lookup(
405
+ id=1,
406
+ )
407
+ """
408
+ _response = self._client_wrapper.httpx_client.request(
409
+ f"v1/ingest/documents/{jsonable_encoder(id)}",
410
+ method="GET",
411
+ params={
412
+ "n": n,
413
+ "filter": filter,
414
+ "sort": sort,
415
+ "sortOrder": sort_order,
416
+ "status": status,
417
+ "nextToken": next_token,
418
+ },
419
+ request_options=request_options,
420
+ )
421
+ try:
422
+ if 200 <= _response.status_code < 300:
423
+ return typing.cast(
424
+ DocumentLookupResponse,
425
+ parse_obj_as(
426
+ type_=DocumentLookupResponse, # type: ignore
427
+ object_=_response.json(),
428
+ ),
429
+ )
430
+ if _response.status_code == 400:
431
+ raise BadRequestError(
432
+ typing.cast(
433
+ typing.Optional[typing.Any],
434
+ parse_obj_as(
435
+ type_=typing.Optional[typing.Any], # type: ignore
436
+ object_=_response.json(),
437
+ ),
438
+ )
439
+ )
440
+ if _response.status_code == 401:
441
+ raise UnauthorizedError(
442
+ typing.cast(
443
+ typing.Optional[typing.Any],
444
+ parse_obj_as(
445
+ type_=typing.Optional[typing.Any], # type: ignore
446
+ object_=_response.json(),
447
+ ),
448
+ )
449
+ )
450
+ _response_json = _response.json()
451
+ except JSONDecodeError:
452
+ raise ApiError(status_code=_response.status_code, body=_response.text)
453
+ raise ApiError(status_code=_response.status_code, body=_response_json)
454
+
455
+ def list(
456
+ self,
457
+ *,
458
+ n: typing.Optional[int] = None,
459
+ filter: typing.Optional[str] = None,
460
+ sort: typing.Optional[Sort] = None,
461
+ sort_order: typing.Optional[SortOrder] = None,
462
+ status: typing.Optional[ProcessingStatus] = None,
463
+ next_token: typing.Optional[str] = None,
464
+ request_options: typing.Optional[RequestOptions] = None,
465
+ ) -> DocumentListResponse:
466
+ """
467
+ lookup all documents across all resources which are currently on GroundX
468
+
469
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
470
+
471
+ Parameters
472
+ ----------
473
+ n : typing.Optional[int]
474
+ The maximum number of returned documents. Accepts 1-100 with a default of 20.
475
+
476
+ filter : typing.Optional[str]
477
+ Only documents with names that contain the filter string will be returned in the results.
478
+
479
+ sort : typing.Optional[Sort]
480
+ The document attribute that will be used to sort the results.
481
+
482
+ sort_order : typing.Optional[SortOrder]
483
+ The order in which to sort the results. A value for sort must also be set.
484
+
485
+ status : typing.Optional[ProcessingStatus]
486
+ A status filter on the get documents query. If this value is set, then only documents with this status will be returned in the results.
487
+
488
+ next_token : typing.Optional[str]
489
+ A token for pagination. If the number of documents for a given query is larger than n, the response will include a "nextToken" value. That token can be included in this field to retrieve the next batch of n documents.
490
+
491
+ request_options : typing.Optional[RequestOptions]
492
+ Request-specific configuration.
493
+
494
+ Returns
495
+ -------
496
+ DocumentListResponse
497
+ Look up success
498
+
499
+ Examples
500
+ --------
501
+ from groundx import GroundX
502
+
503
+ client = GroundX(
504
+ api_key="YOUR_API_KEY",
505
+ )
506
+ client.documents.list()
507
+ """
508
+ _response = self._client_wrapper.httpx_client.request(
509
+ "v1/ingest/documents",
510
+ method="GET",
511
+ params={
512
+ "n": n,
513
+ "filter": filter,
514
+ "sort": sort,
515
+ "sortOrder": sort_order,
516
+ "status": status,
517
+ "nextToken": next_token,
518
+ },
519
+ request_options=request_options,
520
+ )
521
+ try:
522
+ if 200 <= _response.status_code < 300:
523
+ return typing.cast(
524
+ DocumentListResponse,
525
+ parse_obj_as(
526
+ type_=DocumentListResponse, # type: ignore
527
+ object_=_response.json(),
528
+ ),
529
+ )
530
+ _response_json = _response.json()
531
+ except JSONDecodeError:
532
+ raise ApiError(status_code=_response.status_code, body=_response.text)
533
+ raise ApiError(status_code=_response.status_code, body=_response_json)
534
+
535
+ def delete(
536
+ self,
537
+ *,
538
+ document_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
539
+ request_options: typing.Optional[RequestOptions] = None,
540
+ ) -> IngestResponse:
541
+ """
542
+ Delete multiple documents hosted on GroundX
543
+
544
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
545
+
546
+ Parameters
547
+ ----------
548
+ document_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
549
+ A list of documentIds which correspond to documents ingested by GroundX
550
+
551
+ request_options : typing.Optional[RequestOptions]
552
+ Request-specific configuration.
553
+
554
+ Returns
555
+ -------
556
+ IngestResponse
557
+ Documents are queued to be deleted
558
+
559
+ Examples
560
+ --------
561
+ from groundx import GroundX
562
+
563
+ client = GroundX(
564
+ api_key="YOUR_API_KEY",
565
+ )
566
+ client.documents.delete()
567
+ """
568
+ _response = self._client_wrapper.httpx_client.request(
569
+ "v1/ingest/documents",
570
+ method="DELETE",
571
+ params={
572
+ "documentIds": document_ids,
573
+ },
574
+ request_options=request_options,
575
+ )
576
+ try:
577
+ if 200 <= _response.status_code < 300:
578
+ return typing.cast(
579
+ IngestResponse,
580
+ parse_obj_as(
581
+ type_=IngestResponse, # type: ignore
582
+ object_=_response.json(),
583
+ ),
584
+ )
585
+ if _response.status_code == 400:
586
+ raise BadRequestError(
587
+ typing.cast(
588
+ typing.Optional[typing.Any],
589
+ parse_obj_as(
590
+ type_=typing.Optional[typing.Any], # type: ignore
591
+ object_=_response.json(),
592
+ ),
593
+ )
594
+ )
595
+ if _response.status_code == 401:
596
+ raise UnauthorizedError(
597
+ typing.cast(
598
+ typing.Optional[typing.Any],
599
+ parse_obj_as(
600
+ type_=typing.Optional[typing.Any], # type: ignore
601
+ object_=_response.json(),
602
+ ),
603
+ )
604
+ )
605
+ _response_json = _response.json()
606
+ except JSONDecodeError:
607
+ raise ApiError(status_code=_response.status_code, body=_response.text)
608
+ raise ApiError(status_code=_response.status_code, body=_response_json)
609
+
610
+ def get(self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DocumentResponse:
611
+ """
612
+ Look up an existing document by documentId.
613
+
614
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
615
+
616
+ Parameters
617
+ ----------
618
+ document_id : str
619
+ The documentId of the document for which GroundX information will be provided.
620
+
621
+ request_options : typing.Optional[RequestOptions]
622
+ Request-specific configuration.
623
+
624
+ Returns
625
+ -------
626
+ DocumentResponse
627
+ Look up success
628
+
629
+ Examples
630
+ --------
631
+ from groundx import GroundX
632
+
633
+ client = GroundX(
634
+ api_key="YOUR_API_KEY",
635
+ )
636
+ client.documents.get(
637
+ document_id="documentId",
638
+ )
639
+ """
640
+ _response = self._client_wrapper.httpx_client.request(
641
+ f"v1/ingest/document/{jsonable_encoder(document_id)}",
642
+ method="GET",
643
+ request_options=request_options,
644
+ )
645
+ try:
646
+ if 200 <= _response.status_code < 300:
647
+ return typing.cast(
648
+ DocumentResponse,
649
+ parse_obj_as(
650
+ type_=DocumentResponse, # type: ignore
651
+ object_=_response.json(),
652
+ ),
653
+ )
654
+ if _response.status_code == 400:
655
+ raise BadRequestError(
656
+ typing.cast(
657
+ typing.Optional[typing.Any],
658
+ parse_obj_as(
659
+ type_=typing.Optional[typing.Any], # type: ignore
660
+ object_=_response.json(),
661
+ ),
662
+ )
663
+ )
664
+ if _response.status_code == 401:
665
+ raise UnauthorizedError(
666
+ typing.cast(
667
+ typing.Optional[typing.Any],
668
+ parse_obj_as(
669
+ type_=typing.Optional[typing.Any], # type: ignore
670
+ object_=_response.json(),
671
+ ),
672
+ )
673
+ )
674
+ _response_json = _response.json()
675
+ except JSONDecodeError:
676
+ raise ApiError(status_code=_response.status_code, body=_response.text)
677
+ raise ApiError(status_code=_response.status_code, body=_response_json)
678
+
679
+ def delete_by_id(
680
+ self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None
681
+ ) -> IngestResponse:
682
+ """
683
+ Delete a single document hosted on GroundX
684
+
685
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
686
+
687
+ Parameters
688
+ ----------
689
+ document_id : str
690
+ A documentId which correspond to a document ingested by GroundX
691
+
692
+ request_options : typing.Optional[RequestOptions]
693
+ Request-specific configuration.
694
+
695
+ Returns
696
+ -------
697
+ IngestResponse
698
+ Document successfully deleted
699
+
700
+ Examples
701
+ --------
702
+ from groundx import GroundX
703
+
704
+ client = GroundX(
705
+ api_key="YOUR_API_KEY",
706
+ )
707
+ client.documents.delete_by_id(
708
+ document_id="documentId",
709
+ )
710
+ """
711
+ _response = self._client_wrapper.httpx_client.request(
712
+ f"v1/ingest/document/{jsonable_encoder(document_id)}",
713
+ method="DELETE",
714
+ request_options=request_options,
715
+ )
716
+ try:
717
+ if 200 <= _response.status_code < 300:
718
+ return typing.cast(
719
+ IngestResponse,
720
+ parse_obj_as(
721
+ type_=IngestResponse, # type: ignore
722
+ object_=_response.json(),
723
+ ),
724
+ )
725
+ if _response.status_code == 400:
726
+ raise BadRequestError(
727
+ typing.cast(
728
+ typing.Optional[typing.Any],
729
+ parse_obj_as(
730
+ type_=typing.Optional[typing.Any], # type: ignore
731
+ object_=_response.json(),
732
+ ),
733
+ )
734
+ )
735
+ if _response.status_code == 401:
736
+ raise UnauthorizedError(
737
+ typing.cast(
738
+ typing.Optional[typing.Any],
739
+ parse_obj_as(
740
+ type_=typing.Optional[typing.Any], # type: ignore
741
+ object_=_response.json(),
742
+ ),
743
+ )
744
+ )
745
+ _response_json = _response.json()
746
+ except JSONDecodeError:
747
+ raise ApiError(status_code=_response.status_code, body=_response.text)
748
+ raise ApiError(status_code=_response.status_code, body=_response_json)
749
+
750
+
751
+ class AsyncDocumentsClient:
752
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
753
+ self._client_wrapper = client_wrapper
754
+
755
+ async def ingest_remote(
756
+ self,
757
+ *,
758
+ documents: typing.Sequence[DocumentRemoteIngestRequestDocumentsItem],
759
+ request_options: typing.Optional[RequestOptions] = None,
760
+ ) -> IngestResponse:
761
+ """
762
+ Ingest documents hosted on public URLs to a GroundX bucket.
763
+
764
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
765
+
766
+ Parameters
767
+ ----------
768
+ documents : typing.Sequence[DocumentRemoteIngestRequestDocumentsItem]
769
+
770
+ request_options : typing.Optional[RequestOptions]
771
+ Request-specific configuration.
772
+
773
+ Returns
774
+ -------
775
+ IngestResponse
776
+ Documents successfully uploaded
777
+
778
+ Examples
779
+ --------
780
+ import asyncio
781
+
782
+ from groundx import AsyncGroundX
783
+ from groundx.documents import DocumentRemoteIngestRequestDocumentsItem
784
+
785
+ client = AsyncGroundX(
786
+ api_key="YOUR_API_KEY",
787
+ )
788
+
789
+
790
+ async def main() -> None:
791
+ await client.documents.ingest_remote(
792
+ documents=[
793
+ DocumentRemoteIngestRequestDocumentsItem(
794
+ bucket_id=1234,
795
+ source_url="https://my.source.url.com/file.txt",
796
+ )
797
+ ],
798
+ )
799
+
800
+
801
+ asyncio.run(main())
802
+ """
803
+ _response = await self._client_wrapper.httpx_client.request(
804
+ "v1/ingest/documents/remote",
805
+ method="POST",
806
+ json={
807
+ "documents": convert_and_respect_annotation_metadata(
808
+ object_=documents,
809
+ annotation=typing.Sequence[DocumentRemoteIngestRequestDocumentsItem],
810
+ direction="write",
811
+ ),
812
+ },
813
+ headers={
814
+ "content-type": "application/json",
815
+ },
816
+ request_options=request_options,
817
+ omit=OMIT,
818
+ )
819
+ try:
820
+ if 200 <= _response.status_code < 300:
821
+ return typing.cast(
822
+ IngestResponse,
823
+ parse_obj_as(
824
+ type_=IngestResponse, # type: ignore
825
+ object_=_response.json(),
826
+ ),
827
+ )
828
+ if _response.status_code == 400:
829
+ raise BadRequestError(
830
+ typing.cast(
831
+ typing.Optional[typing.Any],
832
+ parse_obj_as(
833
+ type_=typing.Optional[typing.Any], # type: ignore
834
+ object_=_response.json(),
835
+ ),
836
+ )
837
+ )
838
+ if _response.status_code == 401:
839
+ raise UnauthorizedError(
840
+ typing.cast(
841
+ typing.Optional[typing.Any],
842
+ parse_obj_as(
843
+ type_=typing.Optional[typing.Any], # type: ignore
844
+ object_=_response.json(),
845
+ ),
846
+ )
847
+ )
848
+ _response_json = _response.json()
849
+ except JSONDecodeError:
850
+ raise ApiError(status_code=_response.status_code, body=_response.text)
851
+ raise ApiError(status_code=_response.status_code, body=_response_json)
852
+
853
+ async def ingest_local(self, *, request_options: typing.Optional[RequestOptions] = None) -> IngestResponse:
854
+ """
855
+ Upload documents hosted on a local file system for ingestion into a GroundX bucket.
856
+
857
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
858
+
859
+ Parameters
860
+ ----------
861
+ request_options : typing.Optional[RequestOptions]
862
+ Request-specific configuration.
863
+
864
+ Returns
865
+ -------
866
+ IngestResponse
867
+ Documents successfully uploaded
868
+
869
+ Examples
870
+ --------
871
+ import asyncio
872
+
873
+ from groundx import AsyncGroundX
874
+
875
+ client = AsyncGroundX(
876
+ api_key="YOUR_API_KEY",
877
+ )
878
+
879
+
880
+ async def main() -> None:
881
+ await client.documents.ingest_local()
882
+
883
+
884
+ asyncio.run(main())
885
+ """
886
+ _response = await self._client_wrapper.httpx_client.request(
887
+ "v1/ingest/documents/local",
888
+ method="POST",
889
+ data={},
890
+ files={},
891
+ request_options=request_options,
892
+ omit=OMIT,
893
+ )
894
+ try:
895
+ if 200 <= _response.status_code < 300:
896
+ return typing.cast(
897
+ IngestResponse,
898
+ parse_obj_as(
899
+ type_=IngestResponse, # type: ignore
900
+ object_=_response.json(),
901
+ ),
902
+ )
903
+ if _response.status_code == 400:
904
+ raise BadRequestError(
905
+ typing.cast(
906
+ typing.Optional[typing.Any],
907
+ parse_obj_as(
908
+ type_=typing.Optional[typing.Any], # type: ignore
909
+ object_=_response.json(),
910
+ ),
911
+ )
912
+ )
913
+ if _response.status_code == 401:
914
+ raise UnauthorizedError(
915
+ typing.cast(
916
+ typing.Optional[typing.Any],
917
+ parse_obj_as(
918
+ type_=typing.Optional[typing.Any], # type: ignore
919
+ object_=_response.json(),
920
+ ),
921
+ )
922
+ )
923
+ _response_json = _response.json()
924
+ except JSONDecodeError:
925
+ raise ApiError(status_code=_response.status_code, body=_response.text)
926
+ raise ApiError(status_code=_response.status_code, body=_response_json)
927
+
928
+ async def crawl_website(
929
+ self,
930
+ *,
931
+ websites: typing.Sequence[WebsiteCrawlRequestWebsitesItem],
932
+ request_options: typing.Optional[RequestOptions] = None,
933
+ ) -> IngestResponse:
934
+ """
935
+ Upload the content of a publicly accessible website for ingestion into a GroundX bucket. This is done by following links within a specified URL, recursively, up to a specified depth or number of pages.
936
+
937
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
938
+
939
+ Parameters
940
+ ----------
941
+ websites : typing.Sequence[WebsiteCrawlRequestWebsitesItem]
942
+
943
+ request_options : typing.Optional[RequestOptions]
944
+ Request-specific configuration.
945
+
946
+ Returns
947
+ -------
948
+ IngestResponse
949
+ Website successfully queued
950
+
951
+ Examples
952
+ --------
953
+ import asyncio
954
+
955
+ from groundx import AsyncGroundX
956
+ from groundx.documents import WebsiteCrawlRequestWebsitesItem
957
+
958
+ client = AsyncGroundX(
959
+ api_key="YOUR_API_KEY",
960
+ )
961
+
962
+
963
+ async def main() -> None:
964
+ await client.documents.crawl_website(
965
+ websites=[
966
+ WebsiteCrawlRequestWebsitesItem(
967
+ bucket_id=123,
968
+ source_url="https://my.website.com",
969
+ )
970
+ ],
971
+ )
972
+
973
+
974
+ asyncio.run(main())
975
+ """
976
+ _response = await self._client_wrapper.httpx_client.request(
977
+ "v1/ingest/documents/website",
978
+ method="POST",
979
+ json={
980
+ "websites": convert_and_respect_annotation_metadata(
981
+ object_=websites, annotation=typing.Sequence[WebsiteCrawlRequestWebsitesItem], direction="write"
982
+ ),
983
+ },
984
+ headers={
985
+ "content-type": "application/json",
986
+ },
987
+ request_options=request_options,
988
+ omit=OMIT,
989
+ )
990
+ try:
991
+ if 200 <= _response.status_code < 300:
992
+ return typing.cast(
993
+ IngestResponse,
994
+ parse_obj_as(
995
+ type_=IngestResponse, # type: ignore
996
+ object_=_response.json(),
997
+ ),
998
+ )
999
+ if _response.status_code == 400:
1000
+ raise BadRequestError(
1001
+ typing.cast(
1002
+ typing.Optional[typing.Any],
1003
+ parse_obj_as(
1004
+ type_=typing.Optional[typing.Any], # type: ignore
1005
+ object_=_response.json(),
1006
+ ),
1007
+ )
1008
+ )
1009
+ if _response.status_code == 401:
1010
+ raise UnauthorizedError(
1011
+ typing.cast(
1012
+ typing.Optional[typing.Any],
1013
+ parse_obj_as(
1014
+ type_=typing.Optional[typing.Any], # type: ignore
1015
+ object_=_response.json(),
1016
+ ),
1017
+ )
1018
+ )
1019
+ _response_json = _response.json()
1020
+ except JSONDecodeError:
1021
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1022
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1023
+
1024
+ async def get_processing_status_by_id(
1025
+ self, process_id: str, *, request_options: typing.Optional[RequestOptions] = None
1026
+ ) -> ProcessStatusResponse:
1027
+ """
1028
+ Get the current status of an ingest, initiated with documents.ingest_remote, documents.ingest_local, or documents.crawl_website, by specifying the processId (the processId is included in the response of the documents.ingest functions).
1029
+
1030
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
1031
+
1032
+ Parameters
1033
+ ----------
1034
+ process_id : str
1035
+ the processId for the ingest process being checked
1036
+
1037
+ request_options : typing.Optional[RequestOptions]
1038
+ Request-specific configuration.
1039
+
1040
+ Returns
1041
+ -------
1042
+ ProcessStatusResponse
1043
+ Look up success
1044
+
1045
+ Examples
1046
+ --------
1047
+ import asyncio
1048
+
1049
+ from groundx import AsyncGroundX
1050
+
1051
+ client = AsyncGroundX(
1052
+ api_key="YOUR_API_KEY",
1053
+ )
1054
+
1055
+
1056
+ async def main() -> None:
1057
+ await client.documents.get_processing_status_by_id(
1058
+ process_id="processId",
1059
+ )
1060
+
1061
+
1062
+ asyncio.run(main())
1063
+ """
1064
+ _response = await self._client_wrapper.httpx_client.request(
1065
+ f"v1/ingest/{jsonable_encoder(process_id)}",
1066
+ method="GET",
1067
+ request_options=request_options,
1068
+ )
1069
+ try:
1070
+ if 200 <= _response.status_code < 300:
1071
+ return typing.cast(
1072
+ ProcessStatusResponse,
1073
+ parse_obj_as(
1074
+ type_=ProcessStatusResponse, # type: ignore
1075
+ object_=_response.json(),
1076
+ ),
1077
+ )
1078
+ if _response.status_code == 400:
1079
+ raise BadRequestError(
1080
+ typing.cast(
1081
+ typing.Optional[typing.Any],
1082
+ parse_obj_as(
1083
+ type_=typing.Optional[typing.Any], # type: ignore
1084
+ object_=_response.json(),
1085
+ ),
1086
+ )
1087
+ )
1088
+ if _response.status_code == 401:
1089
+ raise UnauthorizedError(
1090
+ typing.cast(
1091
+ typing.Optional[typing.Any],
1092
+ parse_obj_as(
1093
+ type_=typing.Optional[typing.Any], # type: ignore
1094
+ object_=_response.json(),
1095
+ ),
1096
+ )
1097
+ )
1098
+ _response_json = _response.json()
1099
+ except JSONDecodeError:
1100
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1101
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1102
+
1103
+ async def lookup(
1104
+ self,
1105
+ id: int,
1106
+ *,
1107
+ n: typing.Optional[int] = None,
1108
+ filter: typing.Optional[str] = None,
1109
+ sort: typing.Optional[Sort] = None,
1110
+ sort_order: typing.Optional[SortOrder] = None,
1111
+ status: typing.Optional[ProcessingStatus] = None,
1112
+ next_token: typing.Optional[str] = None,
1113
+ request_options: typing.Optional[RequestOptions] = None,
1114
+ ) -> DocumentLookupResponse:
1115
+ """
1116
+ lookup the document(s) associated with a processId, bucketId, groupId, or projectId.
1117
+
1118
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
1119
+
1120
+ Parameters
1121
+ ----------
1122
+ id : int
1123
+ a processId, bucketId, groupId, or projectId
1124
+
1125
+ n : typing.Optional[int]
1126
+ The maximum number of returned documents. Accepts 1-100 with a default of 20.
1127
+
1128
+ filter : typing.Optional[str]
1129
+ Only documents with names that contain the filter string will be returned in the results.
1130
+
1131
+ sort : typing.Optional[Sort]
1132
+ The document attribute that will be used to sort the results.
1133
+
1134
+ sort_order : typing.Optional[SortOrder]
1135
+ The order in which to sort the results. A value for sort must also be set.
1136
+
1137
+ status : typing.Optional[ProcessingStatus]
1138
+ A status filter on the get documents query. If this value is set, then only documents with this status will be returned in the results.
1139
+
1140
+ next_token : typing.Optional[str]
1141
+ A token for pagination. If the number of documents for a given query is larger than n, the response will include a "nextToken" value. That token can be included in this field to retrieve the next batch of n documents.
1142
+
1143
+ request_options : typing.Optional[RequestOptions]
1144
+ Request-specific configuration.
1145
+
1146
+ Returns
1147
+ -------
1148
+ DocumentLookupResponse
1149
+ Look up success
1150
+
1151
+ Examples
1152
+ --------
1153
+ import asyncio
1154
+
1155
+ from groundx import AsyncGroundX
1156
+
1157
+ client = AsyncGroundX(
1158
+ api_key="YOUR_API_KEY",
1159
+ )
1160
+
1161
+
1162
+ async def main() -> None:
1163
+ await client.documents.lookup(
1164
+ id=1,
1165
+ )
1166
+
1167
+
1168
+ asyncio.run(main())
1169
+ """
1170
+ _response = await self._client_wrapper.httpx_client.request(
1171
+ f"v1/ingest/documents/{jsonable_encoder(id)}",
1172
+ method="GET",
1173
+ params={
1174
+ "n": n,
1175
+ "filter": filter,
1176
+ "sort": sort,
1177
+ "sortOrder": sort_order,
1178
+ "status": status,
1179
+ "nextToken": next_token,
1180
+ },
1181
+ request_options=request_options,
1182
+ )
1183
+ try:
1184
+ if 200 <= _response.status_code < 300:
1185
+ return typing.cast(
1186
+ DocumentLookupResponse,
1187
+ parse_obj_as(
1188
+ type_=DocumentLookupResponse, # type: ignore
1189
+ object_=_response.json(),
1190
+ ),
1191
+ )
1192
+ if _response.status_code == 400:
1193
+ raise BadRequestError(
1194
+ typing.cast(
1195
+ typing.Optional[typing.Any],
1196
+ parse_obj_as(
1197
+ type_=typing.Optional[typing.Any], # type: ignore
1198
+ object_=_response.json(),
1199
+ ),
1200
+ )
1201
+ )
1202
+ if _response.status_code == 401:
1203
+ raise UnauthorizedError(
1204
+ typing.cast(
1205
+ typing.Optional[typing.Any],
1206
+ parse_obj_as(
1207
+ type_=typing.Optional[typing.Any], # type: ignore
1208
+ object_=_response.json(),
1209
+ ),
1210
+ )
1211
+ )
1212
+ _response_json = _response.json()
1213
+ except JSONDecodeError:
1214
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1215
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1216
+
1217
+ async def list(
1218
+ self,
1219
+ *,
1220
+ n: typing.Optional[int] = None,
1221
+ filter: typing.Optional[str] = None,
1222
+ sort: typing.Optional[Sort] = None,
1223
+ sort_order: typing.Optional[SortOrder] = None,
1224
+ status: typing.Optional[ProcessingStatus] = None,
1225
+ next_token: typing.Optional[str] = None,
1226
+ request_options: typing.Optional[RequestOptions] = None,
1227
+ ) -> DocumentListResponse:
1228
+ """
1229
+ lookup all documents across all resources which are currently on GroundX
1230
+
1231
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
1232
+
1233
+ Parameters
1234
+ ----------
1235
+ n : typing.Optional[int]
1236
+ The maximum number of returned documents. Accepts 1-100 with a default of 20.
1237
+
1238
+ filter : typing.Optional[str]
1239
+ Only documents with names that contain the filter string will be returned in the results.
1240
+
1241
+ sort : typing.Optional[Sort]
1242
+ The document attribute that will be used to sort the results.
1243
+
1244
+ sort_order : typing.Optional[SortOrder]
1245
+ The order in which to sort the results. A value for sort must also be set.
1246
+
1247
+ status : typing.Optional[ProcessingStatus]
1248
+ A status filter on the get documents query. If this value is set, then only documents with this status will be returned in the results.
1249
+
1250
+ next_token : typing.Optional[str]
1251
+ A token for pagination. If the number of documents for a given query is larger than n, the response will include a "nextToken" value. That token can be included in this field to retrieve the next batch of n documents.
1252
+
1253
+ request_options : typing.Optional[RequestOptions]
1254
+ Request-specific configuration.
1255
+
1256
+ Returns
1257
+ -------
1258
+ DocumentListResponse
1259
+ Look up success
1260
+
1261
+ Examples
1262
+ --------
1263
+ import asyncio
1264
+
1265
+ from groundx import AsyncGroundX
1266
+
1267
+ client = AsyncGroundX(
1268
+ api_key="YOUR_API_KEY",
1269
+ )
1270
+
1271
+
1272
+ async def main() -> None:
1273
+ await client.documents.list()
1274
+
1275
+
1276
+ asyncio.run(main())
1277
+ """
1278
+ _response = await self._client_wrapper.httpx_client.request(
1279
+ "v1/ingest/documents",
1280
+ method="GET",
1281
+ params={
1282
+ "n": n,
1283
+ "filter": filter,
1284
+ "sort": sort,
1285
+ "sortOrder": sort_order,
1286
+ "status": status,
1287
+ "nextToken": next_token,
1288
+ },
1289
+ request_options=request_options,
1290
+ )
1291
+ try:
1292
+ if 200 <= _response.status_code < 300:
1293
+ return typing.cast(
1294
+ DocumentListResponse,
1295
+ parse_obj_as(
1296
+ type_=DocumentListResponse, # type: ignore
1297
+ object_=_response.json(),
1298
+ ),
1299
+ )
1300
+ _response_json = _response.json()
1301
+ except JSONDecodeError:
1302
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1303
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1304
+
1305
+ async def delete(
1306
+ self,
1307
+ *,
1308
+ document_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
1309
+ request_options: typing.Optional[RequestOptions] = None,
1310
+ ) -> IngestResponse:
1311
+ """
1312
+ Delete multiple documents hosted on GroundX
1313
+
1314
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
1315
+
1316
+ Parameters
1317
+ ----------
1318
+ document_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
1319
+ A list of documentIds which correspond to documents ingested by GroundX
1320
+
1321
+ request_options : typing.Optional[RequestOptions]
1322
+ Request-specific configuration.
1323
+
1324
+ Returns
1325
+ -------
1326
+ IngestResponse
1327
+ Documents are queued to be deleted
1328
+
1329
+ Examples
1330
+ --------
1331
+ import asyncio
1332
+
1333
+ from groundx import AsyncGroundX
1334
+
1335
+ client = AsyncGroundX(
1336
+ api_key="YOUR_API_KEY",
1337
+ )
1338
+
1339
+
1340
+ async def main() -> None:
1341
+ await client.documents.delete()
1342
+
1343
+
1344
+ asyncio.run(main())
1345
+ """
1346
+ _response = await self._client_wrapper.httpx_client.request(
1347
+ "v1/ingest/documents",
1348
+ method="DELETE",
1349
+ params={
1350
+ "documentIds": document_ids,
1351
+ },
1352
+ request_options=request_options,
1353
+ )
1354
+ try:
1355
+ if 200 <= _response.status_code < 300:
1356
+ return typing.cast(
1357
+ IngestResponse,
1358
+ parse_obj_as(
1359
+ type_=IngestResponse, # type: ignore
1360
+ object_=_response.json(),
1361
+ ),
1362
+ )
1363
+ if _response.status_code == 400:
1364
+ raise BadRequestError(
1365
+ typing.cast(
1366
+ typing.Optional[typing.Any],
1367
+ parse_obj_as(
1368
+ type_=typing.Optional[typing.Any], # type: ignore
1369
+ object_=_response.json(),
1370
+ ),
1371
+ )
1372
+ )
1373
+ if _response.status_code == 401:
1374
+ raise UnauthorizedError(
1375
+ typing.cast(
1376
+ typing.Optional[typing.Any],
1377
+ parse_obj_as(
1378
+ type_=typing.Optional[typing.Any], # type: ignore
1379
+ object_=_response.json(),
1380
+ ),
1381
+ )
1382
+ )
1383
+ _response_json = _response.json()
1384
+ except JSONDecodeError:
1385
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1386
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1387
+
1388
+ async def get(
1389
+ self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None
1390
+ ) -> DocumentResponse:
1391
+ """
1392
+ Look up an existing document by documentId.
1393
+
1394
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
1395
+
1396
+ Parameters
1397
+ ----------
1398
+ document_id : str
1399
+ The documentId of the document for which GroundX information will be provided.
1400
+
1401
+ request_options : typing.Optional[RequestOptions]
1402
+ Request-specific configuration.
1403
+
1404
+ Returns
1405
+ -------
1406
+ DocumentResponse
1407
+ Look up success
1408
+
1409
+ Examples
1410
+ --------
1411
+ import asyncio
1412
+
1413
+ from groundx import AsyncGroundX
1414
+
1415
+ client = AsyncGroundX(
1416
+ api_key="YOUR_API_KEY",
1417
+ )
1418
+
1419
+
1420
+ async def main() -> None:
1421
+ await client.documents.get(
1422
+ document_id="documentId",
1423
+ )
1424
+
1425
+
1426
+ asyncio.run(main())
1427
+ """
1428
+ _response = await self._client_wrapper.httpx_client.request(
1429
+ f"v1/ingest/document/{jsonable_encoder(document_id)}",
1430
+ method="GET",
1431
+ request_options=request_options,
1432
+ )
1433
+ try:
1434
+ if 200 <= _response.status_code < 300:
1435
+ return typing.cast(
1436
+ DocumentResponse,
1437
+ parse_obj_as(
1438
+ type_=DocumentResponse, # type: ignore
1439
+ object_=_response.json(),
1440
+ ),
1441
+ )
1442
+ if _response.status_code == 400:
1443
+ raise BadRequestError(
1444
+ typing.cast(
1445
+ typing.Optional[typing.Any],
1446
+ parse_obj_as(
1447
+ type_=typing.Optional[typing.Any], # type: ignore
1448
+ object_=_response.json(),
1449
+ ),
1450
+ )
1451
+ )
1452
+ if _response.status_code == 401:
1453
+ raise UnauthorizedError(
1454
+ typing.cast(
1455
+ typing.Optional[typing.Any],
1456
+ parse_obj_as(
1457
+ type_=typing.Optional[typing.Any], # type: ignore
1458
+ object_=_response.json(),
1459
+ ),
1460
+ )
1461
+ )
1462
+ _response_json = _response.json()
1463
+ except JSONDecodeError:
1464
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1465
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1466
+
1467
+ async def delete_by_id(
1468
+ self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None
1469
+ ) -> IngestResponse:
1470
+ """
1471
+ Delete a single document hosted on GroundX
1472
+
1473
+ Interact with the "Request Body" below to explore the arguments of this function. Enter your GroundX API key to send a request directly from this web page. Select your language of choice to structure a code snippet based on your specified arguments.
1474
+
1475
+ Parameters
1476
+ ----------
1477
+ document_id : str
1478
+ A documentId which correspond to a document ingested by GroundX
1479
+
1480
+ request_options : typing.Optional[RequestOptions]
1481
+ Request-specific configuration.
1482
+
1483
+ Returns
1484
+ -------
1485
+ IngestResponse
1486
+ Document successfully deleted
1487
+
1488
+ Examples
1489
+ --------
1490
+ import asyncio
1491
+
1492
+ from groundx import AsyncGroundX
1493
+
1494
+ client = AsyncGroundX(
1495
+ api_key="YOUR_API_KEY",
1496
+ )
1497
+
1498
+
1499
+ async def main() -> None:
1500
+ await client.documents.delete_by_id(
1501
+ document_id="documentId",
1502
+ )
1503
+
1504
+
1505
+ asyncio.run(main())
1506
+ """
1507
+ _response = await self._client_wrapper.httpx_client.request(
1508
+ f"v1/ingest/document/{jsonable_encoder(document_id)}",
1509
+ method="DELETE",
1510
+ request_options=request_options,
1511
+ )
1512
+ try:
1513
+ if 200 <= _response.status_code < 300:
1514
+ return typing.cast(
1515
+ IngestResponse,
1516
+ parse_obj_as(
1517
+ type_=IngestResponse, # type: ignore
1518
+ object_=_response.json(),
1519
+ ),
1520
+ )
1521
+ if _response.status_code == 400:
1522
+ raise BadRequestError(
1523
+ typing.cast(
1524
+ typing.Optional[typing.Any],
1525
+ parse_obj_as(
1526
+ type_=typing.Optional[typing.Any], # type: ignore
1527
+ object_=_response.json(),
1528
+ ),
1529
+ )
1530
+ )
1531
+ if _response.status_code == 401:
1532
+ raise UnauthorizedError(
1533
+ typing.cast(
1534
+ typing.Optional[typing.Any],
1535
+ parse_obj_as(
1536
+ type_=typing.Optional[typing.Any], # type: ignore
1537
+ object_=_response.json(),
1538
+ ),
1539
+ )
1540
+ )
1541
+ _response_json = _response.json()
1542
+ except JSONDecodeError:
1543
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1544
+ raise ApiError(status_code=_response.status_code, body=_response_json)