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.
Files changed (44) hide show
  1. mixpeek/__init__.py +24 -15
  2. mixpeek/base_client.py +883 -22
  3. mixpeek/client.py +7 -7
  4. mixpeek/core/client_wrapper.py +1 -1
  5. mixpeek/environment.py +7 -0
  6. mixpeek/{pipelines → pipeline}/client.py +60 -132
  7. mixpeek/storage/__init__.py +3 -0
  8. mixpeek/storage/client.py +7 -116
  9. mixpeek/storage/sample/client.py +282 -0
  10. mixpeek/types/__init__.py +18 -10
  11. mixpeek/types/{embedding_request.py → api_key.py} +4 -5
  12. mixpeek/types/configs_response.py +14 -3
  13. mixpeek/types/connection.py +1 -1
  14. mixpeek/types/{field_schema.py → destination.py} +15 -6
  15. mixpeek/types/embedding_response.py +6 -2
  16. mixpeek/types/extract_response.py +39 -0
  17. mixpeek/types/field_type.py +1 -1
  18. mixpeek/types/generation_response.py +6 -4
  19. mixpeek/types/message.py +9 -2
  20. mixpeek/types/metadata.py +0 -2
  21. mixpeek/types/modality.py +1 -1
  22. mixpeek/types/model.py +10 -2
  23. mixpeek/types/models.py +5 -0
  24. mixpeek/types/pipeline_response.py +19 -9
  25. mixpeek/types/{configs_request.py → pipeline_task_response.py} +5 -4
  26. mixpeek/types/source.py +43 -0
  27. mixpeek/types/source_destination_mapping.py +44 -0
  28. mixpeek/types/user.py +36 -0
  29. mixpeek/types/{destination_schema.py → workflow_code_response.py} +2 -4
  30. mixpeek/user/client.py +308 -0
  31. mixpeek/{workflows → workflow}/client.py +127 -10
  32. {mixpeek-0.6.1.dist-info → mixpeek-0.6.5.dist-info}/METADATA +1 -1
  33. mixpeek-0.6.5.dist-info/RECORD +75 -0
  34. mixpeek/generators/client.py +0 -239
  35. mixpeek/parse/client.py +0 -349
  36. mixpeek/parse_client.py +0 -14
  37. mixpeek/types/source_schema.py +0 -32
  38. mixpeek-0.6.1.dist-info/RECORD +0 -71
  39. /mixpeek/{generators → pipeline}/__init__.py +0 -0
  40. /mixpeek/{parse → storage/sample}/__init__.py +0 -0
  41. /mixpeek/{pipelines → user}/__init__.py +0 -0
  42. /mixpeek/{workflows → workflow}/__init__.py +0 -0
  43. {mixpeek-0.6.1.dist-info → mixpeek-0.6.5.dist-info}/LICENSE +0 -0
  44. {mixpeek-0.6.1.dist-info → mixpeek-0.6.5.dist-info}/WHEEL +0 -0
@@ -4,7 +4,6 @@ import datetime as dt
4
4
  import typing
5
5
 
6
6
  from ..core.datetime_utils import serialize_datetime
7
- from .modality import Modality
8
7
 
9
8
  try:
10
9
  import pydantic.v1 as pydantic # type: ignore
@@ -12,9 +11,11 @@ except ImportError:
12
11
  import pydantic # type: ignore
13
12
 
14
13
 
15
- class ConfigsRequest(pydantic.BaseModel):
16
- modality: typing.Optional[Modality] = None
17
- model: typing.Optional[str] = None
14
+ class PipelineTaskResponse(pydantic.BaseModel):
15
+ task_id: str = pydantic.Field()
16
+ """
17
+ The ID of the task
18
+ """
18
19
 
19
20
  def json(self, **kwargs: typing.Any) -> str:
20
21
  kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
