123456789101112131415161718192021222324252627282930313233 |
- from common import config
- from common.util import req_api
- class AlarmApi:
- def __init__(self):
- self.headers = None
- def get_alarm_current(self, page_index: int = 1, page_size: int = 400, alarm_severity:int = None, start_time: int = None,
- end_time: int = None, site_dns: list = None, dns: list = None, is_history=False):
- """
- 获取当前的告警信息
- :return:
- """
- params ={}
- if alarm_severity is not None:
- params['alarmSeverity'] = alarm_severity
- if start_time is not None:
- params['startTime'] = start_time
- if end_time is not None:
- params['endTime'] = end_time
- if site_dns is not None:
- params['siteDns'] = site_dns
- if dns is not None:
- params['dns'] = dns
- params['pageIndex'] = page_index
- params['pageSize'] = page_size
- if is_history:
- url = f'{config.DCIM_BASE_URL}/rest/openapi/neteco/nbi/v2/alarm/history'
- else:
- url = f'{config.DCIM_BASE_URL}/rest/openapi/neteco/nbi/v2/alarm/current'
- return req_api(url, headers=self.headers, params=params)
|