Skip to content

Commit 065bb01

Browse files
committed
fix:PRComments
1 parent 9f66e8e commit 065bb01

File tree

12 files changed

+110
-151
lines changed

12 files changed

+110
-151
lines changed

docs/api_reference/alarm.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ nisystemlink.clients.alarm
1010
.. automethod:: create_or_update_alarm
1111
.. automethod:: get_alarm
1212
.. automethod:: delete_alarm
13-
.. automethod:: delete_instances_by_instance_id
13+
.. automethod:: delete_alarms
1414
.. automethod:: acknowledge_alarm
1515
.. automethod:: query_alarms
1616

docs/getting_started.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ With an :class:`.AlarmClient` object, you can:
3535

3636
* Get a specific alarm by its instance_id using :meth:`~.AlarmClient.get_alarm`
3737

38-
* Acknowledge alarms with :meth:`~.AlarmClient.acknowledge_alarm`
38+
* Acknowledge alarms by its instance_id using :meth:`~.AlarmClient.acknowledge_alarm`
3939

4040
* Optionally force-clear alarms when acknowledging
4141

4242
* Delete alarms using :meth:`~.AlarmClient.delete_alarm` or
43-
:meth:`~.AlarmClient.delete_instances_by_instance_id`
43+
:meth:`~.AlarmClient.delete_alarms`
4444

4545
Examples
4646
~~~~~~~~

examples/alarm/alarm.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import uuid
2-
from datetime import datetime, timezone
2+
from datetime import datetime
33

