usecortex-ai 0.3.6__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- usecortex_ai/__init__.py +82 -70
- usecortex_ai/client.py +25 -23
- usecortex_ai/dashboard/client.py +448 -0
- usecortex_ai/{user_memory → dashboard}/raw_client.py +371 -530
- usecortex_ai/embeddings/client.py +229 -102
- usecortex_ai/embeddings/raw_client.py +323 -211
- usecortex_ai/errors/__init__.py +2 -0
- usecortex_ai/errors/bad_request_error.py +1 -2
- usecortex_ai/errors/forbidden_error.py +1 -2
- usecortex_ai/errors/internal_server_error.py +1 -2
- usecortex_ai/errors/not_found_error.py +1 -2
- usecortex_ai/errors/service_unavailable_error.py +1 -2
- usecortex_ai/errors/too_many_requests_error.py +11 -0
- usecortex_ai/errors/unauthorized_error.py +1 -2
- usecortex_ai/fetch/client.py +350 -29
- usecortex_ai/fetch/raw_client.py +919 -65
- usecortex_ai/raw_client.py +8 -2
- usecortex_ai/search/client.py +313 -257
- usecortex_ai/search/raw_client.py +463 -344
- usecortex_ai/search/types/alpha.py +1 -1
- usecortex_ai/sources/client.py +29 -216
- usecortex_ai/sources/raw_client.py +51 -589
- usecortex_ai/tenant/client.py +155 -118
- usecortex_ai/tenant/raw_client.py +227 -350
- usecortex_ai/types/__init__.py +76 -66
- usecortex_ai/types/add_memory_response.py +39 -0
- usecortex_ai/types/{scored_triplet_response.py → api_key_info.py} +16 -12
- usecortex_ai/types/app_sources_upload_data.py +15 -6
- usecortex_ai/types/{file_upload_result.py → collection_stats.py} +5 -5
- usecortex_ai/types/custom_property_definition.py +75 -0
- usecortex_ai/types/dashboard_apis_response.py +33 -0
- usecortex_ai/types/dashboard_sources_response.py +33 -0
- usecortex_ai/types/dashboard_tenants_response.py +33 -0
- usecortex_ai/types/{list_sources_response.py → delete_result.py} +10 -7
- usecortex_ai/types/delete_user_memory_response.py +1 -1
- usecortex_ai/types/entity.py +4 -4
- usecortex_ai/types/fetch_mode.py +5 -0
- usecortex_ai/types/{relations.py → forceful_relations_payload.py} +4 -4
- usecortex_ai/types/graph_context.py +26 -0
- usecortex_ai/types/{delete_sources.py → infra.py} +4 -3
- usecortex_ai/types/{fetch_content_data.py → insert_result.py} +12 -8
- usecortex_ai/types/memory_item.py +88 -0
- usecortex_ai/types/memory_result_item.py +47 -0
- usecortex_ai/types/milvus_data_type.py +21 -0
- usecortex_ai/types/path_triplet.py +3 -18
- usecortex_ai/types/processing_status.py +3 -2
- usecortex_ai/types/processing_status_indexing_status.py +7 -0
- usecortex_ai/types/qn_a_search_response.py +49 -0
- usecortex_ai/types/{retrieve_response.py → raw_embedding_document.py} +11 -8
- usecortex_ai/types/raw_embedding_search_result.py +47 -0
- usecortex_ai/types/{user_memory.py → raw_embedding_vector.py} +6 -6
- usecortex_ai/types/relation_evidence.py +24 -5
- usecortex_ai/types/retrieval_result.py +30 -0
- usecortex_ai/types/scored_path_response.py +5 -19
- usecortex_ai/types/search_mode.py +5 -0
- usecortex_ai/types/{batch_upload_data.py → source_delete_response.py} +8 -8
- usecortex_ai/types/{list_user_memories_response.py → source_delete_result_item.py} +11 -7
- usecortex_ai/types/source_fetch_response.py +70 -0
- usecortex_ai/types/{graph_relations_response.py → source_graph_relations_response.py} +3 -3
- usecortex_ai/types/{single_upload_data.py → source_list_response.py} +7 -10
- usecortex_ai/types/source_model.py +11 -1
- usecortex_ai/types/source_status.py +5 -0
- usecortex_ai/types/source_upload_response.py +35 -0
- usecortex_ai/types/source_upload_result_item.py +38 -0
- usecortex_ai/types/supported_llm_providers.py +5 -0
- usecortex_ai/types/{embeddings_create_collection_data.py → tenant_create_response.py} +9 -7
- usecortex_ai/types/{webpage_scrape_request.py → tenant_info.py} +10 -5
- usecortex_ai/types/tenant_metadata_schema_info.py +36 -0
- usecortex_ai/types/{tenant_create_data.py → tenant_stats_response.py} +9 -8
- usecortex_ai/types/{triple_with_evidence.py → triplet_with_evidence.py} +5 -1
- usecortex_ai/types/user_assistant_pair.py +4 -0
- usecortex_ai/types/{search_chunk.py → vector_store_chunk.py} +5 -11
- usecortex_ai/upload/__init__.py +3 -0
- usecortex_ai/upload/client.py +233 -1937
- usecortex_ai/upload/raw_client.py +364 -4401
- usecortex_ai/upload/types/__init__.py +7 -0
- usecortex_ai/upload/types/body_upload_app_ingestion_upload_app_post_app_sources.py +7 -0
- {usecortex_ai-0.3.6.dist-info → usecortex_ai-0.5.0.dist-info}/METADATA +2 -2
- usecortex_ai-0.5.0.dist-info/RECORD +114 -0
- {usecortex_ai-0.3.6.dist-info → usecortex_ai-0.5.0.dist-info}/WHEEL +1 -1
- {usecortex_ai-0.3.6.dist-info → usecortex_ai-0.5.0.dist-info}/licenses/LICENSE +21 -21
- {usecortex_ai-0.3.6.dist-info → usecortex_ai-0.5.0.dist-info}/top_level.txt +0 -0
- usecortex_ai/document/client.py +0 -139
- usecortex_ai/document/raw_client.py +0 -312
- usecortex_ai/types/add_user_memory_response.py +0 -41
- usecortex_ai/types/body_scrape_webpage_upload_scrape_webpage_post.py +0 -17
- usecortex_ai/types/body_update_scrape_job_upload_update_webpage_patch.py +0 -17
- usecortex_ai/types/chunk_graph_relations_response.py +0 -33
- usecortex_ai/types/delete_memory_request.py +0 -32
- usecortex_ai/types/delete_sub_tenant_data.py +0 -42
- usecortex_ai/types/embeddings_delete_data.py +0 -37
- usecortex_ai/types/embeddings_get_data.py +0 -37
- usecortex_ai/types/embeddings_search_data.py +0 -37
- usecortex_ai/types/extended_context.py +0 -17
- usecortex_ai/types/markdown_upload_request.py +0 -41
- usecortex_ai/types/related_chunk.py +0 -22
- usecortex_ai/types/retrieve_user_memory_response.py +0 -38
- usecortex_ai/types/source.py +0 -52
- usecortex_ai/types/sub_tenant_ids_data.py +0 -47
- usecortex_ai/types/tenant_stats.py +0 -42
- usecortex_ai/user/__init__.py +0 -4
- usecortex_ai/user/client.py +0 -145
- usecortex_ai/user/raw_client.py +0 -316
- usecortex_ai/user_memory/__init__.py +0 -4
- usecortex_ai/user_memory/client.py +0 -515
- usecortex_ai-0.3.6.dist-info/RECORD +0 -112
- /usecortex_ai/{document → dashboard}/__init__.py +0 -0
usecortex_ai/fetch/raw_client.py
CHANGED
|
@@ -15,8 +15,10 @@ from ..errors.not_found_error import NotFoundError
|
|
|
15
15
|
from ..errors.service_unavailable_error import ServiceUnavailableError
|
|
16
16
|
from ..errors.unauthorized_error import UnauthorizedError
|
|
17
17
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
18
|
-
from ..types.
|
|
19
|
-
from ..types.
|
|
18
|
+
from ..types.fetch_mode import FetchMode
|
|
19
|
+
from ..types.source_fetch_response import SourceFetchResponse
|
|
20
|
+
from ..types.source_graph_relations_response import SourceGraphRelationsResponse
|
|
21
|
+
from ..types.source_list_response import SourceListResponse
|
|
20
22
|
|
|
21
23
|
# this is used as the default value for optional parameters
|
|
22
24
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -26,45 +28,753 @@ class RawFetchClient:
|
|
|
26
28
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
27
29
|
self._client_wrapper = client_wrapper
|
|
28
30
|
|
|
29
|
-
def
|
|
31
|
+
def sources(
|
|
30
32
|
self,
|
|
31
33
|
*,
|
|
32
|
-
file_id: str,
|
|
33
|
-
file_type: str,
|
|
34
34
|
tenant_id: str,
|
|
35
|
-
|
|
35
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
36
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
37
|
+
) -> HttpResponse[SourceListResponse]:
|
|
38
|
+
"""
|
|
39
|
+
Retrieve all sources for a specific tenant and subtenant combination.
|
|
40
|
+
|
|
41
|
+
Use this endpoint to fetch a complete list of all sources associated
|
|
42
|
+
with your tenant. This includes documents, files, and other content
|
|
43
|
+
you've uploaded for processing.
|
|
44
|
+
|
|
45
|
+
You can optionally specify a sub-tenant to narrow down the results to
|
|
46
|
+
sources within that specific sub-tenant scope.
|
|
47
|
+
|
|
48
|
+
Parameters
|
|
49
|
+
----------
|
|
50
|
+
tenant_id : str
|
|
51
|
+
Unique identifier for the tenant/organization
|
|
52
|
+
|
|
53
|
+
sub_tenant_id : typing.Optional[str]
|
|
54
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
55
|
+
|
|
56
|
+
request_options : typing.Optional[RequestOptions]
|
|
57
|
+
Request-specific configuration.
|
|
58
|
+
|
|
59
|
+
Returns
|
|
60
|
+
-------
|
|
61
|
+
HttpResponse[SourceListResponse]
|
|
62
|
+
Successful Response
|
|
63
|
+
"""
|
|
64
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
65
|
+
"list/list-sources",
|
|
66
|
+
method="GET",
|
|
67
|
+
params={
|
|
68
|
+
"tenant_id": tenant_id,
|
|
69
|
+
"sub_tenant_id": sub_tenant_id,
|
|
70
|
+
},
|
|
71
|
+
request_options=request_options,
|
|
72
|
+
)
|
|
73
|
+
try:
|
|
74
|
+
if 200 <= _response.status_code < 300:
|
|
75
|
+
_data = typing.cast(
|
|
76
|
+
SourceListResponse,
|
|
77
|
+
parse_obj_as(
|
|
78
|
+
type_=SourceListResponse, # type: ignore
|
|
79
|
+
object_=_response.json(),
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
return HttpResponse(response=_response, data=_data)
|
|
83
|
+
if _response.status_code == 400:
|
|
84
|
+
raise BadRequestError(
|
|
85
|
+
headers=dict(_response.headers),
|
|
86
|
+
body=typing.cast(
|
|
87
|
+
typing.Optional[typing.Any],
|
|
88
|
+
parse_obj_as(
|
|
89
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
90
|
+
object_=_response.json(),
|
|
91
|
+
),
|
|
92
|
+
),
|
|
93
|
+
)
|
|
94
|
+
if _response.status_code == 401:
|
|
95
|
+
raise UnauthorizedError(
|
|
96
|
+
headers=dict(_response.headers),
|
|
97
|
+
body=typing.cast(
|
|
98
|
+
typing.Optional[typing.Any],
|
|
99
|
+
parse_obj_as(
|
|
100
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
101
|
+
object_=_response.json(),
|
|
102
|
+
),
|
|
103
|
+
),
|
|
104
|
+
)
|
|
105
|
+
if _response.status_code == 403:
|
|
106
|
+
raise ForbiddenError(
|
|
107
|
+
headers=dict(_response.headers),
|
|
108
|
+
body=typing.cast(
|
|
109
|
+
typing.Optional[typing.Any],
|
|
110
|
+
parse_obj_as(
|
|
111
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
112
|
+
object_=_response.json(),
|
|
113
|
+
),
|
|
114
|
+
),
|
|
115
|
+
)
|
|
116
|
+
if _response.status_code == 404:
|
|
117
|
+
raise NotFoundError(
|
|
118
|
+
headers=dict(_response.headers),
|
|
119
|
+
body=typing.cast(
|
|
120
|
+
typing.Optional[typing.Any],
|
|
121
|
+
parse_obj_as(
|
|
122
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
123
|
+
object_=_response.json(),
|
|
124
|
+
),
|
|
125
|
+
),
|
|
126
|
+
)
|
|
127
|
+
if _response.status_code == 422:
|
|
128
|
+
raise UnprocessableEntityError(
|
|
129
|
+
headers=dict(_response.headers),
|
|
130
|
+
body=typing.cast(
|
|
131
|
+
typing.Optional[typing.Any],
|
|
132
|
+
parse_obj_as(
|
|
133
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
134
|
+
object_=_response.json(),
|
|
135
|
+
),
|
|
136
|
+
),
|
|
137
|
+
)
|
|
138
|
+
if _response.status_code == 500:
|
|
139
|
+
raise InternalServerError(
|
|
140
|
+
headers=dict(_response.headers),
|
|
141
|
+
body=typing.cast(
|
|
142
|
+
typing.Optional[typing.Any],
|
|
143
|
+
parse_obj_as(
|
|
144
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
145
|
+
object_=_response.json(),
|
|
146
|
+
),
|
|
147
|
+
),
|
|
148
|
+
)
|
|
149
|
+
if _response.status_code == 503:
|
|
150
|
+
raise ServiceUnavailableError(
|
|
151
|
+
headers=dict(_response.headers),
|
|
152
|
+
body=typing.cast(
|
|
153
|
+
typing.Optional[typing.Any],
|
|
154
|
+
parse_obj_as(
|
|
155
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
156
|
+
object_=_response.json(),
|
|
157
|
+
),
|
|
158
|
+
),
|
|
159
|
+
)
|
|
160
|
+
_response_json = _response.json()
|
|
161
|
+
except JSONDecodeError:
|
|
162
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
163
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
164
|
+
|
|
165
|
+
def source_by_ids(
|
|
166
|
+
self,
|
|
167
|
+
*,
|
|
168
|
+
source_ids: typing.Sequence[str],
|
|
169
|
+
tenant_id: str,
|
|
170
|
+
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
171
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
172
|
+
) -> HttpResponse[SourceListResponse]:
|
|
173
|
+
"""
|
|
174
|
+
Retrieve specific sources by their IDs.
|
|
175
|
+
|
|
176
|
+
Use this endpoint to fetch one or more sources by providing their
|
|
177
|
+
unique identifiers. This is useful when you need detailed information
|
|
178
|
+
about specific documents or content you've previously uploaded.
|
|
179
|
+
|
|
180
|
+
Provide the source IDs in the request body along with your tenant
|
|
181
|
+
information to get the exact sources you need.
|
|
182
|
+
|
|
183
|
+
Parameters
|
|
184
|
+
----------
|
|
185
|
+
source_ids : typing.Sequence[str]
|
|
186
|
+
List of source IDs to fetch.
|
|
187
|
+
|
|
188
|
+
tenant_id : str
|
|
189
|
+
Tenant ID
|
|
190
|
+
|
|
191
|
+
sub_tenant_id : typing.Optional[str]
|
|
192
|
+
Sub-tenant ID
|
|
193
|
+
|
|
194
|
+
request_options : typing.Optional[RequestOptions]
|
|
195
|
+
Request-specific configuration.
|
|
196
|
+
|
|
197
|
+
Returns
|
|
198
|
+
-------
|
|
199
|
+
HttpResponse[SourceListResponse]
|
|
200
|
+
Successful Response
|
|
201
|
+
"""
|
|
202
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
203
|
+
"list/list-sources-by-id",
|
|
204
|
+
method="POST",
|
|
205
|
+
json={
|
|
206
|
+
"source_ids": source_ids,
|
|
207
|
+
"tenant_id": tenant_id,
|
|
208
|
+
"sub_tenant_id": sub_tenant_id,
|
|
209
|
+
},
|
|
210
|
+
headers={
|
|
211
|
+
"content-type": "application/json",
|
|
212
|
+
},
|
|
213
|
+
request_options=request_options,
|
|
214
|
+
omit=OMIT,
|
|
215
|
+
)
|
|
216
|
+
try:
|
|
217
|
+
if 200 <= _response.status_code < 300:
|
|
218
|
+
_data = typing.cast(
|
|
219
|
+
SourceListResponse,
|
|
220
|
+
parse_obj_as(
|
|
221
|
+
type_=SourceListResponse, # type: ignore
|
|
222
|
+
object_=_response.json(),
|
|
223
|
+
),
|
|
224
|
+
)
|
|
225
|
+
return HttpResponse(response=_response, data=_data)
|
|
226
|
+
if _response.status_code == 400:
|
|
227
|
+
raise BadRequestError(
|
|
228
|
+
headers=dict(_response.headers),
|
|
229
|
+
body=typing.cast(
|
|
230
|
+
typing.Optional[typing.Any],
|
|
231
|
+
parse_obj_as(
|
|
232
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
233
|
+
object_=_response.json(),
|
|
234
|
+
),
|
|
235
|
+
),
|
|
236
|
+
)
|
|
237
|
+
if _response.status_code == 401:
|
|
238
|
+
raise UnauthorizedError(
|
|
239
|
+
headers=dict(_response.headers),
|
|
240
|
+
body=typing.cast(
|
|
241
|
+
typing.Optional[typing.Any],
|
|
242
|
+
parse_obj_as(
|
|
243
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
244
|
+
object_=_response.json(),
|
|
245
|
+
),
|
|
246
|
+
),
|
|
247
|
+
)
|
|
248
|
+
if _response.status_code == 403:
|
|
249
|
+
raise ForbiddenError(
|
|
250
|
+
headers=dict(_response.headers),
|
|
251
|
+
body=typing.cast(
|
|
252
|
+
typing.Optional[typing.Any],
|
|
253
|
+
parse_obj_as(
|
|
254
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
255
|
+
object_=_response.json(),
|
|
256
|
+
),
|
|
257
|
+
),
|
|
258
|
+
)
|
|
259
|
+
if _response.status_code == 404:
|
|
260
|
+
raise NotFoundError(
|
|
261
|
+
headers=dict(_response.headers),
|
|
262
|
+
body=typing.cast(
|
|
263
|
+
typing.Optional[typing.Any],
|
|
264
|
+
parse_obj_as(
|
|
265
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
266
|
+
object_=_response.json(),
|
|
267
|
+
),
|
|
268
|
+
),
|
|
269
|
+
)
|
|
270
|
+
if _response.status_code == 422:
|
|
271
|
+
raise UnprocessableEntityError(
|
|
272
|
+
headers=dict(_response.headers),
|
|
273
|
+
body=typing.cast(
|
|
274
|
+
typing.Optional[typing.Any],
|
|
275
|
+
parse_obj_as(
|
|
276
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
277
|
+
object_=_response.json(),
|
|
278
|
+
),
|
|
279
|
+
),
|
|
280
|
+
)
|
|
281
|
+
if _response.status_code == 500:
|
|
282
|
+
raise InternalServerError(
|
|
283
|
+
headers=dict(_response.headers),
|
|
284
|
+
body=typing.cast(
|
|
285
|
+
typing.Optional[typing.Any],
|
|
286
|
+
parse_obj_as(
|
|
287
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
288
|
+
object_=_response.json(),
|
|
289
|
+
),
|
|
290
|
+
),
|
|
291
|
+
)
|
|
292
|
+
if _response.status_code == 503:
|
|
293
|
+
raise ServiceUnavailableError(
|
|
294
|
+
headers=dict(_response.headers),
|
|
295
|
+
body=typing.cast(
|
|
296
|
+
typing.Optional[typing.Any],
|
|
297
|
+
parse_obj_as(
|
|
298
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
299
|
+
object_=_response.json(),
|
|
300
|
+
),
|
|
301
|
+
),
|
|
302
|
+
)
|
|
303
|
+
_response_json = _response.json()
|
|
304
|
+
except JSONDecodeError:
|
|
305
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
306
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
307
|
+
|
|
308
|
+
def graph_relations_by_source_id(
|
|
309
|
+
self,
|
|
310
|
+
*,
|
|
311
|
+
source_id: str,
|
|
312
|
+
tenant_id: typing.Optional[str] = None,
|
|
313
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
314
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
315
|
+
) -> HttpResponse[SourceGraphRelationsResponse]:
|
|
316
|
+
"""
|
|
317
|
+
Retrieve relations for a specific source.
|
|
318
|
+
|
|
319
|
+
Use this endpoint to fetch all relations associated with a specific source.
|
|
320
|
+
This is useful when you need to understand the relationships between entities within a source.
|
|
321
|
+
|
|
322
|
+
Provide the source ID in the request body along with your tenant information to get the relations for that source.
|
|
323
|
+
|
|
324
|
+
Parameters
|
|
325
|
+
----------
|
|
326
|
+
source_id : str
|
|
327
|
+
The source ID to fetch relations for
|
|
328
|
+
|
|
329
|
+
tenant_id : typing.Optional[str]
|
|
330
|
+
Unique identifier for the tenant/organization
|
|
331
|
+
|
|
332
|
+
sub_tenant_id : typing.Optional[str]
|
|
333
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
334
|
+
|
|
335
|
+
request_options : typing.Optional[RequestOptions]
|
|
336
|
+
Request-specific configuration.
|
|
337
|
+
|
|
338
|
+
Returns
|
|
339
|
+
-------
|
|
340
|
+
HttpResponse[SourceGraphRelationsResponse]
|
|
341
|
+
Successful Response
|
|
342
|
+
"""
|
|
343
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
344
|
+
"list/graph-relations-by-id",
|
|
345
|
+
method="GET",
|
|
346
|
+
params={
|
|
347
|
+
"source_id": source_id,
|
|
348
|
+
"tenant_id": tenant_id,
|
|
349
|
+
"sub_tenant_id": sub_tenant_id,
|
|
350
|
+
},
|
|
351
|
+
request_options=request_options,
|
|
352
|
+
)
|
|
353
|
+
try:
|
|
354
|
+
if 200 <= _response.status_code < 300:
|
|
355
|
+
_data = typing.cast(
|
|
356
|
+
SourceGraphRelationsResponse,
|
|
357
|
+
parse_obj_as(
|
|
358
|
+
type_=SourceGraphRelationsResponse, # type: ignore
|
|
359
|
+
object_=_response.json(),
|
|
360
|
+
),
|
|
361
|
+
)
|
|
362
|
+
return HttpResponse(response=_response, data=_data)
|
|
363
|
+
if _response.status_code == 400:
|
|
364
|
+
raise BadRequestError(
|
|
365
|
+
headers=dict(_response.headers),
|
|
366
|
+
body=typing.cast(
|
|
367
|
+
typing.Optional[typing.Any],
|
|
368
|
+
parse_obj_as(
|
|
369
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
370
|
+
object_=_response.json(),
|
|
371
|
+
),
|
|
372
|
+
),
|
|
373
|
+
)
|
|
374
|
+
if _response.status_code == 401:
|
|
375
|
+
raise UnauthorizedError(
|
|
376
|
+
headers=dict(_response.headers),
|
|
377
|
+
body=typing.cast(
|
|
378
|
+
typing.Optional[typing.Any],
|
|
379
|
+
parse_obj_as(
|
|
380
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
381
|
+
object_=_response.json(),
|
|
382
|
+
),
|
|
383
|
+
),
|
|
384
|
+
)
|
|
385
|
+
if _response.status_code == 403:
|
|
386
|
+
raise ForbiddenError(
|
|
387
|
+
headers=dict(_response.headers),
|
|
388
|
+
body=typing.cast(
|
|
389
|
+
typing.Optional[typing.Any],
|
|
390
|
+
parse_obj_as(
|
|
391
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
392
|
+
object_=_response.json(),
|
|
393
|
+
),
|
|
394
|
+
),
|
|
395
|
+
)
|
|
396
|
+
if _response.status_code == 404:
|
|
397
|
+
raise NotFoundError(
|
|
398
|
+
headers=dict(_response.headers),
|
|
399
|
+
body=typing.cast(
|
|
400
|
+
typing.Optional[typing.Any],
|
|
401
|
+
parse_obj_as(
|
|
402
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
403
|
+
object_=_response.json(),
|
|
404
|
+
),
|
|
405
|
+
),
|
|
406
|
+
)
|
|
407
|
+
if _response.status_code == 422:
|
|
408
|
+
raise UnprocessableEntityError(
|
|
409
|
+
headers=dict(_response.headers),
|
|
410
|
+
body=typing.cast(
|
|
411
|
+
typing.Optional[typing.Any],
|
|
412
|
+
parse_obj_as(
|
|
413
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
414
|
+
object_=_response.json(),
|
|
415
|
+
),
|
|
416
|
+
),
|
|
417
|
+
)
|
|
418
|
+
if _response.status_code == 500:
|
|
419
|
+
raise InternalServerError(
|
|
420
|
+
headers=dict(_response.headers),
|
|
421
|
+
body=typing.cast(
|
|
422
|
+
typing.Optional[typing.Any],
|
|
423
|
+
parse_obj_as(
|
|
424
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
425
|
+
object_=_response.json(),
|
|
426
|
+
),
|
|
427
|
+
),
|
|
428
|
+
)
|
|
429
|
+
if _response.status_code == 503:
|
|
430
|
+
raise ServiceUnavailableError(
|
|
431
|
+
headers=dict(_response.headers),
|
|
432
|
+
body=typing.cast(
|
|
433
|
+
typing.Optional[typing.Any],
|
|
434
|
+
parse_obj_as(
|
|
435
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
436
|
+
object_=_response.json(),
|
|
437
|
+
),
|
|
438
|
+
),
|
|
439
|
+
)
|
|
440
|
+
_response_json = _response.json()
|
|
441
|
+
except JSONDecodeError:
|
|
442
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
443
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
444
|
+
|
|
445
|
+
def source_content(
|
|
446
|
+
self,
|
|
447
|
+
*,
|
|
448
|
+
tenant_id: str,
|
|
449
|
+
source_id: str,
|
|
450
|
+
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
451
|
+
mode: typing.Optional[FetchMode] = OMIT,
|
|
452
|
+
expiry_seconds: typing.Optional[int] = OMIT,
|
|
453
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
454
|
+
) -> HttpResponse[SourceFetchResponse]:
|
|
455
|
+
"""
|
|
456
|
+
Fetch the content of a source ingested.
|
|
457
|
+
|
|
458
|
+
This endpoint can return:
|
|
459
|
+
- File content directly (as string or base64)
|
|
460
|
+
- A presigned URL to access the file
|
|
461
|
+
- Both content and presigned URL
|
|
462
|
+
|
|
463
|
+
Parameters
|
|
464
|
+
----------
|
|
465
|
+
tenant_id : str
|
|
466
|
+
Unique identifier for the tenant/organization
|
|
467
|
+
|
|
468
|
+
source_id : str
|
|
469
|
+
Source ID of the file to fetch
|
|
470
|
+
|
|
471
|
+
sub_tenant_id : typing.Optional[str]
|
|
472
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
473
|
+
|
|
474
|
+
mode : typing.Optional[FetchMode]
|
|
475
|
+
Fetch mode: 'content' returns file content, 'url' returns presigned URL, 'both' returns both
|
|
476
|
+
|
|
477
|
+
expiry_seconds : typing.Optional[int]
|
|
478
|
+
Expiry time in seconds for presigned URL (60-604800, default: 3600)
|
|
479
|
+
|
|
480
|
+
request_options : typing.Optional[RequestOptions]
|
|
481
|
+
Request-specific configuration.
|
|
482
|
+
|
|
483
|
+
Returns
|
|
484
|
+
-------
|
|
485
|
+
HttpResponse[SourceFetchResponse]
|
|
486
|
+
Successful Response
|
|
487
|
+
"""
|
|
488
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
489
|
+
"fetch/fetch-source-content",
|
|
490
|
+
method="POST",
|
|
491
|
+
json={
|
|
492
|
+
"tenant_id": tenant_id,
|
|
493
|
+
"sub_tenant_id": sub_tenant_id,
|
|
494
|
+
"source_id": source_id,
|
|
495
|
+
"mode": mode,
|
|
496
|
+
"expiry_seconds": expiry_seconds,
|
|
497
|
+
},
|
|
498
|
+
headers={
|
|
499
|
+
"content-type": "application/json",
|
|
500
|
+
},
|
|
501
|
+
request_options=request_options,
|
|
502
|
+
omit=OMIT,
|
|
503
|
+
)
|
|
504
|
+
try:
|
|
505
|
+
if 200 <= _response.status_code < 300:
|
|
506
|
+
_data = typing.cast(
|
|
507
|
+
SourceFetchResponse,
|
|
508
|
+
parse_obj_as(
|
|
509
|
+
type_=SourceFetchResponse, # type: ignore
|
|
510
|
+
object_=_response.json(),
|
|
511
|
+
),
|
|
512
|
+
)
|
|
513
|
+
return HttpResponse(response=_response, data=_data)
|
|
514
|
+
if _response.status_code == 400:
|
|
515
|
+
raise BadRequestError(
|
|
516
|
+
headers=dict(_response.headers),
|
|
517
|
+
body=typing.cast(
|
|
518
|
+
typing.Optional[typing.Any],
|
|
519
|
+
parse_obj_as(
|
|
520
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
521
|
+
object_=_response.json(),
|
|
522
|
+
),
|
|
523
|
+
),
|
|
524
|
+
)
|
|
525
|
+
if _response.status_code == 401:
|
|
526
|
+
raise UnauthorizedError(
|
|
527
|
+
headers=dict(_response.headers),
|
|
528
|
+
body=typing.cast(
|
|
529
|
+
typing.Optional[typing.Any],
|
|
530
|
+
parse_obj_as(
|
|
531
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
532
|
+
object_=_response.json(),
|
|
533
|
+
),
|
|
534
|
+
),
|
|
535
|
+
)
|
|
536
|
+
if _response.status_code == 403:
|
|
537
|
+
raise ForbiddenError(
|
|
538
|
+
headers=dict(_response.headers),
|
|
539
|
+
body=typing.cast(
|
|
540
|
+
typing.Optional[typing.Any],
|
|
541
|
+
parse_obj_as(
|
|
542
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
543
|
+
object_=_response.json(),
|
|
544
|
+
),
|
|
545
|
+
),
|
|
546
|
+
)
|
|
547
|
+
if _response.status_code == 404:
|
|
548
|
+
raise NotFoundError(
|
|
549
|
+
headers=dict(_response.headers),
|
|
550
|
+
body=typing.cast(
|
|
551
|
+
typing.Optional[typing.Any],
|
|
552
|
+
parse_obj_as(
|
|
553
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
554
|
+
object_=_response.json(),
|
|
555
|
+
),
|
|
556
|
+
),
|
|
557
|
+
)
|
|
558
|
+
if _response.status_code == 422:
|
|
559
|
+
raise UnprocessableEntityError(
|
|
560
|
+
headers=dict(_response.headers),
|
|
561
|
+
body=typing.cast(
|
|
562
|
+
typing.Optional[typing.Any],
|
|
563
|
+
parse_obj_as(
|
|
564
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
565
|
+
object_=_response.json(),
|
|
566
|
+
),
|
|
567
|
+
),
|
|
568
|
+
)
|
|
569
|
+
if _response.status_code == 500:
|
|
570
|
+
raise InternalServerError(
|
|
571
|
+
headers=dict(_response.headers),
|
|
572
|
+
body=typing.cast(
|
|
573
|
+
typing.Optional[typing.Any],
|
|
574
|
+
parse_obj_as(
|
|
575
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
576
|
+
object_=_response.json(),
|
|
577
|
+
),
|
|
578
|
+
),
|
|
579
|
+
)
|
|
580
|
+
if _response.status_code == 503:
|
|
581
|
+
raise ServiceUnavailableError(
|
|
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
|
+
_response_json = _response.json()
|
|
592
|
+
except JSONDecodeError:
|
|
593
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
594
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
class AsyncRawFetchClient:
|
|
598
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
599
|
+
self._client_wrapper = client_wrapper
|
|
600
|
+
|
|
601
|
+
async def sources(
|
|
602
|
+
self,
|
|
603
|
+
*,
|
|
604
|
+
tenant_id: str,
|
|
605
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
606
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
607
|
+
) -> AsyncHttpResponse[SourceListResponse]:
|
|
608
|
+
"""
|
|
609
|
+
Retrieve all sources for a specific tenant and subtenant combination.
|
|
610
|
+
|
|
611
|
+
Use this endpoint to fetch a complete list of all sources associated
|
|
612
|
+
with your tenant. This includes documents, files, and other content
|
|
613
|
+
you've uploaded for processing.
|
|
614
|
+
|
|
615
|
+
You can optionally specify a sub-tenant to narrow down the results to
|
|
616
|
+
sources within that specific sub-tenant scope.
|
|
617
|
+
|
|
618
|
+
Parameters
|
|
619
|
+
----------
|
|
620
|
+
tenant_id : str
|
|
621
|
+
Unique identifier for the tenant/organization
|
|
622
|
+
|
|
623
|
+
sub_tenant_id : typing.Optional[str]
|
|
624
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
625
|
+
|
|
626
|
+
request_options : typing.Optional[RequestOptions]
|
|
627
|
+
Request-specific configuration.
|
|
628
|
+
|
|
629
|
+
Returns
|
|
630
|
+
-------
|
|
631
|
+
AsyncHttpResponse[SourceListResponse]
|
|
632
|
+
Successful Response
|
|
633
|
+
"""
|
|
634
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
635
|
+
"list/list-sources",
|
|
636
|
+
method="GET",
|
|
637
|
+
params={
|
|
638
|
+
"tenant_id": tenant_id,
|
|
639
|
+
"sub_tenant_id": sub_tenant_id,
|
|
640
|
+
},
|
|
641
|
+
request_options=request_options,
|
|
642
|
+
)
|
|
643
|
+
try:
|
|
644
|
+
if 200 <= _response.status_code < 300:
|
|
645
|
+
_data = typing.cast(
|
|
646
|
+
SourceListResponse,
|
|
647
|
+
parse_obj_as(
|
|
648
|
+
type_=SourceListResponse, # type: ignore
|
|
649
|
+
object_=_response.json(),
|
|
650
|
+
),
|
|
651
|
+
)
|
|
652
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
653
|
+
if _response.status_code == 400:
|
|
654
|
+
raise BadRequestError(
|
|
655
|
+
headers=dict(_response.headers),
|
|
656
|
+
body=typing.cast(
|
|
657
|
+
typing.Optional[typing.Any],
|
|
658
|
+
parse_obj_as(
|
|
659
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
660
|
+
object_=_response.json(),
|
|
661
|
+
),
|
|
662
|
+
),
|
|
663
|
+
)
|
|
664
|
+
if _response.status_code == 401:
|
|
665
|
+
raise UnauthorizedError(
|
|
666
|
+
headers=dict(_response.headers),
|
|
667
|
+
body=typing.cast(
|
|
668
|
+
typing.Optional[typing.Any],
|
|
669
|
+
parse_obj_as(
|
|
670
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
671
|
+
object_=_response.json(),
|
|
672
|
+
),
|
|
673
|
+
),
|
|
674
|
+
)
|
|
675
|
+
if _response.status_code == 403:
|
|
676
|
+
raise ForbiddenError(
|
|
677
|
+
headers=dict(_response.headers),
|
|
678
|
+
body=typing.cast(
|
|
679
|
+
typing.Optional[typing.Any],
|
|
680
|
+
parse_obj_as(
|
|
681
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
682
|
+
object_=_response.json(),
|
|
683
|
+
),
|
|
684
|
+
),
|
|
685
|
+
)
|
|
686
|
+
if _response.status_code == 404:
|
|
687
|
+
raise NotFoundError(
|
|
688
|
+
headers=dict(_response.headers),
|
|
689
|
+
body=typing.cast(
|
|
690
|
+
typing.Optional[typing.Any],
|
|
691
|
+
parse_obj_as(
|
|
692
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
693
|
+
object_=_response.json(),
|
|
694
|
+
),
|
|
695
|
+
),
|
|
696
|
+
)
|
|
697
|
+
if _response.status_code == 422:
|
|
698
|
+
raise UnprocessableEntityError(
|
|
699
|
+
headers=dict(_response.headers),
|
|
700
|
+
body=typing.cast(
|
|
701
|
+
typing.Optional[typing.Any],
|
|
702
|
+
parse_obj_as(
|
|
703
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
704
|
+
object_=_response.json(),
|
|
705
|
+
),
|
|
706
|
+
),
|
|
707
|
+
)
|
|
708
|
+
if _response.status_code == 500:
|
|
709
|
+
raise InternalServerError(
|
|
710
|
+
headers=dict(_response.headers),
|
|
711
|
+
body=typing.cast(
|
|
712
|
+
typing.Optional[typing.Any],
|
|
713
|
+
parse_obj_as(
|
|
714
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
715
|
+
object_=_response.json(),
|
|
716
|
+
),
|
|
717
|
+
),
|
|
718
|
+
)
|
|
719
|
+
if _response.status_code == 503:
|
|
720
|
+
raise ServiceUnavailableError(
|
|
721
|
+
headers=dict(_response.headers),
|
|
722
|
+
body=typing.cast(
|
|
723
|
+
typing.Optional[typing.Any],
|
|
724
|
+
parse_obj_as(
|
|
725
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
726
|
+
object_=_response.json(),
|
|
727
|
+
),
|
|
728
|
+
),
|
|
729
|
+
)
|
|
730
|
+
_response_json = _response.json()
|
|
731
|
+
except JSONDecodeError:
|
|
732
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
733
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
734
|
+
|
|
735
|
+
async def source_by_ids(
|
|
736
|
+
self,
|
|
737
|
+
*,
|
|
738
|
+
source_ids: typing.Sequence[str],
|
|
739
|
+
tenant_id: str,
|
|
36
740
|
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
37
741
|
request_options: typing.Optional[RequestOptions] = None,
|
|
38
|
-
) ->
|
|
742
|
+
) -> AsyncHttpResponse[SourceListResponse]:
|
|
39
743
|
"""
|
|
744
|
+
Retrieve specific sources by their IDs.
|
|
745
|
+
|
|
746
|
+
Use this endpoint to fetch one or more sources by providing their
|
|
747
|
+
unique identifiers. This is useful when you need detailed information
|
|
748
|
+
about specific documents or content you've previously uploaded.
|
|
749
|
+
|
|
750
|
+
Provide the source IDs in the request body along with your tenant
|
|
751
|
+
information to get the exact sources you need.
|
|
752
|
+
|
|
40
753
|
Parameters
|
|
41
754
|
----------
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
file_type : str
|
|
755
|
+
source_ids : typing.Sequence[str]
|
|
756
|
+
List of source IDs to fetch.
|
|
45
757
|
|
|
46
758
|
tenant_id : str
|
|
47
|
-
|
|
48
|
-
return_content : typing.Optional[bool]
|
|
759
|
+
Tenant ID
|
|
49
760
|
|
|
50
761
|
sub_tenant_id : typing.Optional[str]
|
|
762
|
+
Sub-tenant ID
|
|
51
763
|
|
|
52
764
|
request_options : typing.Optional[RequestOptions]
|
|
53
765
|
Request-specific configuration.
|
|
54
766
|
|
|
55
767
|
Returns
|
|
56
768
|
-------
|
|
57
|
-
|
|
769
|
+
AsyncHttpResponse[SourceListResponse]
|
|
58
770
|
Successful Response
|
|
59
771
|
"""
|
|
60
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
61
|
-
"
|
|
772
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
773
|
+
"list/list-sources-by-id",
|
|
62
774
|
method="POST",
|
|
63
775
|
json={
|
|
64
|
-
"
|
|
65
|
-
"file_type": file_type,
|
|
776
|
+
"source_ids": source_ids,
|
|
66
777
|
"tenant_id": tenant_id,
|
|
67
|
-
"return_content": return_content,
|
|
68
778
|
"sub_tenant_id": sub_tenant_id,
|
|
69
779
|
},
|
|
70
780
|
headers={
|
|
@@ -76,20 +786,20 @@ class RawFetchClient:
|
|
|
76
786
|
try:
|
|
77
787
|
if 200 <= _response.status_code < 300:
|
|
78
788
|
_data = typing.cast(
|
|
79
|
-
|
|
789
|
+
SourceListResponse,
|
|
80
790
|
parse_obj_as(
|
|
81
|
-
type_=
|
|
791
|
+
type_=SourceListResponse, # type: ignore
|
|
82
792
|
object_=_response.json(),
|
|
83
793
|
),
|
|
84
794
|
)
|
|
85
|
-
return
|
|
795
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
86
796
|
if _response.status_code == 400:
|
|
87
797
|
raise BadRequestError(
|
|
88
798
|
headers=dict(_response.headers),
|
|
89
799
|
body=typing.cast(
|
|
90
|
-
|
|
800
|
+
typing.Optional[typing.Any],
|
|
91
801
|
parse_obj_as(
|
|
92
|
-
type_=
|
|
802
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
93
803
|
object_=_response.json(),
|
|
94
804
|
),
|
|
95
805
|
),
|
|
@@ -98,9 +808,9 @@ class RawFetchClient:
|
|
|
98
808
|
raise UnauthorizedError(
|
|
99
809
|
headers=dict(_response.headers),
|
|
100
810
|
body=typing.cast(
|
|
101
|
-
|
|
811
|
+
typing.Optional[typing.Any],
|
|
102
812
|
parse_obj_as(
|
|
103
|
-
type_=
|
|
813
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
104
814
|
object_=_response.json(),
|
|
105
815
|
),
|
|
106
816
|
),
|
|
@@ -109,9 +819,9 @@ class RawFetchClient:
|
|
|
109
819
|
raise ForbiddenError(
|
|
110
820
|
headers=dict(_response.headers),
|
|
111
821
|
body=typing.cast(
|
|
112
|
-
|
|
822
|
+
typing.Optional[typing.Any],
|
|
113
823
|
parse_obj_as(
|
|
114
|
-
type_=
|
|
824
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
115
825
|
object_=_response.json(),
|
|
116
826
|
),
|
|
117
827
|
),
|
|
@@ -120,9 +830,9 @@ class RawFetchClient:
|
|
|
120
830
|
raise NotFoundError(
|
|
121
831
|
headers=dict(_response.headers),
|
|
122
832
|
body=typing.cast(
|
|
123
|
-
|
|
833
|
+
typing.Optional[typing.Any],
|
|
124
834
|
parse_obj_as(
|
|
125
|
-
type_=
|
|
835
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
126
836
|
object_=_response.json(),
|
|
127
837
|
),
|
|
128
838
|
),
|
|
@@ -142,9 +852,9 @@ class RawFetchClient:
|
|
|
142
852
|
raise InternalServerError(
|
|
143
853
|
headers=dict(_response.headers),
|
|
144
854
|
body=typing.cast(
|
|
145
|
-
|
|
855
|
+
typing.Optional[typing.Any],
|
|
146
856
|
parse_obj_as(
|
|
147
|
-
type_=
|
|
857
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
148
858
|
object_=_response.json(),
|
|
149
859
|
),
|
|
150
860
|
),
|
|
@@ -153,9 +863,9 @@ class RawFetchClient:
|
|
|
153
863
|
raise ServiceUnavailableError(
|
|
154
864
|
headers=dict(_response.headers),
|
|
155
865
|
body=typing.cast(
|
|
156
|
-
|
|
866
|
+
typing.Optional[typing.Any],
|
|
157
867
|
parse_obj_as(
|
|
158
|
-
type_=
|
|
868
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
159
869
|
object_=_response.json(),
|
|
160
870
|
),
|
|
161
871
|
),
|
|
@@ -165,51 +875,195 @@ class RawFetchClient:
|
|
|
165
875
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
166
876
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
167
877
|
|
|
878
|
+
async def graph_relations_by_source_id(
|
|
879
|
+
self,
|
|
880
|
+
*,
|
|
881
|
+
source_id: str,
|
|
882
|
+
tenant_id: typing.Optional[str] = None,
|
|
883
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
884
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
885
|
+
) -> AsyncHttpResponse[SourceGraphRelationsResponse]:
|
|
886
|
+
"""
|
|
887
|
+
Retrieve relations for a specific source.
|
|
168
888
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
self._client_wrapper = client_wrapper
|
|
889
|
+
Use this endpoint to fetch all relations associated with a specific source.
|
|
890
|
+
This is useful when you need to understand the relationships between entities within a source.
|
|
172
891
|
|
|
173
|
-
|
|
892
|
+
Provide the source ID in the request body along with your tenant information to get the relations for that source.
|
|
893
|
+
|
|
894
|
+
Parameters
|
|
895
|
+
----------
|
|
896
|
+
source_id : str
|
|
897
|
+
The source ID to fetch relations for
|
|
898
|
+
|
|
899
|
+
tenant_id : typing.Optional[str]
|
|
900
|
+
Unique identifier for the tenant/organization
|
|
901
|
+
|
|
902
|
+
sub_tenant_id : typing.Optional[str]
|
|
903
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
904
|
+
|
|
905
|
+
request_options : typing.Optional[RequestOptions]
|
|
906
|
+
Request-specific configuration.
|
|
907
|
+
|
|
908
|
+
Returns
|
|
909
|
+
-------
|
|
910
|
+
AsyncHttpResponse[SourceGraphRelationsResponse]
|
|
911
|
+
Successful Response
|
|
912
|
+
"""
|
|
913
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
914
|
+
"list/graph-relations-by-id",
|
|
915
|
+
method="GET",
|
|
916
|
+
params={
|
|
917
|
+
"source_id": source_id,
|
|
918
|
+
"tenant_id": tenant_id,
|
|
919
|
+
"sub_tenant_id": sub_tenant_id,
|
|
920
|
+
},
|
|
921
|
+
request_options=request_options,
|
|
922
|
+
)
|
|
923
|
+
try:
|
|
924
|
+
if 200 <= _response.status_code < 300:
|
|
925
|
+
_data = typing.cast(
|
|
926
|
+
SourceGraphRelationsResponse,
|
|
927
|
+
parse_obj_as(
|
|
928
|
+
type_=SourceGraphRelationsResponse, # type: ignore
|
|
929
|
+
object_=_response.json(),
|
|
930
|
+
),
|
|
931
|
+
)
|
|
932
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
933
|
+
if _response.status_code == 400:
|
|
934
|
+
raise BadRequestError(
|
|
935
|
+
headers=dict(_response.headers),
|
|
936
|
+
body=typing.cast(
|
|
937
|
+
typing.Optional[typing.Any],
|
|
938
|
+
parse_obj_as(
|
|
939
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
940
|
+
object_=_response.json(),
|
|
941
|
+
),
|
|
942
|
+
),
|
|
943
|
+
)
|
|
944
|
+
if _response.status_code == 401:
|
|
945
|
+
raise UnauthorizedError(
|
|
946
|
+
headers=dict(_response.headers),
|
|
947
|
+
body=typing.cast(
|
|
948
|
+
typing.Optional[typing.Any],
|
|
949
|
+
parse_obj_as(
|
|
950
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
951
|
+
object_=_response.json(),
|
|
952
|
+
),
|
|
953
|
+
),
|
|
954
|
+
)
|
|
955
|
+
if _response.status_code == 403:
|
|
956
|
+
raise ForbiddenError(
|
|
957
|
+
headers=dict(_response.headers),
|
|
958
|
+
body=typing.cast(
|
|
959
|
+
typing.Optional[typing.Any],
|
|
960
|
+
parse_obj_as(
|
|
961
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
962
|
+
object_=_response.json(),
|
|
963
|
+
),
|
|
964
|
+
),
|
|
965
|
+
)
|
|
966
|
+
if _response.status_code == 404:
|
|
967
|
+
raise NotFoundError(
|
|
968
|
+
headers=dict(_response.headers),
|
|
969
|
+
body=typing.cast(
|
|
970
|
+
typing.Optional[typing.Any],
|
|
971
|
+
parse_obj_as(
|
|
972
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
973
|
+
object_=_response.json(),
|
|
974
|
+
),
|
|
975
|
+
),
|
|
976
|
+
)
|
|
977
|
+
if _response.status_code == 422:
|
|
978
|
+
raise UnprocessableEntityError(
|
|
979
|
+
headers=dict(_response.headers),
|
|
980
|
+
body=typing.cast(
|
|
981
|
+
typing.Optional[typing.Any],
|
|
982
|
+
parse_obj_as(
|
|
983
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
984
|
+
object_=_response.json(),
|
|
985
|
+
),
|
|
986
|
+
),
|
|
987
|
+
)
|
|
988
|
+
if _response.status_code == 500:
|
|
989
|
+
raise InternalServerError(
|
|
990
|
+
headers=dict(_response.headers),
|
|
991
|
+
body=typing.cast(
|
|
992
|
+
typing.Optional[typing.Any],
|
|
993
|
+
parse_obj_as(
|
|
994
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
995
|
+
object_=_response.json(),
|
|
996
|
+
),
|
|
997
|
+
),
|
|
998
|
+
)
|
|
999
|
+
if _response.status_code == 503:
|
|
1000
|
+
raise ServiceUnavailableError(
|
|
1001
|
+
headers=dict(_response.headers),
|
|
1002
|
+
body=typing.cast(
|
|
1003
|
+
typing.Optional[typing.Any],
|
|
1004
|
+
parse_obj_as(
|
|
1005
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1006
|
+
object_=_response.json(),
|
|
1007
|
+
),
|
|
1008
|
+
),
|
|
1009
|
+
)
|
|
1010
|
+
_response_json = _response.json()
|
|
1011
|
+
except JSONDecodeError:
|
|
1012
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1013
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1014
|
+
|
|
1015
|
+
async def source_content(
|
|
174
1016
|
self,
|
|
175
1017
|
*,
|
|
176
|
-
file_id: str,
|
|
177
|
-
file_type: str,
|
|
178
1018
|
tenant_id: str,
|
|
179
|
-
|
|
1019
|
+
source_id: str,
|
|
180
1020
|
sub_tenant_id: typing.Optional[str] = OMIT,
|
|
1021
|
+
mode: typing.Optional[FetchMode] = OMIT,
|
|
1022
|
+
expiry_seconds: typing.Optional[int] = OMIT,
|
|
181
1023
|
request_options: typing.Optional[RequestOptions] = None,
|
|
182
|
-
) -> AsyncHttpResponse[
|
|
1024
|
+
) -> AsyncHttpResponse[SourceFetchResponse]:
|
|
183
1025
|
"""
|
|
184
|
-
|
|
185
|
-
----------
|
|
186
|
-
file_id : str
|
|
1026
|
+
Fetch the content of a source ingested.
|
|
187
1027
|
|
|
188
|
-
|
|
1028
|
+
This endpoint can return:
|
|
1029
|
+
- File content directly (as string or base64)
|
|
1030
|
+
- A presigned URL to access the file
|
|
1031
|
+
- Both content and presigned URL
|
|
189
1032
|
|
|
1033
|
+
Parameters
|
|
1034
|
+
----------
|
|
190
1035
|
tenant_id : str
|
|
1036
|
+
Unique identifier for the tenant/organization
|
|
191
1037
|
|
|
192
|
-
|
|
1038
|
+
source_id : str
|
|
1039
|
+
Source ID of the file to fetch
|
|
193
1040
|
|
|
194
1041
|
sub_tenant_id : typing.Optional[str]
|
|
1042
|
+
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
1043
|
+
|
|
1044
|
+
mode : typing.Optional[FetchMode]
|
|
1045
|
+
Fetch mode: 'content' returns file content, 'url' returns presigned URL, 'both' returns both
|
|
1046
|
+
|
|
1047
|
+
expiry_seconds : typing.Optional[int]
|
|
1048
|
+
Expiry time in seconds for presigned URL (60-604800, default: 3600)
|
|
195
1049
|
|
|
196
1050
|
request_options : typing.Optional[RequestOptions]
|
|
197
1051
|
Request-specific configuration.
|
|
198
1052
|
|
|
199
1053
|
Returns
|
|
200
1054
|
-------
|
|
201
|
-
AsyncHttpResponse[
|
|
1055
|
+
AsyncHttpResponse[SourceFetchResponse]
|
|
202
1056
|
Successful Response
|
|
203
1057
|
"""
|
|
204
1058
|
_response = await self._client_wrapper.httpx_client.request(
|
|
205
|
-
"fetch/
|
|
1059
|
+
"fetch/fetch-source-content",
|
|
206
1060
|
method="POST",
|
|
207
1061
|
json={
|
|
208
|
-
"file_id": file_id,
|
|
209
|
-
"file_type": file_type,
|
|
210
1062
|
"tenant_id": tenant_id,
|
|
211
|
-
"return_content": return_content,
|
|
212
1063
|
"sub_tenant_id": sub_tenant_id,
|
|
1064
|
+
"source_id": source_id,
|
|
1065
|
+
"mode": mode,
|
|
1066
|
+
"expiry_seconds": expiry_seconds,
|
|
213
1067
|
},
|
|
214
1068
|
headers={
|
|
215
1069
|
"content-type": "application/json",
|
|
@@ -220,9 +1074,9 @@ class AsyncRawFetchClient:
|
|
|
220
1074
|
try:
|
|
221
1075
|
if 200 <= _response.status_code < 300:
|
|
222
1076
|
_data = typing.cast(
|
|
223
|
-
|
|
1077
|
+
SourceFetchResponse,
|
|
224
1078
|
parse_obj_as(
|
|
225
|
-
type_=
|
|
1079
|
+
type_=SourceFetchResponse, # type: ignore
|
|
226
1080
|
object_=_response.json(),
|
|
227
1081
|
),
|
|
228
1082
|
)
|
|
@@ -231,9 +1085,9 @@ class AsyncRawFetchClient:
|
|
|
231
1085
|
raise BadRequestError(
|
|
232
1086
|
headers=dict(_response.headers),
|
|
233
1087
|
body=typing.cast(
|
|
234
|
-
|
|
1088
|
+
typing.Optional[typing.Any],
|
|
235
1089
|
parse_obj_as(
|
|
236
|
-
type_=
|
|
1090
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
237
1091
|
object_=_response.json(),
|
|
238
1092
|
),
|
|
239
1093
|
),
|
|
@@ -242,9 +1096,9 @@ class AsyncRawFetchClient:
|
|
|
242
1096
|
raise UnauthorizedError(
|
|
243
1097
|
headers=dict(_response.headers),
|
|
244
1098
|
body=typing.cast(
|
|
245
|
-
|
|
1099
|
+
typing.Optional[typing.Any],
|
|
246
1100
|
parse_obj_as(
|
|
247
|
-
type_=
|
|
1101
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
248
1102
|
object_=_response.json(),
|
|
249
1103
|
),
|
|
250
1104
|
),
|
|
@@ -253,9 +1107,9 @@ class AsyncRawFetchClient:
|
|
|
253
1107
|
raise ForbiddenError(
|
|
254
1108
|
headers=dict(_response.headers),
|
|
255
1109
|
body=typing.cast(
|
|
256
|
-
|
|
1110
|
+
typing.Optional[typing.Any],
|
|
257
1111
|
parse_obj_as(
|
|
258
|
-
type_=
|
|
1112
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
259
1113
|
object_=_response.json(),
|
|
260
1114
|
),
|
|
261
1115
|
),
|
|
@@ -264,9 +1118,9 @@ class AsyncRawFetchClient:
|
|
|
264
1118
|
raise NotFoundError(
|
|
265
1119
|
headers=dict(_response.headers),
|
|
266
1120
|
body=typing.cast(
|
|
267
|
-
|
|
1121
|
+
typing.Optional[typing.Any],
|
|
268
1122
|
parse_obj_as(
|
|
269
|
-
type_=
|
|
1123
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
270
1124
|
object_=_response.json(),
|
|
271
1125
|
),
|
|
272
1126
|
),
|
|
@@ -286,9 +1140,9 @@ class AsyncRawFetchClient:
|
|
|
286
1140
|
raise InternalServerError(
|
|
287
1141
|
headers=dict(_response.headers),
|
|
288
1142
|
body=typing.cast(
|
|
289
|
-
|
|
1143
|
+
typing.Optional[typing.Any],
|
|
290
1144
|
parse_obj_as(
|
|
291
|
-
type_=
|
|
1145
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
292
1146
|
object_=_response.json(),
|
|
293
1147
|
),
|
|
294
1148
|
),
|
|
@@ -297,9 +1151,9 @@ class AsyncRawFetchClient:
|
|
|
297
1151
|
raise ServiceUnavailableError(
|
|
298
1152
|
headers=dict(_response.headers),
|
|
299
1153
|
body=typing.cast(
|
|
300
|
-
|
|
1154
|
+
typing.Optional[typing.Any],
|
|
301
1155
|
parse_obj_as(
|
|
302
|
-
type_=
|
|
1156
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
303
1157
|
object_=_response.json(),
|
|
304
1158
|
),
|
|
305
1159
|
),
|