qdash-client 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.
@@ -0,0 +1,46 @@
1
+ """QDash exporter client package."""
2
+
3
+ from qdash.client.services.client import QDashClient
4
+ from qdash.client.services.config import (
5
+ QDashConfig,
6
+ QDashRetryConfig,
7
+ )
8
+ from qdash.client.services.errors import (
9
+ QDashApiError,
10
+ QDashAuthError,
11
+ QDashClientError,
12
+ QDashConfigError,
13
+ QDashNotFoundError,
14
+ QDashTransportError,
15
+ QDashValidationError,
16
+ )
17
+ from qdash.client.services.exporter_models import NormalizedMetricRecord
18
+ from qdash.client.services.models import (
19
+ ChipMetricsResponse,
20
+ ChipResponse,
21
+ ListChipsResponse,
22
+ ParameterModel,
23
+ TimeSeriesData,
24
+ )
25
+
26
+ from . import rest
27
+
28
+ __all__ = [
29
+ "ChipMetricsResponse",
30
+ "ChipResponse",
31
+ "ListChipsResponse",
32
+ "NormalizedMetricRecord",
33
+ "ParameterModel",
34
+ "QDashApiError",
35
+ "QDashAuthError",
36
+ "QDashClient",
37
+ "QDashClientError",
38
+ "QDashConfig",
39
+ "QDashConfigError",
40
+ "QDashNotFoundError",
41
+ "QDashRetryConfig",
42
+ "QDashTransportError",
43
+ "QDashValidationError",
44
+ "TimeSeriesData",
45
+ "rest",
46
+ ]
qdash/client/py.typed ADDED
File without changes
@@ -0,0 +1,8 @@
1
+ """Low-level REST transport layer for qdash client."""
2
+
3
+ from qdash.client.rest.api_client import ApiClient
4
+ from qdash.client.rest.api_response import ApiResponse
5
+ from qdash.client.rest.configuration import Configuration
6
+ from qdash.client.rest.exceptions import ApiException
7
+
8
+ __all__ = ["ApiClient", "ApiException", "ApiResponse", "Configuration"]
@@ -0,0 +1,66 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any
4
+
5
+ import httpx
6
+
7
+ from qdash.client.rest.api_response import ApiResponse
8
+ from qdash.client.rest.exceptions import ApiException
9
+
10
+ if TYPE_CHECKING:
11
+ from qdash.client.rest.configuration import Configuration
12
+
13
+
14
+ class ApiClient:
15
+ """Small synchronous REST client used by service layer."""
16
+
17
+ def __init__(
18
+ self,
19
+ configuration: Configuration,
20
+ http_client: httpx.Client | None = None,
21
+ ) -> None:
22
+ self.configuration = configuration
23
+ self._client = http_client or httpx.Client(
24
+ base_url=configuration.host,
25
+ timeout=configuration.timeout,
26
+ verify=configuration.verify_tls,
27
+ proxy=configuration.proxy,
28
+ )
29
+
30
+ def request(
31
+ self,
32
+ method: str,
33
+ path: str,
34
+ *,
35
+ headers: dict[str, str] | None = None,
36
+ params: dict[str, Any] | None = None,
37
+ json: dict[str, Any] | None = None,
38
+ raise_on_status: bool = False,
39
+ ) -> ApiResponse[Any]:
40
+ try:
41
+ response = self._client.request(
42
+ method,
43
+ path,
44
+ headers=headers,
45
+ params=params,
46
+ json=json,
47
+ )
48
+ except httpx.HTTPError as exc:
49
+ raise ApiException(None, str(exc)) from exc
50
+
51
+ try:
52
+ payload = response.json()
53
+ except Exception:
54
+ payload = response.text
55
+
56
+ if raise_on_status and response.status_code >= 400:
57
+ raise ApiException(response.status_code, response.reason_phrase, payload)
58
+
59
+ return ApiResponse(
60
+ status_code=response.status_code,
61
+ data=payload,
62
+ headers=dict(response.headers),
63
+ )
64
+
65
+ def close(self) -> None:
66
+ self._client.close()
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Generic, TypeVar
5
+
6
+ _T = TypeVar("_T")
7
+
8
+
9
+ @dataclass(slots=True)
10
+ class ApiResponse(Generic[_T]):
11
+ """Typed REST response container."""
12
+
13
+ status_code: int
14
+ data: _T
15
+ headers: dict[str, str]
@@ -0,0 +1,13 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+
5
+
6
+ @dataclass(slots=True)
7
+ class Configuration:
8
+ """Basic REST client configuration."""
9
+
10
+ host: str
11
+ timeout: float = 30.0
12
+ verify_tls: bool = True
13
+ proxy: str | None = None
@@ -0,0 +1,11 @@
1
+ from __future__ import annotations
2
+
3
+
4
+ class ApiException(Exception):
5
+ """Exception raised by low-level REST transport."""
6
+
7
+ def __init__(self, status: int | None, reason: str, body: object | None = None) -> None:
8
+ self.status = status
9
+ self.reason = reason
10
+ self.body = body
11
+ super().__init__(f"HTTP {status}: {reason}" if status is not None else reason)
@@ -0,0 +1,43 @@
1
+ """Service layer for qdash client package."""
2
+
3
+ from qdash.client.services.client import QDashClient
4
+ from qdash.client.services.config import (
5
+ QDashConfig,
6
+ QDashRetryConfig,
7
+ )
8
+ from qdash.client.services.errors import (
9
+ QDashApiError,
10
+ QDashAuthError,
11
+ QDashClientError,
12
+ QDashConfigError,
13
+ QDashNotFoundError,
14
+ QDashTransportError,
15
+ QDashValidationError,
16
+ )
17
+ from qdash.client.services.exporter_models import NormalizedMetricRecord
18
+ from qdash.client.services.models import (
19
+ ChipMetricsResponse,
20
+ ChipResponse,
21
+ ListChipsResponse,
22
+ ParameterModel,
23
+ TimeSeriesData,
24
+ )
25
+
26
+ __all__ = [
27
+ "ChipMetricsResponse",
28
+ "ChipResponse",
29
+ "ListChipsResponse",
30
+ "NormalizedMetricRecord",
31
+ "ParameterModel",
32
+ "QDashApiError",
33
+ "QDashAuthError",
34
+ "QDashClient",
35
+ "QDashClientError",
36
+ "QDashConfig",
37
+ "QDashConfigError",
38
+ "QDashNotFoundError",
39
+ "QDashRetryConfig",
40
+ "QDashTransportError",
41
+ "QDashValidationError",
42
+ "TimeSeriesData",
43
+ ]