@xen-orchestra/rest-api 0.18.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.
- 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 +44 -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/pbd.oa-example.mjs +41 -0
- package/dist/open-api/oa-examples/user.oa-example.mjs +12 -0
- package/dist/open-api/routes/routes.js +2025 -565
- 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 +2 -1
- package/open-api/spec/swagger.json +7565 -2508
- package/package.json +3 -3
- package/tsoa.json +19 -0
- package/dist/tasks/task.service.mjs +0 -24
|
@@ -10,14 +10,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { inject } from 'inversify';
|
|
11
11
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
12
12
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
13
|
-
import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
|
|
13
|
+
import { Delete, Example, Get, Path, Put, Query, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa';
|
|
14
14
|
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
15
15
|
import { escapeUnsafeComplexMatcher, limitAndFilterArray } from '../helpers/utils.helper.mjs';
|
|
16
16
|
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
17
|
-
import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
17
|
+
import { badRequestResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
18
18
|
import { provide } from 'inversify-binding-decorators';
|
|
19
19
|
import { partialVmControllers, vmController, vmControllerIds, vmControllerVdis, } from '../open-api/oa-examples/vm-controller.oa-example.mjs';
|
|
20
20
|
import { VmService } from '../vms/vm.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 VmControllerController = class VmControllerController extends XapiXoController {
|
|
22
24
|
#alarmService;
|
|
23
25
|
#vmService;
|
|
@@ -65,6 +67,42 @@ let VmControllerController = class VmControllerController extends XapiXoControll
|
|
|
65
67
|
const vdis = this.#vmService.getVmVdis(id, 'VM-controller');
|
|
66
68
|
return this.sendObjects(limitAndFilterArray(vdis, { filter, limit }), req, obj => obj.type.toLowerCase() + 's');
|
|
67
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* @example id "9b4775bd-9493-490a-9afa-f786a44caa4f"
|
|
72
|
+
* @example fields "name,id,$object"
|
|
73
|
+
* @example filter "name:VM_STARTED"
|
|
74
|
+
* @example limit 42
|
|
75
|
+
*/
|
|
76
|
+
getVmControllerMessages(req, id, fields, ndjson, filter, limit) {
|
|
77
|
+
const messages = this.getMessagesForObject(id, { filter, limit });
|
|
78
|
+
return this.sendObjects(Object.values(messages), req, 'messages');
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @example id "9b4775bd-9493-490a-9afa-f786a44caa4f"
|
|
82
|
+
* @example fields "id,status,properties"
|
|
83
|
+
* @example filter "status:failure"
|
|
84
|
+
* @example limit 42
|
|
85
|
+
*/
|
|
86
|
+
async getVmControllerTasks(req, id, fields, ndjson, filter, limit) {
|
|
87
|
+
const tasks = await this.getTasksForObject(id, { filter, limit });
|
|
88
|
+
return this.sendObjects(Object.values(tasks), req, 'tasks');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @example id "9b4775bd-9493-490a-9afa-f786a44caa4f"
|
|
92
|
+
* @example tag "from-rest-api"
|
|
93
|
+
*/
|
|
94
|
+
async putVmControllerTag(id, tag) {
|
|
95
|
+
const vmController = this.getXapiObject(id);
|
|
96
|
+
await vmController.$call('add_tags', tag);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @example id "9b4775bd-9493-490a-9afa-f786a44caa4f"
|
|
100
|
+
* @example tag "from-rest-api"
|
|
101
|
+
*/
|
|
102
|
+
async deleteVmControllerTag(id, tag) {
|
|
103
|
+
const vmController = this.getXapiObject(id);
|
|
104
|
+
await vmController.$call('remove_tags', tag);
|
|
105
|
+
}
|
|
68
106
|
};
|
|
69
107
|
__decorate([
|
|
70
108
|
Example(vmControllerIds),
|
|
@@ -106,9 +144,50 @@ __decorate([
|
|
|
106
144
|
__param(4, Query()),
|
|
107
145
|
__param(5, Query())
|
|
108
146
|
], VmControllerController.prototype, "getVmControllerVdis", null);
|
|
147
|
+
__decorate([
|
|
148
|
+
Example(messageIds),
|
|
149
|
+
Example(partialMessages),
|
|
150
|
+
Get('{id}/messages'),
|
|
151
|
+
Tags('messages'),
|
|
152
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
153
|
+
__param(0, Request()),
|
|
154
|
+
__param(1, Path()),
|
|
155
|
+
__param(2, Query()),
|
|
156
|
+
__param(3, Query()),
|
|
157
|
+
__param(4, Query()),
|
|
158
|
+
__param(5, Query())
|
|
159
|
+
], VmControllerController.prototype, "getVmControllerMessages", null);
|
|
160
|
+
__decorate([
|
|
161
|
+
Example(taskIds),
|
|
162
|
+
Example(partialTasks),
|
|
163
|
+
Get('{id}/tasks'),
|
|
164
|
+
Tags('tasks'),
|
|
165
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
166
|
+
__param(0, Request()),
|
|
167
|
+
__param(1, Path()),
|
|
168
|
+
__param(2, Query()),
|
|
169
|
+
__param(3, Query()),
|
|
170
|
+
__param(4, Query()),
|
|
171
|
+
__param(5, Query())
|
|
172
|
+
], VmControllerController.prototype, "getVmControllerTasks", null);
|
|
173
|
+
__decorate([
|
|
174
|
+
Put('{id}/tags/{tag}'),
|
|
175
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
176
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
177
|
+
__param(0, Path()),
|
|
178
|
+
__param(1, Path())
|
|
179
|
+
], VmControllerController.prototype, "putVmControllerTag", null);
|
|
180
|
+
__decorate([
|
|
181
|
+
Delete('{id}/tags/{tag}'),
|
|
182
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
183
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
184
|
+
__param(0, Path()),
|
|
185
|
+
__param(1, Path())
|
|
186
|
+
], VmControllerController.prototype, "deleteVmControllerTag", null);
|
|
109
187
|
VmControllerController = __decorate([
|
|
110
188
|
Route('vm-controllers'),
|
|
111
189
|
Security('*'),
|
|
190
|
+
Response(badRequestResp.status, badRequestResp.description),
|
|
112
191
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
113
192
|
Tags('vms'),
|
|
114
193
|
provide(VmControllerController),
|
|
@@ -7,12 +7,13 @@ 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 { AlarmService } from '../alarms/alarm.service.mjs';
|
|
13
13
|
import { escapeUnsafeComplexMatcher, limitAndFilterArray } from '../helpers/utils.helper.mjs';
|
|
14
14
|
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
15
|
-
import {
|
|
15
|
+
import { partialTasks, taskIds } from '../open-api/oa-examples/task.oa-example.mjs';
|
|
16
|
+
import { badRequestResp, forbiddenOperationResp, incorrectStateResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
16
17
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
17
18
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
18
19
|
import { provide } from 'inversify-binding-decorators';
|
|
@@ -99,6 +100,32 @@ let VmSnapshotController = class VmSnapshotController extends XapiXoController {
|
|
|
99
100
|
const messages = this.getMessagesForObject(id, { filter, limit });
|
|
100
101
|
return this.sendObjects(Object.values(messages), req, 'messages');
|
|
101
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
105
|
+
* @example fields "id,status,properties"
|
|
106
|
+
* @example filter "status:failure"
|
|
107
|
+
* @example limit 42
|
|
108
|
+
*/
|
|
109
|
+
async getVmSnapshotTasks(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 "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
115
|
+
* @example tag "from-rest-api"
|
|
116
|
+
*/
|
|
117
|
+
async putVmSnapshotTag(id, tag) {
|
|
118
|
+
const vmSnapshot = this.getXapiObject(id);
|
|
119
|
+
await vmSnapshot.$call('add_tags', tag);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @example id "d68fca2c-41e6-be87-d790-105c1642a090"
|
|
123
|
+
* @example tag "from-rest-api"
|
|
124
|
+
*/
|
|
125
|
+
async deleteVmSnapshotTag(id, tag) {
|
|
126
|
+
const vmSnapshot = this.getXapiObject(id);
|
|
127
|
+
await vmSnapshot.$call('remove_tags', tag);
|
|
128
|
+
}
|
|
102
129
|
};
|
|
103
130
|
__decorate([
|
|
104
131
|
Example(vmSnapshotIds),
|
|
@@ -171,9 +198,37 @@ __decorate([
|
|
|
171
198
|
__param(4, Query()),
|
|
172
199
|
__param(5, Query())
|
|
173
200
|
], VmSnapshotController.prototype, "getVmSnapshotsMessages", null);
|
|
201
|
+
__decorate([
|
|
202
|
+
Example(taskIds),
|
|
203
|
+
Example(partialTasks),
|
|
204
|
+
Get('{id}/tasks'),
|
|
205
|
+
Tags('tasks'),
|
|
206
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
207
|
+
__param(0, Request()),
|
|
208
|
+
__param(1, Path()),
|
|
209
|
+
__param(2, Query()),
|
|
210
|
+
__param(3, Query()),
|
|
211
|
+
__param(4, Query()),
|
|
212
|
+
__param(5, Query())
|
|
213
|
+
], VmSnapshotController.prototype, "getVmSnapshotTasks", null);
|
|
214
|
+
__decorate([
|
|
215
|
+
Put('{id}/tags/{tag}'),
|
|
216
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
217
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
218
|
+
__param(0, Path()),
|
|
219
|
+
__param(1, Path())
|
|
220
|
+
], VmSnapshotController.prototype, "putVmSnapshotTag", null);
|
|
221
|
+
__decorate([
|
|
222
|
+
Delete('{id}/tags/{tag}'),
|
|
223
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
224
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
225
|
+
__param(0, Path()),
|
|
226
|
+
__param(1, Path())
|
|
227
|
+
], VmSnapshotController.prototype, "deleteVmSnapshotTag", null);
|
|
174
228
|
VmSnapshotController = __decorate([
|
|
175
229
|
Route('vm-snapshots'),
|
|
176
230
|
Security('*'),
|
|
231
|
+
Response(badRequestResp.status, badRequestResp.description),
|
|
177
232
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
178
233
|
Tags('vms'),
|
|
179
234
|
provide(VmSnapshotController),
|
|
@@ -7,18 +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 { Example, Get, Security, Query, Request, Response, Route, Tags, Path, Delete, SuccessResponse } from 'tsoa';
|
|
10
|
+
import { Example, Get, Security, Query, Request, Response, Route, Tags, Path, Delete, SuccessResponse, Put } 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, limitAndFilterArray } from '../helpers/utils.helper.mjs';
|
|
15
15
|
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
16
|
-
import { forbiddenOperationResp, incorrectStateResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
16
|
+
import { badRequestResp, forbiddenOperationResp, incorrectStateResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
17
17
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
18
18
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
19
19
|
import { partialVmTemplates, vmTemplate, vmTemplateIds, vmTemplateVdis, } from '../open-api/oa-examples/vm-template.oa-example.mjs';
|
|
20
20
|
import { VmService } from '../vms/vm.service.mjs';
|
|
21
21
|
import { messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs';
|
|
22
|
+
import { partialTasks, taskIds } from '../open-api/oa-examples/task.oa-example.mjs';
|
|
22
23
|
let VmTemplateController = class VmTemplateController extends XapiXoController {
|
|
23
24
|
#alarmService;
|
|
24
25
|
#vmService;
|
|
@@ -98,6 +99,32 @@ let VmTemplateController = class VmTemplateController extends XapiXoController {
|
|
|
98
99
|
const messages = this.getMessagesForObject(id, { filter, limit });
|
|
99
100
|
return this.sendObjects(Object.values(messages), req, 'messages');
|
|
100
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* @example id "613f541c-4bed-fc77-7ca8-2db6b68f079c"
|
|
104
|
+
* @example fields "id,status,properties"
|
|
105
|
+
* @example filter "status:failure"
|
|
106
|
+
* @example limit 42
|
|
107
|
+
*/
|
|
108
|
+
async getVmTemplateTasks(req, id, fields, ndjson, filter, limit) {
|
|
109
|
+
const tasks = await this.getTasksForObject(id, { filter, limit });
|
|
110
|
+
return this.sendObjects(Object.values(tasks), req, 'tasks');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @example id "613f541c-4bed-fc77-7ca8-2db6b68f079c"
|
|
114
|
+
* @example tag "from-rest-api"
|
|
115
|
+
*/
|
|
116
|
+
async putVmTemplateTag(id, tag) {
|
|
117
|
+
const vmTemplate = this.getXapiObject(id);
|
|
118
|
+
await vmTemplate.$call('add_tags', tag);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @example id "613f541c-4bed-fc77-7ca8-2db6b68f079c"
|
|
122
|
+
* @example tag "from-rest-api"
|
|
123
|
+
*/
|
|
124
|
+
async deleteVmTemplateTag(id, tag) {
|
|
125
|
+
const vmTemplate = this.getXapiObject(id);
|
|
126
|
+
await vmTemplate.$call('remove_tags', tag);
|
|
127
|
+
}
|
|
101
128
|
};
|
|
102
129
|
__decorate([
|
|
103
130
|
Example(vmTemplateIds),
|
|
@@ -170,9 +197,37 @@ __decorate([
|
|
|
170
197
|
__param(4, Query()),
|
|
171
198
|
__param(5, Query())
|
|
172
199
|
], VmTemplateController.prototype, "getVmTemplateMessages", null);
|
|
200
|
+
__decorate([
|
|
201
|
+
Example(taskIds),
|
|
202
|
+
Example(partialTasks),
|
|
203
|
+
Get('{id}/tasks'),
|
|
204
|
+
Tags('tasks'),
|
|
205
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
206
|
+
__param(0, Request()),
|
|
207
|
+
__param(1, Path()),
|
|
208
|
+
__param(2, Query()),
|
|
209
|
+
__param(3, Query()),
|
|
210
|
+
__param(4, Query()),
|
|
211
|
+
__param(5, Query())
|
|
212
|
+
], VmTemplateController.prototype, "getVmTemplateTasks", null);
|
|
213
|
+
__decorate([
|
|
214
|
+
Put('{id}/tags/{tag}'),
|
|
215
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
216
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
217
|
+
__param(0, Path()),
|
|
218
|
+
__param(1, Path())
|
|
219
|
+
], VmTemplateController.prototype, "putVmTemplateTag", null);
|
|
220
|
+
__decorate([
|
|
221
|
+
Delete('{id}/tags/{tag}'),
|
|
222
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
223
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
224
|
+
__param(0, Path()),
|
|
225
|
+
__param(1, Path())
|
|
226
|
+
], VmTemplateController.prototype, "deleteVmTemplateTag", null);
|
|
173
227
|
VmTemplateController = __decorate([
|
|
174
228
|
Route('vm-templates'),
|
|
175
229
|
Security('*'),
|
|
230
|
+
Response(badRequestResp.status, badRequestResp.description),
|
|
176
231
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
177
232
|
Tags('vms'),
|
|
178
233
|
provide(VmTemplateController),
|
|
@@ -12,7 +12,7 @@ import { inject } from 'inversify';
|
|
|
12
12
|
import { incorrectState, invalidParameters } from 'xo-common/api-errors.js';
|
|
13
13
|
import { provide } from 'inversify-binding-decorators';
|
|
14
14
|
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
15
|
-
import { asynchronousActionResp, createdResp, forbiddenOperationResp, incorrectStateResp, internalServerErrorResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
15
|
+
import { asynchronousActionResp, badRequestResp, createdResp, forbiddenOperationResp, incorrectStateResp, internalServerErrorResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
16
16
|
import { BASE_URL } from '../index.mjs';
|
|
17
17
|
import { escapeUnsafeComplexMatcher, limitAndFilterArray } from '../helpers/utils.helper.mjs';
|
|
18
18
|
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
@@ -21,7 +21,6 @@ import { RestApi } from '../rest-api/rest-api.mjs';
|
|
|
21
21
|
import { partialTasks, taskIds, taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
|
|
22
22
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
23
23
|
import { VmService } from './vm.service.mjs';
|
|
24
|
-
import { TaskService } from '../tasks/task.service.mjs';
|
|
25
24
|
import { BackupJobService } from '../backup-jobs/backup-job.service.mjs';
|
|
26
25
|
import { partialVmBackupJobs, vmBackupJobIds } from '../open-api/oa-examples/backup-job.oa-example.mjs';
|
|
27
26
|
import { messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs';
|
|
@@ -29,13 +28,11 @@ const IGNORED_VDIS_TAG = '[NOSNAP]';
|
|
|
29
28
|
let VmController = class VmController extends XapiXoController {
|
|
30
29
|
#alarmService;
|
|
31
30
|
#vmService;
|
|
32
|
-
#taskService;
|
|
33
31
|
#backupJobService;
|
|
34
|
-
constructor(restApi, alarmService, vmService,
|
|
32
|
+
constructor(restApi, alarmService, vmService, backupJobService) {
|
|
35
33
|
super('VM', restApi);
|
|
36
34
|
this.#alarmService = alarmService;
|
|
37
35
|
this.#vmService = vmService;
|
|
38
|
-
this.#taskService = taskService;
|
|
39
36
|
this.#backupJobService = backupJobService;
|
|
40
37
|
}
|
|
41
38
|
/**
|
|
@@ -386,12 +383,24 @@ let VmController = class VmController extends XapiXoController {
|
|
|
386
383
|
* @example limit 42
|
|
387
384
|
*/
|
|
388
385
|
async getVmTasks(req, id, fields, ndjson, filter, limit) {
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
386
|
+
const tasks = await this.getTasksForObject(id, { filter, limit });
|
|
387
|
+
return this.sendObjects(Object.values(tasks), req, 'tasks');
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* @example id "613f541c-4bed-fc77-7ca8-2db6b68f079c"
|
|
391
|
+
* @example tag "from-rest-api"
|
|
392
|
+
*/
|
|
393
|
+
async putVmTag(id, tag) {
|
|
394
|
+
const vm = this.getXapiObject(id);
|
|
395
|
+
await vm.$call('add_tags', tag);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* @example id "613f541c-4bed-fc77-7ca8-2db6b68f079c"
|
|
399
|
+
* @example tag "from-rest-api"
|
|
400
|
+
*/
|
|
401
|
+
async deleteVmTag(id, tag) {
|
|
402
|
+
const vm = this.getXapiObject(id);
|
|
403
|
+
await vm.$call('remove_tags', tag);
|
|
395
404
|
}
|
|
396
405
|
};
|
|
397
406
|
__decorate([
|
|
@@ -613,9 +622,24 @@ __decorate([
|
|
|
613
622
|
__param(4, Query()),
|
|
614
623
|
__param(5, Query())
|
|
615
624
|
], VmController.prototype, "getVmTasks", null);
|
|
625
|
+
__decorate([
|
|
626
|
+
Put('{id}/tags/{tag}'),
|
|
627
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
628
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
629
|
+
__param(0, Path()),
|
|
630
|
+
__param(1, Path())
|
|
631
|
+
], VmController.prototype, "putVmTag", null);
|
|
632
|
+
__decorate([
|
|
633
|
+
Delete('{id}/tags/{tag}'),
|
|
634
|
+
SuccessResponse(noContentResp.status, noContentResp.description),
|
|
635
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
636
|
+
__param(0, Path()),
|
|
637
|
+
__param(1, Path())
|
|
638
|
+
], VmController.prototype, "deleteVmTag", null);
|
|
616
639
|
VmController = __decorate([
|
|
617
640
|
Route('vms'),
|
|
618
641
|
Security('*'),
|
|
642
|
+
Response(badRequestResp.status, badRequestResp.description),
|
|
619
643
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
620
644
|
Tags('vms')
|
|
621
645
|
// the `provide` decorator is mandatory on class that injects/receives dependencies.
|
|
@@ -625,7 +649,6 @@ VmController = __decorate([
|
|
|
625
649
|
__param(0, inject(RestApi)),
|
|
626
650
|
__param(1, inject(AlarmService)),
|
|
627
651
|
__param(2, inject(VmService)),
|
|
628
|
-
__param(3, inject(
|
|
629
|
-
__param(4, inject(BackupJobService))
|
|
652
|
+
__param(3, inject(BackupJobService))
|
|
630
653
|
], VmController);
|
|
631
654
|
export { VmController };
|
|
@@ -11,7 +11,7 @@ import { Controller, Example, Get, Query, Request, Response, Route, Security, Ta
|
|
|
11
11
|
import { inject } from 'inversify';
|
|
12
12
|
import { PassThrough } from 'node:stream';
|
|
13
13
|
import { provide } from 'inversify-binding-decorators';
|
|
14
|
-
import { unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
14
|
+
import { badRequestResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
15
15
|
import { xoaDashboard } from '../open-api/oa-examples/xoa.oa-example.mjs';
|
|
16
16
|
import { XoaService } from './xoa.service.mjs';
|
|
17
17
|
import { NDJSON_CONTENT_TYPE } from '../helpers/utils.helper.mjs';
|
|
@@ -47,6 +47,7 @@ __decorate([
|
|
|
47
47
|
XoaController = __decorate([
|
|
48
48
|
Route(''),
|
|
49
49
|
Security('*'),
|
|
50
|
+
Response(badRequestResp.status, badRequestResp.description),
|
|
50
51
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
51
52
|
Tags('xoa'),
|
|
52
53
|
provide(XoaController),
|