# -*- coding: utf-8 -*-
# 查询最新告警列表
# 作者: 陈磊
# 时间: 2019-12-10
from WorkUtils.UtilsRequest import UtilsRequest
from WorkUtils.UtilsLog import UtilsLog
from WorkApi.ApiBase import ApiBase, GetBase


class LatestWarningGet(object):
    def __init__(self, _host):
        """
        :param _host: 域名
        :return:
        """
        self.log = UtilsLog()
        self.log.info("调用查询最新告警列表")
        self.log.info(self.__class__)

        self._host = _host
        self._headers = {}
        self._path = "/latestWarning/get"
        self._url = self._host + self._path
        self._params = {}
        self._json = {}
        self._data = {}
        self.response = ""

        self.token = None
        self.severity = None
        self.manageLevel = None
        self.acknowledged = None
        self.dateFrom = None
        self.dateTo = None
        self.hostType = None
        self.hostName = None
        self.alarmRuleid = None
        self.experienceid = None
        self.businessid = None

        self.api = UtilsRequest()

    def get_response(self):
        base = ApiBase()
        base.dict_add_key(_key="token", value=self.token)
        self._headers = base._json

        base = ApiBase()
        base.dict_add_key(_key="severity", value=self.severity)
        base.dict_add_key(_key="manageLevel", value=self.manageLevel)
        base.dict_add_key(_key="acknowledged", value=self.acknowledged)
        base.dict_add_key(_key="dateFrom", value=self.dateFrom)
        base.dict_add_key(_key="dateTo", value=self.dateTo)
        base.dict_add_key(_key="hostType", value=self.hostType)
        base.dict_add_key(_key="hostName", value=self.hostName)
        base.dict_add_key(_key="alarmRuleid", value=self.alarmRuleid)
        base.dict_add_key(_key="experienceid", value=self.experienceid)
        base.dict_add_key(_key="businessid", value=self.businessid)
        self._params = base._json
        self.response = self.api.get(url=self._url, headers=self._headers, params=self._params)
