mixpeek 0.11.2__py3-none-any.whl → 0.12.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.
Files changed (111) hide show
  1. mixpeek/__init__.py +83 -1
  2. mixpeek/_base_client.py +2041 -0
  3. mixpeek/_client.py +444 -0
  4. mixpeek/_compat.py +221 -0
  5. mixpeek/_constants.py +14 -0
  6. mixpeek/_exceptions.py +108 -0
  7. mixpeek/_files.py +123 -0
  8. mixpeek/_models.py +788 -0
  9. mixpeek/_qs.py +150 -0
  10. mixpeek/_resource.py +43 -0
  11. mixpeek/_response.py +824 -0
  12. mixpeek/_streaming.py +333 -0
  13. mixpeek/_types.py +219 -0
  14. mixpeek/_utils/__init__.py +56 -0
  15. mixpeek/_utils/_logs.py +25 -0
  16. mixpeek/_utils/_proxy.py +62 -0
  17. mixpeek/_utils/_reflection.py +42 -0
  18. mixpeek/_utils/_streams.py +12 -0
  19. mixpeek/_utils/_sync.py +81 -0
  20. mixpeek/_utils/_transform.py +387 -0
  21. mixpeek/_utils/_typing.py +120 -0
  22. mixpeek/_utils/_utils.py +414 -0
  23. mixpeek/_version.py +4 -0
  24. mixpeek/lib/.keep +4 -0
  25. mixpeek/resources/__init__.py +117 -0
  26. mixpeek/resources/accounts.py +271 -0
  27. mixpeek/resources/assets/__init__.py +33 -0
  28. mixpeek/resources/assets/assets.py +708 -0
  29. mixpeek/resources/assets/features.py +172 -0
  30. mixpeek/resources/collections.py +283 -0
  31. mixpeek/resources/entities/__init__.py +47 -0
  32. mixpeek/resources/entities/entities.py +134 -0
  33. mixpeek/resources/entities/faces.py +514 -0
  34. mixpeek/resources/entities/labels.py +388 -0
  35. mixpeek/resources/features/__init__.py +33 -0
  36. mixpeek/resources/features/features.py +562 -0
  37. mixpeek/resources/features/search.py +731 -0
  38. mixpeek/resources/healthcheck.py +135 -0
  39. mixpeek/resources/index/__init__.py +47 -0
  40. mixpeek/resources/index/images.py +249 -0
  41. mixpeek/resources/index/index.py +289 -0
  42. mixpeek/resources/index/videos.py +249 -0
  43. mixpeek/resources/tasks.py +258 -0
  44. mixpeek/types/__init__.py +31 -0
  45. mixpeek/types/account_update_params.py +28 -0
  46. mixpeek/types/asset_create_params.py +36 -0
  47. mixpeek/types/asset_create_response.py +15 -0
  48. mixpeek/types/asset_response.py +46 -0
  49. mixpeek/types/asset_search_params.py +43 -0
  50. mixpeek/types/asset_search_response.py +15 -0
  51. mixpeek/types/asset_update_params.py +25 -0
  52. mixpeek/types/asset_update_response.py +11 -0
  53. mixpeek/types/assets/__init__.py +3 -0
  54. mixpeek/types/collection_list_params.py +19 -0
  55. mixpeek/types/collection_list_response.py +14 -0
  56. mixpeek/types/entities/__init__.py +13 -0
  57. mixpeek/types/entities/face_create_params.py +21 -0
  58. mixpeek/types/entities/face_list_params.py +18 -0
  59. mixpeek/types/entities/face_list_response.py +15 -0
  60. mixpeek/types/entities/face_response.py +17 -0
  61. mixpeek/types/entities/face_update_params.py +22 -0
  62. mixpeek/types/entities/label_list_params.py +18 -0
  63. mixpeek/types/entities/label_list_response.py +30 -0
  64. mixpeek/types/entities/label_response.py +30 -0
  65. mixpeek/types/entities/label_update_params.py +21 -0
  66. mixpeek/types/feature.py +32 -0
  67. mixpeek/types/feature_list_params.py +37 -0
  68. mixpeek/types/feature_list_response.py +28 -0
  69. mixpeek/types/feature_retrieve_params.py +18 -0
  70. mixpeek/types/feature_update_params.py +16 -0
  71. mixpeek/types/features/__init__.py +8 -0
  72. mixpeek/types/features/search_feedback_params.py +23 -0
  73. mixpeek/types/features/search_file_params.py +29 -0
  74. mixpeek/types/features/search_text_params.py +72 -0
  75. mixpeek/types/features/search_url_params.py +72 -0
  76. mixpeek/types/grouped_asset_data.py +24 -0
  77. mixpeek/types/health_check_response.py +10 -0
  78. mixpeek/types/index/__init__.py +8 -0
  79. mixpeek/types/index/image_url_params.py +135 -0
  80. mixpeek/types/index/image_url_response.py +20 -0
  81. mixpeek/types/index/video_url_params.py +154 -0
  82. mixpeek/types/index/video_url_response.py +20 -0
  83. mixpeek/types/index_text_params.py +77 -0
  84. mixpeek/types/index_text_response.py +14 -0
  85. mixpeek/types/shared/__init__.py +7 -0
  86. mixpeek/types/shared/filter_condition.py +19 -0
  87. mixpeek/types/shared/logical_operator.py +12 -0
  88. mixpeek/types/shared/model_pagination_response.py +21 -0
  89. mixpeek/types/shared/sort_option.py +15 -0
  90. mixpeek/types/shared/task_response.py +15 -0
  91. mixpeek/types/shared_params/__init__.py +4 -0
  92. mixpeek/types/shared_params/logical_operator.py +13 -0
  93. mixpeek/types/shared_params/sort_option.py +15 -0
  94. mixpeek/types/user.py +34 -0
  95. mixpeek-0.12.0.dist-info/METADATA +345 -0
  96. mixpeek-0.12.0.dist-info/RECORD +99 -0
  97. {mixpeek-0.11.2.dist-info → mixpeek-0.12.0.dist-info}/WHEEL +1 -2
  98. mixpeek-0.12.0.dist-info/licenses/LICENSE +201 -0
  99. mixpeek/client.py +0 -27
  100. mixpeek/endpoints/collections.py +0 -86
  101. mixpeek/endpoints/embed.py +0 -66
  102. mixpeek/endpoints/index.py +0 -51
  103. mixpeek/endpoints/register.py +0 -34
  104. mixpeek/endpoints/search.py +0 -44
  105. mixpeek/endpoints/tasks.py +0 -26
  106. mixpeek/endpoints/tools.py +0 -138
  107. mixpeek/exceptions.py +0 -13
  108. mixpeek-0.11.2.dist-info/METADATA +0 -375
  109. mixpeek-0.11.2.dist-info/RECORD +0 -15
  110. mixpeek-0.11.2.dist-info/top_level.txt +0 -1
  111. /mixpeek/{endpoints/__init__.py → py.typed} +0 -0
mixpeek/_client.py ADDED
@@ -0,0 +1,444 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from typing import Any, Union, Mapping
7
+ from typing_extensions import Self, override
8
+
9
+ import httpx
10
+
11
+ from . import resources, _exceptions
12
+ from ._qs import Querystring
13
+ from ._types import (
14
+ NOT_GIVEN,
15
+ Omit,
16
+ Timeout,
17
+ NotGiven,
18
+ Transport,
19
+ ProxiesTypes,
20
+ RequestOptions,
21
+ )
22
+ from ._utils import (
23
+ is_given,
24
+ get_async_library,
25
+ )
26
+ from ._version import __version__
27
+ from ._streaming import Stream as Stream, AsyncStream as AsyncStream
28
+ from ._exceptions import APIStatusError
29
+ from ._base_client import (
30
+ DEFAULT_MAX_RETRIES,
31
+ SyncAPIClient,
32
+ AsyncAPIClient,
33
+ )
34
+
35
+ __all__ = [
36
+ "Timeout",
37
+ "Transport",
38
+ "ProxiesTypes",
39
+ "RequestOptions",
40
+ "resources",
41
+ "Mixpeek",
42
+ "AsyncMixpeek",
43
+ "Client",
44
+ "AsyncClient",
45
+ ]
46
+
47
+
48
+ class Mixpeek(SyncAPIClient):
49
+ accounts: resources.AccountsResource
50
+ features: resources.FeaturesResource
51
+ index: resources.IndexResource
52
+ entities: resources.EntitiesResource
53
+ assets: resources.AssetsResource
54
+ collections: resources.CollectionsResource
55
+ tasks: resources.TasksResource
56
+ healthcheck: resources.HealthcheckResource
57
+ with_raw_response: MixpeekWithRawResponse
58
+ with_streaming_response: MixpeekWithStreamedResponse
59
+
60
+ # client options
61
+ api_key: str
62
+
63
+ def __init__(
64
+ self,
65
+ *,
66
+ api_key: str,
67
+ base_url: str | httpx.URL | None = None,
68
+ timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
69
+ max_retries: int = DEFAULT_MAX_RETRIES,
70
+ default_headers: Mapping[str, str] | None = None,
71
+ default_query: Mapping[str, object] | None = None,
72
+ # Configure a custom httpx client.
73
+ # We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
74
+ # See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
75
+ http_client: httpx.Client | None = None,
76
+ # Enable or disable schema validation for data returned by the API.
77
+ # When enabled an error APIResponseValidationError is raised
78
+ # if the API responds with invalid data for the expected schema.
79
+ #
80
+ # This parameter may be removed or changed in the future.
81
+ # If you rely on this feature, please open a GitHub issue
82
+ # outlining your use-case to help us decide if it should be
83
+ # part of our public interface in the future.
84
+ _strict_response_validation: bool = False,
85
+ ) -> None:
86
+ """Construct a new synchronous mixpeek client instance."""
87
+ self.api_key = api_key
88
+
89
+ if base_url is None:
90
+ base_url = os.environ.get("MIXPEEK_BASE_URL")
91
+ if base_url is None:
92
+ base_url = f"https://api.mixpeek.com/"
93
+
94
+ super().__init__(
95
+ version=__version__,
96
+ base_url=base_url,
97
+ max_retries=max_retries,
98
+ timeout=timeout,
99
+ http_client=http_client,
100
+ custom_headers=default_headers,
101
+ custom_query=default_query,
102
+ _strict_response_validation=_strict_response_validation,
103
+ )
104
+
105
+ self.accounts = resources.AccountsResource(self)
106
+ self.features = resources.FeaturesResource(self)
107
+ self.index = resources.IndexResource(self)
108
+ self.entities = resources.EntitiesResource(self)
109
+ self.assets = resources.AssetsResource(self)
110
+ self.collections = resources.CollectionsResource(self)
111
+ self.tasks = resources.TasksResource(self)
112
+ self.healthcheck = resources.HealthcheckResource(self)
113
+ self.with_raw_response = MixpeekWithRawResponse(self)
114
+ self.with_streaming_response = MixpeekWithStreamedResponse(self)
115
+
116
+ @property
117
+ @override
118
+ def qs(self) -> Querystring:
119
+ return Querystring(array_format="comma")
120
+
121
+ @property
122
+ @override
123
+ def auth_headers(self) -> dict[str, str]:
124
+ api_key = self.api_key
125
+ return {"Authorization": f"Bearer {api_key}"}
126
+
127
+ @property
128
+ @override
129
+ def default_headers(self) -> dict[str, str | Omit]:
130
+ return {
131
+ **super().default_headers,
132
+ "X-Stainless-Async": "false",
133
+ **self._custom_headers,
134
+ }
135
+
136
+ def copy(
137
+ self,
138
+ *,
139
+ api_key: str | None = None,
140
+ base_url: str | httpx.URL | None = None,
141
+ timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
142
+ http_client: httpx.Client | None = None,
143
+ max_retries: int | NotGiven = NOT_GIVEN,
144
+ default_headers: Mapping[str, str] | None = None,
145
+ set_default_headers: Mapping[str, str] | None = None,
146
+ default_query: Mapping[str, object] | None = None,
147
+ set_default_query: Mapping[str, object] | None = None,
148
+ _extra_kwargs: Mapping[str, Any] = {},
149
+ ) -> Self:
150
+ """
151
+ Create a new client instance re-using the same options given to the current client with optional overriding.
152
+ """
153
+ if default_headers is not None and set_default_headers is not None:
154
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
155
+
156
+ if default_query is not None and set_default_query is not None:
157
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
158
+
159
+ headers = self._custom_headers
160
+ if default_headers is not None:
161
+ headers = {**headers, **default_headers}
162
+ elif set_default_headers is not None:
163
+ headers = set_default_headers
164
+
165
+ params = self._custom_query
166
+ if default_query is not None:
167
+ params = {**params, **default_query}
168
+ elif set_default_query is not None:
169
+ params = set_default_query
170
+
171
+ http_client = http_client or self._client
172
+ return self.__class__(
173
+ api_key=api_key or self.api_key,
174
+ base_url=base_url or self.base_url,
175
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
176
+ http_client=http_client,
177
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
178
+ default_headers=headers,
179
+ default_query=params,
180
+ **_extra_kwargs,
181
+ )
182
+
183
+ # Alias for `copy` for nicer inline usage, e.g.
184
+ # client.with_options(timeout=10).foo.create(...)
185
+ with_options = copy
186
+
187
+ @override
188
+ def _make_status_error(
189
+ self,
190
+ err_msg: str,
191
+ *,
192
+ body: object,
193
+ response: httpx.Response,
194
+ ) -> APIStatusError:
195
+ if response.status_code == 400:
196
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
197
+
198
+ if response.status_code == 401:
199
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
200
+
201
+ if response.status_code == 403:
202
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
203
+
204
+ if response.status_code == 404:
205
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
206
+
207
+ if response.status_code == 409:
208
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
209
+
210
+ if response.status_code == 422:
211
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
212
+
213
+ if response.status_code == 429:
214
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
215
+
216
+ if response.status_code >= 500:
217
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
218
+ return APIStatusError(err_msg, response=response, body=body)
219
+
220
+
221
+ class AsyncMixpeek(AsyncAPIClient):
222
+ accounts: resources.AsyncAccountsResource
223
+ features: resources.AsyncFeaturesResource
224
+ index: resources.AsyncIndexResource
225
+ entities: resources.AsyncEntitiesResource
226
+ assets: resources.AsyncAssetsResource
227
+ collections: resources.AsyncCollectionsResource
228
+ tasks: resources.AsyncTasksResource
229
+ healthcheck: resources.AsyncHealthcheckResource
230
+ with_raw_response: AsyncMixpeekWithRawResponse
231
+ with_streaming_response: AsyncMixpeekWithStreamedResponse
232
+
233
+ # client options
234
+ api_key: str
235
+
236
+ def __init__(
237
+ self,
238
+ *,
239
+ api_key: str,
240
+ base_url: str | httpx.URL | None = None,
241
+ timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
242
+ max_retries: int = DEFAULT_MAX_RETRIES,
243
+ default_headers: Mapping[str, str] | None = None,
244
+ default_query: Mapping[str, object] | None = None,
245
+ # Configure a custom httpx client.
246
+ # We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
247
+ # See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
248
+ http_client: httpx.AsyncClient | None = None,
249
+ # Enable or disable schema validation for data returned by the API.
250
+ # When enabled an error APIResponseValidationError is raised
251
+ # if the API responds with invalid data for the expected schema.
252
+ #
253
+ # This parameter may be removed or changed in the future.
254
+ # If you rely on this feature, please open a GitHub issue
255
+ # outlining your use-case to help us decide if it should be
256
+ # part of our public interface in the future.
257
+ _strict_response_validation: bool = False,
258
+ ) -> None:
259
+ """Construct a new async mixpeek client instance."""
260
+ self.api_key = api_key
261
+
262
+ if base_url is None:
263
+ base_url = os.environ.get("MIXPEEK_BASE_URL")
264
+ if base_url is None:
265
+ base_url = f"https://api.mixpeek.com/"
266
+
267
+ super().__init__(
268
+ version=__version__,
269
+ base_url=base_url,
270
+ max_retries=max_retries,
271
+ timeout=timeout,
272
+ http_client=http_client,
273
+ custom_headers=default_headers,
274
+ custom_query=default_query,
275
+ _strict_response_validation=_strict_response_validation,
276
+ )
277
+
278
+ self.accounts = resources.AsyncAccountsResource(self)
279
+ self.features = resources.AsyncFeaturesResource(self)
280
+ self.index = resources.AsyncIndexResource(self)
281
+ self.entities = resources.AsyncEntitiesResource(self)
282
+ self.assets = resources.AsyncAssetsResource(self)
283
+ self.collections = resources.AsyncCollectionsResource(self)
284
+ self.tasks = resources.AsyncTasksResource(self)
285
+ self.healthcheck = resources.AsyncHealthcheckResource(self)
286
+ self.with_raw_response = AsyncMixpeekWithRawResponse(self)
287
+ self.with_streaming_response = AsyncMixpeekWithStreamedResponse(self)
288
+
289
+ @property
290
+ @override
291
+ def qs(self) -> Querystring:
292
+ return Querystring(array_format="comma")
293
+
294
+ @property
295
+ @override
296
+ def auth_headers(self) -> dict[str, str]:
297
+ api_key = self.api_key
298
+ return {"Authorization": f"Bearer {api_key}"}
299
+
300
+ @property
301
+ @override
302
+ def default_headers(self) -> dict[str, str | Omit]:
303
+ return {
304
+ **super().default_headers,
305
+ "X-Stainless-Async": f"async:{get_async_library()}",
306
+ **self._custom_headers,
307
+ }
308
+
309
+ def copy(
310
+ self,
311
+ *,
312
+ api_key: str | None = None,
313
+ base_url: str | httpx.URL | None = None,
314
+ timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
315
+ http_client: httpx.AsyncClient | None = None,
316
+ max_retries: int | NotGiven = NOT_GIVEN,
317
+ default_headers: Mapping[str, str] | None = None,
318
+ set_default_headers: Mapping[str, str] | None = None,
319
+ default_query: Mapping[str, object] | None = None,
320
+ set_default_query: Mapping[str, object] | None = None,
321
+ _extra_kwargs: Mapping[str, Any] = {},
322
+ ) -> Self:
323
+ """
324
+ Create a new client instance re-using the same options given to the current client with optional overriding.
325
+ """
326
+ if default_headers is not None and set_default_headers is not None:
327
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
328
+
329
+ if default_query is not None and set_default_query is not None:
330
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
331
+
332
+ headers = self._custom_headers
333
+ if default_headers is not None:
334
+ headers = {**headers, **default_headers}
335
+ elif set_default_headers is not None:
336
+ headers = set_default_headers
337
+
338
+ params = self._custom_query
339
+ if default_query is not None:
340
+ params = {**params, **default_query}
341
+ elif set_default_query is not None:
342
+ params = set_default_query
343
+
344
+ http_client = http_client or self._client
345
+ return self.__class__(
346
+ api_key=api_key or self.api_key,
347
+ base_url=base_url or self.base_url,
348
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
349
+ http_client=http_client,
350
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
351
+ default_headers=headers,
352
+ default_query=params,
353
+ **_extra_kwargs,
354
+ )
355
+
356
+ # Alias for `copy` for nicer inline usage, e.g.
357
+ # client.with_options(timeout=10).foo.create(...)
358
+ with_options = copy
359
+
360
+ @override
361
+ def _make_status_error(
362
+ self,
363
+ err_msg: str,
364
+ *,
365
+ body: object,
366
+ response: httpx.Response,
367
+ ) -> APIStatusError:
368
+ if response.status_code == 400:
369
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
370
+
371
+ if response.status_code == 401:
372
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
373
+
374
+ if response.status_code == 403:
375
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
376
+
377
+ if response.status_code == 404:
378
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
379
+
380
+ if response.status_code == 409:
381
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
382
+
383
+ if response.status_code == 422:
384
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
385
+
386
+ if response.status_code == 429:
387
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
388
+
389
+ if response.status_code >= 500:
390
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
391
+ return APIStatusError(err_msg, response=response, body=body)
392
+
393
+
394
+ class MixpeekWithRawResponse:
395
+ def __init__(self, client: Mixpeek) -> None:
396
+ self.accounts = resources.AccountsResourceWithRawResponse(client.accounts)
397
+ self.features = resources.FeaturesResourceWithRawResponse(client.features)
398
+ self.index = resources.IndexResourceWithRawResponse(client.index)
399
+ self.entities = resources.EntitiesResourceWithRawResponse(client.entities)
400
+ self.assets = resources.AssetsResourceWithRawResponse(client.assets)
401
+ self.collections = resources.CollectionsResourceWithRawResponse(client.collections)
402
+ self.tasks = resources.TasksResourceWithRawResponse(client.tasks)
403
+ self.healthcheck = resources.HealthcheckResourceWithRawResponse(client.healthcheck)
404
+
405
+
406
+ class AsyncMixpeekWithRawResponse:
407
+ def __init__(self, client: AsyncMixpeek) -> None:
408
+ self.accounts = resources.AsyncAccountsResourceWithRawResponse(client.accounts)
409
+ self.features = resources.AsyncFeaturesResourceWithRawResponse(client.features)
410
+ self.index = resources.AsyncIndexResourceWithRawResponse(client.index)
411
+ self.entities = resources.AsyncEntitiesResourceWithRawResponse(client.entities)
412
+ self.assets = resources.AsyncAssetsResourceWithRawResponse(client.assets)
413
+ self.collections = resources.AsyncCollectionsResourceWithRawResponse(client.collections)
414
+ self.tasks = resources.AsyncTasksResourceWithRawResponse(client.tasks)
415
+ self.healthcheck = resources.AsyncHealthcheckResourceWithRawResponse(client.healthcheck)
416
+
417
+
418
+ class MixpeekWithStreamedResponse:
419
+ def __init__(self, client: Mixpeek) -> None:
420
+ self.accounts = resources.AccountsResourceWithStreamingResponse(client.accounts)
421
+ self.features = resources.FeaturesResourceWithStreamingResponse(client.features)
422
+ self.index = resources.IndexResourceWithStreamingResponse(client.index)
423
+ self.entities = resources.EntitiesResourceWithStreamingResponse(client.entities)
424
+ self.assets = resources.AssetsResourceWithStreamingResponse(client.assets)
425
+ self.collections = resources.CollectionsResourceWithStreamingResponse(client.collections)
426
+ self.tasks = resources.TasksResourceWithStreamingResponse(client.tasks)
427
+ self.healthcheck = resources.HealthcheckResourceWithStreamingResponse(client.healthcheck)
428
+
429
+
430
+ class AsyncMixpeekWithStreamedResponse:
431
+ def __init__(self, client: AsyncMixpeek) -> None:
432
+ self.accounts = resources.AsyncAccountsResourceWithStreamingResponse(client.accounts)
433
+ self.features = resources.AsyncFeaturesResourceWithStreamingResponse(client.features)
434
+ self.index = resources.AsyncIndexResourceWithStreamingResponse(client.index)
435
+ self.entities = resources.AsyncEntitiesResourceWithStreamingResponse(client.entities)
436
+ self.assets = resources.AsyncAssetsResourceWithStreamingResponse(client.assets)
437
+ self.collections = resources.AsyncCollectionsResourceWithStreamingResponse(client.collections)
438
+ self.tasks = resources.AsyncTasksResourceWithStreamingResponse(client.tasks)
439
+ self.healthcheck = resources.AsyncHealthcheckResourceWithStreamingResponse(client.healthcheck)
440
+
441
+
442
+ Client = Mixpeek
443
+
444
+ AsyncClient = AsyncMixpeek
mixpeek/_compat.py ADDED
@@ -0,0 +1,221 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
4
+ from datetime import date, datetime
5
+ from typing_extensions import Self, Literal
6
+
7
+ import pydantic
8
+ from pydantic.fields import FieldInfo
9
+
10
+ from ._types import IncEx, StrBytesIntFloat
11
+
12
+ _T = TypeVar("_T")
13
+ _ModelT = TypeVar("_ModelT", bound=pydantic.BaseModel)
14
+
15
+ # --------------- Pydantic v2 compatibility ---------------
16
+
17
+ # Pyright incorrectly reports some of our functions as overriding a method when they don't
18
+ # pyright: reportIncompatibleMethodOverride=false
19
+
20
+ PYDANTIC_V2 = pydantic.VERSION.startswith("2.")
21
+
22
+ # v1 re-exports
23
+ if TYPE_CHECKING:
24
+
25
+ def parse_date(value: date | StrBytesIntFloat) -> date: # noqa: ARG001
26
+ ...
27
+
28
+ def parse_datetime(value: Union[datetime, StrBytesIntFloat]) -> datetime: # noqa: ARG001
29
+ ...
30
+
31
+ def get_args(t: type[Any]) -> tuple[Any, ...]: # noqa: ARG001
32
+ ...
33
+
34
+ def is_union(tp: type[Any] | None) -> bool: # noqa: ARG001
35
+ ...
36
+
37
+ def get_origin(t: type[Any]) -> type[Any] | None: # noqa: ARG001
38
+ ...
39
+
40
+ def is_literal_type(type_: type[Any]) -> bool: # noqa: ARG001
41
+ ...
42
+
43
+ def is_typeddict(type_: type[Any]) -> bool: # noqa: ARG001
44
+ ...
45
+
46
+ else:
47
+ if PYDANTIC_V2:
48
+ from pydantic.v1.typing import (
49
+ get_args as get_args,
50
+ is_union as is_union,
51
+ get_origin as get_origin,
52
+ is_typeddict as is_typeddict,
53
+ is_literal_type as is_literal_type,
54
+ )
55
+ from pydantic.v1.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
56
+ else:
57
+ from pydantic.typing import (
58
+ get_args as get_args,
59
+ is_union as is_union,
60
+ get_origin as get_origin,
61
+ is_typeddict as is_typeddict,
62
+ is_literal_type as is_literal_type,
63
+ )
64
+ from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
65
+
66
+
67
+ # refactored config
68
+ if TYPE_CHECKING:
69
+ from pydantic import ConfigDict as ConfigDict
70
+ else:
71
+ if PYDANTIC_V2:
72
+ from pydantic import ConfigDict
73
+ else:
74
+ # TODO: provide an error message here?
75
+ ConfigDict = None
76
+
77
+
78
+ # renamed methods / properties
79
+ def parse_obj(model: type[_ModelT], value: object) -> _ModelT:
80
+ if PYDANTIC_V2:
81
+ return model.model_validate(value)
82
+ else:
83
+ return cast(_ModelT, model.parse_obj(value)) # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
84
+
85
+
86
+ def field_is_required(field: FieldInfo) -> bool:
87
+ if PYDANTIC_V2:
88
+ return field.is_required()
89
+ return field.required # type: ignore
90
+
91
+
92
+ def field_get_default(field: FieldInfo) -> Any:
93
+ value = field.get_default()
94
+ if PYDANTIC_V2:
95
+ from pydantic_core import PydanticUndefined
96
+
97
+ if value == PydanticUndefined:
98
+ return None
99
+ return value
100
+ return value
101
+
102
+
103
+ def field_outer_type(field: FieldInfo) -> Any:
104
+ if PYDANTIC_V2:
105
+ return field.annotation
106
+ return field.outer_type_ # type: ignore
107
+
108
+
109
+ def get_model_config(model: type[pydantic.BaseModel]) -> Any:
110
+ if PYDANTIC_V2:
111
+ return model.model_config
112
+ return model.__config__ # type: ignore
113
+
114
+
115
+ def get_model_fields(model: type[pydantic.BaseModel]) -> dict[str, FieldInfo]:
116
+ if PYDANTIC_V2:
117
+ return model.model_fields
118
+ return model.__fields__ # type: ignore
119
+
120
+
121
+ def model_copy(model: _ModelT, *, deep: bool = False) -> _ModelT:
122
+ if PYDANTIC_V2:
123
+ return model.model_copy(deep=deep)
124
+ return model.copy(deep=deep) # type: ignore
125
+
126
+
127
+ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
128
+ if PYDANTIC_V2:
129
+ return model.model_dump_json(indent=indent)
130
+ return model.json(indent=indent) # type: ignore
131
+
132
+
133
+ def model_dump(
134
+ model: pydantic.BaseModel,
135
+ *,
136
+ exclude: IncEx | None = None,
137
+ exclude_unset: bool = False,
138
+ exclude_defaults: bool = False,
139
+ warnings: bool = True,
140
+ mode: Literal["json", "python"] = "python",
141
+ ) -> dict[str, Any]:
142
+ if PYDANTIC_V2 or hasattr(model, "model_dump"):
143
+ return model.model_dump(
144
+ mode=mode,
145
+ exclude=exclude,
146
+ exclude_unset=exclude_unset,
147
+ exclude_defaults=exclude_defaults,
148
+ warnings=warnings,
149
+ )
150
+ return cast(
151
+ "dict[str, Any]",
152
+ model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
153
+ exclude=exclude,
154
+ exclude_unset=exclude_unset,
155
+ exclude_defaults=exclude_defaults,
156
+ ),
157
+ )
158
+
159
+
160
+ def model_parse(model: type[_ModelT], data: Any) -> _ModelT:
161
+ if PYDANTIC_V2:
162
+ return model.model_validate(data)
163
+ return model.parse_obj(data) # pyright: ignore[reportDeprecated]
164
+
165
+
166
+ # generic models
167
+ if TYPE_CHECKING:
168
+
169
+ class GenericModel(pydantic.BaseModel): ...
170
+
171
+ else:
172
+ if PYDANTIC_V2:
173
+ # there no longer needs to be a distinction in v2 but
174
+ # we still have to create our own subclass to avoid
175
+ # inconsistent MRO ordering errors
176
+ class GenericModel(pydantic.BaseModel): ...
177
+
178
+ else:
179
+ import pydantic.generics
180
+
181
+ class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ...
182
+
183
+
184
+ # cached properties
185
+ if TYPE_CHECKING:
186
+ cached_property = property
187
+
188
+ # we define a separate type (copied from typeshed)
189
+ # that represents that `cached_property` is `set`able
190
+ # at runtime, which differs from `@property`.
191
+ #
192
+ # this is a separate type as editors likely special case
193
+ # `@property` and we don't want to cause issues just to have
194
+ # more helpful internal types.
195
+
196
+ class typed_cached_property(Generic[_T]):
197
+ func: Callable[[Any], _T]
198
+ attrname: str | None
199
+
200
+ def __init__(self, func: Callable[[Any], _T]) -> None: ...
201
+
202
+ @overload
203
+ def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: ...
204
+
205
+ @overload
206
+ def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: ...
207
+
208
+ def __get__(self, instance: object, owner: type[Any] | None = None) -> _T | Self:
209
+ raise NotImplementedError()
210
+
211
+ def __set_name__(self, owner: type[Any], name: str) -> None: ...
212
+
213
+ # __set__ is not defined at runtime, but @cached_property is designed to be settable
214
+ def __set__(self, instance: object, value: _T) -> None: ...
215
+ else:
216
+ try:
217
+ from functools import cached_property as cached_property
218
+ except ImportError:
219
+ from cached_property import cached_property as cached_property
220
+
221
+ typed_cached_property = cached_property
mixpeek/_constants.py ADDED
@@ -0,0 +1,14 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import httpx
4
+
5
+ RAW_RESPONSE_HEADER = "X-Stainless-Raw-Response"
6
+ OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to"
7
+
8
+ # default timeout is 1 minute
9
+ DEFAULT_TIMEOUT = httpx.Timeout(timeout=60.0, connect=5.0)
10
+ DEFAULT_MAX_RETRIES = 2
11
+ DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)
12
+
13
+ INITIAL_RETRY_DELAY = 0.5
14
+ MAX_RETRY_DELAY = 8.0