mixpeek 0.6.7__py3-none-any.whl → 0.6.9__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.
Files changed (84) hide show
  1. mixpeek/__init__.py +1 -106
  2. mixpeek/client.py +21 -65
  3. mixpeek/endpoints/connections.py +16 -0
  4. mixpeek/endpoints/embed.py +50 -0
  5. mixpeek/endpoints/extract.py +16 -0
  6. mixpeek/endpoints/generate.py +17 -0
  7. mixpeek/endpoints/tools.py +23 -0
  8. mixpeek/exceptions.py +13 -0
  9. mixpeek-0.6.9.dist-info/METADATA +68 -0
  10. mixpeek-0.6.9.dist-info/RECORD +13 -0
  11. {mixpeek-0.6.7.dist-info → mixpeek-0.6.9.dist-info}/WHEEL +2 -1
  12. mixpeek-0.6.9.dist-info/top_level.txt +1 -0
  13. mixpeek/base_client.py +0 -989
  14. mixpeek/core/__init__.py +0 -25
  15. mixpeek/core/api_error.py +0 -15
  16. mixpeek/core/client_wrapper.py +0 -83
  17. mixpeek/core/datetime_utils.py +0 -28
  18. mixpeek/core/file.py +0 -38
  19. mixpeek/core/http_client.py +0 -130
  20. mixpeek/core/jsonable_encoder.py +0 -103
  21. mixpeek/core/remove_none_from_dict.py +0 -11
  22. mixpeek/core/request_options.py +0 -32
  23. mixpeek/environment.py +0 -7
  24. mixpeek/errors/__init__.py +0 -17
  25. mixpeek/errors/bad_request_error.py +0 -9
  26. mixpeek/errors/forbidden_error.py +0 -9
  27. mixpeek/errors/internal_server_error.py +0 -9
  28. mixpeek/errors/not_found_error.py +0 -9
  29. mixpeek/errors/unauthorized_error.py +0 -9
  30. mixpeek/errors/unprocessable_entity_error.py +0 -9
  31. mixpeek/pipeline/__init__.py +0 -2
  32. mixpeek/pipeline/client.py +0 -474
  33. mixpeek/storage/__init__.py +0 -5
  34. mixpeek/storage/client.py +0 -145
  35. mixpeek/storage/sample/__init__.py +0 -2
  36. mixpeek/storage/sample/client.py +0 -282
  37. mixpeek/types/__init__.py +0 -81
  38. mixpeek/types/api_key.py +0 -31
  39. mixpeek/types/audio_params.py +0 -29
  40. mixpeek/types/configs_response.py +0 -42
  41. mixpeek/types/connection.py +0 -36
  42. mixpeek/types/connection_engine.py +0 -5
  43. mixpeek/types/csv_params.py +0 -29
  44. mixpeek/types/destination.py +0 -42
  45. mixpeek/types/embedding_response.py +0 -34
  46. mixpeek/types/error_message.py +0 -29
  47. mixpeek/types/error_response.py +0 -30
  48. mixpeek/types/extract_response.py +0 -35
  49. mixpeek/types/field_type.py +0 -5
  50. mixpeek/types/generation_response.py +0 -36
  51. mixpeek/types/html_params.py +0 -29
  52. mixpeek/types/http_validation_error.py +0 -30
  53. mixpeek/types/image_params.py +0 -32
  54. mixpeek/types/message.py +0 -37
  55. mixpeek/types/metadata.py +0 -32
  56. mixpeek/types/modality.py +0 -5
  57. mixpeek/types/model.py +0 -38
  58. mixpeek/types/models.py +0 -5
  59. mixpeek/types/pdf_params.py +0 -41
  60. mixpeek/types/pipeline_response.py +0 -49
  61. mixpeek/types/pipeline_task_response.py +0 -32
  62. mixpeek/types/ppt_params.py +0 -27
  63. mixpeek/types/pptx_params.py +0 -27
  64. mixpeek/types/settings.py +0 -35
  65. mixpeek/types/source.py +0 -43
  66. mixpeek/types/source_destination_mapping.py +0 -44
  67. mixpeek/types/txt_params.py +0 -27
  68. mixpeek/types/user.py +0 -36
  69. mixpeek/types/validation_error.py +0 -32
  70. mixpeek/types/validation_error_loc_item.py +0 -5
  71. mixpeek/types/video_params.py +0 -27
  72. mixpeek/types/workflow_code_response.py +0 -29
  73. mixpeek/types/workflow_response.py +0 -32
  74. mixpeek/types/workflow_settings.py +0 -30
  75. mixpeek/types/xlsx_params.py +0 -29
  76. mixpeek/user/__init__.py +0 -2
  77. mixpeek/user/client.py +0 -308
  78. mixpeek/version.py +0 -4
  79. mixpeek/workflow/__init__.py +0 -2
  80. mixpeek/workflow/client.py +0 -535
  81. mixpeek-0.6.7.dist-info/LICENSE +0 -21
  82. mixpeek-0.6.7.dist-info/METADATA +0 -145
  83. mixpeek-0.6.7.dist-info/RECORD +0 -75
  84. /mixpeek/{py.typed → endpoints/__init__.py} +0 -0
