Commit cd649d6
Refactor and enhance Zabbix API interaction. (#1111)
* Handle Zabbix API exceptions and improve error reporting.
Add explicit handling for ZabbixAPIException by re-raising it when necessary. Additionally, improve error handling throughout by capturing exceptions, processing them with the `error()` method, and returning a well-structured Result object to ensure robustness and better debugging.
* Add support for bearer token authentication in Zabbix server
This update introduces a check for the authentication type, adding support for bearer token authentication alongside basic authentication. An exception is raised for invalid authentication methods, ensuring better error handling and robustness.
* Ensure Zabbix API URL is correctly formatted.
Added a conditional check to append '/api_jsonrpc.php' to the server URL only if it's not already included. This ensures compatibility with servers using preformatted URLs and avoids redundant suffixes.
* Add bearer token authentication support to Zabbix API
Refactors `login`, `test_login`, and `logged_in` methods to handle bearer tokens as an alternative authentication method. This improves flexibility and extends the API to support token-based authentication in addition to traditional user/password schemes. Also includes minor fixes like correcting a typo in exceptions.
* Refactor Zabbix API request handling for better clarity
Enhanced error handling, modularized header preparation and URL opener creation, and improved method documentation. This ensures more robust and maintainable interactions with the Zabbix API.
* Add authentication property initialization in Zabbix server
This change introduces the initialization of the `authentication` property using the server configuration. It ensures the Zabbix server object has the necessary authentication data available for further operations.
* Add new event actions and error handling for Zabbix API
Expanded event actions to include suppression and rank changes. Introduced error handling for blocked or incorrect credentials in the `event.acknowledge` API call to improve robustness.
* Fix error handling in Zabbix server login and acknowledgment
Enhanced error handling during login by catching exceptions and logging errors. Prevent execution continuation if login fails and ensure proper response for authentication issues.
---------
Co-authored-by: Kimmig, Simon - D0242573 <simon.kimmig@dm.de>1 parent 61e481b commit cd649d6
2 files changed
Lines changed: 144 additions & 72 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
| |||
127 | 133 | | |
128 | 134 | | |
129 | 135 | | |
130 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
131 | 141 | | |
132 | 142 | | |
133 | 143 | | |
| |||
153 | 163 | | |
154 | 164 | | |
155 | 165 | | |
| 166 | + | |
| 167 | + | |
156 | 168 | | |
157 | 169 | | |
158 | 170 | | |
| |||
212 | 224 | | |
213 | 225 | | |
214 | 226 | | |
| 227 | + | |
215 | 228 | | |
| 229 | + | |
216 | 230 | | |
217 | 231 | | |
218 | 232 | | |
| |||
457 | 471 | | |
458 | 472 | | |
459 | 473 | | |
460 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
461 | 479 | | |
462 | 480 | | |
463 | 481 | | |
| |||
486 | 504 | | |
487 | 505 | | |
488 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
489 | 512 | | |
490 | 513 | | |
491 | 514 | | |
| |||
501 | 524 | | |
502 | 525 | | |
503 | 526 | | |
504 | | - | |
505 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
506 | 535 | | |
507 | 536 | | |
508 | 537 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | 98 | | |
100 | 99 | | |
101 | 100 | | |
| |||
139 | 138 | | |
140 | 139 | | |
141 | 140 | | |
142 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
| |||
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
192 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
193 | 198 | | |
194 | 199 | | |
195 | 200 | | |
| |||
217 | 222 | | |
218 | 223 | | |
219 | 224 | | |
220 | | - | |
221 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
222 | 229 | | |
223 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
224 | 235 | | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
242 | 252 | | |
243 | 253 | | |
244 | 254 | | |
245 | 255 | | |
246 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
247 | 313 | | |
248 | 314 | | |
249 | 315 | | |
| |||
258 | 324 | | |
259 | 325 | | |
260 | 326 | | |
261 | | - | |
| 327 | + | |
262 | 328 | | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
| 329 | + | |
277 | 330 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
292 | 334 | | |
293 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
294 | 338 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
303 | 345 | | |
304 | | - | |
| 346 | + | |
305 | 347 | | |
306 | | - | |
| 348 | + | |
| 349 | + | |
307 | 350 | | |
308 | 351 | | |
309 | 352 | | |
| |||
0 commit comments