@meowpanel/api 0.3.0 → 0.5.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/esm/mod.d.ts +37 -16
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +25 -7
- package/esm/src/client.d.ts +48 -11
- package/esm/src/client.d.ts.map +1 -1
- package/esm/src/client.js +53 -12
- package/esm/src/http.d.ts +2 -2
- package/esm/src/http.d.ts.map +1 -1
- package/esm/src/http.js +5 -2
- package/esm/src/namespace.d.ts +1 -1
- package/esm/src/namespace.js +1 -1
- package/esm/src/resources/account.d.ts +50 -19
- package/esm/src/resources/account.d.ts.map +1 -1
- package/esm/src/resources/account.js +51 -13
- package/esm/src/resources/api-keys.d.ts +16 -24
- package/esm/src/resources/api-keys.d.ts.map +1 -1
- package/esm/src/resources/api-keys.js +16 -20
- package/esm/src/resources/auth.d.ts +70 -4
- package/esm/src/resources/auth.d.ts.map +1 -1
- package/esm/src/resources/auth.js +47 -4
- package/esm/src/resources/eggs.d.ts +261 -22
- package/esm/src/resources/eggs.d.ts.map +1 -1
- package/esm/src/resources/eggs.js +261 -25
- package/esm/src/resources/features.d.ts +35 -0
- package/esm/src/resources/features.d.ts.map +1 -0
- package/esm/src/resources/features.js +21 -0
- package/esm/src/resources/hosts.d.ts +151 -21
- package/esm/src/resources/hosts.d.ts.map +1 -1
- package/esm/src/resources/hosts.js +143 -10
- package/esm/src/resources/logs.d.ts +39 -0
- package/esm/src/resources/logs.d.ts.map +1 -0
- package/esm/src/resources/logs.js +38 -0
- package/esm/src/resources/nodes.d.ts +108 -33
- package/esm/src/resources/nodes.d.ts.map +1 -1
- package/esm/src/resources/nodes.js +116 -24
- package/esm/src/resources/permissions.d.ts +45 -0
- package/esm/src/resources/permissions.d.ts.map +1 -0
- package/esm/src/resources/permissions.js +26 -0
- package/esm/src/resources/request-logs.d.ts +91 -0
- package/esm/src/resources/request-logs.d.ts.map +1 -0
- package/esm/src/resources/request-logs.js +70 -0
- package/esm/src/resources/roles.d.ts +128 -0
- package/esm/src/resources/roles.d.ts.map +1 -0
- package/esm/src/resources/roles.js +142 -0
- package/esm/src/resources/server-groups.d.ts +141 -7
- package/esm/src/resources/server-groups.d.ts.map +1 -1
- package/esm/src/resources/server-groups.js +157 -8
- package/esm/src/resources/servers/activity.d.ts +50 -8
- package/esm/src/resources/servers/activity.d.ts.map +1 -1
- package/esm/src/resources/servers/activity.js +54 -13
- package/esm/src/resources/servers/allocations.d.ts +3 -3
- package/esm/src/resources/servers/allocations.d.ts.map +1 -1
- package/esm/src/resources/servers/allocations.js +7 -7
- package/esm/src/resources/servers/backups.d.ts +46 -0
- package/esm/src/resources/servers/backups.d.ts.map +1 -0
- package/esm/src/resources/servers/backups.js +43 -0
- package/esm/src/resources/servers/connection.d.ts +33 -13
- package/esm/src/resources/servers/connection.d.ts.map +1 -1
- package/esm/src/resources/servers/connection.js +32 -11
- package/esm/src/resources/servers/features.d.ts +81 -0
- package/esm/src/resources/servers/features.d.ts.map +1 -0
- package/esm/src/resources/servers/features.js +60 -0
- package/esm/src/resources/servers/files.d.ts +41 -53
- package/esm/src/resources/servers/files.d.ts.map +1 -1
- package/esm/src/resources/servers/files.js +74 -116
- package/esm/src/resources/servers/index.d.ts +46 -27
- package/esm/src/resources/servers/index.d.ts.map +1 -1
- package/esm/src/resources/servers/index.js +26 -12
- package/esm/src/resources/servers/jobs.d.ts +88 -0
- package/esm/src/resources/servers/jobs.d.ts.map +1 -0
- package/esm/src/resources/servers/jobs.js +115 -0
- package/esm/src/resources/servers/node-client.d.ts +33 -0
- package/esm/src/resources/servers/node-client.d.ts.map +1 -0
- package/esm/src/resources/servers/node-client.js +61 -0
- package/esm/src/resources/servers/profiles.d.ts +83 -18
- package/esm/src/resources/servers/profiles.d.ts.map +1 -1
- package/esm/src/resources/servers/profiles.js +78 -11
- package/esm/src/resources/servers/server.d.ts +13 -28
- package/esm/src/resources/servers/server.d.ts.map +1 -1
- package/esm/src/resources/servers/server.js +21 -37
- package/esm/src/resources/servers/sftp.d.ts +12 -19
- package/esm/src/resources/servers/sftp.d.ts.map +1 -1
- package/esm/src/resources/servers/sftp.js +10 -14
- package/esm/src/resources/servers/sub-users.d.ts +99 -0
- package/esm/src/resources/servers/sub-users.d.ts.map +1 -0
- package/esm/src/resources/servers/sub-users.js +94 -0
- package/esm/src/resources/servers/types.d.ts +30 -28
- package/esm/src/resources/servers/types.d.ts.map +1 -1
- package/esm/src/resources/systems.d.ts +124 -0
- package/esm/src/resources/systems.d.ts.map +1 -0
- package/esm/src/resources/systems.js +139 -0
- package/esm/src/resources/users.d.ts +330 -0
- package/esm/src/resources/users.d.ts.map +1 -0
- package/esm/src/resources/users.js +280 -0
- package/esm/src/types.d.ts +18 -1
- package/esm/src/types.d.ts.map +1 -1
- package/esm/src/types.js +11 -0
- package/package.json +1 -1
- package/script/mod.d.ts +37 -16
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +50 -5
- package/script/src/client.d.ts +48 -11
- package/script/src/client.d.ts.map +1 -1
- package/script/src/client.js +53 -12
- package/script/src/http.d.ts +2 -2
- package/script/src/http.d.ts.map +1 -1
- package/script/src/http.js +5 -2
- package/script/src/namespace.d.ts +1 -1
- package/script/src/namespace.js +1 -1
- package/script/src/resources/account.d.ts +50 -19
- package/script/src/resources/account.d.ts.map +1 -1
- package/script/src/resources/account.js +50 -12
- package/script/src/resources/api-keys.d.ts +16 -24
- package/script/src/resources/api-keys.d.ts.map +1 -1
- package/script/src/resources/api-keys.js +15 -19
- package/script/src/resources/auth.d.ts +70 -4
- package/script/src/resources/auth.d.ts.map +1 -1
- package/script/src/resources/auth.js +47 -4
- package/script/src/resources/eggs.d.ts +261 -22
- package/script/src/resources/eggs.d.ts.map +1 -1
- package/script/src/resources/eggs.js +267 -26
- package/script/src/resources/features.d.ts +35 -0
- package/script/src/resources/features.d.ts.map +1 -0
- package/script/src/resources/features.js +25 -0
- package/script/src/resources/hosts.d.ts +151 -21
- package/script/src/resources/hosts.d.ts.map +1 -1
- package/script/src/resources/hosts.js +144 -10
- package/script/src/resources/logs.d.ts +39 -0
- package/script/src/resources/logs.d.ts.map +1 -0
- package/script/src/resources/logs.js +42 -0
- package/script/src/resources/nodes.d.ts +108 -33
- package/script/src/resources/nodes.d.ts.map +1 -1
- package/script/src/resources/nodes.js +117 -24
- package/script/src/resources/permissions.d.ts +45 -0
- package/script/src/resources/permissions.d.ts.map +1 -0
- package/script/src/resources/permissions.js +31 -0
- package/script/src/resources/request-logs.d.ts +91 -0
- package/script/src/resources/request-logs.d.ts.map +1 -0
- package/script/src/resources/request-logs.js +75 -0
- package/script/src/resources/roles.d.ts +128 -0
- package/script/src/resources/roles.d.ts.map +1 -0
- package/script/src/resources/roles.js +148 -0
- package/script/src/resources/server-groups.d.ts +141 -7
- package/script/src/resources/server-groups.d.ts.map +1 -1
- package/script/src/resources/server-groups.js +158 -8
- package/script/src/resources/servers/activity.d.ts +50 -8
- package/script/src/resources/servers/activity.d.ts.map +1 -1
- package/script/src/resources/servers/activity.js +54 -12
- package/script/src/resources/servers/allocations.d.ts +3 -3
- package/script/src/resources/servers/allocations.d.ts.map +1 -1
- package/script/src/resources/servers/allocations.js +7 -7
- package/script/src/resources/servers/backups.d.ts +46 -0
- package/script/src/resources/servers/backups.d.ts.map +1 -0
- package/script/src/resources/servers/backups.js +47 -0
- package/script/src/resources/servers/connection.d.ts +33 -13
- package/script/src/resources/servers/connection.d.ts.map +1 -1
- package/script/src/resources/servers/connection.js +32 -11
- package/script/src/resources/servers/features.d.ts +81 -0
- package/script/src/resources/servers/features.d.ts.map +1 -0
- package/script/src/resources/servers/features.js +64 -0
- package/script/src/resources/servers/files.d.ts +41 -53
- package/script/src/resources/servers/files.d.ts.map +1 -1
- package/script/src/resources/servers/files.js +74 -116
- package/script/src/resources/servers/index.d.ts +46 -27
- package/script/src/resources/servers/index.d.ts.map +1 -1
- package/script/src/resources/servers/index.js +26 -12
- package/script/src/resources/servers/jobs.d.ts +88 -0
- package/script/src/resources/servers/jobs.d.ts.map +1 -0
- package/script/src/resources/servers/jobs.js +120 -0
- package/script/src/resources/servers/node-client.d.ts +33 -0
- package/script/src/resources/servers/node-client.d.ts.map +1 -0
- package/script/src/resources/servers/node-client.js +65 -0
- package/script/src/resources/servers/profiles.d.ts +83 -18
- package/script/src/resources/servers/profiles.d.ts.map +1 -1
- package/script/src/resources/servers/profiles.js +77 -10
- package/script/src/resources/servers/server.d.ts +13 -28
- package/script/src/resources/servers/server.d.ts.map +1 -1
- package/script/src/resources/servers/server.js +21 -37
- package/script/src/resources/servers/sftp.d.ts +12 -19
- package/script/src/resources/servers/sftp.d.ts.map +1 -1
- package/script/src/resources/servers/sftp.js +10 -14
- package/script/src/resources/servers/sub-users.d.ts +99 -0
- package/script/src/resources/servers/sub-users.d.ts.map +1 -0
- package/script/src/resources/servers/sub-users.js +99 -0
- package/script/src/resources/servers/types.d.ts +30 -28
- package/script/src/resources/servers/types.d.ts.map +1 -1
- package/script/src/resources/systems.d.ts +124 -0
- package/script/src/resources/systems.d.ts.map +1 -0
- package/script/src/resources/systems.js +145 -0
- package/script/src/resources/users.d.ts +330 -0
- package/script/src/resources/users.d.ts.map +1 -0
- package/script/src/resources/users.js +287 -0
- package/script/src/types.d.ts +18 -1
- package/script/src/types.d.ts.map +1 -1
- package/script/src/types.js +12 -0
- package/esm/src/resources/members.d.ts +0 -138
- package/esm/src/resources/members.d.ts.map +0 -1
- package/esm/src/resources/members.js +0 -122
- package/script/src/resources/members.d.ts +0 -138
- package/script/src/resources/members.d.ts.map +0 -1
- package/script/src/resources/members.js +0 -127
|
@@ -1,7 +1,49 @@
|
|
|
1
1
|
import type { HttpClient } from '../../http.js';
|
|
2
2
|
import { ReactiveResource } from '../../reactive.js';
|
|
3
|
-
import type { ListOptions, NanoID, Paginated } from '../../types.js';
|
|
3
|
+
import type { IncludeOptions, ListOptions, NanoID, Paginated, ResourceWith } from '../../types.js';
|
|
4
|
+
import { Egg } from '../eggs.js';
|
|
4
5
|
import type { ServerProfileData } from './types.js';
|
|
6
|
+
/** An egg environment variable configured for a profile. */
|
|
7
|
+
export interface StartupVariable {
|
|
8
|
+
key: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
value: string;
|
|
12
|
+
default: string;
|
|
13
|
+
/** Laravel validation rules, e.g. `"required|numeric|min:1"`. */
|
|
14
|
+
rules: string;
|
|
15
|
+
}
|
|
16
|
+
/** Startup command and egg variables. Populated via `include=startup`. */
|
|
17
|
+
export interface ServerStartup {
|
|
18
|
+
command: string;
|
|
19
|
+
variables: Record<string, StartupVariable>;
|
|
20
|
+
}
|
|
21
|
+
/** Type-safe `include` keys for {@link ServerProfilesManager} reads. */
|
|
22
|
+
export type ServerProfileInclude = 'egg' | 'startup' | 'folder';
|
|
23
|
+
/** Maps each {@link ServerProfileInclude} key to the field(s) it guarantees on the {@link ServerProfile} instance. */
|
|
24
|
+
interface ServerProfileIncludeMap {
|
|
25
|
+
egg: {
|
|
26
|
+
egg: Egg;
|
|
27
|
+
};
|
|
28
|
+
startup: {
|
|
29
|
+
startup: ServerStartup;
|
|
30
|
+
};
|
|
31
|
+
folder: {
|
|
32
|
+
folder: string | null;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** A {@link ServerProfile} with the fields guaranteed by the requested includes `I`. */
|
|
36
|
+
export type ServerProfileWith<I extends readonly ServerProfileInclude[] = []> = ResourceWith<ServerProfile, ServerProfileIncludeMap, I>;
|
|
37
|
+
/** Fields a profile update can change. `startup` requires `server.startup.manage` (and `server.startup.command.manage` for `command`). */
|
|
38
|
+
export interface ServerProfileUpdate {
|
|
39
|
+
name?: string;
|
|
40
|
+
description?: string | null;
|
|
41
|
+
notes?: string | null;
|
|
42
|
+
startup?: {
|
|
43
|
+
command?: string | null;
|
|
44
|
+
variables?: Record<string, string | null>;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
5
47
|
/**
|
|
6
48
|
* A named configuration profile for a server.
|
|
7
49
|
*
|
|
@@ -21,6 +63,18 @@ export declare class ServerProfile extends ReactiveResource {
|
|
|
21
63
|
description: string | null;
|
|
22
64
|
/** Internal notes for this profile. */
|
|
23
65
|
notes: string | null | undefined;
|
|
66
|
+
/** The egg this profile runs. Requires `server.egg.read`. */
|
|
67
|
+
eggId: NanoID | undefined;
|
|
68
|
+
/** The expanded egg. Populated with `?include=egg` (requires `server.egg.read`). */
|
|
69
|
+
egg: Egg | undefined;
|
|
70
|
+
/** The egg image (Docker image) id this profile uses. */
|
|
71
|
+
eggImageId: NanoID | undefined;
|
|
72
|
+
/** A custom Docker image overriding the egg's default. */
|
|
73
|
+
eggImageOverride: string | null | undefined;
|
|
74
|
+
/** Whether the egg install scripts are skipped for this profile. */
|
|
75
|
+
skipInstallScripts: boolean | undefined;
|
|
76
|
+
/** Startup command and variables. Populated with `include=startup`. */
|
|
77
|
+
startup: ServerStartup | undefined;
|
|
24
78
|
/** The folder name used to store this profile's files on disk. */
|
|
25
79
|
folder: string | null | undefined;
|
|
26
80
|
/** `true` if this is the currently active profile for the server. */
|
|
@@ -46,15 +100,11 @@ export declare class ServerProfile extends ReactiveResource {
|
|
|
46
100
|
*/
|
|
47
101
|
setAsActive(): Promise<void>;
|
|
48
102
|
/**
|
|
49
|
-
* Update this profile's name, description, or
|
|
103
|
+
* Update this profile's name, description, notes, or startup command and variables.
|
|
50
104
|
*
|
|
51
105
|
* @param payload Fields to update.
|
|
52
106
|
*/
|
|
53
|
-
update(payload:
|
|
54
|
-
name?: string;
|
|
55
|
-
description?: string | null;
|
|
56
|
-
notes?: string | null;
|
|
57
|
-
}): Promise<void>;
|
|
107
|
+
update(payload: ServerProfileUpdate): Promise<void>;
|
|
58
108
|
/**
|
|
59
109
|
* Delete this profile permanently.
|
|
60
110
|
*/
|
|
@@ -84,23 +134,25 @@ export declare class ServerProfilesManager {
|
|
|
84
134
|
/**
|
|
85
135
|
* Fetch all profiles for this server.
|
|
86
136
|
*
|
|
87
|
-
* @param opts Pagination options.
|
|
137
|
+
* @param opts Pagination and include options.
|
|
88
138
|
*/
|
|
89
|
-
list(opts?: ListOptions): Promise<Paginated<
|
|
139
|
+
list<const I extends readonly ServerProfileInclude[] = []>(opts?: ListOptions & IncludeOptions<ServerProfileInclude, I>): Promise<Paginated<ServerProfileWith<I>>>;
|
|
90
140
|
/**
|
|
91
141
|
* Fetch the currently active profile.
|
|
92
142
|
*
|
|
143
|
+
* @param opts Include options.
|
|
93
144
|
* @throws {@link ApiError} with `isNotFound === true` if no profile is active.
|
|
94
145
|
*/
|
|
95
|
-
getActive(): Promise<
|
|
146
|
+
getActive<const I extends readonly ServerProfileInclude[] = []>(opts?: IncludeOptions<ServerProfileInclude, I>): Promise<ServerProfileWith<I>>;
|
|
96
147
|
/**
|
|
97
148
|
* Fetch a single profile by ID.
|
|
98
149
|
*
|
|
99
150
|
* @param profileId The profile's NanoID.
|
|
151
|
+
* @param opts Include options.
|
|
100
152
|
*/
|
|
101
|
-
get(profileId: NanoID): Promise<
|
|
153
|
+
get<const I extends readonly ServerProfileInclude[] = []>(profileId: NanoID, opts?: IncludeOptions<ServerProfileInclude, I>): Promise<ServerProfileWith<I>>;
|
|
102
154
|
/**
|
|
103
|
-
* Create a new profile for this server.
|
|
155
|
+
* Create a new profile for this server. A profile binds an egg and image.
|
|
104
156
|
*
|
|
105
157
|
* @param payload Profile creation parameters.
|
|
106
158
|
*/
|
|
@@ -108,18 +160,30 @@ export declare class ServerProfilesManager {
|
|
|
108
160
|
name: string;
|
|
109
161
|
description?: string;
|
|
110
162
|
notes?: string;
|
|
163
|
+
eggId: NanoID;
|
|
164
|
+
eggImageId: NanoID;
|
|
165
|
+
eggImageOverride?: string;
|
|
166
|
+
startupCommandOverride?: string;
|
|
167
|
+
skipInstallScripts?: boolean;
|
|
111
168
|
}): Promise<ServerProfile>;
|
|
112
169
|
/**
|
|
113
|
-
*
|
|
170
|
+
* Change a profile's egg, reselecting a valid image and re-basing its variables.
|
|
114
171
|
*
|
|
115
172
|
* @param profileId The profile's NanoID.
|
|
116
|
-
* @param
|
|
173
|
+
* @param eggId The egg to switch to.
|
|
174
|
+
* @param opts `keep: true` carries over all compatible variable overrides;
|
|
175
|
+
* an array keeps only the named variables.
|
|
117
176
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
description?: string;
|
|
121
|
-
notes?: string;
|
|
177
|
+
changeEgg(profileId: NanoID, eggId: NanoID, opts?: {
|
|
178
|
+
keep?: boolean | string[];
|
|
122
179
|
}): Promise<ServerProfile>;
|
|
180
|
+
/**
|
|
181
|
+
* Update a profile's name, description, notes, or startup command and variables.
|
|
182
|
+
*
|
|
183
|
+
* @param profileId The profile's NanoID.
|
|
184
|
+
* @param payload Fields to update.
|
|
185
|
+
*/
|
|
186
|
+
update(profileId: NanoID, payload: ServerProfileUpdate): Promise<ServerProfile>;
|
|
123
187
|
/**
|
|
124
188
|
* Set a profile as the active profile for this server.
|
|
125
189
|
*
|
|
@@ -135,4 +199,5 @@ export declare class ServerProfilesManager {
|
|
|
135
199
|
*/
|
|
136
200
|
delete(profileId: NanoID): Promise<void>;
|
|
137
201
|
}
|
|
202
|
+
export {};
|
|
138
203
|
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAA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CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC7B,GAAG,OAAO,CAAC,aAAa,CAAC;IAc1B;;;;;;;OAOG;IACU,SAAS,CACrB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;KAAO,GACtC,OAAO,CAAC,aAAa,CAAC;IAczB;;;;;OAKG;IACU,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IAK5F;;;;;;OAMG;IACU,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAW/E;;;;OAIG;IACU,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactiveResource } from '../../reactive.js';
|
|
2
|
-
import { toNanoID } from '../../types.js';
|
|
2
|
+
import { joinIncludes, toNanoID } from '../../types.js';
|
|
3
|
+
import { Egg } from '../eggs.js';
|
|
3
4
|
/**
|
|
4
5
|
* A named configuration profile for a server.
|
|
5
6
|
*
|
|
@@ -19,6 +20,18 @@ export class ServerProfile extends ReactiveResource {
|
|
|
19
20
|
description;
|
|
20
21
|
/** Internal notes for this profile. */
|
|
21
22
|
notes;
|
|
23
|
+
/** The egg this profile runs. Requires `server.egg.read`. */
|
|
24
|
+
eggId;
|
|
25
|
+
/** The expanded egg. Populated with `?include=egg` (requires `server.egg.read`). */
|
|
26
|
+
egg;
|
|
27
|
+
/** The egg image (Docker image) id this profile uses. */
|
|
28
|
+
eggImageId;
|
|
29
|
+
/** A custom Docker image overriding the egg's default. */
|
|
30
|
+
eggImageOverride;
|
|
31
|
+
/** Whether the egg install scripts are skipped for this profile. */
|
|
32
|
+
skipInstallScripts;
|
|
33
|
+
/** Startup command and variables. Populated with `include=startup`. */
|
|
34
|
+
startup;
|
|
22
35
|
/** The folder name used to store this profile's files on disk. */
|
|
23
36
|
folder;
|
|
24
37
|
/** `true` if this is the currently active profile for the server. */
|
|
@@ -47,6 +60,20 @@ export class ServerProfile extends ReactiveResource {
|
|
|
47
60
|
this.name = data.name;
|
|
48
61
|
this.description = data.description ?? null;
|
|
49
62
|
this.notes = data.notes;
|
|
63
|
+
this.eggId = data.egg_id ? toNanoID(data.egg_id) : undefined;
|
|
64
|
+
this.eggImageId = data.egg_image_id ? toNanoID(data.egg_image_id) : undefined;
|
|
65
|
+
this.eggImageOverride = data.egg_image_override;
|
|
66
|
+
this.skipInstallScripts = data.skip_install_scripts;
|
|
67
|
+
if (data.egg)
|
|
68
|
+
this.egg = new Egg(data.egg);
|
|
69
|
+
if (data.startup !== undefined) {
|
|
70
|
+
this.startup = data.startup
|
|
71
|
+
? {
|
|
72
|
+
command: data.startup.command,
|
|
73
|
+
variables: Object.fromEntries(Object.entries(data.startup.variables).map(([key, v]) => [key, { key, ...v }])),
|
|
74
|
+
}
|
|
75
|
+
: undefined;
|
|
76
|
+
}
|
|
50
77
|
this.folder = data.folder;
|
|
51
78
|
this.isActive = data.is_active;
|
|
52
79
|
this.updatedAt = new Date(data.updated_at);
|
|
@@ -62,7 +89,7 @@ export class ServerProfile extends ReactiveResource {
|
|
|
62
89
|
this.applyData(data);
|
|
63
90
|
}
|
|
64
91
|
/**
|
|
65
|
-
* Update this profile's name, description, or
|
|
92
|
+
* Update this profile's name, description, notes, or startup command and variables.
|
|
66
93
|
*
|
|
67
94
|
* @param payload Fields to update.
|
|
68
95
|
*/
|
|
@@ -106,41 +133,81 @@ export class ServerProfilesManager {
|
|
|
106
133
|
/**
|
|
107
134
|
* Fetch all profiles for this server.
|
|
108
135
|
*
|
|
109
|
-
* @param opts Pagination options.
|
|
136
|
+
* @param opts Pagination and include options.
|
|
110
137
|
*/
|
|
111
138
|
async list(opts = {}) {
|
|
112
|
-
const
|
|
139
|
+
const extra = {};
|
|
140
|
+
const include = joinIncludes(opts);
|
|
141
|
+
if (include)
|
|
142
|
+
extra['include'] = include;
|
|
143
|
+
const result = await this.http.list(`/servers/${this.serverId}/profiles`, opts, extra);
|
|
113
144
|
return { ...result, data: result.data.map((d) => this.makeProfile(d)) };
|
|
114
145
|
}
|
|
115
146
|
/**
|
|
116
147
|
* Fetch the currently active profile.
|
|
117
148
|
*
|
|
149
|
+
* @param opts Include options.
|
|
118
150
|
* @throws {@link ApiError} with `isNotFound === true` if no profile is active.
|
|
119
151
|
*/
|
|
120
|
-
async getActive() {
|
|
121
|
-
const
|
|
152
|
+
async getActive(opts = {}) {
|
|
153
|
+
const params = {};
|
|
154
|
+
const include = joinIncludes(opts);
|
|
155
|
+
if (include)
|
|
156
|
+
params['include'] = include;
|
|
157
|
+
const data = await this.http.get(`/servers/${this.serverId}/profiles/active`, { params });
|
|
122
158
|
return this.makeProfile(data);
|
|
123
159
|
}
|
|
124
160
|
/**
|
|
125
161
|
* Fetch a single profile by ID.
|
|
126
162
|
*
|
|
127
163
|
* @param profileId The profile's NanoID.
|
|
164
|
+
* @param opts Include options.
|
|
128
165
|
*/
|
|
129
|
-
async get(profileId) {
|
|
130
|
-
const
|
|
166
|
+
async get(profileId, opts = {}) {
|
|
167
|
+
const params = {};
|
|
168
|
+
const include = joinIncludes(opts);
|
|
169
|
+
if (include)
|
|
170
|
+
params['include'] = include;
|
|
171
|
+
const data = await this.http.get(`/servers/${this.serverId}/profiles/${profileId}`, { params });
|
|
131
172
|
return this.makeProfile(data);
|
|
132
173
|
}
|
|
133
174
|
/**
|
|
134
|
-
* Create a new profile for this server.
|
|
175
|
+
* Create a new profile for this server. A profile binds an egg and image.
|
|
135
176
|
*
|
|
136
177
|
* @param payload Profile creation parameters.
|
|
137
178
|
*/
|
|
138
179
|
async create(payload) {
|
|
139
|
-
const data = await this.http.post(`/servers/${this.serverId}/profiles`,
|
|
180
|
+
const data = await this.http.post(`/servers/${this.serverId}/profiles`, {
|
|
181
|
+
name: payload.name,
|
|
182
|
+
description: payload.description,
|
|
183
|
+
notes: payload.notes,
|
|
184
|
+
egg_id: payload.eggId,
|
|
185
|
+
egg_image_id: payload.eggImageId,
|
|
186
|
+
egg_image_override: payload.eggImageOverride,
|
|
187
|
+
startup_command_override: payload.startupCommandOverride,
|
|
188
|
+
skip_install_scripts: payload.skipInstallScripts,
|
|
189
|
+
});
|
|
190
|
+
return this.makeProfile(data);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Change a profile's egg, reselecting a valid image and re-basing its variables.
|
|
194
|
+
*
|
|
195
|
+
* @param profileId The profile's NanoID.
|
|
196
|
+
* @param eggId The egg to switch to.
|
|
197
|
+
* @param opts `keep: true` carries over all compatible variable overrides;
|
|
198
|
+
* an array keeps only the named variables.
|
|
199
|
+
*/
|
|
200
|
+
async changeEgg(profileId, eggId, opts = {}) {
|
|
201
|
+
const params = {};
|
|
202
|
+
if (opts.keep === true)
|
|
203
|
+
params['keep'] = 'true';
|
|
204
|
+
else if (Array.isArray(opts.keep))
|
|
205
|
+
params['keep'] = opts.keep.join(',');
|
|
206
|
+
const data = await this.http.put(`/servers/${this.serverId}/profiles/${profileId}/egg`, JSON.stringify({ egg_id: eggId }), 'application/json', { params });
|
|
140
207
|
return this.makeProfile(data);
|
|
141
208
|
}
|
|
142
209
|
/**
|
|
143
|
-
* Update a profile's name, description, or
|
|
210
|
+
* Update a profile's name, description, notes, or startup command and variables.
|
|
144
211
|
*
|
|
145
212
|
* @param profileId The profile's NanoID.
|
|
146
213
|
* @param payload Fields to update.
|
|
@@ -1,37 +1,30 @@
|
|
|
1
1
|
import type { HttpClient } from '../../http.js';
|
|
2
2
|
import { ReactiveResource } from '../../reactive.js';
|
|
3
3
|
import type { NanoID, PowerAction, PowerState, ServerRestrictedState } from '../../types.js';
|
|
4
|
-
import { Egg } from '../eggs.js';
|
|
5
4
|
import { ServerGroup } from '../server-groups.js';
|
|
6
5
|
import { ServerActivityManager } from './activity.js';
|
|
7
6
|
import { ServerAllocationsManager } from './allocations.js';
|
|
7
|
+
import { ServerBackupsManager } from './backups.js';
|
|
8
8
|
import { ServerConnection } from './connection.js';
|
|
9
|
+
import { ServerFeaturesManager } from './features.js';
|
|
9
10
|
import { ServerFilesManager } from './files.js';
|
|
11
|
+
import { ServerJobsManager } from './jobs.js';
|
|
10
12
|
import { ServerProfilesManager } from './profiles.js';
|
|
11
13
|
import { ServerSftpManager } from './sftp.js';
|
|
14
|
+
import { ServerUserManager } from './sub-users.js';
|
|
12
15
|
import type { ServerAllocationsData, ServerData, UpdateServerPayload } from './types.js';
|
|
13
|
-
/** An egg environment variable configured for a server. */
|
|
14
|
-
export interface StartupVariable {
|
|
15
|
-
key: string;
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
|
-
value: string;
|
|
19
|
-
default: string;
|
|
20
|
-
/** Laravel validation rules, e.g. `"required|numeric|min:1"`. */
|
|
21
|
-
rules: string;
|
|
22
|
-
}
|
|
23
16
|
/** Real-time power state and utilization. Populated via `include=status`. */
|
|
24
17
|
export interface ServerStatus {
|
|
25
18
|
state: PowerState;
|
|
26
19
|
/** `null` when the server is offline. */
|
|
27
20
|
utilization: {
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
ramBytes: number;
|
|
22
|
+
ramLimitBytes: number;
|
|
30
23
|
cpuAbsolute: number;
|
|
31
24
|
networkRxBytes: number;
|
|
32
25
|
networkTxBytes: number;
|
|
33
26
|
uptimeMs: number;
|
|
34
|
-
|
|
27
|
+
storageBytes: number;
|
|
35
28
|
} | null;
|
|
36
29
|
}
|
|
37
30
|
/** Build and resource limit configuration. Populated via `include=build`. */
|
|
@@ -52,17 +45,12 @@ export interface ServerBuild {
|
|
|
52
45
|
backup: number | null | undefined;
|
|
53
46
|
} | null | undefined;
|
|
54
47
|
}
|
|
55
|
-
/** Startup command and egg variables. Populated via `include=startup`. */
|
|
56
|
-
export interface ServerStartup {
|
|
57
|
-
command: string;
|
|
58
|
-
variables: Record<string, StartupVariable>;
|
|
59
|
-
}
|
|
60
48
|
/**
|
|
61
49
|
* A MeowPanel game server.
|
|
62
50
|
*
|
|
63
51
|
* @example
|
|
64
52
|
* ```ts ignore
|
|
65
|
-
* const server = await api.servers.get(id, { include: ['status'
|
|
53
|
+
* const server = await api.servers.get(id, { include: ['status'] });
|
|
66
54
|
* server.status; // ServerStatus (guaranteed by include)
|
|
67
55
|
*
|
|
68
56
|
* await server.sendPower('start');
|
|
@@ -85,19 +73,12 @@ export declare class Server extends ReactiveResource {
|
|
|
85
73
|
/** When non-null, overrides the node's reported power state for display. */
|
|
86
74
|
restrictedState: ServerRestrictedState;
|
|
87
75
|
readonly groupId: NanoID;
|
|
88
|
-
readonly eggId: NanoID;
|
|
89
|
-
eggImageId: NanoID | undefined;
|
|
90
76
|
/** Populated with `include=group`. */
|
|
91
77
|
group: ServerGroup | undefined;
|
|
92
|
-
/** Populated with `include=egg`. */
|
|
93
|
-
egg: Egg | undefined;
|
|
94
|
-
eggImageOverride: string | null | undefined;
|
|
95
78
|
/** Populated with `include=status`. Use {@link getStatus} to fetch on demand. */
|
|
96
79
|
status: ServerStatus | undefined;
|
|
97
80
|
/** Populated with `include=build`. */
|
|
98
81
|
build: ServerBuild | undefined;
|
|
99
|
-
/** Populated with `include=startup`. */
|
|
100
|
-
startup: ServerStartup | undefined;
|
|
101
82
|
/** Populated with `include=allocations`. */
|
|
102
83
|
allocationPorts: ServerAllocationsData | undefined;
|
|
103
84
|
createdAt: Date;
|
|
@@ -107,11 +88,15 @@ export declare class Server extends ReactiveResource {
|
|
|
107
88
|
readonly profiles: ServerProfilesManager;
|
|
108
89
|
readonly activity: ServerActivityManager;
|
|
109
90
|
readonly files: ServerFilesManager;
|
|
91
|
+
readonly backups: ServerBackupsManager;
|
|
92
|
+
readonly jobs: ServerJobsManager;
|
|
93
|
+
readonly subUsers: ServerUserManager;
|
|
94
|
+
readonly features: ServerFeaturesManager;
|
|
110
95
|
/** @internal */
|
|
111
96
|
constructor(data: ServerData, http: HttpClient, resolveNodeUrl: () => Promise<string>, onMutated: () => void);
|
|
112
97
|
/** Apply raw API data, updating all mutable fields. */
|
|
113
98
|
applyData(data: ServerData): void;
|
|
114
|
-
/** Update this server's details
|
|
99
|
+
/** Update this server's details or primary allocation. */
|
|
115
100
|
update(payload: UpdateServerPayload): Promise<void>;
|
|
116
101
|
/** Fetch current power state and utilization from the node. */
|
|
117
102
|
getStatus(): Promise<ServerStatus>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE7F,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/src/resources/servers/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE7F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,wBAAwB,E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qB,CAAC;IAChD,SAAgB,KAAK,EAAE,kBAAkB,CAAC;IAC1C,SAAgB,OAAO,EAAE,oBAAoB,CAAC;IAC9C,SAAgB,IAAI,EAAE,iBAAiB,CAAC;IACxC,SAAgB,QAAQ,EAAE,iBAAiB,CAAC;IAC5C,SAAgB,QAAQ,EAAE,qBAAqB,CAAC;IAEhD,gBAAgB;gBAEf,IAAI,EAAE,UAAU,EACC,IAAI,EAAE,UAAU,EAChB,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACrC,SAAS,EAAE,MAAM,IAAI;IAqBvC,uDAAuD;IAChD,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAuBxC,0DAA0D;IAC7C,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBhE,+DAA+D;IAClD,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;IAO/C,yCAAyC;IAC5B,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1D,yCAAyC;IAC5B,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnE;;;;;;;;;;;OAWG;IACU,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAI1D"}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { ReactiveResource } from '../../reactive.js';
|
|
2
2
|
import { toNanoID } from '../../types.js';
|
|
3
|
-
import { Egg } from '../eggs.js';
|
|
4
3
|
import { ServerGroup } from '../server-groups.js';
|
|
5
4
|
import { ServerActivityManager } from './activity.js';
|
|
6
5
|
import { ServerAllocationsManager } from './allocations.js';
|
|
6
|
+
import { ServerBackupsManager } from './backups.js';
|
|
7
7
|
import { ServerConnection } from './connection.js';
|
|
8
|
+
import { ServerFeaturesManager } from './features.js';
|
|
8
9
|
import { ServerFilesManager } from './files.js';
|
|
10
|
+
import { ServerJobsManager } from './jobs.js';
|
|
11
|
+
import { NodeClient } from './node-client.js';
|
|
9
12
|
import { ServerProfilesManager } from './profiles.js';
|
|
10
13
|
import { ServerSftpManager } from './sftp.js';
|
|
14
|
+
import { ServerUserManager } from './sub-users.js';
|
|
11
15
|
/**
|
|
12
16
|
* A MeowPanel game server.
|
|
13
17
|
*
|
|
14
18
|
* @example
|
|
15
19
|
* ```ts ignore
|
|
16
|
-
* const server = await api.servers.get(id, { include: ['status'
|
|
20
|
+
* const server = await api.servers.get(id, { include: ['status'] });
|
|
17
21
|
* server.status; // ServerStatus (guaranteed by include)
|
|
18
22
|
*
|
|
19
23
|
* await server.sendPower('start');
|
|
@@ -36,19 +40,12 @@ export class Server extends ReactiveResource {
|
|
|
36
40
|
/** When non-null, overrides the node's reported power state for display. */
|
|
37
41
|
restrictedState;
|
|
38
42
|
groupId;
|
|
39
|
-
eggId;
|
|
40
|
-
eggImageId;
|
|
41
43
|
/** Populated with `include=group`. */
|
|
42
44
|
group;
|
|
43
|
-
/** Populated with `include=egg`. */
|
|
44
|
-
egg;
|
|
45
|
-
eggImageOverride;
|
|
46
45
|
/** Populated with `include=status`. Use {@link getStatus} to fetch on demand. */
|
|
47
46
|
status;
|
|
48
47
|
/** Populated with `include=build`. */
|
|
49
48
|
build;
|
|
50
|
-
/** Populated with `include=startup`. */
|
|
51
|
-
startup;
|
|
52
49
|
/** Populated with `include=allocations`. */
|
|
53
50
|
allocationPorts;
|
|
54
51
|
createdAt;
|
|
@@ -58,6 +55,10 @@ export class Server extends ReactiveResource {
|
|
|
58
55
|
profiles;
|
|
59
56
|
activity;
|
|
60
57
|
files;
|
|
58
|
+
backups;
|
|
59
|
+
jobs;
|
|
60
|
+
subUsers;
|
|
61
|
+
features;
|
|
61
62
|
/** @internal */
|
|
62
63
|
constructor(data, http, resolveNodeUrl, onMutated) {
|
|
63
64
|
super();
|
|
@@ -66,12 +67,16 @@ export class Server extends ReactiveResource {
|
|
|
66
67
|
this.onMutated = onMutated;
|
|
67
68
|
this.id = toNanoID(data.id);
|
|
68
69
|
this.groupId = toNanoID(data.group_id);
|
|
69
|
-
this.eggId = toNanoID(data.egg_id);
|
|
70
70
|
this.allocations = new ServerAllocationsManager(this.id, http);
|
|
71
71
|
this.sftp = new ServerSftpManager(this.id, http);
|
|
72
72
|
this.profiles = new ServerProfilesManager(this.id, http);
|
|
73
73
|
this.activity = new ServerActivityManager(this.id, http);
|
|
74
|
-
this.
|
|
74
|
+
this.subUsers = new ServerUserManager(`/servers/${this.id}`, http);
|
|
75
|
+
this.features = new ServerFeaturesManager(this.id, http);
|
|
76
|
+
const node = new NodeClient(this.id, http.getToken(), resolveNodeUrl);
|
|
77
|
+
this.files = new ServerFilesManager(node);
|
|
78
|
+
this.backups = new ServerBackupsManager(node);
|
|
79
|
+
this.jobs = new ServerJobsManager(node);
|
|
75
80
|
this.applyData(data);
|
|
76
81
|
}
|
|
77
82
|
/** Apply raw API data, updating all mutable fields. */
|
|
@@ -80,30 +85,15 @@ export class Server extends ReactiveResource {
|
|
|
80
85
|
this.description = data.description;
|
|
81
86
|
this.notes = data.notes;
|
|
82
87
|
this.restrictedState = data.restricted_state;
|
|
83
|
-
this.eggImageId = data.egg_image_id ? toNanoID(data.egg_image_id) : undefined;
|
|
84
|
-
this.eggImageOverride = data.egg_image_override;
|
|
85
88
|
// Include-gated fields: only overwrite if present in response
|
|
86
89
|
if (data.group)
|
|
87
90
|
this.group = new ServerGroup(data.group);
|
|
88
|
-
if (data.egg)
|
|
89
|
-
this.egg = new Egg(data.egg);
|
|
90
91
|
if (data.status !== undefined) {
|
|
91
92
|
this.status = data.status ? parseStatus(data.status) : undefined;
|
|
92
93
|
}
|
|
93
94
|
if (data.build !== undefined) {
|
|
94
95
|
this.build = data.build ? parseBuild(data.build) : undefined;
|
|
95
96
|
}
|
|
96
|
-
if (data.startup !== undefined) {
|
|
97
|
-
this.startup = data.startup
|
|
98
|
-
? {
|
|
99
|
-
command: data.startup.command,
|
|
100
|
-
variables: Object.fromEntries(Object.entries(data.startup.variables).map(([k, v]) => [
|
|
101
|
-
k,
|
|
102
|
-
{ key: k, ...v, default: v.default },
|
|
103
|
-
])),
|
|
104
|
-
}
|
|
105
|
-
: undefined;
|
|
106
|
-
}
|
|
107
97
|
if (data.allocations !== undefined) {
|
|
108
98
|
this.allocationPorts = data.allocations ?? undefined;
|
|
109
99
|
}
|
|
@@ -111,7 +101,7 @@ export class Server extends ReactiveResource {
|
|
|
111
101
|
this.updatedAt = new Date(data.updated_at);
|
|
112
102
|
this.notify();
|
|
113
103
|
}
|
|
114
|
-
/** Update this server's details
|
|
104
|
+
/** Update this server's details or primary allocation. */
|
|
115
105
|
async update(payload) {
|
|
116
106
|
const body = {};
|
|
117
107
|
if (payload.name !== undefined)
|
|
@@ -124,12 +114,6 @@ export class Server extends ReactiveResource {
|
|
|
124
114
|
if (payload.allocationPrimary) {
|
|
125
115
|
body['allocation_primary'] = payload.allocationPrimary;
|
|
126
116
|
}
|
|
127
|
-
if (payload.startup) {
|
|
128
|
-
body['startup'] = {
|
|
129
|
-
command: payload.startup.command,
|
|
130
|
-
variables: payload.startup.variables,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
117
|
const data = await this.http.patch(`/servers/${this.id}`, body);
|
|
134
118
|
this.applyData(data);
|
|
135
119
|
this.onMutated();
|
|
@@ -170,13 +154,13 @@ function parseStatus(data) {
|
|
|
170
154
|
state: data.state,
|
|
171
155
|
utilization: data.utilization
|
|
172
156
|
? {
|
|
173
|
-
|
|
174
|
-
|
|
157
|
+
ramBytes: data.utilization.ram_bytes,
|
|
158
|
+
ramLimitBytes: data.utilization.ram_limit_bytes,
|
|
175
159
|
cpuAbsolute: data.utilization.cpu_absolute,
|
|
176
160
|
networkRxBytes: data.utilization.network.rx_bytes,
|
|
177
161
|
networkTxBytes: data.utilization.network.tx_bytes,
|
|
178
|
-
uptimeMs: data.utilization.
|
|
179
|
-
|
|
162
|
+
uptimeMs: data.utilization.uptime,
|
|
163
|
+
storageBytes: data.utilization.storage_bytes,
|
|
180
164
|
}
|
|
181
165
|
: null,
|
|
182
166
|
};
|