@meowpanel/api 0.1.0-alpha.11 → 1.0.0-beta.2
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/LICENSE +1 -1
- package/README.md +40 -0
- package/esm/mod.d.ts +87 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +85 -1
- package/esm/src/client.d.ts +248 -0
- package/esm/src/client.d.ts.map +1 -0
- package/esm/src/client.js +235 -0
- package/esm/src/emitter.d.ts +53 -0
- package/esm/src/emitter.d.ts.map +1 -0
- package/esm/src/emitter.js +55 -0
- package/esm/src/errors.d.ts +42 -0
- package/esm/src/errors.d.ts.map +1 -0
- package/esm/src/errors.js +45 -0
- package/esm/src/http.d.ts +157 -0
- package/esm/src/http.d.ts.map +1 -0
- package/esm/src/http.js +317 -0
- package/esm/src/namespace.d.ts +59 -0
- package/esm/src/namespace.d.ts.map +1 -0
- package/esm/src/namespace.js +79 -0
- package/esm/src/reactive.d.ts +29 -0
- package/esm/src/reactive.d.ts.map +1 -0
- package/esm/src/reactive.js +35 -0
- package/esm/src/resources/account.d.ts +125 -0
- package/esm/src/resources/account.d.ts.map +1 -0
- package/esm/src/resources/account.js +151 -0
- package/esm/src/resources/api-keys.d.ts +116 -0
- package/esm/src/resources/api-keys.d.ts.map +1 -0
- package/esm/src/resources/api-keys.js +105 -0
- package/esm/src/resources/auth.d.ts +57 -0
- package/esm/src/resources/auth.d.ts.map +1 -0
- package/esm/src/resources/auth.js +39 -0
- package/esm/src/resources/eggs.d.ts +238 -0
- package/esm/src/resources/eggs.d.ts.map +1 -0
- package/esm/src/resources/eggs.js +187 -0
- package/esm/src/resources/hosts.d.ts +62 -0
- package/esm/src/resources/hosts.d.ts.map +1 -0
- package/esm/src/resources/hosts.js +62 -0
- package/esm/src/resources/members.d.ts +138 -0
- package/esm/src/resources/members.d.ts.map +1 -0
- package/esm/src/resources/members.js +122 -0
- package/esm/src/resources/nodes.d.ts +397 -0
- package/esm/src/resources/nodes.d.ts.map +1 -0
- package/esm/src/resources/nodes.js +352 -0
- package/esm/src/resources/server-groups.d.ts +150 -0
- package/esm/src/resources/server-groups.d.ts.map +1 -0
- package/esm/src/resources/server-groups.js +111 -0
- package/esm/src/resources/servers/activity.d.ts +120 -0
- package/esm/src/resources/servers/activity.d.ts.map +1 -0
- package/esm/src/resources/servers/activity.js +163 -0
- package/esm/src/resources/servers/allocations.d.ts +125 -0
- package/esm/src/resources/servers/allocations.d.ts.map +1 -0
- package/esm/src/resources/servers/allocations.js +137 -0
- package/esm/src/resources/servers/connection.d.ts +108 -0
- package/esm/src/resources/servers/connection.d.ts.map +1 -0
- package/esm/src/resources/servers/connection.js +169 -0
- package/esm/src/resources/servers/files.d.ts +164 -0
- package/esm/src/resources/servers/files.d.ts.map +1 -0
- package/esm/src/resources/servers/files.js +281 -0
- package/esm/src/resources/servers/index.d.ts +126 -0
- package/esm/src/resources/servers/index.d.ts.map +1 -0
- package/esm/src/resources/servers/index.js +135 -0
- package/esm/src/resources/servers/profiles.d.ts +138 -0
- package/esm/src/resources/servers/profiles.d.ts.map +1 -0
- package/esm/src/resources/servers/profiles.js +177 -0
- package/esm/src/resources/servers/server.d.ts +136 -0
- package/esm/src/resources/servers/server.d.ts.map +1 -0
- package/esm/src/resources/servers/server.js +202 -0
- package/esm/src/resources/servers/sftp.d.ts +147 -0
- package/esm/src/resources/servers/sftp.d.ts.map +1 -0
- package/esm/src/resources/servers/sftp.js +153 -0
- package/esm/src/resources/servers/types.d.ts +199 -0
- package/esm/src/resources/servers/types.d.ts.map +1 -0
- package/esm/src/resources/servers/types.js +1 -0
- package/esm/src/sse.d.ts +53 -0
- package/esm/src/sse.d.ts.map +1 -0
- package/esm/src/sse.js +133 -0
- package/esm/src/types.d.ts +126 -0
- package/esm/src/types.d.ts.map +1 -0
- package/esm/src/types.js +21 -0
- package/package.json +4 -92
- package/script/mod.d.ts +87 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +132 -3
- package/script/src/client.d.ts +248 -0
- package/script/src/client.d.ts.map +1 -0
- package/script/src/client.js +239 -0
- package/script/src/emitter.d.ts +53 -0
- package/script/src/emitter.d.ts.map +1 -0
- package/script/src/emitter.js +59 -0
- package/script/src/errors.d.ts +42 -0
- package/script/src/errors.d.ts.map +1 -0
- package/script/src/errors.js +49 -0
- package/script/src/http.d.ts +157 -0
- package/script/src/http.d.ts.map +1 -0
- package/script/src/http.js +321 -0
- package/script/src/namespace.d.ts +59 -0
- package/script/src/namespace.d.ts.map +1 -0
- package/script/src/namespace.js +83 -0
- package/script/src/reactive.d.ts +29 -0
- package/script/src/reactive.d.ts.map +1 -0
- package/script/src/reactive.js +39 -0
- package/script/src/resources/account.d.ts +125 -0
- package/script/src/resources/account.d.ts.map +1 -0
- package/script/src/resources/account.js +158 -0
- package/script/src/resources/api-keys.d.ts +116 -0
- package/script/src/resources/api-keys.d.ts.map +1 -0
- package/script/src/resources/api-keys.js +110 -0
- package/script/src/resources/auth.d.ts +57 -0
- package/script/src/resources/auth.d.ts.map +1 -0
- package/script/src/resources/auth.js +43 -0
- package/script/src/resources/eggs.d.ts +238 -0
- package/script/src/resources/eggs.d.ts.map +1 -0
- package/script/src/resources/eggs.js +193 -0
- package/script/src/resources/hosts.d.ts +62 -0
- package/script/src/resources/hosts.d.ts.map +1 -0
- package/script/src/resources/hosts.js +67 -0
- package/script/src/resources/members.d.ts +138 -0
- package/script/src/resources/members.d.ts.map +1 -0
- package/script/src/resources/members.js +127 -0
- package/script/src/resources/nodes.d.ts +397 -0
- package/script/src/resources/nodes.d.ts.map +1 -0
- package/script/src/resources/nodes.js +362 -0
- package/script/src/resources/server-groups.d.ts +150 -0
- package/script/src/resources/server-groups.d.ts.map +1 -0
- package/script/src/resources/server-groups.js +116 -0
- package/script/src/resources/servers/activity.d.ts +120 -0
- package/script/src/resources/servers/activity.d.ts.map +1 -0
- package/script/src/resources/servers/activity.js +170 -0
- package/script/src/resources/servers/allocations.d.ts +125 -0
- package/script/src/resources/servers/allocations.d.ts.map +1 -0
- package/script/src/resources/servers/allocations.js +142 -0
- package/script/src/resources/servers/connection.d.ts +108 -0
- package/script/src/resources/servers/connection.d.ts.map +1 -0
- package/script/src/resources/servers/connection.js +173 -0
- package/script/src/resources/servers/files.d.ts +164 -0
- package/script/src/resources/servers/files.d.ts.map +1 -0
- package/script/src/resources/servers/files.js +286 -0
- package/script/src/resources/servers/index.d.ts +126 -0
- package/script/src/resources/servers/index.d.ts.map +1 -0
- package/script/src/resources/servers/index.js +139 -0
- package/script/src/resources/servers/profiles.d.ts +138 -0
- package/script/src/resources/servers/profiles.d.ts.map +1 -0
- package/script/src/resources/servers/profiles.js +182 -0
- package/script/src/resources/servers/server.d.ts +136 -0
- package/script/src/resources/servers/server.d.ts.map +1 -0
- package/script/src/resources/servers/server.js +206 -0
- package/script/src/resources/servers/sftp.d.ts +147 -0
- package/script/src/resources/servers/sftp.d.ts.map +1 -0
- package/script/src/resources/servers/sftp.js +158 -0
- package/script/src/resources/servers/types.d.ts +199 -0
- package/script/src/resources/servers/types.d.ts.map +1 -0
- package/script/src/resources/servers/types.js +2 -0
- package/script/src/sse.d.ts +53 -0
- package/script/src/sse.d.ts.map +1 -0
- package/script/src/sse.js +137 -0
- package/script/src/types.d.ts +126 -0
- package/script/src/types.d.ts.map +1 -0
- package/script/src/types.js +25 -0
- package/esm/api.d.ts +0 -76
- package/esm/api.d.ts.map +0 -1
- package/esm/api.js +0 -187
- package/esm/components/auth.d.ts +0 -15
- package/esm/components/auth.d.ts.map +0 -1
- package/esm/components/auth.js +0 -13
- package/esm/components/connection/abstract.d.ts +0 -23
- package/esm/components/connection/abstract.d.ts.map +0 -1
- package/esm/components/connection/abstract.js +0 -43
- package/esm/components/connection/sse.d.ts +0 -20
- package/esm/components/connection/sse.d.ts.map +0 -1
- package/esm/components/connection/sse.js +0 -65
- package/esm/components/egg/egg.d.ts +0 -32
- package/esm/components/egg/egg.d.ts.map +0 -1
- package/esm/components/egg/egg.js +0 -70
- package/esm/components/group.d.ts +0 -14
- package/esm/components/group.d.ts.map +0 -1
- package/esm/components/group.js +0 -33
- package/esm/components/member_2.d.ts +0 -69
- package/esm/components/member_2.d.ts.map +0 -1
- package/esm/components/member_2.js +0 -140
- package/esm/components/node.d.ts +0 -78
- package/esm/components/node.d.ts.map +0 -1
- package/esm/components/node.js +0 -342
- package/esm/components/server/activity.d.ts +0 -45
- package/esm/components/server/activity.d.ts.map +0 -1
- package/esm/components/server/activity.js +0 -158
- package/esm/components/server/allocations.d.ts +0 -45
- package/esm/components/server/allocations.d.ts.map +0 -1
- package/esm/components/server/allocations.js +0 -146
- package/esm/components/server/files.d.ts +0 -50
- package/esm/components/server/files.d.ts.map +0 -1
- package/esm/components/server/files.js +0 -90
- package/esm/components/server/power.d.ts +0 -21
- package/esm/components/server/power.d.ts.map +0 -1
- package/esm/components/server/power.js +0 -43
- package/esm/components/server/profiles.d.ts +0 -63
- package/esm/components/server/profiles.d.ts.map +0 -1
- package/esm/components/server/profiles.js +0 -163
- package/esm/components/server/server.d.ts +0 -141
- package/esm/components/server/server.d.ts.map +0 -1
- package/esm/components/server/server.js +0 -358
- package/esm/components/server/sftp.d.ts +0 -31
- package/esm/components/server/sftp.d.ts.map +0 -1
- package/esm/components/server/sftp.js +0 -84
- package/esm/components/server/startup.d.ts +0 -17
- package/esm/components/server/startup.d.ts.map +0 -1
- package/esm/components/server/startup.js +0 -21
- package/esm/components/server/stats.d.ts +0 -19
- package/esm/components/server/stats.d.ts.map +0 -1
- package/esm/components/server/stats.js +0 -46
- package/esm/utils/cache.d.ts +0 -20
- package/esm/utils/cache.d.ts.map +0 -1
- package/esm/utils/cache.js +0 -66
- package/esm/utils/event.d.ts +0 -38
- package/esm/utils/event.d.ts.map +0 -1
- package/esm/utils/event.js +0 -71
- package/esm/utils/object.d.ts +0 -58
- package/esm/utils/object.d.ts.map +0 -1
- package/esm/utils/object.js +0 -86
- package/esm/utils/subscribe.d.ts +0 -37
- package/esm/utils/subscribe.d.ts.map +0 -1
- package/esm/utils/subscribe.js +0 -29
- package/esm/utils/timer.d.ts +0 -13
- package/esm/utils/timer.d.ts.map +0 -1
- package/esm/utils/timer.js +0 -32
- package/esm/utils/units.d.ts +0 -18
- package/esm/utils/units.d.ts.map +0 -1
- package/esm/utils/units.js +0 -82
- package/script/api.d.ts +0 -76
- package/script/api.d.ts.map +0 -1
- package/script/api.js +0 -192
- package/script/components/auth.d.ts +0 -15
- package/script/components/auth.d.ts.map +0 -1
- package/script/components/auth.js +0 -17
- package/script/components/connection/abstract.d.ts +0 -23
- package/script/components/connection/abstract.d.ts.map +0 -1
- package/script/components/connection/abstract.js +0 -47
- package/script/components/connection/sse.d.ts +0 -20
- package/script/components/connection/sse.d.ts.map +0 -1
- package/script/components/connection/sse.js +0 -69
- package/script/components/egg/egg.d.ts +0 -32
- package/script/components/egg/egg.d.ts.map +0 -1
- package/script/components/egg/egg.js +0 -74
- package/script/components/group.d.ts +0 -14
- package/script/components/group.d.ts.map +0 -1
- package/script/components/group.js +0 -37
- package/script/components/member_2.d.ts +0 -69
- package/script/components/member_2.d.ts.map +0 -1
- package/script/components/member_2.js +0 -146
- package/script/components/node.d.ts +0 -78
- package/script/components/node.d.ts.map +0 -1
- package/script/components/node.js +0 -349
- package/script/components/server/activity.d.ts +0 -45
- package/script/components/server/activity.d.ts.map +0 -1
- package/script/components/server/activity.js +0 -164
- package/script/components/server/allocations.d.ts +0 -45
- package/script/components/server/allocations.d.ts.map +0 -1
- package/script/components/server/allocations.js +0 -152
- package/script/components/server/files.d.ts +0 -50
- package/script/components/server/files.d.ts.map +0 -1
- package/script/components/server/files.js +0 -94
- package/script/components/server/power.d.ts +0 -21
- package/script/components/server/power.d.ts.map +0 -1
- package/script/components/server/power.js +0 -47
- package/script/components/server/profiles.d.ts +0 -63
- package/script/components/server/profiles.d.ts.map +0 -1
- package/script/components/server/profiles.js +0 -168
- package/script/components/server/server.d.ts +0 -141
- package/script/components/server/server.d.ts.map +0 -1
- package/script/components/server/server.js +0 -362
- package/script/components/server/sftp.d.ts +0 -31
- package/script/components/server/sftp.d.ts.map +0 -1
- package/script/components/server/sftp.js +0 -88
- package/script/components/server/startup.d.ts +0 -17
- package/script/components/server/startup.d.ts.map +0 -1
- package/script/components/server/startup.js +0 -25
- package/script/components/server/stats.d.ts +0 -19
- package/script/components/server/stats.d.ts.map +0 -1
- package/script/components/server/stats.js +0 -50
- package/script/utils/cache.d.ts +0 -20
- package/script/utils/cache.d.ts.map +0 -1
- package/script/utils/cache.js +0 -70
- package/script/utils/event.d.ts +0 -38
- package/script/utils/event.d.ts.map +0 -1
- package/script/utils/event.js +0 -75
- package/script/utils/object.d.ts +0 -58
- package/script/utils/object.d.ts.map +0 -1
- package/script/utils/object.js +0 -90
- package/script/utils/subscribe.d.ts +0 -37
- package/script/utils/subscribe.d.ts.map +0 -1
- package/script/utils/subscribe.js +0 -32
- package/script/utils/timer.d.ts +0 -13
- package/script/utils/timer.d.ts.map +0 -1
- package/script/utils/timer.js +0 -36
- package/script/utils/units.d.ts +0 -18
- package/script/utils/units.d.ts.map +0 -1
- package/script/utils/units.js +0 -86
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodesNamespace = exports.NodeAllocationsManager = exports.Node = exports.NodeAllocationIp = exports.NodeAllocationPort = exports.NodeType = exports.NodeLocation = void 0;
|
|
4
|
+
const namespace_js_1 = require("../namespace.js");
|
|
5
|
+
const reactive_js_1 = require("../reactive.js");
|
|
6
|
+
const types_js_1 = require("../types.js");
|
|
7
|
+
const members_js_1 = require("./members.js");
|
|
8
|
+
const activity_js_1 = require("./servers/activity.js");
|
|
9
|
+
/**
|
|
10
|
+
* A geographic location associated with one or more nodes.
|
|
11
|
+
*/
|
|
12
|
+
class NodeLocation extends reactive_js_1.ReactiveResource {
|
|
13
|
+
/** Unique NanoID of this location. */
|
|
14
|
+
id;
|
|
15
|
+
/** Full display name of the location, e.g. `"US East"`. */
|
|
16
|
+
name;
|
|
17
|
+
/** Short code used in node name generation, e.g. `"use"`. */
|
|
18
|
+
short;
|
|
19
|
+
/** Internal notes. */
|
|
20
|
+
notes;
|
|
21
|
+
/** Owner of this location record. */
|
|
22
|
+
owner;
|
|
23
|
+
/** When this location was created. */
|
|
24
|
+
createdAt;
|
|
25
|
+
/** When this location was last updated. */
|
|
26
|
+
updatedAt;
|
|
27
|
+
/** @internal */
|
|
28
|
+
constructor(data) {
|
|
29
|
+
super();
|
|
30
|
+
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
31
|
+
this.name = data.name;
|
|
32
|
+
this.short = data.short;
|
|
33
|
+
this.notes = data.notes;
|
|
34
|
+
this.owner = data.owner ? new members_js_1.Member(data.owner) : undefined;
|
|
35
|
+
this.createdAt = new Date(data.created_at);
|
|
36
|
+
this.updatedAt = new Date(data.updated_at);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.NodeLocation = NodeLocation;
|
|
40
|
+
/**
|
|
41
|
+
* A classification type for nodes (e.g. `"Apex"`, `"Shared"`).
|
|
42
|
+
*/
|
|
43
|
+
class NodeType extends reactive_js_1.ReactiveResource {
|
|
44
|
+
/** Unique NanoID of this node type. */
|
|
45
|
+
id;
|
|
46
|
+
/** Full display name of the node type, e.g. `"Apex"`. */
|
|
47
|
+
name;
|
|
48
|
+
/** Short code used in node name generation, e.g. `"a"`. */
|
|
49
|
+
short;
|
|
50
|
+
/** Internal notes. */
|
|
51
|
+
notes;
|
|
52
|
+
/** Owner of this type record. */
|
|
53
|
+
owner;
|
|
54
|
+
/** When this type was created. */
|
|
55
|
+
createdAt;
|
|
56
|
+
/** When this type was last updated. */
|
|
57
|
+
updatedAt;
|
|
58
|
+
/** @internal */
|
|
59
|
+
constructor(data) {
|
|
60
|
+
super();
|
|
61
|
+
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
62
|
+
this.name = data.name;
|
|
63
|
+
this.short = data.short;
|
|
64
|
+
this.notes = data.notes;
|
|
65
|
+
this.owner = data.owner ? new members_js_1.Member(data.owner) : undefined;
|
|
66
|
+
this.createdAt = new Date(data.created_at);
|
|
67
|
+
this.updatedAt = new Date(data.updated_at);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.NodeType = NodeType;
|
|
71
|
+
/**
|
|
72
|
+
* A single port on a node allocation IP.
|
|
73
|
+
*/
|
|
74
|
+
class NodeAllocationPort extends reactive_js_1.ReactiveResource {
|
|
75
|
+
id;
|
|
76
|
+
ip;
|
|
77
|
+
port;
|
|
78
|
+
readyProtocols;
|
|
79
|
+
isInUse;
|
|
80
|
+
notes;
|
|
81
|
+
createdAt;
|
|
82
|
+
updatedAt;
|
|
83
|
+
/** @internal */
|
|
84
|
+
constructor(data) {
|
|
85
|
+
super();
|
|
86
|
+
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
87
|
+
this.ip = data.ip;
|
|
88
|
+
this.port = data.port;
|
|
89
|
+
this.readyProtocols = data.ready_protocols;
|
|
90
|
+
this.isInUse = data.is_in_use;
|
|
91
|
+
this.notes = data.notes;
|
|
92
|
+
this.createdAt = new Date(data.created_at);
|
|
93
|
+
this.updatedAt = new Date(data.updated_at);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.NodeAllocationPort = NodeAllocationPort;
|
|
97
|
+
/**
|
|
98
|
+
* An allocation IP assigned to a node, including its available ports.
|
|
99
|
+
*/
|
|
100
|
+
class NodeAllocationIp extends reactive_js_1.ReactiveResource {
|
|
101
|
+
id;
|
|
102
|
+
ip;
|
|
103
|
+
ipAlias;
|
|
104
|
+
ports;
|
|
105
|
+
node;
|
|
106
|
+
notes;
|
|
107
|
+
createdAt;
|
|
108
|
+
updatedAt;
|
|
109
|
+
/** @internal */
|
|
110
|
+
constructor(data) {
|
|
111
|
+
super();
|
|
112
|
+
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
113
|
+
this.ip = data.ip;
|
|
114
|
+
this.ipAlias = data.ipAlias;
|
|
115
|
+
this.ports = data.ports.map((port) => new NodeAllocationPort(port));
|
|
116
|
+
this.node = new Node(data.node);
|
|
117
|
+
this.notes = data.notes;
|
|
118
|
+
this.createdAt = new Date(data.created_at);
|
|
119
|
+
this.updatedAt = new Date(data.updated_at);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.NodeAllocationIp = NodeAllocationIp;
|
|
123
|
+
/**
|
|
124
|
+
* A MeowPanel daemon node (physical or virtual server hosting game servers).
|
|
125
|
+
*
|
|
126
|
+
* Retrieved via {@link NodesNamespace.get} or {@link NodesNamespace.list}.
|
|
127
|
+
*/
|
|
128
|
+
class Node extends reactive_js_1.ReactiveResource {
|
|
129
|
+
/** The node's unique NanoID. */
|
|
130
|
+
id;
|
|
131
|
+
/**
|
|
132
|
+
* Auto-generated display name in the format `{type}{num}{location}.{hostname}`,
|
|
133
|
+
* e.g. `"a001use.host.example.com"`.
|
|
134
|
+
*/
|
|
135
|
+
name;
|
|
136
|
+
/** Optional description of the node. */
|
|
137
|
+
description;
|
|
138
|
+
/** Owner of this node record. */
|
|
139
|
+
owner;
|
|
140
|
+
/** Geographic location of this node. */
|
|
141
|
+
location;
|
|
142
|
+
/** Classification type of this node. */
|
|
143
|
+
type;
|
|
144
|
+
/** Sequential number of this node within its type and location. */
|
|
145
|
+
num;
|
|
146
|
+
/** Resource limits configured for this node. */
|
|
147
|
+
limits;
|
|
148
|
+
/**
|
|
149
|
+
/** Direct connection details for the node daemon API. */
|
|
150
|
+
connection;
|
|
151
|
+
/** `true` when the node is in maintenance mode (no new servers will be started). */
|
|
152
|
+
isMaintenanceMode;
|
|
153
|
+
/** `true` when the node can be auto-deployed to. */
|
|
154
|
+
canAutoDeploy;
|
|
155
|
+
/** `true` when the node is behind a reverse proxy. */
|
|
156
|
+
isBehindProxy;
|
|
157
|
+
/** Internal notes visible to administrators. */
|
|
158
|
+
notes;
|
|
159
|
+
/** When this node was registered. */
|
|
160
|
+
createdAt;
|
|
161
|
+
/** When this node was last updated. */
|
|
162
|
+
updatedAt;
|
|
163
|
+
/** @internal */
|
|
164
|
+
constructor(data) {
|
|
165
|
+
super();
|
|
166
|
+
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
167
|
+
this.name = data.name;
|
|
168
|
+
this.description = data.description;
|
|
169
|
+
this.owner = data.owner ? new members_js_1.Member(data.owner) : undefined;
|
|
170
|
+
this.location = new NodeLocation(data.location);
|
|
171
|
+
this.type = new NodeType(data.type);
|
|
172
|
+
this.num = data.num;
|
|
173
|
+
this.limits = {
|
|
174
|
+
memoryMb: data.limits.memory_mb,
|
|
175
|
+
memoryOverallocateMb: data.limits.memory_overallocate_mb,
|
|
176
|
+
diskMb: data.limits.disk_mb,
|
|
177
|
+
diskOverallocateMb: data.limits.disk_overallocate_mb,
|
|
178
|
+
uploadSizeMb: data.limits.upload_size_mb,
|
|
179
|
+
};
|
|
180
|
+
this.connection = data.connection ?? undefined;
|
|
181
|
+
this.isMaintenanceMode = data.is_maintenance_mode;
|
|
182
|
+
this.canAutoDeploy = data.can_auto_deploy;
|
|
183
|
+
this.isBehindProxy = data.is_behind_proxy;
|
|
184
|
+
this.notes = data.notes;
|
|
185
|
+
this.createdAt = new Date(data.created_at);
|
|
186
|
+
this.updatedAt = new Date(data.updated_at);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.Node = Node;
|
|
190
|
+
/**
|
|
191
|
+
* Manage allocation IPs and ports on a specific node.
|
|
192
|
+
*/
|
|
193
|
+
class NodeAllocationsManager {
|
|
194
|
+
nodeId;
|
|
195
|
+
http;
|
|
196
|
+
/** @internal */
|
|
197
|
+
constructor(nodeId, http) {
|
|
198
|
+
this.nodeId = nodeId;
|
|
199
|
+
this.http = http;
|
|
200
|
+
}
|
|
201
|
+
async list() {
|
|
202
|
+
const data = await this.http.get(`/nodes/${this.nodeId}/allocations`);
|
|
203
|
+
return data.map((allocation) => new NodeAllocationIp(allocation));
|
|
204
|
+
}
|
|
205
|
+
async get(allocationIp) {
|
|
206
|
+
const data = await this.http.get(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}`);
|
|
207
|
+
return new NodeAllocationIp(data);
|
|
208
|
+
}
|
|
209
|
+
async create(payload) {
|
|
210
|
+
const data = await this.http.post(`/nodes/${this.nodeId}/allocations`, {
|
|
211
|
+
ip: payload.ip,
|
|
212
|
+
ip_alias: payload.ipAlias,
|
|
213
|
+
notes: payload.notes,
|
|
214
|
+
});
|
|
215
|
+
return new NodeAllocationIp(data);
|
|
216
|
+
}
|
|
217
|
+
async update(allocationIp, payload) {
|
|
218
|
+
const data = await this.http.patch(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}`, {
|
|
219
|
+
ip_alias: payload.ipAlias,
|
|
220
|
+
notes: payload.notes,
|
|
221
|
+
});
|
|
222
|
+
return new NodeAllocationIp(data);
|
|
223
|
+
}
|
|
224
|
+
async delete(allocationIp) {
|
|
225
|
+
await this.http.delete(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}`);
|
|
226
|
+
}
|
|
227
|
+
async createPorts(allocationIp, payload) {
|
|
228
|
+
const data = await this.http.post(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}/ports`, payload);
|
|
229
|
+
return new NodeAllocationIp(data);
|
|
230
|
+
}
|
|
231
|
+
async updatePort(allocationIp, port, payload) {
|
|
232
|
+
const data = await this.http.patch(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}/ports/${port}`, payload);
|
|
233
|
+
return new NodeAllocationIp(data);
|
|
234
|
+
}
|
|
235
|
+
async deletePort(allocationIp, port) {
|
|
236
|
+
await this.http.delete(`/nodes/${this.nodeId}/allocations/${encodeURIComponent(allocationIp)}/ports/${port}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.NodeAllocationsManager = NodeAllocationsManager;
|
|
240
|
+
/**
|
|
241
|
+
* Namespace for node management.
|
|
242
|
+
*
|
|
243
|
+
* Access via `api.nodes`.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts ignore
|
|
247
|
+
* const nodes = await api.nodes.list();
|
|
248
|
+
* const node = await api.nodes.get(id, { includeConnection: true });
|
|
249
|
+
* console.log(node.connection?.url); // "http://1.2.3.4:8080"
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
class NodesNamespace extends namespace_js_1.ResourceNamespace {
|
|
253
|
+
/** @internal */
|
|
254
|
+
constructor(http) {
|
|
255
|
+
super(http);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Fetch a paginated list of nodes.
|
|
259
|
+
*
|
|
260
|
+
* @param opts Pagination, search, and include options.
|
|
261
|
+
*/
|
|
262
|
+
async list(opts = {}) {
|
|
263
|
+
const extra = {};
|
|
264
|
+
const include = (0, types_js_1.joinIncludes)(opts);
|
|
265
|
+
if (include)
|
|
266
|
+
extra['include'] = include;
|
|
267
|
+
const result = await this.http.list('/nodes', opts, extra);
|
|
268
|
+
const nodes = result.data.map((d) => new Node(d));
|
|
269
|
+
this.setCache(nodes);
|
|
270
|
+
return { ...result, data: nodes };
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Fetch a single node by ID.
|
|
274
|
+
*
|
|
275
|
+
* @param id The node's NanoID.
|
|
276
|
+
* @param opts Include options (e.g. `{ include: ['connection'] }`).
|
|
277
|
+
*/
|
|
278
|
+
async get(id, opts = {}) {
|
|
279
|
+
const params = {};
|
|
280
|
+
const include = (0, types_js_1.joinIncludes)(opts);
|
|
281
|
+
if (include)
|
|
282
|
+
params['include'] = include;
|
|
283
|
+
const data = await this.http.get(`/nodes/${id}`, { params });
|
|
284
|
+
return new Node(data);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Create a new node.
|
|
288
|
+
*
|
|
289
|
+
* @param payload Node creation parameters.
|
|
290
|
+
*/
|
|
291
|
+
async create(payload) {
|
|
292
|
+
const body = {
|
|
293
|
+
fqdn: payload.fqdn,
|
|
294
|
+
scheme: payload.scheme,
|
|
295
|
+
api_port: payload.apiPort,
|
|
296
|
+
sftp_port: payload.sftpPort,
|
|
297
|
+
host_id: payload.hostId,
|
|
298
|
+
location_id: payload.locationId,
|
|
299
|
+
type_id: payload.typeId,
|
|
300
|
+
description: payload.description,
|
|
301
|
+
notes: payload.notes,
|
|
302
|
+
num: payload.num,
|
|
303
|
+
is_maintenance_mode: payload.isMaintenanceMode,
|
|
304
|
+
can_auto_deploy: payload.canAutoDeploy,
|
|
305
|
+
is_behind_proxy: payload.isBehindProxy,
|
|
306
|
+
limits: {
|
|
307
|
+
memory_mb: payload.limits.memoryMb,
|
|
308
|
+
memory_overallocate_mb: payload.limits.memoryOverallocateMb,
|
|
309
|
+
disk_mb: payload.limits.diskMb,
|
|
310
|
+
disk_overallocate_mb: payload.limits.diskOverallocateMb,
|
|
311
|
+
upload_size_mb: payload.limits.uploadSizeMb,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
const data = await this.http.post('/nodes', body);
|
|
315
|
+
const node = new Node(data);
|
|
316
|
+
this.addToCache(node);
|
|
317
|
+
this.emit('created', node);
|
|
318
|
+
return node;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Fetch all servers deployed on a specific node.
|
|
322
|
+
*
|
|
323
|
+
* @param id The node's NanoID.
|
|
324
|
+
* @returns An array of minimal server data. Use `api.servers.get()` to fetch full server details.
|
|
325
|
+
*/
|
|
326
|
+
async servers(id) {
|
|
327
|
+
const data = await this.http.get(`/nodes/${id}/servers`);
|
|
328
|
+
return data.map((s) => ({ id: (0, types_js_1.toNanoID)(s.id) }));
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Access allocation management for a specific node.
|
|
332
|
+
*/
|
|
333
|
+
allocations(id) {
|
|
334
|
+
return new NodeAllocationsManager(id, this.http);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Log activity on behalf of a node daemon.
|
|
338
|
+
*
|
|
339
|
+
* This endpoint is intended for node-authenticated clients.
|
|
340
|
+
*/
|
|
341
|
+
async logActivity(entries) {
|
|
342
|
+
await this.http.post('/nodes/activity', {
|
|
343
|
+
data: entries.map((entry) => ({
|
|
344
|
+
user_id: entry.userId,
|
|
345
|
+
server_id: entry.serverId,
|
|
346
|
+
event: entry.event,
|
|
347
|
+
metadata: entry.metadata,
|
|
348
|
+
ip: entry.ip,
|
|
349
|
+
timestamp: entry.timestamp instanceof Date ? entry.timestamp.toISOString() : entry.timestamp,
|
|
350
|
+
})),
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Create an activity log model from a raw payload.
|
|
355
|
+
*
|
|
356
|
+
* Useful when consuming activity data returned from other endpoints.
|
|
357
|
+
*/
|
|
358
|
+
toActivityLog(data) {
|
|
359
|
+
return new activity_js_1.ActivityLog(data);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
exports.NodesNamespace = NodesNamespace;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import { ResourceNamespace } from '../namespace.js';
|
|
3
|
+
import { ReactiveResource } from '../reactive.js';
|
|
4
|
+
import { type ISODate, type NanoID, type Paginated } from '../types.js';
|
|
5
|
+
import type { NodeData } from './nodes.js';
|
|
6
|
+
import { Node } from './nodes.js';
|
|
7
|
+
/** Resource limit values for a server group. @internal */
|
|
8
|
+
export interface ServerGroupLimitsData {
|
|
9
|
+
cpu_percent?: number | null;
|
|
10
|
+
ram_mb?: number | null;
|
|
11
|
+
swap_mb?: number | null;
|
|
12
|
+
storage_mb?: number | null;
|
|
13
|
+
backup?: number | null;
|
|
14
|
+
database?: number | null;
|
|
15
|
+
allocation?: number | null;
|
|
16
|
+
}
|
|
17
|
+
/** Raw API shape for a server group. @internal */
|
|
18
|
+
export interface ServerGroupData {
|
|
19
|
+
id: string;
|
|
20
|
+
/** Always present. */
|
|
21
|
+
node_id: string;
|
|
22
|
+
/** @see NodeData */
|
|
23
|
+
node?: NodeData;
|
|
24
|
+
build?: {
|
|
25
|
+
cpu_threads?: number | null;
|
|
26
|
+
io_weight?: number | null;
|
|
27
|
+
} | null;
|
|
28
|
+
limits?: ServerGroupLimitsData | null;
|
|
29
|
+
created_at: ISODate;
|
|
30
|
+
updated_at: ISODate;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resource allocation limits for a server group.
|
|
34
|
+
*
|
|
35
|
+
* Each field is the maximum value allowed for all servers in the group combined.
|
|
36
|
+
* `null` means unlimited.
|
|
37
|
+
*/
|
|
38
|
+
export interface ServerGroupLimits {
|
|
39
|
+
/** Maximum CPU usage percentage across all servers. */
|
|
40
|
+
cpuPercent: number | null | undefined;
|
|
41
|
+
/** Maximum RAM in megabytes across all servers. */
|
|
42
|
+
ramMb: number | null | undefined;
|
|
43
|
+
/** Maximum swap in megabytes across all servers. */
|
|
44
|
+
swapMb: number | null | undefined;
|
|
45
|
+
/** Maximum storage in megabytes across all servers. */
|
|
46
|
+
storageMb: number | null | undefined;
|
|
47
|
+
/** Maximum number of backups across all servers. */
|
|
48
|
+
backup: number | null | undefined;
|
|
49
|
+
/** Maximum number of databases across all servers. */
|
|
50
|
+
database: number | null | undefined;
|
|
51
|
+
/** Maximum number of port allocations across all servers. */
|
|
52
|
+
allocation: number | null | undefined;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A server group that ties one or more servers to a specific node with shared resource limits.
|
|
56
|
+
*
|
|
57
|
+
* Retrieved via {@link ServerGroupsNamespace.get} or {@link ServerGroupsNamespace.list}.
|
|
58
|
+
*/
|
|
59
|
+
export declare class ServerGroup extends ReactiveResource {
|
|
60
|
+
/** The server group's unique NanoID. */
|
|
61
|
+
readonly id: NanoID;
|
|
62
|
+
/** The ID of the node this group is deployed on. Always present. */
|
|
63
|
+
readonly nodeId: NanoID;
|
|
64
|
+
/** The full node object. */
|
|
65
|
+
node: Node | undefined;
|
|
66
|
+
/** Build settings inherited by all servers in this group. */
|
|
67
|
+
build: {
|
|
68
|
+
cpuThreads: number | null | undefined;
|
|
69
|
+
ioWeight: number | null | undefined;
|
|
70
|
+
} | undefined;
|
|
71
|
+
/** Resource limits that apply to this group as a whole. */
|
|
72
|
+
limits: ServerGroupLimits | undefined;
|
|
73
|
+
/** When this server group was created. */
|
|
74
|
+
createdAt: Date;
|
|
75
|
+
/** When this server group was last updated. */
|
|
76
|
+
updatedAt: Date;
|
|
77
|
+
/** @internal */
|
|
78
|
+
constructor(data: ServerGroupData);
|
|
79
|
+
}
|
|
80
|
+
/** Payload for creating a new server group. */
|
|
81
|
+
export interface CreateServerGroupPayload {
|
|
82
|
+
/** NanoID of the node to deploy this group on. */
|
|
83
|
+
nodeId: NanoID;
|
|
84
|
+
/** Optional expiry date for the group. */
|
|
85
|
+
expiresAt?: Date;
|
|
86
|
+
/** Resource limits for this group. */
|
|
87
|
+
limits: {
|
|
88
|
+
/** Maximum RAM in megabytes. */
|
|
89
|
+
ramMb: number;
|
|
90
|
+
/** Maximum swap in megabytes. */
|
|
91
|
+
swapMb: number;
|
|
92
|
+
/** Maximum storage in megabytes. */
|
|
93
|
+
storageMb: number;
|
|
94
|
+
/** IO weight (1–1000). */
|
|
95
|
+
weightIo: number;
|
|
96
|
+
/** Maximum CPU usage percentage. */
|
|
97
|
+
cpuPercent: number;
|
|
98
|
+
/** CPU thread pinning, or `undefined` for no restriction. */
|
|
99
|
+
cpuThreads?: string;
|
|
100
|
+
/** Maximum number of backups. */
|
|
101
|
+
backup?: number;
|
|
102
|
+
/** Maximum number of databases. */
|
|
103
|
+
database?: number;
|
|
104
|
+
/** Maximum number of port allocations. */
|
|
105
|
+
allocation?: number;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** Typed events emitted by {@link ServerGroupsNamespace}. */
|
|
109
|
+
export interface ServerGroupEvents {
|
|
110
|
+
/** Fired after a server group is created. */
|
|
111
|
+
created: ServerGroup;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Namespace for server group management.
|
|
115
|
+
*
|
|
116
|
+
* Access via `api.serverGroups`.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts ignore
|
|
120
|
+
* const groups = await api.serverGroups.list();
|
|
121
|
+
* const group = await api.serverGroups.get(id);
|
|
122
|
+
* const newGroup = await api.serverGroups.create({ nodeId, limits: { ramMb: 1024 } });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare class ServerGroupsNamespace extends ResourceNamespace<ServerGroup, ServerGroupEvents> {
|
|
126
|
+
/** @internal */
|
|
127
|
+
constructor(http: HttpClient);
|
|
128
|
+
/**
|
|
129
|
+
* Fetch a paginated list of server groups.
|
|
130
|
+
*
|
|
131
|
+
* @param opts Pagination and search options.
|
|
132
|
+
*/
|
|
133
|
+
list(opts?: {
|
|
134
|
+
page?: number;
|
|
135
|
+
perPage?: number;
|
|
136
|
+
}): Promise<Paginated<ServerGroup>>;
|
|
137
|
+
/**
|
|
138
|
+
* Fetch a single server group by ID.
|
|
139
|
+
*
|
|
140
|
+
* @param id The server group's NanoID.
|
|
141
|
+
*/
|
|
142
|
+
get(id: NanoID): Promise<ServerGroup>;
|
|
143
|
+
/**
|
|
144
|
+
* Create a new server group.
|
|
145
|
+
*
|
|
146
|
+
* @param payload Server group creation parameters.
|
|
147
|
+
*/
|
|
148
|
+
create(payload: CreateServerGroupPayload): Promise<ServerGroup>;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=server-groups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-groups.d.ts","sourceRoot":"","sources":["../../../src/src/resources/server-groups.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServerGroupsNamespace = exports.ServerGroup = void 0;
|
|
4
|
+
const namespace_js_1 = require("../namespace.js");
|
|
5
|
+
const reactive_js_1 = require("../reactive.js");
|
|
6
|
+
const types_js_1 = require("../types.js");
|
|
7
|
+
const nodes_js_1 = require("./nodes.js");
|
|
8
|
+
/**
|
|
9
|
+
* A server group that ties one or more servers to a specific node with shared resource limits.
|
|
10
|
+
*
|
|
11
|
+
* Retrieved via {@link ServerGroupsNamespace.get} or {@link ServerGroupsNamespace.list}.
|
|
12
|
+
*/
|
|
13
|
+
class ServerGroup extends reactive_js_1.ReactiveResource {
|
|
14
|
+
/** The server group's unique NanoID. */
|
|
15
|
+
id;
|
|
16
|
+
/** The ID of the node this group is deployed on. Always present. */
|
|
17
|
+
nodeId;
|
|
18
|
+
/** The full node object. */
|
|
19
|
+
node;
|
|
20
|
+
/** Build settings inherited by all servers in this group. */
|
|
21
|
+
build;
|
|
22
|
+
/** Resource limits that apply to this group as a whole. */
|
|
23
|
+
limits;
|
|
24
|
+
/** When this server group was created. */
|
|
25
|
+
createdAt;
|
|
26
|
+
/** When this server group was last updated. */
|
|
27
|
+
updatedAt;
|
|
28
|
+
/** @internal */
|
|
29
|
+
constructor(data) {
|
|
30
|
+
super();
|
|
31
|
+
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
32
|
+
this.nodeId = (0, types_js_1.toNanoID)(data.node_id);
|
|
33
|
+
this.node = data.node ? new nodes_js_1.Node(data.node) : undefined;
|
|
34
|
+
this.build = data.build ? { cpuThreads: data.build.cpu_threads, ioWeight: data.build.io_weight } : undefined;
|
|
35
|
+
this.limits = data.limits
|
|
36
|
+
? {
|
|
37
|
+
cpuPercent: data.limits.cpu_percent,
|
|
38
|
+
ramMb: data.limits.ram_mb,
|
|
39
|
+
swapMb: data.limits.swap_mb,
|
|
40
|
+
storageMb: data.limits.storage_mb,
|
|
41
|
+
backup: data.limits.backup,
|
|
42
|
+
database: data.limits.database,
|
|
43
|
+
allocation: data.limits.allocation,
|
|
44
|
+
}
|
|
45
|
+
: undefined;
|
|
46
|
+
this.createdAt = new Date(data.created_at);
|
|
47
|
+
this.updatedAt = new Date(data.updated_at);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.ServerGroup = ServerGroup;
|
|
51
|
+
/**
|
|
52
|
+
* Namespace for server group management.
|
|
53
|
+
*
|
|
54
|
+
* Access via `api.serverGroups`.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts ignore
|
|
58
|
+
* const groups = await api.serverGroups.list();
|
|
59
|
+
* const group = await api.serverGroups.get(id);
|
|
60
|
+
* const newGroup = await api.serverGroups.create({ nodeId, limits: { ramMb: 1024 } });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
class ServerGroupsNamespace extends namespace_js_1.ResourceNamespace {
|
|
64
|
+
/** @internal */
|
|
65
|
+
constructor(http) {
|
|
66
|
+
super(http);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Fetch a paginated list of server groups.
|
|
70
|
+
*
|
|
71
|
+
* @param opts Pagination and search options.
|
|
72
|
+
*/
|
|
73
|
+
async list(opts = {}) {
|
|
74
|
+
const result = await this.http.list('/servers/groups', opts);
|
|
75
|
+
const groups = result.data.map((d) => new ServerGroup(d));
|
|
76
|
+
this.setCache(groups);
|
|
77
|
+
return { ...result, data: groups };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Fetch a single server group by ID.
|
|
81
|
+
*
|
|
82
|
+
* @param id The server group's NanoID.
|
|
83
|
+
*/
|
|
84
|
+
async get(id) {
|
|
85
|
+
const data = await this.http.get(`/servers/groups/${id}`);
|
|
86
|
+
return new ServerGroup(data);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a new server group.
|
|
90
|
+
*
|
|
91
|
+
* @param payload Server group creation parameters.
|
|
92
|
+
*/
|
|
93
|
+
async create(payload) {
|
|
94
|
+
const body = {
|
|
95
|
+
node_id: payload.nodeId,
|
|
96
|
+
expires_at: payload.expiresAt,
|
|
97
|
+
limits: {
|
|
98
|
+
ram_mb: payload.limits.ramMb,
|
|
99
|
+
swap_mb: payload.limits.swapMb,
|
|
100
|
+
storage_mb: payload.limits.storageMb,
|
|
101
|
+
weight_io: payload.limits.weightIo,
|
|
102
|
+
cpu_percent: payload.limits.cpuPercent,
|
|
103
|
+
cpu_threads: payload.limits.cpuThreads,
|
|
104
|
+
backup: payload.limits.backup,
|
|
105
|
+
database: payload.limits.database,
|
|
106
|
+
allocation: payload.limits.allocation,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
const data = await this.http.post('/servers/groups', body);
|
|
110
|
+
const group = new ServerGroup(data);
|
|
111
|
+
this.addToCache(group);
|
|
112
|
+
this.emit('created', group);
|
|
113
|
+
return group;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.ServerGroupsNamespace = ServerGroupsNamespace;
|