Name

sn_em_arm.EvtMgmtGetActionsFromRulesScoped

Description

No description available

Script

var EvtMgmtGetActionsFromRulesScoped = Class.create();
EvtMgmtGetActionsFromRulesScoped.prototype = {

  type: 'EvtMgmtGetActionsFromRulesScoped',

  initialize: function() {
      this.evtMgmtAlertMgmtMediator = new global.EvtMgmtAlertMgmtMediator();
  },

  getRemediationsAndLaunches: function(alertSysId, retrieveParams) {
      var result = {};
      result.toolsForAlert = [];
      result.manualRemediationData = [];
      result.workflowsData = [];

      if (retrieveParams.retrieveLaunchApplications) {
          var alertManagerActions = this.evtMgmtAlertMgmtMediator.getToolsForAlert(alertSysId);
          result.toolsForAlert = this.getLaunchApplicationObjectsList(alertManagerActions);
      }

      if (retrieveParams.retrieveRemediations) {
          var legacyManualRemediations = this.evtMgmtAlertMgmtMediator.getManualRemediationActionsForAlert(String(alertSysId));
          if (this.evtMgmtAlertMgmtMediator.getRemediationObjectsList && (typeof this.evtMgmtAlertMgmtMediator.getRemediationObjectsList == 'function')) {
              result.manualRemediationData = this.evtMgmtAlertMgmtMediator.getRemediationObjectsList(legacyManualRemediations, false);
          } else {
              result.manualRemediationData = this.getRemediationObjectsList(legacyManualRemediations, false);
          }
      }
      return result;
  },
  
  getRemediationObjectsList: function(remediationsList, isFromAlertManagement, alertSysId) {
      var manualRemediationsArray = [];
      for (var index = 0; index < remediationsList.length; index++) {
          var manualRemediationOBJ = {};
          if (isFromAlertManagement) {
              manualRemediationOBJ.workflowId = remediationsList[index].action.getWorkflowId();
              manualRemediationOBJ.workflowName = remediationsList[index].action.getWorkflowName();
              manualRemediationOBJ.actionId = remediationsList[index].action.getActionSysid();
              manualRemediationOBJ.rule = remediationsList[index].rule;
              manualRemediationOBJ.alertManagementRule = true;
              manualRemediationOBJ.ruleOrder = remediationsList[index].ruleOrder;
              manualRemediationOBJ.ruleName = remediationsList[index].ruleName;
          } else {
              manualRemediationOBJ.workflowId = remediationsList[index].getWorkflowId();
              manualRemediationOBJ.workflowName = remediationsList[index].getWorkflowName();
          }
          manualRemediationOBJ.alertSysId = alertSysId;
          manualRemediationsArray.push(manualRemediationOBJ);
      }
      return manualRemediationsArray;
  },


  getLaunchApplicationObjectsList: function(launchApplicationList) {
      var toolsArray = [];
      for (var i = 0; i < launchApplicationList.length; i++) {
          //convert to a js object
          var tool = {};
          tool.ruleName = launchApplicationList[i].getRuleName();
          tool.displayName = launchApplicationList[i].getDisplayName();
          tool.url = launchApplicationList[i].getUrl();
          tool.valid = launchApplicationList[i].isValid();
          toolsArray.push(tool);
      }
      return toolsArray;
  },
};

Sys ID

720bd122b71d20107c038229ce11a97f

Offical Documentation

Official Docs: