# -*- coding: utf-8 -*-
# 确认事件
# 作者: 陈磊
# 时间: 2019-10-24
from WorkUtils.UtilsRequest import UtilsRequest
from WorkUtils.UtilsLog import UtilsLog


class EventAcknowledge(object):
    def __init__(self, _host, eventids=None, action=None, message=None, severity=None):
        """
        :param _host: 域名
        :param eventids: 应用ID
        :param action : 主机组的ID
        :param message: 应用名称
        :param severity: 应用程序的来源
        :return:
        """
        self.log = UtilsLog()
        self.log.info("调用确认事件")
        self.log.info(self.__class__)

        self._host = _host
        self._headers = {}
        self._path = "/event/acknowledge"
        self._url = self._host + self._path
        self._params = {}
        self._json = {}
        self.response = ""

        self.eventids = eventids
        self.action = action
        self.message = message
        self.severity = severity

        self.api = UtilsRequest()

    def get_response(self):
        self._json = {
            "eventids": self.eventids,
            "action": self.action,
            "message": self.message,
            "severity": self.severity,
        }
        self.response = self.api.post(url=self._url, json=self._json)
