@xen-orchestra/rest-api 0.17.0 → 0.19.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 (47) hide show
  1. package/dist/abstract-classes/base-controller.mjs +20 -0
  2. package/dist/abstract-classes/xapi-xo-controller.mjs +10 -0
  3. package/dist/abstract-classes/xo-controller.mjs +1 -1
  4. package/dist/alarms/alarm.controller.mjs +2 -1
  5. package/dist/backup-archives/backup-archive.controller.mjs +96 -0
  6. package/dist/backup-jobs/backup-job.controller.mjs +3 -1
  7. package/dist/backup-logs/backup-log.controller.mjs +2 -1
  8. package/dist/backup-repositories/backup-repositories.controller.mjs +2 -1
  9. package/dist/groups/group.controller.mjs +26 -1
  10. package/dist/hosts/host.controller.mjs +81 -2
  11. package/dist/index.mjs +3 -2
  12. package/dist/ioc/ioc.mjs +0 -5
  13. package/dist/messages/message.controller.mjs +3 -2
  14. package/dist/middlewares/authentication.middleware.mjs +44 -20
  15. package/dist/networks/network.controller.mjs +81 -2
  16. package/dist/open-api/oa-examples/backup-archive.oa-example.mjs +60 -0
  17. package/dist/open-api/oa-examples/pbd.oa-example.mjs +41 -0
  18. package/dist/open-api/oa-examples/user.oa-example.mjs +12 -0
  19. package/dist/open-api/routes/routes.js +2094 -538
  20. package/dist/pbds/pbd.controller.mjs +60 -0
  21. package/dist/pcis/pci.controller.mjs +2 -1
  22. package/dist/pgpus/pgpu.controller.mjs +2 -1
  23. package/dist/pifs/pif.controller.mjs +50 -1
  24. package/dist/pools/pool.controller.mjs +80 -3
  25. package/dist/proxies/proxy.controller.mjs +2 -1
  26. package/dist/restore-logs/restore-log.controller.mjs +3 -1
  27. package/dist/schedules/schedule.controller.mjs +2 -1
  28. package/dist/servers/server.controller.mjs +26 -2
  29. package/dist/sms/sm.controller.mjs +2 -1
  30. package/dist/srs/sr.controller.mjs +81 -2
  31. package/dist/tasks/task.controller.mjs +2 -1
  32. package/dist/users/user.controller.mjs +80 -31
  33. package/dist/users/user.middleware.mjs +11 -0
  34. package/dist/vbds/vbd.controller.mjs +50 -1
  35. package/dist/vdi-snapshots/vdi-snapshot.controller.mjs +81 -2
  36. package/dist/vdis/vdi.controller.mjs +105 -2
  37. package/dist/vifs/vif.controller.mjs +50 -1
  38. package/dist/vm-controller/vm-controller.controller.mjs +81 -2
  39. package/dist/vm-snapshots/vm-snapshot.controller.mjs +59 -8
  40. package/dist/vm-templates/vm-template.controller.mjs +59 -8
  41. package/dist/vms/vm.controller.mjs +38 -19
  42. package/dist/xoa/xoa.controller.mjs +2 -1
  43. package/open-api/spec/swagger.json +6380 -1008
  44. package/package.json +4 -4
  45. package/tsconfig.json +1 -0
  46. package/tsoa.json +19 -0
  47. package/dist/tasks/task.service.mjs +0 -24