@@ -0,0 +1,43 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ..core.datetime_utils import serialize_datetime
7
+ from .field_type import FieldType
8
+
9
+ try:
10
+ import pydantic.v1 as pydantic # type: ignore
11
+ except ImportError:
12
+ import pydantic # type: ignore
13
+
14
+
15
+ class Source(pydantic.BaseModel):
16
+ field: str = pydantic.Field()
17
+ """
18
+ The field name
19
+ """
20
+
21
+ type: FieldType = pydantic.Field()
22
+ """
23
+ The type of the field
24
+ """
25
+
26
+ settings: typing.Dict[str, typing.Any] = pydantic.Field()
27
+ """
28
+ The settings for the field
29
+ """
30
+
31
+ def json(self, **kwargs: typing.Any) -> str:
32
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
33
+ return super().json(**kwargs_with_defaults)
34
+
35
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
36
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
37
+ return super().dict(**kwargs_with_defaults)
38
+
39
+ class Config:
40
+ frozen = True
41
+ smart_union = True
42
+ extra = pydantic.Extra.allow
43
+ json_encoders = {dt.datetime: serialize_datetime}
@@ -0,0 +1,44 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ..core.datetime_utils import serialize_datetime
7
+ from .destination import Destination
8
+ from .source import Source
9
+
10
+ try:
11
+ import pydantic.v1 as pydantic # type: ignore
12
+ except ImportError:
13
+ import pydantic # type: ignore
14
+
15
+
16
+ class SourceDestinationMapping(pydantic.BaseModel):
17
+ embedding_model: str = pydantic.Field()
18
+ """
19
+ The embedding model
20
+ """
21
+
22
+ source: Source = pydantic.Field()
23
+ """
24
+ The source
25
+ """
26
+
27
+ destination: Destination = pydantic.Field()
28
+ """
29
+ The destination
30
+ """
31
+
32
+ def json(self, **kwargs: typing.Any) -> str:
33
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
34
+ return super().json(**kwargs_with_defaults)
35
+
36
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
37
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
38
+ return super().dict(**kwargs_with_defaults)
39
+
40
+ class Config:
41
+ frozen = True
42
+ smart_union = True
43
+ extra = pydantic.Extra.allow
44
+ json_encoders = {dt.datetime: serialize_datetime}
mixpeek/types/user.py ADDED
@@ -0,0 +1,36 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ..core.datetime_utils import serialize_datetime
7
+ from .api_key import ApiKey
8
+ from .connection import Connection
9
+
10
+ try:
11
+ import pydantic.v1 as pydantic # type: ignore
12
+ except ImportError:
13
+ import pydantic # type: ignore
14
+
15
+
16
+ class User(pydantic.BaseModel):
17
+ user_id: typing.Optional[str] = None
18
+ email: str
19
+ api_keys: typing.Optional[typing.List[ApiKey]] = None
20
+ index_ids: typing.Optional[typing.List[str]] = None
21
+ metadata: typing.Optional[typing.Dict[str, typing.Any]] = None
22
+ connections: typing.Optional[typing.List[Connection]] = None
23
+
24
+ def json(self, **kwargs: typing.Any) -> str:
25
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
26
+ return super().json(**kwargs_with_defaults)
27
+
28
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
29
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
30
+ return super().dict(**kwargs_with_defaults)
31
+
32
+ class Config:
33
+ frozen = True
34
+ smart_union = True
35
+ extra = pydantic.Extra.allow
36
+ json_encoders = {dt.datetime: serialize_datetime}
@@ -11,10 +11,8 @@ except ImportError:
11
11
  import pydantic # type: ignore
12
12
 
13
13
 
14
- class DestinationSchema(pydantic.BaseModel):
15
- collection: str
16
- new_field_name: str
17
- new_embeddings: str
14
+ class WorkflowCodeResponse(pydantic.BaseModel):
15
+ code_as_string: str
18
16
 
19
17
  def json(self, **kwargs: typing.Any) -> str:
20
18
  kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