@@ -1,474 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
- import urllib.parse
5
- from json.decoder import JSONDecodeError
6
-
7
- from ..core.api_error import ApiError
8
- from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
- from ..core.jsonable_encoder import jsonable_encoder
10
- from ..core.remove_none_from_dict import remove_none_from_dict
11
- from ..core.request_options import RequestOptions
12
- from ..errors.bad_request_error import BadRequestError
13
- from ..errors.forbidden_error import ForbiddenError
14
- from ..errors.internal_server_error import InternalServerError
15
- from ..errors.not_found_error import NotFoundError
16
- from ..errors.unauthorized_error import UnauthorizedError
17
- from ..errors.unprocessable_entity_error import UnprocessableEntityError
18
- from ..types.error_response import ErrorResponse
19
- from ..types.http_validation_error import HttpValidationError
20
- from ..types.pipeline_response import PipelineResponse
21
- from ..types.pipeline_task_response import PipelineTaskResponse
22
- from ..types.source_destination_mapping import SourceDestinationMapping
23
-
24
- try:
25
- import pydantic.v1 as pydantic # type: ignore
26
- except ImportError:
27
- import pydantic # type: ignore
28
-
29
- # this is used as the default value for optional parameters
30
- OMIT = typing.cast(typing.Any, ...)
31
-
32
-
33
- class PipelineClient:
34
- def __init__(self, *, client_wrapper: SyncClientWrapper):
35
- self._client_wrapper = client_wrapper
36
-
37
- def invoke(
38
- self, pipeline_id: str, *, request_options: typing.Optional[RequestOptions] = None
39
- ) -> PipelineTaskResponse:
40
- """
41
- Parameters:
42
- - pipeline_id: str.
43
-
44
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
45
- ---
46
- from mixpeek.client import Mixpeek
47
-
48
- client = Mixpeek(
49
- authorization="YOUR_AUTHORIZATION",
50
- index_id="YOUR_INDEX_ID",
51
- api_key="YOUR_API_KEY",
52
- )
53
- client.pipeline.invoke(
54
- pipeline_id="pipeline_id",
55
- )
56
- """
57
- _response = self._client_wrapper.httpx_client.request(
58
- "POST",
59
- urllib.parse.urljoin(
60
- f"{self._client_wrapper.get_base_url()}/", f"pipelines/{jsonable_encoder(pipeline_id)}"
61
- ),
62
- params=jsonable_encoder(
63
- request_options.get("additional_query_parameters") if request_options is not None else None
64
- ),
65
- json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
66
- if request_options is not None
67
- else None,
68
- headers=jsonable_encoder(
69
- remove_none_from_dict(
70
- {
71
- **self._client_wrapper.get_headers(),
72
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
73
- }
74
- )
75
- ),
76
- timeout=request_options.get("timeout_in_seconds")
77
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
78
- else self._client_wrapper.get_timeout(),
79
- retries=0,
80
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
81
- )
82
- if 200 <= _response.status_code < 300:
83
- return pydantic.parse_obj_as(PipelineTaskResponse, _response.json()) # type: ignore
84
- if _response.status_code == 400:
85
- raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
86
- if _response.status_code == 401:
87
- raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
88
- if _response.status_code == 403:
89
- raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
90
- if _response.status_code == 404:
91
- raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
92
- if _response.status_code == 422:
93
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
94
- if _response.status_code == 500:
95
- raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
96
- try:
97
- _response_json = _response.json()
98
- except JSONDecodeError:
99
- raise ApiError(status_code=_response.status_code, body=_response.text)
100
- raise ApiError(status_code=_response.status_code, body=_response_json)
101
-
102
- def create(
103
- self,
104
- *,
105
- source_destination_mappings: typing.Sequence[SourceDestinationMapping],
106
- metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
107
- request_options: typing.Optional[RequestOptions] = None,
108
- ) -> PipelineResponse:
109
- """
110
- Parameters:
111
- - source_destination_mappings: typing.Sequence[SourceDestinationMapping]. The source-destination mappings
112
-
113
- - metadata: typing.Optional[typing.Dict[str, typing.Any]].
114
-
115
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
116
- ---
117
- from mixpeek import Destination, Source, SourceDestinationMapping
118
- from mixpeek.client import Mixpeek
119
-
120
- client = Mixpeek(
121
- authorization="YOUR_AUTHORIZATION",
122
- index_id="YOUR_INDEX_ID",
123
- api_key="YOUR_API_KEY",
124
- )
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
- ],
141
- )
142
- """
143
- _request: typing.Dict[str, typing.Any] = {"source_destination_mappings": source_destination_mappings}
144
- if metadata is not OMIT:
145
- _request["metadata"] = metadata
146
- _response = self._client_wrapper.httpx_client.request(
147
- "POST",
148
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "pipelines"),
149
- params=jsonable_encoder(
150
- request_options.get("additional_query_parameters") if request_options is not None else None
151
- ),
152
- json=jsonable_encoder(_request)
153
- if request_options is None or request_options.get("additional_body_parameters") is None
154
- else {
155
- **jsonable_encoder(_request),
156
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
157
- },
158
- headers=jsonable_encoder(
159
- remove_none_from_dict(
160
- {
161
- **self._client_wrapper.get_headers(),
162
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
163
- }
164
- )
165
- ),
166
- timeout=request_options.get("timeout_in_seconds")
167
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
168
- else self._client_wrapper.get_timeout(),
169
- retries=0,
170
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
171
- )
172
- if 200 <= _response.status_code < 300:
173
- return pydantic.parse_obj_as(PipelineResponse, _response.json()) # type: ignore
174
- if _response.status_code == 400:
175
- raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
176
- if _response.status_code == 401:
177
- raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
178
- if _response.status_code == 403:
179
- raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
180
- if _response.status_code == 404:
181
- raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
182
- if _response.status_code == 422:
183
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
184
- if _response.status_code == 500:
185
- raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
186
- try:
187
- _response_json = _response.json()
188
- except JSONDecodeError:
189
- raise ApiError(status_code=_response.status_code, body=_response.text)
190
- raise ApiError(status_code=_response.status_code, body=_response_json)
191
-
192
- def status(self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
193
- """
194
- Query tasks status.
195
-
196
- Parameters:
197
- - task_id: str.
198
-
199
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
200
- ---
201
- from mixpeek.client import Mixpeek
202
-
203
- client = Mixpeek(
204
- authorization="YOUR_AUTHORIZATION",
205
- index_id="YOUR_INDEX_ID",
206
- api_key="YOUR_API_KEY",
207
- )
208
- client.pipeline.status(
209
- task_id="task_id",
210
- )
211
- """
212
- _response = self._client_wrapper.httpx_client.request(
213
- "GET",
214
- urllib.parse.urljoin(
215
- f"{self._client_wrapper.get_base_url()}/", f"pipelines/status/{jsonable_encoder(task_id)}"
216
- ),
217
- params=jsonable_encoder(
218
- request_options.get("additional_query_parameters") if request_options is not None else None
219
- ),
220
- headers=jsonable_encoder(
221
- remove_none_from_dict(
222
- {
223
- **self._client_wrapper.get_headers(),
224
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
225
- }
226
- )
227
- ),
228
- timeout=request_options.get("timeout_in_seconds")
229
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
230
- else self._client_wrapper.get_timeout(),
231
- retries=0,
232
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
233
- )
234
- if 200 <= _response.status_code < 300:
235
- return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
236
- if _response.status_code == 400:
237
- raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
238
- if _response.status_code == 401:
239
- raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
240
- if _response.status_code == 403:
241
- raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
242
- if _response.status_code == 404:
243
- raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
244
- if _response.status_code == 422:
245
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
246
- if _response.status_code == 500:
247
- raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
248
- try:
249
- _response_json = _response.json()
250
- except JSONDecodeError:
251
- raise ApiError(status_code=_response.status_code, body=_response.text)
252
- raise ApiError(status_code=_response.status_code, body=_response_json)
253
-
254
-
255
- class AsyncPipelineClient:
256
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
257
- self._client_wrapper = client_wrapper
258
-
259
- async def invoke(
260
- self, pipeline_id: str, *, request_options: typing.Optional[RequestOptions] = None
261
- ) -> PipelineTaskResponse:
262
- """
263
- Parameters:
264
- - pipeline_id: str.
265
-
266
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
267
- ---
268
- from mixpeek.client import AsyncMixpeek
269
-
270
- client = AsyncMixpeek(
271
- authorization="YOUR_AUTHORIZATION",
272
- index_id="YOUR_INDEX_ID",
273
- api_key="YOUR_API_KEY",
274
- )
275
- await client.pipeline.invoke(
276
- pipeline_id="pipeline_id",
277
- )
278
- """
279
- _response = await self._client_wrapper.httpx_client.request(
280
- "POST",
281
- urllib.parse.urljoin(
282
- f"{self._client_wrapper.get_base_url()}/", f"pipelines/{jsonable_encoder(pipeline_id)}"
283
- ),
284
- params=jsonable_encoder(
285
- request_options.get("additional_query_parameters") if request_options is not None else None
286
- ),
287
- json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
288
- if request_options is not None
289
- else None,
290
- headers=jsonable_encoder(
291
- remove_none_from_dict(
292
- {
293
- **self._client_wrapper.get_headers(),
294
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
295
- }
296
- )
297
- ),
298
- timeout=request_options.get("timeout_in_seconds")
299
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
300
- else self._client_wrapper.get_timeout(),
301
- retries=0,
302
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
303
- )
304
- if 200 <= _response.status_code < 300:
305
- return pydantic.parse_obj_as(PipelineTaskResponse, _response.json()) # type: ignore
306
- if _response.status_code == 400:
307
- raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
308
- if _response.status_code == 401:
309
- raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
310
- if _response.status_code == 403:
311
- raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
312
- if _response.status_code == 404:
313
- raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
314
- if _response.status_code == 422:
315
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
316
- if _response.status_code == 500:
317
- raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
318
- try:
319
- _response_json = _response.json()
320
- except JSONDecodeError:
321
- raise ApiError(status_code=_response.status_code, body=_response.text)
322
- raise ApiError(status_code=_response.status_code, body=_response_json)
323
-
324
- async def create(
325
- self,
326
- *,
327
- source_destination_mappings: typing.Sequence[SourceDestinationMapping],
328
- metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
329
- request_options: typing.Optional[RequestOptions] = None,
330
- ) -> PipelineResponse:
331
- """
332
- Parameters:
333
- - source_destination_mappings: typing.Sequence[SourceDestinationMapping]. The source-destination mappings
334
-
335
- - metadata: typing.Optional[typing.Dict[str, typing.Any]].
336
-
337
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
338
- ---
339
- from mixpeek import Destination, Source, SourceDestinationMapping
340
- from mixpeek.client import AsyncMixpeek
341
-
342
- client = AsyncMixpeek(
343
- authorization="YOUR_AUTHORIZATION",
344
- index_id="YOUR_INDEX_ID",
345
- api_key="YOUR_API_KEY",
346
- )
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
- ],
363
- )
364
- """
365
- _request: typing.Dict[str, typing.Any] = {"source_destination_mappings": source_destination_mappings}
366
- if metadata is not OMIT:
367
- _request["metadata"] = metadata
368
- _response = await self._client_wrapper.httpx_client.request(
369
- "POST",
370
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "pipelines"),
371
- params=jsonable_encoder(
372
- request_options.get("additional_query_parameters") if request_options is not None else None
373
- ),
374
- json=jsonable_encoder(_request)
375
- if request_options is None or request_options.get("additional_body_parameters") is None
376
- else {
377
- **jsonable_encoder(_request),
378
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
379
- },
380
- headers=jsonable_encoder(
381
- remove_none_from_dict(
382
- {
383
- **self._client_wrapper.get_headers(),
384
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
385
- }
386
- )
387
- ),
388
- timeout=request_options.get("timeout_in_seconds")
389
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
390
- else self._client_wrapper.get_timeout(),
391
- retries=0,
392
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
393
- )
394
- if 200 <= _response.status_code < 300:
395
- return pydantic.parse_obj_as(PipelineResponse, _response.json()) # type: ignore
396
- if _response.status_code == 400:
397
- raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
398
- if _response.status_code == 401:
399
- raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
400
- if _response.status_code == 403:
401
- raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
402
- if _response.status_code == 404:
403
- raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
404
- if _response.status_code == 422:
405
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
406
- if _response.status_code == 500:
407
- raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
408
- try:
409
- _response_json = _response.json()
410
- except JSONDecodeError:
411
- raise ApiError(status_code=_response.status_code, body=_response.text)
412
- raise ApiError(status_code=_response.status_code, body=_response_json)
413
-
414
- async def status(self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
415
- """
416
- Query tasks status.
417
-
418
- Parameters:
419
- - task_id: str.
420
-
421
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
422
- ---
423
- from mixpeek.client import AsyncMixpeek
424
-
425
- client = AsyncMixpeek(
426
- authorization="YOUR_AUTHORIZATION",
427
- index_id="YOUR_INDEX_ID",
428
- api_key="YOUR_API_KEY",
429
- )
430
- await client.pipeline.status(
431
- task_id="task_id",
432
- )
433
- """
434
- _response = await self._client_wrapper.httpx_client.request(
435
- "GET",
436
- urllib.parse.urljoin(
437
- f"{self._client_wrapper.get_base_url()}/", f"pipelines/status/{jsonable_encoder(task_id)}"
438
- ),
439
- params=jsonable_encoder(
440
- request_options.get("additional_query_parameters") if request_options is not None else None
441
- ),
442
- headers=jsonable_encoder(
443
- remove_none_from_dict(
444
- {
445
- **self._client_wrapper.get_headers(),
446
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
447
- }
448
- )
449
- ),
450
- timeout=request_options.get("timeout_in_seconds")
451
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
452
- else self._client_wrapper.get_timeout(),
453
- retries=0,
454
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
455
- )
456
- if 200 <= _response.status_code < 300:
457
- return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
458
- if _response.status_code == 400:
459
- raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
460
- if _response.status_code == 401:
461
- raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
462
- if _response.status_code == 403:
463
- raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
464
- if _response.status_code == 404:
465
- raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
466
- if _response.status_code == 422:
467
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
468
- if _response.status_code == 500:
469
- raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
470
- try:
471
- _response_json = _response.json()
472
- except JSONDecodeError:
473
- raise ApiError(status_code=_response.status_code, body=_response.text)
474
- raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -1,5 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- from . import sample
4
-
5
- __all__ = ["sample"]
mixpeek/storage/client.py DELETED
@@ -1,145 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
- import urllib.parse
5
- from json.decoder import JSONDecodeError
6
-
7
- from ..core.api_error import ApiError
8
- from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
- from ..core.jsonable_encoder import jsonable_encoder
10
- from ..core.remove_none_from_dict import remove_none_from_dict
11
- from ..core.request_options import RequestOptions
12
- from ..errors.bad_request_error import BadRequestError
13
- from ..errors.forbidden_error import ForbiddenError
14
- from ..errors.internal_server_error import InternalServerError
15
- from ..errors.not_found_error import NotFoundError
16
- from ..errors.unauthorized_error import UnauthorizedError
17
- from ..errors.unprocessable_entity_error import UnprocessableEntityError
18
- from ..types.error_response import ErrorResponse
19
- from ..types.http_validation_error import HttpValidationError
20
- from .sample.client import AsyncSampleClient, SampleClient
21
-
22
- try:
23
- import pydantic.v1 as pydantic # type: ignore
24
- except ImportError:
25
- import pydantic # type: ignore
26
-
27
-
28
- class StorageClient:
29
- def __init__(self, *, client_wrapper: SyncClientWrapper):
30
- self._client_wrapper = client_wrapper
31
- self.sample = SampleClient(client_wrapper=self._client_wrapper)
32
-
33
- def connect(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
34
- """
35
- Parameters:
36
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
37
- ---
38
- from mixpeek.client import Mixpeek
39
-
40
- client = Mixpeek(
41
- authorization="YOUR_AUTHORIZATION",
42
- index_id="YOUR_INDEX_ID",
43
- api_key="YOUR_API_KEY",
44
- )
45
- client.storage.connect()
46
- """
47
- _response = self._client_wrapper.httpx_client.request(
48
- "GET",
49
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "storage/connect"),
50
- params=jsonable_encoder(
51
- request_options.get("additional_query_parameters") if request_options is not None else None
52
- ),
53
- headers=jsonable_encoder(
54
- remove_none_from_dict(
55
- {
56
- **self._client_wrapper.get_headers(),
57
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
58
- }
59
- )
60
- ),
61
- timeout=request_options.get("timeout_in_seconds")
62
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
63
- else self._client_wrapper.get_timeout(),
64
- retries=0,
65
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
66
- )
67
- if 200 <= _response.status_code < 300:
68
- return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
69
- if _response.status_code == 400:
70
- raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
71
- if _response.status_code == 401:
72
- raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
73
- if _response.status_code == 403:
74
- raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
75
- if _response.status_code == 404:
76
- raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
77
- if _response.status_code == 422:
78
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
79
- if _response.status_code == 500:
80
- raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
81
- try:
82
- _response_json = _response.json()
83
- except JSONDecodeError:
84
- raise ApiError(status_code=_response.status_code, body=_response.text)
85
- raise ApiError(status_code=_response.status_code, body=_response_json)
86
-
87
-
88
- class AsyncStorageClient:
89
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
90
- self._client_wrapper = client_wrapper
91
- self.sample = AsyncSampleClient(client_wrapper=self._client_wrapper)
92
-
93
- async def connect(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
94
- """
95
- Parameters:
96
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
97
- ---
98
- from mixpeek.client import AsyncMixpeek
99
-
100
- client = AsyncMixpeek(
101
- authorization="YOUR_AUTHORIZATION",
102
- index_id="YOUR_INDEX_ID",
103
- api_key="YOUR_API_KEY",
104
- )
105
- await client.storage.connect()
106
- """
107
- _response = await self._client_wrapper.httpx_client.request(
108
- "GET",
109
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "storage/connect"),
110
- params=jsonable_encoder(
111
- request_options.get("additional_query_parameters") if request_options is not None else None
112
- ),
113
- headers=jsonable_encoder(
114
- remove_none_from_dict(
115
- {
116
- **self._client_wrapper.get_headers(),
117
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
118
- }
119
- )
120
- ),
121
- timeout=request_options.get("timeout_in_seconds")
122
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
123
- else self._client_wrapper.get_timeout(),
124
- retries=0,
125
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
126
- )
127
- if 200 <= _response.status_code < 300:
128
- return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
129
- if _response.status_code == 400:
130
- raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
131
- if _response.status_code == 401:
132
- raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
133
- if _response.status_code == 403:
134
- raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
135
- if _response.status_code == 404:
136
- raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
137
- if _response.status_code == 422:
138
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
139
- if _response.status_code == 500:
140
- raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
141
- try:
142
- _response_json = _response.json()
143
- except JSONDecodeError:
144
- raise ApiError(status_code=_response.status_code, body=_response.text)
145
- raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -1,2 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-