@xen-orchestra/rest-api 0.8.0 → 0.10.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.
Files changed (48) hide show
  1. package/README.md +2 -1
  2. package/dist/abstract-classes/base-controller.mjs +17 -2
  3. package/dist/alarms/alarm.controller.mjs +3 -2
  4. package/dist/groups/group.controller.mjs +3 -2
  5. package/dist/helpers/cache.helper.mjs +52 -0
  6. package/dist/helpers/stream.helper.mjs +5 -0
  7. package/dist/helpers/utils.helper.mjs +4 -0
  8. package/dist/hosts/host.controller.mjs +3 -2
  9. package/dist/index.mjs +1 -1
  10. package/dist/ioc/ioc.mjs +16 -0
  11. package/dist/messages/message.controller.mjs +3 -2
  12. package/dist/middlewares/generic-error-handler.middleware.mjs +5 -1
  13. package/dist/networks/network.controller.mjs +18 -4
  14. package/dist/open-api/common/response.common.mjs +1 -1
  15. package/dist/open-api/oa-examples/pci.oa-example.mjs +30 -0
  16. package/dist/open-api/oa-examples/pgpu.oa-example.mjs +36 -0
  17. package/dist/open-api/oa-examples/pool.oa-example.mjs +4 -0
  18. package/dist/open-api/oa-examples/schedule.oa-example.mjs +3 -0
  19. package/dist/open-api/oa-examples/sm.oa-example.mjs +58 -0
  20. package/dist/open-api/oa-examples/vm-controller.oa-example.mjs +1 -1
  21. package/dist/open-api/oa-examples/xoa.oa-example.mjs +61 -0
  22. package/dist/open-api/routes/routes.js +897 -67
  23. package/dist/pcis/pci.controller.mjs +60 -0
  24. package/dist/pgpus/pgpu.controller.mjs +60 -0
  25. package/dist/pifs/pif.controller.mjs +3 -2
  26. package/dist/pools/pool.controller.mjs +215 -7
  27. package/dist/pools/pool.type.mjs +1 -0
  28. package/dist/rest-api/rest-api.mjs +3 -0
  29. package/dist/schedules/schedule.controller.mjs +5 -4
  30. package/dist/servers/server.controller.mjs +19 -6
  31. package/dist/sms/sm.controller.mjs +60 -0
  32. package/dist/srs/sr.controller.mjs +3 -2
  33. package/dist/users/user.controller.mjs +3 -2
  34. package/dist/vbds/vbd.controller.mjs +3 -2
  35. package/dist/vdi-snapshots/vdi-snapshot.controller.mjs +3 -2
  36. package/dist/vdis/vdi.controller.mjs +3 -2
  37. package/dist/vifs/vif.controller.mjs +3 -2
  38. package/dist/vm-controller/vm-controller.controller.mjs +3 -2
  39. package/dist/vm-snapshots/vm-snapshot.controller.mjs +3 -2
  40. package/dist/vm-templates/vm-template.controller.mjs +3 -2
  41. package/dist/vms/vm.controller.mjs +198 -12
  42. package/dist/vms/vm.service.mjs +47 -0
  43. package/dist/xoa/xoa.controller.mjs +55 -0
  44. package/dist/xoa/xoa.service.mjs +488 -0
  45. package/dist/xoa/xoa.type.mjs +1 -0
  46. package/open-api/spec/swagger.json +5729 -2883
  47. package/package.json +12 -4
  48. package/tsoa.json +20 -0
