def getByTriggerID(strigger_id, conditionJson, likeConditionjson=None, page_no=1, page_size=15, headers=None, **kwargs): '''根据user的ID查找告警策略''' try: conditionJson = json.loads(conditionJson) likeConditionjson = json.loads(likeConditionjson) triggerObjOP = TriggerObjAction() result = triggerObjOP.getTriggerObjByPage( triggerObjOP.getQueryByCondition(conditionJson, likeConditionjson), page_no, page_size) triggerObjOP.getByTriggerID(strigger_id) dataResult = [] if result: for i in result: dataResult.append(getJsonFromObj(i)) return outSuccess( "triggerObjList", pagePackage("triggerObjs", dataResult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) return outError("取得告警策略对象失败!")
def listByPage(conditionJson, likeConditionjson=None, page_no=1, page_size=15, headers=None, **kwargs): ''' 分页查询策略 ''' try: triggerObj = TriggerObjAction() result = triggerObj.getTriggerObjByPage( triggerObj.getQueryByCondition(conditionJson, likeConditionjson), page_no, page_size) dataResult = [] if result: for i in result: dataResult.append(getJsonFromObj(i)) return outSuccess( "triggerObjList", pagePackage("triggerObjs", dataResult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) return outError("取得策略对象失败!")
def getNoticeByUserID(user_id, conditionJson, likeConditionjson=None, page_no=1, page_size=15, headers=None, **kwargs): '''根据user的ID查找告警策略''' try: conditionJson = json.loads(conditionJson) likeConditionjson = json.loads(likeConditionjson) noticeOP = SysNoticesAction() result = noticeOP.getNoticeByPage()(noticeOP.getQueryByCondition( conditionJson, likeConditionjson), page_no, page_size) noticeOP.getNoticeByPage(user_id) dataResult = [] if result: for i in result: dataResult.append(getJsonFromObj(i)) return outSuccess( "noticeList", pagePackage("notices", dataResult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) return outError("取得告警接收人失败!")
def listByPage(conditionJson, likeConditionjson=None, page_no=1, page_size=15, headers=None, **kwargs): ''' 分页查询策略 ''' try: notices = SysNoticesAction() result = notices.getNoticeByPage( notices.getQueryByCondition(conditionJson, likeConditionjson), page_no, page_size) dataResult = [] if result: for i in result: dataResult.append(getJsonFromObj(i)) return outSuccess( "noticeList", pagePackage("notices", dataResult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) return outError("取得接收人失败!")
def getByTriggerID(strigger_id, headers=None, **kwargs): '''根据strigger_id查找触发器项''' try: triggeritemOP = SysTriggerItemsAction(SysTriggerItems) result = triggeritemOP.getByTriggerID(strigger_id) dataResult = [] if result: for i in result: dataResult.append(getJsonFromObj(i)) return outSuccess("triitemList", pagePackage('triitems', dataResult)) except Exception as e: LOG.error(str(e)) return outError("取得触发器项失败!")
def listByPage(conditionJson, likeConditionjson=None, page_no=1, page_size=15, headers=None, **kwargs): ''' 分页查询策略 ''' try: trigger = SysTriggersAction() result = trigger.getAlarmByPage(trigger.getQueryByCondition(conditionJson, likeConditionjson), page_no, page_size) dataResult = [] if result: for i in result: dataResult.append(getJsonFromObj(i)) return outSuccess("triggerList", pagePackage("triggers", dataResult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) return outError("取得策略列表失败!")
def listByPage(conditionJson, likeConditionjson=None, page_no=1, page_size=15, headers=None, **kwargs): ''' 分页查询策略 ''' try: notices = SysNoticesAction() result = notices.getNoticeByPage(notices.getQueryByCondition(conditionJson, likeConditionjson), page_no, page_size) dataResult = [] if result: for i in result: dataResult.append(getJsonFromObj(i)) return outSuccess("noticeList", pagePackage("notices", dataResult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) return outError("取得接收人失败!")
def listByPage(conditionJson, likeConditionjson=None, page_no=1, page_size=15, headers=None, **kwargs): ''' 分页查询告警历史 ''' try: triggerlog = SysAlarmLogsAction() result = triggerlog.getalarmlogByPage(triggerlog.getQueryByCondition(conditionJson, likeConditionjson), page_no, page_size) dataResult = [] if result: for i in result: dataResult.append(getJsonFromObj(i)) return outSuccess("alarmlogList", pagePackage("alarmlogs", dataResult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) return outError("取得告警历史列表失败!")
def getTriggerByUserID(user_id, conditionJson, likeConditionjson=None, page_no=1, page_size=15, headers=None, **kwargs): '''根据user的ID查找告警策略''' try: conditionJson = json.loads(conditionJson) likeConditionjson = json.loads(likeConditionjson) triggerOP = SysTriggersAction() result = triggerOP.getAlarmByPage(triggerOP.getQueryByCondition(conditionJson, likeConditionjson), page_no, page_size) triggerOP.getTriggerByUserID(user_id) dataResult = [] if result: for i in result: dataResult.append(getJsonFromObj(i)) return outSuccess("triggerList", pagePackage("triggers", dataResult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) return outError("取得告警策略失败!")