Skip to content

Commit

Permalink
feat(api): Initial work
Browse files Browse the repository at this point in the history
Correlation PoC
Extend OnmsAlarm type with 'impacts' and 'causes'
  • Loading branch information
smith-opennms authored and Jesse White committed May 24, 2018
1 parent e1083c3 commit fa62503
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {V1FilterProcessor} from './dao/V1FilterProcessor';
import {V2FilterProcessor} from './dao/V2FilterProcessor';

import {OnmsAlarm} from './model/OnmsAlarm';
import {OnmsAlarmSummary} from './model/OnmsAlarmSummary';
import {OnmsAlarmType, AlarmTypes} from './model/OnmsAlarmType';
import {OnmsCategory, Categories} from './model/OnmsCategory';
import {OnmsCollectType, CollectTypes} from './model/OnmsCollectType';
Expand Down Expand Up @@ -93,6 +94,7 @@ const DAO = Object.freeze({
/** @hidden */
const Model = Object.freeze({
OnmsAlarm,
OnmsAlarmSummary,
OnmsAlarmType,
OnmsCategory,
Categories,
Expand Down
4 changes: 4 additions & 0 deletions src/dao/AlarmDAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {OnmsResult} from '../api/OnmsResult';
import {SearchProperty} from '../api/SearchProperty';

import {OnmsAlarm} from '../model/OnmsAlarm';
import {OnmsAlarmSummary} from '../model/OnmsAlarmSummary';
import {AlarmTypes} from '../model/OnmsAlarmType';
import {OnmsParm} from '../model/OnmsParm';
import {OnmsServiceType} from '../model/OnmsServiceType';
Expand Down Expand Up @@ -392,6 +393,9 @@ export class AlarmDAO extends AbstractDAO<number, OnmsAlarm> {
}
}

alarm.causes = data.causes;
alarm.impacts = data.impacts;

alarm.sticky = this.toMemo(data.stickyMemo);
alarm.journal = this.toMemo(data.reductionKeyMemo);

Expand Down
7 changes: 7 additions & 0 deletions src/model/OnmsAlarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Moment} from 'moment';

import {IHasUrlValue} from '../api/IHasUrlValue';
import {OnmsAlarmType} from './OnmsAlarmType';
import {OnmsAlarmSummary} from './OnmsAlarmSummary';
import {OnmsEvent} from './OnmsEvent';
import {OnmsParm} from './OnmsParm';
import {OnmsServiceType} from './OnmsServiceType';
Expand Down Expand Up @@ -83,6 +84,12 @@ export class OnmsAlarm implements IHasUrlValue {
/** the parameters emitted with this alarm's event */
public parameters: OnmsParm[];

/** impacts - A list of alarms impacted by this alarm */
public impacts: OnmsAlarmSummary[];

/** causes - A list of alarms that cause this alarm */
public causes: OnmsAlarmSummary[];

/** sticky memo - a note associated with this specific alarm instance */
public sticky: OnmsMemo;

Expand Down
30 changes: 30 additions & 0 deletions src/model/OnmsAlarmSummary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {Moment} from 'moment';

import {IHasUrlValue} from '../api/IHasUrlValue';
import {OnmsAlarmType} from './OnmsAlarmType';
import {OnmsSeverity} from './OnmsSeverity';

/**
* Represents an OpenNMS alarm.
* @module OnmsAlarm
*/
export class OnmsAlarmSummary implements IHasUrlValue {
/** the alarm ID */
public id: number;

/** the alarm's reduction key */
public reductionKey: string;

/** the alarm's type */
public type: OnmsAlarmType;

/** the alarm's severity */
public severity: OnmsSeverity;

/** the alarm's description */
public description: string;

public get urlValue() {
return String(this.id);
}
}

0 comments on commit fa62503

Please sign in to comment.