alarm_api.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. from common import config
  2. from common.util import req_api
  3. class AlarmApi:
  4. def __init__(self):
  5. self.headers = None
  6. def get_alarm_current(self, page_index: int = 1, page_size: int = 400, alarm_severity:int = None, start_time: int = None,
  7. end_time: int = None, site_dns: list = None, dns: list = None, is_history=False):
  8. """
  9. 获取当前的告警信息
  10. :return:
  11. """
  12. params ={}
  13. if alarm_severity is not None:
  14. params['alarmSeverity'] = alarm_severity
  15. if start_time is not None:
  16. params['startTime'] = start_time
  17. if end_time is not None:
  18. params['endTime'] = end_time
  19. if site_dns is not None:
  20. params['siteDns'] = site_dns
  21. if dns is not None:
  22. params['dns'] = dns
  23. params['pageIndex'] = page_index
  24. params['pageSize'] = page_size
  25. if is_history:
  26. url = f'{config.DCIM_BASE_URL}/rest/openapi/neteco/nbi/v2/alarm/history'
  27. else:
  28. url = f'{config.DCIM_BASE_URL}/rest/openapi/neteco/nbi/v2/alarm/current'
  29. return req_api(url, headers=self.headers, params=params)