1- from typing import Any , Optional
1+ from typing import Any , Optional , Union
22
33from linode_api4 import PaginatedList
44from linode_api4 .errors import UnexpectedResponseError
55from linode_api4 .groups import Group
66from linode_api4 .objects import (
77 AlertChannel ,
88 AlertDefinition ,
9+ AlertDefinitionEntity ,
10+ AlertScope ,
911 MonitorDashboard ,
1012 MonitorMetricsDefinition ,
1113 MonitorService ,
@@ -202,7 +204,7 @@ def alert_channels(self, *filters) -> PaginatedList:
202204
203205 .. note:: This endpoint is in beta and requires using the v4beta base URL.
204206
205- API Documentation: https://techdocs.akamai.com/linode-api/reference/get-alert -channels
207+ API Documentation: https://techdocs.akamai.com/linode-api/reference/get-notification -channels
206208
207209 :param filters: Optional filter expressions to apply to the collection.
208210 See :doc:`Filtering Collections</linode_api4/objects/filtering>` for details.
@@ -221,6 +223,8 @@ def create_alert_definition(
221223 trigger_conditions : dict ,
222224 entity_ids : Optional [list [str ]] = None ,
223225 description : Optional [str ] = None ,
226+ scope : Optional [Union [AlertScope , str ]] = None ,
227+ regions : Optional [list [str ]] = None ,
224228 ) -> AlertDefinition :
225229 """
226230 Create a new alert definition for a given service type.
@@ -252,6 +256,10 @@ def create_alert_definition(
252256 :type entity_ids: Optional[list[str]]
253257 :param description: (Optional) Longer description for the alert definition.
254258 :type description: Optional[str]
259+ :param scope: (Optional) Alert scope (for example: `account`, `entity`, or `region`). Defaults to `entity`.
260+ :type scope: Optional[Union[AlertScope, str]]
261+ :param regions: (Optional) Regions to monitor.
262+ :type regions: Optional[list[str]]
255263
256264 :returns: The newly created :class:`AlertDefinition`.
257265 :rtype: AlertDefinition
@@ -267,10 +275,15 @@ def create_alert_definition(
267275 "rule_criteria" : rule_criteria ,
268276 "trigger_conditions" : trigger_conditions ,
269277 }
270- if description is not None :
271- params ["description" ] = description
278+
272279 if entity_ids is not None :
273280 params ["entity_ids" ] = entity_ids
281+ if description is not None :
282+ params ["description" ] = description
283+ if scope is not None :
284+ params ["scope" ] = scope
285+ if regions is not None :
286+ params ["regions" ] = regions
274287
275288 # API will validate service_type and return an error if missing
276289 result = self .client .post (
@@ -284,3 +297,38 @@ def create_alert_definition(
284297 )
285298
286299 return AlertDefinition (self .client , result ["id" ], service_type , result )
300+
301+ def alert_definition_entities (
302+ self ,
303+ service_type : str ,
304+ id : int ,
305+ * filters ,
306+ ) -> PaginatedList :
307+ """
308+ List entities associated with a specific alert definition.
309+
310+ This endpoint supports pagination fields (`page`, `page_size`) in the API.
311+
312+ .. note:: This endpoint is in beta and requires using the v4beta base URL.
313+
314+ API Documentation: TODO
315+
316+ :param service_type: Service type for the alert definition (e.g. `dbaas`).
317+ :type service_type: str
318+ :param id: Alert definition identifier.
319+ :type id: int
320+ :param filters: Optional filter expressions to apply to the collection.
321+ See :doc:`Filtering Collections</linode_api4/objects/filtering>`.
322+
323+ :returns: A paginated list of entities associated with the alert definition.
324+ :rtype: PaginatedList[AlertDefinitionEntity]
325+ """
326+
327+ endpoint = (
328+ f"/monitor/services/{ service_type } /alert-definitions/{ id } /entities"
329+ )
330+ return self .client ._get_and_filter (
331+ AlertDefinitionEntity ,
332+ * filters ,
333+ endpoint = endpoint ,
334+ )
0 commit comments