mixpeek 0.13.2__py3-none-any.whl → 0.14.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.
mixpeek/sdk.py CHANGED
@@ -7,7 +7,7 @@ from .utils.logger import Logger, get_default_logger
7
7
  from .utils.retries import RetryConfig
8
8
  import httpx
9
9
  from mixpeek import models, utils
10
- from mixpeek._hooks import HookContext, SDKHooks
10
+ from mixpeek._hooks import SDKHooks
11
11
  from mixpeek.assets import Assets
12
12
  from mixpeek.collections import Collections
13
13
  from mixpeek.featureextractors import FeatureExtractors
@@ -20,7 +20,7 @@ from mixpeek.organizations import Organizations
20
20
  from mixpeek.searchinteractions import SearchInteractions
21
21
  from mixpeek.tasks import Tasks
22
22
  from mixpeek.types import OptionalNullable, UNSET
23
- from typing import Any, Dict, Mapping, Optional
23
+ from typing import Any, Callable, Dict, Optional, Union
24
24
 
25
25
 
26
26
  class Mixpeek(BaseSDK):
@@ -40,6 +40,7 @@ class Mixpeek(BaseSDK):
40
40
 
41
41
  def __init__(
42
42
  self,
43
+ bearer_auth: Optional[Union[Optional[str], Callable[[], Optional[str]]]] = None,
43
44
  server_idx: Optional[int] = None,
44
45
  server_url: Optional[str] = None,
45
46
  url_params: Optional[Dict[str, str]] = None,
@@ -51,6 +52,7 @@ class Mixpeek(BaseSDK):
51
52
  ) -> None:
