@xen-orchestra/rest-api 0.2.0 → 0.4.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.
@@ -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, Response, Request, Route, Security, Tags } from 'tsoa';
11
+ import { inject } from 'inversify';
12
+ import { provide } from 'inversify-binding-decorators';
13
+ import { RestApi } from '../rest-api/rest-api.mjs';
14
+ import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
15
+ import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
16
+ import { partialPools, pool, poolIds } from '../open-api/oa-examples/pool.oa-example.mjs';
17
+ let PoolController = class PoolController extends XapiXoController {
18
+ constructor(restApi) {
19
+ super('pool', restApi);
20
+ }
21
+ /**
22
+ *
23
+ * @example fields "auto_poweron,name_label,id"
24
+ * @example filter "auto_poweron?"
25
+ * @example limit 42
26
+ */
27
+ getPools(req, fields, filter, limit) {
28
+ return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
29
+ }
30
+ /**
31
+ * @example id "355ee47d-ff4c-4924-3db2-fd86ae629676"
32
+ */
33
+ getPool(id) {
34
+ return this.getObject(id);
35
+ }
36
+ };
37
+ __decorate([
38
+ Example(poolIds),
39
+ Example(partialPools),
40
+ Get(''),
41
+ __param(0, Request()),
42
+ __param(1, Query()),
43
+ __param(2, Query()),
44
+ __param(3, Query())
45
+ ], PoolController.prototype, "getPools", null);
46
+ __decorate([
47
+ Example(pool),
48
+ Get('{id}'),
49
+ Response(notFoundResp.status, notFoundResp.description),
50
+ __param(0, Path())
51
+ ], PoolController.prototype, "getPool", null);
52
+ PoolController = __decorate([
53
+ Route('pools'),
54
+ Security('*'),
55
+ Response(unauthorizedResp.status, unauthorizedResp.description),
56
+ Tags('pools'),
57
+ provide(PoolController),
58
+ __param(0, inject(RestApi))
59
+ ], PoolController);
60
+ export { PoolController };
@@ -0,0 +1,89 @@
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, Post, Query, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa';
11
+ import { provide } from 'inversify-binding-decorators';
12
+ import { actionAsyncroneResp, featureUnauthorized, internalServerErrorResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
13
+ import { partialSchedules, schedule, scheduleIds } from '../open-api/oa-examples/schedule.oa-example.mjs';
14
+ import { taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
15
+ import { XoController } from '../abstract-classes/xo-controller.mjs';
16
+ let ScheduleController = class ScheduleController extends XoController {
17
+ // --- abstract methods
18
+ getAllCollectionObjects() {
19
+ return this.restApi.xoApp.getAllSchedules();
20
+ }
21
+ getCollectionObject(id) {
22
+ return this.restApi.xoApp.getSchedule(id);
23
+ }
24
+ /**
25
+ * @example fields "enabled,jobId,cron,id"
26
+ * @example filter "enabled?"
27
+ * @example limit 42
28
+ */
29
+ async getSchedules(req, fields, filter, limit) {
30
+ return this.sendObjects(Object.values(await this.getObjects({ filter, limit })), req);
31
+ }
32
+ /**
33
+ * @example id "cf7249f8-d20b-494f-97f4-b1f32f94e780"
34
+ */
35
+ async getSchedule(id) {
36
+ return this.getObject(id);
37
+ }
38
+ /**
39
+ * @example id "cf7249f8-d20b-494f-97f4-b1f32f94e780"
40
+ */
41
+ async runSchedule(id, sync) {
42
+ const scheduleId = id;
43
+ const action = async () => {
44
+ const xoApp = this.restApi.xoApp;
45
+ const schedule = await this.getObject(scheduleId);
46
+ const job = await xoApp.getJob(schedule.jobId);
47
+ await xoApp.runJob(job, schedule);
48
+ };
49
+ return this.createAction(action, {
50
+ sync,
51
+ statusCode: noContentResp.status,
52
+ taskProperties: { name: 'run schedule', objectId: scheduleId },
53
+ });
54
+ }
55
+ };
56
+ __decorate([
57
+ Example(scheduleIds),
58
+ Example(partialSchedules),
59
+ Get(''),
60
+ __param(0, Request()),
61
+ __param(1, Query()),
62
+ __param(2, Query()),
63
+ __param(3, Query())
64
+ ], ScheduleController.prototype, "getSchedules", null);
65
+ __decorate([
66
+ Example(schedule),
67
+ Get('{id}'),
68
+ Response(notFoundResp.status, notFoundResp.description),
69
+ __param(0, Path())
70
+ ], ScheduleController.prototype, "getSchedule", null);
71
+ __decorate([
72
+ Example(taskLocation),
73
+ Post('{id}/actions/run'),
74
+ SuccessResponse(actionAsyncroneResp.status, actionAsyncroneResp.description, actionAsyncroneResp.produce),
75
+ Response(noContentResp.status, noContentResp.description),
76
+ Response(featureUnauthorized.status, featureUnauthorized.description),
77
+ Response(notFoundResp.status, notFoundResp.description),
78
+ Response(internalServerErrorResp.status, internalServerErrorResp.description),
79
+ __param(0, Path()),
80
+ __param(1, Query())
81
+ ], ScheduleController.prototype, "runSchedule", null);
82
+ ScheduleController = __decorate([
83
+ Route('schedules'),
84
+ Security('*'),
85
+ Response(unauthorizedResp.status, unauthorizedResp.description),
86
+ Tags('schedules'),
87
+ provide(ScheduleController)
88
+ ], ScheduleController);
89
+ export { ScheduleController };
@@ -0,0 +1,59 @@
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 { RestApi } from '../rest-api/rest-api.mjs';
14
+ import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
15
+ import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
16
+ import { partialVifs, vif, vifIds } from '../open-api/oa-examples/vif.oa-example.mjs';
17
+ let VifController = class VifController extends XapiXoController {
18
+ constructor(restApi) {
19
+ super('VIF', restApi);
20
+ }
21
+ /**
22
+ * @example fields "attached,id,device"
23
+ * @example filter "attached?"
24
+ * @example limit 42
25
+ */
26
+ getVifs(req, fields, filter, limit) {
27
+ return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
28
+ }
29
+ /**
30
+ * @example id "f028c5d4-578a-332c-394e-087aaca32dd3"
31
+ */
32
+ getVif(id) {
33
+ return this.getObject(id);
34
+ }
35
+ };
36
+ __decorate([
37
+ Example(vifIds),
38
+ Example(partialVifs),
39
+ Get(''),
40
+ __param(0, Request()),
41
+ __param(1, Query()),
42
+ __param(2, Query()),
43
+ __param(3, Query())
44
+ ], VifController.prototype, "getVifs", null);
45
+ __decorate([
46
+ Example(vif),
47
+ Get('{id}'),
48
+ Response(notFoundResp.status, notFoundResp.description),
49
+ __param(0, Path())
50
+ ], VifController.prototype, "getVif", null);
51
+ VifController = __decorate([
52
+ Route('vifs'),
53
+ Security('*'),
54
+ Response(unauthorizedResp.status, unauthorizedResp.description),
55
+ Tags('vifs'),
56
+ provide(VifController),
57
+ __param(0, inject(RestApi))
58
+ ], VifController);
59
+ export { VifController };
@@ -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 { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
12
+ import { RestApi } from '../rest-api/rest-api.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 { partialVmControllers, vmController, vmControllerIds, } from '../open-api/oa-examples/vm-controller.oa-example.mjs';
17
+ let VmControllerController = class VmControllerController extends XapiXoController {
18
+ constructor(restApi) {
19
+ super('VM-controller', restApi);
20
+ }
21
+ /**
22
+ *
23
+ * @example fields "type,uuid"
24
+ * @example filter "power_state:Running"
25
+ * @example limit 42
26
+ */
27
+ getVmControllers(req, fields, filter, limit) {
28
+ return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
29
+ }
30
+ /**
31
+ * @example id "9b4775bd-9493-490a-9afa-f786a44caa4f"
32
+ */
33
+ getVmController(id) {
34
+ return this.getObject(id);
35
+ }
36
+ };
37
+ __decorate([
38
+ Example(vmControllerIds),
39
+ Example(partialVmControllers),
40
+ Get(''),
41
+ __param(0, Request()),
42
+ __param(1, Query()),
43
+ __param(2, Query()),
44
+ __param(3, Query())
45
+ ], VmControllerController.prototype, "getVmControllers", null);
46
+ __decorate([
47
+ Example(vmController),
48
+ Get('{id}'),
49
+ Response(notFoundResp.status, notFoundResp.description),
50
+ __param(0, Path())
51
+ ], VmControllerController.prototype, "getVmController", null);
52
+ VmControllerController = __decorate([
53
+ Route('vm-controllers'),
54
+ Security('*'),
55
+ Response(unauthorizedResp.status, unauthorizedResp.description),
56
+ Tags('vms'),
57
+ provide(VmControllerController),
58
+ __param(0, inject(RestApi))
59
+ ], VmControllerController);
60
+ export { VmControllerController };
@@ -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 { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
13
+ import { RestApi } from '../rest-api/rest-api.mjs';
14
+ import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
15
+ import { provide } from 'inversify-binding-decorators';
16
+ import { partialVmSnapshots, vmSnapshot, vmSnapshotIds } from '../open-api/oa-examples/vm-snapshot.oa-example.mjs';
17
+ let VmSnapshotController = class VmSnapshotController extends XapiXoController {
18
+ constructor(restApi) {
19
+ super('VM-snapshot', restApi);
20
+ }
21
+ /**
22
+ *
23
+ * @example fields "uuid,snapshot_time,$snapshot_of"
24
+ * @example filter "snapshot_time:>1725020038"
25
+ * @example limit 42
26
+ */
27
+ getVmSnapshots(req, fields, filter, limit) {
28
+ return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
29
+ }
30
+ /**
31
+ * @example id "d68fca2c-41e6-be87-d790-105c1642a090"
32
+ */
33
+ getVmSnapshot(id) {
34
+ return this.getObject(id);
35
+ }
36
+ };
37
+ __decorate([
38
+ Example(vmSnapshotIds),
39
+ Example(partialVmSnapshots),
40
+ Get(''),
41
+ __param(0, Request()),
42
+ __param(1, Query()),
43
+ __param(2, Query()),
44
+ __param(3, Query())
45
+ ], VmSnapshotController.prototype, "getVmSnapshots", null);
46
+ __decorate([
47
+ Example(vmSnapshot),
48
+ Get('{id}'),
49
+ Response(notFoundResp.status, notFoundResp.description),
50
+ __param(0, Path())
51
+ ], VmSnapshotController.prototype, "getVmSnapshot", null);
52
+ VmSnapshotController = __decorate([
53
+ Route('vm-snapshots'),
54
+ Security('*'),
55
+ Response(unauthorizedResp.status, unauthorizedResp.description),
56
+ Tags('vms'),
57
+ provide(VmSnapshotController),
58
+ __param(0, inject(RestApi))
59
+ ], VmSnapshotController);
60
+ export { VmSnapshotController };
@@ -0,0 +1,59 @@
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, Security, Query, Request, Response, Route, Tags, Path } 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 { RestApi } from '../rest-api/rest-api.mjs';
15
+ import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
16
+ import { partialVmTemplates, vmTemplate, vmTemplateIds } from '../open-api/oa-examples/vm-template.oa-example.mjs';
17
+ let VmTemplateController = class VmTemplateController extends XapiXoController {
18
+ constructor(restApi) {
19
+ super('VM-template', restApi);
20
+ }
21
+ /**
22
+ * @example fields "id,isDefaultTemplate,name_label"
23
+ * @example filter "isDefaultTemplate?"
24
+ * @example limit 42
25
+ * */
26
+ getVmTemplates(req, fields, filter, limit) {
27
+ return this.sendObjects(Object.values(this.getObjects({ filter, limit })), req);
28
+ }
29
+ /**
30
+ * @example id "b7569d99-30f8-178a-7d94-801de3e29b5b-f873abe0-b138-4995-8f6f-498b423d234d"
31
+ * */
32
+ getVmTemplate(id) {
33
+ return this.getObject(id);
34
+ }
35
+ };
36
+ __decorate([
37
+ Example(vmTemplateIds),
38
+ Example(partialVmTemplates),
39
+ Get(''),
40
+ __param(0, Request()),
41
+ __param(1, Query()),
42
+ __param(2, Query()),
43
+ __param(3, Query())
44
+ ], VmTemplateController.prototype, "getVmTemplates", null);
45
+ __decorate([
46
+ Example(vmTemplate),
47
+ Get('{id}'),
48
+ Response(notFoundResp.status, notFoundResp.description),
49
+ __param(0, Path())
50
+ ], VmTemplateController.prototype, "getVmTemplate", null);
51
+ VmTemplateController = __decorate([
52
+ Route('vm-templates'),
53
+ Security('*'),
54
+ Response(unauthorizedResp.status, unauthorizedResp.description),
55
+ Tags('vms'),
56
+ provide(VmTemplateController),
57
+ __param(0, inject(RestApi))
58
+ ], VmTemplateController);
59
+ export { VmTemplateController };