@pelican.ts/sdk 0.4.16-next.3 → 0.5.1
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/CHANGELOG.md +15 -0
- package/bun.lock +47 -57
- package/dist/api/index.d.mts +115 -66
- package/dist/api/index.d.ts +115 -66
- package/dist/api/index.js +22 -1
- package/dist/api/index.mjs +22 -1
- package/dist/index.d.mts +357 -144
- package/dist/index.d.ts +357 -144
- package/dist/index.js +105 -3
- package/dist/index.mjs +105 -3
- package/dist/types.d.ts +294 -249
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type FileObject = {
|
|
5
|
+
name: string;
|
|
6
|
+
mode: string;
|
|
7
|
+
mode_bits: string;
|
|
8
|
+
size: number;
|
|
9
|
+
is_file: boolean;
|
|
10
|
+
is_symlink: boolean;
|
|
11
|
+
mimetype: string;
|
|
12
|
+
created_at: string;
|
|
13
|
+
modified_at: string;
|
|
14
|
+
};
|
|
5
15
|
|
|
6
16
|
type GenericResponse<T, N extends string = string, M = undefined> = {
|
|
7
17
|
object: N;
|
|
@@ -49,16 +59,74 @@ type ServerDatabase$1 = {
|
|
|
49
59
|
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
50
60
|
type Nullable<T> = T | null;
|
|
51
61
|
|
|
62
|
+
type ServerBackup$1 = {
|
|
63
|
+
uuid: string;
|
|
64
|
+
is_successful: boolean;
|
|
65
|
+
is_locked: boolean;
|
|
66
|
+
name: string;
|
|
67
|
+
ignored_files: string[];
|
|
68
|
+
checksum: Nullable<string>;
|
|
69
|
+
bytes: number;
|
|
70
|
+
created_at: string;
|
|
71
|
+
completed_at: Nullable<string>;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type ServerSignalOption = "start" | "stop" | "restart" | "kill";
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Server limits indicate how many resources can be used by the server
|
|
78
|
+
*/
|
|
52
79
|
type ServerLimits = {
|
|
80
|
+
/**
|
|
81
|
+
* Memory limit in megabytes, 0 = unlimited
|
|
82
|
+
* @remarks
|
|
83
|
+
* This is not a pterodactyl's MiB, it's a MB (multiple of 1000).
|
|
84
|
+
* That means to set 8GB RAM, you should set 8000 instead of 8192
|
|
85
|
+
*/
|
|
53
86
|
memory: number;
|
|
87
|
+
/**
|
|
88
|
+
* Swap limit in megabytes, 0 = disabled, -1 = unlimited
|
|
89
|
+
* @see memory
|
|
90
|
+
*/
|
|
54
91
|
swap: number;
|
|
92
|
+
/**
|
|
93
|
+
* Disk limit in megabytes, 0 = unlimited
|
|
94
|
+
* @see memory
|
|
95
|
+
*/
|
|
55
96
|
disk: number;
|
|
97
|
+
/**
|
|
98
|
+
* IO is an arbitrary value indicating IO importance relative to other servers
|
|
99
|
+
*/
|
|
56
100
|
io: number;
|
|
101
|
+
/**
|
|
102
|
+
* CPU limit in percentage, 0 = unlimited (1 core = 100%)
|
|
103
|
+
*/
|
|
57
104
|
cpu: number;
|
|
105
|
+
/**
|
|
106
|
+
* CPU pinning (Optional)
|
|
107
|
+
* @usage
|
|
108
|
+
* ```
|
|
109
|
+
* 1 or 1,2,4 or 1-4
|
|
110
|
+
* ```
|
|
111
|
+
* @remarks
|
|
112
|
+
* Can be useful to pin workloads to P-cores and avoid E-cores or HT/SMT cores
|
|
113
|
+
* @see https://superuser.com/questions/122536/what-is-hyper-threading-and-how-does-it-work
|
|
114
|
+
*/
|
|
58
115
|
threads: Nullable<number | string>;
|
|
116
|
+
/**
|
|
117
|
+
* If OOM killer should be disabled, opposite of {@link oom_killer}
|
|
118
|
+
* @deprecated use {@link oom_killer}
|
|
119
|
+
*/
|
|
59
120
|
oom_disabled: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* If OOM killer should be enabled, opposite of {@link oom_disabled}
|
|
123
|
+
*/
|
|
60
124
|
oom_killer: boolean;
|
|
61
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Feature limits indicate how many features can user enable by themselves. It doesn't include features assigned
|
|
128
|
+
* by admins
|
|
129
|
+
*/
|
|
62
130
|
type FeatureLimits = {
|
|
63
131
|
databases: number;
|
|
64
132
|
allocations: number;
|
|
@@ -79,40 +147,6 @@ type StartupMeta = {
|
|
|
79
147
|
raw_startup_command: string;
|
|
80
148
|
};
|
|
81
149
|
|
|
82
|
-
type ServerBackup$1 = {
|
|
83
|
-
uuid: string;
|
|
84
|
-
is_successful: boolean;
|
|
85
|
-
is_locked: boolean;
|
|
86
|
-
name: string;
|
|
87
|
-
ignored_files: string[];
|
|
88
|
-
checksum: Nullable<string>;
|
|
89
|
-
bytes: number;
|
|
90
|
-
created_at: string;
|
|
91
|
-
completed_at: Nullable<string>;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
type EggVariable = {
|
|
95
|
-
name: string;
|
|
96
|
-
description: string;
|
|
97
|
-
env_variable: string;
|
|
98
|
-
default_value: string;
|
|
99
|
-
server_value: string;
|
|
100
|
-
is_editable: boolean;
|
|
101
|
-
rules: string;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
type FileObject = {
|
|
105
|
-
name: string;
|
|
106
|
-
mode: string;
|
|
107
|
-
mode_bits: string;
|
|
108
|
-
size: number;
|
|
109
|
-
is_file: boolean;
|
|
110
|
-
is_symlink: boolean;
|
|
111
|
-
mimetype: string;
|
|
112
|
-
created_at: string;
|
|
113
|
-
modified_at: string;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
150
|
type Schedule = {
|
|
117
151
|
id: number;
|
|
118
152
|
name: string;
|
|
@@ -145,101 +179,14 @@ type ScheduleTask = {
|
|
|
145
179
|
updated_at: Nullable<string>;
|
|
146
180
|
};
|
|
147
181
|
|
|
148
|
-
type
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
[SOCKET_EVENT.INSTALL_STARTED]: undefined;
|
|
157
|
-
[SOCKET_EVENT.INSTALL_COMPLETED]: undefined;
|
|
158
|
-
[SOCKET_EVENT.TRANSFER_LOGS]: string;
|
|
159
|
-
[SOCKET_EVENT.TRANSFER_STATUS]: string;
|
|
160
|
-
[SOCKET_EVENT.BACKUP_COMPLETED]: BackupCompletedJson;
|
|
161
|
-
[SOCKET_EVENT.BACKUP_RESTORE_COMPLETED]: undefined;
|
|
162
|
-
[SOCKET_EVENT.TOKEN_EXPIRING]: undefined;
|
|
163
|
-
[SOCKET_EVENT.TOKEN_EXPIRED]: undefined;
|
|
164
|
-
[SOCKET_EVENT.JWT_ERROR]: string;
|
|
165
|
-
};
|
|
166
|
-
type Listener<E extends SOCKET_EVENT> = SocketEventPayloadMap[E] extends undefined ? () => void : (payload: SocketEventPayloadMap[E]) => void;
|
|
167
|
-
type CloseEventLike = Parameters<NonNullable<WebSocket["onclose"]>>[0];
|
|
168
|
-
type ErrorEventLike = Parameters<NonNullable<WebSocket["onerror"]>>[0];
|
|
169
|
-
declare class ServerWebsocket {
|
|
170
|
-
private readonly r;
|
|
171
|
-
private readonly serverId;
|
|
172
|
-
private socket?;
|
|
173
|
-
private currentToken?;
|
|
174
|
-
private readonly bus;
|
|
175
|
-
private debugLogging;
|
|
176
|
-
private stripColors;
|
|
177
|
-
private detachMessageListener?;
|
|
178
|
-
constructor(requester: AxiosInstance, id: string, stripColors?: boolean);
|
|
179
|
-
on<E extends SOCKET_EVENT>(event: E, listener: Listener<E>): () => void;
|
|
180
|
-
deregister<E extends SOCKET_EVENT>(event: E, listener: Listener<E>): void;
|
|
181
|
-
private emit;
|
|
182
|
-
connect(resumable?: boolean, debugLogging?: boolean): Promise<void>;
|
|
183
|
-
onSocketDisconnect(handler: (event: CloseEventLike) => void): void;
|
|
184
|
-
onSocketError(handler: (event: ErrorEventLike) => void): void;
|
|
185
|
-
makeResumable(disconnectsToo: boolean): void;
|
|
186
|
-
private attachMessageListener;
|
|
187
|
-
private handleIncomingMessage;
|
|
188
|
-
private parseMessage;
|
|
189
|
-
private normalisePayload;
|
|
190
|
-
private dispatchMessage;
|
|
191
|
-
private refreshCredentials;
|
|
192
|
-
private authenticate;
|
|
193
|
-
disconnect(): void;
|
|
194
|
-
requestStats(): void;
|
|
195
|
-
requestLogs(): void;
|
|
196
|
-
private send;
|
|
197
|
-
getStats(): Promise<StatsWsJson>;
|
|
198
|
-
getLogs(): Promise<string[]>;
|
|
199
|
-
sendPoweraction(action: ServerSignalOption): void;
|
|
200
|
-
sendCommand(cmd: string): void;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Source: https://github.com/pterodactyl/panel/blob/1.0-develop/resources/scripts/components/server/events.ts
|
|
205
|
-
*/
|
|
206
|
-
declare enum SOCKET_EVENT {
|
|
207
|
-
AUTH_SUCCESS = "auth success",
|
|
208
|
-
DAEMON_MESSAGE = "daemon message",
|
|
209
|
-
DAEMON_ERROR = "daemon error",
|
|
210
|
-
INSTALL_OUTPUT = "install output",
|
|
211
|
-
INSTALL_STARTED = "install started",
|
|
212
|
-
INSTALL_COMPLETED = "install completed",
|
|
213
|
-
CONSOLE_OUTPUT = "console output",
|
|
214
|
-
STATUS = "status",
|
|
215
|
-
STATS = "stats",
|
|
216
|
-
TRANSFER_LOGS = "transfer logs",
|
|
217
|
-
TRANSFER_STATUS = "transfer status",
|
|
218
|
-
BACKUP_COMPLETED = "backup completed",
|
|
219
|
-
BACKUP_RESTORE_COMPLETED = "backup restore completed",
|
|
220
|
-
TOKEN_EXPIRING = "token expiring",
|
|
221
|
-
TOKEN_EXPIRED = "token expired",
|
|
222
|
-
JWT_ERROR = "jwt error"
|
|
223
|
-
}
|
|
224
|
-
type BackupCompletedJson = {
|
|
225
|
-
checksum: string;
|
|
226
|
-
checksum_type: "sha1";
|
|
227
|
-
file_size: number;
|
|
228
|
-
is_successful: boolean;
|
|
229
|
-
uuid: string;
|
|
230
|
-
};
|
|
231
|
-
type PowerState = "starting" | "stopping" | "running" | "offline";
|
|
232
|
-
type StatsWsJson = {
|
|
233
|
-
memory_bytes: number;
|
|
234
|
-
memory_limit_bytes: number;
|
|
235
|
-
cpu_absolute: number;
|
|
236
|
-
network: {
|
|
237
|
-
rx_bytes: number;
|
|
238
|
-
tx_bytes: number;
|
|
239
|
-
};
|
|
240
|
-
state: PowerState;
|
|
241
|
-
uptime: number;
|
|
242
|
-
disk_bytes: number;
|
|
182
|
+
type EggVariable = {
|
|
183
|
+
name: string;
|
|
184
|
+
description: string;
|
|
185
|
+
env_variable: string;
|
|
186
|
+
default_value: string;
|
|
187
|
+
server_value: string;
|
|
188
|
+
is_editable: boolean;
|
|
189
|
+
rules: string;
|
|
243
190
|
};
|
|
244
191
|
|
|
245
192
|
type ServerAllocation$1 = {
|
|
@@ -284,7 +231,7 @@ type Server$1 = {
|
|
|
284
231
|
docker_image: string;
|
|
285
232
|
egg_features: Nullable<string[]>;
|
|
286
233
|
feature_limits: FeatureLimits;
|
|
287
|
-
status: Nullable<
|
|
234
|
+
status: Nullable<ServerStats["current_state"]>;
|
|
288
235
|
is_suspended: boolean;
|
|
289
236
|
is_installing: boolean;
|
|
290
237
|
is_transferring: boolean;
|
|
@@ -352,12 +299,109 @@ type Permission = {
|
|
|
352
299
|
keys: Record<string, string>;
|
|
353
300
|
};
|
|
354
301
|
|
|
302
|
+
type SocketEventPayloadMap = {
|
|
303
|
+
[SOCKET_EVENT.AUTH_SUCCESS]: undefined;
|
|
304
|
+
[SOCKET_EVENT.STATUS]: PowerState;
|
|
305
|
+
[SOCKET_EVENT.CONSOLE_OUTPUT]: string;
|
|
306
|
+
[SOCKET_EVENT.STATS]: StatsWsJson;
|
|
307
|
+
[SOCKET_EVENT.DAEMON_ERROR]: undefined;
|
|
308
|
+
[SOCKET_EVENT.DAEMON_MESSAGE]: string;
|
|
309
|
+
[SOCKET_EVENT.INSTALL_OUTPUT]: string;
|
|
310
|
+
[SOCKET_EVENT.INSTALL_STARTED]: undefined;
|
|
311
|
+
[SOCKET_EVENT.INSTALL_COMPLETED]: undefined;
|
|
312
|
+
[SOCKET_EVENT.TRANSFER_LOGS]: string;
|
|
313
|
+
[SOCKET_EVENT.TRANSFER_STATUS]: string;
|
|
314
|
+
[SOCKET_EVENT.BACKUP_COMPLETED]: BackupCompletedJson;
|
|
315
|
+
[SOCKET_EVENT.BACKUP_RESTORE_COMPLETED]: undefined;
|
|
316
|
+
[SOCKET_EVENT.TOKEN_EXPIRING]: undefined;
|
|
317
|
+
[SOCKET_EVENT.TOKEN_EXPIRED]: undefined;
|
|
318
|
+
[SOCKET_EVENT.JWT_ERROR]: string;
|
|
319
|
+
};
|
|
320
|
+
type Listener<E extends SOCKET_EVENT> = SocketEventPayloadMap[E] extends undefined ? () => void : (payload: SocketEventPayloadMap[E]) => void;
|
|
321
|
+
type CloseEventLike = Parameters<NonNullable<WebSocket["onclose"]>>[0];
|
|
322
|
+
type ErrorEventLike = Parameters<NonNullable<WebSocket["onerror"]>>[0];
|
|
323
|
+
declare class ServerWebsocket {
|
|
324
|
+
private readonly r;
|
|
325
|
+
private readonly serverId;
|
|
326
|
+
private socket?;
|
|
327
|
+
private currentToken?;
|
|
328
|
+
private readonly bus;
|
|
329
|
+
private debugLogging;
|
|
330
|
+
private stripColors;
|
|
331
|
+
private detachMessageListener?;
|
|
332
|
+
constructor(requester: AxiosInstance, id: string, stripColors?: boolean);
|
|
333
|
+
on<E extends SOCKET_EVENT>(event: E, listener: Listener<E>): () => void;
|
|
334
|
+
deregister<E extends SOCKET_EVENT>(event: E, listener: Listener<E>): void;
|
|
335
|
+
private emit;
|
|
336
|
+
connect(resumable?: boolean, debugLogging?: boolean): Promise<void>;
|
|
337
|
+
onSocketDisconnect(handler: (event: CloseEventLike) => void): void;
|
|
338
|
+
onSocketError(handler: (event: ErrorEventLike) => void): void;
|
|
339
|
+
makeResumable(disconnectsToo: boolean): void;
|
|
340
|
+
private attachMessageListener;
|
|
341
|
+
private handleIncomingMessage;
|
|
342
|
+
private parseMessage;
|
|
343
|
+
private normalisePayload;
|
|
344
|
+
private dispatchMessage;
|
|
345
|
+
private refreshCredentials;
|
|
346
|
+
private authenticate;
|
|
347
|
+
disconnect(): void;
|
|
348
|
+
requestStats(): void;
|
|
349
|
+
requestLogs(): void;
|
|
350
|
+
private send;
|
|
351
|
+
getStats(): Promise<StatsWsJson>;
|
|
352
|
+
getLogs(): Promise<string[]>;
|
|
353
|
+
sendPoweraction(action: ServerSignalOption): void;
|
|
354
|
+
sendCommand(cmd: string): void;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Source: https://github.com/pterodactyl/panel/blob/1.0-develop/resources/scripts/components/server/events.ts
|
|
359
|
+
*/
|
|
360
|
+
declare enum SOCKET_EVENT {
|
|
361
|
+
AUTH_SUCCESS = "auth success",
|
|
362
|
+
DAEMON_MESSAGE = "daemon message",
|
|
363
|
+
DAEMON_ERROR = "daemon error",
|
|
364
|
+
INSTALL_OUTPUT = "install output",
|
|
365
|
+
INSTALL_STARTED = "install started",
|
|
366
|
+
INSTALL_COMPLETED = "install completed",
|
|
367
|
+
CONSOLE_OUTPUT = "console output",
|
|
368
|
+
STATUS = "status",
|
|
369
|
+
STATS = "stats",
|
|
370
|
+
TRANSFER_LOGS = "transfer logs",
|
|
371
|
+
TRANSFER_STATUS = "transfer status",
|
|
372
|
+
BACKUP_COMPLETED = "backup completed",
|
|
373
|
+
BACKUP_RESTORE_COMPLETED = "backup restore completed",
|
|
374
|
+
TOKEN_EXPIRING = "token expiring",
|
|
375
|
+
TOKEN_EXPIRED = "token expired",
|
|
376
|
+
JWT_ERROR = "jwt error"
|
|
377
|
+
}
|
|
378
|
+
type BackupCompletedJson = {
|
|
379
|
+
checksum: string;
|
|
380
|
+
checksum_type: "sha1";
|
|
381
|
+
file_size: number;
|
|
382
|
+
is_successful: boolean;
|
|
383
|
+
uuid: string;
|
|
384
|
+
};
|
|
385
|
+
type PowerState = "starting" | "stopping" | "running" | "offline";
|
|
386
|
+
type StatsWsJson = {
|
|
387
|
+
memory_bytes: number;
|
|
388
|
+
memory_limit_bytes: number;
|
|
389
|
+
cpu_absolute: number;
|
|
390
|
+
network: {
|
|
391
|
+
rx_bytes: number;
|
|
392
|
+
tx_bytes: number;
|
|
393
|
+
};
|
|
394
|
+
state: PowerState;
|
|
395
|
+
uptime: number;
|
|
396
|
+
disk_bytes: number;
|
|
397
|
+
};
|
|
398
|
+
|
|
355
399
|
declare class Account$1 {
|
|
356
400
|
private readonly r;
|
|
357
401
|
constructor(requester: AxiosInstance);
|
|
358
402
|
info: () => Promise<User>;
|
|
359
403
|
updateEmail: (newEmail: string, password: string) => Promise<void>;
|
|
360
|
-
updatePassword: (newPassword: string) => Promise<void>;
|
|
404
|
+
updatePassword: (currentPassword: string, newPassword: string) => Promise<void>;
|
|
361
405
|
apiKeys: {
|
|
362
406
|
list: () => Promise<APIKey[]>;
|
|
363
407
|
create: (description: string, allowed_ips?: string[]) => Promise<APIKey & {
|
|
@@ -567,6 +611,9 @@ declare class Account {
|
|
|
567
611
|
readonly language: string;
|
|
568
612
|
readonly image: string;
|
|
569
613
|
readonly admin: boolean;
|
|
614
|
+
/**
|
|
615
|
+
* Has currently no significance
|
|
616
|
+
*/
|
|
570
617
|
readonly root_admin: boolean;
|
|
571
618
|
private $has2faEnabled;
|
|
572
619
|
get has2faEnabled(): boolean;
|
|
@@ -574,7 +621,7 @@ declare class Account {
|
|
|
574
621
|
readonly updatedAt: Date;
|
|
575
622
|
constructor(client: Client$1, user: User);
|
|
576
623
|
updateEmail: (newEmail: string, password: string) => Promise<void>;
|
|
577
|
-
updatePassword: (newPassword: string) => Promise<void>;
|
|
624
|
+
updatePassword: (currentPassword: string, newPassword: string) => Promise<void>;
|
|
578
625
|
listApiKeys: () => Promise<APIKey[]>;
|
|
579
626
|
createApiKey: (description: string, allowed_ips?: string[]) => Promise<APIKey & {
|
|
580
627
|
secret_token: string;
|
|
@@ -585,6 +632,19 @@ declare class Account {
|
|
|
585
632
|
deleteSshKey: (fingerprint: string) => Promise<void>;
|
|
586
633
|
}
|
|
587
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Instance of a Humane Pelican Server Allocation
|
|
637
|
+
*
|
|
638
|
+
* @class
|
|
639
|
+
* @example
|
|
640
|
+
* You can create allocation from a raw client
|
|
641
|
+
* ```ts
|
|
642
|
+
* import {PelicanAPIClient} from "@pelican.ts/sdk/api"
|
|
643
|
+
* const client = new PelicanAPIClient(...)
|
|
644
|
+
* const allocData = await client.account.server(...).allocations.list()
|
|
645
|
+
* const alloc = new ServerAllocation(client, allocData[0])
|
|
646
|
+
* ```
|
|
647
|
+
*/
|
|
588
648
|
declare class ServerAllocation {
|
|
589
649
|
private readonly client;
|
|
590
650
|
readonly alias: Nullable<string>;
|
|
@@ -596,11 +656,34 @@ declare class ServerAllocation {
|
|
|
596
656
|
get notes(): Nullable<string>;
|
|
597
657
|
readonly port: number;
|
|
598
658
|
constructor(client: ServerClient, alloc: ServerAllocation$1);
|
|
659
|
+
/**
|
|
660
|
+
* Set description for this allocation
|
|
661
|
+
* @param notes
|
|
662
|
+
*/
|
|
599
663
|
setNotes: (notes: string) => Promise<void>;
|
|
664
|
+
/**
|
|
665
|
+
* Make port primary
|
|
666
|
+
*/
|
|
600
667
|
makeDefault: () => Promise<void>;
|
|
668
|
+
/**
|
|
669
|
+
* Remove allocation (if user is allowed to manage allocations by themselves)
|
|
670
|
+
*/
|
|
601
671
|
unassign: () => Promise<void>;
|
|
602
672
|
}
|
|
603
673
|
|
|
674
|
+
/**
|
|
675
|
+
* Instance of a Humane Pelican Server Backup
|
|
676
|
+
*
|
|
677
|
+
* @class
|
|
678
|
+
* @example
|
|
679
|
+
* You can create account from a raw client
|
|
680
|
+
* ```ts
|
|
681
|
+
* import {PelicanAPIClient} from "@pelican.ts/sdk/api"
|
|
682
|
+
* const client = new PelicanAPIClient(...)
|
|
683
|
+
* const backupData = await client.account.server(...).backups.info(...)
|
|
684
|
+
* const backup = new ServerBackup(client, backupData)
|
|
685
|
+
* ```
|
|
686
|
+
*/
|
|
604
687
|
declare class ServerBackup {
|
|
605
688
|
private readonly client;
|
|
606
689
|
readonly bytes: number;
|
|
@@ -621,6 +704,19 @@ declare class ServerBackup {
|
|
|
621
704
|
restore: (truncate: boolean) => Promise<void>;
|
|
622
705
|
}
|
|
623
706
|
|
|
707
|
+
/**
|
|
708
|
+
* Instance of a Humane Pelican Server Database
|
|
709
|
+
*
|
|
710
|
+
* @class
|
|
711
|
+
* @example
|
|
712
|
+
* You can create account from a raw client
|
|
713
|
+
* ```ts
|
|
714
|
+
* import {PelicanAPIClient} from "@pelican.ts/sdk/api"
|
|
715
|
+
* const client = new PelicanAPIClient(...)
|
|
716
|
+
* const dbData = await client.account.server(...).databases.info(...)
|
|
717
|
+
* const database = new ServerDatabase(client, dbData)
|
|
718
|
+
* ```
|
|
719
|
+
*/
|
|
624
720
|
declare class ServerDatabase {
|
|
625
721
|
private readonly client;
|
|
626
722
|
readonly allowConnectionsFrom: string;
|
|
@@ -633,10 +729,26 @@ declare class ServerDatabase {
|
|
|
633
729
|
get password(): string | undefined;
|
|
634
730
|
readonly username: string;
|
|
635
731
|
constructor(client: ServerClient, database: ServerDatabase$1);
|
|
732
|
+
/**
|
|
733
|
+
* Reset password to a random one, password will be updated in this ServerDatabase instance
|
|
734
|
+
*/
|
|
636
735
|
rotatePassword: () => Promise<void>;
|
|
637
736
|
delete: () => Promise<void>;
|
|
638
737
|
}
|
|
639
738
|
|
|
739
|
+
/**
|
|
740
|
+
* Instance of a Humane Pelican Server File/Folder
|
|
741
|
+
*
|
|
742
|
+
* @class
|
|
743
|
+
* @example
|
|
744
|
+
* You can create account from a raw client
|
|
745
|
+
* ```ts
|
|
746
|
+
* import {PelicanAPIClient} from "@pelican.ts/sdk/api"
|
|
747
|
+
* const client = new PelicanAPIClient(...)
|
|
748
|
+
* const filesData = await client.account.server(...).files.list(FOLDER)
|
|
749
|
+
* const server = new ServerFile(client, filesData[0], FOLDER)
|
|
750
|
+
* ```
|
|
751
|
+
*/
|
|
640
752
|
declare class ServerFile {
|
|
641
753
|
private readonly client;
|
|
642
754
|
private readonly dir;
|
|
@@ -651,6 +763,12 @@ declare class ServerFile {
|
|
|
651
763
|
readonly name: string;
|
|
652
764
|
readonly size: number;
|
|
653
765
|
constructor(client: ServerClient, file: FileObject, dir?: string);
|
|
766
|
+
/**
|
|
767
|
+
* Is this file an archive
|
|
768
|
+
*
|
|
769
|
+
* @remarks
|
|
770
|
+
* It uses extension check instead of mimetype as Pelican currently has some issue with mimetypes
|
|
771
|
+
*/
|
|
654
772
|
get isArchive(): boolean;
|
|
655
773
|
/**
|
|
656
774
|
* Return the contents of a file. To read binary file (non-editable) use {@link download} instead
|
|
@@ -667,10 +785,26 @@ declare class ServerFile {
|
|
|
667
785
|
chmod: (mode: number) => Promise<void>;
|
|
668
786
|
}
|
|
669
787
|
|
|
788
|
+
/**
|
|
789
|
+
* Instance of a Humane Pelican Server Schedule
|
|
790
|
+
*
|
|
791
|
+
* @class
|
|
792
|
+
* @example
|
|
793
|
+
* You can create account from a raw client
|
|
794
|
+
* ```ts
|
|
795
|
+
* import {PelicanAPIClient} from "@pelican.ts/sdk/api"
|
|
796
|
+
* const client = new PelicanAPIClient(...)
|
|
797
|
+
* const schedData = await client.account.server(...).schedules.list()
|
|
798
|
+
* const server = new ServerSchedule(client, schedData[0])
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
670
801
|
declare class ServerSchedule {
|
|
671
802
|
private readonly client;
|
|
672
803
|
readonly createdAt: Date;
|
|
673
804
|
private $cron;
|
|
805
|
+
/**
|
|
806
|
+
* CRON representation of schedule
|
|
807
|
+
*/
|
|
674
808
|
get cron(): {
|
|
675
809
|
day_of_week: string;
|
|
676
810
|
day_of_month: string;
|
|
@@ -679,14 +813,23 @@ declare class ServerSchedule {
|
|
|
679
813
|
};
|
|
680
814
|
readonly id: number;
|
|
681
815
|
private $isActive;
|
|
816
|
+
/**
|
|
817
|
+
* Is this schedule enabled
|
|
818
|
+
*/
|
|
682
819
|
get isActive(): boolean;
|
|
683
820
|
private $isProcessing;
|
|
821
|
+
/**
|
|
822
|
+
* Is this schedule currently running
|
|
823
|
+
*/
|
|
684
824
|
get isProcessing(): boolean;
|
|
685
825
|
readonly lastRunAt: Nullable<Date>;
|
|
686
826
|
private $name;
|
|
687
827
|
get name(): string;
|
|
688
828
|
readonly nextRunAt: Date;
|
|
689
829
|
private $onlyWhenOnline;
|
|
830
|
+
/**
|
|
831
|
+
* Should schedule run only if server is online
|
|
832
|
+
*/
|
|
690
833
|
get onlyWhenOnline(): boolean;
|
|
691
834
|
readonly tasks: ServerScheduleTask[];
|
|
692
835
|
private $updatedAt;
|
|
@@ -709,18 +852,36 @@ declare class ServerScheduleTask {
|
|
|
709
852
|
private readonly client;
|
|
710
853
|
private readonly scheduleId;
|
|
711
854
|
private $action;
|
|
855
|
+
/**
|
|
856
|
+
* Task action (command would likely need server to be online)
|
|
857
|
+
*/
|
|
712
858
|
get action(): "command" | "power" | "backup" | "delete_files";
|
|
713
859
|
private $continueOnFailure;
|
|
860
|
+
/**
|
|
861
|
+
* Should we fail on error or continue with other tasks?
|
|
862
|
+
*/
|
|
714
863
|
get continueOnFailure(): boolean;
|
|
715
864
|
readonly createdAt: Date;
|
|
716
865
|
readonly id: number;
|
|
717
866
|
private $isQueued;
|
|
867
|
+
/**
|
|
868
|
+
* Is this task queued right now?
|
|
869
|
+
*/
|
|
718
870
|
get isQueued(): boolean;
|
|
719
871
|
private $payload;
|
|
872
|
+
/**
|
|
873
|
+
* Whatever task should do: command to execute, power action or list of files to backup
|
|
874
|
+
*/
|
|
720
875
|
get payload(): string;
|
|
721
876
|
private $sequenceId;
|
|
877
|
+
/**
|
|
878
|
+
* Order of this task in defined schedule
|
|
879
|
+
*/
|
|
722
880
|
get sequenceId(): number;
|
|
723
881
|
private $timeOffset;
|
|
882
|
+
/**
|
|
883
|
+
* Time offset in seconds relative to schedule start time
|
|
884
|
+
*/
|
|
724
885
|
get timeOffset(): number;
|
|
725
886
|
private $updatedAt;
|
|
726
887
|
get updatedAt(): Nullable<Date>;
|
|
@@ -729,6 +890,19 @@ declare class ServerScheduleTask {
|
|
|
729
890
|
update: (opts: PartialBy<Pick<ScheduleTask, "action" | "payload" | "time_offset" | "sequence_id" | "continue_on_failure">, "payload" | "sequence_id" | "continue_on_failure">) => Promise<void>;
|
|
730
891
|
}
|
|
731
892
|
|
|
893
|
+
/**
|
|
894
|
+
* Instance of a Humane Pelican Server Subuser
|
|
895
|
+
*
|
|
896
|
+
* @class
|
|
897
|
+
* @example
|
|
898
|
+
* You can create account from a raw client
|
|
899
|
+
* ```ts
|
|
900
|
+
* import {PelicanAPIClient} from "@pelican.ts/sdk/api"
|
|
901
|
+
* const client = new PelicanAPIClient(...)
|
|
902
|
+
* const userData = await client.account.server(...).users.info(...)
|
|
903
|
+
* const user = new ServerUser(client, userData)
|
|
904
|
+
* ```
|
|
905
|
+
*/
|
|
732
906
|
declare class ServerUser {
|
|
733
907
|
private readonly client;
|
|
734
908
|
readonly uuid: string;
|
|
@@ -737,6 +911,10 @@ declare class ServerUser {
|
|
|
737
911
|
readonly language: string;
|
|
738
912
|
readonly image: string;
|
|
739
913
|
readonly admin: boolean;
|
|
914
|
+
/**
|
|
915
|
+
* Currently unused
|
|
916
|
+
* @deprecated
|
|
917
|
+
*/
|
|
740
918
|
readonly root_admin: boolean;
|
|
741
919
|
readonly has2faEnabled: boolean;
|
|
742
920
|
readonly createdAt: Date;
|
|
@@ -752,7 +930,7 @@ declare class ServerUser {
|
|
|
752
930
|
*
|
|
753
931
|
* @class
|
|
754
932
|
* @example
|
|
755
|
-
* You can create
|
|
933
|
+
* You can create server from a raw client
|
|
756
934
|
* ```ts
|
|
757
935
|
* import {PelicanAPIClient} from "@pelican.ts/sdk/api"
|
|
758
936
|
* const client = new PelicanAPIClient(...)
|
|
@@ -779,7 +957,8 @@ declare class Server {
|
|
|
779
957
|
get name(): string;
|
|
780
958
|
/**
|
|
781
959
|
* Node name used by this server
|
|
782
|
-
* @
|
|
960
|
+
* @remarks
|
|
961
|
+
* This is the name of the node used by this server, not the ID
|
|
783
962
|
*/
|
|
784
963
|
readonly node: string;
|
|
785
964
|
readonly isNodeUnderMaintenance: boolean;
|
|
@@ -791,6 +970,9 @@ declare class Server {
|
|
|
791
970
|
private $description;
|
|
792
971
|
get description(): string;
|
|
793
972
|
readonly limits: ServerLimits;
|
|
973
|
+
/**
|
|
974
|
+
* It's a Startup command used to start the server
|
|
975
|
+
*/
|
|
794
976
|
readonly invocation: string;
|
|
795
977
|
private $dockerImage;
|
|
796
978
|
get dockerImage(): string;
|
|
@@ -801,11 +983,20 @@ declare class Server {
|
|
|
801
983
|
readonly isInstalling: boolean;
|
|
802
984
|
readonly isTransferring: boolean;
|
|
803
985
|
readonly allocations: ServerAllocation[];
|
|
986
|
+
/**
|
|
987
|
+
* Egg variables
|
|
988
|
+
*/
|
|
804
989
|
readonly variables: EggVariable[];
|
|
990
|
+
/**
|
|
991
|
+
* Egg used by this server, available only if request had include=egg
|
|
992
|
+
*/
|
|
805
993
|
readonly egg?: {
|
|
806
994
|
uuid: string;
|
|
807
995
|
name: string;
|
|
808
996
|
};
|
|
997
|
+
/**
|
|
998
|
+
* Server subusers, available only if request had include=subusers
|
|
999
|
+
*/
|
|
809
1000
|
readonly subusers?: ServerUser[];
|
|
810
1001
|
constructor(client: ServerClient, server: Server$1);
|
|
811
1002
|
rename: (name: string) => Promise<void>;
|
|
@@ -824,23 +1015,45 @@ declare class Server {
|
|
|
824
1015
|
include?: "password"[];
|
|
825
1016
|
page?: number;
|
|
826
1017
|
}) => Promise<ServerDatabase[]>;
|
|
1018
|
+
/**
|
|
1019
|
+
* Create a database
|
|
1020
|
+
* @param database - optional database name (leave blank for autogenerated)
|
|
1021
|
+
* @param remote - allow connections from (ip, % or anything db-wise)
|
|
1022
|
+
*
|
|
1023
|
+
* @remarks
|
|
1024
|
+
* I have no idea why API endpoint doesn't allow to select database host
|
|
1025
|
+
*/
|
|
827
1026
|
createDatabase: (database: string, remote: string) => Promise<ServerDatabase>;
|
|
828
1027
|
getSchedules: () => Promise<ServerSchedule[]>;
|
|
829
1028
|
createSchedule: (...opts: Parameters<ServerSchedules["create"]>) => Promise<ServerSchedule>;
|
|
830
1029
|
getBackups: (page?: number) => Promise<ServerBackup[]>;
|
|
831
1030
|
createBackup: (...args: Parameters<ServerBackups["create"]>) => Promise<ServerBackup>;
|
|
832
1031
|
getAllocations: () => Promise<ServerAllocation[]>;
|
|
1032
|
+
/**
|
|
1033
|
+
* Create new allocation (if user is allowed to manage allocations by themselves)
|
|
1034
|
+
*/
|
|
833
1035
|
createAllocation: () => Promise<ServerAllocation>;
|
|
834
1036
|
getFiles: (path?: string) => Promise<ServerFile[]>;
|
|
835
1037
|
createFolder: (...opts: Parameters<ServerFiles["createFolder"]>) => Promise<void>;
|
|
836
1038
|
uploadFile: (...opts: Parameters<ServerFiles["upload"]>) => Promise<void>;
|
|
837
1039
|
uploadFileGetUrl: (...opts: Parameters<ServerFiles["uploadGetUrl"]>) => Promise<string>;
|
|
1040
|
+
/**
|
|
1041
|
+
* Make wings agent download file or archive folder from specified URL instead of uploading directly
|
|
1042
|
+
*/
|
|
838
1043
|
pullFileFromRemote: (...opts: Parameters<ServerFiles["pullFromRemote"]>) => Promise<void>;
|
|
839
1044
|
compressMultipleFiles: (...opts: Parameters<ServerFiles["compress"]>) => Promise<FileObject>;
|
|
840
1045
|
renameMultipleFiles: (...opts: Parameters<ServerFiles["rename"]>) => Promise<void>;
|
|
841
1046
|
deleteMultipleFiles: (...opts: Parameters<ServerFiles["delete"]>) => Promise<void>;
|
|
842
1047
|
getUsers: () => Promise<ServerUser[]>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Create a subuser
|
|
1050
|
+
* @param email
|
|
1051
|
+
* @param permissions
|
|
1052
|
+
*/
|
|
843
1053
|
createUser: (email: string, permissions: SubuserPermission[] | string[]) => Promise<ServerUser>;
|
|
1054
|
+
/**
|
|
1055
|
+
* Get server egg variables and startup commands
|
|
1056
|
+
*/
|
|
844
1057
|
getStartupInfo: () => Promise<CustomListResponse<StartupParams, StartupMeta>>;
|
|
845
1058
|
setStartupVariable: (key: string, value: string) => Promise<StartupParams>;
|
|
846
1059
|
}
|
|
@@ -872,17 +1085,17 @@ declare class Client {
|
|
|
872
1085
|
* List servers
|
|
873
1086
|
*
|
|
874
1087
|
* @param opts Filtering options (all optional)
|
|
1088
|
+
*
|
|
1089
|
+
* @remarks
|
|
1090
|
+
* `type` — Server access type (Default: accessible)
|
|
1091
|
+
*
|
|
1092
|
+
* Variants:
|
|
1093
|
+
* - `accessible` — your servers and servers you have access to as a subuser
|
|
1094
|
+
* - `mine` — only your servers
|
|
1095
|
+
* - `admin` — only servers you have admin access to (excluding yours)
|
|
1096
|
+
* - `admin-all` — all servers you have admin access to
|
|
875
1097
|
*/
|
|
876
1098
|
listServers: (opts?: {
|
|
877
|
-
/**
|
|
878
|
-
* Server access type (Default: accessible)
|
|
879
|
-
*
|
|
880
|
-
* Variants:
|
|
881
|
-
* - `accessible` — your servers and servers you have access to as a subuser
|
|
882
|
-
* - `mine` — only your servers
|
|
883
|
-
* - `admin` — only servers you have admin access to (excluding yours)
|
|
884
|
-
* - `admin-all` — all servers you have admin access to
|
|
885
|
-
*/
|
|
886
1099
|
type?: "accessible" | "mine" | "admin" | "admin-all";
|
|
887
1100
|
page?: number;
|
|
888
1101
|
per_page?: number;
|