|
| 1 | +from datetime import datetime |
| 2 | +from enum import Enum |
| 3 | +from typing import Dict, List, Optional |
| 4 | + |
| 5 | +from nisystemlink.clients.core._uplink._json_model import JsonModel |
| 6 | + |
| 7 | + |
| 8 | +class AlarmTransitionType(str, Enum): |
| 9 | + """Specifies a type of alarm transition.""" |
| 10 | + |
| 11 | + CLEAR = "CLEAR" |
| 12 | + """The transition corresponds to the clearing of the condition tracked by the alarm.""" |
| 13 | + |
| 14 | + SET = "SET" |
| 15 | + """The transition corresponds to the condition tracked by the alarm entering into the triggered state.""" |
| 16 | + |
| 17 | + |
| 18 | +class AlarmTransition(JsonModel): |
| 19 | + """A transition within an instance, or occurrence, of an alarm. |
| 20 | + |
| 21 | + Alarm transitions record changes to an alarm's clear field as well as an alarm |
| 22 | + increasing or decreasing in severity. |
| 23 | + """ |
| 24 | + |
| 25 | + transition_type: AlarmTransitionType |
| 26 | + """Specifies a type of alarm transition: CLEAR or SET.""" |
| 27 | + |
| 28 | + occurred_at: datetime |
| 29 | + """The date and time when the transition occurred.""" |
| 30 | + |
| 31 | + severity_level: int |
| 32 | + """The severity of the transition. |
| 33 | + |
| 34 | + Valid values for CLEAR transitions are [-1, -1]. |
| 35 | + Valid values for SET transitions are [1, infinity]. |
| 36 | + Note that the SystemLink Alarm UI only has display strings for SET severities in the range [1, 4]. |
| 37 | + """ |
| 38 | + |
| 39 | + value: str |
| 40 | + """The value that caused the alarm to transition.""" |
| 41 | + |
| 42 | + condition: str |
| 43 | + """A description of the condition associated with the transition.""" |
| 44 | + |
| 45 | + short_text: str |
| 46 | + """A short description of the condition.""" |
| 47 | + |
| 48 | + detail_text: str |
| 49 | + """A detailed description of the condition.""" |
| 50 | + |
| 51 | + keywords: List[str] |
| 52 | + """Words or phrases associated with a transition. |
| 53 | + |
| 54 | + Useful for attaching metadata to a transition which could aid in an investigation |
| 55 | + into an alarm's root cause in the future. |
| 56 | + """ |
| 57 | + |
| 58 | + properties: Dict[str, str] |
| 59 | + """Key-value pair metadata associated with a transition. |
| 60 | + |
| 61 | + Useful for attaching additional metadata to a transition which could aid in an investigation |
| 62 | + into an alarm's root cause in the future. Property keys must be between 1 and 255 characters. |
| 63 | + """ |
| 64 | + |
| 65 | + |
| 66 | +class AlarmNote(JsonModel): |
| 67 | + """Information about a particular alarm instance. |
| 68 | + |
| 69 | + Such as a description of the root cause of the alarm. |
| 70 | + """ |
| 71 | + |
| 72 | + note: str |
| 73 | + """Information about a particular alarm instance, such as a description of the root cause of the alarm.""" |
| 74 | + |
| 75 | + created_at: Optional[datetime] = None |
| 76 | + """The date and time when the note was created.""" |
| 77 | + |
| 78 | + user: Optional[str] = None |
| 79 | + """The userId of the person who created the note.""" |
| 80 | + |
| 81 | + |
| 82 | +class Alarm(JsonModel): |
| 83 | + """An individual instance, or occurrence, of an alarm. |
| 84 | + |
| 85 | + The lifecycle of an alarm begins the first time it is triggered and ends when it has been |
| 86 | + both acknowledged and cleared. The service enforces the invariant that there can be at most |
| 87 | + one active=True alarm with the same alarmId. |
| 88 | + """ |
| 89 | + |
| 90 | + instance_id: str |
| 91 | + """The unique identifier for the instance, or occurrence, of the alarm.""" |
| 92 | + |
| 93 | + alarm_id: str |
| 94 | + """A value meant to uniquely identify the particular process or condition tracked by the alarm. |
| 95 | + |
| 96 | + For example, alarms created by a tag rule engine might have their alarmIds set to the |
| 97 | + concatenation of the path of the tag which caused the rule to be triggered and the ID of the rule. |
| 98 | + """ |
| 99 | + |
| 100 | + workspace: str |
| 101 | + """The workspace the alarm belongs to.""" |
| 102 | + |
| 103 | + active: bool |
| 104 | + """Whether or not the alarm is active. |
| 105 | + |
| 106 | + An active alarm deserves human or automated attention. Alarms always begin life with active=True. |
| 107 | + This field will be automatically set to false when the clear and acknowledged fields are set to true. |
| 108 | + """ |
| 109 | + |
| 110 | + clear: bool |
| 111 | + """When set to true, the condition that triggered the alarm no longer matches the trigger condition. |
| 112 | + |
| 113 | + When an alarm is created, clear is initially set to false. The creator of the alarm (typically a |
| 114 | + rule engine or application element of some sort) may determine that the trigger condition no longer |
| 115 | + applies, and may send an update, clearing the alarm. Clearing the alarm does not deactivate the alarm, |
| 116 | + unless the alarm had previously been acknowledged. As long as the alarm is active=true, the alarm may |
| 117 | + transition from clear=True to clear=False (or vice versa) multiple times. |
| 118 | + """ |
| 119 | + |
| 120 | + acknowledged: bool |
| 121 | + """When set to true, the alarm has been acknowledged by an alarm handler, which is typically a human. |
| 122 | + |
| 123 | + Alarms always begin life with acknowledged=False. Acknowledging an alarm will not affect the active |
| 124 | + flag unless clear is also true. When clear and acknowledged are true, the alarm will become inactive |
| 125 | + (active=False). This field is automatically reset to false when the alarm's highestSeverityLevel field increases. |
| 126 | + """ |
| 127 | + |
| 128 | + acknowledged_at: Optional[datetime] |
| 129 | + """The date and time when the alarm instance was acknowledged. |
| 130 | + |
| 131 | + This field will be cleared when the alarm's highestSeverityLevel field increases. |
| 132 | + """ |
| 133 | + |
| 134 | + acknowledged_by: Optional[str] |
| 135 | + """The userId of the individual who acknowledged the alarm. |
| 136 | + |
| 137 | + This field will be cleared when the alarm's highestSeverityLevel field increases. |
| 138 | + """ |
| 139 | + |
| 140 | + occurred_at: datetime |
| 141 | + """The date and time when the alarm was created/first occurred.""" |
| 142 | + |
| 143 | + updated_at: datetime |
| 144 | + """The date and time when the alarm was last updated or modified.""" |
| 145 | + |
| 146 | + created_by: str |
| 147 | + """An identifier for who or what created the alarm. |
| 148 | + |
| 149 | + This is usually used to identify the particular rule engine which requested that the alarm be created. |
| 150 | + """ |
| 151 | + |
| 152 | + transitions: List[AlarmTransition] |
| 153 | + """A collection of AlarmTransitions for the alarm. |
| 154 | + |
| 155 | + The service stores the first transition and the most recent 99 other transitions by default. |
| 156 | + The configuration for the service determines the total number of stored transitions per alarm. |
| 157 | + """ |
| 158 | + |
| 159 | + transition_overflow_count: int |
| 160 | + """The number of transitions which overflowed the transitions field for the alarm. |
| 161 | + |
| 162 | + For example, if the alarm transitioned 250 times, transitionOverflowCount is set to 150 and |
| 163 | + transitions contains the first and most recent 99 transitions. The configuration for the service |
| 164 | + determines the total number of stored transitions per alarm. |
| 165 | + """ |
| 166 | + |
| 167 | + notification_strategy_ids: List[str] |
| 168 | + """The IDs of the notification strategies which will be triggered. |
| 169 | + |
| 170 | + These are triggered when the alarm is first created and when its highestSeverityLevel increases. |
| 171 | + """ |
| 172 | + |
| 173 | + current_severity_level: int |
| 174 | + """The current severity level of the alarm.""" |
| 175 | + |
| 176 | + highest_severity_level: int |
| 177 | + """The highest severity level that the alarm has ever been in.""" |
| 178 | + |
| 179 | + most_recent_set_occurred_at: Optional[datetime] |
| 180 | + """The date and time of the most recent occurrence of a SET transition. |
| 181 | + |
| 182 | + This property only considers transitions that cause an alarm state change. |
| 183 | + """ |
| 184 | + |
| 185 | + most_recent_transition_occurred_at: Optional[datetime] |
| 186 | + """The date and time of the most recent occurrence of a transition. |
| 187 | + |
| 188 | + This property only considers transitions that cause an alarm state change. |
| 189 | + """ |
| 190 | + |
| 191 | + channel: str |
| 192 | + """An identifier for the tag or resource associated with the alarm.""" |
| 193 | + |
| 194 | + condition: str |
| 195 | + """A description of the condition associated with the alarm.""" |
| 196 | + |
| 197 | + display_name: str |
| 198 | + """Optional display name for the alarm. Display names do not need to be unique.""" |
| 199 | + |
| 200 | + description: str |
| 201 | + """Optional description text for the alarm.""" |
| 202 | + |
| 203 | + keywords: List[str] |
| 204 | + """Words or phrases associated with the alarm. |
| 205 | + |
| 206 | + Alarms can be tagged with keywords to make it easier to find them with queries. |
| 207 | + """ |
| 208 | + |
| 209 | + notes: List[AlarmNote] |
| 210 | + """A collection of notes for a given alarm instance. |
| 211 | + |
| 212 | + Notes are set by humans to record information such as the root cause of the alarm. |
| 213 | + """ |
| 214 | + |
| 215 | + properties: Dict[str, str] |
| 216 | + """The alarm's custom properties.""" |
| 217 | + |
| 218 | + resource_type: str |
| 219 | + """The type of resource associated with the alarm.""" |
0 commit comments