mixpeek/user/client.py ADDED
@@ -0,0 +1,308 @@
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.api_key import ApiKey
19
+ from ..types.connection import Connection
20
+ from ..types.error_response import ErrorResponse
21
+ from ..types.http_validation_error import HttpValidationError
22
+ from ..types.user import User
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 UserClient:
34
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
35
+ self._client_wrapper = client_wrapper
36
+
37
+ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> User:
38
+ """
39
+ Parameters:
40
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
41
+ ---
42
+ from mixpeek.client import Mixpeek
43
+
44
+ client = Mixpeek(
45
+ authorization="YOUR_AUTHORIZATION",
46
+ index_id="YOUR_INDEX_ID",
47
+ api_key="YOUR_API_KEY",
48
+ )
49
+ client.user.get()
50
+ """
51
+ _response = self._client_wrapper.httpx_client.request(
52
+ "GET",
53
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users"),
54
+ params=jsonable_encoder(
55
+ request_options.get("additional_query_parameters") if request_options is not None else None
56
+ ),
57
+ headers=jsonable_encoder(
58
+ remove_none_from_dict(
59
+ {
60
+ **self._client_wrapper.get_headers(),
61
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
62
+ }
63
+ )
64
+ ),
65
+ timeout=request_options.get("timeout_in_seconds")
66
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
67
+ else self._client_wrapper.get_timeout(),
68
+ retries=0,
69
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
70
+ )
71
+ if 200 <= _response.status_code < 300:
72
+ return pydantic.parse_obj_as(User, _response.json()) # type: ignore
73
+ if _response.status_code == 400:
74
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
75
+ if _response.status_code == 401:
76
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
77
+ if _response.status_code == 403:
78
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
79
+ if _response.status_code == 404:
80
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
81
+ if _response.status_code == 422:
82
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
83
+ if _response.status_code == 500:
84
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
85
+ try:
86
+ _response_json = _response.json()
87
+ except JSONDecodeError:
88
+ raise ApiError(status_code=_response.status_code, body=_response.text)
89
+ raise ApiError(status_code=_response.status_code, body=_response_json)
90
+
91
+ def update(
92
+ self,
93
+ *,
94
+ api_keys: typing.Optional[typing.Sequence[ApiKey]] = OMIT,
95
+ metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
96
+ connections: typing.Optional[typing.Sequence[Connection]] = OMIT,
97
+ request_options: typing.Optional[RequestOptions] = None,
98
+ ) -> User:
99
+ """
100
+ Parameters:
101
+ - api_keys: typing.Optional[typing.Sequence[ApiKey]].
102
+
103
+ - metadata: typing.Optional[typing.Dict[str, typing.Any]].
104
+
105
+ - connections: typing.Optional[typing.Sequence[Connection]].
106
+
107
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
108
+ ---
109
+ from mixpeek.client import Mixpeek
110
+
111
+ client = Mixpeek(
112
+ authorization="YOUR_AUTHORIZATION",
113
+ index_id="YOUR_INDEX_ID",
114
+ api_key="YOUR_API_KEY",
115
+ )
116
+ client.user.update()
117
+ """
118
+ _request: typing.Dict[str, typing.Any] = {}
119
+ if api_keys is not OMIT:
120
+ _request["api_keys"] = api_keys
121
+ if metadata is not OMIT:
122
+ _request["metadata"] = metadata
123
+ if connections is not OMIT:
124
+ _request["connections"] = connections
125
+ _response = self._client_wrapper.httpx_client.request(
126
+ "PUT",
127
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users"),
128
+ params=jsonable_encoder(
129
+ request_options.get("additional_query_parameters") if request_options is not None else None
130
+ ),
131
+ json=jsonable_encoder(_request)
132
+ if request_options is None or request_options.get("additional_body_parameters") is None
133
+ else {
134
+ **jsonable_encoder(_request),
135
+ **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
136
+ },
137
+ headers=jsonable_encoder(
138
+ remove_none_from_dict(
139
+ {
140
+ **self._client_wrapper.get_headers(),
141
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
142
+ }
143
+ )
144
+ ),
145
+ timeout=request_options.get("timeout_in_seconds")
146
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
147
+ else self._client_wrapper.get_timeout(),
148
+ retries=0,
149
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
150
+ )
151
+ if 200 <= _response.status_code < 300:
152
+ return pydantic.parse_obj_as(User, _response.json()) # type: ignore
153
+ if _response.status_code == 400:
154
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
155
+ if _response.status_code == 401:
156
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
157
+ if _response.status_code == 403:
158
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
159
+ if _response.status_code == 404:
160
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
161
+ if _response.status_code == 422:
162
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
163
+ if _response.status_code == 500:
164
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
165
+ try:
166
+ _response_json = _response.json()
167
+ except JSONDecodeError:
168
+ raise ApiError(status_code=_response.status_code, body=_response.text)
169
+ raise ApiError(status_code=_response.status_code, body=_response_json)
170
+
171
+
172
+ class AsyncUserClient:
173
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
174
+ self._client_wrapper = client_wrapper
175
+
176
+ async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> User:
177
+ """
178
+ Parameters:
179
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
180
+ ---
181
+ from mixpeek.client import AsyncMixpeek
182
+
183
+ client = AsyncMixpeek(
184
+ authorization="YOUR_AUTHORIZATION",
185
+ index_id="YOUR_INDEX_ID",
186
+ api_key="YOUR_API_KEY",
187
+ )
188
+ await client.user.get()
189
+ """
190
+ _response = await self._client_wrapper.httpx_client.request(
191
+ "GET",
192
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users"),
193
+ params=jsonable_encoder(
194
+ request_options.get("additional_query_parameters") if request_options is not None else None
195
+ ),
196
+ headers=jsonable_encoder(
197
+ remove_none_from_dict(
198
+ {
199
+ **self._client_wrapper.get_headers(),
200
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
201
+ }
202
+ )
203
+ ),
204
+ timeout=request_options.get("timeout_in_seconds")
205
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
206
+ else self._client_wrapper.get_timeout(),
207
+ retries=0,
208
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
209
+ )
210
+ if 200 <= _response.status_code < 300:
211
+ return pydantic.parse_obj_as(User, _response.json()) # type: ignore
212
+ if _response.status_code == 400:
213
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
214
+ if _response.status_code == 401:
215
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
216
+ if _response.status_code == 403:
217
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
218
+ if _response.status_code == 404:
219
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
220
+ if _response.status_code == 422:
221
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
222
+ if _response.status_code == 500:
223
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
224
+ try:
225
+ _response_json = _response.json()
226
+ except JSONDecodeError:
227
+ raise ApiError(status_code=_response.status_code, body=_response.text)
228
+ raise ApiError(status_code=_response.status_code, body=_response_json)
229
+
230
+ async def update(
231
+ self,
232
+ *,
233
+ api_keys: typing.Optional[typing.Sequence[ApiKey]] = OMIT,
234
+ metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
235
+ connections: typing.Optional[typing.Sequence[Connection]] = OMIT,
236
+ request_options: typing.Optional[RequestOptions] = None,
237
+ ) -> User:
238
+ """
239
+ Parameters:
240
+ - api_keys: typing.Optional[typing.Sequence[ApiKey]].
241
+
242
+ - metadata: typing.Optional[typing.Dict[str, typing.Any]].
243
+
244
+ - connections: typing.Optional[typing.Sequence[Connection]].
245
+
246
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
247
+ ---
248
+ from mixpeek.client import AsyncMixpeek
249
+
250
+ client = AsyncMixpeek(
251
+ authorization="YOUR_AUTHORIZATION",
252
+ index_id="YOUR_INDEX_ID",
253
+ api_key="YOUR_API_KEY",
254
+ )
255
+ await client.user.update()
256
+ """
257
+ _request: typing.Dict[str, typing.Any] = {}
258
+ if api_keys is not OMIT:
259
+ _request["api_keys"] = api_keys
260
+ if metadata is not OMIT:
261
+ _request["metadata"] = metadata
262
+ if connections is not OMIT:
263
+ _request["connections"] = connections
264
+ _response = await self._client_wrapper.httpx_client.request(
265
+ "PUT",
266
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users"),
267
+ params=jsonable_encoder(
268
+ request_options.get("additional_query_parameters") if request_options is not None else None
269
+ ),
270
+ json=jsonable_encoder(_request)
271
+ if request_options is None or request_options.get("additional_body_parameters") is None
272
+ else {
273
+ **jsonable_encoder(_request),
274
+ **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
275
+ },
276
+ headers=jsonable_encoder(
277
+ remove_none_from_dict(
278
+ {
279
+ **self._client_wrapper.get_headers(),
280
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
281
+ }
282
+ )
283
+ ),
284
+ timeout=request_options.get("timeout_in_seconds")
285
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
286
+ else self._client_wrapper.get_timeout(),
287
+ retries=0,
288
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
289
+ )
290
+ if 200 <= _response.status_code < 300:
291
+ return pydantic.parse_obj_as(User, _response.json()) # type: ignore
292
+ if _response.status_code == 400:
293
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
294
+ if _response.status_code == 401:
295
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
296
+ if _response.status_code == 403:
297
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
298
+ if _response.status_code == 404:
299
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
300
+ if _response.status_code == 422:
301
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
302
+ if _response.status_code == 500:
303
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
304
+ try:
305
+ _response_json = _response.json()
306
+ except JSONDecodeError:
307
+ raise ApiError(status_code=_response.status_code, body=_response.text)
308
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -18,6 +18,7 @@ from ..errors.unauthorized_error import UnauthorizedError
18
18
  from ..errors.unprocessable_entity_error import UnprocessableEntityError
