77
88__all__ = [
99 "AggregateFunction" ,
10- "Alert" ,
1110 "AlertChannel" ,
1211 "AlertDefinition" ,
12+ "AlertDefinitionChannel" ,
13+ "AlertDefinitionEntity" ,
14+ "AlertEntities" ,
15+ "AlertScope" ,
1316 "AlertType" ,
14- "Alerts" ,
1517 "MonitorDashboard" ,
1618 "MonitorMetricsDefinition" ,
1719 "MonitorService" ,
@@ -341,15 +343,15 @@ class RuleCriteria(JSONObject):
341343
342344
343345@dataclass
344- class Alert (JSONObject ):
346+ class AlertDefinitionChannel (JSONObject ):
345347 """
346- Represents an alert definition reference within an AlertChannel .
348+ Represents the notification channel set up for use with an alert .
347349
348350 Fields:
349- - id: int - Unique identifier of the alert definition .
350- - label: str - Human-readable name for the alert definition .
351- - type: str - Type of the alert (e.g., 'alerts-definitions') .
352- - url: str - API URL for the alert definition .
351+ - id: int - Unique identifier for this notification channel .
352+ - label: str - Human-readable name for the alert channel .
353+ - type: str - Type of notification used with the channel. For a user alert definition, only `email` is supported .
354+ - url: str - URL for the channel that ends in the channel's id .
353355 """
354356
355357 id : int = 0
@@ -358,18 +360,6 @@ class Alert(JSONObject):
358360 url : str = ""
359361
360362
361- @dataclass
362- class Alerts (JSONObject ):
363- """
364- Represents a collection of alert definitions within an AlertChannel.
365-
366- Fields:
367- - items: List[Alert] - List of alert definitions.
368- """
369-
370- items : List [Alert ] = field (default_factory = list )
371-
372-
373363class AlertType (StrEnum ):
374364 """
375365 Enumeration of alert origin types used by alert definitions.
@@ -387,6 +377,43 @@ class AlertType(StrEnum):
387377 user = "user"
388378
389379
380+ class AlertScope (StrEnum ):
381+ """
382+ Scope values supported for alert definitions.
383+ """
384+
385+ entity = "entity"
386+ region = "region"
387+ account = "account"
388+
389+
390+ @dataclass
391+ class AlertEntities (JSONObject ):
392+ """
393+ Represents entity metadata for an alert definition.
394+
395+ For entity scoped alerts, `entities` envelope contains the URL to list entities,
396+ a count, and a has_more_resources flag.
397+ For region/account scoped alerts, the `entities` are returned as an empty object.
398+ """
399+
400+ url : str = ""
401+ count : int = 0
402+ has_more_resources : bool = False
403+
404+
405+ @dataclass
406+ class AlertDefinitionEntity (JSONObject ):
407+ """
408+ Represents an entity associated with an alert definition.
409+ """
410+
411+ id : str = ""
412+ label : str = ""
413+ url : str = ""
414+ _type : str = field (default = "" , metadata = {"json_key" : "type" })
415+
416+
390417class AlertDefinition (DerivedBase ):
391418 """
392419 Represents an alert definition for a monitor service.
@@ -406,17 +433,26 @@ class AlertDefinition(DerivedBase):
406433 "severity" : Property (mutable = True ),
407434 "type" : Property (mutable = True ),
408435 "status" : Property (mutable = True ),
409- "has_more_resources" : Property (mutable = True ),
436+ "scope" : Property (AlertScope ),
437+ "regions" : Property (mutable = True ),
438+ "has_more_resources" : Property (
439+ mutable = True
440+ ), # Deprecated; use entities.has_more_resources
441+ "entities" : Property (json_object = AlertEntities ),
410442 "rule_criteria" : Property (mutable = True , json_object = RuleCriteria ),
411443 "trigger_conditions" : Property (
412444 mutable = True , json_object = TriggerConditions
413445 ),
414- "alert_channels" : Property (mutable = True , json_object = Alerts ),
446+ "alert_channels" : Property (
447+ mutable = True , json_object = AlertDefinitionChannel
448+ ),
415449 "created" : Property (is_datetime = True ),
416450 "updated" : Property (is_datetime = True ),
417451 "updated_by" : Property (),
418452 "created_by" : Property (),
419- "entity_ids" : Property (mutable = True ),
453+ "entity_ids" : Property (
454+ mutable = True
455+ ), # Deprecated; use entities.url to fetch associated entities
420456 "description" : Property (mutable = True ),
421457 "service_class" : Property (alias_of = "class" ),
422458 }
0 commit comments