# -*- coding: utf-8 -*-
# 查询历史告警
# 作者: 陈磊
# 时间: 2019-11-19
from WorkUtils.UtilsRequest import UtilsRequest
from WorkUtils.UtilsLog import UtilsLog
from WorkApi.ApiBase import ApiBase, GetBase


class HistoryWarningGet(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 = "/historyWarning/get"
        self._url = self._host + self._path
        self._params = {}
        self._json = {}
        self._data = {}
        self.response = ""

        self.token = {}
        self.severity = None
        self.manageLevel = None
        self.solveStatus = None
        self.acknowledged = None
        self.ignoreStatus = None
        self.knowledgeBase = None
        self.dateFrom = None
        self.dateTo = None
        self.object = None
        self.source = 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="solveStatus", value=self.solveStatus)
        base.dict_add_key(_key="acknowledged", value=self.acknowledged)
        base.dict_add_key(_key="ignoreStatus", value=self.ignoreStatus)
        base.dict_add_key(_key="knowledgeBase", value=self.knowledgeBase)
        base.dict_add_key(_key="dateFrom", value=self.dateFrom)
        base.dict_add_key(_key="dateTo", value=self.dateTo)
        base.dict_add_key(_key="object", value=self.object)
        base.dict_add_key(_key="source", value=self.source)
        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, params=self._params)
