usecortex-ai 0.1.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.
- cortex_ai/__init__.py +103 -0
- cortex_ai/client.py +244 -0
- cortex_ai/core/__init__.py +52 -0
- cortex_ai/core/api_error.py +23 -0
- cortex_ai/core/client_wrapper.py +84 -0
- cortex_ai/core/datetime_utils.py +28 -0
- cortex_ai/core/file.py +67 -0
- cortex_ai/core/force_multipart.py +18 -0
- cortex_ai/core/http_client.py +543 -0
- cortex_ai/core/http_response.py +55 -0
- cortex_ai/core/jsonable_encoder.py +100 -0
- cortex_ai/core/pydantic_utilities.py +258 -0
- cortex_ai/core/query_encoder.py +58 -0
- cortex_ai/core/remove_none_from_dict.py +11 -0
- cortex_ai/core/request_options.py +35 -0
- cortex_ai/core/serialization.py +276 -0
- cortex_ai/embeddings/__init__.py +4 -0
- cortex_ai/embeddings/client.py +442 -0
- cortex_ai/embeddings/raw_client.py +1153 -0
- cortex_ai/environment.py +7 -0
- cortex_ai/errors/__init__.py +21 -0
- cortex_ai/errors/bad_request_error.py +11 -0
- cortex_ai/errors/forbidden_error.py +11 -0
- cortex_ai/errors/internal_server_error.py +11 -0
- cortex_ai/errors/not_found_error.py +11 -0
- cortex_ai/errors/service_unavailable_error.py +11 -0
- cortex_ai/errors/unauthorized_error.py +11 -0
- cortex_ai/errors/unprocessable_entity_error.py +10 -0
- cortex_ai/fetch/__init__.py +4 -0
- cortex_ai/fetch/client.py +143 -0
- cortex_ai/fetch/raw_client.py +310 -0
- cortex_ai/raw_client.py +90 -0
- cortex_ai/search/__init__.py +7 -0
- cortex_ai/search/client.py +536 -0
- cortex_ai/search/raw_client.py +1064 -0
- cortex_ai/search/types/__init__.py +7 -0
- cortex_ai/search/types/alpha.py +5 -0
- cortex_ai/sources/__init__.py +4 -0
- cortex_ai/sources/client.py +187 -0
- cortex_ai/sources/raw_client.py +532 -0
- cortex_ai/tenant/__init__.py +4 -0
- cortex_ai/tenant/client.py +120 -0
- cortex_ai/tenant/raw_client.py +283 -0
- cortex_ai/types/__init__.py +69 -0
- cortex_ai/types/actual_error_response.py +20 -0
- cortex_ai/types/app_sources_upload_data.py +22 -0
- cortex_ai/types/attachment_model.py +26 -0
- cortex_ai/types/batch_upload_data.py +22 -0
- cortex_ai/types/bm_25_operator_type.py +5 -0
- cortex_ai/types/content_model.py +26 -0
- cortex_ai/types/delete_memory_request.py +21 -0
- cortex_ai/types/embeddings_create_collection_data.py +22 -0
- cortex_ai/types/embeddings_delete_data.py +22 -0
- cortex_ai/types/embeddings_get_data.py +22 -0
- cortex_ai/types/embeddings_search_data.py +22 -0
- cortex_ai/types/error_response.py +22 -0
- cortex_ai/types/extended_context.py +20 -0
- cortex_ai/types/fetch_content_data.py +23 -0
- cortex_ai/types/file_upload_result.py +20 -0
- cortex_ai/types/full_text_search_data.py +22 -0
- cortex_ai/types/http_validation_error.py +20 -0
- cortex_ai/types/list_sources_response.py +22 -0
- cortex_ai/types/markdown_upload_request.py +21 -0
- cortex_ai/types/processing_status.py +22 -0
- cortex_ai/types/related_chunk.py +22 -0
- cortex_ai/types/search_chunk.py +34 -0
- cortex_ai/types/search_data.py +22 -0
- cortex_ai/types/single_upload_data.py +21 -0
- cortex_ai/types/source.py +32 -0
- cortex_ai/types/source_content.py +26 -0
- cortex_ai/types/source_model.py +32 -0
- cortex_ai/types/tenant_create_data.py +22 -0
- cortex_ai/types/tenant_stats.py +23 -0
- cortex_ai/types/validation_error.py +22 -0
- cortex_ai/types/validation_error_loc_item.py +5 -0
- cortex_ai/upload/__init__.py +4 -0
- cortex_ai/upload/client.py +1572 -0
- cortex_ai/upload/raw_client.py +4202 -0
- cortex_ai/user/__init__.py +4 -0
- cortex_ai/user/client.py +125 -0
- cortex_ai/user/raw_client.py +300 -0
- cortex_ai/user_memory/__init__.py +4 -0
- cortex_ai/user_memory/client.py +443 -0
- cortex_ai/user_memory/raw_client.py +651 -0
- usecortex_ai-0.1.0.dist-info/METADATA +136 -0
- usecortex_ai-0.1.0.dist-info/RECORD +89 -0
- usecortex_ai-0.1.0.dist-info/WHEEL +5 -0
- usecortex_ai-0.1.0.dist-info/licenses/LICENSE +22 -0
- usecortex_ai-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,532 @@
|
|
|
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.pydantic_utilities import parse_obj_as
|
|
10
|
+
from ..core.request_options import RequestOptions
|
|
11
|
+
from ..errors.bad_request_error import BadRequestError
|
|
12
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
13
|
+
from ..errors.internal_server_error import InternalServerError
|
|
14
|
+
from ..errors.not_found_error import NotFoundError
|
|
15
|
+
from ..errors.service_unavailable_error import ServiceUnavailableError
|
|
16
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
17
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
18
|
+
from ..types.actual_error_response import ActualErrorResponse
|
|
19
|
+
from ..types.list_sources_response import ListSourcesResponse
|
|
20
|
+
|
|
21
|
+
# this is used as the default value for optional parameters
|
|
22
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RawSourcesClient:
|
|
26
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
27
|
+
self._client_wrapper = client_wrapper
|
|
28
|
+
|
|
29
|
+
def get_all(
|
|
30
|
+
self,
|
|
31
|
+
*,
|
|
32
|
+
tenant_id: str,
|
|
33
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
34
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
35
|
+
) -> HttpResponse[ListSourcesResponse]:
|
|
36
|
+
"""
|
|
37
|
+
Parameters
|
|
38
|
+
----------
|
|
39
|
+
tenant_id : str
|
|
40
|
+
|
|
41
|
+
sub_tenant_id : typing.Optional[str]
|
|
42
|
+
|
|
43
|
+
request_options : typing.Optional[RequestOptions]
|
|
44
|
+
Request-specific configuration.
|
|
45
|
+
|
|
46
|
+
Returns
|
|
47
|
+
-------
|
|
48
|
+
HttpResponse[ListSourcesResponse]
|
|
49
|
+
Successful Response
|
|
50
|
+
"""
|
|
51
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
52
|
+
"list/sources",
|
|
53
|
+
method="GET",
|
|
54
|
+
params={
|
|
55
|
+
"tenant_id": tenant_id,
|
|
56
|
+
"sub_tenant_id": sub_tenant_id,
|
|
57
|
+
},
|
|
58
|
+
request_options=request_options,
|
|
59
|
+
)
|
|
60
|
+
try:
|
|
61
|
+
if 200 <= _response.status_code < 300:
|
|
62
|
+
_data = typing.cast(
|
|
63
|
+
ListSourcesResponse,
|
|
64
|
+
parse_obj_as(
|
|
65
|
+
type_=ListSourcesResponse, # type: ignore
|
|
66
|
+
object_=_response.json(),
|
|
67
|
+
),
|
|
68
|
+
)
|
|
69
|
+
return HttpResponse(response=_response, data=_data)
|
|
70
|
+
if _response.status_code == 400:
|
|
71
|
+
raise BadRequestError(
|
|
72
|
+
headers=dict(_response.headers),
|
|
73
|
+
body=typing.cast(
|
|
74
|
+
ActualErrorResponse,
|
|
75
|
+
parse_obj_as(
|
|
76
|
+
type_=ActualErrorResponse, # type: ignore
|
|
77
|
+
object_=_response.json(),
|
|
78
|
+
),
|
|
79
|
+
),
|
|
80
|
+
)
|
|
81
|
+
if _response.status_code == 401:
|
|
82
|
+
raise UnauthorizedError(
|
|
83
|
+
headers=dict(_response.headers),
|
|
84
|
+
body=typing.cast(
|
|
85
|
+
ActualErrorResponse,
|
|
86
|
+
parse_obj_as(
|
|
87
|
+
type_=ActualErrorResponse, # type: ignore
|
|
88
|
+
object_=_response.json(),
|
|
89
|
+
),
|
|
90
|
+
),
|
|
91
|
+
)
|
|
92
|
+
if _response.status_code == 403:
|
|
93
|
+
raise ForbiddenError(
|
|
94
|
+
headers=dict(_response.headers),
|
|
95
|
+
body=typing.cast(
|
|
96
|
+
ActualErrorResponse,
|
|
97
|
+
parse_obj_as(
|
|
98
|
+
type_=ActualErrorResponse, # type: ignore
|
|
99
|
+
object_=_response.json(),
|
|
100
|
+
),
|
|
101
|
+
),
|
|
102
|
+
)
|
|
103
|
+
if _response.status_code == 404:
|
|
104
|
+
raise NotFoundError(
|
|
105
|
+
headers=dict(_response.headers),
|
|
106
|
+
body=typing.cast(
|
|
107
|
+
ActualErrorResponse,
|
|
108
|
+
parse_obj_as(
|
|
109
|
+
type_=ActualErrorResponse, # type: ignore
|
|
110
|
+
object_=_response.json(),
|
|
111
|
+
),
|
|
112
|
+
),
|
|
113
|
+
)
|
|
114
|
+
if _response.status_code == 422:
|
|
115
|
+
raise UnprocessableEntityError(
|
|
116
|
+
headers=dict(_response.headers),
|
|
117
|
+
body=typing.cast(
|
|
118
|
+
typing.Optional[typing.Any],
|
|
119
|
+
parse_obj_as(
|
|
120
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
121
|
+
object_=_response.json(),
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
)
|
|
125
|
+
if _response.status_code == 500:
|
|
126
|
+
raise InternalServerError(
|
|
127
|
+
headers=dict(_response.headers),
|
|
128
|
+
body=typing.cast(
|
|
129
|
+
ActualErrorResponse,
|
|
130
|
+
parse_obj_as(
|
|
131
|
+
type_=ActualErrorResponse, # type: ignore
|
|
132
|
+
object_=_response.json(),
|
|
133
|
+
),
|
|
134
|
+
),
|
|
135
|
+
)
|
|
136
|
+
if _response.status_code == 503:
|
|
137
|
+
raise ServiceUnavailableError(
|
|
138
|
+
headers=dict(_response.headers),
|
|
139
|
+
body=typing.cast(
|
|
140
|
+
ActualErrorResponse,
|
|
141
|
+
parse_obj_as(
|
|
142
|
+
type_=ActualErrorResponse, # type: ignore
|
|
143
|
+
object_=_response.json(),
|
|
144
|
+
),
|
|
145
|
+
),
|
|
146
|
+
)
|
|
147
|
+
_response_json = _response.json()
|
|
148
|
+
except JSONDecodeError:
|
|
149
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
150
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
151
|
+
|
|
152
|
+
def get_by_ids(
|
|
153
|
+
self,
|
|
154
|
+
*,
|
|
155
|
+
tenant_id: str,
|
|
156
|
+
source_ids: typing.Sequence[str],
|
|
157
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
158
|
+
) -> HttpResponse[ListSourcesResponse]:
|
|
159
|
+
"""
|
|
160
|
+
Parameters
|
|
161
|
+
----------
|
|
162
|
+
tenant_id : str
|
|
163
|
+
|
|
164
|
+
source_ids : typing.Sequence[str]
|
|
165
|
+
|
|
166
|
+
request_options : typing.Optional[RequestOptions]
|
|
167
|
+
Request-specific configuration.
|
|
168
|
+
|
|
169
|
+
Returns
|
|
170
|
+
-------
|
|
171
|
+
HttpResponse[ListSourcesResponse]
|
|
172
|
+
Successful Response
|
|
173
|
+
"""
|
|
174
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
175
|
+
"list/sources_by_id",
|
|
176
|
+
method="POST",
|
|
177
|
+
json={
|
|
178
|
+
"tenant_id": tenant_id,
|
|
179
|
+
"source_ids": source_ids,
|
|
180
|
+
},
|
|
181
|
+
headers={
|
|
182
|
+
"content-type": "application/json",
|
|
183
|
+
},
|
|
184
|
+
request_options=request_options,
|
|
185
|
+
omit=OMIT,
|
|
186
|
+
)
|
|
187
|
+
try:
|
|
188
|
+
if 200 <= _response.status_code < 300:
|
|
189
|
+
_data = typing.cast(
|
|
190
|
+
ListSourcesResponse,
|
|
191
|
+
parse_obj_as(
|
|
192
|
+
type_=ListSourcesResponse, # type: ignore
|
|
193
|
+
object_=_response.json(),
|
|
194
|
+
),
|
|
195
|
+
)
|
|
196
|
+
return HttpResponse(response=_response, data=_data)
|
|
197
|
+
if _response.status_code == 400:
|
|
198
|
+
raise BadRequestError(
|
|
199
|
+
headers=dict(_response.headers),
|
|
200
|
+
body=typing.cast(
|
|
201
|
+
ActualErrorResponse,
|
|
202
|
+
parse_obj_as(
|
|
203
|
+
type_=ActualErrorResponse, # type: ignore
|
|
204
|
+
object_=_response.json(),
|
|
205
|
+
),
|
|
206
|
+
),
|
|
207
|
+
)
|
|
208
|
+
if _response.status_code == 401:
|
|
209
|
+
raise UnauthorizedError(
|
|
210
|
+
headers=dict(_response.headers),
|
|
211
|
+
body=typing.cast(
|
|
212
|
+
ActualErrorResponse,
|
|
213
|
+
parse_obj_as(
|
|
214
|
+
type_=ActualErrorResponse, # type: ignore
|
|
215
|
+
object_=_response.json(),
|
|
216
|
+
),
|
|
217
|
+
),
|
|
218
|
+
)
|
|
219
|
+
if _response.status_code == 403:
|
|
220
|
+
raise ForbiddenError(
|
|
221
|
+
headers=dict(_response.headers),
|
|
222
|
+
body=typing.cast(
|
|
223
|
+
ActualErrorResponse,
|
|
224
|
+
parse_obj_as(
|
|
225
|
+
type_=ActualErrorResponse, # type: ignore
|
|
226
|
+
object_=_response.json(),
|
|
227
|
+
),
|
|
228
|
+
),
|
|
229
|
+
)
|
|
230
|
+
if _response.status_code == 404:
|
|
231
|
+
raise NotFoundError(
|
|
232
|
+
headers=dict(_response.headers),
|
|
233
|
+
body=typing.cast(
|
|
234
|
+
ActualErrorResponse,
|
|
235
|
+
parse_obj_as(
|
|
236
|
+
type_=ActualErrorResponse, # type: ignore
|
|
237
|
+
object_=_response.json(),
|
|
238
|
+
),
|
|
239
|
+
),
|
|
240
|
+
)
|
|
241
|
+
if _response.status_code == 422:
|
|
242
|
+
raise UnprocessableEntityError(
|
|
243
|
+
headers=dict(_response.headers),
|
|
244
|
+
body=typing.cast(
|
|
245
|
+
typing.Optional[typing.Any],
|
|
246
|
+
parse_obj_as(
|
|
247
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
248
|
+
object_=_response.json(),
|
|
249
|
+
),
|
|
250
|
+
),
|
|
251
|
+
)
|
|
252
|
+
if _response.status_code == 500:
|
|
253
|
+
raise InternalServerError(
|
|
254
|
+
headers=dict(_response.headers),
|
|
255
|
+
body=typing.cast(
|
|
256
|
+
ActualErrorResponse,
|
|
257
|
+
parse_obj_as(
|
|
258
|
+
type_=ActualErrorResponse, # type: ignore
|
|
259
|
+
object_=_response.json(),
|
|
260
|
+
),
|
|
261
|
+
),
|
|
262
|
+
)
|
|
263
|
+
if _response.status_code == 503:
|
|
264
|
+
raise ServiceUnavailableError(
|
|
265
|
+
headers=dict(_response.headers),
|
|
266
|
+
body=typing.cast(
|
|
267
|
+
ActualErrorResponse,
|
|
268
|
+
parse_obj_as(
|
|
269
|
+
type_=ActualErrorResponse, # type: ignore
|
|
270
|
+
object_=_response.json(),
|
|
271
|
+
),
|
|
272
|
+
),
|
|
273
|
+
)
|
|
274
|
+
_response_json = _response.json()
|
|
275
|
+
except JSONDecodeError:
|
|
276
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
277
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
class AsyncRawSourcesClient:
|
|
281
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
282
|
+
self._client_wrapper = client_wrapper
|
|
283
|
+
|
|
284
|
+
async def get_all(
|
|
285
|
+
self,
|
|
286
|
+
*,
|
|
287
|
+
tenant_id: str,
|
|
288
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
289
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
290
|
+
) -> AsyncHttpResponse[ListSourcesResponse]:
|
|
291
|
+
"""
|
|
292
|
+
Parameters
|
|
293
|
+
----------
|
|
294
|
+
tenant_id : str
|
|
295
|
+
|
|
296
|
+
sub_tenant_id : typing.Optional[str]
|
|
297
|
+
|
|
298
|
+
request_options : typing.Optional[RequestOptions]
|
|
299
|
+
Request-specific configuration.
|
|
300
|
+
|
|
301
|
+
Returns
|
|
302
|
+
-------
|
|
303
|
+
AsyncHttpResponse[ListSourcesResponse]
|
|
304
|
+
Successful Response
|
|
305
|
+
"""
|
|
306
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
307
|
+
"list/sources",
|
|
308
|
+
method="GET",
|
|
309
|
+
params={
|
|
310
|
+
"tenant_id": tenant_id,
|
|
311
|
+
"sub_tenant_id": sub_tenant_id,
|
|
312
|
+
},
|
|
313
|
+
request_options=request_options,
|
|
314
|
+
)
|
|
315
|
+
try:
|
|
316
|
+
if 200 <= _response.status_code < 300:
|
|
317
|
+
_data = typing.cast(
|
|
318
|
+
ListSourcesResponse,
|
|
319
|
+
parse_obj_as(
|
|
320
|
+
type_=ListSourcesResponse, # type: ignore
|
|
321
|
+
object_=_response.json(),
|
|
322
|
+
),
|
|
323
|
+
)
|
|
324
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
325
|
+
if _response.status_code == 400:
|
|
326
|
+
raise BadRequestError(
|
|
327
|
+
headers=dict(_response.headers),
|
|
328
|
+
body=typing.cast(
|
|
329
|
+
ActualErrorResponse,
|
|
330
|
+
parse_obj_as(
|
|
331
|
+
type_=ActualErrorResponse, # type: ignore
|
|
332
|
+
object_=_response.json(),
|
|
333
|
+
),
|
|
334
|
+
),
|
|
335
|
+
)
|
|
336
|
+
if _response.status_code == 401:
|
|
337
|
+
raise UnauthorizedError(
|
|
338
|
+
headers=dict(_response.headers),
|
|
339
|
+
body=typing.cast(
|
|
340
|
+
ActualErrorResponse,
|
|
341
|
+
parse_obj_as(
|
|
342
|
+
type_=ActualErrorResponse, # type: ignore
|
|
343
|
+
object_=_response.json(),
|
|
344
|
+
),
|
|
345
|
+
),
|
|
346
|
+
)
|
|
347
|
+
if _response.status_code == 403:
|
|
348
|
+
raise ForbiddenError(
|
|
349
|
+
headers=dict(_response.headers),
|
|
350
|
+
body=typing.cast(
|
|
351
|
+
ActualErrorResponse,
|
|
352
|
+
parse_obj_as(
|
|
353
|
+
type_=ActualErrorResponse, # type: ignore
|
|
354
|
+
object_=_response.json(),
|
|
355
|
+
),
|
|
356
|
+
),
|
|
357
|
+
)
|
|
358
|
+
if _response.status_code == 404:
|
|
359
|
+
raise NotFoundError(
|
|
360
|
+
headers=dict(_response.headers),
|
|
361
|
+
body=typing.cast(
|
|
362
|
+
ActualErrorResponse,
|
|
363
|
+
parse_obj_as(
|
|
364
|
+
type_=ActualErrorResponse, # type: ignore
|
|
365
|
+
object_=_response.json(),
|
|
366
|
+
),
|
|
367
|
+
),
|
|
368
|
+
)
|
|
369
|
+
if _response.status_code == 422:
|
|
370
|
+
raise UnprocessableEntityError(
|
|
371
|
+
headers=dict(_response.headers),
|
|
372
|
+
body=typing.cast(
|
|
373
|
+
typing.Optional[typing.Any],
|
|
374
|
+
parse_obj_as(
|
|
375
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
376
|
+
object_=_response.json(),
|
|
377
|
+
),
|
|
378
|
+
),
|
|
379
|
+
)
|
|
380
|
+
if _response.status_code == 500:
|
|
381
|
+
raise InternalServerError(
|
|
382
|
+
headers=dict(_response.headers),
|
|
383
|
+
body=typing.cast(
|
|
384
|
+
ActualErrorResponse,
|
|
385
|
+
parse_obj_as(
|
|
386
|
+
type_=ActualErrorResponse, # type: ignore
|
|
387
|
+
object_=_response.json(),
|
|
388
|
+
),
|
|
389
|
+
),
|
|
390
|
+
)
|
|
391
|
+
if _response.status_code == 503:
|
|
392
|
+
raise ServiceUnavailableError(
|
|
393
|
+
headers=dict(_response.headers),
|
|
394
|
+
body=typing.cast(
|
|
395
|
+
ActualErrorResponse,
|
|
396
|
+
parse_obj_as(
|
|
397
|
+
type_=ActualErrorResponse, # type: ignore
|
|
398
|
+
object_=_response.json(),
|
|
399
|
+
),
|
|
400
|
+
),
|
|
401
|
+
)
|
|
402
|
+
_response_json = _response.json()
|
|
403
|
+
except JSONDecodeError:
|
|
404
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
405
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
406
|
+
|
|
407
|
+
async def get_by_ids(
|
|
408
|
+
self,
|
|
409
|
+
*,
|
|
410
|
+
tenant_id: str,
|
|
411
|
+
source_ids: typing.Sequence[str],
|
|
412
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
413
|
+
) -> AsyncHttpResponse[ListSourcesResponse]:
|
|
414
|
+
"""
|
|
415
|
+
Parameters
|
|
416
|
+
----------
|
|
417
|
+
tenant_id : str
|
|
418
|
+
|
|
419
|
+
source_ids : typing.Sequence[str]
|
|
420
|
+
|
|
421
|
+
request_options : typing.Optional[RequestOptions]
|
|
422
|
+
Request-specific configuration.
|
|
423
|
+
|
|
424
|
+
Returns
|
|
425
|
+
-------
|
|
426
|
+
AsyncHttpResponse[ListSourcesResponse]
|
|
427
|
+
Successful Response
|
|
428
|
+
"""
|
|
429
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
430
|
+
"list/sources_by_id",
|
|
431
|
+
method="POST",
|
|
432
|
+
json={
|
|
433
|
+
"tenant_id": tenant_id,
|
|
434
|
+
"source_ids": source_ids,
|
|
435
|
+
},
|
|
436
|
+
headers={
|
|
437
|
+
"content-type": "application/json",
|
|
438
|
+
},
|
|
439
|
+
request_options=request_options,
|
|
440
|
+
omit=OMIT,
|
|
441
|
+
)
|
|
442
|
+
try:
|
|
443
|
+
if 200 <= _response.status_code < 300:
|
|
444
|
+
_data = typing.cast(
|
|
445
|
+
ListSourcesResponse,
|
|
446
|
+
parse_obj_as(
|
|
447
|
+
type_=ListSourcesResponse, # type: ignore
|
|
448
|
+
object_=_response.json(),
|
|
449
|
+
),
|
|
450
|
+
)
|
|
451
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
452
|
+
if _response.status_code == 400:
|
|
453
|
+
raise BadRequestError(
|
|
454
|
+
headers=dict(_response.headers),
|
|
455
|
+
body=typing.cast(
|
|
456
|
+
ActualErrorResponse,
|
|
457
|
+
parse_obj_as(
|
|
458
|
+
type_=ActualErrorResponse, # type: ignore
|
|
459
|
+
object_=_response.json(),
|
|
460
|
+
),
|
|
461
|
+
),
|
|
462
|
+
)
|
|
463
|
+
if _response.status_code == 401:
|
|
464
|
+
raise UnauthorizedError(
|
|
465
|
+
headers=dict(_response.headers),
|
|
466
|
+
body=typing.cast(
|
|
467
|
+
ActualErrorResponse,
|
|
468
|
+
parse_obj_as(
|
|
469
|
+
type_=ActualErrorResponse, # type: ignore
|
|
470
|
+
object_=_response.json(),
|
|
471
|
+
),
|
|
472
|
+
),
|
|
473
|
+
)
|
|
474
|
+
if _response.status_code == 403:
|
|
475
|
+
raise ForbiddenError(
|
|
476
|
+
headers=dict(_response.headers),
|
|
477
|
+
body=typing.cast(
|
|
478
|
+
ActualErrorResponse,
|
|
479
|
+
parse_obj_as(
|
|
480
|
+
type_=ActualErrorResponse, # type: ignore
|
|
481
|
+
object_=_response.json(),
|
|
482
|
+
),
|
|
483
|
+
),
|
|
484
|
+
)
|
|
485
|
+
if _response.status_code == 404:
|
|
486
|
+
raise NotFoundError(
|
|
487
|
+
headers=dict(_response.headers),
|
|
488
|
+
body=typing.cast(
|
|
489
|
+
ActualErrorResponse,
|
|
490
|
+
parse_obj_as(
|
|
491
|
+
type_=ActualErrorResponse, # type: ignore
|
|
492
|
+
object_=_response.json(),
|
|
493
|
+
),
|
|
494
|
+
),
|
|
495
|
+
)
|
|
496
|
+
if _response.status_code == 422:
|
|
497
|
+
raise UnprocessableEntityError(
|
|
498
|
+
headers=dict(_response.headers),
|
|
499
|
+
body=typing.cast(
|
|
500
|
+
typing.Optional[typing.Any],
|
|
501
|
+
parse_obj_as(
|
|
502
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
503
|
+
object_=_response.json(),
|
|
504
|
+
),
|
|
505
|
+
),
|
|
506
|
+
)
|
|
507
|
+
if _response.status_code == 500:
|
|
508
|
+
raise InternalServerError(
|
|
509
|
+
headers=dict(_response.headers),
|
|
510
|
+
body=typing.cast(
|
|
511
|
+
ActualErrorResponse,
|
|
512
|
+
parse_obj_as(
|
|
513
|
+
type_=ActualErrorResponse, # type: ignore
|
|
514
|
+
object_=_response.json(),
|
|
515
|
+
),
|
|
516
|
+
),
|
|
517
|
+
)
|
|
518
|
+
if _response.status_code == 503:
|
|
519
|
+
raise ServiceUnavailableError(
|
|
520
|
+
headers=dict(_response.headers),
|
|
521
|
+
body=typing.cast(
|
|
522
|
+
ActualErrorResponse,
|
|
523
|
+
parse_obj_as(
|
|
524
|
+
type_=ActualErrorResponse, # type: ignore
|
|
525
|
+
object_=_response.json(),
|
|
526
|
+
),
|
|
527
|
+
),
|
|
528
|
+
)
|
|
529
|
+
_response_json = _response.json()
|
|
530
|
+
except JSONDecodeError:
|
|
531
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
532
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
|
+
from ..core.request_options import RequestOptions
|
|
7
|
+
from ..types.tenant_stats import TenantStats
|
|
8
|
+
from .raw_client import AsyncRawTenantClient, RawTenantClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TenantClient:
|
|
12
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
13
|
+
self._raw_client = RawTenantClient(client_wrapper=client_wrapper)
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def with_raw_response(self) -> RawTenantClient:
|
|
17
|
+
"""
|
|
18
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
19
|
+
|
|
20
|
+
Returns
|
|
21
|
+
-------
|
|
22
|
+
RawTenantClient
|
|
23
|
+
"""
|
|
24
|
+
return self._raw_client
|
|
25
|
+
|
|
26
|
+
def stats(
|
|
27
|
+
self,
|
|
28
|
+
*,
|
|
29
|
+
tenant_id: str,
|
|
30
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
31
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
32
|
+
) -> TenantStats:
|
|
33
|
+
"""
|
|
34
|
+
Get tenant stats.
|
|
35
|
+
|
|
36
|
+
This endpoint returns stats for tenant.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
tenant_id : str
|
|
41
|
+
|
|
42
|
+
sub_tenant_id : typing.Optional[str]
|
|
43
|
+
|
|
44
|
+
request_options : typing.Optional[RequestOptions]
|
|
45
|
+
Request-specific configuration.
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
TenantStats
|
|
50
|
+
Successful Response
|
|
51
|
+
|
|
52
|
+
Examples
|
|
53
|
+
--------
|
|
54
|
+
from cortex-ai import CortexAI
|
|
55
|
+
|
|
56
|
+
client = CortexAI(token="YOUR_TOKEN", )
|
|
57
|
+
client.tenant.stats(tenant_id='tenant_id', )
|
|
58
|
+
"""
|
|
59
|
+
_response = self._raw_client.stats(
|
|
60
|
+
tenant_id=tenant_id, sub_tenant_id=sub_tenant_id, request_options=request_options
|
|
61
|
+
)
|
|
62
|
+
return _response.data
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class AsyncTenantClient:
|
|
66
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
67
|
+
self._raw_client = AsyncRawTenantClient(client_wrapper=client_wrapper)
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def with_raw_response(self) -> AsyncRawTenantClient:
|
|
71
|
+
"""
|
|
72
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
AsyncRawTenantClient
|
|
77
|
+
"""
|
|
78
|
+
return self._raw_client
|
|
79
|
+
|
|
80
|
+
async def stats(
|
|
81
|
+
self,
|
|
82
|
+
*,
|
|
83
|
+
tenant_id: str,
|
|
84
|
+
sub_tenant_id: typing.Optional[str] = None,
|
|
85
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
86
|
+
) -> TenantStats:
|
|
87
|
+
"""
|
|
88
|
+
Get tenant stats.
|
|
89
|
+
|
|
90
|
+
This endpoint returns stats for tenant.
|
|
91
|
+
|
|
92
|
+
Parameters
|
|
93
|
+
----------
|
|
94
|
+
tenant_id : str
|
|
95
|
+
|
|
96
|
+
sub_tenant_id : typing.Optional[str]
|
|
97
|
+
|
|
98
|
+
request_options : typing.Optional[RequestOptions]
|
|
99
|
+
Request-specific configuration.
|
|
100
|
+
|
|
101
|
+
Returns
|
|
102
|
+
-------
|
|
103
|
+
TenantStats
|
|
104
|
+
Successful Response
|
|
105
|
+
|
|
106
|
+
Examples
|
|
107
|
+
--------
|
|
108
|
+
import asyncio
|
|
109
|
+
|
|
110
|
+
from cortex-ai import AsyncCortexAI
|
|
111
|
+
|
|
112
|
+
client = AsyncCortexAI(token="YOUR_TOKEN", )
|
|
113
|
+
async def main() -> None:
|
|
114
|
+
await client.tenant.stats(tenant_id='tenant_id', )
|
|
115
|
+
asyncio.run(main())
|
|
116
|
+
"""
|
|
117
|
+
_response = await self._raw_client.stats(
|
|
118
|
+
tenant_id=tenant_id, sub_tenant_id=sub_tenant_id, request_options=request_options
|
|
119
|
+
)
|
|
120
|
+
return _response.data
|