19
19
  from ..types.error_response import ErrorResponse
20
20
  from ..types.http_validation_error import HttpValidationError
21
+ from ..types.workflow_code_response import WorkflowCodeResponse
21
22
  from ..types.workflow_response import WorkflowResponse
22
23
  from ..types.workflow_settings import WorkflowSettings
23
24
 
@@ -30,7 +31,7 @@ except ImportError:
30
31
  OMIT = typing.cast(typing.Any, ...)
31
32
 
32
33
 
33
- class WorkflowsClient:
34
+ class WorkflowClient:
34
35
  def __init__(self, *, client_wrapper: SyncClientWrapper):
35
36
  self._client_wrapper = client_wrapper
36
37
 
@@ -71,9 +72,8 @@ class WorkflowsClient:
71
72
  authorization="YOUR_AUTHORIZATION",
72
73
  index_id="YOUR_INDEX_ID",
73
74
  api_key="YOUR_API_KEY",
74
- base_url="https://yourhost.com/path/to/api",
75
75
  )
76
- client.workflows.create(
76
+ client.workflow.create(
77
77
  code_as_string="code_as_string",
78
78
  settings=WorkflowSettings(),
79
79
  )
@@ -159,9 +159,8 @@ class WorkflowsClient:
159
159
  authorization="YOUR_AUTHORIZATION",
160
160
  index_id="YOUR_INDEX_ID",
161
161
  api_key="YOUR_API_KEY",
162
- base_url="https://yourhost.com/path/to/api",
163
162
  )
