@xen-orchestra/rest-api 0.13.1 → 0.14.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/xo-controller.mjs +3 -9
- package/dist/helpers/object-wrapper.helper.mjs +10 -7
- package/dist/helpers/utils.helper.mjs +11 -0
- package/dist/hosts/host.controller.mjs +19 -1
- package/dist/open-api/oa-examples/host.oa-example.mjs +1 -0
- package/dist/open-api/oa-examples/vm-controller.oa-example.mjs +14 -0
- package/dist/open-api/oa-examples/vm-snapshot.oa-example.mjs +14 -0
- package/dist/open-api/oa-examples/vm-template.oa-example.mjs +14 -0
- package/dist/open-api/oa-examples/vm.oa-example.mjs +14 -0
- package/dist/open-api/routes/routes.js +211 -41
- package/dist/rest-api/rest-api.mjs +10 -2
- package/dist/users/user.controller.mjs +0 -3
- package/dist/vm-controller/vm-controller.controller.mjs +30 -4
- package/dist/vm-snapshots/vm-snapshot.controller.mjs +30 -4
- package/dist/vm-templates/vm-template.controller.mjs +30 -4
- package/dist/vms/vm.controller.mjs +30 -4
- package/dist/vms/vm.service.mjs +14 -1
- package/open-api/spec/swagger.json +1069 -406
- package/package.json +2 -2
|
@@ -7,23 +7,17 @@ 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 * as CM from 'complex-matcher';
|
|
11
10
|
import { inject } from 'inversify';
|
|
12
11
|
import { BaseController } from './base-controller.mjs';
|
|
13
12
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
13
|
+
import { limitAndFilterArray } from '../helpers/utils.helper.mjs';
|
|
14
14
|
let XoController = class XoController extends BaseController {
|
|
15
15
|
constructor(restApi) {
|
|
16
16
|
super(restApi);
|
|
17
17
|
}
|
|
18
|
-
async getObjects(
|
|
18
|
+
async getObjects(opts = {}) {
|
|
19
19
|
let objects = await this.getAllCollectionObjects();
|
|
20
|
-
|
|
21
|
-
const predicate = CM.parse(filter).createPredicate();
|
|
22
|
-
objects = objects.filter(predicate);
|
|
23
|
-
}
|
|
24
|
-
if (limit < objects.length) {
|
|
25
|
-
objects.length = limit;
|
|
26
|
-
}
|
|
20
|
+
objects = limitAndFilterArray(objects, opts);
|
|
27
21
|
const objectById = {};
|
|
28
22
|
objects.forEach(obj => {
|
|
29
23
|
objectById[obj.id] = obj;
|
|
@@ -3,13 +3,16 @@ import pick from 'lodash/pick.js';
|
|
|
3
3
|
import { BASE_URL } from '../index.mjs';
|
|
4
4
|
const { join } = path.posix;
|
|
5
5
|
export function makeObjectMapper(req, path) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const makeUrl = (obj) => {
|
|
7
|
+
let _path;
|
|
8
|
+
if (path === undefined) {
|
|
9
|
+
_path = req.path;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
_path = `${BASE_URL}/${typeof path === 'string' ? path : path(obj)}`;
|
|
13
|
+
}
|
|
14
|
+
return join(_path, typeof obj.id === 'number' ? String(obj.id) : obj.id);
|
|
15
|
+
};
|
|
13
16
|
let objectMapper;
|
|
14
17
|
const { query } = req;
|
|
15
18
|
const { fields } = query;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as CM from 'complex-matcher';
|
|
1
2
|
import { createLogger } from '@xen-orchestra/log';
|
|
2
3
|
import { isPromise } from 'node:util/types';
|
|
3
4
|
export const NDJSON_CONTENT_TYPE = 'application/x-ndjson';
|
|
@@ -75,3 +76,13 @@ export function escapeUnsafeComplexMatcher(maybeString) {
|
|
|
75
76
|
}
|
|
76
77
|
return `(${maybeString})`;
|
|
77
78
|
}
|
|
79
|
+
export function limitAndFilterArray(array, { filter, limit = Infinity } = {}) {
|
|
80
|
+
if (filter !== undefined) {
|
|
81
|
+
const predicate = typeof filter === 'string' ? CM.parse(filter).createPredicate() : filter;
|
|
82
|
+
array = array.filter(predicate);
|
|
83
|
+
}
|
|
84
|
+
if (limit < array.length) {
|
|
85
|
+
array = array.slice(0, limit);
|
|
86
|
+
}
|
|
87
|
+
return array;
|
|
88
|
+
}
|
|
@@ -14,7 +14,7 @@ import { provide } from 'inversify-binding-decorators';
|
|
|
14
14
|
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
15
15
|
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
16
16
|
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
17
|
-
import { host, hostIds, hostStats, partialHosts } from '../open-api/oa-examples/host.oa-example.mjs';
|
|
17
|
+
import { host, hostIds, hostSmt, hostStats, partialHosts } from '../open-api/oa-examples/host.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
20
|
import { internalServerErrorResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
|
|
@@ -94,6 +94,17 @@ let HostController = class HostController extends XapiXoController {
|
|
|
94
94
|
});
|
|
95
95
|
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns a boolean indicating whether SMT (Simultaneous Multi-Threading) is enabled
|
|
99
|
+
*
|
|
100
|
+
* @example id "b61a5c92-700e-4966-a13b-00633f03eea8"
|
|
101
|
+
*/
|
|
102
|
+
async gethostSmt(id) {
|
|
103
|
+
const hostId = id;
|
|
104
|
+
const xapiHost = this.getXapiObject(hostId);
|
|
105
|
+
const enabled = Boolean(await xapiHost.$xapi.isHyperThreadingEnabled(hostId));
|
|
106
|
+
return { enabled };
|
|
107
|
+
}
|
|
97
108
|
};
|
|
98
109
|
__decorate([
|
|
99
110
|
Example(hostIds),
|
|
@@ -148,6 +159,13 @@ __decorate([
|
|
|
148
159
|
__param(4, Query()),
|
|
149
160
|
__param(5, Query())
|
|
150
161
|
], HostController.prototype, "getHostAlarms", null);
|
|
162
|
+
__decorate([
|
|
163
|
+
Example(hostSmt),
|
|
164
|
+
Get('{id}/smt'),
|
|
165
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
166
|
+
Response(internalServerErrorResp.status, internalServerErrorResp.description),
|
|
167
|
+
__param(0, Path())
|
|
168
|
+
], HostController.prototype, "gethostSmt", null);
|
|
151
169
|
HostController = __decorate([
|
|
152
170
|
Route('hosts'),
|
|
153
171
|
Security('*'),
|
|
@@ -69,3 +69,17 @@ export const vmController = {
|
|
|
69
69
|
$poolId: 'b7569d99-30f8-178a-7d94-801de3e29b5b',
|
|
70
70
|
_xapiRef: 'OpaqueRef:ca27fcfc-5083-d039-e752-2e6c3364bde9',
|
|
71
71
|
};
|
|
72
|
+
export const vmControllerVdis = [
|
|
73
|
+
{
|
|
74
|
+
VDI_type: 'user',
|
|
75
|
+
id: '6b67c24d-5f09-4845-b753-0b73abf658f0',
|
|
76
|
+
name_label: 'debian 12 hub disk',
|
|
77
|
+
href: '/rest/v0/vdi-snapshots/6b67c24d-5f09-4845-b753-0b73abf658f0',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
VDI_type: 'user',
|
|
81
|
+
id: '11d85da8-7caf-4a47-b030-15e78adb3f72',
|
|
82
|
+
name_label: 'xoa root',
|
|
83
|
+
href: '/rest/v0/vdi-snapshots/11d85da8-7caf-4a47-b030-15e78adb3f72',
|
|
84
|
+
},
|
|
85
|
+
];
|
|
@@ -176,3 +176,17 @@ export const vmSnapshot = {
|
|
|
176
176
|
suspendVdi: 'string',
|
|
177
177
|
type: 'VM-snapshot',
|
|
178
178
|
};
|
|
179
|
+
export const vmSnapshotVdis = [
|
|
180
|
+
{
|
|
181
|
+
VDI_type: 'user',
|
|
182
|
+
id: 'a2831a61-6b1c-41e3-a328-bdfd13e76488',
|
|
183
|
+
name_label: 'Debian Buster 10_oreva',
|
|
184
|
+
href: '/rest/v0/vdi-snapshots/a2831a61-6b1c-41e3-a328-bdfd13e76488',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
VDI_type: 'user',
|
|
188
|
+
id: '41c52deb-0083-471e-bd72-252ea06a48b9',
|
|
189
|
+
name_label: 'MRA XCP 8.2_uvuvo',
|
|
190
|
+
href: '/rest/v0/vdi-snapshots/41c52deb-0083-471e-bd72-252ea06a48b9',
|
|
191
|
+
},
|
|
192
|
+
];
|
|
@@ -89,3 +89,17 @@ export const vmTemplate = {
|
|
|
89
89
|
$poolId: 'b7569d99-30f8-178a-7d94-801de3e29b5b',
|
|
90
90
|
_xapiRef: 'OpaqueRef:3a9b74fe-57d5-52f7-31ec-fbb0de9e8a1e',
|
|
91
91
|
};
|
|
92
|
+
export const vmTemplateVdis = [
|
|
93
|
+
{
|
|
94
|
+
VDI_type: 'user',
|
|
95
|
+
id: 'cbfeabfc-20c8-46eb-a094-84076eb29f04',
|
|
96
|
+
name_label: 'Hard disk 1',
|
|
97
|
+
href: '/rest/v0/vdis/cbfeabfc-20c8-46eb-a094-84076eb29f04',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
VDI_type: 'user',
|
|
101
|
+
id: 'bee66a2e-68a4-4ff8-9ed4-2f429587524f',
|
|
102
|
+
name_label: 'Hard disk 2',
|
|
103
|
+
href: '/rest/v0/vdis/bee66a2e-68a4-4ff8-9ed4-2f429587524f',
|
|
104
|
+
},
|
|
105
|
+
];
|
|
@@ -243,3 +243,17 @@ export const vmStatsExample = {
|
|
|
243
243
|
],
|
|
244
244
|
},
|
|
245
245
|
};
|
|
246
|
+
export const vmVdis = [
|
|
247
|
+
{
|
|
248
|
+
VDI_type: 'user',
|
|
249
|
+
id: '11045407-4764-4c1c-8865-63f89d686b1b',
|
|
250
|
+
name_label: 'Debian Bookworm 12_ogupi',
|
|
251
|
+
href: '/rest/v0/vdis/11045407-4764-4c1c-8865-63f89d686b1b',
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
VDI_type: 'user',
|
|
255
|
+
id: '0eb73d40-e5f8-443d-b611-a52e03858a6a',
|
|
256
|
+
name_label: 'MRA TrueNAS_emodi',
|
|
257
|
+
href: '/rest/v0/vdis/0eb73d40-e5f8-443d-b611-a52e03858a6a',
|
|
258
|
+
},
|
|
259
|
+
];
|