@xen-orchestra/rest-api 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/groups/group.controller.mjs +82 -3
- package/dist/groups/group.type.mjs +1 -0
- package/dist/hosts/host.service.mjs +4 -4
- package/dist/middlewares/generic-error-handler.middleware.mjs +4 -3
- package/dist/open-api/common/response.common.mjs +4 -0
- package/dist/open-api/oa-examples/group.oa-example.mjs +3 -0
- package/dist/open-api/routes/routes.js +334 -16
- package/dist/users/user.controller.mjs +44 -2
- package/dist/users/user.type.mjs +1 -0
- package/dist/vbds/vbd.controller.mjs +34 -2
- package/dist/vifs/vif.controller.mjs +34 -2
- package/dist/vm-controller/vm-controller.controller.mjs +34 -2
- package/dist/vm-snapshots/vm-snapshot.controller.mjs +34 -2
- package/dist/vms/vm.controller.mjs +34 -2
- package/open-api/spec/swagger.json +968 -198
- package/package.json +1 -1
|
@@ -7,10 +7,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
-
import { Body, Delete, Example, Get, Middlewares, Path, Post, Query, Request, Response, Route, Security, SuccessResponse, Tags, } from 'tsoa';
|
|
10
|
+
import { Body, Delete, Example, Get, Middlewares, Patch, Path, Post, Query, Request, Response, Route, Security, SuccessResponse, Tags, } from 'tsoa';
|
|
11
11
|
import { json } from 'express';
|
|
12
12
|
import { provide } from 'inversify-binding-decorators';
|
|
13
|
-
import { createdResp, invalidParameters, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
13
|
+
import { createdResp, forbiddenOperationResp, invalidParameters, noContentResp, notFoundResp, resourceAlreadyExists, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
14
|
+
import { forbiddenOperation } from 'xo-common/api-errors.js';
|
|
14
15
|
import { partialUsers, user, userId, userIds } from '../open-api/oa-examples/user.oa-example.mjs';
|
|
15
16
|
import { XoController } from '../abstract-classes/xo-controller.mjs';
|
|
16
17
|
let UserController = class UserController extends XoController {
|
|
@@ -45,6 +46,37 @@ let UserController = class UserController extends XoController {
|
|
|
45
46
|
getUser(id) {
|
|
46
47
|
return this.getObject(id);
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* @example id "722d17b9-699b-49d2-8193-be1ac573d3de"
|
|
51
|
+
* @example body {
|
|
52
|
+
* "name": "updated user name",
|
|
53
|
+
* "password": "newP4ssword",
|
|
54
|
+
* "permission": "admin",
|
|
55
|
+
* "preferences": {}
|
|
56
|
+
* }
|
|
57
|
+
*/
|
|
58
|
+
async updateUser(id, body) {
|
|
59
|
+
const currentUser = this.restApi.getCurrentUser();
|
|
60
|
+
if (currentUser === undefined) {
|
|
61
|
+
throw new Error('current user is not defined');
|
|
62
|
+
}
|
|
63
|
+
const isAdmin = currentUser.permission === 'admin';
|
|
64
|
+
if (isAdmin) {
|
|
65
|
+
if (body.permission !== undefined && currentUser.id === id) {
|
|
66
|
+
throw forbiddenOperation('update user', 'cannot change own permission');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (body.name !== undefined || body.password !== undefined || body.permission !== undefined) {
|
|
70
|
+
throw forbiddenOperation('update user', 'cannot change these fields without admin rights');
|
|
71
|
+
}
|
|
72
|
+
const user = await this.getObject(id);
|
|
73
|
+
if (user.authProviders !== undefined &&
|
|
74
|
+
Object.keys(user.authProviders).length > 0 &&
|
|
75
|
+
(body.name !== undefined || body.password !== undefined)) {
|
|
76
|
+
throw forbiddenOperation('update user', 'cannot change name or password of synchronized user');
|
|
77
|
+
}
|
|
78
|
+
await this.restApi.xoApp.updateUser(user.id, body);
|
|
79
|
+
}
|
|
48
80
|
/**
|
|
49
81
|
* @example body { "name": "new user", "password": "password", "permission": "none" }
|
|
50
82
|
*/
|
|
@@ -75,6 +107,16 @@ __decorate([
|
|
|
75
107
|
Response(notFoundResp.status, notFoundResp.description),
|
|
76
108
|
__param(0, Path())
|
|
77
109
|
], UserController.prototype, "getUser", null);
|
|
110
|
+
__decorate([
|
|
111
|
+
Patch('{id}'),
|
|
112
|
+
Middlewares(json()),
|
|
113
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
114
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
115
|
+
Response(resourceAlreadyExists.status, resourceAlreadyExists.description),
|
|
116
|
+
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
117
|
+
__param(0, Path()),
|
|
118
|
+
__param(1, Body())
|
|
119
|
+
], UserController.prototype, "updateUser", null);
|
|
78
120
|
__decorate([
|
|
79
121
|
Example(userId),
|
|
80
122
|
Post(''),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,13 +10,18 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
|
|
11
11
|
import { inject } from 'inversify';
|
|
12
12
|
import { provide } from 'inversify-binding-decorators';
|
|
13
|
+
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
14
|
+
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
15
|
+
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
13
16
|
import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
14
17
|
import { partialVbds, vbd, vbdIds } from '../open-api/oa-examples/vbd.oa-example.mjs';
|
|
15
18
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
16
19
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
17
20
|
let VbdController = class VbdController extends XapiXoController {
|
|
18
|
-
|
|
21
|
+
#alarmService;
|
|
22
|
+
constructor(restApi, alarmService) {
|
|
19
23
|
super('VBD', restApi);
|
|
24
|
+
this.#alarmService = alarmService;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
*
|
|
@@ -34,6 +39,20 @@ let VbdController = class VbdController extends XapiXoController {
|
|
|
34
39
|
getVbd(id) {
|
|
35
40
|
return this.getObject(id);
|
|
36
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* @example id "f07ab729-c0e8-721c-45ec-f11276377030"
|
|
44
|
+
* @example fields "id,time"
|
|
45
|
+
* @example filter "time:>1747053793"
|
|
46
|
+
* @example limit 42
|
|
47
|
+
*/
|
|
48
|
+
getVbdAlarms(req, id, fields, ndjson, filter, limit) {
|
|
49
|
+
const vbd = this.getObject(id);
|
|
50
|
+
const alarms = this.#alarmService.getAlarms({
|
|
51
|
+
filter: `${escapeUnsafeComplexMatcher(filter) ?? ''} object:uuid:${vbd.uuid}`,
|
|
52
|
+
limit,
|
|
53
|
+
});
|
|
54
|
+
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
55
|
+
}
|
|
37
56
|
};
|
|
38
57
|
__decorate([
|
|
39
58
|
Example(vbdIds),
|
|
@@ -51,12 +70,25 @@ __decorate([
|
|
|
51
70
|
Response(notFoundResp.status, notFoundResp.description),
|
|
52
71
|
__param(0, Path())
|
|
53
72
|
], VbdController.prototype, "getVbd", null);
|
|
73
|
+
__decorate([
|
|
74
|
+
Example(genericAlarmsExample),
|
|
75
|
+
Get('{id}/alarms'),
|
|
76
|
+
Tags('alarms'),
|
|
77
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
78
|
+
__param(0, Request()),
|
|
79
|
+
__param(1, Path()),
|
|
80
|
+
__param(2, Query()),
|
|
81
|
+
__param(3, Query()),
|
|
82
|
+
__param(4, Query()),
|
|
83
|
+
__param(5, Query())
|
|
84
|
+
], VbdController.prototype, "getVbdAlarms", null);
|
|
54
85
|
VbdController = __decorate([
|
|
55
86
|
Route('vbds'),
|
|
56
87
|
Security('*'),
|
|
57
88
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
58
89
|
Tags('vbds'),
|
|
59
90
|
provide(VbdController),
|
|
60
|
-
__param(0, inject(RestApi))
|
|
91
|
+
__param(0, inject(RestApi)),
|
|
92
|
+
__param(1, inject(AlarmService))
|
|
61
93
|
], VbdController);
|
|
62
94
|
export { VbdController };
|
|
@@ -9,14 +9,19 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
|
|
11
11
|
import { inject } from 'inversify';
|
|
12
|
+
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
12
13
|
import { provide } from 'inversify-binding-decorators';
|
|
13
14
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
14
15
|
import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
15
16
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
16
17
|
import { partialVifs, vif, vifIds } from '../open-api/oa-examples/vif.oa-example.mjs';
|
|
18
|
+
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
19
|
+
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
17
20
|
let VifController = class VifController extends XapiXoController {
|
|
18
|
-
|
|
21
|
+
#alarmService;
|
|
22
|
+
constructor(restApi, alarmService) {
|
|
19
23
|
super('VIF', restApi);
|
|
24
|
+
this.#alarmService = alarmService;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* @example fields "attached,id,device"
|
|
@@ -32,6 +37,20 @@ let VifController = class VifController extends XapiXoController {
|
|
|
32
37
|
getVif(id) {
|
|
33
38
|
return this.getObject(id);
|
|
34
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* @example id "f028c5d4-578a-332c-394e-087aaca32dd3"
|
|
42
|
+
* @example fields "id,time"
|
|
43
|
+
* @example filter "time:>1747053793"
|
|
44
|
+
* @example limit 42
|
|
45
|
+
*/
|
|
46
|
+
getVifAlarms(req, id, fields, ndjson, filter, limit) {
|
|
47
|
+
const vif = this.getObject(id);
|
|
48
|
+
const alarms = this.#alarmService.getAlarms({
|
|
49
|
+
filter: `${escapeUnsafeComplexMatcher(filter) ?? ''} object:uuid:${vif.uuid}`,
|
|
50
|
+
limit,
|
|
51
|
+
});
|
|
52
|
+
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
53
|
+
}
|
|
35
54
|
};
|
|
36
55
|
__decorate([
|
|
37
56
|
Example(vifIds),
|
|
@@ -49,12 +68,25 @@ __decorate([
|
|
|
49
68
|
Response(notFoundResp.status, notFoundResp.description),
|
|
50
69
|
__param(0, Path())
|
|
51
70
|
], VifController.prototype, "getVif", null);
|
|
71
|
+
__decorate([
|
|
72
|
+
Example(genericAlarmsExample),
|
|
73
|
+
Get('{id}/alarms'),
|
|
74
|
+
Tags('alarms'),
|
|
75
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
76
|
+
__param(0, Request()),
|
|
77
|
+
__param(1, Path()),
|
|
78
|
+
__param(2, Query()),
|
|
79
|
+
__param(3, Query()),
|
|
80
|
+
__param(4, Query()),
|
|
81
|
+
__param(5, Query())
|
|
82
|
+
], VifController.prototype, "getVifAlarms", null);
|
|
52
83
|
VifController = __decorate([
|
|
53
84
|
Route('vifs'),
|
|
54
85
|
Security('*'),
|
|
55
86
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
56
87
|
Tags('vifs'),
|
|
57
88
|
provide(VifController),
|
|
58
|
-
__param(0, inject(RestApi))
|
|
89
|
+
__param(0, inject(RestApi)),
|
|
90
|
+
__param(1, inject(AlarmService))
|
|
59
91
|
], VifController);
|
|
60
92
|
export { VifController };
|
|
@@ -11,12 +11,17 @@ import { inject } from 'inversify';
|
|
|
11
11
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
12
12
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
13
13
|
import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
|
|
14
|
+
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
15
|
+
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
16
|
+
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
14
17
|
import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
15
18
|
import { provide } from 'inversify-binding-decorators';
|
|
16
19
|
import { partialVmControllers, vmController, vmControllerIds, } from '../open-api/oa-examples/vm-controller.oa-example.mjs';
|
|
17
20
|
let VmControllerController = class VmControllerController extends XapiXoController {
|
|
18
|
-
|
|
21
|
+
#alarmService;
|
|
22
|
+
constructor(restApi, alarmService) {
|
|
19
23
|
super('VM-controller', restApi);
|
|
24
|
+
this.#alarmService = alarmService;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
*
|
|
@@ -33,6 +38,20 @@ let VmControllerController = class VmControllerController extends XapiXoControll
|
|
|
33
38
|
getVmController(id) {
|
|
34
39
|
return this.getObject(id);
|
|
35
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* @example id "9b4775bd-9493-490a-9afa-f786a44caa4f"
|
|
43
|
+
* @example fields "id,time"
|
|
44
|
+
* @example filter "time:>1747053793"
|
|
45
|
+
* @example limit 42
|
|
46
|
+
*/
|
|
47
|
+
getVmControllerAlarms(req, id, fields, ndjson, filter, limit) {
|
|
48
|
+
const vmController = this.getObject(id);
|
|
49
|
+
const alarms = this.#alarmService.getAlarms({
|
|
50
|
+
filter: `${escapeUnsafeComplexMatcher(filter) ?? ''} object:uuid:${vmController.uuid}`,
|
|
51
|
+
limit,
|
|
52
|
+
});
|
|
53
|
+
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
54
|
+
}
|
|
36
55
|
};
|
|
37
56
|
__decorate([
|
|
38
57
|
Example(vmControllerIds),
|
|
@@ -50,12 +69,25 @@ __decorate([
|
|
|
50
69
|
Response(notFoundResp.status, notFoundResp.description),
|
|
51
70
|
__param(0, Path())
|
|
52
71
|
], VmControllerController.prototype, "getVmController", null);
|
|
72
|
+
__decorate([
|
|
73
|
+
Example(genericAlarmsExample),
|
|
74
|
+
Get('{id}/alarms'),
|
|
75
|
+
Tags('alarms'),
|
|
76
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
77
|
+
__param(0, Request()),
|
|
78
|
+
__param(1, Path()),
|
|
79
|
+
__param(2, Query()),
|
|
80
|
+
__param(3, Query()),
|
|
81
|
+
__param(4, Query()),
|
|
82
|
+
__param(5, Query())
|
|
83
|
+
], VmControllerController.prototype, "getVmControllerAlarms", null);
|
|
53
84
|
VmControllerController = __decorate([
|
|
54
85
|
Route('vm-controllers'),
|
|
55
86
|
Security('*'),
|
|
56
87
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
57
88
|
Tags('vms'),
|
|
58
89
|
provide(VmControllerController),
|
|
59
|
-
__param(0, inject(RestApi))
|
|
90
|
+
__param(0, inject(RestApi)),
|
|
91
|
+
__param(1, inject(AlarmService))
|
|
60
92
|
], VmControllerController);
|
|
61
93
|
export { VmControllerController };
|
|
@@ -9,14 +9,19 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
|
|
11
11
|
import { inject } from 'inversify';
|
|
12
|
+
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
13
|
+
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
14
|
+
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
12
15
|
import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
13
16
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
14
17
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
15
18
|
import { provide } from 'inversify-binding-decorators';
|
|
16
19
|
import { partialVmSnapshots, vmSnapshot, vmSnapshotIds } from '../open-api/oa-examples/vm-snapshot.oa-example.mjs';
|
|
17
20
|
let VmSnapshotController = class VmSnapshotController extends XapiXoController {
|
|
18
|
-
|
|
21
|
+
#alarmService;
|
|
22
|
+
constructor(restApi, alarmService) {
|
|
19
23
|
super('VM-snapshot', restApi);
|
|
24
|
+
this.#alarmService = alarmService;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
*
|
|
@@ -33,6 +38,20 @@ let VmSnapshotController = class VmSnapshotController extends XapiXoController {
|
|
|
33
38
|
getVmSnapshot(id) {
|
|
34
39
|
return this.getObject(id);
|
|
35
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
43
|
+
* @example fields "id,time"
|
|
44
|
+
* @example filter "time:>1747053793"
|
|
45
|
+
* @example limit 42
|
|
46
|
+
*/
|
|
47
|
+
getVmSnapshotAlarms(req, id, fields, ndjson, filter, limit) {
|
|
48
|
+
const vmSnapshot = this.getObject(id);
|
|
49
|
+
const alarms = this.#alarmService.getAlarms({
|
|
50
|
+
filter: `${escapeUnsafeComplexMatcher(filter) ?? ''} object:uuid:${vmSnapshot.uuid}`,
|
|
51
|
+
limit,
|
|
52
|
+
});
|
|
53
|
+
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
54
|
+
}
|
|
36
55
|
};
|
|
37
56
|
__decorate([
|
|
38
57
|
Example(vmSnapshotIds),
|
|
@@ -50,12 +69,25 @@ __decorate([
|
|
|
50
69
|
Response(notFoundResp.status, notFoundResp.description),
|
|
51
70
|
__param(0, Path())
|
|
52
71
|
], VmSnapshotController.prototype, "getVmSnapshot", null);
|
|
72
|
+
__decorate([
|
|
73
|
+
Example(genericAlarmsExample),
|
|
74
|
+
Get('{id}/alarms'),
|
|
75
|
+
Tags('alarms'),
|
|
76
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
77
|
+
__param(0, Request()),
|
|
78
|
+
__param(1, Path()),
|
|
79
|
+
__param(2, Query()),
|
|
80
|
+
__param(3, Query()),
|
|
81
|
+
__param(4, Query()),
|
|
82
|
+
__param(5, Query())
|
|
83
|
+
], VmSnapshotController.prototype, "getVmSnapshotAlarms", null);
|
|
53
84
|
VmSnapshotController = __decorate([
|
|
54
85
|
Route('vm-snapshots'),
|
|
55
86
|
Security('*'),
|
|
56
87
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
57
88
|
Tags('vms'),
|
|
58
89
|
provide(VmSnapshotController),
|
|
59
|
-
__param(0, inject(RestApi))
|
|
90
|
+
__param(0, inject(RestApi)),
|
|
91
|
+
__param(1, inject(AlarmService))
|
|
60
92
|
], VmSnapshotController);
|
|
61
93
|
export { VmSnapshotController };
|
|
@@ -11,16 +11,21 @@ import { Example, Get, Path, Post, Query, Request, Response, Route, Security, Ta
|
|
|
11
11
|
import { inject } from 'inversify';
|
|
12
12
|
import { incorrectState, invalidParameters } from 'xo-common/api-errors.js';
|
|
13
13
|
import { provide } from 'inversify-binding-decorators';
|
|
14
|
+
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
14
15
|
import { asynchronousActionResp, createdResp, internalServerErrorResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
15
16
|
import { BASE_URL } from '../index.mjs';
|
|
17
|
+
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
18
|
+
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
16
19
|
import { partialVms, vm, vmIds, vmStatsExample } from '../open-api/oa-examples/vm.oa-example.mjs';
|
|
17
20
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
18
21
|
import { taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
|
|
19
22
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
20
23
|
const IGNORED_VDIS_TAG = '[NOSNAP]';
|
|
21
24
|
let VmController = class VmController extends XapiXoController {
|
|
22
|
-
|
|
25
|
+
#alarmService;
|
|
26
|
+
constructor(restApi, alarmService) {
|
|
23
27
|
super('VM', restApi);
|
|
28
|
+
this.#alarmService = alarmService;
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
26
31
|
*
|
|
@@ -294,6 +299,20 @@ let VmController = class VmController extends XapiXoController {
|
|
|
294
299
|
},
|
|
295
300
|
});
|
|
296
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* @example id "f07ab729-c0e8-721c-45ec-f11276377030"
|
|
304
|
+
* @example fields "id,time"
|
|
305
|
+
* @example filter "time:>1747053793"
|
|
306
|
+
* @example limit 42
|
|
307
|
+
*/
|
|
308
|
+
getVmAlarms(req, id, fields, ndjson, filter, limit) {
|
|
309
|
+
const vm = this.getObject(id);
|
|
310
|
+
const alarms = this.#alarmService.getAlarms({
|
|
311
|
+
filter: `${escapeUnsafeComplexMatcher(filter) ?? ''} object:uuid:${vm.uuid}`,
|
|
312
|
+
limit,
|
|
313
|
+
});
|
|
314
|
+
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
315
|
+
}
|
|
297
316
|
};
|
|
298
317
|
__decorate([
|
|
299
318
|
Example(vmIds),
|
|
@@ -433,6 +452,18 @@ __decorate([
|
|
|
433
452
|
__param(1, Body()),
|
|
434
453
|
__param(2, Query())
|
|
435
454
|
], VmController.prototype, "snapshotVm", null);
|
|
455
|
+
__decorate([
|
|
456
|
+
Example(genericAlarmsExample),
|
|
457
|
+
Get('{id}/alarms'),
|
|
458
|
+
Tags('alarms'),
|
|
459
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
460
|
+
__param(0, Request()),
|
|
461
|
+
__param(1, Path()),
|
|
462
|
+
__param(2, Query()),
|
|
463
|
+
__param(3, Query()),
|
|
464
|
+
__param(4, Query()),
|
|
465
|
+
__param(5, Query())
|
|
466
|
+
], VmController.prototype, "getVmAlarms", null);
|
|
436
467
|
VmController = __decorate([
|
|
437
468
|
Route('vms'),
|
|
438
469
|
Security('*'),
|
|
@@ -442,6 +473,7 @@ VmController = __decorate([
|
|
|
442
473
|
// It automatically bind the class to the IOC container that handles dependency injection
|
|
443
474
|
,
|
|
444
475
|
provide(VmController),
|
|
445
|
-
__param(0, inject(RestApi))
|
|
476
|
+
__param(0, inject(RestApi)),
|
|
477
|
+
__param(1, inject(AlarmService))
|
|
446
478
|
], VmController);
|
|
447
479
|
export { VmController };
|