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