-
Notifications
You must be signed in to change notification settings - Fork 8
/
OnmsMonitoredService.ts
61 lines (46 loc) · 1.51 KB
/
OnmsMonitoredService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import {Moment} from 'moment';
import {IHasUrlValue} from '../api/IHasUrlValue';
import {OnmsServiceType} from './OnmsServiceType';
import {OnmsServiceStatusType} from './OnmsServiceStatusType';
import { Util } from '../internal/Util';
/**
* Represents an OpenNMS monitored service.
* @category Model
*/
export class OnmsMonitoredService implements IHasUrlValue {
/** the service ID */
public id?: number;
/** the last time the service failed */
public lastFail?: Moment;
/** the last time the service passed */
public lastGood?: Moment;
/** the node associated with this service */
public node?: any;
/** the ipInterface associated with this service */
public ipInterface?: any;
/** the service type associated with this service */
public type?: OnmsServiceType;
/** the current status */
public status?: OnmsServiceStatusType;
/** @inheritdoc */
public get urlValue() {
return this.type ? this.type.name : 'null';
}
/**
* create a monitored service object from a JSON object
* @hidden
*/
public static fromData(data: any): OnmsMonitoredService {
const service = new OnmsMonitoredService();
service.id = Util.toNumber(data.id);
service.lastFail = Util.toDate(data.lastFail);
service.lastGood = Util.toDate(data.lastGood);
if (data.serviceType) {
service.type = OnmsServiceType.for(data.serviceType.id, data.serviceType.name);
}
if (data.status) {
service.status = OnmsServiceStatusType.forId(data.status);
}
return service;
}
}