44
from nisystemlink.clients.alarm import AlarmClient
55
from nisystemlink.clients.alarm.models import (
6-
CreateOrUpdateAlarmRequest,
7-
QueryWithFilterRequest,
8-
)
9-
from nisystemlink.clients.alarm.models._alarm import AlarmTransitionType
10-
from nisystemlink.clients.alarm.models._create_or_update_alarm_request import (
11-
CreateAlarmTransition,
12-
)
13-
from nisystemlink.clients.alarm.models._query_alarms_request import (
146
AlarmOrderBy,
7+
AlarmTransitionType,
8+
CreateAlarmTransition,
9+
CreateOrUpdateAlarmRequest,
10+
QueryAlarmsWithFilterRequest,
1511
TransitionInclusionOption,
1612
)
1713
from nisystemlink.clients.core import HttpConfiguration
@@ -32,7 +28,7 @@
3228
alarm_id=alarm_id,
3329
transition=CreateAlarmTransition(
3430
transition_type=AlarmTransitionType.SET,
35-
occurred_at=datetime.now(timezone.utc),
31+
occurred_at=datetime.now(),
3632
severity_level=3,
3733
condition="Temperature exceeded threshold",
3834
message="Temperature sensor reading: 85°C",
@@ -49,7 +45,7 @@
4945
alarm_id=alarm_id,
5046
transition=CreateAlarmTransition(
5147
transition_type=AlarmTransitionType.SET,
52-
occurred_at=datetime.now(timezone.utc),
48+
occurred_at=datetime.now(),
5349
severity_level=5,
5450
condition="Temperature critically high",
5551
message="Temperature sensor reading: 95°C",
@@ -58,7 +54,7 @@
5854
client.create_or_update_alarm(update_request)
5955

6056
# Query alarms with a filter (can filter by alarm_id to find all instances)
61-
query_request = QueryWithFilterRequest(
57+
query_request = QueryAlarmsWithFilterRequest(
6258
filter=f'alarmId="{alarm_id}"',
6359
transition_inclusion_option=TransitionInclusionOption.ALL,
6460
order_by=AlarmOrderBy.UPDATED_AT,
@@ -68,14 +64,14 @@
6864
query_response = client.query_alarms(query_request)
6965

7066
# Acknowledge the alarm using its instance ID
71-
ack_response = client.acknowledge_alarm([id])
67+
ack_response = client.acknowledge_alarms(ids=[id])
7268

7369
# Clear the alarm
7470
clear_request = CreateOrUpdateAlarmRequest(
7571
alarm_id=alarm_id,
7672
transition=CreateAlarmTransition(
7773
transition_type=AlarmTransitionType.CLEAR,
78-
occurred_at=datetime.now(timezone.utc),
74+
occurred_at=datetime.now(),
7975
severity_level=0,
8076
condition="Temperature returned to normal",
8177
),

nisystemlink/clients/alarm/_alarm_client.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Implementation of Alarm Client"""
22

3-
from typing import Optional
3+
from typing import List, Optional
44

55
from nisystemlink.clients import core
66
from nisystemlink.clients.core._uplink._base_client import BaseClient
77
from nisystemlink.clients.core._uplink._methods import delete, get, post
8-
from uplink import Field, retry
8+
from uplink import Field, Path, retry
99

1010
from . import models
1111

@@ -38,15 +38,15 @@ def __init__(self, configuration: Optional[core.HttpConfiguration] = None):
3838
"acknowledge-instances-by-instance-id",
3939
args=[Field("instanceIds"), Field("forceClear")],
4040
)
41-
def acknowledge_alarm(
42-
self, instance_ids: list[str], force_clear: bool = False
43-
) -> models.AcknowledgeByInstanceIdResponse:
41+
def acknowledge_alarms(
42+
self, ids: List[str], force_clear: bool = False
43+
) -> models.AcknowledgeAlarmsResponse:
4444
"""Acknowledges one or more alarm instances by their instance IDs.
4545
4646
Args:
47-
instance_ids: List of instance IDs (unique occurrence identifiers) of the alarms to acknowledge.
48-
These are the server-generated IDs returned when creating/updating alarms,
49-
not the user-defined alarm_id.
47+
ids: List of instance IDs (unique occurrence identifiers) of the alarms to acknowledge.
48+
These are the server-generated IDs returned when creating/updating alarms,
49+
not the user-defined alarm_id.
5050
force_clear: Whether or not the affected alarms should have their clear field set to true.
5151
Defaults to False.
5252
@@ -80,14 +80,14 @@ def create_or_update_alarm(self, request: models.CreateOrUpdateAlarmRequest) ->
8080
"""
8181
...
8282

83-
@get("instances/{instance_id}")
84-
def get_alarm(self, instance_id: str) -> models.Alarm:
83+
@get("instances/{instance_id}", args=[Path("instance_id")])
84+
def get_alarm(self, id: str) -> models.Alarm:
8585
"""Gets an alarm by its instance_id.
8686
8787
Args:
88-
instance_id: The unique instance ID (occurrence identifier) of the alarm to retrieve.
89-
This is the server-generated ID returned from create_or_update_alarm(),
90-
not the user-defined alarm_id.
88+
id: The unique instance ID (occurrence identifier) of the alarm to retrieve.
89+
This is the server-generated ID returned from create_or_update_alarm(),
90+
not the user-defined alarm_id.
9191
9292
Returns:
9393
The alarm with the specified instance_id.
@@ -97,30 +97,30 @@ def get_alarm(self, instance_id: str) -> models.Alarm:
9797
"""
9898
...
9999

100-
@delete("instances/{instance_id}")
101-
def delete_alarm(self, instance_id: str) -> None:
100+
@delete("instances/{instance_id}", args=[Path("instance_id")])
101+
def delete_alarm(self, id: str) -> None:
102102
"""Deletes an alarm by its instance_id.
103103
104104
Args:
105-
instance_id: The unique instance ID (occurrence identifier) of the alarm to delete.
106-
This is the server-generated ID returned from create_or_update_alarm(),
107-
not the user-defined alarm_id.
105+
id: The unique instance ID (occurrence identifier) of the alarm to delete.
106+
This is the server-generated ID returned from create_or_update_alarm(),
107+
not the user-defined alarm_id.
108108
109109
Raises:
110110
ApiException: if unable to communicate with the `/nialarm` Service or provided invalid arguments.
111111
"""
112112
...
113113

114114
@post("delete-instances-by-instance-id", args=[Field("instanceIds")])
115-
def delete_instances_by_instance_id(
116-
self, instance_ids: list[str]
115+
def delete_alarms(
116+
self, ids: List[str]
117117
) -> models.DeleteByInstanceIdResponse:
118118
"""Deletes multiple alarm instances by their instance IDs.
119119
120120
Args:
121-
instance_ids: List of instance IDs (unique occurrence identifiers) of the alarms to delete.
122-
These are the server-generated IDs returned when creating/updating alarms,
123-
not the user-defined alarm_id.
121+
ids: List of instance IDs (unique occurrence identifiers) of the alarms to delete.
122+
These are the server-generated IDs returned when creating/updating alarms,
123+
not the user-defined alarm_id.
124124
125125
Returns:
126126
A response containing lists of successfully deleted and failed instance IDs,
@@ -133,8 +133,8 @@ def delete_instances_by_instance_id(
133133

134134
@post("query-instances-with-filter")
135135
def query_alarms(
136-
self, request: models.QueryWithFilterRequest
137-
) -> models.QueryWithFilterResponse:
136+
self, request: models.QueryAlarmsWithFilterRequest
137+
) -> models.QueryAlarmsWithFilterResponse:
138138
"""Queries for instances, or occurrences, of alarms using Dynamic LINQ.
139139
140140
Specifying an empty JSON object in the request body will result in all alarms being returned.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ._acknowledge_by_instance_id_response import AcknowledgeByInstanceIdResponse
1+
from ._acknowledge_alarms_response import AcknowledgeAlarmsResponse
22
from ._alarm import Alarm, AlarmNote, AlarmTransition, AlarmTransitionType
33
from ._create_or_update_alarm_request import (
44
CreateAlarmTransition,
@@ -7,9 +7,9 @@
77
from ._delete_by_instance_id_response import DeleteByInstanceIdResponse
88
from ._query_alarms_request import (
99
AlarmOrderBy,
10-
QueryWithFilterRequest,
10+
QueryAlarmsWithFilterRequest,
1111
TransitionInclusionOption,
1212
)
13-
from ._query_alarms_response import QueryWithFilterResponse
13+
from ._query_alarms_response import QueryAlarmsWithFilterResponse
1414

1515
# flake8: noqa

nisystemlink/clients/alarm/models/_acknowledge_by_instance_id_response.py renamed to nisystemlink/clients/alarm/models/_acknowledge_alarms_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from typing import List
22

3-
from nisystemlink.clients.alarm.models._partial_success_response_base import (
3+
from nisystemlink.clients.alarm.models._alarm_instances_partial_success import (
44
AlarmInstancesPartialSuccess,
55
)
66

77

8-
class AcknowledgeByInstanceIdResponse(AlarmInstancesPartialSuccess):
8+
class AcknowledgeAlarmsResponse(AlarmInstancesPartialSuccess):
99
"""Contains information about which alarms were acknowledged."""
1010

1111
acknowledged: List[str]

nisystemlink/clients/alarm/models/_partial_success_response_base.py renamed to nisystemlink/clients/alarm/models/_alarm_instances_partial_success.py

File renamed without changes.

nisystemlink/clients/alarm/models/_delete_by_instance_id_request.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

nisystemlink/clients/alarm/models/_delete_by_instance_id_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import List
22

3-
from nisystemlink.clients.alarm.models._partial_success_response_base import (
3+
from nisystemlink.clients.alarm.models._alarm_instances_partial_success import (
44
AlarmInstancesPartialSuccess,
55
)
66

nisystemlink/clients/alarm/models/_query_alarms_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AlarmOrderBy(str, Enum):
2525
"""The date and time the alarm was last updated."""
2626

2727

28-
class QueryWithFilterRequest(JsonModel):
28+
class QueryAlarmsWithFilterRequest(JsonModel):
2929
"""Contains filter information for querying alarms."""
3030

3131
filter: Optional[str] = None

0 commit comments

Comments
 (0)