52
53
  r"""Instantiates the SDK configuring it with the provided parameters.
53
54
 
55
+ :param bearer_auth: The bearer_auth required for authentication
54
56
  :param server_idx: The index of the server to use for all methods
55
57
  :param server_url: The server URL to use for all methods
56
58
  :param url_params: Parameters to optionally template the server URL with
@@ -76,6 +78,12 @@ class Mixpeek(BaseSDK):
76
78
  type(async_client), AsyncHttpClient
77
79
  ), "The provided async_client must implement the AsyncHttpClient protocol."
78
80
 
81
+ security: Any = None
82
+ if callable(bearer_auth):
83
+ security = lambda: models.Security(bearer_auth=bearer_auth()) # pylint: disable=unnecessary-lambda-assignment
84
+ else:
85
+ security = models.Security(bearer_auth=bearer_auth)
86
+
79
87
  if server_url is not None:
80
88
  if url_params is not None:
81
89
  server_url = utils.template_url(server_url, url_params)
@@ -85,6 +93,7 @@ class Mixpeek(BaseSDK):
85
93
  SDKConfiguration(
86
94
  client=client,
87
95
  async_client=async_client,
96
+ security=security,
88
97
  server_url=server_url,
89
98
  server_idx=server_idx,
90
99
  retry_config=retry_config,
@@ -133,149 +142,3 @@ class Mixpeek(BaseSDK):
133
142
  async def __aexit__(self, exc_type, exc_val, exc_tb):
134
143
  if self.sdk_configuration.async_client is not None:
135
144
  await self.sdk_configuration.async_client.aclose()
136
-
137
- def debug_openapi_debug_openapi_get(
138
- self,
139
- *,
140
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
141
- server_url: Optional[str] = None,
142
- timeout_ms: Optional[int] = None,
143
- http_headers: Optional[Mapping[str, str]] = None,
144
- ) -> Any:
145
- r"""Debug Openapi
146
-
147
- :param retries: Override the default retry configuration for this method
148
- :param server_url: Override the default server URL for this method
149
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
150
- :param http_headers: Additional headers to set or replace on requests.
151
- """
152
- base_url = None
153
- url_variables = None
154
- if timeout_ms is None:
155
- timeout_ms = self.sdk_configuration.timeout_ms
156
-
157
- if server_url is not None:
158
- base_url = server_url
159
- req = self._build_request(
160
- method="GET",
161
- path="/debug-openapi",
162
- base_url=base_url,
163
- url_variables=url_variables,
164
- request=None,
165
- request_body_required=False,
166
- request_has_path_params=False,
167
- request_has_query_params=False,
168
- user_agent_header="user-agent",
169
- accept_header_value="application/json",
170
- http_headers=http_headers,
171
- timeout_ms=timeout_ms,
172
- )
173
-
174
- if retries == UNSET:
175
- if self.sdk_configuration.retry_config is not UNSET:
176
- retries = self.sdk_configuration.retry_config
177
-
178
- retry_config = None
179
- if isinstance(retries, utils.RetryConfig):
180
- retry_config = (retries, ["429", "500", "502", "503", "504"])
181
-
182
- http_res = self.do_request(
183
- hook_ctx=HookContext(
184
- operation_id="debug_openapi_debug_openapi_get",
185
- oauth2_scopes=[],
186
- security_source=None,
187
- ),
188
- request=req,
189
- error_status_codes=["4XX", "5XX"],
190
- retry_config=retry_config,
191
- )
192
-
193
- if utils.match_response(http_res, "200", "application/json"):
194
- return utils.unmarshal_json(http_res.text, Any)
195
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
196
- http_res_text = utils.stream_to_text(http_res)
197
- raise models.APIError(
198
- "API error occurred", http_res.status_code, http_res_text, http_res
199
- )
200
-
201
- content_type = http_res.headers.get("Content-Type")
202
- http_res_text = utils.stream_to_text(http_res)
203
- raise models.APIError(
204
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
205
- http_res.status_code,
206
- http_res_text,
207
- http_res,
208
- )
209
-
210
- async def debug_openapi_debug_openapi_get_async(
211
- self,
212
- *,
213
- retries: OptionalNullable[utils.RetryConfig] = UNSET,
214
- server_url: Optional[str] = None,
215
- timeout_ms: Optional[int] = None,
216
- http_headers: Optional[Mapping[str, str]] = None,
217
- ) -> Any:
218
- r"""Debug Openapi
219
-
220
- :param retries: Override the default retry configuration for this method
221
- :param server_url: Override the default server URL for this method
222
- :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
223
- :param http_headers: Additional headers to set or replace on requests.
224
- """
225
- base_url = None
226
- url_variables = None
227
- if timeout_ms is None:
228
- timeout_ms = self.sdk_configuration.timeout_ms
229
-
230
- if server_url is not None:
231
- base_url = server_url
232
- req = self._build_request_async(
233
- method="GET",
234
- path="/debug-openapi",
235
- base_url=base_url,
236
- url_variables=url_variables,
237
- request=None,
238
- request_body_required=False,
239
- request_has_path_params=False,
240
- request_has_query_params=False,
241
- user_agent_header="user-agent",
242
- accept_header_value="application/json",
243
- http_headers=http_headers,
244
- timeout_ms=timeout_ms,
245
- )
246
-
247
- if retries == UNSET:
248
- if self.sdk_configuration.retry_config is not UNSET:
249
- retries = self.sdk_configuration.retry_config
250
-
251
- retry_config = None
252
- if isinstance(retries, utils.RetryConfig):
253
- retry_config = (retries, ["429", "500", "502", "503", "504"])
254
-
255
- http_res = await self.do_request_async(
256
- hook_ctx=HookContext(
257
- operation_id="debug_openapi_debug_openapi_get",
258
- oauth2_scopes=[],
259
- security_source=None,
260
- ),
261
- request=req,
262
- error_status_codes=["4XX", "5XX"],
263
- retry_config=retry_config,
264
- )
265
-
266
- if utils.match_response(http_res, "200", "application/json"):
267
- return utils.unmarshal_json(http_res.text, Any)
268
- if utils.match_response(http_res, ["4XX", "5XX"], "*"):
269
- http_res_text = await utils.stream_to_text_async(http_res)
270
- raise models.APIError(
271
- "API error occurred", http_res.status_code, http_res_text, http_res
272
- )
273
-
274
- content_type = http_res.headers.get("Content-Type")
275
- http_res_text = await utils.stream_to_text_async(http_res)
276
- raise models.APIError(
277
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
278
- http_res.status_code,
279
- http_res_text,
280
- http_res,
281
- )
@@ -4,9 +4,10 @@ from ._hooks import SDKHooks
4
4
  from .httpclient import AsyncHttpClient, HttpClient
5
5
  from .utils import Logger, RetryConfig, remove_suffix
6
6
  from dataclasses import dataclass
7
+ from mixpeek import models
7
8
  from mixpeek.types import OptionalNullable, UNSET
8
9
  from pydantic import Field
9
- from typing import Dict, Optional, Tuple
10
+ from typing import Callable, Dict, Optional, Tuple, Union
10
11
 
11
12
 
12
13
  SERVERS = [
@@ -20,13 +21,14 @@ class SDKConfiguration:
20
21
  client: HttpClient
21
22
  async_client: AsyncHttpClient
22
23
  debug_logger: Logger
24
+ security: Optional[Union[models.Security, Callable[[], models.Security]]] = None
23
25
  server_url: Optional[str] = ""
24
26
  server_idx: Optional[int] = 0
25
27
  language: str = "python"
26
28
  openapi_doc_version: str = "0.81"
27
- sdk_version: str = "0.13.2"
28
- gen_version: str = "2.483.6"
29
- user_agent: str = "speakeasy-sdk/python 0.13.2 2.483.6 0.81 mixpeek"
29
+ sdk_version: str = "0.14.0"
30
+ gen_version: str = "2.484.0"
31
+ user_agent: str = "speakeasy-sdk/python 0.14.0 2.484.0 0.81 mixpeek"
30
32
  retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
31
33
  timeout_ms: Optional[int] = None
32
34
 
@@ -4,6 +4,7 @@ from .basesdk import BaseSDK
4
4
  from mixpeek import models, utils
5
5
  from mixpeek._hooks import HookContext
6
6
  from mixpeek.types import OptionalNullable, UNSET
7
+ from mixpeek.utils import get_security_from_env
7
8
  from typing import Any, Mapping, Optional, Union
8
9
 
9
10
 
@@ -78,10 +79,11 @@ class SearchInteractions(BaseSDK):
78
79
  request=request,
79
80
  request_body_required=True,
80
81
  request_has_path_params=False,
81
- request_has_query_params=False,
82
+ request_has_query_params=True,
82
83
  user_agent_header="user-agent",
83
84
  accept_header_value="application/json",
84
85
  http_headers=http_headers,
86
+ security=self.sdk_configuration.security,
85
87
  get_serialized_body=lambda: utils.serialize_request_body(
86
88
  request.search_interaction,
87
89
  False,
@@ -104,7 +106,9 @@ class SearchInteractions(BaseSDK):
104
106
  hook_ctx=HookContext(
105
107
  operation_id="create_interaction_features_search_interactions_post",
106
108
  oauth2_scopes=[],
107
- security_source=None,
109
+ security_source=get_security_from_env(
110
+ self.sdk_configuration.security, models.Security
111
+ ),
108
112
  ),
109
113
  request=req,
110
114
  error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
@@ -207,10 +211,11 @@ class SearchInteractions(BaseSDK):
207
211
  request=request,
208
212
  request_body_required=True,
209
213
  request_has_path_params=False,
210
- request_has_query_params=False,
214
+ request_has_query_params=True,
211
215
  user_agent_header="user-agent",
212
216
  accept_header_value="application/json",
213
217
  http_headers=http_headers,
218
+ security=self.sdk_configuration.security,
214
219
  get_serialized_body=lambda: utils.serialize_request_body(
215
220
  request.search_interaction,
216
221
  False,
@@ -233,7 +238,9 @@ class SearchInteractions(BaseSDK):
233
238
  hook_ctx=HookContext(
234
239
  operation_id="create_interaction_features_search_interactions_post",
235
240
  oauth2_scopes=[],
236
- security_source=None,
241
+ security_source=get_security_from_env(
242
+ self.sdk_configuration.security, models.Security
243
+ ),
237
244
  ),
238
245
  request=req,
239
246
  error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
@@ -310,10 +317,11 @@ class SearchInteractions(BaseSDK):
310
317
  request=request,
311
318
  request_body_required=False,
312
319
  request_has_path_params=True,
313
- request_has_query_params=False,
320
+ request_has_query_params=True,
314
321
  user_agent_header="user-agent",
315
322
  accept_header_value="application/json",
316
323
  http_headers=http_headers,
324
+ security=self.sdk_configuration.security,
317
325
  timeout_ms=timeout_ms,
318
326
  )
319
327
 
@@ -329,7 +337,9 @@ class SearchInteractions(BaseSDK):
329
337
  hook_ctx=HookContext(
330
338
  operation_id="get_interaction_features_search_interactions__interaction_id__get",
331
339
  oauth2_scopes=[],
332
- security_source=None,
340
+ security_source=get_security_from_env(
341
+ self.sdk_configuration.security, models.Security
342
+ ),
333
343
  ),
334
344
  request=req,
335
345
  error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
@@ -406,10 +416,11 @@ class SearchInteractions(BaseSDK):
406
416
  request=request,
407
417
  request_body_required=False,
408
418
  request_has_path_params=True,
409
- request_has_query_params=False,
419
+ request_has_query_params=True,
410
420
  user_agent_header="user-agent",
411
421
  accept_header_value="application/json",
412
422
  http_headers=http_headers,
423
+ security=self.sdk_configuration.security,
413
424
  timeout_ms=timeout_ms,
414
425
  )
415
426
 
@@ -425,7 +436,9 @@ class SearchInteractions(BaseSDK):
425
436
  hook_ctx=HookContext(
426
437
  operation_id="get_interaction_features_search_interactions__interaction_id__get",
427
438
  oauth2_scopes=[],
428
- security_source=None,
439
+ security_source=get_security_from_env(
440
+ self.sdk_configuration.security, models.Security
441
+ ),
429
442
  ),
430
443
  request=req,
431
444
  error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
@@ -500,10 +513,11 @@ class SearchInteractions(BaseSDK):
500
513
  request=request,
501
514
  request_body_required=False,
502
515
  request_has_path_params=True,
503
- request_has_query_params=False,
516
+ request_has_query_params=True,
504
517
  user_agent_header="user-agent",
505
518
  accept_header_value="application/json",
506
519
  http_headers=http_headers,
520
+ security=self.sdk_configuration.security,
507
521
  timeout_ms=timeout_ms,
508
522
  )
509
523
 
@@ -519,7 +533,9 @@ class SearchInteractions(BaseSDK):
519
533
  hook_ctx=HookContext(
520
534
  operation_id="delete_interaction_features_search_interactions__interaction_id__delete",
521
535
  oauth2_scopes=[],
522
- security_source=None,
536
+ security_source=get_security_from_env(
537
+ self.sdk_configuration.security, models.Security
538
+ ),
523
539
  ),
524
540
  request=req,
525
541
  error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
@@ -594,10 +610,11 @@ class SearchInteractions(BaseSDK):
594
610
  request=request,
595
611
  request_body_required=False,
596
612
  request_has_path_params=True,
597
- request_has_query_params=False,
613
+ request_has_query_params=True,
598
614
  user_agent_header="user-agent",
599
615
  accept_header_value="application/json",
600
616
  http_headers=http_headers,
617
+ security=self.sdk_configuration.security,
601
618
  timeout_ms=timeout_ms,
602
619
  )
603
620
 
@@ -613,7 +630,9 @@ class SearchInteractions(BaseSDK):
613
630
  hook_ctx=HookContext(
614
631
  operation_id="delete_interaction_features_search_interactions__interaction_id__delete",
615
632
  oauth2_scopes=[],
616
- security_source=None,
633
+ security_source=get_security_from_env(
634
+ self.sdk_configuration.security, models.Security
635
+ ),
617
636
  ),
618
637
  request=req,
619
638
  error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
mixpeek/tasks.py CHANGED
@@ -4,6 +4,7 @@ from .basesdk import BaseSDK
4
4
  from mixpeek import models, utils
5
5
  from mixpeek._hooks import HookContext
6
6
  from mixpeek.types import OptionalNullable, UNSET
7
+ from mixpeek.utils import get_security_from_env
7
8
  from typing import Any, Mapping, Optional
8
9
 
9
10
 
@@ -48,10 +49,11 @@ class Tasks(BaseSDK):
48
49
  request=request,
49
50
  request_body_required=False,
50
51
  request_has_path_params=True,
51
- request_has_query_params=False,
52
+ request_has_query_params=True,
52
53
  user_agent_header="user-agent",
53
54
  accept_header_value="application/json",
54
55
  http_headers=http_headers,
56
+ security=self.sdk_configuration.security,
55
57
  timeout_ms=timeout_ms,
56
58
  )
57
59
 
@@ -67,7 +69,9 @@ class Tasks(BaseSDK):
67
69
  hook_ctx=HookContext(
68
70
  operation_id="kill_task_tasks__task_id__delete",
69
71
  oauth2_scopes=[],
70
- security_source=None,
72
+ security_source=get_security_from_env(
73
+ self.sdk_configuration.security, models.Security
74
+ ),
71
75
  ),
72
76
  request=req,
73
77
  error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
@@ -140,10 +144,11 @@ class Tasks(BaseSDK):
140
144
  request=request,
141
145
  request_body_required=False,
142
146
  request_has_path_params=True,
143
- request_has_query_params=False,
147
+ request_has_query_params=True,
144
148
  user_agent_header="user-agent",
145
149
  accept_header_value="application/json",
146
150
  http_headers=http_headers,
151
+ security=self.sdk_configuration.security,
147
152
  timeout_ms=timeout_ms,
148
153
  )
149
154
 
@@ -159,7 +164,9 @@ class Tasks(BaseSDK):
159
164
  hook_ctx=HookContext(
160
165
  operation_id="kill_task_tasks__task_id__delete",
161
166
  oauth2_scopes=[],
162
- security_source=None,
167
+ security_source=get_security_from_env(
168
+ self.sdk_configuration.security, models.Security
169
+ ),
163
170
  ),
164
171
  request=req,
165
172
  error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
@@ -237,10 +244,11 @@ class Tasks(BaseSDK):
237
244
  request=request,
238
245
  request_body_required=False,
239
246
  request_has_path_params=True,
240
- request_has_query_params=False,
247
+ request_has_query_params=True,
241
248
  user_agent_header="user-agent",
242
249
  accept_header_value="application/json",
243
250
  http_headers=http_headers,
251
+ security=self.sdk_configuration.security,
244
252
  timeout_ms=timeout_ms,
245
253
  )
246
254
 
@@ -256,7 +264,9 @@ class Tasks(BaseSDK):
256
264
  hook_ctx=HookContext(
257
265
  operation_id="get_task_tasks__task_id__get",
258
266
  oauth2_scopes=[],
259
- security_source=None,
267
+ security_source=get_security_from_env(
268
+ self.sdk_configuration.security, models.Security
269
+ ),
260
270
  ),
261
271
  request=req,
262
272
  error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
@@ -334,10 +344,11 @@ class Tasks(BaseSDK):
334
344
  request=request,
335
345
  request_body_required=False,
336
346
  request_has_path_params=True,
337
- request_has_query_params=False,
347
+ request_has_query_params=True,
338
348
  user_agent_header="user-agent",
339
349
  accept_header_value="application/json",
340
350
  http_headers=http_headers,
351
+ security=self.sdk_configuration.security,
341
352
  timeout_ms=timeout_ms,
342
353
  )
343
354
 
@@ -353,7 +364,9 @@ class Tasks(BaseSDK):
353
364
  hook_ctx=HookContext(
354
365
  operation_id="get_task_tasks__task_id__get",
355
366
  oauth2_scopes=[],
356
- security_source=None,
367
+ security_source=get_security_from_env(
368
+ self.sdk_configuration.security, models.Security
369
+ ),
357
370
  ),
358
371
  request=req,
359
372
  error_status_codes=["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
mixpeek/utils/__init__.py CHANGED
@@ -17,7 +17,8 @@ from .metadata import (
17
17
  from .queryparams import get_query_params
18
18
  from .retries import BackoffStrategy, Retries, retry, retry_async, RetryConfig
19
19
  from .requestbodies import serialize_request_body, SerializedRequestBody
20
- from .security import get_security
20
+ from .security import get_security, get_security_from_env
21
+
21
22
  from .serializers import (
22
23
  get_pydantic_model,
23
24
  marshal_json,
@@ -60,6 +61,7 @@ __all__ = [
60
61
  "get_query_params",
61
62
  "get_response_headers",
62
63
  "get_security",
64
+ "get_security_from_env",
63
65
  "HeaderMetadata",
64
66
  "Logger",
65
67
  "marshal_json",
mixpeek/utils/security.py CHANGED
@@ -1,10 +1,12 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  import base64
4
+
4
5
  from typing import (
5
6
  Any,
6
7
  Dict,
7
8
  List,
9
+ Optional,
8
10
  Tuple,
9
11
  )
10
12
  from pydantic import BaseModel
@@ -14,6 +16,7 @@ from .metadata import (
14
16
  SecurityMetadata,
15
17
  find_field_metadata,
16
18
  )
19
+ import os
17
20
 
18
21
 
19
22
  def get_security(security: Any) -> Tuple[Dict[str, str], Dict[str, List[str]]]:
@@ -52,6 +55,21 @@ def get_security(security: Any) -> Tuple[Dict[str, str], Dict[str, List[str]]]:
52
55
  return headers, query_params
53
56
 
54
57
 
58
+ def get_security_from_env(security: Any, security_class: Any) -> Optional[BaseModel]:
59
+ if security is not None:
60
+ return security
61
+
62
+ if not issubclass(security_class, BaseModel):
63
+ raise TypeError("security_class must be a pydantic model class")
64
+
65
+ security_dict: Any = {}
66
+
67
+ if os.getenv("MIXPEEK_BEARER_AUTH"):
68
+ security_dict["bearer_auth"] = os.getenv("MIXPEEK_BEARER_AUTH")
69
+
70
+ return security_class(**security_dict) if security_dict else None
71
+
72
+
55
73
  def _parse_security_option(
56
74
  headers: Dict[str, str], query_params: Dict[str, List[str]], option: Any
57
75
  ):