164
- client.workflows.invoke(
163
+ client.workflow.invoke(
165
164
  workflow_id="workflow_id",
166
165
  request={},
167
166
  )
@@ -223,8 +222,67 @@ class WorkflowsClient:
223
222
  raise ApiError(status_code=_response.status_code, body=_response.text)
224
223
  raise ApiError(status_code=_response.status_code, body=_response_json)
225
224
 
225
+ def code(self, *, request: str, request_options: typing.Optional[RequestOptions] = None) -> WorkflowCodeResponse:
226
+ """
227
+ Parameters:
228
+ - request: str.
229
+
230
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
231
+ ---
232
+ from mixpeek.client import Mixpeek
233
+
234
+ client = Mixpeek(
235
+ authorization="YOUR_AUTHORIZATION",
236
+ index_id="YOUR_INDEX_ID",
237
+ api_key="YOUR_API_KEY",
238
+ )
239
+ client.workflow.code(
240
+ request="string",
241
+ )
242
+ """
243
+ _response = self._client_wrapper.httpx_client.request(
244
+ "POST",
245
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "workflows/code"),
246
+ params=jsonable_encoder(
247
+ request_options.get("additional_query_parameters") if request_options is not None else None
248
+ ),
249
+ json=jsonable_encoder(request),
250
+ headers=jsonable_encoder(
251
+ remove_none_from_dict(
252
+ {
253
+ **self._client_wrapper.get_headers(),
254
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
255
+ }
256
+ )
257
+ ),
258
+ timeout=request_options.get("timeout_in_seconds")
259
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
260
+ else self._client_wrapper.get_timeout(),
261
+ retries=0,
262
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
263
+ )
264
+ if 200 <= _response.status_code < 300:
265
+ return pydantic.parse_obj_as(WorkflowCodeResponse, _response.json()) # type: ignore
266
+ if _response.status_code == 400:
267
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
268
+ if _response.status_code == 401:
269
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
270
+ if _response.status_code == 403:
271
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
272
+ if _response.status_code == 404:
273
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
274
+ if _response.status_code == 422:
275
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
276
+ if _response.status_code == 500:
277
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
278
+ try:
279
+ _response_json = _response.json()
280
+ except JSONDecodeError:
281
+ raise ApiError(status_code=_response.status_code, body=_response.text)
282
+ raise ApiError(status_code=_response.status_code, body=_response_json)
283
+
226
284
 