@@ -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 { provide } from 'inversify-binding-decorators';
12
+ import { Route, Security, Request, Response, Get, Query, Path, Tags, Example } from 'tsoa';
13
+ import { badRequestResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
14
+ import { RestApi } from '../rest-api/rest-api.mjs';
15
+ import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
16
+ import { partialPbds, pbd, pbdIds } from '../open-api/oa-examples/pbd.oa-example.mjs';
17
+ let PbdController = class PbdController extends XapiXoController {
18
+ constructor(restApi) {
19
+ super('PBD', restApi);
20
+ }
21
+ /**
22
+ * @example fields "attached,id,device_config"
23
+ * @example filter "attached?"
24
+ * @example limit 42
25
+ */
26
+ getPbds(req, fields, ndjson, filter, limit) {
27
+ return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
28
+ }
29
+ /**
30
+ * @example id "16b2a60f-7c4d-f45f-7c7a-963b06fc587d"
31
+ */
32
+ getPbd(id) {
33
+ return this.getObject(id);
34
+ }
35
+ };
36
+ __decorate([
37
+ Example(pbdIds),
38
+ Example(partialPbds),
39
+ Get(''),
40
+ __param(0, Request()),
41
+ __param(1, Query()),
42
+ __param(2, Query()),
43
+ __param(3, Query()),
44
+ __param(4, Query())
45
+ ], PbdController.prototype, "getPbds", null);
46
+ __decorate([
47
+ Example(pbd),
48
+ Get('{id}'),
49
+ __param(0, Path())
50
+ ], PbdController.prototype, "getPbd", null);
51
+ PbdController = __decorate([
52
+ Route('pbds'),
53
+ Security('*'),
54
+ Response(unauthorizedResp.status, unauthorizedResp.description),
55
+ Response(badRequestResp.status, badRequestResp.description),
56
+ Tags('pbds'),
57
+ provide(PbdController),
58
+ __param(0, inject(RestApi))
59
+ ], PbdController);
60
+ export { PbdController };
@@ -10,7 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
11
11
  import { inject } from 'inversify';
12
12
  import { provide } from 'inversify-binding-decorators';
13
- import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
13
+ import { badRequestResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
14
14
  import { partialPcis, pci, pciIds } from '../open-api/oa-examples/pci.oa-example.mjs';
15
15
  import { RestApi } from '../rest-api/rest-api.mjs';
16
16
  import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
@@ -52,6 +52,7 @@ __decorate([
52
52
  PciController = __decorate([
53
53
  Route('pcis'),
54
54
  Security('*'),
55
+ Response(badRequestResp.status, badRequestResp.description),
55
56
  Response(unauthorizedResp.status, unauthorizedResp.description),
56
57
  Tags('pcis'),
57
58
  provide(PciController),
@@ -11,7 +11,7 @@ import { inject } from 'inversify';
11
11
  import { RestApi } from '../rest-api/rest-api.mjs';
12
12
  import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
13
13
  import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
14
- import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
14
+ import { badRequestResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
15
15
  import { provide } from 'inversify-binding-decorators';
16
16
  import { partialPgpus, pgpu, pgpuIds } from '../open-api/oa-examples/pgpu.oa-example.mjs';
17
17
  let PgpuController = class PgpuController extends XapiXoController {
@@ -52,6 +52,7 @@ __decorate([
52
52
  PgpuController = __decorate([
53
53
  Route('pgpus'),
54
54
  Security('*'),
55
+ Response(badRequestResp.status, badRequestResp.description),
55
56
  Response(unauthorizedResp.status, unauthorizedResp.description),
56
57
  Tags('pgpus'),
57
58
  provide(PgpuController),
@@ -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 { partialPifs, pif, pifIds } from '../open-api/oa-examples/pif.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 { partialTasks, taskIds } from '../open-api/oa-examples/task.oa-example.mjs';
20
22
  let PifController = class PifController extends XapiXoController {
21
23
  #alarmService;
22
24
  constructor(restApi, alarmService) {
@@ -51,6 +53,26 @@ let PifController = class PifController extends XapiXoController {
51
53
  });
52
54
  return this.sendObjects(Object.values(alarms), req, 'alarms');
53
55
  }
56
+ /**
57
+ * @example id "d9e42451-3794-089f-de81-4ee0e6137bee"
58
+ * @example fields "name,id,$object"
59
+ * @example filter "name:VM_STARTED"
60
+ * @example limit 42
61
+ */
62
+ getPifMessages(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 "d9e42451-3794-089f-de81-4ee0e6137bee"
68
+ * @example fields "id,status,properties"
69
+ * @example filter "status:failure"
70
+ * @example limit 42
71
+ */
72
+ async getPifTasks(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(pifIds),
@@ -80,9 +102,36 @@ __decorate([
80
102
  __param(4, Query()),
81
103
  __param(5, Query())
82
104
  ], PifController.prototype, "getPifAlarms", 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
+ ], PifController.prototype, "getPifMessages", 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
+ ], PifController.prototype, "getPifTasks", null);
83
131
  PifController = __decorate([
84
132
  Route('pifs'),
85
133
  Security('*'),
134
+ Response(badRequestResp.status, badRequestResp.description),
86
135
  Response(unauthorizedResp.status, unauthorizedResp.description),
87
136
  Tags('pifs'),
88
137
  provide(PifController),
@@ -7,23 +7,24 @@ 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, Post, Middlewares, Body, SuccessResponse, } from 'tsoa';
10
+ import { Example, Get, Path, Query, Response, Request, Route, Security, Tags, Post, Middlewares, Body, SuccessResponse, Put, Delete, } from 'tsoa';
11
11
  import { inject } from 'inversify';
12
12
  import { PassThrough } from 'node:stream';
13
13
  import { provide } from 'inversify-binding-decorators';
14
14
  import { json } from 'express';
15
15
  import { RestApi } from '../rest-api/rest-api.mjs';
16
- import { asynchronousActionResp, createdResp, featureUnauthorized, internalServerErrorResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
16
+ import { asynchronousActionResp, badRequestResp, createdResp, featureUnauthorized, internalServerErrorResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
17
17
  import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
18
18
  import { AlarmService } from '../alarms/alarm.service.mjs';
19
19
  import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
20
20
  import { createVm, importVm, partialPools, pool, poolDashboard, poolIds, poolMissingPatches, poolStats, } from '../open-api/oa-examples/pool.oa-example.mjs';
21
- import { taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
21
+ import { partialTasks, taskIds, taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
22
22
  import { createNetwork } from '../open-api/oa-examples/schedule.oa-example.mjs';
23
23
  import { BASE_URL } from '../index.mjs';
24
24
  import { VmService } from '../vms/vm.service.mjs';
25
25
  import { PoolService } from './pool.service.mjs';
26
26
  import { escapeUnsafeComplexMatcher, NDJSON_CONTENT_TYPE } from '../helpers/utils.helper.mjs';
27
+ import { messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs';
27
28
  let PoolController = class PoolController extends XapiXoController {
28
29
  #vmService;
29
30
  #poolService;
@@ -229,6 +230,41 @@ let PoolController = class PoolController extends XapiXoController {
229
230
  const { missingPatches } = await this.#poolService.getMissingPatches(pool.id);
230
231
  return missingPatches;
231
232
  }
233
+ /**
234
+ * @example id "355ee47d-ff4c-4924-3db2-fd86ae629676"
235
+ * @example fields "name,id,$object"
236
+ * @example filter "name:IP_CONFIGURED_PIF_CAN_UNPLUG"
237
+ * @example limit 42
238
+ */
239
+ getPoolMessages(req, id, fields, ndjson, filter, limit) {
240
+ const messages = this.getMessagesForObject(id, { filter, limit });
241
+ return this.sendObjects(Object.values(messages), req, 'messages');
242
+ }
243
+ /**
244
+ * @example id "355ee47d-ff4c-4924-3db2-fd86ae629676"
245
+ * @example tag "from-rest-api"
246
+ */
247
+ async putPoolTag(id, tag) {
248
+ const pool = this.getXapiObject(id);
249
+ await pool.$call('add_tags', tag);
250
+ }
251
+ /**
252
+ * @example id "355ee47d-ff4c-4924-3db2-fd86ae629676"
253
+ * @example tag "from-rest-api"
254
+ */
255
+ async deletePoolTag(id, tag) {
256
+ const pool = this.getXapiObject(id);
257
+ await pool.$call('remove_tags', tag);
258
+ }
259
+ /**
260
+ * @example fields "id,status,properties"
261
+ * @example filter "status:failure"
262
+ * @example limit 42
263
+ */
264
+ async getPoolTasks(req, id, fields, ndjson, filter, limit) {
265
+ const tasks = await this.getTasksForObject(id, { filter, limit });
266
+ return this.sendObjects(Object.values(tasks), req, 'tasks');
267
+ }
232
268
  };
233
269
  __decorate([
234
270
  Example(poolIds),
@@ -350,9 +386,50 @@ __decorate([
350
386
  Response(featureUnauthorized.status, featureUnauthorized.description),
351
387
  __param(0, Path())
352
388
  ], PoolController.prototype, "getPoolMissingPatches", null);
389
+ __decorate([
390
+ Example(messageIds),
391
+ Example(partialMessages),
392
+ Get('{id}/messages'),
393
+ Tags('messages'),
394
+ Response(notFoundResp.status, notFoundResp.description),
395
+ __param(0, Request()),
396
+ __param(1, Path()),
397
+ __param(2, Query()),
398
+ __param(3, Query()),
399
+ __param(4, Query()),
400
+ __param(5, Query())
401
+ ], PoolController.prototype, "getPoolMessages", null);
402
+ __decorate([
403
+ Put('{id}/tags/{tag}'),
404
+ SuccessResponse(noContentResp.status, noContentResp.description),
405
+ Response(notFoundResp.status, notFoundResp.description),
406
+ __param(0, Path()),
407
+ __param(1, Path())
408
+ ], PoolController.prototype, "putPoolTag", null);
409
+ __decorate([
410
+ Delete('{id}/tags/{tag}'),
411
+ SuccessResponse(noContentResp.status, noContentResp.description),
412
+ Response(notFoundResp.status, notFoundResp.description),
413
+ __param(0, Path()),
414
+ __param(1, Path())
415
+ ], PoolController.prototype, "deletePoolTag", null);
416
+ __decorate([
417
+ Example(taskIds),
418
+ Example(partialTasks),
419
+ Get('{id}/tasks'),
420
+ Tags('tasks'),
421
+ Response(notFoundResp.status, notFoundResp.description),
422
+ __param(0, Request()),
423
+ __param(1, Path()),
424
+ __param(2, Query()),
425
+ __param(3, Query()),
426
+ __param(4, Query()),
427
+ __param(5, Query())
428
+ ], PoolController.prototype, "getPoolTasks", null);
353
429
  PoolController = __decorate([
354
430
  Route('pools'),
355
431
  Security('*'),
432
+ Response(badRequestResp.status, badRequestResp.description),
356
433
  Response(unauthorizedResp.status, unauthorizedResp.description),
357
434
  Tags('pools'),
358
435
  provide(PoolController),
@@ -9,7 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
11
11
  import { provide } from 'inversify-binding-decorators';
12
- import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
12
+ import { badRequestResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
13
13
  import { partialProxies, proxy, proxyIds } from '../open-api/oa-examples/proxy.oa-example.mjs';
14
14
  import { XoController } from '../abstract-classes/xo-controller.mjs';
15
15
  let ProxyController = class ProxyController extends XoController {
@@ -54,6 +54,7 @@ __decorate([
54
54
  ProxyController = __decorate([
55
55
  Route('proxies'),
56
56
  Security('*'),
57
+ Response(badRequestResp.status, badRequestResp.description),
57
58
  Response(unauthorizedResp.status, unauthorizedResp.description),
58
59
  Tags('proxies'),
59
60
  provide(ProxyController)
@@ -14,7 +14,7 @@ import { noSuchObject } from 'xo-common/api-errors.js';
14
14
  import { provide } from 'inversify-binding-decorators';
15
15
  import { BackupLogService } from '../backup-logs/backup-log.service.mjs';
16
16
  import { RestApi } from '../rest-api/rest-api.mjs';
17
- import { unauthorizedResp } from '../open-api/common/response.common.mjs';
17
+ import { badRequestResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
18
18
  import { XoController } from '../abstract-classes/xo-controller.mjs';
19
19
  import { partialRestoreLogs, restoreLog, restoreLogIds } from '../open-api/oa-examples/restore-log.oa-example.mjs';
20
20
  const log = createLogger('xo:rest-api:restoreLog-controller');
@@ -69,6 +69,7 @@ __decorate([
69
69
  RestoreLogController = __decorate([
70
70
  Route('restore-logs'),
71
71
  Security('*'),
72
+ Response(badRequestResp.status, badRequestResp.description),
72
73
  Response(unauthorizedResp.status, unauthorizedResp.description),
73
74
  Tags('restore-logs'),
74
75
  provide(RestoreLogController),
@@ -130,6 +131,7 @@ __decorate([
130
131
  DeprecatedRestoreController = __decorate([
131
132
  Route('restore/logs'),
132
133
  Security('*'),
134
+ Response(badRequestResp.status, badRequestResp.description),
133
135
  Response(unauthorizedResp.status, unauthorizedResp.description),
134
136
  Middlewares((_req, _res, next) => {
135
137
  log.warn('You are calling a deprecated route. It will be removed in the futur. Please use `/rest/v0/restore-logs` instead');
@@ -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 { asynchronousActionResp, featureUnauthorized, internalServerErrorResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
12
+ import { asynchronousActionResp, badRequestResp, 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';
@@ -83,6 +83,7 @@ __decorate([
83
83
  ScheduleController = __decorate([
84
84
  Route('schedules'),
85
85
  Security('*'),
86
+ Response(badRequestResp.status, badRequestResp.description),
86
87
  Response(unauthorizedResp.status, unauthorizedResp.description),
87
88
  Tags('schedules'),
88
89
  provide(ScheduleController)
@@ -10,9 +10,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
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 { asynchronousActionResp, createdResp, invalidParameters, noContentResp, notFoundResp, resourceAlreadyExists, unauthorizedResp, } from '../open-api/common/response.common.mjs';
13
+ import { asynchronousActionResp, badRequestResp, 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
- import { taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
15
+ import { partialTasks, taskIds, taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
16
16
  import { XoController } from '../abstract-classes/xo-controller.mjs';
17
17
  let ServerController = class ServerController extends XoController {
18
18
  // --- abstract methods
@@ -83,6 +83,16 @@ let ServerController = class ServerController extends XoController {
83
83
  taskProperties: { name: 'disconnect server', objectId: serverId },
84
84
  });
85
85
  }
86
+ /**
87
+ * @example id "f07ab729-c0e8-721c-45ec-f11276377030"
88
+ * @example fields "id,status,properties"
89
+ * @example filter "status:failure"
90
+ * @example limit 42
91
+ */
92
+ async getServerTasks(req, id, fields, ndjson, filter, limit) {
93
+ const tasks = await this.getTasksForObject(id, { filter, limit });
94
+ return this.sendObjects(Object.values(tasks), req, 'tasks');
95
+ }
86
96
  };
87
97
  __decorate([
88
98
  Example(serverIds),
@@ -135,9 +145,23 @@ __decorate([
135
145
  __param(0, Path()),
136
146
  __param(1, Query())
137
147
  ], ServerController.prototype, "disconnectServer", null);
148
+ __decorate([
149
+ Example(taskIds),
150
+ Example(partialTasks),
151
+ Get('{id}/tasks'),
152
+ Tags('tasks'),
153
+ Response(notFoundResp.status, notFoundResp.description),
154
+ __param(0, Request()),
155
+ __param(1, Path()),
156
+ __param(2, Query()),
157
+ __param(3, Query()),
158
+ __param(4, Query()),
159
+ __param(5, Query())
160
+ ], ServerController.prototype, "getServerTasks", null);
138
161
  ServerController = __decorate([
139
162
  Route('servers'),
140
163
  Security('*'),
164
+ Response(badRequestResp.status, badRequestResp.description),
141
165
  Response(unauthorizedResp.status, unauthorizedResp.description),
142
166
  Tags('servers'),
143
167
  provide(ServerController)
@@ -10,7 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
11
11
  import { inject } from 'inversify';
12
12
  import { provide } from 'inversify-binding-decorators';
13
- import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
13
+ import { badRequestResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
14
14
  import { partialSms, sm, smIds } from '../open-api/oa-examples/sm.oa-example.mjs';
15
15
  import { RestApi } from '../rest-api/rest-api.mjs';
16
16
  import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
@@ -52,6 +52,7 @@ __decorate([
52
52
  SmController = __decorate([
53
53
  Route('sms'),
54
54
  Security('*'),
55
+ Response(badRequestResp.status, badRequestResp.description),
55
56
  Response(unauthorizedResp.status, unauthorizedResp.description),
56
57
  Tags('sms'),
57
58
  provide(SmController),
@@ -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, Path, Post, Query, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa';
10
+ import { Delete, Example, Get, Path, Post, 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 { SUPPORTED_VDI_FORMAT } from '@vates/types';
@@ -15,11 +15,13 @@ import { AlarmService } from '../alarms/alarm.service.mjs';
15
15
  import { BASE_URL } from '../index.mjs';
16
16
  import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
17
17
  import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
18
- import { createdResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
18
+ import { badRequestResp, createdResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
19
19
  import { partialSrs, sr, srIds } from '../open-api/oa-examples/sr.oa-example.mjs';
20
20
  import { vdiId } from '../open-api/oa-examples/vdi.oa-example.mjs';
21
21
  import { RestApi } from '../rest-api/rest-api.mjs';
22
22
  import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
23
+ import { messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs';
24
+ import { taskIds, partialTasks } from '../open-api/oa-examples/task.oa-example.mjs';
23
25
  let SrController = class SrController extends XapiXoController {
24
26
  #alarmService;
25
27
  constructor(restApi, alarmService) {
@@ -76,6 +78,42 @@ let SrController = class SrController extends XapiXoController {
76
78
  this.setHeader('Location', `${BASE_URL}/vdis/${vdiId}`);
77
79
  return { id: vdiId };
78
80
  }
81
+ /**
82
+ * @example id "c4284e12-37c9-7967-b9e8-83ef229c3e03"
83
+ * @example fields "name,id,$object"
84
+ * @example filter "name:VM_STARTED"
85
+ * @example limit 42
86
+ */
87
+ getSrMessages(req, id, fields, ndjson, filter, limit) {
88
+ const messages = this.getMessagesForObject(id, { filter, limit });
89
+ return this.sendObjects(Object.values(messages), req, 'messages');
90
+ }
91
+ /**
92
+ * @example id "c4284e12-37c9-7967-b9e8-83ef229c3e03"
93
+ * @example fields "id,status,properties"
94
+ * @example filter "status:failure"
95
+ * @example limit 42
96
+ */
97
+ async getSrTasks(req, id, fields, ndjson, filter, limit) {
98
+ const tasks = await this.getTasksForObject(id, { filter, limit });
99
+ return this.sendObjects(Object.values(tasks), req, 'tasks');
100
+ }
101
+ /**
102
+ * @example id "c4284e12-37c9-7967-b9e8-83ef229c3e03"
103
+ * @example tag "from-rest-api"
104
+ */
105
+ async putSrTag(id, tag) {
106
+ const sr = this.getXapiObject(id);
107
+ await sr.$call('add_tags', tag);
108
+ }
109
+ /**
110
+ * @example id "c4284e12-37c9-7967-b9e8-83ef229c3e03"
111
+ * @example tag "from-rest-api"
112
+ */
113
+ async deleteSrTag(id, tag) {
114
+ const sr = this.getXapiObject(id);
115
+ await sr.$call('remove_tags', tag);
116
+ }
79
117
  };
80
118
  __decorate([
81
119
  Example(srIds),
@@ -117,9 +155,50 @@ __decorate([
117
155
  __param(3, Query()),
118
156
  __param(4, Query())
119
157
  ], SrController.prototype, "srImportVdi", null);
158
+ __decorate([
159
+ Example(messageIds),
160
+ Example(partialMessages),
161
+ Get('{id}/messages'),
162
+ Tags('messages'),
163
+ Response(notFoundResp.status, notFoundResp.description),
164
+ __param(0, Request()),
165
+ __param(1, Path()),
166
+ __param(2, Query()),
167
+ __param(3, Query()),
168
+ __param(4, Query()),
169
+ __param(5, Query())
170
+ ], SrController.prototype, "getSrMessages", null);
171
+ __decorate([
172
+ Example(taskIds),
173
+ Example(partialTasks),
174
+ Get('{id}/tasks'),
175
+ Tags('tasks'),
176
+ Response(notFoundResp.status, notFoundResp.description),
177
+ __param(0, Request()),
178
+ __param(1, Path()),
179
+ __param(2, Query()),
180
+ __param(3, Query()),
181
+ __param(4, Query()),
182
+ __param(5, Query())
183
+ ], SrController.prototype, "getSrTasks", null);
184
+ __decorate([
185
+ SuccessResponse(noContentResp.status, noContentResp.description),
186
+ Response(notFoundResp.status, notFoundResp.description),
187
+ Put('{id}/tags/{tag}'),
188
+ __param(0, Path()),
189
+ __param(1, Path())
190
+ ], SrController.prototype, "putSrTag", null);
191
+ __decorate([
192
+ SuccessResponse(noContentResp.status, noContentResp.description),
193
+ Response(notFoundResp.status, notFoundResp.description),
194
+ Delete('{id}/tags/{tag}'),
195
+ __param(0, Path()),
196
+ __param(1, Path())
197
+ ], SrController.prototype, "deleteSrTag", null);
120
198
  SrController = __decorate([
121
199
  Route('srs'),
122
200
  Security('*'),
201
+ Response(badRequestResp.status, badRequestResp.description),
123
202
  Response(unauthorizedResp.status, unauthorizedResp.description),
124
203
  Tags('srs'),
125
204
  provide(SrController),
@@ -9,7 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import * as CM from 'complex-matcher';
11
11
  import { XoController } from '../abstract-classes/xo-controller.mjs';
12
- import { Get, Path, Query, Request, Route, Security, Tags, Response, Example, Delete, Post, SuccessResponse } from 'tsoa';
12
+ import { Get, Path, Query, Request, Route, Security, Tags, Response, Example, Delete, Post, SuccessResponse, } from 'tsoa';
13
13
  import { asynchronousActionResp, badRequestResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
14
14
  import { provide } from 'inversify-binding-decorators';
15
15
  import { partialTasks, task, taskIds, taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
@@ -160,6 +160,7 @@ __decorate([
160
160
  TaskController = __decorate([
161
161
  Route('tasks'),
162
162
  Security('*'),
163
+ Response(badRequestResp.status, badRequestResp.description),
163
164
  Response(unauthorizedResp.status, unauthorizedResp.description),
164
165
  Tags('tasks'),
165
166
  provide(TaskController)