mindvoice-sdk 0.1.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.
- mindvoice/__init__.py +7 -0
- mindvoice/_errors.py +49 -0
- mindvoice/_operations.py +1460 -0
- mindvoice/_transport.py +290 -0
- mindvoice/models.py +4386 -0
- mindvoice/py.typed +0 -0
- mindvoice_sdk-0.1.0.dist-info/METADATA +305 -0
- mindvoice_sdk-0.1.0.dist-info/RECORD +9 -0
- mindvoice_sdk-0.1.0.dist-info/WHEEL +4 -0
mindvoice/__init__.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""Клиент публичного API MindVoice с типизированными операциями Workspace."""
|
|
2
|
+
|
|
3
|
+
from . import models
|
|
4
|
+
from ._errors import HTTPError, ResponseError
|
|
5
|
+
from ._operations import AsyncClient, Client, TranscriptFormat
|
|
6
|
+
|
|
7
|
+
__all__ = ["AsyncClient", "Client", "HTTPError", "ResponseError", "TranscriptFormat", "models"]
|
mindvoice/_errors.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Ошибки HTTP и чтения ответа MindVoice."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
from pydantic import JsonValue, ValidationError
|
|
7
|
+
|
|
8
|
+
from .models import ErrorResponse, FieldViolation
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class HTTPError(Exception):
|
|
12
|
+
"""Ответ MindVoice с HTTP-статусом вне диапазона 2xx."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, response: httpx.Response, body: bytes) -> None:
|
|
15
|
+
"""Сохраняет статус, служебные заголовки и сведения из JSON-ошибки API."""
|
|
16
|
+
self.status_code = response.status_code
|
|
17
|
+
self.retry_after = response.headers.get("Retry-After")
|
|
18
|
+
self.content_range = response.headers.get("Content-Range")
|
|
19
|
+
self.request_id = response.headers.get("X-Request-ID")
|
|
20
|
+
self.code: str | None = None
|
|
21
|
+
self.message: str | None = None
|
|
22
|
+
self.violations: list[FieldViolation] = []
|
|
23
|
+
self.details: dict[str, JsonValue] | None = None
|
|
24
|
+
|
|
25
|
+
# Ответ прокси или ответ без тела сохраняет HTTP-статус и заголовки.
|
|
26
|
+
if body:
|
|
27
|
+
try:
|
|
28
|
+
error = ErrorResponse.model_validate_json(body, extra="ignore").error
|
|
29
|
+
except ValidationError:
|
|
30
|
+
pass
|
|
31
|
+
else:
|
|
32
|
+
self.code = error.code
|
|
33
|
+
self.message = error.message
|
|
34
|
+
self.violations = error.violations
|
|
35
|
+
self.details = error.details
|
|
36
|
+
self.request_id = error.request_id or self.request_id
|
|
37
|
+
|
|
38
|
+
suffix = f" ({self.code})" if self.code else ""
|
|
39
|
+
super().__init__(f"MindVoice: HTTP {self.status_code}{suffix}")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ResponseError(Exception):
|
|
43
|
+
"""Успешный HTTP-ответ с телом, которое не соответствует схеме операции."""
|
|
44
|
+
|
|
45
|
+
def __init__(self, response: httpx.Response) -> None:
|
|
46
|
+
"""Сохраняет статус и ID запроса без содержимого ответа."""
|
|
47
|
+
self.status_code = response.status_code
|
|
48
|
+
self.request_id = response.headers.get("X-Request-ID")
|
|
49
|
+
super().__init__(f"MindVoice: некорректный JSON-ответ (HTTP {self.status_code})")
|