@@ -155,39 +155,27 @@ def alert_definitions(
155155 service_type : Optional [str ] = None ,
156156 ) -> Union [PaginatedList , AlertDefinition ]:
157157 """
158- Retrieve one or more alert definitions.
158+ Retrieve alert definitions.
159159
160- If both `service_type` and `alert_id` are provided, a single
161- :class:`AlertDefinition` instance is returned. If only `service_type` is
162- provided (or neither), a paginated list of :class:`AlertDefinition`
163- objects is returned.
164-
165- Examples:
166- alert_definitions = client.monitor.get_alert_definitions()
167- alert_definition = client.load(AlertDefinition, alert_id,"dbaas")
168- alert_definitions_for_service = client.monitor.get_alert_definitions(service_type="dbaas")
160+ Returns a paginated collection of :class:`AlertDefinition` objects. If you
161+ need to obtain a single :class:`AlertDefinition`, use :meth:`LinodeClient.load`
162+ and supply the `service_type` as the parent identifier, for example:
169163
164+ alerts = client.monitor.alert_definitions()
165+ alerts_by_service = client.monitor.alert_definitions(service_type="dbaas")
170166 .. note:: This endpoint is in beta and requires using the v4beta base URL.
171167
172168 API Documentation:
173- https://techdocs.akamai.com/linode-api/reference/get-alert-definition
174169 https://techdocs.akamai.com/linode-api/reference/get-alert-definitions
175170 https://techdocs.akamai.com/linode-api/reference/get-alert-definitions-for-service-type
176171
177- :param service_type: If provided, limits the query to alert definitions for
178- the given service type (e.g. ``"dbaas"``).
172+ :param service_type: Optional service type to scope the query (e.g. ``"dbaas"``).
179173 :type service_type: Optional[str]
180- :param alert_id: If provided, the ID of the alert definition to fetch. When
181- specifying an ``alert_id``, ``service_type`` must also be
182- provided.
183- :type alert_id: Optional[int]
184174 :param filters: Optional filtering expressions to apply to the returned
185175 collection. See :doc:`Filtering Collections</linode_api4/objects/filtering>`.
186176
187- :returns: A single :class:`AlertDefinition` when ``alert_id`` is used, or
188- a :class:`PaginatedList` of :class:`AlertDefinition` objects
189- otherwise.
190- :rtype: Union[AlertDefinition, PaginatedList[AlertDefinition]]
177+ :returns: A paginated list of :class:`AlertDefinition` objects.
178+ :rtype: PaginatedList[AlertDefinition]
191179 """
192180
193181 endpoint = "/monitor/alert-definitions"
@@ -291,75 +279,4 @@ def create_alert_definition(
291279 json = result ,
292280 )
293281
294- return AlertDefinition (self .client , result ["id" ],service_type , result )
295-
296- def update_alert_definition (
297- self ,
298- service_type : str ,
299- alert_id : int ,
300- label : Optional [str ] = None ,
301- severity : Optional [str ] = None ,
302- description : Optional [str ] = None ,
303- rule_criteria : Optional [dict ] = None ,
304- trigger_conditions : Optional [dict ] = None ,
305- entity_ids : Optional [list [str ]] = None ,
306- channel_ids : Optional [list [int ]] = None ,
307- ) -> AlertDefinition :
308- """
309- Update an existing alert definition.
310-
311- Only the parameters provided will be updated; omitted parameters are left
312- unchanged.
313-
314- .. note:: This endpoint is in beta and requires using the v4beta base URL.
315-
316- API Documentation: https://techdocs.akamai.com/linode-api/reference/put-alert-definition
317-
318- :param service_type: Service type of the alert definition to update
319- (e.g. ``"dbaas"``).
320- :type service_type: str
321- :param alert_id: ID of the alert definition to update.
322- :type alert_id: int
323- :param label: (Optional) New label for the alert definition.
324- :type label: Optional[str]
325- :param severity: (Optional) New severity for the alert. The SDK accepts
326- this value as provided to the API (commonly an integer).
327- :type severity: Optional[str]
328- :param description: (Optional) New description for the alert definition.
329- :type description: Optional[str]
330- :param rule_criteria: (Optional) New rule criteria to replace the current
331- definition.
332- :type rule_criteria: Optional[RuleCriteria]
333- :param trigger_conditions: (Optional) New trigger conditions.
334- :type trigger_conditions: Optional[TriggerConditions]
335- :param entity_ids: (Optional) New list of entity IDs to scope the alert.
336- :type entity_ids: Optional[list[str]]
337- :param channel_ids: (Optional) New list of channel IDs to notify.
338- :type channel_ids: Optional[list[int]]
339-
340- :returns: The updated :class:`AlertDefinition` as returned by the API.
341- :rtype: AlertDefinition
342- """
343- params = {}
344- if label is not None :
345- params ["label" ] = label
346- if severity is not None :
347- params ["severity" ] = severity
348- if description is not None :
349- params ["description" ] = description
350- if rule_criteria is not None :
351- params ["rule_criteria" ] = rule_criteria
352- if trigger_conditions is not None :
353- params ["trigger_conditions" ] = trigger_conditions
354- if entity_ids is not None :
355- params ["entity_ids" ] = entity_ids
356- if channel_ids is not None :
357- params ["channel_ids" ] = channel_ids
358-
359- #API will handle check for service_type and alert_id and return correct error if missing
360- result = self .client .put (
361- f"/monitor/services/{ service_type } /alert-definitions/{ alert_id } " ,
362- data = params ,
363- )
364-
365- return AlertDefinition (self .client , result ["id" ], service_type , result )
282+ return AlertDefinition (self .client , result ["id" ],service_type , result )
0 commit comments