|
| 1 | +# MIT License |
| 2 | +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP. |
| 3 | +# |
| 4 | +# alarm : Alarms |
| 5 | +from __future__ import annotations |
| 6 | + |
| 7 | + |
| 8 | +def get_appliance_alarms( |
| 9 | + self, |
| 10 | +) -> dict: |
| 11 | + """Return active alarms |
| 12 | +
|
| 13 | + .. list-table:: |
| 14 | + :header-rows: 1 |
| 15 | +
|
| 16 | + * - Swagger Section |
| 17 | + - Method |
| 18 | + - Endpoint |
| 19 | + * - alarm |
| 20 | + - GET |
| 21 | + - /alarm |
| 22 | +
|
| 23 | + :return: Returns summary of alarms and outstanding alarm details \n |
| 24 | + * keyword **summary** (`dict`): Alarm summary object \n |
| 25 | + * keyword **num_cleared** (`int`): Number of alarms cleared |
| 26 | + * keyword **num_critical** (`int`): Number of critical |
| 27 | + alarms |
| 28 | + * keyword **num_equipment_outstanding** (`int`): Number of |
| 29 | + hardware alarms outstanding |
| 30 | + * keyword **num_major** (`int`): Number of major alarms |
| 31 | + * keyword **num_minor** (`int`): Number of minor alarms |
| 32 | + * keyword **num_outstanding** (`int`): Number of |
| 33 | + outstanding alarms |
| 34 | + * keyword **num_raise_ignore** (`int`): Number of raise |
| 35 | + ignore |
| 36 | + * keyword **num_software_outstanding** (`int`): Number of |
| 37 | + software alarms outstanding |
| 38 | + * keyword **num_tca_outstanding** (`int`): Number of TCA |
| 39 | + alarms outstanding |
| 40 | + * keyword **num_traffic_class_outstanding** (`int`): Number |
| 41 | + of traffic class alarms outstanding |
| 42 | + * keyword **num_tunnel_outstanding** (`int`): Number of |
| 43 | + tunnel alarms outstanding |
| 44 | + * keyword **num_warning** (`int`): Number of warning alarms |
| 45 | + * keyword **outstanding* (`list[dict]`): Outstanding alarms \n |
| 46 | + * [`dict`]: Outstanding Alarm detail object \n |
| 47 | + * keyword **severity** (`int`): Alarm severity, |
| 48 | + ``0`` translates to ``Info``, |
| 49 | + ``1`` translates to ``Warning``, |
| 50 | + ``2`` translates to ``Minor``, |
| 51 | + ``3`` translates to ``Major``, |
| 52 | + ``4`` translates to ``Critical``, |
| 53 | + * keyword **sequenceId** (`int`): Alarm sequence ID |
| 54 | + * keyword **source** (`str`): Source IP address |
| 55 | + * keyword **acknowledged** (`bool`): ``True`` if alarm |
| 56 | + has been acknowledged |
| 57 | + * keyword **clearable** (`bool`): ``True`` if alarm |
| 58 | + can be cleared by user |
| 59 | + * keyword **time** (`int`): Time alarm occured in unix |
| 60 | + epoch ms |
| 61 | + * keyword **description** (`str`): Description of alarm |
| 62 | + detail |
| 63 | + * keyword **type** (`str`): Hardware (``HW``) or |
| 64 | + Software (``SW``) |
| 65 | + * keyword **recommendation** (`str`): Recommended action |
| 66 | + for alarm |
| 67 | + * keyword **serviceAffect** (`bool`): ``True`` if |
| 68 | + condition could be service affecting |
| 69 | + * keyword **typeId** (`int`): Alarm type ID number |
| 70 | + * keyword **name** (`str`): Alarm name |
| 71 | + * keyword **occurenceCount** (`int`): Count of |
| 72 | + occurences of alarm |
| 73 | + * keyword **active** (`bool`): ``True`` if alarm is |
| 74 | + currently active |
| 75 | + * keyword **ackedBy** (`str`): Username that |
| 76 | + acknolwedged alarm |
| 77 | + * keyword **ackedTime** (`int`): Time of acknolwedgement |
| 78 | + in Unix epoch ms |
| 79 | + * keyword **clearedBy** (`str`): Username that cleared |
| 80 | + alarm |
| 81 | + * keyword **clearedTime** (`int`): Time of clear in Unix |
| 82 | + epoch ms |
| 83 | + * keyword **note** (`str`): Additional alarm notes |
| 84 | + :rtype: dict |
| 85 | + """ |
| 86 | + return self._get("/alarm") |
| 87 | + |
| 88 | + |
| 89 | +def acknowledge_appliance_alarms( |
| 90 | + self, |
| 91 | + alarm_seq_ids: list[int], |
| 92 | + acknowledge: bool, |
| 93 | + ack_by: str, |
| 94 | +) -> bool: |
| 95 | + """Acknowledge appliance alarms by sequence ids |
| 96 | +
|
| 97 | + .. list-table:: |
| 98 | + :header-rows: 1 |
| 99 | +
|
| 100 | + * - Swagger Section |
| 101 | + - Method |
| 102 | + - Endpoint |
| 103 | + * - alarm |
| 104 | + - POST |
| 105 | + - /alarm/acknowledgement |
| 106 | +
|
| 107 | + :param alarm_seq_ids: List of alarm sequence ids to acknowledge |
| 108 | + :type alarm_seq_ids: list[int] |
| 109 | + :param acknowledge: ``True`` to acknowledge alarms |
| 110 | + :type acknowledge: bool |
| 111 | + :param ack_by: User to mark alarms acknowledged by |
| 112 | + :type ack_by: str |
| 113 | + :return: Returns True/False based on successful call |
| 114 | + :rtype: bool |
| 115 | + """ |
| 116 | + data = { |
| 117 | + "sequenceIds": alarm_seq_ids, |
| 118 | + "acknowledge": acknowledge, |
| 119 | + "ackedBy": ack_by, |
| 120 | + } |
| 121 | + |
| 122 | + return self._post( |
| 123 | + "/alarm/acknowledgement", |
| 124 | + data=data, |
| 125 | + return_type="bool", |
| 126 | + ) |
| 127 | + |
| 128 | + |
| 129 | +def clear_appliance_alarms( |
| 130 | + self, |
| 131 | + alarm_seq_ids: list[int], |
| 132 | + cleared_by: str, |
| 133 | +) -> bool: |
| 134 | + """Acknowledge appliance alarms by sequence ids |
| 135 | +
|
| 136 | + .. list-table:: |
| 137 | + :header-rows: 1 |
| 138 | +
|
| 139 | + * - Swagger Section |
| 140 | + - Method |
| 141 | + - Endpoint |
| 142 | + * - alarm |
| 143 | + - POST |
| 144 | + - /alarm/clearance |
| 145 | +
|
| 146 | + :param alarm_seq_ids: List of alarm sequence ids to clear |
| 147 | + :type alarm_seq_ids: list[int] |
| 148 | + :param cleared_by: User to mark alarms cleared by |
| 149 | + :type cleared_by: str |
| 150 | + :return: Returns True/False based on successful call |
| 151 | + :rtype: bool |
| 152 | + """ |
| 153 | + data = { |
| 154 | + "sequenceIds": alarm_seq_ids, |
| 155 | + "clearedBy": cleared_by, |
| 156 | + } |
| 157 | + |
| 158 | + return self._post( |
| 159 | + "/alarm/clearance", |
| 160 | + data=data, |
| 161 | + return_type="bool", |
| 162 | + ) |
| 163 | + |
| 164 | + |
| 165 | +def get_appliance_alarm_descriptions( |
| 166 | + self, |
| 167 | + format: str, |
| 168 | +) -> list: |
| 169 | + """Get Orchestrator alarm descriptions |
| 170 | +
|
| 171 | + .. list-table:: |
| 172 | + :header-rows: 1 |
| 173 | +
|
| 174 | + * - Swagger Section |
| 175 | + - Method |
| 176 | + - Endpoint |
| 177 | + * - alarm |
| 178 | + - GET |
| 179 | + - /alarm/description2 |
| 180 | + :param format: Specify to ``csv`` to download CSV format, otherwise |
| 181 | + will return information in list of dictionaries of JSON format |
| 182 | + :type format: str |
| 183 | + :return: Returns list of alarm descriptions and details \n |
| 184 | + * [`dict`]: List of alarm description dictionaries \n |
| 185 | + * keyword **typeId** (`int`): Alarm type id |
| 186 | + * keyword **severity** (`str`): Alarm severity info |
| 187 | + * keyword **description** (`str`): Alarm description |
| 188 | + * keyword **recommendedAction** (`str`): recommended action |
| 189 | + * keyword **serviceAffecting** (`bool`): Is alarm service |
| 190 | + affecting |
| 191 | + * keyword **source** (`str`): Module/system that generates |
| 192 | + alarm |
| 193 | + * keyword **systemType** (`int`): Identifies which system |
| 194 | + generated the alaram.0 = Appliance,100 = Orchestartor |
| 195 | + * keyword **sourceType** (`int`): Identifies the category of |
| 196 | + alarm. ``1`` = Tunnel, ``2`` = Traffic Class, ``3`` = |
| 197 | + Equipment, ``4`` = Software, ``5`` = Threshold |
| 198 | + * keyword **alarmType** (`int`): Uniquely identifies the |
| 199 | + type of alarm within a sourceType |
| 200 | + * keyword **clearable** (`bool`): Identifies whether an |
| 201 | + alarm is clearable |
| 202 | + :rtype: dict |
| 203 | + """ |
| 204 | + return self._get("/alarm/description2") |
| 205 | + |
| 206 | + |
| 207 | +def add_note_appliance_alarms( |
| 208 | + self, |
| 209 | + alarm_seq_ids: list[int], |
| 210 | + note: str, |
| 211 | +) -> bool: |
| 212 | + """Update notes on appliance alarms |
| 213 | +
|
| 214 | + .. list-table:: |
| 215 | + :header-rows: 1 |
| 216 | +
|
| 217 | + * - Swagger Section |
| 218 | + - Method |
| 219 | + - Endpoint |
| 220 | + * - alarm |
| 221 | + - POST |
| 222 | + - /alarm/note |
| 223 | +
|
| 224 | + :param alarm_seq_ids: List of alarm sequence ids to add note to |
| 225 | + :type alarm_seq_ids: list[int] |
| 226 | + :param note: Note to add to specified alarms |
| 227 | + :type note: str |
| 228 | + :return: Returns True/False based on successful call |
| 229 | + :rtype: bool |
| 230 | + """ |
| 231 | + data = { |
| 232 | + "sequenceIds": alarm_seq_ids, |
| 233 | + "note": note, |
| 234 | + } |
| 235 | + |
| 236 | + return self._post( |
| 237 | + "/alarm/note", |
| 238 | + data=data, |
| 239 | + return_type="bool", |
| 240 | + ) |
| 241 | + |
| 242 | + |
| 243 | +def delete_appliance_alarms( |
| 244 | + self, |
| 245 | + alarm_seq_ids: list[int], |
| 246 | +) -> bool: |
| 247 | + """Delete alarms on appliance |
| 248 | +
|
| 249 | + .. list-table:: |
| 250 | + :header-rows: 1 |
| 251 | +
|
| 252 | + * - Swagger Section |
| 253 | + - Method |
| 254 | + - Endpoint |
| 255 | + * - alarm |
| 256 | + - POST |
| 257 | + - /alarm/delete |
| 258 | +
|
| 259 | + :param alarm_seq_ids: List of alarm sequence ids to delete |
| 260 | + :type alarm_seq_ids: list[int] |
| 261 | + :return: Returns True/False based on successful call |
| 262 | + :rtype: bool |
| 263 | + """ |
| 264 | + data = { |
| 265 | + "sequenceIds": alarm_seq_ids, |
| 266 | + } |
| 267 | + |
| 268 | + return self._post( |
| 269 | + "/alarm/delete", |
| 270 | + data=data, |
| 271 | + return_type="bool", |
| 272 | + ) |
0 commit comments