@xen-orchestra/rest-api 0.18.0 → 0.20.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/abstract-classes/base-controller.mjs +20 -0
- package/dist/abstract-classes/xo-controller.mjs +1 -1
- package/dist/alarms/alarm.controller.mjs +2 -1
- package/dist/backup-archives/backup-archive.controller.mjs +96 -0
- package/dist/backup-jobs/backup-job.controller.mjs +3 -1
- package/dist/backup-logs/backup-log.controller.mjs +2 -1
- package/dist/backup-repositories/backup-repositories.controller.mjs +2 -1
- package/dist/groups/group.controller.mjs +26 -1
- package/dist/hosts/host.controller.mjs +57 -2
- package/dist/index.mjs +3 -2
- package/dist/ioc/ioc.mjs +0 -5
- package/dist/messages/message.controller.mjs +2 -1
- package/dist/middlewares/authentication.middleware.mjs +47 -20
- package/dist/networks/network.controller.mjs +81 -2
- package/dist/open-api/oa-examples/backup-archive.oa-example.mjs +60 -0
- package/dist/open-api/oa-examples/gui-routes.oa-example.mjs +4 -0
- package/dist/open-api/oa-examples/pbd.oa-example.mjs +41 -0
- package/dist/open-api/oa-examples/ping.oa-example.mjs +4 -0
- package/dist/open-api/oa-examples/user.oa-example.mjs +12 -0
- package/dist/open-api/routes/routes.js +2050 -530
- package/dist/pbds/pbd.controller.mjs +60 -0
- package/dist/pcis/pci.controller.mjs +2 -1
- package/dist/pgpus/pgpu.controller.mjs +2 -1
- package/dist/pifs/pif.controller.mjs +50 -1
- package/dist/pools/pool.controller.mjs +56 -3
- package/dist/proxies/proxy.controller.mjs +2 -1
- package/dist/restore-logs/restore-log.controller.mjs +3 -1
- package/dist/schedules/schedule.controller.mjs +2 -1
- package/dist/servers/server.controller.mjs +26 -2
- package/dist/sms/sm.controller.mjs +2 -1
- package/dist/srs/sr.controller.mjs +57 -2
- package/dist/tasks/task.controller.mjs +2 -1
- package/dist/users/user.controller.mjs +80 -31
- package/dist/users/user.middleware.mjs +11 -0
- package/dist/vbds/vbd.controller.mjs +50 -1
- package/dist/vdi-snapshots/vdi-snapshot.controller.mjs +81 -2
- package/dist/vdis/vdi.controller.mjs +105 -2
- package/dist/vifs/vif.controller.mjs +50 -1
- package/dist/vm-controller/vm-controller.controller.mjs +81 -2
- package/dist/vm-snapshots/vm-snapshot.controller.mjs +57 -2
- package/dist/vm-templates/vm-template.controller.mjs +57 -2
- package/dist/vms/vm.controller.mjs +36 -13
- package/dist/xoa/xoa.controller.mjs +24 -2
- package/dist/xoa/xoa.service.mjs +17 -0
- package/open-api/spec/swagger.json +8223 -3060
- package/package.json +3 -3
- package/tsoa.json +19 -0
- package/dist/tasks/task.service.mjs +0 -24
|
@@ -7,18 +7,22 @@ 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, Patch, Path, Post, Query, Request, Response, Route, Security, SuccessResponse, Tags, } from 'tsoa';
|
|
10
|
+
import { Body, Delete, Deprecated, Example, Get, Middlewares, Patch, Path, Post, Query, Request, Response, Route, Security, SuccessResponse, Tags, } from 'tsoa';
|
|
11
|
+
import { createLogger } from '@xen-orchestra/log';
|
|
11
12
|
import { inject } from 'inversify';
|
|
12
13
|
import { json } from 'express';
|
|
13
14
|
import { provide } from 'inversify-binding-decorators';
|
|
14
|
-
import { createdResp, forbiddenOperationResp, invalidParameters, noContentResp, notFoundResp, resourceAlreadyExists, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
15
|
+
import { badRequestResp, createdResp, forbiddenOperationResp, internalServerErrorResp, invalidParameters, noContentResp, notFoundResp, resourceAlreadyExists, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
15
16
|
import { forbiddenOperation } from 'xo-common/api-errors.js';
|
|
16
|
-
import { partialUsers, user, authenticationTokens, userId, userIds } from '../open-api/oa-examples/user.oa-example.mjs';
|
|
17
|
+
import { partialUsers, user, authenticationTokens, userId, userIds, authenticationToken, } from '../open-api/oa-examples/user.oa-example.mjs';
|
|
17
18
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
18
19
|
import { limitAndFilterArray } from '../helpers/utils.helper.mjs';
|
|
19
20
|
import { UserService } from './user.service.mjs';
|
|
20
21
|
import { XoController } from '../abstract-classes/xo-controller.mjs';
|
|
21
22
|
import { groupIds, partialGroups } from '../open-api/oa-examples/group.oa-example.mjs';
|
|
23
|
+
import { partialTasks, taskIds } from '../open-api/oa-examples/task.oa-example.mjs';
|
|
24
|
+
import { redirectMeAlias } from './user.middleware.mjs';
|
|
25
|
+
const log = createLogger('xo:rest-api:user-controller');
|
|
22
26
|
let UserController = class UserController extends XoController {
|
|
23
27
|
#userService;
|
|
24
28
|
constructor(restApi, userService) {
|
|
@@ -32,12 +36,6 @@ let UserController = class UserController extends XoController {
|
|
|
32
36
|
async getCollectionObject(id) {
|
|
33
37
|
return this.#userService.getUser(id);
|
|
34
38
|
}
|
|
35
|
-
#redirectCurrentUser(req) {
|
|
36
|
-
const currentUser = this.restApi.getCurrentUser();
|
|
37
|
-
const originalUrl = req.originalUrl;
|
|
38
|
-
const res = req.res;
|
|
39
|
-
res.redirect(307, originalUrl.replace(/\/users\/me(?=\/|$)/, `/users/${currentUser.id}`));
|
|
40
|
-
}
|
|
41
39
|
/**
|
|
42
40
|
* @example fields "permission,name,id"
|
|
43
41
|
* @example filter "permission:none"
|
|
@@ -47,18 +45,6 @@ let UserController = class UserController extends XoController {
|
|
|
47
45
|
const users = Object.values(await this.getObjects({ filter, limit }));
|
|
48
46
|
return this.sendObjects(users, req);
|
|
49
47
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Redirect to `/users/:id`
|
|
52
|
-
*/
|
|
53
|
-
redirectMe(req) {
|
|
54
|
-
this.#redirectCurrentUser(req);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Redirect to `/users/:id/<rest-of-your-path>`
|
|
58
|
-
*/
|
|
59
|
-
redirectMeWithPath(req) {
|
|
60
|
-
this.#redirectCurrentUser(req);
|
|
61
|
-
}
|
|
62
48
|
/**
|
|
63
49
|
* @example id "722d17b9-699b-49d2-8193-be1ac573d3de"
|
|
64
50
|
*/
|
|
@@ -131,6 +117,45 @@ let UserController = class UserController extends XoController {
|
|
|
131
117
|
const tokens = await this.restApi.xoApp.getAuthenticationTokensForUser(user.id);
|
|
132
118
|
return limitAndFilterArray(tokens, { filter, limit });
|
|
133
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* @example id "722d17b9-699b-49d2-8193-be1ac573d3de"
|
|
122
|
+
* @example fields "id,status,properties"
|
|
123
|
+
* @example filter "status:failure"
|
|
124
|
+
* @example limit 42
|
|
125
|
+
*/
|
|
126
|
+
async getUserTasks(req, id, fields, ndjson, filter, limit) {
|
|
127
|
+
const tasks = await this.getTasksForObject(id, { filter, limit });
|
|
128
|
+
return this.sendObjects(Object.values(tasks), req, 'tasks');
|
|
129
|
+
}
|
|
130
|
+
// ----------- DEPRECATED TO BE REMOVED IN ONE YEAR (10-13-2026)--------------------
|
|
131
|
+
/**
|
|
132
|
+
* @example body {"client": {"id": "my-fav-client"}, "description": "token for CLI usage", "expiresIn": "1 hour"}
|
|
133
|
+
*/
|
|
134
|
+
async postDeprecatedAuthenticationTokens(body) {
|
|
135
|
+
log.warn('You are calling a deprecated route. It will be removed in the futur. Please use `/rest/v0/users/:id/authentication_tokens` or `/rest/v0/users/me/authentication_tokens` instead');
|
|
136
|
+
const user = this.restApi.getCurrentUser();
|
|
137
|
+
const token = await this.restApi.xoApp.createAuthenticationToken({
|
|
138
|
+
...body,
|
|
139
|
+
userId: user.id,
|
|
140
|
+
});
|
|
141
|
+
return { token };
|
|
142
|
+
}
|
|
143
|
+
// ----------- DEPRECATED TO BE REMOVED IN ONE YEAR (10-13-2026)--------------------
|
|
144
|
+
/**
|
|
145
|
+
* @example id "me"
|
|
146
|
+
* @example body {"client": {"id": "my-fav-client"}, "description": "token for CLI usage", "expiresIn": "1 hour"}
|
|
147
|
+
*/
|
|
148
|
+
async postAuthenticationTokens(body, id) {
|
|
149
|
+
const user = this.restApi.getCurrentUser();
|
|
150
|
+
if (user.id !== id) {
|
|
151
|
+
throw forbiddenOperation('create authentication token', 'you can only create token for yourself');
|
|
152
|
+
}
|
|
153
|
+
const token = await this.restApi.xoApp.createAuthenticationToken({
|
|
154
|
+
...body,
|
|
155
|
+
userId: user.id,
|
|
156
|
+
});
|
|
157
|
+
return { token };
|
|
158
|
+
}
|
|
134
159
|
};
|
|
135
160
|
__decorate([
|
|
136
161
|
Example(userIds),
|
|
@@ -142,16 +167,6 @@ __decorate([
|
|
|
142
167
|
__param(3, Query()),
|
|
143
168
|
__param(4, Query())
|
|
144
169
|
], UserController.prototype, "getUsers", null);
|
|
145
|
-
__decorate([
|
|
146
|
-
SuccessResponse(307, 'Temporary redirect'),
|
|
147
|
-
Get('me'),
|
|
148
|
-
__param(0, Request())
|
|
149
|
-
], UserController.prototype, "redirectMe", null);
|
|
150
|
-
__decorate([
|
|
151
|
-
SuccessResponse(307, 'Temporary redirect'),
|
|
152
|
-
Get('me/*'),
|
|
153
|
-
__param(0, Request())
|
|
154
|
-
], UserController.prototype, "redirectMeWithPath", null);
|
|
155
170
|
__decorate([
|
|
156
171
|
Example(user),
|
|
157
172
|
Get('{id}'),
|
|
@@ -206,9 +221,43 @@ __decorate([
|
|
|
206
221
|
__param(2, Query()),
|
|
207
222
|
__param(3, Query())
|
|
208
223
|
], UserController.prototype, "getAuthenticationTokens", null);
|
|
224
|
+
__decorate([
|
|
225
|
+
Example(taskIds),
|
|
226
|
+
Example(partialTasks),
|
|
227
|
+
Get('{id}/tasks'),
|
|
228
|
+
Tags('tasks'),
|
|
229
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
230
|
+
__param(0, Request()),
|
|
231
|
+
__param(1, Path()),
|
|
232
|
+
__param(2, Query()),
|
|
233
|
+
__param(3, Query()),
|
|
234
|
+
__param(4, Query()),
|
|
235
|
+
__param(5, Query())
|
|
236
|
+
], UserController.prototype, "getUserTasks", null);
|
|
237
|
+
__decorate([
|
|
238
|
+
Example(authenticationToken),
|
|
239
|
+
Deprecated(),
|
|
240
|
+
Post('authentication_tokens'),
|
|
241
|
+
Middlewares(json()),
|
|
242
|
+
SuccessResponse(createdResp.status, createdResp.description),
|
|
243
|
+
Response(internalServerErrorResp.status, internalServerErrorResp.description),
|
|
244
|
+
__param(0, Body())
|
|
245
|
+
], UserController.prototype, "postDeprecatedAuthenticationTokens", null);
|
|
246
|
+
__decorate([
|
|
247
|
+
Example(authenticationToken),
|
|
248
|
+
Post('{id}/authentication_tokens'),
|
|
249
|
+
Middlewares(json()),
|
|
250
|
+
SuccessResponse(createdResp.status, createdResp.description),
|
|
251
|
+
Response(forbiddenOperationResp.status, forbiddenOperationResp.description),
|
|
252
|
+
Response(internalServerErrorResp.status, internalServerErrorResp.description),
|
|
253
|
+
__param(0, Body()),
|
|
254
|
+
__param(1, Path())
|
|
255
|
+
], UserController.prototype, "postAuthenticationTokens", null);
|
|
209
256
|
UserController = __decorate([
|
|
210
257
|
Route('users'),
|
|
211
258
|
Security('*'),
|
|
259
|
+
Middlewares(redirectMeAlias),
|
|
260
|
+
Response(badRequestResp.status, badRequestResp.description),
|
|
212
261
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
213
262
|
Tags('users'),
|
|
214
263
|
provide(UserController),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function redirectMeAlias(req, res, next) {
|
|
2
|
+
const meAliasRegex = /\/users\/me(?=\/|$)/;
|
|
3
|
+
const originalUrl = req.originalUrl;
|
|
4
|
+
const currentUser = req.user;
|
|
5
|
+
const matchMeAlias = originalUrl.match(meAliasRegex);
|
|
6
|
+
if (currentUser !== undefined && matchMeAlias) {
|
|
7
|
+
res.redirect(307, originalUrl.replace(meAliasRegex, `/users/${currentUser.id}`));
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
next();
|
|
11
|
+
}
|
|
@@ -13,10 +13,12 @@ import { provide } from 'inversify-binding-decorators';
|
|
|
13
13
|
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
14
14
|
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
15
15
|
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
16
|
-
import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
16
|
+
import { badRequestResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
17
17
|
import { partialVbds, vbd, vbdIds } from '../open-api/oa-examples/vbd.oa-example.mjs';
|
|
18
18
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
19
19
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
20
|
+
import { messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs';
|
|
21
|
+
import { taskIds, partialTasks } from '../open-api/oa-examples/task.oa-example.mjs';
|
|
20
22
|
let VbdController = class VbdController extends XapiXoController {
|
|
21
23
|
#alarmService;
|
|
22
24
|
constructor(restApi, alarmService) {
|
|
@@ -53,6 +55,26 @@ let VbdController = class VbdController extends XapiXoController {
|
|
|
53
55
|
});
|
|
54
56
|
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
55
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @example id "f07ab729-c0e8-721c-45ec-f11276377030"
|
|
60
|
+
* @example fields "name,id,$object"
|
|
61
|
+
* @example filter "name:VM_STARTED"
|
|
62
|
+
* @example limit 42
|
|
63
|
+
*/
|
|
64
|
+
getVbdMessages(req, id, fields, ndjson, filter, limit) {
|
|
65
|
+
const messages = this.getMessagesForObject(id, { filter, limit });
|
|
66
|
+
return this.sendObjects(Object.values(messages), req, 'messages');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @example id "f07ab729-c0e8-721c-45ec-f11276377030"
|
|
70
|
+
* @example fields "id,status,properties"
|
|
71
|
+
* @example filter "status:failure"
|
|
72
|
+
* @example limit 42
|
|
73
|
+
*/
|
|
74
|
+
async getVbdTasks(req, id, fields, ndjson, filter, limit) {
|
|
75
|
+
const tasks = await this.getTasksForObject(id, { filter, limit });
|
|
76
|
+
return this.sendObjects(Object.values(tasks), req, 'tasks');
|
|
77
|
+
}
|
|
56
78
|
};
|
|
57
79
|
__decorate([
|
|
58
80
|
Example(vbdIds),
|
|
@@ -82,9 +104,36 @@ __decorate([
|
|
|
82
104
|
__param(4, Query()),
|
|
83
105
|
__param(5, Query())
|
|
84
106
|
], VbdController.prototype, "getVbdAlarms", null);
|
|
107
|
+
__decorate([
|
|
108
|
+
Example(messageIds),
|
|
109
|
+
Example(partialMessages),
|
|
110
|
+
Get('{id}/messages'),
|
|
111
|
+
Tags('messages'),
|
|
112
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
113
|
+
__param(0, Request()),
|
|
114
|
+
__param(1, Path()),
|
|
115
|
+
__param(2, Query()),
|
|
116
|
+
__param(3, Query()),
|
|
117
|
+
__param(4, Query()),
|
|
118
|
+
__param(5, Query())
|
|
119
|
+
], VbdController.prototype, "getVbdMessages", null);
|
|
120
|
+
__decorate([
|
|
121
|
+
Example(taskIds),
|
|
122
|
+
Example(partialTasks),
|
|
123
|
+
Get('{id}/tasks'),
|
|
124
|
+
Tags('tasks'),
|
|
125
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
126
|
+
__param(0, Request()),
|
|
127
|
+
__param(1, Path()),
|
|
128
|
+
__param(2, Query()),
|
|
129
|
+
__param(3, Query()),
|
|
130
|
+
__param(4, Query()),
|
|
131
|
+
__param(5, Query())
|
|
132
|
+
], VbdController.prototype, "getVbdTasks", null);
|
|
85
133
|
VbdController = __decorate([
|
|
86
134
|
Route('vbds'),
|
|
87
135
|
Security('*'),
|
|
136
|
+
Response(badRequestResp.status, badRequestResp.description),
|
|
88
137
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
89
138
|
Tags('vbds'),
|
|
90
139
|
provide(VbdController),
|
|
@@ -7,17 +7,19 @@ 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, Query, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa';
|
|
10
|
+
import { Delete, Example, Get, Path, Put, Query, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa';
|
|
11
11
|
import { inject } from 'inversify';
|
|
12
12
|
import { provide } from 'inversify-binding-decorators';
|
|
13
13
|
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
14
|
-
import { noContentResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
14
|
+
import { badRequestResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
15
15
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
16
16
|
import { partialVdiSnapshots, vdiSnapshot, vdiSnapshotIds } from '../open-api/oa-examples/vdi-snapshot.oa-example.mjs';
|
|
17
17
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
18
18
|
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
19
19
|
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
20
20
|
import { VdiService } from '../vdis/vdi.service.mjs';
|
|
21
|
+
import { messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs';
|
|
22
|
+
import { taskIds, partialTasks } from '../open-api/oa-examples/task.oa-example.mjs';
|
|
21
23
|
let VdiSnapshotController = class VdiSnapshotController extends XapiXoController {
|
|
22
24
|
#alarmService;
|
|
23
25
|
#vdiService;
|
|
@@ -77,6 +79,42 @@ let VdiSnapshotController = class VdiSnapshotController extends XapiXoController
|
|
|
77
79
|
const xapiVdiSnapshot = this.getXapiObject(id);
|
|
78
80
|
await xapiVdiSnapshot.$xapi.VDI_destroy(xapiVdiSnapshot.$ref);
|
|
79
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* @example id "d2727772-735b-478f-b6f9-11e7db56dfd0"
|
|
84
|
+
* @example fields "name,id,$object"
|
|
85
|
+
* @example filter "name:VM_STARTED"
|
|
86
|
+
* @example limit 42
|
|
87
|
+
*/
|
|
88
|
+
getVdiSnapshotMessages(req, id, fields, ndjson, filter, limit) {
|
|
89
|
+
const messages = this.getMessagesForObject(id, { filter, limit });
|
|
90
|
+
return this.sendObjects(Object.values(messages), req, 'messages');
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @example id "d2727772-735b-478f-b6f9-11e7db56dfd0"
|
|
94
|
+
* @example fields "id,status,properties"
|
|
95
|
+
* @example filter "status:failure"
|
|
96
|
+
* @example limit 42
|
|
97
|
+
*/
|
|
98
|
+
async getVdiSnapshotTasks(req, id, fields, ndjson, filter, limit) {
|
|
99
|
+
const tasks = await this.getTasksForObject(id, { filter, limit });
|
|
100
|
+
return this.sendObjects(Object.values(tasks), req, 'tasks');
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @example id "d2727772-735b-478f-b6f9-11e7db56dfd0"
|
|
104
|
+
* @example tag "from-rest-api"
|
|
105
|
+
*/
|
|
106
|
+
async putVdiSnapshotTag(id, tag) {
|
|
107
|
+
const vdiSnapshot = this.getXapiObject(id);
|
|
108
|
+
await vdiSnapshot.$call('add_tags', tag);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @example id "d2727772-735b-478f-b6f9-11e7db56dfd0"
|
|
112
|
+
* @example tag "from-rest-api"
|
|
113
|
+
*/
|
|
114
|
+
async deleteVdiSnapshotTag(id, tag) {
|
|
115
|
+
const vdiSnapshot = this.getXapiObject(id);
|
|
116
|
+
await vdiSnapshot.$call('remove_tags', tag);
|
|
117
|
+
}
|
|
80
118
|
};
|
|
81
119
|
__decorate([
|
|
82
120
|
Example(vdiSnapshotIds),
|
|
@@ -121,9 +159,50 @@ __decorate([
|
|
|
121
159
|
Response(notFoundResp.status, notFoundResp.description),
|
|
122
160
|
__param(0, Path())
|
|
123
161
|
], VdiSnapshotController.prototype, "deleteVdiSnapshot", null);
|
|
162
|
+
__decorate([
|
|
163
|
+
Example(messageIds),
|
|
164
|
+
Example(partialMessages),
|
|
165
|
+
Get('{id}/messages'),
|
|
166
|
+
Tags('messages'),
|
|
167
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
168
|
+
__param(0, Request()),
|
|
169
|
+
__param(1, Path()),
|
|
170
|
+
__param(2, Query()),
|
|
171
|
+
__param(3, Query()),
|
|
172
|
+
__param(4, Query()),
|
|
173
|
+
__param(5, Query())
|
|
174
|
+
], VdiSnapshotController.prototype, "getVdiSnapshotMessages", null);
|
|
175
|
+
__decorate([
|
|
176
|
+
Example(taskIds),
|
|
177
|
+
Example(partialTasks),
|
|
178
|
+
Get('{id}/tasks'),
|
|
179
|
+
Tags('tasks'),
|
|
180
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
181
|
+
__param(0, Request()),
|
|
182
|
+
__param(1, Path()),
|
|
183
|
+
__param(2, Query()),
|
|
184
|
+
__param(3, Query()),
|
|
185
|
+
__param(4, Query()),
|
|
186
|
+
__param(5, Query())
|
|
187
|
+
], VdiSnapshotController.prototype, "getVdiSnapshotTasks", null);
|
|
188
|
+
__decorate([
|
|
189
|
+
Put('{id}/tags/{tag}'),
|
|
190
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
191
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
192
|
+
__param(0, Path()),
|
|
193
|
+
__param(1, Path())
|
|
194
|
+
], VdiSnapshotController.prototype, "putVdiSnapshotTag", null);
|
|
195
|
+
__decorate([
|
|
196
|
+
Delete('{id}/tags/{tag}'),
|
|
197
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
198
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
199
|
+
__param(0, Path()),
|
|
200
|
+
__param(1, Path())
|
|
201
|
+
], VdiSnapshotController.prototype, "deleteVdiSnapshotTag", null);
|
|
124
202
|
VdiSnapshotController = __decorate([
|
|
125
203
|
Route('vdi-snapshots'),
|
|
126
204
|
Security('*'),
|
|
205
|
+
Response(badRequestResp.status, badRequestResp.description),
|
|
127
206
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
128
207
|
Tags('vdis'),
|
|
129
208
|
provide(VdiSnapshotController),
|
|
@@ -7,17 +7,19 @@ 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, Query, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa';
|
|
10
|
+
import { Delete, Example, Get, Path, Put, Query, Request, Response, Route, Security, SuccessResponse, Tags } 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';
|
|
14
14
|
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
15
15
|
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
16
|
-
import { noContentResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
16
|
+
import { badRequestResp, internalServerErrorResp, 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
19
|
import { partialVdis, vdi, vdiIds } from '../open-api/oa-examples/vdi.oa-example.mjs';
|
|
20
20
|
import { VdiService } from './vdi.service.mjs';
|
|
21
|
+
import { messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs';
|
|
22
|
+
import { taskIds, partialTasks } from '../open-api/oa-examples/task.oa-example.mjs';
|
|
21
23
|
let VdiController = class VdiController extends XapiXoController {
|
|
22
24
|
#alarmService;
|
|
23
25
|
#vdiService;
|
|
@@ -47,6 +49,20 @@ let VdiController = class VdiController extends XapiXoController {
|
|
|
47
49
|
req.on('close', () => stream.destroy());
|
|
48
50
|
return stream;
|
|
49
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* Import VDI content
|
|
55
|
+
*
|
|
56
|
+
* @example id "c77f9955-c1d2-4b39-aa1c-73cdb2dacb7e"
|
|
57
|
+
*/
|
|
58
|
+
async importVdiContent(req, id, format) {
|
|
59
|
+
const xapiVdi = this.getXapiObject(id);
|
|
60
|
+
if (req.headers['content-length'] !== undefined) {
|
|
61
|
+
req.length = +req.headers['content-length'];
|
|
62
|
+
}
|
|
63
|
+
process.on('SIGTERM', () => req.destroy());
|
|
64
|
+
await xapiVdi.$xapi.VDI_importContent(xapiVdi.$ref, req, { format });
|
|
65
|
+
}
|
|
50
66
|
/**
|
|
51
67
|
* @example id "c77f9955-c1d2-4b39-aa1c-73cdb2dacb7e"
|
|
52
68
|
*/
|
|
@@ -74,6 +90,42 @@ let VdiController = class VdiController extends XapiXoController {
|
|
|
74
90
|
const xapiVdi = this.getXapiObject(id);
|
|
75
91
|
await xapiVdi.$xapi.VDI_destroy(xapiVdi.$ref);
|
|
76
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* @example id "c77f9955-c1d2-4b39-aa1c-73cdb2dacb7e"
|
|
95
|
+
* @example fields "name,id,$object"
|
|
96
|
+
* @example filter "name:VM_STARTED"
|
|
97
|
+
* @example limit 42
|
|
98
|
+
*/
|
|
99
|
+
getVdiMessages(req, id, fields, ndjson, filter, limit) {
|
|
100
|
+
const messages = this.getMessagesForObject(id, { filter, limit });
|
|
101
|
+
return this.sendObjects(Object.values(messages), req, 'messages');
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @example id "c77f9955-c1d2-4b39-aa1c-73cdb2dacb7e"
|
|
105
|
+
* @example fields "id,status,properties"
|
|
106
|
+
* @example filter "status:failure"
|
|
107
|
+
* @example limit 42
|
|
108
|
+
*/
|
|
109
|
+
async getVdiTasks(req, id, fields, ndjson, filter, limit) {
|
|
110
|
+
const tasks = await this.getTasksForObject(id, { filter, limit });
|
|
111
|
+
return this.sendObjects(Object.values(tasks), req, 'tasks');
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @example id "c77f9955-c1d2-4b39-aa1c-73cdb2dacb7e"
|
|
115
|
+
* @example tag "from-rest-api"
|
|
116
|
+
*/
|
|
117
|
+
async putVdiTag(id, tag) {
|
|
118
|
+
const vdi = this.getXapiObject(id);
|
|
119
|
+
await vdi.$call('add_tags', tag);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @example id "c77f9955-c1d2-4b39-aa1c-73cdb2dacb7e"
|
|
123
|
+
* @example tag "from-rest-api"
|
|
124
|
+
*/
|
|
125
|
+
async deleteVdiTag(id, tag) {
|
|
126
|
+
const vdi = this.getXapiObject(id);
|
|
127
|
+
await vdi.$call('remove_tags', tag);
|
|
128
|
+
}
|
|
77
129
|
};
|
|
78
130
|
__decorate([
|
|
79
131
|
Example(vdiIds),
|
|
@@ -94,6 +146,16 @@ __decorate([
|
|
|
94
146
|
__param(1, Path()),
|
|
95
147
|
__param(2, Path())
|
|
96
148
|
], VdiController.prototype, "exportVdiContent", null);
|
|
149
|
+
__decorate([
|
|
150
|
+
Put('{id}.{format}'),
|
|
151
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
152
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
153
|
+
Response(422, 'Invalid format'),
|
|
154
|
+
Response(internalServerErrorResp.status, internalServerErrorResp.description),
|
|
155
|
+
__param(0, Request()),
|
|
156
|
+
__param(1, Path()),
|
|
157
|
+
__param(2, Path())
|
|
158
|
+
], VdiController.prototype, "importVdiContent", null);
|
|
97
159
|
__decorate([
|
|
98
160
|
Example(vdi),
|
|
99
161
|
Get('{id}'),
|
|
@@ -118,9 +180,50 @@ __decorate([
|
|
|
118
180
|
Response(notFoundResp.status, notFoundResp.description),
|
|
119
181
|
__param(0, Path())
|
|
120
182
|
], VdiController.prototype, "deleteVdi", null);
|
|
183
|
+
__decorate([
|
|
184
|
+
Example(messageIds),
|
|
185
|
+
Example(partialMessages),
|
|
186
|
+
Get('{id}/messages'),
|
|
187
|
+
Tags('messages'),
|
|
188
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
189
|
+
__param(0, Request()),
|
|
190
|
+
__param(1, Path()),
|
|
191
|
+
__param(2, Query()),
|
|
192
|
+
__param(3, Query()),
|
|
193
|
+
__param(4, Query()),
|
|
194
|
+
__param(5, Query())
|
|
195
|
+
], VdiController.prototype, "getVdiMessages", null);
|
|
196
|
+
__decorate([
|
|
197
|
+
Example(taskIds),
|
|
198
|
+
Example(partialTasks),
|
|
199
|
+
Get('{id}/tasks'),
|
|
200
|
+
Tags('tasks'),
|
|
201
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
202
|
+
__param(0, Request()),
|
|
203
|
+
__param(1, Path()),
|
|
204
|
+
__param(2, Query()),
|
|
205
|
+
__param(3, Query()),
|
|
206
|
+
__param(4, Query()),
|
|
207
|
+
__param(5, Query())
|
|
208
|
+
], VdiController.prototype, "getVdiTasks", null);
|
|
209
|
+
__decorate([
|
|
210
|
+
Put('{id}/tags/{tag}'),
|
|
211
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
212
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
213
|
+
__param(0, Path()),
|
|
214
|
+
__param(1, Path())
|
|
215
|
+
], VdiController.prototype, "putVdiTag", null);
|
|
216
|
+
__decorate([
|
|
217
|
+
Delete('{id}/tags/{tag}'),
|
|
218
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
219
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
220
|
+
__param(0, Path()),
|
|
221
|
+
__param(1, Path())
|
|
222
|
+
], VdiController.prototype, "deleteVdiTag", null);
|
|
121
223
|
VdiController = __decorate([
|
|
122
224
|
Route('vdis'),
|
|
123
225
|
Security('*'),
|
|
226
|
+
Response(badRequestResp.status, badRequestResp.description),
|
|
124
227
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
125
228
|
Tags('vdis'),
|
|
126
229
|
provide(VdiController),
|
|
@@ -12,11 +12,13 @@ import { inject } from 'inversify';
|
|
|
12
12
|
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
13
13
|
import { provide } from 'inversify-binding-decorators';
|
|
14
14
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
15
|
-
import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
15
|
+
import { badRequestResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
16
16
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
17
17
|
import { partialVifs, vif, vifIds } from '../open-api/oa-examples/vif.oa-example.mjs';
|
|
18
18
|
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
19
19
|
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
20
|
+
import { messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs';
|
|
21
|
+
import { taskIds, partialTasks } from '../open-api/oa-examples/task.oa-example.mjs';
|
|
20
22
|
let VifController = class VifController extends XapiXoController {
|
|
21
23
|
#alarmService;
|
|
22
24
|
constructor(restApi, alarmService) {
|
|
@@ -51,6 +53,26 @@ let VifController = class VifController extends XapiXoController {
|
|
|
51
53
|
});
|
|
52
54
|
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
53
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* @example id "f028c5d4-578a-332c-394e-087aaca32dd3"
|
|
58
|
+
* @example fields "name,id,$object"
|
|
59
|
+
* @example filter "name:VM_STARTED"
|
|
60
|
+
* @example limit 42
|
|
61
|
+
*/
|
|
62
|
+
getVifMessages(req, id, fields, ndjson, filter, limit) {
|
|
63
|
+
const messages = this.getMessagesForObject(id, { filter, limit });
|
|
64
|
+
return this.sendObjects(Object.values(messages), req, 'messages');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @example id "f028c5d4-578a-332c-394e-087aaca32dd3"
|
|
68
|
+
* @example fields "id,status,properties"
|
|
69
|
+
* @example filter "status:failure"
|
|
70
|
+
* @example limit 42
|
|
71
|
+
*/
|
|
72
|
+
async getVifTasks(req, id, fields, ndjson, filter, limit) {
|
|
73
|
+
const tasks = await this.getTasksForObject(id, { filter, limit });
|
|
74
|
+
return this.sendObjects(Object.values(tasks), req, 'tasks');
|
|
75
|
+
}
|
|
54
76
|
};
|
|
55
77
|
__decorate([
|
|
56
78
|
Example(vifIds),
|
|
@@ -80,9 +102,36 @@ __decorate([
|
|
|
80
102
|
__param(4, Query()),
|
|
81
103
|
__param(5, Query())
|
|
82
104
|
], VifController.prototype, "getVifAlarms", null);
|
|
105
|
+
__decorate([
|
|
106
|
+
Example(messageIds),
|
|
107
|
+
Example(partialMessages),
|
|
108
|
+
Get('{id}/messages'),
|
|
109
|
+
Tags('messages'),
|
|
110
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
111
|
+
__param(0, Request()),
|
|
112
|
+
__param(1, Path()),
|
|
113
|
+
__param(2, Query()),
|
|
114
|
+
__param(3, Query()),
|
|
115
|
+
__param(4, Query()),
|
|
116
|
+
__param(5, Query())
|
|
117
|
+
], VifController.prototype, "getVifMessages", null);
|
|
118
|
+
__decorate([
|
|
119
|
+
Example(taskIds),
|
|
120
|
+
Example(partialTasks),
|
|
121
|
+
Get('{id}/tasks'),
|
|
122
|
+
Tags('tasks'),
|
|
123
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
124
|
+
__param(0, Request()),
|
|
125
|
+
__param(1, Path()),
|
|
126
|
+
__param(2, Query()),
|
|
127
|
+
__param(3, Query()),
|
|
128
|
+
__param(4, Query()),
|
|
129
|
+
__param(5, Query())
|
|
130
|
+
], VifController.prototype, "getVifTasks", null);
|
|
83
131
|
VifController = __decorate([
|
|
84
132
|
Route('vifs'),
|
|
85
133
|
Security('*'),
|
|
134
|
+
Response(badRequestResp.status, badRequestResp.description),
|
|
86
135
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
87
136
|
Tags('vifs'),
|
|
88
137
|
provide(VifController),
|