@@ -0,0 +1,60 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
11
+ import { inject } from 'inversify';
12
+ import { provide } from 'inversify-binding-decorators';
13
+ import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
14
+ import { partialPcis, pci, pciIds } from '../open-api/oa-examples/pci.oa-example.mjs';
15
+ import { RestApi } from '../rest-api/rest-api.mjs';
16
+ import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
17
+ let PciController = class PciController extends XapiXoController {
18
+ constructor(restApi) {
19
+ super('PCI', restApi);
20
+ }
21
+ /**
22
+ * @example fields "class_name,device_name,id"
23
+ * @example filter "class_name:Non-Volatile memory controller"
24
+ * @example limit 42
25
+ */
26
+ getPcis(req, fields, ndjson, filter, limit) {
27
+ return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
28
+ }
29
+ /**
30
+ * @example id "9377b642-cc71-8749-1e71-308898b652da"
31
+ */
32
+ getPci(id) {
33
+ return this.getObject(id);
34
+ }
35
+ };
36
+ __decorate([
37
+ Example(pciIds),
38
+ Example(partialPcis),
39
+ Get(''),
40
+ __param(0, Request()),
41
+ __param(1, Query()),
42
+ __param(2, Query()),
43
+ __param(3, Query()),
44
+ __param(4, Query())
45
+ ], PciController.prototype, "getPcis", null);
46
+ __decorate([
47
+ Example(pci),
48
+ Get('{id}'),
49
+ Response(notFoundResp.status, notFoundResp.description),
50
+ __param(0, Path())
51
+ ], PciController.prototype, "getPci", null);
52
+ PciController = __decorate([
53
+ Route('pcis'),
54
+ Security('*'),
55
+ Response(unauthorizedResp.status, unauthorizedResp.description),
56
+ Tags('pcis'),
57
+ provide(PciController),
58
+ __param(0, inject(RestApi))
59
+ ], PciController);
60
+ export { PciController };
@@ -0,0 +1,60 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { inject } from 'inversify';
11
+ import { RestApi } from '../rest-api/rest-api.mjs';
12
+ import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
13
+ import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
14
+ import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
15
+ import { provide } from 'inversify-binding-decorators';
16
+ import { partialPgpus, pgpu, pgpuIds } from '../open-api/oa-examples/pgpu.oa-example.mjs';
17
+ let PgpuController = class PgpuController extends XapiXoController {
18
+ constructor(restApi) {
19
+ super('PGPU', restApi);
20
+ }
21
+ /**
22
+ * @example fields "id,dom0Access,gpuGroup"
23
+ * @example filter "dom0Access:enabled"
24
+ * @example limit 42
25
+ */
26
+ getPgpus(req, fields, ndjson, filter, limit) {
27
+ return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
28
+ }
29
+ /**
30
+ * @example id "838335fa-ee21-15e1-760a-a37a3a4ef1db"
31
+ */
32
+ getPgpu(id) {
33
+ return this.getObject(id);
34
+ }
35
+ };
36
+ __decorate([
37
+ Example(pgpuIds),
38
+ Example(partialPgpus),
39
+ Get(''),
40
+ __param(0, Request()),
41
+ __param(1, Query()),
42
+ __param(2, Query()),
43
+ __param(3, Query()),
44
+ __param(4, Query())
45
+ ], PgpuController.prototype, "getPgpus", null);
46
+ __decorate([
47
+ Example(pgpu),
48
+ Get('{id}'),
49
+ Response(notFoundResp.status, notFoundResp.description),
50
+ __param(0, Path())
51
+ ], PgpuController.prototype, "getPgpu", null);
52
+ PgpuController = __decorate([
53
+ Route('pgpus'),
54
+ Security('*'),
55
+ Response(unauthorizedResp.status, unauthorizedResp.description),
56
+ Tags('pgpus'),
57
+ provide(PgpuController),
58
+ __param(0, inject(RestApi))
59
+ ], PgpuController);
60
+ export { PgpuController };
@@ -23,7 +23,7 @@ let PifController = class PifController extends XapiXoController {
23
23
  * @example filter "attached?"
24
24
  * @example limit 42
25
25
  */
26
- getPifs(req, fields, filter, limit) {
26
+ getPifs(req, fields, ndjson, filter, limit) {
27
27
  return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
28
28
  }
29
29
  /**
@@ -40,7 +40,8 @@ __decorate([
40
40
  __param(0, Request()),
41
41
  __param(1, Query()),
42
42
  __param(2, Query()),
43
- __param(3, Query())
43
+ __param(3, Query()),
44
+ __param(4, Query())
44
45
  ], PifController.prototype, "getPifs", null);
45
46
  __decorate([
46
47
  Example(pif),
@@ -7,16 +7,23 @@ 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, Path, Query, Response, Request, Route, Security, Tags } from 'tsoa';
10
+ import { Example, Get, Path, Query, Response, Request, Route, Security, Tags, Post, Middlewares, Body, SuccessResponse, } from 'tsoa';
11
11
  import { inject } from 'inversify';
12
12
  import { provide } from 'inversify-binding-decorators';
13
+ import { json } from 'express';
13
14
  import { RestApi } from '../rest-api/rest-api.mjs';
14
- import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
15
+ import { asynchronousActionResp, createdResp, featureUnauthorized, internalServerErrorResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
15
16
  import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
16
- import { partialPools, pool, poolIds } from '../open-api/oa-examples/pool.oa-example.mjs';
17
+ import { createVm, importVm, partialPools, pool, poolIds } from '../open-api/oa-examples/pool.oa-example.mjs';
18
+ import { taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
19
+ import { createNetwork } from '../open-api/oa-examples/schedule.oa-example.mjs';
20
+ import { BASE_URL } from '../index.mjs';
21
+ import { VmService } from '../vms/vm.service.mjs';
17
22
  let PoolController = class PoolController extends XapiXoController {
18
- constructor(restApi) {
23
+ #vmService;
24
+ constructor(restApi, vmService) {
19
25
  super('pool', restApi);
26
+ this.#vmService = vmService;
20
27
  }
21
28
  /**
22
29
  *
@@ -24,7 +31,7 @@ let PoolController = class PoolController extends XapiXoController {
24
31
  * @example filter "auto_poweron?"
25
32
  * @example limit 42
26
33
  */
27
- getPools(req, fields, filter, limit) {
34
+ getPools(req, fields, ndjson, filter, limit) {
28
35
  return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
29
36
  }
30
37
  /**
@@ -33,6 +40,136 @@ let PoolController = class PoolController extends XapiXoController {
33
40
  getPool(id) {
34
41
  return this.getObject(id);
35
42
  }
43
+ /**
44
+ * @example id "355ee47d-ff4c-4924-3db2-fd86ae629676"
45
+ * @example body {
46
+ * "name": "awes0me_network",
47
+ * "description": "random description",
48
+ * "pif": "ad15b2c8-3d9a-194e-c43a-e3dcda74b256",
49
+ * "vlan": 0
50
+ * }
51
+ */
52
+ createNetwork(id, body, sync) {
53
+ const poolId = id;
54
+ const action = async () => {
55
+ const { pif, ...rest } = body;
56
+ const xapiPool = this.getXapiObject(poolId);
57
+ const xapiNetwork = await xapiPool.$xapi.createNetwork({ pifId: pif, ...rest });
58
+ const network = this.restApi.getObject(xapiNetwork.uuid, 'network');
59
+ return { id: network.id };
60
+ };
61
+ return this.createAction(action, {
62
+ sync,
63
+ statusCode: createdResp.status,
64
+ taskProperties: {
65
+ name: 'create network',
66
+ objectId: poolId,
67
+ args: body,
68
+ },
69
+ });
70
+ }
71
+ /**
72
+ * @example id "355ee47d-ff4c-4924-3db2-fd86ae629677"
73
+ */
74
+ emergencyShutdown(id, sync) {
75
+ const poolId = id;
76
+ const action = async () => {
77
+ await this.restApi.xoApp.checkFeatureAuthorization('POOL_EMERGENCY_SHUTDOWN');
78
+ await this.getXapiObject(poolId).$xapi.pool_emergencyShutdown();
79
+ };
80
+ return this.createAction(action, {
81
+ sync,
82
+ statusCode: noContentResp.status,
83
+ taskProperties: {
84
+ name: 'pool emergency shutdown',
85
+ objectId: poolId,
86
+ },
87
+ });
88
+ }
89
+ /**
90
+ * @example id "355ee47d-ff4c-4924-3db2-fd86ae629677"
91
+ */
92
+ rollingReboot(id, sync) {
93
+ const poolId = id;
94
+ const action = async (task) => {
95
+ const pool = this.getObject(poolId);
96
+ await this.restApi.xoApp.rollingPoolReboot(pool, { parentTask: task });
97
+ };
98
+ return this.createAction(action, {
99
+ sync,
100
+ statusCode: noContentResp.status,
101
+ taskProperties: {
102
+ name: 'rolling pool reboot',
103
+ objectId: poolId,
104
+ progress: 0,
105
+ },
106
+ });
107
+ }
108
+ /**
109
+ * @example id "355ee47d-ff4c-4924-3db2-fd86ae629677"
110
+ */
111
+ rollingUpdate(id, sync) {
112
+ const poolId = id;
113
+ const action = async (task) => {
114
+ const pool = this.getObject(poolId);
115
+ await this.restApi.xoApp.rollingPoolUpdate(pool, { parentTask: task });
116
+ };
117
+ return this.createAction(action, {
118
+ sync,
119
+ statusCode: noContentResp.status,
120
+ taskProperties: {
121
+ name: 'rolling pool update',
122
+ objectId: poolId,
123
+ progress: 0,
124
+ },
125
+ });
126
+ }
127
+ // For this endpoint, the requestBody type is written directly to `tsoa.json` because TSOA does not provide a decorator for "octet-stream" file uploads
128
+ /**
129
+ * Import an XVA VM into a pool
130
+ *
131
+ * @example id "355ee47d-ff4c-4924-3db2-fd86ae629677"
132
+ * @example sr "c787b75c-3e0d-70fa-d0c3-cbfd382d7e33"
133
+ *
134
+ */
135
+ async importVm(req, id, sr) {
136
+ const pool = this.getXapiObject(id);
137
+ const xapi = pool.$xapi;
138
+ let srRef;
139
+ if (sr !== undefined) {
140
+ srRef = this.restApi.getXapiObject(sr, 'SR').$ref;
141
+ }
142
+ const vmRef = await xapi.VM_import(req, srRef);
143
+ const vmId = await xapi.getField('VM', vmRef, 'uuid');
144
+ this.setHeader('Location', `${BASE_URL}/vms/${vmId}`);
145
+ return { id: vmId };
146
+ }
147
+ /**
148
+ * @example id "355ee47d-ff4c-4924-3db2-fd86ae629677"
149
+ * @example body {
150
+ * "name_label": "new VM from REST API",
151
+ * "template": "9bbcc5d1-ad4b-06f1-18f6-03125e809c38",
152
+ * "boot": true
153
+ * }
154
+ */
155
+ async createVm(id, body, sync) {
156
+ const poolId = id;
157
+ const action = async () => {
158
+ const { affinity, template, ...rest } = body;
159
+ const params = { affinityHost: affinity, ...rest };
160
+ const vmId = await this.#vmService.create({ pool: poolId, template, ...params });
161
+ return { id: vmId };
162
+ };
163
+ return this.createAction(action, {
164
+ sync,
165
+ statusCode: createdResp.status,
166
+ taskProperties: {
167
+ args: body,
168
+ name: 'create VM',
169
+ objectId: poolId,
170
+ },
171
+ });
172
+ }
36
173
  };
37
174
  __decorate([
38
175
  Example(poolIds),
@@ -41,7 +178,8 @@ __decorate([
41
178
  __param(0, Request()),
42
179
  __param(1, Query()),
43
180
  __param(2, Query()),
44
- __param(3, Query())
181
+ __param(3, Query()),
182
+ __param(4, Query())
45
183
  ], PoolController.prototype, "getPools", null);
46
184
  __decorate([
47
185
  Example(pool),
@@ -49,12 +187,82 @@ __decorate([
49
187
  Response(notFoundResp.status, notFoundResp.description),
50
188
  __param(0, Path())
51
189
  ], PoolController.prototype, "getPool", null);
190
+ __decorate([
191
+ Example(taskLocation),
192
+ Example(createNetwork),
193
+ Post('{id}/actions/create_network'),
194
+ Middlewares(json()),
195
+ Tags('networks'),
196
+ SuccessResponse(createdResp.status, createdResp.description),
197
+ Response(asynchronousActionResp.status, asynchronousActionResp.description, asynchronousActionResp.produce),
198
+ Response(notFoundResp.status, notFoundResp.description),
199
+ Response(internalServerErrorResp.status, internalServerErrorResp.description),
200
+ __param(0, Path()),
201
+ __param(1, Body()),
202
+ __param(2, Query())
203
+ ], PoolController.prototype, "createNetwork", null);
204
+ __decorate([
205
+ Example(taskLocation),
206
+ Post('{id}/actions/emergency_shutdown'),
207
+ SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description, asynchronousActionResp.produce),
208
+ Response(noContentResp.status, noContentResp.description),
209
+ Response(featureUnauthorized.status, featureUnauthorized.description),
210
+ Response(notFoundResp.status, notFoundResp.description),
211
+ __param(0, Path()),
212
+ __param(1, Query())
213
+ ], PoolController.prototype, "emergencyShutdown", null);
214
+ __decorate([
215
+ Example(taskLocation),
216
+ Post('{id}/actions/rolling_reboot'),
217
+ SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description, asynchronousActionResp.produce),
218
+ Response(noContentResp.status, noContentResp.description),
219
+ Response(featureUnauthorized.status, featureUnauthorized.description),
220
+ Response(notFoundResp.status, notFoundResp.description),
221
+ __param(0, Path()),
222
+ __param(1, Query())
223
+ ], PoolController.prototype, "rollingReboot", null);
224
+ __decorate([
225
+ Example(taskLocation),
226
+ Post('{id}/actions/rolling_update'),
227
+ SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description, asynchronousActionResp.produce),
228
+ Response(noContentResp.status, noContentResp.description),
229
+ Response(featureUnauthorized.status, featureUnauthorized.description),
230
+ Response(notFoundResp.status, notFoundResp.description),
231
+ __param(0, Path()),
232
+ __param(1, Query())
233
+ ], PoolController.prototype, "rollingUpdate", null);
234
+ __decorate([
235
+ Example(importVm),
236
+ Post('{id}/vms'),
237
+ Tags('vms'),
238
+ SuccessResponse(createdResp.status, 'VM imported'),
239
+ Response(notFoundResp.status, notFoundResp.description),
240
+ Response(internalServerErrorResp.status, internalServerErrorResp.description),
241
+ __param(0, Request()),
242
+ __param(1, Path()),
243
+ __param(2, Query())
244
+ ], PoolController.prototype, "importVm", null);
245
+ __decorate([
246
+ Example(taskLocation),
247
+ Example(createVm),
248
+ Post('{id}/actions/create_vm'),
249
+ Middlewares(json()),
250
+ Tags('vms'),
251
+ SuccessResponse(createdResp.status, createdResp.description),
252
+ Response(asynchronousActionResp.status, asynchronousActionResp.description, asynchronousActionResp.produce),
253
+ Response(notFoundResp.status, notFoundResp.description),
254
+ Response(internalServerErrorResp.status, internalServerErrorResp.description),
255
+ __param(0, Path()),
256
+ __param(1, Body()),
257
+ __param(2, Query())
258
+ ], PoolController.prototype, "createVm", null);
52
259
  PoolController = __decorate([
53
260
  Route('pools'),
54
261
  Security('*'),
55
262
  Response(unauthorizedResp.status, unauthorizedResp.description),
56
263
  Tags('pools'),
57
264
  provide(PoolController),
58
- __param(0, inject(RestApi))
265
+ __param(0, inject(RestApi)),
266
+ __param(1, inject(VmService))
59
267
  ], PoolController);
60
268
  export { PoolController };
@@ -0,0 +1 @@
1
+ export {};
@@ -12,6 +12,9 @@ export class RestApi {
12
12
  authenticateUser(...args) {
13
13
  return this.#xoApp.authenticateUser(...args);
14
14
  }
15
+ getCurrentUser() {
16
+ return this.#xoApp.apiContext.user;
17
+ }
15
18
  getObject(id, type) {
16
19
  return this.#xoApp.getObject(id, type);
17
20
  }
@@ -9,7 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Example, Get, Path, Post, Query, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa';
11
11
  import { provide } from 'inversify-binding-decorators';
12
- import { actionAsyncroneResp, featureUnauthorized, internalServerErrorResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
12
+ import { asynchronousActionResp, featureUnauthorized, internalServerErrorResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
13
13
  import { partialSchedules, schedule, scheduleIds } from '../open-api/oa-examples/schedule.oa-example.mjs';
14
14
  import { taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
15
15
  import { XoController } from '../abstract-classes/xo-controller.mjs';
@@ -26,7 +26,7 @@ let ScheduleController = class ScheduleController extends XoController {
26
26
  * @example filter "enabled?"
27
27
  * @example limit 42
28
28
  */
29
- async getSchedules(req, fields, filter, limit) {
29
+ async getSchedules(req, fields, ndjson, filter, limit) {
30
30
  return this.sendObjects(Object.values(await this.getObjects({ filter, limit })), req);
31
31
  }
32
32
  /**
@@ -60,7 +60,8 @@ __decorate([
60
60
  __param(0, Request()),
61
61
  __param(1, Query()),
62
62
  __param(2, Query()),
63
- __param(3, Query())
63
+ __param(3, Query()),
64
+ __param(4, Query())
64
65
  ], ScheduleController.prototype, "getSchedules", null);
65
66
  __decorate([
66
67
  Example(schedule),
@@ -71,7 +72,7 @@ __decorate([
71
72
  __decorate([
72
73
  Example(taskLocation),
73
74
  Post('{id}/actions/run'),
74
- SuccessResponse(actionAsyncroneResp.status, actionAsyncroneResp.description, actionAsyncroneResp.produce),
75
+ SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description, asynchronousActionResp.produce),
75
76
  Response(noContentResp.status, noContentResp.description),
76
77
  Response(featureUnauthorized.status, featureUnauthorized.description),
77
78
  Response(notFoundResp.status, notFoundResp.description),
@@ -7,10 +7,10 @@ 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, Example, Get, Middlewares, Path, Post, Query, Request, Response, Route, Security, SuccessResponse, Tags, } from 'tsoa';
10
+ import { Body, Delete, Example, Get, Middlewares, 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 { actionAsyncroneResp, createdResp, invalidParameters, noContentResp, notFoundResp, resourceAlreadyExists, unauthorizedResp, } from '../open-api/common/response.common.mjs';
13
+ import { asynchronousActionResp, createdResp, invalidParameters, noContentResp, notFoundResp, resourceAlreadyExists, unauthorizedResp, } from '../open-api/common/response.common.mjs';
14
14
  import { partialServers, server, serverId, serverIds } from '../open-api/oa-examples/server.oa-example.mjs';
15
15
  import { taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
16
16
  import { XoController } from '../abstract-classes/xo-controller.mjs';
@@ -27,7 +27,7 @@ let ServerController = class ServerController extends XoController {
27
27
  * @example filter "status:/^connected$/"
28
28
  * @example limit 42
29
29
  */
30
- async getServers(req, fields, filter, limit) {
30
+ async getServers(req, fields, ndjson, filter, limit) {
31
31
  return this.sendObjects(Object.values(await this.getObjects({ filter, limit })), req);
32
32
  }
33
33
  /**
@@ -36,6 +36,12 @@ let ServerController = class ServerController extends XoController {
36
36
  getServer(id) {
37
37
  return this.getObject(id);
38
38
  }
39
+ /**
40
+ * @example id "f07ab729-c0e8-721c-45ec-f11276377030"
41
+ */
42
+ async deleteServer(id) {
43
+ await this.restApi.xoApp.unregisterXenServer(id);
44
+ }
39
45
  /**
40
46
  * @example body {
41
47
  * "allowUnauthorized": true,
@@ -85,7 +91,8 @@ __decorate([
85
91
  __param(0, Request()),
86
92
  __param(1, Query()),
87
93
  __param(2, Query()),
88
- __param(3, Query())
94
+ __param(3, Query()),
95
+ __param(4, Query())
89
96
  ], ServerController.prototype, "getServers", null);
90
97
  __decorate([
91
98
  Example(server),
@@ -93,6 +100,12 @@ __decorate([
93
100
  Response(notFoundResp.status, notFoundResp.description),
94
101
  __param(0, Path())
95
102
  ], ServerController.prototype, "getServer", null);
103
+ __decorate([
104
+ Delete('{id}'),
105
+ SuccessResponse(noContentResp.status, noContentResp.description),
106
+ Response(notFoundResp.status, notFoundResp.description),
107
+ __param(0, Path())
108
+ ], ServerController.prototype, "deleteServer", null);
96
109
  __decorate([
97
110
  Example(serverId),
98
111
  Post(''),
@@ -105,7 +118,7 @@ __decorate([
105
118
  __decorate([
106
119
  Example(taskLocation),
107
120
  Post('{id}/actions/connect'),
108
- SuccessResponse(actionAsyncroneResp.status, actionAsyncroneResp.description, actionAsyncroneResp.produce),
121
+ SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description, asynchronousActionResp.produce),
109
122
  Response(noContentResp.status, noContentResp.description),
110
123
  Response(notFoundResp.status, notFoundResp.description),
111
124
  Response(409, 'The server is already connected'),
@@ -115,7 +128,7 @@ __decorate([
115
128
  __decorate([
116
129
  Example(taskLocation),
117
130
  Post('{id}/actions/disconnect'),
118
- SuccessResponse(actionAsyncroneResp.status, actionAsyncroneResp.description, actionAsyncroneResp.produce),
131
+ SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description, asynchronousActionResp.produce),
119
132
  Response(noContentResp.status, noContentResp.description),
120
133
  Response(notFoundResp.status, notFoundResp.description),
121
134
  Response(409, 'The server is already disconnected'),
@@ -0,0 +1,60 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
11
+ import { inject } from 'inversify';
12
+ import { provide } from 'inversify-binding-decorators';
13
+ import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
14
+ import { partialSms, sm, smIds } from '../open-api/oa-examples/sm.oa-example.mjs';
15
+ import { RestApi } from '../rest-api/rest-api.mjs';
16
+ import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
17
+ let SmController = class SmController extends XapiXoController {
18
+ constructor(restApi) {
19
+ super('SM', restApi);
20
+ }
21
+ /**
22
+ * @example fields "uuid,name_label,SM_type"
23
+ * @example filter "SM_type:ext"
24
+ * @example limit 42
25
+ */
26
+ getSrs(req, fields, ndjson, filter, limit) {
27
+ return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
28
+ }
29
+ /**
30
+ * @example id "c4284e12-37c9-7967-b9e8-83ef229c3e03"
31
+ */
32
+ getSr(id) {
33
+ return this.getObject(id);
34
+ }
35
+ };
36
+ __decorate([
37
+ Example(smIds),
38
+ Example(partialSms),
39
+ Get(''),
40
+ __param(0, Request()),
41
+ __param(1, Query()),
42
+ __param(2, Query()),
43
+ __param(3, Query()),
44
+ __param(4, Query())
45
+ ], SmController.prototype, "getSrs", null);
46
+ __decorate([
47
+ Example(sm),
48
+ Get('{id}'),
49
+ Response(notFoundResp.status, notFoundResp.description),
50
+ __param(0, Path())
51
+ ], SmController.prototype, "getSr", null);
52
+ SmController = __decorate([
53
+ Route('sms'),
54
+ Security('*'),
55
+ Response(unauthorizedResp.status, unauthorizedResp.description),
56
+ Tags('sms'),
57
+ provide(SmController),
58
+ __param(0, inject(RestApi))
59
+ ], SmController);
60
+ export { SmController };
@@ -23,7 +23,7 @@ let SrController = class SrController extends XapiXoController {
23
23
  * @example filter "allocationStrategy:thin"
24
24
  * @example limit 42
25
25
  */
26
- getSrs(req, fields, filter, limit) {
26
+ getSrs(req, fields, ndjson, filter, limit) {
27
27
  return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
28
28
  }
29
29
  /**
@@ -40,7 +40,8 @@ __decorate([
40
40
  __param(0, Request()),
41
41
  __param(1, Query()),
42
42
  __param(2, Query()),
43
- __param(3, Query())
43
+ __param(3, Query()),
44
+ __param(4, Query())
44
45
  ], SrController.prototype, "getSrs", null);
45
46
  __decorate([
46
47
  Example(sr),
@@ -34,7 +34,7 @@ let UserController = class UserController extends XoController {
34
34
  * @example filter "permission:none"
35
35
  * @example limit 42
36
36
  */
37
- async getUsers(req, fields, filter, limit) {
37
+ async getUsers(req, fields, ndjson, filter, limit) {
38
38
  const users = Object.values(await this.getObjects({ filter, limit }));
39
39
  return this.sendObjects(users, req);
40
40
  }
@@ -52,7 +52,8 @@ __decorate([
52
52
  __param(0, Request()),
53
53
  __param(1, Query()),
54
54
  __param(2, Query()),
55
- __param(3, Query())
55
+ __param(3, Query()),
56
+ __param(4, Query())
56
57
  ], UserController.prototype, "getUsers", null);
57
58
  __decorate([
58
59
  Example(user),
@@ -24,7 +24,7 @@ let VbdController = class VbdController extends XapiXoController {
24
24
  * @example filter "!bootable?"
25
25
  * @example limit 42
26
26
  */
27
- getVbds(req, fields, filter, limit) {
27
+ getVbds(req, fields, ndjson, filter, limit) {
28
28
  return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
29
29
  }
30
30
  /**
@@ -42,7 +42,8 @@ __decorate([
42
42
  __param(0, Request()),
43
43
  __param(1, Query()),
44
44
  __param(2, Query()),
45
- __param(3, Query())
45
+ __param(3, Query()),
46
+ __param(4, Query())
46
47
  ], VbdController.prototype, "getVbds", null);
47
48
  __decorate([
48
49
  Example(vbd),
@@ -23,7 +23,7 @@ let VdiSnapshotController = class VdiSnapshotController extends XapiXoController
23
23
  * @example filter "snapshot_time:>1725020038"
24
24
  * @example limit 42
25
25
  */
26
- getVdiSnapshots(req, fields, filter, limit) {
26
+ getVdiSnapshots(req, fields, ndjson, filter, limit) {
27
27
  return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
28
28
  }
29
29
  /**
@@ -40,7 +40,8 @@ __decorate([
40
40
  __param(0, Request()),
41
41
  __param(1, Query()),
42
42
  __param(2, Query()),
43
- __param(3, Query())
43
+ __param(3, Query()),
44
+ __param(4, Query())
44
45
  ], VdiSnapshotController.prototype, "getVdiSnapshots", null);
45
46
  __decorate([
46
47
  Example(vdiSnapshot),