Skip to content

Commit 8961668

Browse files
committed
Incorporated copilot comments
1 parent 1bdde74 commit 8961668

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

linode_api4/objects/monitor.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"AlertChannel",
1818
"AlertDefinition",
1919
"AlertChannelEnvelope",
20+
"Alert",
2021
]
2122

2223

@@ -280,7 +281,7 @@ class RuleCriteria(JSONObject):
280281
"rule_criteria": { "rules": [ { ... }, ... ] }
281282
"""
282283

283-
rules: List[Rule] = None
284+
rules: Optional[List[Rule]] = None
284285

285286

286287
@dataclass
@@ -312,8 +313,8 @@ class AlertType(StrEnum):
312313
Enumeration of alert origin types used by alert definitions.
313314
314315
Values:
315-
- SYSTEM: Alerts that originate from the system (built-in or platform-managed).
316-
- USER: Alerts created and managed by users (custom alerts).
316+
- system: Alerts that originate from the system (built-in or platform-managed).
317+
- user: Alerts created and managed by users (custom alerts).
317318
318319
The API uses this value in the `type` field of alert-definition responses.
319320
This enum can be used to compare or validate the `type` value when
@@ -376,6 +377,23 @@ class ChannelContent(JSONObject):
376377
# Other channel types like 'webhook', 'slack' could be added here as Optional fields.
377378

378379

380+
@dataclass
381+
class Alert(JSONObject):
382+
"""
383+
Represents an alert definition reference within an AlertChannel.
384+
385+
Fields:
386+
- id: int - Unique identifier of the alert definition.
387+
- label: str - Human-readable name for the alert definition.
388+
- type: str - Type of the alert (e.g., 'alerts-definitions').
389+
- url: str - API URL for the alert definition.
390+
"""
391+
id: int = 0
392+
label: str = ""
393+
type: str = ""
394+
url: str = ""
395+
396+
379397
class AlertChannel(Base):
380398
"""
381399
Represents an alert channel used to deliver notifications when alerts
@@ -396,13 +414,12 @@ class AlertChannel(Base):
396414
properties = {
397415
"id": Property(identifier=True),
398416
"label": Property(),
399-
"type": Property("channel_type"),
417+
"type": Property(AlertType),
400418
"channel_type": Property(),
419+
"alerts": Property(List[Alert]),
401420
"content": Property(ChannelContent),
402421
"created": Property(is_datetime=True),
403422
"updated": Property(is_datetime=True),
404423
"created_by": Property(),
405424
"updated_by": Property(),
406-
"url": Property(),
407-
# Add other fields as needed
408425
}

0 commit comments

Comments
 (0)