devhelm 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.
- devhelm/__init__.py +123 -0
- devhelm/_errors.py +62 -0
- devhelm/_generated.py +6406 -0
- devhelm/_http.py +99 -0
- devhelm/_pagination.py +74 -0
- devhelm/client.py +83 -0
- devhelm/py.typed +0 -0
- devhelm/resources/__init__.py +0 -0
- devhelm/resources/alert_channels.py +56 -0
- devhelm/resources/api_keys.py +35 -0
- devhelm/resources/dependencies.py +39 -0
- devhelm/resources/deploy_lock.py +33 -0
- devhelm/resources/environments.py +50 -0
- devhelm/resources/incidents.py +44 -0
- devhelm/resources/monitors.py +91 -0
- devhelm/resources/notification_policies.py +60 -0
- devhelm/resources/resource_groups.py +67 -0
- devhelm/resources/secrets.py +37 -0
- devhelm/resources/status.py +18 -0
- devhelm/resources/tags.py +48 -0
- devhelm/resources/webhooks.py +56 -0
- devhelm/types.py +90 -0
- devhelm-0.1.0.dist-info/METADATA +171 -0
- devhelm-0.1.0.dist-info/RECORD +26 -0
- devhelm-0.1.0.dist-info/WHEEL +4 -0
- devhelm-0.1.0.dist-info/licenses/LICENSE +21 -0
devhelm/__init__.py
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""DevHelm SDK for Python — typed client for monitors, incidents, alerting, and more."""
|
|
2
|
+
|
|
3
|
+
from devhelm._errors import AuthError, DevhelmError
|
|
4
|
+
from devhelm._pagination import CursorPage, Page
|
|
5
|
+
from devhelm.client import Devhelm
|
|
6
|
+
from devhelm.resources.alert_channels import AlertChannels
|
|
7
|
+
from devhelm.resources.api_keys import ApiKeys
|
|
8
|
+
from devhelm.resources.dependencies import Dependencies
|
|
9
|
+
from devhelm.resources.deploy_lock import DeployLock
|
|
10
|
+
from devhelm.resources.environments import Environments
|
|
11
|
+
from devhelm.resources.incidents import Incidents
|
|
12
|
+
from devhelm.resources.monitors import Monitors
|
|
13
|
+
from devhelm.resources.notification_policies import NotificationPolicies
|
|
14
|
+
from devhelm.resources.resource_groups import ResourceGroups
|
|
15
|
+
from devhelm.resources.secrets import Secrets
|
|
16
|
+
from devhelm.resources.status import Status
|
|
17
|
+
from devhelm.resources.tags import Tags
|
|
18
|
+
from devhelm.resources.webhooks import Webhooks
|
|
19
|
+
from devhelm.types import (
|
|
20
|
+
AcquireDeployLockRequest,
|
|
21
|
+
AlertChannelDto,
|
|
22
|
+
ApiKeyCreateResponse,
|
|
23
|
+
ApiKeyDto,
|
|
24
|
+
AssertionTestResultDto,
|
|
25
|
+
CheckResultDto,
|
|
26
|
+
CreateAlertChannelRequest,
|
|
27
|
+
CreateApiKeyRequest,
|
|
28
|
+
CreateEnvironmentRequest,
|
|
29
|
+
CreateManualIncidentRequest,
|
|
30
|
+
CreateMonitorRequest,
|
|
31
|
+
CreateNotificationPolicyRequest,
|
|
32
|
+
CreateResourceGroupRequest,
|
|
33
|
+
CreateSecretRequest,
|
|
34
|
+
CreateTagRequest,
|
|
35
|
+
CreateWebhookEndpointRequest,
|
|
36
|
+
DashboardOverviewDto,
|
|
37
|
+
DeployLockDto,
|
|
38
|
+
EnvironmentDto,
|
|
39
|
+
IncidentDetailDto,
|
|
40
|
+
IncidentDto,
|
|
41
|
+
MonitorDto,
|
|
42
|
+
MonitorVersionDto,
|
|
43
|
+
NotificationPolicyDto,
|
|
44
|
+
ResourceGroupDto,
|
|
45
|
+
ResourceGroupMemberDto,
|
|
46
|
+
SecretDto,
|
|
47
|
+
ServiceSubscriptionDto,
|
|
48
|
+
TagDto,
|
|
49
|
+
UpdateAlertChannelRequest,
|
|
50
|
+
UpdateEnvironmentRequest,
|
|
51
|
+
UpdateMonitorRequest,
|
|
52
|
+
UpdateNotificationPolicyRequest,
|
|
53
|
+
UpdateResourceGroupRequest,
|
|
54
|
+
UpdateSecretRequest,
|
|
55
|
+
UpdateTagRequest,
|
|
56
|
+
UpdateWebhookEndpointRequest,
|
|
57
|
+
WebhookEndpointDto,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
__all__ = [
|
|
61
|
+
# Client
|
|
62
|
+
"Devhelm",
|
|
63
|
+
# Errors
|
|
64
|
+
"DevhelmError",
|
|
65
|
+
"AuthError",
|
|
66
|
+
# Pagination
|
|
67
|
+
"Page",
|
|
68
|
+
"CursorPage",
|
|
69
|
+
# Resource classes
|
|
70
|
+
"Monitors",
|
|
71
|
+
"Incidents",
|
|
72
|
+
"AlertChannels",
|
|
73
|
+
"NotificationPolicies",
|
|
74
|
+
"Environments",
|
|
75
|
+
"Secrets",
|
|
76
|
+
"Tags",
|
|
77
|
+
"ResourceGroups",
|
|
78
|
+
"Webhooks",
|
|
79
|
+
"ApiKeys",
|
|
80
|
+
"Dependencies",
|
|
81
|
+
"DeployLock",
|
|
82
|
+
"Status",
|
|
83
|
+
# Response DTOs
|
|
84
|
+
"MonitorDto",
|
|
85
|
+
"IncidentDto",
|
|
86
|
+
"IncidentDetailDto",
|
|
87
|
+
"AlertChannelDto",
|
|
88
|
+
"NotificationPolicyDto",
|
|
89
|
+
"EnvironmentDto",
|
|
90
|
+
"SecretDto",
|
|
91
|
+
"TagDto",
|
|
92
|
+
"ResourceGroupDto",
|
|
93
|
+
"ResourceGroupMemberDto",
|
|
94
|
+
"WebhookEndpointDto",
|
|
95
|
+
"ApiKeyDto",
|
|
96
|
+
"ApiKeyCreateResponse",
|
|
97
|
+
"ServiceSubscriptionDto",
|
|
98
|
+
"MonitorVersionDto",
|
|
99
|
+
"CheckResultDto",
|
|
100
|
+
"DashboardOverviewDto",
|
|
101
|
+
"DeployLockDto",
|
|
102
|
+
"AssertionTestResultDto",
|
|
103
|
+
# Request types
|
|
104
|
+
"CreateMonitorRequest",
|
|
105
|
+
"UpdateMonitorRequest",
|
|
106
|
+
"CreateManualIncidentRequest",
|
|
107
|
+
"CreateAlertChannelRequest",
|
|
108
|
+
"UpdateAlertChannelRequest",
|
|
109
|
+
"CreateNotificationPolicyRequest",
|
|
110
|
+
"UpdateNotificationPolicyRequest",
|
|
111
|
+
"CreateEnvironmentRequest",
|
|
112
|
+
"UpdateEnvironmentRequest",
|
|
113
|
+
"CreateSecretRequest",
|
|
114
|
+
"UpdateSecretRequest",
|
|
115
|
+
"CreateTagRequest",
|
|
116
|
+
"UpdateTagRequest",
|
|
117
|
+
"CreateResourceGroupRequest",
|
|
118
|
+
"UpdateResourceGroupRequest",
|
|
119
|
+
"CreateWebhookEndpointRequest",
|
|
120
|
+
"UpdateWebhookEndpointRequest",
|
|
121
|
+
"CreateApiKeyRequest",
|
|
122
|
+
"AcquireDeployLockRequest",
|
|
123
|
+
]
|
devhelm/_errors.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import Literal
|
|
5
|
+
|
|
6
|
+
DevhelmErrorCode = Literal["AUTH", "NOT_FOUND", "CONFLICT", "VALIDATION", "API"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DevhelmError(Exception):
|
|
10
|
+
"""Base error for all DevHelm API errors."""
|
|
11
|
+
|
|
12
|
+
code: DevhelmErrorCode
|
|
13
|
+
status: int
|
|
14
|
+
message: str
|
|
15
|
+
detail: str | None
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
code: DevhelmErrorCode,
|
|
20
|
+
message: str,
|
|
21
|
+
status: int,
|
|
22
|
+
detail: str | None = None,
|
|
23
|
+
) -> None:
|
|
24
|
+
super().__init__(message)
|
|
25
|
+
self.code = code
|
|
26
|
+
self.status = status
|
|
27
|
+
self.message = message
|
|
28
|
+
self.detail = detail
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AuthError(DevhelmError):
|
|
32
|
+
"""Raised on 401/403 authentication or authorization failures."""
|
|
33
|
+
|
|
34
|
+
def __init__(self, message: str, status: int) -> None:
|
|
35
|
+
super().__init__("AUTH", message, status)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def error_from_response(status: int, body: str) -> DevhelmError:
|
|
39
|
+
"""Map an HTTP error response to a typed DevhelmError."""
|
|
40
|
+
message = f"HTTP {status}"
|
|
41
|
+
detail: str | None = None
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
parsed = json.loads(body)
|
|
45
|
+
if isinstance(parsed, dict):
|
|
46
|
+
message = str(parsed.get("message") or parsed.get("error") or message)
|
|
47
|
+
raw_detail = parsed.get("detail")
|
|
48
|
+
if raw_detail is not None:
|
|
49
|
+
detail = str(raw_detail)
|
|
50
|
+
except (json.JSONDecodeError, ValueError):
|
|
51
|
+
if body:
|
|
52
|
+
message = body
|
|
53
|
+
|
|
54
|
+
if status in (401, 403):
|
|
55
|
+
return AuthError(message, status)
|
|
56
|
+
if status == 404:
|
|
57
|
+
return DevhelmError("NOT_FOUND", message, status, detail)
|
|
58
|
+
if status == 409:
|
|
59
|
+
return DevhelmError("CONFLICT", message, status, detail)
|
|
60
|
+
if status in (400, 422):
|
|
61
|
+
return DevhelmError("VALIDATION", message, status, detail)
|
|
62
|
+
return DevhelmError("API", message, status, detail)
|