227
- class AsyncWorkflowsClient:
285
+ class AsyncWorkflowClient:
228
286
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
229
287
  self._client_wrapper = client_wrapper
230
288
 
@@ -265,9 +323,8 @@ class AsyncWorkflowsClient:
265
323
  authorization="YOUR_AUTHORIZATION",
266
324
  index_id="YOUR_INDEX_ID",
267
325
  api_key="YOUR_API_KEY",
268
- base_url="https://yourhost.com/path/to/api",
269
326
  )
270
- await client.workflows.create(
327
+ await client.workflow.create(
271
328
  code_as_string="code_as_string",
272
329
  settings=WorkflowSettings(),
273
330
  )
@@ -353,9 +410,8 @@ class AsyncWorkflowsClient:
353
410
  authorization="YOUR_AUTHORIZATION",
354
411
  index_id="YOUR_INDEX_ID",
355
412
  api_key="YOUR_API_KEY",
356
- base_url="https://yourhost.com/path/to/api",
357
413
  )
358
- await client.workflows.invoke(
414
+ await client.workflow.invoke(
359
415
  workflow_id="workflow_id",
360
416
  request={},
361
417
  )
@@ -416,3 +472,64 @@ class AsyncWorkflowsClient:
416
472
  except JSONDecodeError:
417
473
  raise ApiError(status_code=_response.status_code, body=_response.text)
418
474
  raise ApiError(status_code=_response.status_code, body=_response_json)
475
+
476
+ async def code(
477
+ self, *, request: str, request_options: typing.Optional[RequestOptions] = None
478
+ ) -> WorkflowCodeResponse:
479
+ """
480
+ Parameters:
481
+ - request: str.
482
+
483
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
484
+ ---
485
+ from mixpeek.client import AsyncMixpeek
486
+
487
+ client = AsyncMixpeek(
488
+ authorization="YOUR_AUTHORIZATION",
489
+ index_id="YOUR_INDEX_ID",
490
+ api_key="YOUR_API_KEY",
491
+ )
492
+ await client.workflow.code(
493
+ request="string",
494
+ )
495
+ """
496
+ _response = await self._client_wrapper.httpx_client.request(
497
+ "POST",
498
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "workflows/code"),
499
+ params=jsonable_encoder(
500
+ request_options.get("additional_query_parameters") if request_options is not None else None
501
+ ),
502
+ json=jsonable_encoder(request),
503
+ headers=jsonable_encoder(
504
+ remove_none_from_dict(
505
+ {
506
+ **self._client_wrapper.get_headers(),
507
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
508
+ }
509
+ )
510
+ ),
511
+ timeout=request_options.get("timeout_in_seconds")
512
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
513
+ else self._client_wrapper.get_timeout(),
514
+ retries=0,
515
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
516
+ )
517
+ if 200 <= _response.status_code < 300:
518
+ return pydantic.parse_obj_as(WorkflowCodeResponse, _response.json()) # type: ignore
519
+ if _response.status_code == 400:
520
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
521
+ if _response.status_code == 401:
522
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
523
+ if _response.status_code == 403:
524
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
525
+ if _response.status_code == 404:
526
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
527
+ if _response.status_code == 422:
528
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
529
+ if _response.status_code == 500:
530
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
531
+ try:
532
+ _response_json = _response.json()
533
+ except JSONDecodeError:
534
+ raise ApiError(status_code=_response.status_code, body=_response.text)
535
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mixpeek
3
- Version: 0.6.1
3
+ Version: 0.6.5
4
4
  Summary:
5
5
  Requires-Python: >=3.8,<4.0
6
6
  Classifier: Programming Language :: Python :: 3