@xen-orchestra/rest-api 0.28.2 → 0.30.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/README.md +108 -1
- package/dist/abstract-classes/base-controller.mjs +28 -3
- package/dist/abstract-classes/listener.mjs +124 -15
- package/dist/acl-privileges/acl-privilege.controller.mjs +172 -0
- package/dist/acl-roles/acl-role.controller.mjs +384 -0
- package/dist/alarms/alarm.controller.mjs +25 -11
- package/dist/alarms/alarm.service.mjs +8 -0
- package/dist/backup-archives/backup-archive.controller.mjs +33 -23
- package/dist/backup-archives/backup-archive.service.mjs +21 -0
- package/dist/backup-jobs/backup-job.controller.mjs +74 -25
- package/dist/backup-jobs/backup-job.service.mjs +7 -0
- package/dist/backup-logs/backup-log.controller.mjs +28 -13
- package/dist/backup-logs/backup-log.service.mjs +19 -0
- package/dist/backup-repositories/backup-repositories.controller.mjs +24 -5
- package/dist/events/event.class.mjs +36 -18
- package/dist/events/event.controller.mjs +3 -0
- package/dist/events/event.service.mjs +4 -4
- package/dist/groups/group.controller.mjs +99 -12
- package/dist/helpers/markdown.helper.mjs +20 -0
- package/dist/helpers/object-wrapper.helper.mjs +3 -3
- package/dist/hosts/host.controller.mjs +90 -15
- package/dist/ioc/ioc.mjs +13 -4
- package/dist/messages/message.controller.mjs +32 -10
- package/dist/middlewares/acl.middleware.mjs +202 -0
- package/dist/middlewares/authentication.middleware.mjs +15 -6
- package/dist/middlewares/tsoa-to-xo-error.middleware.mjs +19 -1
- package/dist/networks/network.controller.mjs +72 -17
- package/dist/open-api/oa-examples/acl-privilege.oa-example.mjs +25 -0
- package/dist/open-api/oa-examples/acl-role.oa-example.mjs +22 -0
- package/dist/open-api/oa-examples/backup-archive.oa-example.mjs +6 -6
- package/dist/open-api/oa-examples/common.oa-example.mjs +3 -0
- package/dist/open-api/routes/routes.js +856 -172
- package/dist/pbds/pbd.controller.mjs +20 -5
- package/dist/pcis/pci.controller.mjs +19 -5
- package/dist/pgpus/pgpu.controller.mjs +19 -5
- package/dist/pifs/pif.controller.mjs +56 -16
- package/dist/pools/pool.controller.mjs +166 -17
- package/dist/proxies/proxy.controller.mjs +25 -6
- package/dist/restore-logs/restore-log.controller.mjs +42 -23
- package/dist/schedules/schedule.controller.mjs +36 -5
- package/dist/servers/server.controller.mjs +71 -9
- package/dist/sms/sm.controller.mjs +17 -4
- package/dist/srs/sr.controller.mjs +74 -18
- package/dist/tasks/task.controller.mjs +74 -13
- package/dist/users/user.controller.mjs +124 -22
- package/dist/vbds/vbd.controller.mjs +76 -38
- package/dist/vdi-snapshots/vdi-snapshot.controller.mjs +48 -14
- package/dist/vdis/vdi.controller.mjs +81 -16
- package/dist/vifs/vif.controller.mjs +118 -16
- package/dist/vm-controller/vm-controller.controller.mjs +77 -19
- package/dist/vm-snapshots/vm-snapshot.controller.mjs +85 -18
- package/dist/vm-templates/vm-template.controller.mjs +86 -18
- package/dist/vms/vm.controller.mjs +182 -24
- package/open-api/spec/swagger.json +12112 -3537
- package/package.json +12 -11
|
@@ -7,7 +7,7 @@ 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 { Delete, Example, Get, Path, Put, Query, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa';
|
|
10
|
+
import { Delete, Example, Get, Path, Put, Query, Request, Response, Route, Security, SuccessResponse, Tags, Middlewares, } from 'tsoa';
|
|
11
11
|
import { inject } from 'inversify';
|
|
12
12
|
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
13
13
|
import { escapeUnsafeComplexMatcher, limitAndFilterArray } from '../helpers/utils.helper.mjs';
|
|
@@ -16,6 +16,7 @@ import { partialTasks, taskIds } from '../open-api/oa-examples/task.oa-example.m
|
|
|
16
16
|
import { badRequestResp, forbiddenOperationResp, incorrectStateResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
17
17
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
18
18
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
19
|
+
import { acl } from '../middlewares/acl.middleware.mjs';
|
|
19
20
|
import { provide } from 'inversify-binding-decorators';
|
|
20
21
|
import { partialVmSnapshots, vmSnapshot, vmSnapshotIds, vmSnapshotVdis, } from '../open-api/oa-examples/vm-snapshot.oa-example.mjs';
|
|
21
22
|
import { VmService } from '../vms/vm.service.mjs';
|
|
@@ -29,18 +30,26 @@ let VmSnapshotController = class VmSnapshotController extends XapiXoController {
|
|
|
29
30
|
this.#vmService = vmService;
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
33
|
+
* Returns all VM snapshots that match the following privilege:
|
|
34
|
+
* - resource: vm-snapshot, action: read
|
|
32
35
|
*
|
|
33
36
|
* @example fields "uuid,snapshot_time,$snapshot_of"
|
|
34
37
|
* @example filter "snapshot_time:>1725020038"
|
|
35
38
|
* @example limit 42
|
|
36
39
|
*/
|
|
37
|
-
getVmSnapshots(req, fields, ndjson, filter, limit) {
|
|
38
|
-
return this.sendObjects(Object.values(this.getObjects({ filter
|
|
40
|
+
getVmSnapshots(req, fields, ndjson, markdown, filter, limit) {
|
|
41
|
+
return this.sendObjects(Object.values(this.getObjects({ filter })), req, {
|
|
42
|
+
limit,
|
|
43
|
+
privilege: { action: 'read', resource: 'vm-snapshot' },
|
|
44
|
+
});
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
41
47
|
*
|
|
42
48
|
* Export VM-snapshot. Compress is only used for XVA format
|
|
43
49
|
*
|
|
50
|
+
* Required privilege:
|
|
51
|
+
* - resource: vm-snapshot, action: export
|
|
52
|
+
*
|
|
44
53
|
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
45
54
|
*/
|
|
46
55
|
async exportVmSnapshot(req, id, format, compress) {
|
|
@@ -54,12 +63,18 @@ let VmSnapshotController = class VmSnapshotController extends XapiXoController {
|
|
|
54
63
|
return stream;
|
|
55
64
|
}
|
|
56
65
|
/**
|
|
66
|
+
* Required privilege:
|
|
67
|
+
* - resource: vm-snapshot, action: read
|
|
68
|
+
*
|
|
57
69
|
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
58
70
|
*/
|
|
59
71
|
getVmSnapshot(id) {
|
|
60
72
|
return this.getObject(id);
|
|
61
73
|
}
|
|
62
74
|
/**
|
|
75
|
+
* Required privilege:
|
|
76
|
+
* - resource: vm-snapshot, action: delete
|
|
77
|
+
*
|
|
63
78
|
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
64
79
|
*/
|
|
65
80
|
async deleteVmSnapshot(id) {
|
|
@@ -67,50 +82,80 @@ let VmSnapshotController = class VmSnapshotController extends XapiXoController {
|
|
|
67
82
|
await xapiVmSnapshot.$xapi.VM_destroy(xapiVmSnapshot.$ref);
|
|
68
83
|
}
|
|
69
84
|
/**
|
|
85
|
+
* Returns all alarms that match the following privilege:
|
|
86
|
+
* - resource: alarm, action: read
|
|
87
|
+
*
|
|
70
88
|
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
71
89
|
* @example fields "id,time"
|
|
72
90
|
* @example filter "time:>1747053793"
|
|
73
91
|
* @example limit 42
|
|
74
92
|
*/
|
|
75
|
-
getVmSnapshotAlarms(req, id, fields, ndjson, filter, limit) {
|
|
93
|
+
getVmSnapshotAlarms(req, id, fields, ndjson, markdown, filter, limit) {
|
|
76
94
|
const vmSnapshot = this.getObject(id);
|
|
77
95
|
const alarms = this.#alarmService.getAlarms({
|
|
78
96
|
filter: `${escapeUnsafeComplexMatcher(filter) ?? ''} object:uuid:${vmSnapshot.uuid}`,
|
|
97
|
+
});
|
|
98
|
+
return this.sendObjects(Object.values(alarms), req, {
|
|
99
|
+
path: 'alarms',
|
|
79
100
|
limit,
|
|
101
|
+
privilege: { action: 'read', resource: 'alarm' },
|
|
80
102
|
});
|
|
81
|
-
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
82
103
|
}
|
|
83
104
|
/**
|
|
105
|
+
* Returns all VDIs that match the following privilege:
|
|
106
|
+
* - resource: vdi, action: read
|
|
107
|
+
*
|
|
84
108
|
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
85
109
|
* @example fields "VDI_type,id,name_label"
|
|
86
110
|
* @example filter "VDI_type:user"
|
|
87
111
|
* @example limit 42
|
|
88
112
|
*/
|
|
89
|
-
getVmSnapshotVdis(req, id, fields, ndjson, filter, limit) {
|
|
113
|
+
getVmSnapshotVdis(req, id, fields, ndjson, markdown, filter, limit) {
|
|
90
114
|
const vdis = this.#vmService.getVmVdis(id, 'VM-snapshot');
|
|
91
|
-
return this.sendObjects(limitAndFilterArray(vdis, { filter
|
|
115
|
+
return this.sendObjects(limitAndFilterArray(vdis, { filter }), req, {
|
|
116
|
+
path: obj => obj.type.toLowerCase() + 's',
|
|
117
|
+
limit,
|
|
118
|
+
privilege: { action: 'read', resource: 'vdi' },
|
|
119
|
+
});
|
|
92
120
|
}
|
|
93
121
|
/**
|
|
122
|
+
* Returns all messages that match the following privilege:
|
|
123
|
+
* - resource: message, action: read
|
|
124
|
+
*
|
|
94
125
|
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
95
126
|
* @example fields "name,id,$object"
|
|
96
127
|
* @example filter "name:VM_STARTED"
|
|
97
128
|
* @example limit 42
|
|
98
129
|
*/
|
|
99
|
-
getVmSnapshotsMessages(req, id, fields, ndjson, filter, limit) {
|
|
100
|
-
const messages = this.getMessagesForObject(id, { filter
|
|
101
|
-
return this.sendObjects(Object.values(messages), req,
|
|
130
|
+
getVmSnapshotsMessages(req, id, fields, ndjson, markdown, filter, limit) {
|
|
131
|
+
const messages = this.getMessagesForObject(id, { filter });
|
|
132
|
+
return this.sendObjects(Object.values(messages), req, {
|
|
133
|
+
path: 'messages',
|
|
134
|
+
limit,
|
|
135
|
+
privilege: { action: 'read', resource: 'message' },
|
|
136
|
+
});
|
|
102
137
|
}
|
|
103
138
|
/**
|
|
139
|
+
* Returns all tasks that match the following privilege:
|
|
140
|
+
* - resource: task, action: read
|
|
141
|
+
*
|
|
104
142
|
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
105
143
|
* @example fields "id,status,properties"
|
|
106
144
|
* @example filter "status:failure"
|
|
107
145
|
* @example limit 42
|
|
108
146
|
*/
|
|
109
|
-
async getVmSnapshotTasks(req, id, fields, ndjson, filter, limit) {
|
|
110
|
-
const tasks = await this.getTasksForObject(id, { filter
|
|
111
|
-
return this.sendObjects(Object.values(tasks), req,
|
|
147
|
+
async getVmSnapshotTasks(req, id, fields, ndjson, markdown, filter, limit) {
|
|
148
|
+
const tasks = await this.getTasksForObject(id, { filter });
|
|
149
|
+
return this.sendObjects(Object.values(tasks), req, {
|
|
150
|
+
path: 'tasks',
|
|
151
|
+
limit,
|
|
152
|
+
privilege: { action: 'read', resource: 'task' },
|
|
153
|
+
});
|
|
112
154
|
}
|
|
113
155
|
/**
|
|
156
|
+
* Required privilege:
|
|
157
|
+
* - resource: vm-snapshot, action: update:tags
|
|
158
|
+
*
|
|
114
159
|
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
115
160
|
* @example tag "from-rest-api"
|
|
116
161
|
*/
|
|
@@ -119,6 +164,9 @@ let VmSnapshotController = class VmSnapshotController extends XapiXoController {
|
|
|
119
164
|
await vmSnapshot.$call('add_tags', tag);
|
|
120
165
|
}
|
|
121
166
|
/**
|
|
167
|
+
* Required privilege:
|
|
168
|
+
* - resource: vm-snapshot, action: update:tags
|
|
169
|
+
*
|
|
122
170
|
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
123
171
|
* @example tag "from-rest-api"
|
|
124
172
|
*/
|
|
@@ -131,15 +179,19 @@ __decorate([
|
|
|
131
179
|
Example(vmSnapshotIds),
|
|
132
180
|
Example(partialVmSnapshots),
|
|
133
181
|
Get(''),
|
|
182
|
+
Security('*', ['acl']),
|
|
134
183
|
__param(0, Request()),
|
|
135
184
|
__param(1, Query()),
|
|
136
185
|
__param(2, Query()),
|
|
137
186
|
__param(3, Query()),
|
|
138
|
-
__param(4, Query())
|
|
187
|
+
__param(4, Query()),
|
|
188
|
+
__param(5, Query())
|
|
139
189
|
], VmSnapshotController.prototype, "getVmSnapshots", null);
|
|
140
190
|
__decorate([
|
|
141
191
|
Get('{id}.{format}'),
|
|
192
|
+
Middlewares(acl({ resource: 'vm-snapshot', action: 'export', objectId: 'params.id' })),
|
|
142
193
|
SuccessResponse(200, 'Download started', 'application/octet-stream'),
|
|
194
|
+
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
143
195
|
Response(notFoundResp.status, notFoundResp.description),
|
|
144
196
|
Response(422, 'Invalid format, Invalid compress'),
|
|
145
197
|
__param(0, Request()),
|
|
@@ -150,11 +202,14 @@ __decorate([
|
|
|
150
202
|
__decorate([
|
|
151
203
|
Example(vmSnapshot),
|
|
152
204
|
Get('{id}'),
|
|
205
|
+
Middlewares(acl({ resource: 'vm-snapshot', action: 'read', objectId: 'params.id' })),
|
|
206
|
+
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
153
207
|
Response(notFoundResp.status, notFoundResp.description),
|
|
154
208
|
__param(0, Path())
|
|
155
209
|
], VmSnapshotController.prototype, "getVmSnapshot", null);
|
|
156
210
|
__decorate([
|
|
157
211
|
Delete('{id}'),
|
|
212
|
+
Middlewares(acl({ resource: 'vm-snapshot', action: 'delete', objectId: 'params.id' })),
|
|
158
213
|
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
159
214
|
Response(notFoundResp.status, notFoundResp.description),
|
|
160
215
|
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
@@ -164,6 +219,7 @@ __decorate([
|
|
|
164
219
|
__decorate([
|
|
165
220
|
Example(genericAlarmsExample),
|
|
166
221
|
Get('{id}/alarms'),
|
|
222
|
+
Security('*', ['acl']),
|
|
167
223
|
Tags('alarms'),
|
|
168
224
|
Response(notFoundResp.status, notFoundResp.description),
|
|
169
225
|
__param(0, Request()),
|
|
@@ -171,11 +227,13 @@ __decorate([
|
|
|
171
227
|
__param(2, Query()),
|
|
172
228
|
__param(3, Query()),
|
|
173
229
|
__param(4, Query()),
|
|
174
|
-
__param(5, Query())
|
|
230
|
+
__param(5, Query()),
|
|
231
|
+
__param(6, Query())
|
|
175
232
|
], VmSnapshotController.prototype, "getVmSnapshotAlarms", null);
|
|
176
233
|
__decorate([
|
|
177
234
|
Example(vmSnapshotVdis),
|
|
178
235
|
Get('{id}/vdis'),
|
|
236
|
+
Security('*', ['acl']),
|
|
179
237
|
Tags('vdis'),
|
|
180
238
|
Response(notFoundResp.status, notFoundResp.description),
|
|
181
239
|
__param(0, Request()),
|
|
@@ -183,12 +241,14 @@ __decorate([
|
|
|
183
241
|
__param(2, Query()),
|
|
184
242
|
__param(3, Query()),
|
|
185
243
|
__param(4, Query()),
|
|
186
|
-
__param(5, Query())
|
|
244
|
+
__param(5, Query()),
|
|
245
|
+
__param(6, Query())
|
|
187
246
|
], VmSnapshotController.prototype, "getVmSnapshotVdis", null);
|
|
188
247
|
__decorate([
|
|
189
248
|
Example(messageIds),
|
|
190
249
|
Example(partialMessages),
|
|
191
250
|
Get('{id}/messages'),
|
|
251
|
+
Security('*', ['acl']),
|
|
192
252
|
Tags('messages'),
|
|
193
253
|
Response(notFoundResp.status, notFoundResp.description),
|
|
194
254
|
__param(0, Request()),
|
|
@@ -196,12 +256,14 @@ __decorate([
|
|
|
196
256
|
__param(2, Query()),
|
|
197
257
|
__param(3, Query()),
|
|
198
258
|
__param(4, Query()),
|
|
199
|
-
__param(5, Query())
|
|
259
|
+
__param(5, Query()),
|
|
260
|
+
__param(6, Query())
|
|
200
261
|
], VmSnapshotController.prototype, "getVmSnapshotsMessages", null);
|
|
201
262
|
__decorate([
|
|
202
263
|
Example(taskIds),
|
|
203
264
|
Example(partialTasks),
|
|
204
265
|
Get('{id}/tasks'),
|
|
266
|
+
Security('*', ['acl']),
|
|
205
267
|
Tags('tasks'),
|
|
206
268
|
Response(notFoundResp.status, notFoundResp.description),
|
|
207
269
|
__param(0, Request()),
|
|
@@ -209,18 +271,23 @@ __decorate([
|
|
|
209
271
|
__param(2, Query()),
|
|
210
272
|
__param(3, Query()),
|
|
211
273
|
__param(4, Query()),
|
|
212
|
-
__param(5, Query())
|
|
274
|
+
__param(5, Query()),
|
|
275
|
+
__param(6, Query())
|
|
213
276
|
], VmSnapshotController.prototype, "getVmSnapshotTasks", null);
|
|
214
277
|
__decorate([
|
|
215
278
|
Put('{id}/tags/{tag}'),
|
|
279
|
+
Middlewares(acl({ resource: 'vm-snapshot', action: 'update:tags', objectId: 'params.id' })),
|
|
216
280
|
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
281
|
+
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
217
282
|
Response(notFoundResp.status, notFoundResp.description),
|
|
218
283
|
__param(0, Path()),
|
|
219
284
|
__param(1, Path())
|
|
220
285
|
], VmSnapshotController.prototype, "putVmSnapshotTag", null);
|
|
221
286
|
__decorate([
|
|
222
287
|
Delete('{id}/tags/{tag}'),
|
|
288
|
+
Middlewares(acl({ resource: 'vm-snapshot', action: 'update:tags', objectId: 'params.id' })),
|
|
223
289
|
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
290
|
+
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
224
291
|
Response(notFoundResp.status, notFoundResp.description),
|
|
225
292
|
__param(0, Path()),
|
|
226
293
|
__param(1, Path())
|
|
@@ -7,7 +7,7 @@ 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 { Example, Get, Security, Query, Request, Response, Route, Tags, Path, Delete, SuccessResponse, Put } from 'tsoa';
|
|
10
|
+
import { Example, Get, Security, Query, Request, Response, Route, Tags, Path, Delete, SuccessResponse, Put, Middlewares, } from 'tsoa';
|
|
11
11
|
import { inject } from 'inversify';
|
|
12
12
|
import { provide } from 'inversify-binding-decorators';
|
|
13
13
|
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
@@ -16,6 +16,7 @@ import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.m
|
|
|
16
16
|
import { badRequestResp, forbiddenOperationResp, incorrectStateResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
17
17
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
18
18
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
19
|
+
import { acl } from '../middlewares/acl.middleware.mjs';
|
|
19
20
|
import { partialVmTemplates, vmTemplate, vmTemplateIds, vmTemplateVdis, } from '../open-api/oa-examples/vm-template.oa-example.mjs';
|
|
20
21
|
import { VmService } from '../vms/vm.service.mjs';
|
|
21
22
|
import { messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs';
|
|
@@ -29,17 +30,26 @@ let VmTemplateController = class VmTemplateController extends XapiXoController {
|
|
|
29
30
|
this.#vmService = vmService;
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
33
|
+
* Returns all VM templates that match the following privilege:
|
|
34
|
+
* - resource: vm-template, action: read
|
|
35
|
+
*
|
|
32
36
|
* @example fields "id,isDefaultTemplate,name_label"
|
|
33
37
|
* @example filter "isDefaultTemplate?"
|
|
34
38
|
* @example limit 42
|
|
35
39
|
* */
|
|
36
|
-
getVmTemplates(req, fields, ndjson, filter, limit) {
|
|
37
|
-
return this.sendObjects(Object.values(this.getObjects({ filter
|
|
40
|
+
getVmTemplates(req, fields, ndjson, markdown, filter, limit) {
|
|
41
|
+
return this.sendObjects(Object.values(this.getObjects({ filter })), req, {
|
|
42
|
+
limit,
|
|
43
|
+
privilege: { action: 'read', resource: 'vm-template' },
|
|
44
|
+
});
|
|
38
45
|
}
|
|
39
46
|
/**
|
|
40
47
|
*
|
|
41
48
|
* Export VM-template. Compress is only used for XVA format
|
|
42
49
|
*
|
|
50
|
+
* Required privilege:
|
|
51
|
+
* - resource: vm-template, action: export
|
|
52
|
+
*
|
|
43
53
|
* @example id "b7569d99-30f8-178a-7d94-801de3e29b5b-f873abe0-b138-4995-8f6f-498b423d234d"
|
|
44
54
|
*/
|
|
45
55
|
async exportVmTemplate(req, id, format, compress) {
|
|
@@ -53,12 +63,18 @@ let VmTemplateController = class VmTemplateController extends XapiXoController {
|
|
|
53
63
|
return stream;
|
|
54
64
|
}
|
|
55
65
|
/**
|
|
66
|
+
* Required privilege:
|
|
67
|
+
* - resource: vm-template, action: read
|
|
68
|
+
*
|
|
56
69
|
* @example id "b7569d99-30f8-178a-7d94-801de3e29b5b-f873abe0-b138-4995-8f6f-498b423d234d"
|
|
57
70
|
* */
|
|
58
71
|
getVmTemplate(id) {
|
|
59
72
|
return this.getObject(id);
|
|
60
73
|
}
|
|
61
74
|
/**
|
|
75
|
+
* Required privilege:
|
|
76
|
+
* - resource: vm-template, action: delete
|
|
77
|
+
*
|
|
62
78
|
* @example id "6d50ba76-0f11-1ff1-4f6a-b502afc31b8e"
|
|
63
79
|
*/
|
|
64
80
|
async deleteVmTemplate(id) {
|
|
@@ -66,50 +82,80 @@ let VmTemplateController = class VmTemplateController extends XapiXoController {
|
|
|
66
82
|
await xapiVmTemplate.$xapi.VM_destroy(xapiVmTemplate.$ref);
|
|
67
83
|
}
|
|
68
84
|
/**
|
|
85
|
+
* Returns all alarms that match the following privilege:
|
|
86
|
+
* - resource: alarm, action: read
|
|
87
|
+
*
|
|
69
88
|
* @example id "b7569d99-30f8-178a-7d94-801de3e29b5b-f873abe0-b138-4995-8f6f-498b423d234d"
|
|
70
89
|
* @example fields "id,time"
|
|
71
90
|
* @example filter "time:>1747053793"
|
|
72
91
|
* @example limit 42
|
|
73
92
|
*/
|
|
74
|
-
getVmTemplateAlarms(req, id, fields, ndjson, filter, limit) {
|
|
93
|
+
getVmTemplateAlarms(req, id, fields, ndjson, markdown, filter, limit) {
|
|
75
94
|
const vmTemplate = this.getObject(id);
|
|
76
95
|
const alarms = this.#alarmService.getAlarms({
|
|
77
96
|
filter: `${escapeUnsafeComplexMatcher(filter) ?? ''} object:uuid:${vmTemplate.uuid}`,
|
|
97
|
+
});
|
|
98
|
+
return this.sendObjects(Object.values(alarms), req, {
|
|
99
|
+
path: 'alarms',
|
|
78
100
|
limit,
|
|
101
|
+
privilege: { action: 'read', resource: 'alarm' },
|
|
79
102
|
});
|
|
80
|
-
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
81
103
|
}
|
|
82
104
|
/**
|
|
105
|
+
* Returns all VDIs that match the following privilege:
|
|
106
|
+
* - resource: vdi, action: read
|
|
107
|
+
*
|
|
83
108
|
* @example id "6d50ba76-0f11-1ff1-4f6a-b502afc31b8e"
|
|
84
109
|
* @example fields "VDI_type,id,name_label"
|
|
85
110
|
* @example filter "VDI_type:user"
|
|
86
111
|
* @example limit 42
|
|
87
112
|
*/
|
|
88
|
-
getVmTemplateVdis(req, id, fields, ndjson, filter, limit) {
|
|
113
|
+
getVmTemplateVdis(req, id, fields, ndjson, markdown, filter, limit) {
|
|
89
114
|
const vdis = this.#vmService.getVmVdis(id, 'VM-template');
|
|
90
|
-
return this.sendObjects(limitAndFilterArray(vdis, { filter
|
|
115
|
+
return this.sendObjects(limitAndFilterArray(vdis, { filter }), req, {
|
|
116
|
+
path: obj => obj.type.toLowerCase() + 's',
|
|
117
|
+
limit,
|
|
118
|
+
privilege: { action: 'read', resource: 'vdi' },
|
|
119
|
+
});
|
|
91
120
|
}
|
|
92
121
|
/**
|
|
122
|
+
* Returns all messages that match the following privilege:
|
|
123
|
+
* - resource: message, action: read
|
|
124
|
+
*
|
|
93
125
|
* @example id "6d50ba76-0f11-1ff1-4f6a-b502afc31b8e"
|
|
94
126
|
* @example fields "name,id,$object"
|
|
95
127
|
* @example filter "name:VM_STARTED"
|
|
96
128
|
* @example limit 42
|
|
97
129
|
*/
|
|
98
|
-
getVmTemplateMessages(req, id, fields, ndjson, filter, limit) {
|
|
99
|
-
const messages = this.getMessagesForObject(id, { filter
|
|
100
|
-
return this.sendObjects(Object.values(messages), req,
|
|
130
|
+
getVmTemplateMessages(req, id, fields, ndjson, markdown, filter, limit) {
|
|
131
|
+
const messages = this.getMessagesForObject(id, { filter });
|
|
132
|
+
return this.sendObjects(Object.values(messages), req, {
|
|
133
|
+
path: 'messages',
|
|
134
|
+
limit,
|
|
135
|
+
privilege: { action: 'read', resource: 'message' },
|
|
136
|
+
});
|
|
101
137
|
}
|
|
102
138
|
/**
|
|
139
|
+
* Returns all tasks that match the following privilege:
|
|
140
|
+
* - resource: task, action: read
|
|
141
|
+
*
|
|
103
142
|
* @example id "613f541c-4bed-fc77-7ca8-2db6b68f079c"
|
|
104
143
|
* @example fields "id,status,properties"
|
|
105
144
|
* @example filter "status:failure"
|
|
106
145
|
* @example limit 42
|
|
107
146
|
*/
|
|
108
|
-
async getVmTemplateTasks(req, id, fields, ndjson, filter, limit) {
|
|
109
|
-
const tasks = await this.getTasksForObject(id, { filter
|
|
110
|
-
return this.sendObjects(Object.values(tasks), req,
|
|
147
|
+
async getVmTemplateTasks(req, id, fields, ndjson, markdown, filter, limit) {
|
|
148
|
+
const tasks = await this.getTasksForObject(id, { filter });
|
|
149
|
+
return this.sendObjects(Object.values(tasks), req, {
|
|
150
|
+
path: 'tasks',
|
|
151
|
+
limit,
|
|
152
|
+
privilege: { action: 'read', resource: 'task' },
|
|
153
|
+
});
|
|
111
154
|
}
|
|
112
155
|
/**
|
|
156
|
+
* Required privilege:
|
|
157
|
+
* - resource: vm-template, action: update:tags
|
|
158
|
+
*
|
|
113
159
|
* @example id "613f541c-4bed-fc77-7ca8-2db6b68f079c"
|
|
114
160
|
* @example tag "from-rest-api"
|
|
115
161
|
*/
|
|
@@ -118,6 +164,9 @@ let VmTemplateController = class VmTemplateController extends XapiXoController {
|
|
|
118
164
|
await vmTemplate.$call('add_tags', tag);
|
|
119
165
|
}
|
|
120
166
|
/**
|
|
167
|
+
* Required privilege:
|
|
168
|
+
* - resource: vm-template, action: update:tags
|
|
169
|
+
*
|
|
121
170
|
* @example id "613f541c-4bed-fc77-7ca8-2db6b68f079c"
|
|
122
171
|
* @example tag "from-rest-api"
|
|
123
172
|
*/
|
|
@@ -130,15 +179,19 @@ __decorate([
|
|
|
130
179
|
Example(vmTemplateIds),
|
|
131
180
|
Example(partialVmTemplates),
|
|
132
181
|
Get(''),
|
|
182
|
+
Security('*', ['acl']),
|
|
133
183
|
__param(0, Request()),
|
|
134
184
|
__param(1, Query()),
|
|
135
185
|
__param(2, Query()),
|
|
136
186
|
__param(3, Query()),
|
|
137
|
-
__param(4, Query())
|
|
187
|
+
__param(4, Query()),
|
|
188
|
+
__param(5, Query())
|
|
138
189
|
], VmTemplateController.prototype, "getVmTemplates", null);
|
|
139
190
|
__decorate([
|
|
140
191
|
Get('{id}.{format}'),
|
|
192
|
+
Middlewares(acl({ resource: 'vm-template', action: 'export', objectId: 'params.id' })),
|
|
141
193
|
SuccessResponse(200, 'Download started', 'application/octet-stream'),
|
|
194
|
+
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
142
195
|
Response(notFoundResp.status, notFoundResp.description),
|
|
143
196
|
Response(422, 'Invalid format, Invalid compress'),
|
|
144
197
|
__param(0, Request()),
|
|
@@ -149,11 +202,14 @@ __decorate([
|
|
|
149
202
|
__decorate([
|
|
150
203
|
Example(vmTemplate),
|
|
151
204
|
Get('{id}'),
|
|
205
|
+
Middlewares(acl({ resource: 'vm-template', action: 'read', objectId: 'params.id' })),
|
|
206
|
+
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
152
207
|
Response(notFoundResp.status, notFoundResp.description),
|
|
153
208
|
__param(0, Path())
|
|
154
209
|
], VmTemplateController.prototype, "getVmTemplate", null);
|
|
155
210
|
__decorate([
|
|
156
211
|
Delete('{id}'),
|
|
212
|
+
Middlewares(acl({ resource: 'vm-template', action: 'delete', objectId: 'params.id' })),
|
|
157
213
|
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
158
214
|
Response(notFoundResp.status, notFoundResp.description),
|
|
159
215
|
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
@@ -163,6 +219,7 @@ __decorate([
|
|
|
163
219
|
__decorate([
|
|
164
220
|
Example(genericAlarmsExample),
|
|
165
221
|
Get('{id}/alarms'),
|
|
222
|
+
Security('*', ['acl']),
|
|
166
223
|
Tags('alarms'),
|
|
167
224
|
Response(notFoundResp.status, notFoundResp.description),
|
|
168
225
|
__param(0, Request()),
|
|
@@ -170,11 +227,13 @@ __decorate([
|
|
|
170
227
|
__param(2, Query()),
|
|
171
228
|
__param(3, Query()),
|
|
172
229
|
__param(4, Query()),
|
|
173
|
-
__param(5, Query())
|
|
230
|
+
__param(5, Query()),
|
|
231
|
+
__param(6, Query())
|
|
174
232
|
], VmTemplateController.prototype, "getVmTemplateAlarms", null);
|
|
175
233
|
__decorate([
|
|
176
234
|
Example(vmTemplateVdis),
|
|
177
235
|
Get('{id}/vdis'),
|
|
236
|
+
Security('*', ['acl']),
|
|
178
237
|
Tags('vdis'),
|
|
179
238
|
Response(notFoundResp.status, notFoundResp.description),
|
|
180
239
|
__param(0, Request()),
|
|
@@ -182,12 +241,14 @@ __decorate([
|
|
|
182
241
|
__param(2, Query()),
|
|
183
242
|
__param(3, Query()),
|
|
184
243
|
__param(4, Query()),
|
|
185
|
-
__param(5, Query())
|
|
244
|
+
__param(5, Query()),
|
|
245
|
+
__param(6, Query())
|
|
186
246
|
], VmTemplateController.prototype, "getVmTemplateVdis", null);
|
|
187
247
|
__decorate([
|
|
188
248
|
Example(messageIds),
|
|
189
249
|
Example(partialMessages),
|
|
190
250
|
Get('{id}/messages'),
|
|
251
|
+
Security('*', ['acl']),
|
|
191
252
|
Tags('messages'),
|
|
192
253
|
Response(notFoundResp.status, notFoundResp.description),
|
|
193
254
|
__param(0, Request()),
|
|
@@ -195,12 +256,14 @@ __decorate([
|
|
|
195
256
|
__param(2, Query()),
|
|
196
257
|
__param(3, Query()),
|
|
197
258
|
__param(4, Query()),
|
|
198
|
-
__param(5, Query())
|
|
259
|
+
__param(5, Query()),
|
|
260
|
+
__param(6, Query())
|
|
199
261
|
], VmTemplateController.prototype, "getVmTemplateMessages", null);
|
|
200
262
|
__decorate([
|
|
201
263
|
Example(taskIds),
|
|
202
264
|
Example(partialTasks),
|
|
203
265
|
Get('{id}/tasks'),
|
|
266
|
+
Security('*', ['acl']),
|
|
204
267
|
Tags('tasks'),
|
|
205
268
|
Response(notFoundResp.status, notFoundResp.description),
|
|
206
269
|
__param(0, Request()),
|
|
@@ -208,18 +271,23 @@ __decorate([
|
|
|
208
271
|
__param(2, Query()),
|
|
209
272
|
__param(3, Query()),
|
|
210
273
|
__param(4, Query()),
|
|
211
|
-
__param(5, Query())
|
|
274
|
+
__param(5, Query()),
|
|
275
|
+
__param(6, Query())
|
|
212
276
|
], VmTemplateController.prototype, "getVmTemplateTasks", null);
|
|
213
277
|
__decorate([
|
|
214
278
|
Put('{id}/tags/{tag}'),
|
|
279
|
+
Middlewares(acl({ resource: 'vm-template', action: 'update:tags', objectId: 'params.id' })),
|
|
215
280
|
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
281
|
+
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
216
282
|
Response(notFoundResp.status, notFoundResp.description),
|
|
217
283
|
__param(0, Path()),
|
|
218
284
|
__param(1, Path())
|
|
219
285
|
], VmTemplateController.prototype, "putVmTemplateTag", null);
|
|
220
286
|
__decorate([
|
|
221
287
|
Delete('{id}/tags/{tag}'),
|
|
288
|
+
Middlewares(acl({ resource: 'vm-template', action: 'update:tags', objectId: 'params.id' })),
|
|
222
289
|
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
290
|
+
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
223
291
|
Response(notFoundResp.status, notFoundResp.description),
|
|
224
292
|
__param(0, Path()),
|
|
225
293
|
__param(1, Path())
|