groundx 2.0.17__py3-none-any.whl → 2.0.18__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.
groundx/__init__.py CHANGED
@@ -22,6 +22,7 @@ from .types import (
22
22
  HealthResponseHealth,
23
23
  HealthService,
24
24
  HealthServiceStatus,
25
+ IngestDocument,
25
26
  IngestLocalDocument,
26
27
  IngestRemoteDocument,
27
28
  IngestResponse,
@@ -77,6 +78,7 @@ __all__ = [
77
78
  "HealthResponseHealth",
78
79
  "HealthService",
79
80
  "HealthServiceStatus",
81
+ "IngestDocument",
80
82
  "IngestLocalDocument",
81
83
  "IngestRemoteDocument",
82
84
  "IngestResponse",
@@ -16,7 +16,7 @@ class BaseClientWrapper:
16
16
  headers: typing.Dict[str, str] = {
17
17
  "X-Fern-Language": "Python",
18
18
  "X-Fern-SDK-Name": "groundx",
19
- "X-Fern-SDK-Version": "2.0.17",
19
+ "X-Fern-SDK-Version": "2.0.18",
20
20
  }
21
21
  headers["X-API-Key"] = self.api_key
22
22
  return headers
@@ -2,24 +2,25 @@
2
2
 
3
3
  import typing
4
4
  from ..core.client_wrapper import SyncClientWrapper
5
- from ..types.ingest_remote_document import IngestRemoteDocument
5
+ from ..types.sort import Sort
6
+ from ..types.sort_order import SortOrder
7
+ from ..types.processing_status import ProcessingStatus
6
8
  from ..core.request_options import RequestOptions
9
+ from ..types.document_list_response import DocumentListResponse
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from json.decoder import JSONDecodeError
12
+ from ..core.api_error import ApiError
13
+ from ..types.ingest_document import IngestDocument
7
14
  from ..types.ingest_response import IngestResponse
8
15
  from ..core.serialization import convert_and_respect_annotation_metadata
9
- from ..core.pydantic_utilities import parse_obj_as
10
16
  from ..errors.bad_request_error import BadRequestError
11
17
  from ..errors.unauthorized_error import UnauthorizedError
12
- from json.decoder import JSONDecodeError
13
- from ..core.api_error import ApiError
18
+ from ..types.ingest_remote_document import IngestRemoteDocument
14
19
  from ..types.ingest_local_document import IngestLocalDocument
15
20
  from ..types.crawl_website_source import CrawlWebsiteSource
16
21
  from ..types.process_status_response import ProcessStatusResponse
17
22
  from ..core.jsonable_encoder import jsonable_encoder
18
- from ..types.sort import Sort
19
- from ..types.sort_order import SortOrder
20
- from ..types.processing_status import ProcessingStatus
21
23
  from ..types.document_lookup_response import DocumentLookupResponse
22
- from ..types.document_list_response import DocumentListResponse
23
24
  from ..types.document_response import DocumentResponse
24
25
  from ..core.client_wrapper import AsyncClientWrapper
25
26
 
@@ -31,6 +32,248 @@ class DocumentsClient:
31
32
  def __init__(self, *, client_wrapper: SyncClientWrapper):
32
33
  self._client_wrapper = client_wrapper
33
34
 
35
+ def list(
36
+ self,
37
+ *,
38
+ n: typing.Optional[int] = None,
39
+ filter: typing.Optional[str] = None,
40
+ sort: typing.Optional[Sort] = None,
41
+ sort_order: typing.Optional[SortOrder] = None,
42
+ status: typing.Optional[ProcessingStatus] = None,
43
+ next_token: typing.Optional[str] = None,
44
+ request_options: typing.Optional[RequestOptions] = None,
45
+ ) -> DocumentListResponse:
46
+ """
47
+ lookup all documents across all resources which are currently on GroundX
48
+
49
+ 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.
50
+
51
+ Parameters
52
+ ----------
53
+ n : typing.Optional[int]
54
+ The maximum number of returned documents. Accepts 1-100 with a default of 20.
55
+
56
+ filter : typing.Optional[str]
57
+ Only documents with names that contain the filter string will be returned in the results.
58
+
59
+ sort : typing.Optional[Sort]
60
+ The document attribute that will be used to sort the results.
61
+
62
+ sort_order : typing.Optional[SortOrder]
63
+ The order in which to sort the results. A value for sort must also be set.
64
+
65
+ status : typing.Optional[ProcessingStatus]
66
+ 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.
67
+
68
+ next_token : typing.Optional[str]
69
+ 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.
70
+
71
+ request_options : typing.Optional[RequestOptions]
72
+ Request-specific configuration.
73
+
74
+ Returns
75
+ -------
76
+ DocumentListResponse
77
+ Look up success
78
+
79
+ Examples
80
+ --------
81
+ from groundx import GroundX
82
+
83
+ client = GroundX(
84
+ api_key="YOUR_API_KEY",
85
+ )
86
+ client.documents.list()
87
+ """
88
+ _response = self._client_wrapper.httpx_client.request(
89
+ "v1/ingest/documents",
90
+ method="GET",
91
+ params={
92
+ "n": n,
93
+ "filter": filter,
94
+ "sort": sort,
95
+ "sortOrder": sort_order,
96
+ "status": status,
97
+ "nextToken": next_token,
98
+ },
99
+ request_options=request_options,
100
+ )
101
+ try:
102
+ if 200 <= _response.status_code < 300:
103
+ return typing.cast(
104
+ DocumentListResponse,
105
+ parse_obj_as(
106
+ type_=DocumentListResponse, # type: ignore
107
+ object_=_response.json(),
108
+ ),
109
+ )
110
+ _response_json = _response.json()
111
+ except JSONDecodeError:
112
+ raise ApiError(status_code=_response.status_code, body=_response.text)
113
+ raise ApiError(status_code=_response.status_code, body=_response_json)
114
+
115
+ def document_ingest(
116
+ self, *, documents: typing.Sequence[IngestDocument], request_options: typing.Optional[RequestOptions] = None
117
+ ) -> IngestResponse:
118
+ """
119
+ Ingest documents hosted on public URLs or a local file system for ingestion into a GroundX bucket.
120
+
121
+ 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.
122
+
123
+ Parameters
124
+ ----------
125
+ documents : typing.Sequence[IngestDocument]
126
+
127
+ request_options : typing.Optional[RequestOptions]
128
+ Request-specific configuration.
129
+
130
+ Returns
131
+ -------
132
+ IngestResponse
133
+ Documents successfully uploaded
134
+
135
+ Examples
136
+ --------
137
+ from groundx import GroundX, IngestDocument
138
+
139
+ client = GroundX(
140
+ api_key="YOUR_API_KEY",
141
+ )
142
+ client.documents.document_ingest(
143
+ documents=[
144
+ IngestDocument(
145
+ bucket_id=1234,
146
+ file_name="my_file.txt",
147
+ file_path="https://my.source.url.com/file.txt",
148
+ file_type="txt",
149
+ search_data={"key": "value"},
150
+ )
151
+ ],
152
+ )
153
+ """
154
+ _response = self._client_wrapper.httpx_client.request(
155
+ "v1/ingest/documents",
156
+ method="POST",
157
+ json={
158
+ "documents": convert_and_respect_annotation_metadata(
159
+ object_=documents, annotation=typing.Sequence[IngestDocument], direction="write"
160
+ ),
161
+ },
162
+ headers={
163
+ "content-type": "application/json",
164
+ },
165
+ request_options=request_options,
166
+ omit=OMIT,
167
+ )
168
+ try:
169
+ if 200 <= _response.status_code < 300:
170
+ return typing.cast(
171
+ IngestResponse,
172
+ parse_obj_as(
173
+ type_=IngestResponse, # type: ignore
174
+ object_=_response.json(),
175
+ ),
176
+ )
177
+ if _response.status_code == 400:
178
+ raise BadRequestError(
179
+ typing.cast(
180
+ typing.Optional[typing.Any],
181
+ parse_obj_as(
182
+ type_=typing.Optional[typing.Any], # type: ignore
183
+ object_=_response.json(),
184
+ ),
185
+ )
186
+ )
187
+ if _response.status_code == 401:
188
+ raise UnauthorizedError(
189
+ typing.cast(
190
+ typing.Optional[typing.Any],
191
+ parse_obj_as(
192
+ type_=typing.Optional[typing.Any], # type: ignore
193
+ object_=_response.json(),
194
+ ),
195
+ )
196
+ )
197
+ _response_json = _response.json()
198
+ except JSONDecodeError:
199
+ raise ApiError(status_code=_response.status_code, body=_response.text)
200
+ raise ApiError(status_code=_response.status_code, body=_response_json)
201
+
202
+ def delete(
203
+ self,
204
+ *,
205
+ document_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
206
+ request_options: typing.Optional[RequestOptions] = None,
207
+ ) -> IngestResponse:
208
+ """
209
+ Delete multiple documents hosted on GroundX
210
+
211
+ 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.
212
+
213
+ Parameters
214
+ ----------
215
+ document_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
216
+ A list of documentIds which correspond to documents ingested by GroundX
217
+
218
+ request_options : typing.Optional[RequestOptions]
219
+ Request-specific configuration.
220
+
221
+ Returns
222
+ -------
223
+ IngestResponse
224
+ Documents are queued to be deleted
225
+
226
+ Examples
227
+ --------
228
+ from groundx import GroundX
229
+
230
+ client = GroundX(
231
+ api_key="YOUR_API_KEY",
232
+ )
233
+ client.documents.delete()
234
+ """
235
+ _response = self._client_wrapper.httpx_client.request(
236
+ "v1/ingest/documents",
237
+ method="DELETE",
238
+ params={
239
+ "documentIds": document_ids,
240
+ },
241
+ request_options=request_options,
242
+ )
243
+ try:
244
+ if 200 <= _response.status_code < 300:
245
+ return typing.cast(
246
+ IngestResponse,
247
+ parse_obj_as(
248
+ type_=IngestResponse, # type: ignore
249
+ object_=_response.json(),
250
+ ),
251
+ )
252
+ if _response.status_code == 400:
253
+ raise BadRequestError(
254
+ typing.cast(
255
+ typing.Optional[typing.Any],
256
+ parse_obj_as(
257
+ type_=typing.Optional[typing.Any], # type: ignore
258
+ object_=_response.json(),
259
+ ),
260
+ )
261
+ )
262
+ if _response.status_code == 401:
263
+ raise UnauthorizedError(
264
+ typing.cast(
265
+ typing.Optional[typing.Any],
266
+ parse_obj_as(
267
+ type_=typing.Optional[typing.Any], # type: ignore
268
+ object_=_response.json(),
269
+ ),
270
+ )
271
+ )
272
+ _response_json = _response.json()
273
+ except JSONDecodeError:
274
+ raise ApiError(status_code=_response.status_code, body=_response.text)
275
+ raise ApiError(status_code=_response.status_code, body=_response_json)
276
+
34
277
  def ingest_remote(
35
278
  self,
36
279
  *,
@@ -471,48 +714,23 @@ class DocumentsClient:
471
714
  raise ApiError(status_code=_response.status_code, body=_response.text)
472
715
  raise ApiError(status_code=_response.status_code, body=_response_json)
473
716
 
474
- def list(
475
- self,
476
- *,
477
- n: typing.Optional[int] = None,
478
- filter: typing.Optional[str] = None,
479
- sort: typing.Optional[Sort] = None,
480
- sort_order: typing.Optional[SortOrder] = None,
481
- status: typing.Optional[ProcessingStatus] = None,
482
- next_token: typing.Optional[str] = None,
483
- request_options: typing.Optional[RequestOptions] = None,
484
- ) -> DocumentListResponse:
717
+ def get(self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DocumentResponse:
485
718
  """
486
- lookup all documents across all resources which are currently on GroundX
719
+ Look up an existing document by documentId.
487
720
 
488
721
  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.
489
722
 
490
723
  Parameters
491
724
  ----------
492
- n : typing.Optional[int]
493
- The maximum number of returned documents. Accepts 1-100 with a default of 20.
494
-
495
- filter : typing.Optional[str]
496
- Only documents with names that contain the filter string will be returned in the results.
497
-
498
- sort : typing.Optional[Sort]
499
- The document attribute that will be used to sort the results.
500
-
501
- sort_order : typing.Optional[SortOrder]
502
- The order in which to sort the results. A value for sort must also be set.
503
-
504
- status : typing.Optional[ProcessingStatus]
505
- 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.
506
-
507
- next_token : typing.Optional[str]
508
- 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.
725
+ document_id : str
726
+ The documentId of the document for which GroundX information will be provided.
509
727
 
510
728
  request_options : typing.Optional[RequestOptions]
511
729
  Request-specific configuration.
512
730
 
513
731
  Returns
514
732
  -------
515
- DocumentListResponse
733
+ DocumentResponse
516
734
  Look up success
517
735
 
518
736
  Examples
@@ -522,50 +740,61 @@ class DocumentsClient:
522
740
  client = GroundX(
523
741
  api_key="YOUR_API_KEY",
524
742
  )
525
- client.documents.list()
743
+ client.documents.get(
744
+ document_id="documentId",
745
+ )
526
746
  """
527
747
  _response = self._client_wrapper.httpx_client.request(
528
- "v1/ingest/documents",
748
+ f"v1/ingest/document/{jsonable_encoder(document_id)}",
529
749
  method="GET",
530
- params={
531
- "n": n,
532
- "filter": filter,
533
- "sort": sort,
534
- "sortOrder": sort_order,
535
- "status": status,
536
- "nextToken": next_token,
537
- },
538
750
  request_options=request_options,
539
751
  )
540
752
  try:
541
753
  if 200 <= _response.status_code < 300:
542
754
  return typing.cast(
543
- DocumentListResponse,
755
+ DocumentResponse,
544
756
  parse_obj_as(
545
- type_=DocumentListResponse, # type: ignore
757
+ type_=DocumentResponse, # type: ignore
546
758
  object_=_response.json(),
547
759
  ),
548
760
  )
761
+ if _response.status_code == 400:
762
+ raise BadRequestError(
763
+ typing.cast(
764
+ typing.Optional[typing.Any],
765
+ parse_obj_as(
766
+ type_=typing.Optional[typing.Any], # type: ignore
767
+ object_=_response.json(),
768
+ ),
769
+ )
770
+ )
771
+ if _response.status_code == 401:
772
+ raise UnauthorizedError(
773
+ typing.cast(
774
+ typing.Optional[typing.Any],
775
+ parse_obj_as(
776
+ type_=typing.Optional[typing.Any], # type: ignore
777
+ object_=_response.json(),
778
+ ),
779
+ )
780
+ )
549
781
  _response_json = _response.json()
550
782
  except JSONDecodeError:
551
783
  raise ApiError(status_code=_response.status_code, body=_response.text)
552
784
  raise ApiError(status_code=_response.status_code, body=_response_json)
553
785
 
554
- def delete(
555
- self,
556
- *,
557
- document_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
558
- request_options: typing.Optional[RequestOptions] = None,
786
+ def delete_by_id(
787
+ self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None
559
788
  ) -> IngestResponse:
560
789
  """
561
- Delete multiple documents hosted on GroundX
790
+ Delete a single document hosted on GroundX
562
791
 
563
792
  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.
564
793
 
565
794
  Parameters
566
795
  ----------
567
- document_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
568
- A list of documentIds which correspond to documents ingested by GroundX
796
+ document_id : str
797
+ A documentId which correspond to a document ingested by GroundX
569
798
 
570
799
  request_options : typing.Optional[RequestOptions]
571
800
  Request-specific configuration.
@@ -573,7 +802,7 @@ class DocumentsClient:
573
802
  Returns
574
803
  -------
575
804
  IngestResponse
576
- Documents are queued to be deleted
805
+ Document successfully deleted
577
806
 
578
807
  Examples
579
808
  --------
@@ -582,14 +811,13 @@ class DocumentsClient:
582
811
  client = GroundX(
583
812
  api_key="YOUR_API_KEY",
584
813
  )
585
- client.documents.delete()
814
+ client.documents.delete_by_id(
815
+ document_id="documentId",
816
+ )
586
817
  """
587
818
  _response = self._client_wrapper.httpx_client.request(
588
- "v1/ingest/documents",
819
+ f"v1/ingest/document/{jsonable_encoder(document_id)}",
589
820
  method="DELETE",
590
- params={
591
- "documentIds": document_ids,
592
- },
593
821
  request_options=request_options,
594
822
  )
595
823
  try:
@@ -626,47 +854,166 @@ class DocumentsClient:
626
854
  raise ApiError(status_code=_response.status_code, body=_response.text)
627
855
  raise ApiError(status_code=_response.status_code, body=_response_json)
628
856
 
629
- def get(self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DocumentResponse:
857
+
858
+ class AsyncDocumentsClient:
859
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
860
+ self._client_wrapper = client_wrapper
861
+
862
+ async def list(
863
+ self,
864
+ *,
865
+ n: typing.Optional[int] = None,
866
+ filter: typing.Optional[str] = None,
867
+ sort: typing.Optional[Sort] = None,
868
+ sort_order: typing.Optional[SortOrder] = None,
869
+ status: typing.Optional[ProcessingStatus] = None,
870
+ next_token: typing.Optional[str] = None,
871
+ request_options: typing.Optional[RequestOptions] = None,
872
+ ) -> DocumentListResponse:
630
873
  """
631
- Look up an existing document by documentId.
874
+ lookup all documents across all resources which are currently on GroundX
632
875
 
633
876
  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.
634
877
 
635
878
  Parameters
636
879
  ----------
637
- document_id : str
638
- The documentId of the document for which GroundX information will be provided.
880
+ n : typing.Optional[int]
881
+ The maximum number of returned documents. Accepts 1-100 with a default of 20.
882
+
883
+ filter : typing.Optional[str]
884
+ Only documents with names that contain the filter string will be returned in the results.
885
+
886
+ sort : typing.Optional[Sort]
887
+ The document attribute that will be used to sort the results.
888
+
889
+ sort_order : typing.Optional[SortOrder]
890
+ The order in which to sort the results. A value for sort must also be set.
891
+
892
+ status : typing.Optional[ProcessingStatus]
893
+ 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.
894
+
895
+ next_token : typing.Optional[str]
896
+ 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.
639
897
 
640
898
  request_options : typing.Optional[RequestOptions]
641
899
  Request-specific configuration.
642
900
 
643
901
  Returns
644
902
  -------
645
- DocumentResponse
903
+ DocumentListResponse
646
904
  Look up success
647
905
 
648
906
  Examples
649
907
  --------
650
- from groundx import GroundX
908
+ import asyncio
909
+
910
+ from groundx import AsyncGroundX
911
+
912
+ client = AsyncGroundX(
913
+ api_key="YOUR_API_KEY",
914
+ )
915
+
916
+
917
+ async def main() -> None:
918
+ await client.documents.list()
919
+
920
+
921
+ asyncio.run(main())
922
+ """
923
+ _response = await self._client_wrapper.httpx_client.request(
924
+ "v1/ingest/documents",
925
+ method="GET",
926
+ params={
927
+ "n": n,
928
+ "filter": filter,
929
+ "sort": sort,
930
+ "sortOrder": sort_order,
931
+ "status": status,
932
+ "nextToken": next_token,
933
+ },
934
+ request_options=request_options,
935
+ )
936
+ try:
937
+ if 200 <= _response.status_code < 300:
938
+ return typing.cast(
939
+ DocumentListResponse,
940
+ parse_obj_as(
941
+ type_=DocumentListResponse, # type: ignore
942
+ object_=_response.json(),
943
+ ),
944
+ )
945
+ _response_json = _response.json()
946
+ except JSONDecodeError:
947
+ raise ApiError(status_code=_response.status_code, body=_response.text)
948
+ raise ApiError(status_code=_response.status_code, body=_response_json)
949
+
950
+ async def document_ingest(
951
+ self, *, documents: typing.Sequence[IngestDocument], request_options: typing.Optional[RequestOptions] = None
952
+ ) -> IngestResponse:
953
+ """
954
+ Ingest documents hosted on public URLs or a local file system for ingestion into a GroundX bucket.
955
+
956
+ 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.
957
+
958
+ Parameters
959
+ ----------
960
+ documents : typing.Sequence[IngestDocument]
961
+
962
+ request_options : typing.Optional[RequestOptions]
963
+ Request-specific configuration.
964
+
965
+ Returns
966
+ -------
967
+ IngestResponse
968
+ Documents successfully uploaded
969
+
970
+ Examples
971
+ --------
972
+ import asyncio
651
973
 
652
- client = GroundX(
974
+ from groundx import AsyncGroundX, IngestDocument
975
+
976
+ client = AsyncGroundX(
653
977
  api_key="YOUR_API_KEY",
654
978
  )
655
- client.documents.get(
656
- document_id="documentId",
657
- )
979
+
980
+
981
+ async def main() -> None:
982
+ await client.documents.document_ingest(
983
+ documents=[
984
+ IngestDocument(
985
+ bucket_id=1234,
986
+ file_name="my_file.txt",
987
+ file_path="https://my.source.url.com/file.txt",
988
+ file_type="txt",
989
+ search_data={"key": "value"},
990
+ )
991
+ ],
992
+ )
993
+
994
+
995
+ asyncio.run(main())
658
996
  """
659
- _response = self._client_wrapper.httpx_client.request(
660
- f"v1/ingest/document/{jsonable_encoder(document_id)}",
661
- method="GET",
997
+ _response = await self._client_wrapper.httpx_client.request(
998
+ "v1/ingest/documents",
999
+ method="POST",
1000
+ json={
1001
+ "documents": convert_and_respect_annotation_metadata(
1002
+ object_=documents, annotation=typing.Sequence[IngestDocument], direction="write"
1003
+ ),
1004
+ },
1005
+ headers={
1006
+ "content-type": "application/json",
1007
+ },
662
1008
  request_options=request_options,
1009
+ omit=OMIT,
663
1010
  )
664
1011
  try:
665
1012
  if 200 <= _response.status_code < 300:
666
1013
  return typing.cast(
667
- DocumentResponse,
1014
+ IngestResponse,
668
1015
  parse_obj_as(
669
- type_=DocumentResponse, # type: ignore
1016
+ type_=IngestResponse, # type: ignore
670
1017
  object_=_response.json(),
671
1018
  ),
672
1019
  )
@@ -695,18 +1042,21 @@ class DocumentsClient:
695
1042
  raise ApiError(status_code=_response.status_code, body=_response.text)
696
1043
  raise ApiError(status_code=_response.status_code, body=_response_json)
697
1044
 
698
- def delete_by_id(
699
- self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None
1045
+ async def delete(
1046
+ self,
1047
+ *,
1048
+ document_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
1049
+ request_options: typing.Optional[RequestOptions] = None,
700
1050
  ) -> IngestResponse:
701
1051
  """
702
- Delete a single document hosted on GroundX
1052
+ Delete multiple documents hosted on GroundX
703
1053
 
704
1054
  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.
705
1055
 
706
1056
  Parameters
707
1057
  ----------
708
- document_id : str
709
- A documentId which correspond to a document ingested by GroundX
1058
+ document_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
1059
+ A list of documentIds which correspond to documents ingested by GroundX
710
1060
 
711
1061
  request_options : typing.Optional[RequestOptions]
712
1062
  Request-specific configuration.
@@ -714,22 +1064,31 @@ class DocumentsClient:
714
1064
  Returns
715
1065
  -------
716
1066
  IngestResponse
717
- Document successfully deleted
1067
+ Documents are queued to be deleted
718
1068
 
719
1069
  Examples
720
1070
  --------
721
- from groundx import GroundX
1071
+ import asyncio
722
1072
 
723
- client = GroundX(
1073
+ from groundx import AsyncGroundX
1074
+
1075
+ client = AsyncGroundX(
724
1076
  api_key="YOUR_API_KEY",
725
1077
  )
726
- client.documents.delete_by_id(
727
- document_id="documentId",
728
- )
1078
+
1079
+
1080
+ async def main() -> None:
1081
+ await client.documents.delete()
1082
+
1083
+
1084
+ asyncio.run(main())
729
1085
  """
730
- _response = self._client_wrapper.httpx_client.request(
731
- f"v1/ingest/document/{jsonable_encoder(document_id)}",
1086
+ _response = await self._client_wrapper.httpx_client.request(
1087
+ "v1/ingest/documents",
732
1088
  method="DELETE",
1089
+ params={
1090
+ "documentIds": document_ids,
1091
+ },
733
1092
  request_options=request_options,
734
1093
  )
735
1094
  try:
@@ -766,11 +1125,6 @@ class DocumentsClient:
766
1125
  raise ApiError(status_code=_response.status_code, body=_response.text)
767
1126
  raise ApiError(status_code=_response.status_code, body=_response_json)
768
1127
 
769
-
770
- class AsyncDocumentsClient:
771
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
772
- self._client_wrapper = client_wrapper
773
-
774
1128
  async def ingest_remote(
775
1129
  self,
776
1130
  *,
@@ -1251,177 +1605,6 @@ class AsyncDocumentsClient:
1251
1605
  raise ApiError(status_code=_response.status_code, body=_response.text)
1252
1606
  raise ApiError(status_code=_response.status_code, body=_response_json)
1253
1607
 
1254
- async def list(
1255
- self,
1256
- *,
1257
- n: typing.Optional[int] = None,
1258
- filter: typing.Optional[str] = None,
1259
- sort: typing.Optional[Sort] = None,
1260
- sort_order: typing.Optional[SortOrder] = None,
1261
- status: typing.Optional[ProcessingStatus] = None,
1262
- next_token: typing.Optional[str] = None,
1263
- request_options: typing.Optional[RequestOptions] = None,
1264
- ) -> DocumentListResponse:
1265
- """
1266
- lookup all documents across all resources which are currently on GroundX
1267
-
1268
- 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.
1269
-
1270
- Parameters
1271
- ----------
1272
- n : typing.Optional[int]
1273
- The maximum number of returned documents. Accepts 1-100 with a default of 20.
1274
-
1275
- filter : typing.Optional[str]
1276
- Only documents with names that contain the filter string will be returned in the results.
1277
-
1278
- sort : typing.Optional[Sort]
1279
- The document attribute that will be used to sort the results.
1280
-
1281
- sort_order : typing.Optional[SortOrder]
1282
- The order in which to sort the results. A value for sort must also be set.
1283
-
1284
- status : typing.Optional[ProcessingStatus]
1285
- 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.
1286
-
1287
- next_token : typing.Optional[str]
1288
- 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.
1289
-
1290
- request_options : typing.Optional[RequestOptions]
1291
- Request-specific configuration.
1292
-
1293
- Returns
1294
- -------
1295
- DocumentListResponse
1296
- Look up success
1297
-
1298
- Examples
1299
- --------
1300
- import asyncio
1301
-
1302
- from groundx import AsyncGroundX
1303
-
1304
- client = AsyncGroundX(
1305
- api_key="YOUR_API_KEY",
1306
- )
1307
-
1308
-
1309
- async def main() -> None:
1310
- await client.documents.list()
1311
-
1312
-
1313
- asyncio.run(main())
1314
- """
1315
- _response = await self._client_wrapper.httpx_client.request(
1316
- "v1/ingest/documents",
1317
- method="GET",
1318
- params={
1319
- "n": n,
1320
- "filter": filter,
1321
- "sort": sort,
1322
- "sortOrder": sort_order,
1323
- "status": status,
1324
- "nextToken": next_token,
1325
- },
1326
- request_options=request_options,
1327
- )
1328
- try:
1329
- if 200 <= _response.status_code < 300:
1330
- return typing.cast(
1331
- DocumentListResponse,
1332
- parse_obj_as(
1333
- type_=DocumentListResponse, # type: ignore
1334
- object_=_response.json(),
1335
- ),
1336
- )
1337
- _response_json = _response.json()
1338
- except JSONDecodeError:
1339
- raise ApiError(status_code=_response.status_code, body=_response.text)
1340
- raise ApiError(status_code=_response.status_code, body=_response_json)
1341
-
1342
- async def delete(
1343
- self,
1344
- *,
1345
- document_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
1346
- request_options: typing.Optional[RequestOptions] = None,
1347
- ) -> IngestResponse:
1348
- """
1349
- Delete multiple documents hosted on GroundX
1350
-
1351
- 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.
1352
-
1353
- Parameters
1354
- ----------
1355
- document_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
1356
- A list of documentIds which correspond to documents ingested by GroundX
1357
-
1358
- request_options : typing.Optional[RequestOptions]
1359
- Request-specific configuration.
1360
-
1361
- Returns
1362
- -------
1363
- IngestResponse
1364
- Documents are queued to be deleted
1365
-
1366
- Examples
1367
- --------
1368
- import asyncio
1369
-
1370
- from groundx import AsyncGroundX
1371
-
1372
- client = AsyncGroundX(
1373
- api_key="YOUR_API_KEY",
1374
- )
1375
-
1376
-
1377
- async def main() -> None:
1378
- await client.documents.delete()
1379
-
1380
-
1381
- asyncio.run(main())
1382
- """
1383
- _response = await self._client_wrapper.httpx_client.request(
1384
- "v1/ingest/documents",
1385
- method="DELETE",
1386
- params={
1387
- "documentIds": document_ids,
1388
- },
1389
- request_options=request_options,
1390
- )
1391
- try:
1392
- if 200 <= _response.status_code < 300:
1393
- return typing.cast(
1394
- IngestResponse,
1395
- parse_obj_as(
1396
- type_=IngestResponse, # type: ignore
1397
- object_=_response.json(),
1398
- ),
1399
- )
1400
- if _response.status_code == 400:
1401
- raise BadRequestError(
1402
- typing.cast(
1403
- typing.Optional[typing.Any],
1404
- parse_obj_as(
1405
- type_=typing.Optional[typing.Any], # type: ignore
1406
- object_=_response.json(),
1407
- ),
1408
- )
1409
- )
1410
- if _response.status_code == 401:
1411
- raise UnauthorizedError(
1412
- typing.cast(
1413
- typing.Optional[typing.Any],
1414
- parse_obj_as(
1415
- type_=typing.Optional[typing.Any], # type: ignore
1416
- object_=_response.json(),
1417
- ),
1418
- )
1419
- )
1420
- _response_json = _response.json()
1421
- except JSONDecodeError:
1422
- raise ApiError(status_code=_response.status_code, body=_response.text)
1423
- raise ApiError(status_code=_response.status_code, body=_response_json)
1424
-
1425
1608
  async def get(
1426
1609
  self, document_id: str, *, request_options: typing.Optional[RequestOptions] = None
1427
1610
  ) -> DocumentResponse:
groundx/types/__init__.py CHANGED
@@ -21,6 +21,7 @@ from .health_response import HealthResponse
21
21
  from .health_response_health import HealthResponseHealth
22
22
  from .health_service import HealthService
23
23
  from .health_service_status import HealthServiceStatus
24
+ from .ingest_document import IngestDocument
24
25
  from .ingest_local_document import IngestLocalDocument
25
26
  from .ingest_remote_document import IngestRemoteDocument
26
27
  from .ingest_response import IngestResponse
@@ -65,6 +66,7 @@ __all__ = [
65
66
  "HealthResponseHealth",
66
67
  "HealthService",
67
68
  "HealthServiceStatus",
69
+ "IngestDocument",
68
70
  "IngestLocalDocument",
69
71
  "IngestRemoteDocument",
70
72
  "IngestResponse",
@@ -0,0 +1,45 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.pydantic_utilities import UniversalBaseModel
4
+ import typing_extensions
5
+ from ..core.serialization import FieldMetadata
6
+ import pydantic
7
+ import typing
8
+ from .document_type import DocumentType
9
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2
10
+
11
+
12
+ class IngestDocument(UniversalBaseModel):
13
+ bucket_id: typing_extensions.Annotated[int, FieldMetadata(alias="bucketId")] = pydantic.Field()
14
+ """
15
+ the bucketId of the bucket which this remote file will be ingested to.
16
+ """
17
+
18
+ file_name: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="fileName")] = pydantic.Field(
19
+ default=None
20
+ )
21
+ """
22
+ The name of the file being ingested
23
+ """
24
+
25
+ file_path: typing_extensions.Annotated[str, FieldMetadata(alias="filePath")] = pydantic.Field()
26
+ """
27
+ The local file path or remote URL of the document being ingested by GroundX.
28
+ """
29
+
30
+ file_type: typing_extensions.Annotated[typing.Optional[DocumentType], FieldMetadata(alias="fileType")] = None
31
+ search_data: typing_extensions.Annotated[
32
+ typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]], FieldMetadata(alias="searchData")
33
+ ] = pydantic.Field(default=None)
34
+ """
35
+ Custom metadata which can be used to influence GroundX's search functionality. This data can be used to further hone GroundX search.
36
+ """
37
+
38
+ if IS_PYDANTIC_V2:
39
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
40
+ else:
41
+
42
+ class Config:
43
+ frozen = True
44
+ smart_union = True
45
+ extra = pydantic.Extra.allow
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: groundx
3
- Version: 2.0.17
3
+ Version: 2.0.18
4
4
  Summary:
5
5
  License: MIT
6
6
  Requires-Python: >=3.8,<4.0
@@ -52,19 +52,19 @@ A full reference for this library is available [here](./reference.md).
52
52
  Instantiate and use the client with the following:
53
53
 
54
54
  ```python
55
- from groundx import GroundX, IngestRemoteDocument
55
+ from groundx import GroundX, IngestDocument
56
56
 
57
57
  client = GroundX(
58
58
  api_key="YOUR_API_KEY",
59
59
  )
60
- client.documents.ingest_remote(
60
+ client.documents.document_ingest(
61
61
  documents=[
62
- IngestRemoteDocument(
62
+ IngestDocument(
63
63
  bucket_id=1234,
64
64
  file_name="my_file.txt",
65
+ file_path="https://my.source.url.com/file.txt",
65
66
  file_type="txt",
66
67
  search_data={"key": "value"},
67
- source_url="https://my.source.url.com/file.txt",
68
68
  )
69
69
  ],
70
70
  )
@@ -77,7 +77,7 @@ The SDK also exports an `async` client so that you can make non-blocking calls t
77
77
  ```python
78
78
  import asyncio
79
79
 
80
- from groundx import AsyncGroundX, IngestRemoteDocument
80
+ from groundx import AsyncGroundX, IngestDocument
81
81
 
82
82
  client = AsyncGroundX(
83
83
  api_key="YOUR_API_KEY",
@@ -85,14 +85,14 @@ client = AsyncGroundX(
85
85
 
86
86
 
87
87
  async def main() -> None:
88
- await client.documents.ingest_remote(
88
+ await client.documents.document_ingest(
89
89
  documents=[
90
- IngestRemoteDocument(
90
+ IngestDocument(
91
91
  bucket_id=1234,
92
92
  file_name="my_file.txt",
93
+ file_path="https://my.source.url.com/file.txt",
93
94
  file_type="txt",
94
95
  search_data={"key": "value"},
95
- source_url="https://my.source.url.com/file.txt",
96
96
  )
97
97
  ],
98
98
  )
@@ -110,7 +110,7 @@ will be thrown.
110
110
  from groundx.core.api_error import ApiError
111
111
 
112
112
  try:
113
- client.documents.ingest_remote(...)
113
+ client.documents.document_ingest(...)
114
114
  except ApiError as e:
115
115
  print(e.status_code)
116
116
  print(e.body)
@@ -133,7 +133,7 @@ A request is deemed retriable when any of the following HTTP status codes is ret
133
133
  Use the `max_retries` request option to configure this behavior.
134
134
 
135
135
  ```python
136
- client.documents.ingest_remote(..., request_options={
136
+ client.documents.document_ingest(..., request_options={
137
137
  "max_retries": 1
138
138
  })
139
139
  ```
@@ -153,7 +153,7 @@ client = GroundX(
153
153
 
154
154
 
155
155
  # Override timeout for a specific method
156
- client.documents.ingest_remote(..., request_options={
156
+ client.documents.document_ingest(..., request_options={
157
157
  "timeout_in_seconds": 1
158
158
  })
159
159
  ```
@@ -1,10 +1,10 @@
1
- groundx/__init__.py,sha256=22BLAf5omcgumWGCWHDb8o-ha8TnNbkO8LcEvpcYU6A,2851
1
+ groundx/__init__.py,sha256=k9TpTModn8DZ6OiU_90cp_F5o40BSbwuo9z5Pd5xRlo,2893
2
2
  groundx/buckets/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
3
3
  groundx/buckets/client.py,sha256=TofNrkej1AC_-FU5rf_y8KG8ubFUpHtLa8PQ7rqax6E,26537
4
4
  groundx/client.py,sha256=Q1Kw0z6K-z-ShhNyuuPe5fYonM9M2I_55-ukUrUWk1U,6507
5
5
  groundx/core/__init__.py,sha256=SQ85PF84B9MuKnBwHNHWemSGuy-g_515gFYNFhvEE0I,1438
6
6
  groundx/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
7
- groundx/core/client_wrapper.py,sha256=zY1z1mzje1H39BKU9IR7OxYeBRV-PVvs004iAgfDqxI,1803
7
+ groundx/core/client_wrapper.py,sha256=Z-ZEBnqD06tDJsvCV9J77eEZYKXnWnOJny79xUUPQ18,1803
8
8
  groundx/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
9
9
  groundx/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
10
10
  groundx/core/http_client.py,sha256=siUQ6UV0ARZALlxubqWSSAAPC9B4VW8y6MGlHStfaeo,19552
@@ -17,7 +17,7 @@ groundx/core/serialization.py,sha256=D9h_t-RQON3-CHWs1C4ESY9B-Yd5d-l5lnTLb_X896g
17
17
  groundx/customer/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
18
18
  groundx/customer/client.py,sha256=C_JANeDewRD1Kg-q7LPxdiOSWbYSTOiYlBYZLRYPI44,3467
19
19
  groundx/documents/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
20
- groundx/documents/client.py,sha256=_l8K11r-p3qaMd0Qn43JjnSN68stMiaRoTzbbukQxl8,58882
20
+ groundx/documents/client.py,sha256=QbQelu46lRfrrMpb1fXdjQfPUrc7d2KvTO4KrLOS1Og,65667
21
21
  groundx/environment.py,sha256=CInm1_DKtZ1mrxutmKb1qqv82P33r_S87hZD3Hc1VB0,159
22
22
  groundx/errors/__init__.py,sha256=-prNYsFd8xxM4va0vR1raZjcd10tllOJKyEWjX_pwdU,214
23
23
  groundx/errors/bad_request_error.py,sha256=_EbO8mWqN9kFZPvIap8qa1lL_EWkRcsZe1HKV9GDWJY,264
@@ -31,7 +31,7 @@ groundx/search/__init__.py,sha256=RagVzjShP33mDg9o4N3kGzV0egL1RYNjCpXPE8VzMYE,14
31
31
  groundx/search/client.py,sha256=10ifg9GyIwIZF13ULfCXF8iFIydq6H6QRDrGPDjpanw,19756
32
32
  groundx/search/types/__init__.py,sha256=fNFXQloPa1PHHO8VZim6KQNMA9N5EZtfSkissdxtY_c,165
33
33
  groundx/search/types/search_content_request_id.py,sha256=us7mYdzR0qPur_wR5I9BhHaLEzC5nLBRna6-xq4M1ec,128
34
- groundx/types/__init__.py,sha256=yCuwY3aySGDKKYYbxFX_v0kyG_ePu1_M0ZryOwMZJVk,3567
34
+ groundx/types/__init__.py,sha256=ms9d1ANY2mUuAvKUOTd76dWc5Ujza4w31Dw6luDxQ-k,3633
35
35
  groundx/types/bounding_box_detail.py,sha256=51qcen326NTHY2ZqH1cFXut0_MCmk39EbLoDAwotdq4,1832
36
36
  groundx/types/bucket_detail.py,sha256=bQjCvfyWydjItmzNNTvH-iWxNDOggd7R7X1alFZzlEY,1511
37
37
  groundx/types/bucket_list_response.py,sha256=jC0NBsLCYDSwQrBzuW0g3PWFycjtKl8YRkKhic_-1DA,650
@@ -53,6 +53,7 @@ groundx/types/health_response.py,sha256=3UpYL2IZb56tTo-fOpSU-0OTRyWgpYiB3pMU3sfj
53
53
  groundx/types/health_response_health.py,sha256=I0QeEljFp6l5LCJbCTArW031Om84egePgnGdtE6WXlI,632
54
54
  groundx/types/health_service.py,sha256=M1-h1EJSpAXw-j3pY-09_g_WKkO0spdj8e7pgPzSGf0,1083
55
55
  groundx/types/health_service_status.py,sha256=ugKJXlx8QGi83n_J6s1frFrW1hYfOn3Dlb_pPNexwMA,185
56
+ groundx/types/ingest_document.py,sha256=hIVo62aYNOpwmpUbyUya_u1WJy4qXfBNouuyPFMK7eU,1701
56
57
  groundx/types/ingest_local_document.py,sha256=2T1HXR2a-BDj5LEOTM98Sl4sgjVMWbVShQLn8MTR6QA,1602
57
58
  groundx/types/ingest_remote_document.py,sha256=xlPA4SYoUgoGXpxZhyORdezxIPGmr4wneav2ZEVmmOY,1683
58
59
  groundx/types/ingest_response.py,sha256=139rn8wpT44jlUzYXiy0r8XzN2U_OtdLltpSbRU0TyA,633
@@ -75,7 +76,7 @@ groundx/types/sort_order.py,sha256=hfJkStz6zHf3iWQFaVLkNCZPdyj5JS7TsQlN4Ij8Q5A,1
75
76
  groundx/types/subscription_detail.py,sha256=WNfUw2EMVECIvNYcV2s51zZ6T3Utc4zYXw63bPaeM6U,768
76
77
  groundx/types/subscription_detail_meters.py,sha256=lBa8-1QlMVHjr5RLGqhiTKnD1KMM0AAHTWvz9TVtG8w,830
77
78
  groundx/version.py,sha256=1yVogKaq260fQfckM2RYN2144SEw0QROsZW8ICtkG4U,74
78
- groundx-2.0.17.dist-info/LICENSE,sha256=8dMPYAFBTA7O4DUxhrEKEks8CL2waCMYM6dHohW4xrI,1065
79
- groundx-2.0.17.dist-info/METADATA,sha256=HZspuVrfswC62NtJa1cUVkS53KO8stJ8xnqTNfFx4lE,5206
80
- groundx-2.0.17.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
81
- groundx-2.0.17.dist-info/RECORD,,
79
+ groundx-2.0.18.dist-info/LICENSE,sha256=8dMPYAFBTA7O4DUxhrEKEks8CL2waCMYM6dHohW4xrI,1065
80
+ groundx-2.0.18.dist-info/METADATA,sha256=HJlHWrgOt9oD1z1UtEVheD5ZVwZMjYeyqIWQPDsJgug,5190
81
+ groundx-2.0.18.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
82
+ groundx-2.0.18.dist-info/RECORD,,