mixpeek 0.6.1__py3-none-any.whl → 0.6.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.
- mixpeek/__init__.py +24 -15
- mixpeek/base_client.py +883 -22
- mixpeek/client.py +7 -7
- mixpeek/core/client_wrapper.py +1 -1
- mixpeek/environment.py +7 -0
- mixpeek/{pipelines → pipeline}/client.py +60 -132
- mixpeek/storage/__init__.py +3 -0
- mixpeek/storage/client.py +7 -116
- mixpeek/storage/sample/client.py +282 -0
- mixpeek/types/__init__.py +18 -10
- mixpeek/types/{embedding_request.py → api_key.py} +4 -5
- mixpeek/types/configs_response.py +14 -3
- mixpeek/types/connection.py +1 -1
- mixpeek/types/{field_schema.py → destination.py} +15 -6
- mixpeek/types/embedding_response.py +6 -2
- mixpeek/types/extract_response.py +39 -0
- mixpeek/types/field_type.py +1 -1
- mixpeek/types/generation_response.py +6 -4
- mixpeek/types/message.py +9 -2
- mixpeek/types/metadata.py +0 -2
- mixpeek/types/modality.py +1 -1
- mixpeek/types/model.py +10 -2
- mixpeek/types/models.py +5 -0
- mixpeek/types/pipeline_response.py +19 -9
- mixpeek/types/{configs_request.py → pipeline_task_response.py} +5 -4
- mixpeek/types/source.py +43 -0
- mixpeek/types/source_destination_mapping.py +44 -0
- mixpeek/types/user.py +36 -0
- mixpeek/types/{destination_schema.py → workflow_code_response.py} +2 -4
- mixpeek/user/client.py +308 -0
- mixpeek/{workflows → workflow}/client.py +127 -10
- {mixpeek-0.6.1.dist-info → mixpeek-0.6.5.dist-info}/METADATA +1 -1
- mixpeek-0.6.5.dist-info/RECORD +75 -0
- mixpeek/generators/client.py +0 -239
- mixpeek/parse/client.py +0 -349
- mixpeek/parse_client.py +0 -14
- mixpeek/types/source_schema.py +0 -32
- mixpeek-0.6.1.dist-info/RECORD +0 -71
- /mixpeek/{generators → pipeline}/__init__.py +0 -0
- /mixpeek/{parse → storage/sample}/__init__.py +0 -0
- /mixpeek/{pipelines → user}/__init__.py +0 -0
- /mixpeek/{workflows → workflow}/__init__.py +0 -0
- {mixpeek-0.6.1.dist-info → mixpeek-0.6.5.dist-info}/LICENSE +0 -0
- {mixpeek-0.6.1.dist-info → mixpeek-0.6.5.dist-info}/WHEEL +0 -0
mixpeek/client.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
1
|
import typing
|
3
2
|
import httpx
|
4
3
|
|
5
|
-
from .base_client import BaseMixpeek,
|
6
|
-
AsyncBaseMixpeek
|
4
|
+
from .base_client import BaseMixpeek, AsyncBaseMixpeek
|
7
5
|
from .types.message import Message
|
8
6
|
from .types.model import Model
|
9
7
|
from .types.settings import Settings
|
@@ -15,7 +13,7 @@ from .core.request_options import RequestOptions
|
|
15
13
|
OMIT = typing.cast(typing.Any, ...)
|
16
14
|
|
17
15
|
|
18
|
-
class Mixpeek(BaseMixpeek):
|
16
|
+
class Mixpeek(BaseMixpeek):
|
19
17
|
|
20
18
|
def generate(
|
21
19
|
self,
|
@@ -30,7 +28,8 @@ class Mixpeek(BaseMixpeek):
|
|
30
28
|
) -> GenerationResponse:
|
31
29
|
if response_format is not None:
|
32
30
|
response_format = response_format.model_json_schema()
|
33
|
-
|
31
|
+
|
32
|
+
return self.base_generate(
|
34
33
|
model=model,
|
35
34
|
response_format=response_format,
|
36
35
|
context=context,
|
@@ -55,11 +54,12 @@ class AsyncMixpeek(AsyncBaseMixpeek):
|
|
55
54
|
) -> GenerationResponse:
|
56
55
|
if response_format is not None:
|
57
56
|
response_format = response_format.model_json_schema()
|
58
|
-
|
57
|
+
|
58
|
+
return await self.base_generate(
|
59
59
|
model=model,
|
60
60
|
response_format=response_format,
|
61
61
|
context=context,
|
62
62
|
messages=messages,
|
63
63
|
settings=settings,
|
64
64
|
request_options=request_options,
|
65
|
-
)
|
65
|
+
)
|
mixpeek/core/client_wrapper.py
CHANGED
@@ -27,7 +27,7 @@ class BaseClientWrapper:
|
|
27
27
|
headers: typing.Dict[str, str] = {
|
28
28
|
"X-Fern-Language": "Python",
|
29
29
|
"X-Fern-SDK-Name": "mixpeek",
|
30
|
-
"X-Fern-SDK-Version": "0.6.
|
30
|
+
"X-Fern-SDK-Version": "0.6.5",
|
31
31
|
}
|
32
32
|
if self._authorization is not None:
|
33
33
|
headers["Authorization"] = self._authorization
|
mixpeek/environment.py
ADDED
@@ -1,6 +1,5 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
-
import datetime as dt
|
4
3
|
import typing
|
5
4
|
import urllib.parse
|
6
5
|
from json.decoder import JSONDecodeError
|
@@ -16,12 +15,11 @@ from ..errors.internal_server_error import InternalServerError
|
|
16
15
|
from ..errors.not_found_error import NotFoundError
|
17
16
|
from ..errors.unauthorized_error import UnauthorizedError
|
18
17
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
19
|
-
from ..types.connection import Connection
|
20
|
-
from ..types.destination_schema import DestinationSchema
|
21
18
|
from ..types.error_response import ErrorResponse
|
22
19
|
from ..types.http_validation_error import HttpValidationError
|
23
20
|
from ..types.pipeline_response import PipelineResponse
|
24
|
-
from ..types.
|
21
|
+
from ..types.pipeline_task_response import PipelineTaskResponse
|
22
|
+
from ..types.source_destination_mapping import SourceDestinationMapping
|
25
23
|
|
26
24
|
try:
|
27
25
|
import pydantic.v1 as pydantic # type: ignore
|
@@ -32,11 +30,13 @@ except ImportError:
|
|
32
30
|
OMIT = typing.cast(typing.Any, ...)
|
33
31
|
|
34
32
|
|
35
|
-
class
|
33
|
+
class PipelineClient:
|
36
34
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
37
35
|
self._client_wrapper = client_wrapper
|
38
36
|
|
39
|
-
def invoke(
|
37
|
+
def invoke(
|
38
|
+
self, pipeline_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
39
|
+
) -> PipelineTaskResponse:
|
40
40
|
"""
|
41
41
|
Parameters:
|
42
42
|
- pipeline_id: str.
|
@@ -49,9 +49,8 @@ class PipelinesClient:
|
|
49
49
|
authorization="YOUR_AUTHORIZATION",
|
50
50
|
index_id="YOUR_INDEX_ID",
|
51
51
|
api_key="YOUR_API_KEY",
|
52
|
-
base_url="https://yourhost.com/path/to/api",
|
53
52
|
)
|
54
|
-
client.
|
53
|
+
client.pipeline.invoke(
|
55
54
|
pipeline_id="pipeline_id",
|
56
55
|
)
|
57
56
|
"""
|
@@ -81,7 +80,7 @@ class PipelinesClient:
|
|
81
80
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
82
81
|
)
|
83
82
|
if 200 <= _response.status_code < 300:
|
84
|
-
return pydantic.parse_obj_as(
|
83
|
+
return pydantic.parse_obj_as(PipelineTaskResponse, _response.json()) # type: ignore
|
85
84
|
if _response.status_code == 400:
|
86
85
|
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
87
86
|
if _response.status_code == 401:
|
@@ -103,87 +102,52 @@ class PipelinesClient:
|
|
103
102
|
def create(
|
104
103
|
self,
|
105
104
|
*,
|
106
|
-
|
107
|
-
pipeline_id: typing.Optional[str] = OMIT,
|
108
|
-
connection: typing.Optional[Connection] = OMIT,
|
109
|
-
source: SourceSchema,
|
110
|
-
destination: DestinationSchema,
|
105
|
+
source_destination_mappings: typing.Sequence[SourceDestinationMapping],
|
111
106
|
metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
112
|
-
enabled: typing.Optional[bool] = OMIT,
|
113
|
-
last_run: typing.Optional[dt.datetime] = OMIT,
|
114
107
|
request_options: typing.Optional[RequestOptions] = None,
|
115
108
|
) -> PipelineResponse:
|
116
109
|
"""
|
117
110
|
Parameters:
|
118
|
-
-
|
119
|
-
|
120
|
-
- pipeline_id: typing.Optional[str].
|
121
|
-
|
122
|
-
- connection: typing.Optional[Connection].
|
123
|
-
|
124
|
-
- source: SourceSchema.
|
125
|
-
|
126
|
-
- destination: DestinationSchema.
|
111
|
+
- source_destination_mappings: typing.Sequence[SourceDestinationMapping]. The source-destination mappings
|
127
112
|
|
128
113
|
- metadata: typing.Optional[typing.Dict[str, typing.Any]].
|
129
114
|
|
130
|
-
- enabled: typing.Optional[bool].
|
131
|
-
|
132
|
-
- last_run: typing.Optional[dt.datetime].
|
133
|
-
|
134
115
|
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
135
116
|
---
|
136
|
-
from mixpeek import
|
117
|
+
from mixpeek import Destination, Source, SourceDestinationMapping
|
137
118
|
from mixpeek.client import Mixpeek
|
138
119
|
|
139
120
|
client = Mixpeek(
|
140
121
|
authorization="YOUR_AUTHORIZATION",
|
141
122
|
index_id="YOUR_INDEX_ID",
|
142
123
|
api_key="YOUR_API_KEY",
|
143
|
-
base_url="https://yourhost.com/path/to/api",
|
144
124
|
)
|
145
|
-
client.
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
125
|
+
client.pipeline.create(
|
126
|
+
source_destination_mappings=[
|
127
|
+
SourceDestinationMapping(
|
128
|
+
embedding_model="embedding_model",
|
129
|
+
source=Source(
|
130
|
+
field="field",
|
131
|
+
type="file_url",
|
132
|
+
settings={},
|
133
|
+
),
|
134
|
+
destination=Destination(
|
135
|
+
collection="collection",
|
136
|
+
field="field",
|
137
|
+
embedding="embedding",
|
138
|
+
),
|
139
|
+
)
|
140
|
+
],
|
160
141
|
)
|
161
142
|
"""
|
162
|
-
_request: typing.Dict[str, typing.Any] = {"
|
163
|
-
if pipeline_id is not OMIT:
|
164
|
-
_request["pipeline_id"] = pipeline_id
|
165
|
-
if connection is not OMIT:
|
166
|
-
_request["connection"] = connection
|
143
|
+
_request: typing.Dict[str, typing.Any] = {"source_destination_mappings": source_destination_mappings}
|
167
144
|
if metadata is not OMIT:
|
168
145
|
_request["metadata"] = metadata
|
169
|
-
if enabled is not OMIT:
|
170
|
-
_request["enabled"] = enabled
|
171
|
-
if last_run is not OMIT:
|
172
|
-
_request["last_run"] = last_run
|
173
146
|
_response = self._client_wrapper.httpx_client.request(
|
174
147
|
"POST",
|
175
148
|
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "pipelines"),
|
176
149
|
params=jsonable_encoder(
|
177
|
-
|
178
|
-
{
|
179
|
-
"connection_id": connection_id,
|
180
|
-
**(
|
181
|
-
request_options.get("additional_query_parameters", {})
|
182
|
-
if request_options is not None
|
183
|
-
else {}
|
184
|
-
),
|
185
|
-
}
|
186
|
-
)
|
150
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
187
151
|
),
|
188
152
|
json=jsonable_encoder(_request)
|
189
153
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -225,7 +189,7 @@ class PipelinesClient:
|
|
225
189
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
226
190
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
227
191
|
|
228
|
-
def
|
192
|
+
def status(self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
|
229
193
|
"""
|
230
194
|
Query tasks status.
|
231
195
|
|
@@ -240,9 +204,8 @@ class PipelinesClient:
|
|
240
204
|
authorization="YOUR_AUTHORIZATION",
|
241
205
|
index_id="YOUR_INDEX_ID",
|
242
206
|
api_key="YOUR_API_KEY",
|
243
|
-
base_url="https://yourhost.com/path/to/api",
|
244
207
|
)
|
245
|
-
client.
|
208
|
+
client.pipeline.status(
|
246
209
|
task_id="task_id",
|
247
210
|
)
|
248
211
|
"""
|
@@ -289,11 +252,13 @@ class PipelinesClient:
|
|
289
252
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
290
253
|
|
291
254
|
|
292
|
-
class
|
255
|
+
class AsyncPipelineClient:
|
293
256
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
294
257
|
self._client_wrapper = client_wrapper
|
295
258
|
|
296
|
-
async def invoke(
|
259
|
+
async def invoke(
|
260
|
+
self, pipeline_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
261
|
+
) -> PipelineTaskResponse:
|
297
262
|
"""
|
298
263
|
Parameters:
|
299
264
|
- pipeline_id: str.
|
@@ -306,9 +271,8 @@ class AsyncPipelinesClient:
|
|
306
271
|
authorization="YOUR_AUTHORIZATION",
|
307
272
|
index_id="YOUR_INDEX_ID",
|
308
273
|
api_key="YOUR_API_KEY",
|
309
|
-
base_url="https://yourhost.com/path/to/api",
|
310
274
|
)
|
311
|
-
await client.
|
275
|
+
await client.pipeline.invoke(
|
312
276
|
pipeline_id="pipeline_id",
|
313
277
|
)
|
314
278
|
"""
|
@@ -338,7 +302,7 @@ class AsyncPipelinesClient:
|
|
338
302
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
339
303
|
)
|
340
304
|
if 200 <= _response.status_code < 300:
|
341
|
-
return pydantic.parse_obj_as(
|
305
|
+
return pydantic.parse_obj_as(PipelineTaskResponse, _response.json()) # type: ignore
|
342
306
|
if _response.status_code == 400:
|
343
307
|
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
344
308
|
if _response.status_code == 401:
|
@@ -360,87 +324,52 @@ class AsyncPipelinesClient:
|
|
360
324
|
async def create(
|
361
325
|
self,
|
362
326
|
*,
|
363
|
-
|
364
|
-
pipeline_id: typing.Optional[str] = OMIT,
|
365
|
-
connection: typing.Optional[Connection] = OMIT,
|
366
|
-
source: SourceSchema,
|
367
|
-
destination: DestinationSchema,
|
327
|
+
source_destination_mappings: typing.Sequence[SourceDestinationMapping],
|
368
328
|
metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
369
|
-
enabled: typing.Optional[bool] = OMIT,
|
370
|
-
last_run: typing.Optional[dt.datetime] = OMIT,
|
371
329
|
request_options: typing.Optional[RequestOptions] = None,
|
372
330
|
) -> PipelineResponse:
|
373
331
|
"""
|
374
332
|
Parameters:
|
375
|
-
-
|
376
|
-
|
377
|
-
- pipeline_id: typing.Optional[str].
|
378
|
-
|
379
|
-
- connection: typing.Optional[Connection].
|
380
|
-
|
381
|
-
- source: SourceSchema.
|
382
|
-
|
383
|
-
- destination: DestinationSchema.
|
333
|
+
- source_destination_mappings: typing.Sequence[SourceDestinationMapping]. The source-destination mappings
|
384
334
|
|
385
335
|
- metadata: typing.Optional[typing.Dict[str, typing.Any]].
|
386
336
|
|
387
|
-
- enabled: typing.Optional[bool].
|
388
|
-
|
389
|
-
- last_run: typing.Optional[dt.datetime].
|
390
|
-
|
391
337
|
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
392
338
|
---
|
393
|
-
from mixpeek import
|
339
|
+
from mixpeek import Destination, Source, SourceDestinationMapping
|
394
340
|
from mixpeek.client import AsyncMixpeek
|
395
341
|
|
396
342
|
client = AsyncMixpeek(
|
397
343
|
authorization="YOUR_AUTHORIZATION",
|
398
344
|
index_id="YOUR_INDEX_ID",
|
399
345
|
api_key="YOUR_API_KEY",
|
400
|
-
base_url="https://yourhost.com/path/to/api",
|
401
346
|
)
|
402
|
-
await client.
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
347
|
+
await client.pipeline.create(
|
348
|
+
source_destination_mappings=[
|
349
|
+
SourceDestinationMapping(
|
350
|
+
embedding_model="embedding_model",
|
351
|
+
source=Source(
|
352
|
+
field="field",
|
353
|
+
type="file_url",
|
354
|
+
settings={},
|
355
|
+
),
|
356
|
+
destination=Destination(
|
357
|
+
collection="collection",
|
358
|
+
field="field",
|
359
|
+
embedding="embedding",
|
360
|
+
),
|
361
|
+
)
|
362
|
+
],
|
417
363
|
)
|
418
364
|
"""
|
419
|
-
_request: typing.Dict[str, typing.Any] = {"
|
420
|
-
if pipeline_id is not OMIT:
|
421
|
-
_request["pipeline_id"] = pipeline_id
|
422
|
-
if connection is not OMIT:
|
423
|
-
_request["connection"] = connection
|
365
|
+
_request: typing.Dict[str, typing.Any] = {"source_destination_mappings": source_destination_mappings}
|
424
366
|
if metadata is not OMIT:
|
425
367
|
_request["metadata"] = metadata
|
426
|
-
if enabled is not OMIT:
|
427
|
-
_request["enabled"] = enabled
|
428
|
-
if last_run is not OMIT:
|
429
|
-
_request["last_run"] = last_run
|
430
368
|
_response = await self._client_wrapper.httpx_client.request(
|
431
369
|
"POST",
|
432
370
|
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "pipelines"),
|
433
371
|
params=jsonable_encoder(
|
434
|
-
|
435
|
-
{
|
436
|
-
"connection_id": connection_id,
|
437
|
-
**(
|
438
|
-
request_options.get("additional_query_parameters", {})
|
439
|
-
if request_options is not None
|
440
|
-
else {}
|
441
|
-
),
|
442
|
-
}
|
443
|
-
)
|
372
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
444
373
|
),
|
445
374
|
json=jsonable_encoder(_request)
|
446
375
|
if request_options is None or request_options.get("additional_body_parameters") is None
|
@@ -482,7 +411,7 @@ class AsyncPipelinesClient:
|
|
482
411
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
483
412
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
484
413
|
|
485
|
-
async def
|
414
|
+
async def status(self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
|
486
415
|
"""
|
487
416
|
Query tasks status.
|
488
417
|
|
@@ -497,9 +426,8 @@ class AsyncPipelinesClient:
|
|
497
426
|
authorization="YOUR_AUTHORIZATION",
|
498
427
|
index_id="YOUR_INDEX_ID",
|
499
428
|
api_key="YOUR_API_KEY",
|
500
|
-
base_url="https://yourhost.com/path/to/api",
|
501
429
|
)
|
502
|
-
await client.
|
430
|
+
await client.pipeline.status(
|
503
431
|
task_id="task_id",
|
504
432
|
)
|
505
433
|
"""
|
mixpeek/storage/__init__.py
CHANGED
mixpeek/storage/client.py
CHANGED
@@ -17,6 +17,7 @@ from ..errors.unauthorized_error import UnauthorizedError
|
|
17
17
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
18
18
|
from ..types.error_response import ErrorResponse
|
19
19
|
from ..types.http_validation_error import HttpValidationError
|
20
|
+
from .sample.client import AsyncSampleClient, SampleClient
|
20
21
|
|
21
22
|
try:
|
22
23
|
import pydantic.v1 as pydantic # type: ignore
|
@@ -27,8 +28,9 @@ except ImportError:
|
|
27
28
|
class StorageClient:
|
28
29
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
29
30
|
self._client_wrapper = client_wrapper
|
31
|
+
self.sample = SampleClient(client_wrapper=self._client_wrapper)
|
30
32
|
|
31
|
-
def
|
33
|
+
def connect(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
|
32
34
|
"""
|
33
35
|
Parameters:
|
34
36
|
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
@@ -39,9 +41,8 @@ class StorageClient:
|
|
39
41
|
authorization="YOUR_AUTHORIZATION",
|
40
42
|
index_id="YOUR_INDEX_ID",
|
41
43
|
api_key="YOUR_API_KEY",
|
42
|
-
base_url="https://yourhost.com/path/to/api",
|
43
44
|
)
|
44
|
-
client.storage.
|
45
|
+
client.storage.connect()
|
45
46
|
"""
|
46
47
|
_response = self._client_wrapper.httpx_client.request(
|
47
48
|
"GET",
|
@@ -83,67 +84,13 @@ class StorageClient:
|
|
83
84
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
84
85
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
85
86
|
|
86
|
-
def sample_database(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
|
87
|
-
"""
|
88
|
-
Parameters:
|
89
|
-
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
90
|
-
---
|
91
|
-
from mixpeek.client import Mixpeek
|
92
|
-
|
93
|
-
client = Mixpeek(
|
94
|
-
authorization="YOUR_AUTHORIZATION",
|
95
|
-
index_id="YOUR_INDEX_ID",
|
96
|
-
api_key="YOUR_API_KEY",
|
97
|
-
base_url="https://yourhost.com/path/to/api",
|
98
|
-
)
|
99
|
-
client.storage.sample_database()
|
100
|
-
"""
|
101
|
-
_response = self._client_wrapper.httpx_client.request(
|
102
|
-
"GET",
|
103
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "storage/sample/database"),
|
104
|
-
params=jsonable_encoder(
|
105
|
-
request_options.get("additional_query_parameters") if request_options is not None else None
|
106
|
-
),
|
107
|
-
headers=jsonable_encoder(
|
108
|
-
remove_none_from_dict(
|
109
|
-
{
|
110
|
-
**self._client_wrapper.get_headers(),
|
111
|
-
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
112
|
-
}
|
113
|
-
)
|
114
|
-
),
|
115
|
-
timeout=request_options.get("timeout_in_seconds")
|
116
|
-
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
117
|
-
else self._client_wrapper.get_timeout(),
|
118
|
-
retries=0,
|
119
|
-
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
120
|
-
)
|
121
|
-
if 200 <= _response.status_code < 300:
|
122
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
123
|
-
if _response.status_code == 400:
|
124
|
-
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
125
|
-
if _response.status_code == 401:
|
126
|
-
raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
127
|
-
if _response.status_code == 403:
|
128
|
-
raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
129
|
-
if _response.status_code == 404:
|
130
|
-
raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
131
|
-
if _response.status_code == 422:
|
132
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
133
|
-
if _response.status_code == 500:
|
134
|
-
raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
135
|
-
try:
|
136
|
-
_response_json = _response.json()
|
137
|
-
except JSONDecodeError:
|
138
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
139
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
140
|
-
|
141
87
|
|
142
88
|
class AsyncStorageClient:
|
143
89
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
144
90
|
self._client_wrapper = client_wrapper
|
91
|
+
self.sample = AsyncSampleClient(client_wrapper=self._client_wrapper)
|
145
92
|
|
146
|
-
async def
|
93
|
+
async def connect(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
|
147
94
|
"""
|
148
95
|
Parameters:
|
149
96
|
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
@@ -154,9 +101,8 @@ class AsyncStorageClient:
|
|
154
101
|
authorization="YOUR_AUTHORIZATION",
|
155
102
|
index_id="YOUR_INDEX_ID",
|
156
103
|
api_key="YOUR_API_KEY",
|
157
|
-
base_url="https://yourhost.com/path/to/api",
|
158
104
|
)
|
159
|
-
await client.storage.
|
105
|
+
await client.storage.connect()
|
160
106
|
"""
|
161
107
|
_response = await self._client_wrapper.httpx_client.request(
|
162
108
|
"GET",
|
@@ -197,58 +143,3 @@ class AsyncStorageClient:
|
|
197
143
|
except JSONDecodeError:
|
198
144
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
199
145
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
200
|
-
|
201
|
-
async def sample_database(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
|
202
|
-
"""
|
203
|
-
Parameters:
|
204
|
-
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
205
|
-
---
|
206
|
-
from mixpeek.client import AsyncMixpeek
|
207
|
-
|
208
|
-
client = AsyncMixpeek(
|
209
|
-
authorization="YOUR_AUTHORIZATION",
|
210
|
-
index_id="YOUR_INDEX_ID",
|
211
|
-
api_key="YOUR_API_KEY",
|
212
|
-
base_url="https://yourhost.com/path/to/api",
|
213
|
-
)
|
214
|
-
await client.storage.sample_database()
|
215
|
-
"""
|
216
|
-
_response = await self._client_wrapper.httpx_client.request(
|
217
|
-
"GET",
|
218
|
-
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "storage/sample/database"),
|
219
|
-
params=jsonable_encoder(
|
220
|
-
request_options.get("additional_query_parameters") if request_options is not None else None
|
221
|
-
),
|
222
|
-
headers=jsonable_encoder(
|
223
|
-
remove_none_from_dict(
|
224
|
-
{
|
225
|
-
**self._client_wrapper.get_headers(),
|
226
|
-
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
227
|
-
}
|
228
|
-
)
|
229
|
-
),
|
230
|
-
timeout=request_options.get("timeout_in_seconds")
|
231
|
-
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
232
|
-
else self._client_wrapper.get_timeout(),
|
233
|
-
retries=0,
|
234
|
-
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
235
|
-
)
|
236
|
-
if 200 <= _response.status_code < 300:
|
237
|
-
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
238
|
-
if _response.status_code == 400:
|
239
|
-
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
240
|
-
if _response.status_code == 401:
|
241
|
-
raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
242
|
-
if _response.status_code == 403:
|
243
|
-
raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
244
|
-
if _response.status_code == 404:
|
245
|
-
raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
246
|
-
if _response.status_code == 422:
|
247
|
-
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
248
|
-
if _response.status_code == 500:
|
249
|
-
raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
250
|
-
try:
|
251
|
-
_response_json = _response.json()
|
252
|
-
except JSONDecodeError:
|
253
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
254
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|