11"""Implementation of Alarm Client"""
22
3- from typing import List
3+ from typing import List , Literal , overload
44
55from nisystemlink .clients import core
66from nisystemlink .clients .core ._uplink ._base_client import BaseClient
@@ -39,12 +39,12 @@ def __init__(self, configuration: core.HttpConfiguration | None = None):
3939 args = [Field ("instanceIds" ), Field ("forceClear" )],
4040 )
4141 def acknowledge_alarms (
42- self , ids : List [str ], * , force_clear : bool = False
42+ self , instance_ids : List [str ], * , force_clear : bool = False
4343 ) -> models .AcknowledgeAlarmsResponse :
4444 """Acknowledges one or more alarm instances by their instance IDs.
4545
4646 Args:
47- ids : List of instance IDs (unique occurrence identifiers) of the alarms to acknowledge.
47+ instance_ids : List of instance IDs (unique occurrence identifiers) of the alarms to acknowledge.
4848 These are the server-generated IDs returned when creating/updating alarms,
4949 not the user-defined alarm_id.
5050 force_clear: Whether or not the affected alarms should have their clear field set to true.
@@ -59,6 +59,22 @@ def acknowledge_alarms(
5959 """
6060 ...
6161
62+ @overload
63+ def create_or_update_alarm ( # noqa: E704
64+ self ,
65+ request : models .CreateOrUpdateAlarmRequest ,
66+ * ,
67+ ignore_conflict : Literal [False ] = False ,
68+ ) -> str : ...
69+
70+ @overload
71+ def create_or_update_alarm ( # noqa: E704
72+ self ,
73+ request : models .CreateOrUpdateAlarmRequest ,
74+ * ,
75+ ignore_conflict : Literal [True ],
76+ ) -> str | None : ...
77+
6278 def create_or_update_alarm (
6379 self ,
6480 request : models .CreateOrUpdateAlarmRequest ,
@@ -91,15 +107,12 @@ def create_or_update_alarm(
91107 or attempting to set an alarm which is already set at the given severity level.
92108 This error can be suppressed by setting ignore_conflict=True.
93109 """
94- if ignore_conflict :
95- try :
96- return self ._create_or_update_alarm (request )
97- except core .ApiException as e :
98- if e .http_status_code == 409 :
99- return None
100- raise
101- else :
110+ try :
102111 return self ._create_or_update_alarm (request )
112+ except core .ApiException as e :
113+ if ignore_conflict and e .http_status_code == 409 :
114+ return None
115+ raise
103116
104117 @post ("instances" , return_key = "instanceId" )
105118 def _create_or_update_alarm (
@@ -109,11 +122,11 @@ def _create_or_update_alarm(
109122 ...
110123
111124 @get ("instances/{instance_id}" , args = [Path ("instance_id" )])
112- def get_alarm (self , id : str ) -> models .Alarm :
125+ def get_alarm (self , instance_id : str ) -> models .Alarm :
113126 """Gets an alarm by its instance_id.
114127
115128 Args:
116- id : The unique instance ID (occurrence identifier) of the alarm to retrieve.
129+ instance_id : The unique instance ID (occurrence identifier) of the alarm to retrieve.
117130 This is the server-generated ID returned from create_or_update_alarm(),
118131 not the user-defined alarm_id.
119132
@@ -126,11 +139,11 @@ def get_alarm(self, id: str) -> models.Alarm:
126139 ...
127140
128141 @delete ("instances/{instance_id}" , args = [Path ("instance_id" )])
129- def delete_alarm (self , id : str ) -> None :
142+ def delete_alarm (self , instance_id : str ) -> None :
130143 """Deletes an alarm by its instance_id.
131144
132145 Args:
133- id : The unique instance ID (occurrence identifier) of the alarm to delete.
146+ instance_id : The unique instance ID (occurrence identifier) of the alarm to delete.
134147 This is the server-generated ID returned from create_or_update_alarm(),
135148 not the user-defined alarm_id.
136149
@@ -140,11 +153,11 @@ def delete_alarm(self, id: str) -> None:
140153 ...
141154
142155 @post ("delete-instances-by-instance-id" , args = [Field ("instanceIds" )])
143- def delete_alarms (self , ids : List [str ]) -> models .DeleteAlarmsResponse :
156+ def delete_alarms (self , instance_ids : List [str ]) -> models .DeleteAlarmsResponse :
144157 """Deletes multiple alarm instances by their instance IDs.
145158
146159 Args:
147- ids : List of instance IDs (unique occurrence identifiers) of the alarms to delete.
160+ instance_ids : List of instance IDs (unique occurrence identifiers) of the alarms to delete.
148161 These are the server-generated IDs returned when creating/updating alarms,
149162 not the user-defined alarm_id.
150163
0 commit comments