wispjs 2.1.3 → 2.1.4
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/README.md +4 -4
- package/{wisp.ts → dist/wisp.d.ts} +11 -28
- package/dist/wisp.js +34 -0
- package/dist/wisp_api/apis/allocations.d.ts +55 -0
- package/dist/wisp_api/apis/allocations.js +32 -0
- package/dist/wisp_api/apis/audit_log.d.ts +68 -0
- package/dist/wisp_api/apis/audit_log.js +21 -0
- package/{wisp_api/apis/backups.ts → dist/wisp_api/apis/backups.d.ts} +13 -51
- package/dist/wisp_api/apis/backups.js +93 -0
- package/dist/wisp_api/apis/databases.d.ts +61 -0
- package/dist/wisp_api/apis/databases.js +43 -0
- package/dist/wisp_api/apis/fastdl.d.ts +19 -0
- package/dist/wisp_api/apis/fastdl.js +21 -0
- package/dist/wisp_api/apis/filesystem.d.ts +200 -0
- package/dist/wisp_api/apis/filesystem.js +182 -0
- package/dist/wisp_api/apis/index.d.ts +52 -0
- package/dist/wisp_api/apis/index.js +100 -0
- package/dist/wisp_api/apis/mods.d.ts +40 -0
- package/dist/wisp_api/apis/mods.js +30 -0
- package/dist/wisp_api/apis/schedules.d.ts +179 -0
- package/dist/wisp_api/apis/schedules.js +167 -0
- package/dist/wisp_api/apis/servers.d.ts +120 -0
- package/dist/wisp_api/apis/servers.js +76 -0
- package/dist/wisp_api/apis/startup.d.ts +52 -0
- package/dist/wisp_api/apis/startup.js +35 -0
- package/dist/wisp_api/apis/subusers.d.ts +106 -0
- package/dist/wisp_api/apis/subusers.js +87 -0
- package/dist/wisp_api/index.d.ts +39 -0
- package/dist/wisp_api/index.js +41 -0
- package/dist/wisp_socket/index.d.ts +161 -0
- package/{wisp_socket/index.ts → dist/wisp_socket/index.js} +130 -236
- package/dist/wisp_socket/pool.d.ts +183 -0
- package/dist/wisp_socket/pool.js +171 -0
- package/package.json +1 -1
- package/.github/workflows/release.yml +0 -72
- package/tsconfig.json +0 -19
- package/wisp_api/apis/allocations.ts +0 -71
- package/wisp_api/apis/audit_log.ts +0 -81
- package/wisp_api/apis/databases.ts +0 -80
- package/wisp_api/apis/fastdl.ts +0 -22
- package/wisp_api/apis/filesystem.ts +0 -291
- package/wisp_api/apis/index.ts +0 -135
- package/wisp_api/apis/mods.ts +0 -53
- package/wisp_api/apis/schedules.ts +0 -270
- package/wisp_api/apis/servers.ts +0 -155
- package/wisp_api/apis/startup.ts +0 -65
- package/wisp_api/apis/subusers.ts +0 -159
- package/wisp_api/index.ts +0 -57
- package/wisp_socket/pool.ts +0 -387
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { WispAPICore } from "./index";
|
|
2
|
+
import type { PaginationData } from "./index";
|
|
3
|
+
/**
|
|
4
|
+
* A Cron-formatted scheduling object
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface CronSchedule {
|
|
9
|
+
minute: string;
|
|
10
|
+
hour: string;
|
|
11
|
+
day_of_week: string;
|
|
12
|
+
day_of_month: string;
|
|
13
|
+
}
|
|
14
|
+
export interface Schedule {
|
|
15
|
+
object: "schedule";
|
|
16
|
+
attributes: {
|
|
17
|
+
id: number;
|
|
18
|
+
name: string;
|
|
19
|
+
cron: CronSchedule;
|
|
20
|
+
is_active: boolean;
|
|
21
|
+
is_processing: boolean;
|
|
22
|
+
last_run_at: string | null;
|
|
23
|
+
next_run_at: string | null;
|
|
24
|
+
created_at: string;
|
|
25
|
+
updated_at: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A response object for the GetSchedule call
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Used in {@link SchedulesAPI.List}
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export interface GetSchedulesResponse {
|
|
37
|
+
object: "list";
|
|
38
|
+
data: Schedule[];
|
|
39
|
+
meta: {
|
|
40
|
+
pagination: PaginationData;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface CreateScheduleRequest {
|
|
44
|
+
name: string;
|
|
45
|
+
cron_minute: string;
|
|
46
|
+
cron_hour: string;
|
|
47
|
+
cron_day_of_week: string;
|
|
48
|
+
cron_day_of_month: string;
|
|
49
|
+
is_active: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface ScheduleTask {
|
|
52
|
+
object: "schedule_task";
|
|
53
|
+
attributes: {
|
|
54
|
+
id: number;
|
|
55
|
+
sequence_id: number;
|
|
56
|
+
action: string;
|
|
57
|
+
payload: string;
|
|
58
|
+
time_offset: string;
|
|
59
|
+
is_processing: boolean;
|
|
60
|
+
created_at: string;
|
|
61
|
+
updated_at: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export type ScheduleTaskAction = "command" | "power" | "backup";
|
|
65
|
+
export interface CreateScheduleTaskRequest {
|
|
66
|
+
action: ScheduleTaskAction;
|
|
67
|
+
time_offset: number;
|
|
68
|
+
payload: string | null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Handles interactions with Server Schedules
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export declare class SchedulesAPI {
|
|
76
|
+
private core;
|
|
77
|
+
constructor(core: WispAPICore);
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves all of the Schedules for the Server
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
List(): Promise<GetSchedulesResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieves the Details for the Schedule
|
|
86
|
+
*
|
|
87
|
+
* @param id The ID of the Schedule
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
GetDetails(id: string): Promise<Schedule>;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a new Schedule
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* Creates a Schedule that runs at 12am every day
|
|
97
|
+
* ```
|
|
98
|
+
* await wisp.api.Schedules.Create("Example", "0", "0", "*", "*", true);
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @param name The name of the Schedule
|
|
102
|
+
* @param minute The Cron minute string
|
|
103
|
+
* @param hour The Cron hour string
|
|
104
|
+
* @param dow The Cron day of week string
|
|
105
|
+
* @param dom The Cron day of month string
|
|
106
|
+
* @param active Whether to enable the Schedle on creation
|
|
107
|
+
*
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
Create(name: string, minute: string, hour: string, dow: string, dom: string, active: boolean): Promise<Schedule>;
|
|
111
|
+
/**
|
|
112
|
+
* Updates the values of the Schedule
|
|
113
|
+
*
|
|
114
|
+
* @param id The ID of the Schedule
|
|
115
|
+
* @param name The name of the Schedule
|
|
116
|
+
* @param minute The Cron minute string
|
|
117
|
+
* @param hour The Cron hour string
|
|
118
|
+
* @param dow The Cron day of week string
|
|
119
|
+
* @param dom The Cron day of month string
|
|
120
|
+
* @param active Whether to enable the Schedle on creation
|
|
121
|
+
*
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
Update(id: string, name: string, minute: string, hour: string, dow: string, dom: string, active: boolean): Promise<Schedule>;
|
|
125
|
+
/**
|
|
126
|
+
* Triggers the Schedule
|
|
127
|
+
*
|
|
128
|
+
* @param id The ID of the Schedule
|
|
129
|
+
*
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
Trigger(id: string): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Deletes the Schedule
|
|
135
|
+
*
|
|
136
|
+
* @param id The ID of the Schedule
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
Delete(id: string): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Creates a new Task for a Schedule
|
|
143
|
+
*
|
|
144
|
+
* @remarks
|
|
145
|
+
* ℹ️ Payload is not required for backup action!
|
|
146
|
+
*
|
|
147
|
+
* @param id The ID of the Schedule to create a Task for
|
|
148
|
+
* @param action The Task action. One of: ["command", "power", "backup"]
|
|
149
|
+
* @param timeOffset The time offset of the Task
|
|
150
|
+
* @param payload The payload to provide to the Task
|
|
151
|
+
*
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
CreateTask(id: string, action: ScheduleTaskAction, timeOffset: number, payload: string | null): Promise<ScheduleTask>;
|
|
155
|
+
/**
|
|
156
|
+
* Update the Task
|
|
157
|
+
*
|
|
158
|
+
* @remarks
|
|
159
|
+
* ℹ️ Payload is not required for backup action!
|
|
160
|
+
*
|
|
161
|
+
* @param scheduleID The ID of the Schedule that contains the Task
|
|
162
|
+
* @param taskID The ID of the Task
|
|
163
|
+
* @param action The Task action. One of: ["command", "power", "backup"]
|
|
164
|
+
* @param timeOffset The time offset of the Task
|
|
165
|
+
* @param payload The payload to provide to the Task
|
|
166
|
+
*
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
UpdateTask(scheduleID: string, taskID: string, action: ScheduleTaskAction, timeOffset: number, payload: string | null): Promise<ScheduleTask>;
|
|
170
|
+
/**
|
|
171
|
+
* Delete the Task
|
|
172
|
+
*
|
|
173
|
+
* @param scheduleID The ID of the Schedule that contains the Task
|
|
174
|
+
* @param taskID The ID of the Task
|
|
175
|
+
*
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
DeleteTask(scheduleID: string, taskID: string): Promise<void>;
|
|
179
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles interactions with Server Schedules
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class SchedulesAPI {
|
|
7
|
+
constructor(core) {
|
|
8
|
+
this.core = core;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves all of the Schedules for the Server
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
async List() {
|
|
16
|
+
const response = await this.core.makeRequest("GET", "schedules", { include: "tasks" });
|
|
17
|
+
const data = await response.json();
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the Details for the Schedule
|
|
22
|
+
*
|
|
23
|
+
* @param id The ID of the Schedule
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
async GetDetails(id) {
|
|
28
|
+
const response = await this.core.makeRequest("GET", `schedules/${id}`, { include: "tasks" });
|
|
29
|
+
const data = await response.json();
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new Schedule
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* Creates a Schedule that runs at 12am every day
|
|
37
|
+
* ```
|
|
38
|
+
* await wisp.api.Schedules.Create("Example", "0", "0", "*", "*", true);
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param name The name of the Schedule
|
|
42
|
+
* @param minute The Cron minute string
|
|
43
|
+
* @param hour The Cron hour string
|
|
44
|
+
* @param dow The Cron day of week string
|
|
45
|
+
* @param dom The Cron day of month string
|
|
46
|
+
* @param active Whether to enable the Schedle on creation
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
async Create(name, minute, hour, dow, dom, active) {
|
|
51
|
+
const requestData = {
|
|
52
|
+
name: name,
|
|
53
|
+
cron_minute: minute,
|
|
54
|
+
cron_hour: hour,
|
|
55
|
+
cron_day_of_week: dow,
|
|
56
|
+
cron_day_of_month: dom,
|
|
57
|
+
is_active: active
|
|
58
|
+
};
|
|
59
|
+
const response = await this.core.makeRequest("POST", "schedules", requestData);
|
|
60
|
+
const data = await response.json();
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Updates the values of the Schedule
|
|
65
|
+
*
|
|
66
|
+
* @param id The ID of the Schedule
|
|
67
|
+
* @param name The name of the Schedule
|
|
68
|
+
* @param minute The Cron minute string
|
|
69
|
+
* @param hour The Cron hour string
|
|
70
|
+
* @param dow The Cron day of week string
|
|
71
|
+
* @param dom The Cron day of month string
|
|
72
|
+
* @param active Whether to enable the Schedle on creation
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
async Update(id, name, minute, hour, dow, dom, active) {
|
|
77
|
+
const requestData = {
|
|
78
|
+
name: name,
|
|
79
|
+
cron_minute: minute,
|
|
80
|
+
cron_hour: hour,
|
|
81
|
+
cron_day_of_week: dow,
|
|
82
|
+
cron_day_of_month: dom,
|
|
83
|
+
is_active: active
|
|
84
|
+
};
|
|
85
|
+
const response = await this.core.makeRequest("PATCH", `schedules/${id}`, requestData);
|
|
86
|
+
const data = await response.json();
|
|
87
|
+
return data;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Triggers the Schedule
|
|
91
|
+
*
|
|
92
|
+
* @param id The ID of the Schedule
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
async Trigger(id) {
|
|
97
|
+
await this.core.makeRequest("POST", `schedules/${id}`);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Deletes the Schedule
|
|
101
|
+
*
|
|
102
|
+
* @param id The ID of the Schedule
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
async Delete(id) {
|
|
107
|
+
await this.core.makeRequest("DELETE", `schedules/${id}`);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates a new Task for a Schedule
|
|
111
|
+
*
|
|
112
|
+
* @remarks
|
|
113
|
+
* ℹ️ Payload is not required for backup action!
|
|
114
|
+
*
|
|
115
|
+
* @param id The ID of the Schedule to create a Task for
|
|
116
|
+
* @param action The Task action. One of: ["command", "power", "backup"]
|
|
117
|
+
* @param timeOffset The time offset of the Task
|
|
118
|
+
* @param payload The payload to provide to the Task
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
async CreateTask(id, action, timeOffset, payload) {
|
|
123
|
+
const requestData = {
|
|
124
|
+
action: action,
|
|
125
|
+
time_offset: timeOffset,
|
|
126
|
+
payload: payload
|
|
127
|
+
};
|
|
128
|
+
const response = await this.core.makeRequest("POST", `schedules/${id}/tasks`, requestData);
|
|
129
|
+
const data = await response.json();
|
|
130
|
+
return data;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Update the Task
|
|
134
|
+
*
|
|
135
|
+
* @remarks
|
|
136
|
+
* ℹ️ Payload is not required for backup action!
|
|
137
|
+
*
|
|
138
|
+
* @param scheduleID The ID of the Schedule that contains the Task
|
|
139
|
+
* @param taskID The ID of the Task
|
|
140
|
+
* @param action The Task action. One of: ["command", "power", "backup"]
|
|
141
|
+
* @param timeOffset The time offset of the Task
|
|
142
|
+
* @param payload The payload to provide to the Task
|
|
143
|
+
*
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
async UpdateTask(scheduleID, taskID, action, timeOffset, payload) {
|
|
147
|
+
const requestData = {
|
|
148
|
+
action: action,
|
|
149
|
+
time_offset: timeOffset,
|
|
150
|
+
payload: payload
|
|
151
|
+
};
|
|
152
|
+
const response = await this.core.makeRequest("PATCH", `schedules/${scheduleID}/tasks/${taskID}`, requestData);
|
|
153
|
+
const data = await response.json();
|
|
154
|
+
return data;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Delete the Task
|
|
158
|
+
*
|
|
159
|
+
* @param scheduleID The ID of the Schedule that contains the Task
|
|
160
|
+
* @param taskID The ID of the Task
|
|
161
|
+
*
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
async DeleteTask(scheduleID, taskID) {
|
|
165
|
+
await this.core.makeRequest("DELETE", `schedules/${scheduleID}/tasks/${taskID}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { WispAPICore } from "./index";
|
|
2
|
+
export type PowerRequest = "start" | "stop" | "restart" | "kill";
|
|
3
|
+
export interface GetDetailsResponse {
|
|
4
|
+
object: "server";
|
|
5
|
+
attributes: {
|
|
6
|
+
id: number;
|
|
7
|
+
uuid: string;
|
|
8
|
+
uuid_short: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string | null;
|
|
11
|
+
monitor: boolean;
|
|
12
|
+
support_op: boolean;
|
|
13
|
+
installed: number;
|
|
14
|
+
limits: {
|
|
15
|
+
memory: number;
|
|
16
|
+
swap: number;
|
|
17
|
+
disk: number;
|
|
18
|
+
io: number;
|
|
19
|
+
cpu: number;
|
|
20
|
+
};
|
|
21
|
+
feature_limits: {
|
|
22
|
+
databases: number;
|
|
23
|
+
backup_megabytes: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface GetWebsocketDetailsResponse {
|
|
28
|
+
url: string;
|
|
29
|
+
upload_url: string;
|
|
30
|
+
token: string;
|
|
31
|
+
}
|
|
32
|
+
export interface GetResourcesResponse {
|
|
33
|
+
status: number;
|
|
34
|
+
proc: {
|
|
35
|
+
memory: {
|
|
36
|
+
total: number;
|
|
37
|
+
limit: number;
|
|
38
|
+
};
|
|
39
|
+
cpu: {
|
|
40
|
+
total: number;
|
|
41
|
+
limit: number;
|
|
42
|
+
};
|
|
43
|
+
disk: {
|
|
44
|
+
used: number;
|
|
45
|
+
limit: number;
|
|
46
|
+
io_limit: number;
|
|
47
|
+
};
|
|
48
|
+
network: {
|
|
49
|
+
[key: string]: {
|
|
50
|
+
rx_bytes: number;
|
|
51
|
+
rx_packets: number;
|
|
52
|
+
rx_errors: number;
|
|
53
|
+
rx_dropped: number;
|
|
54
|
+
tx_bytes: number;
|
|
55
|
+
tx_packets: number;
|
|
56
|
+
tx_errors: number;
|
|
57
|
+
tx_dropped: number;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Handles generic Server interaction, such as Sending Commands, managing Power State, and getting Details
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export declare class ServersAPI {
|
|
68
|
+
private core;
|
|
69
|
+
constructor(core: WispAPICore);
|
|
70
|
+
/**
|
|
71
|
+
* Sends a command to the Server
|
|
72
|
+
*
|
|
73
|
+
* @param command The full command string to send to the Server
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
SendCommand(command: string): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the Websocket connection (and upload) details for the Server
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
GetWebsocketDetails(): Promise<GetWebsocketDetailsResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the name of the Server as it appears in the panel
|
|
86
|
+
* (Same thing as setting the name in the "Server Details" menu)
|
|
87
|
+
*
|
|
88
|
+
* @param name The new name of the server
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
SetName(name: string): Promise<GetDetailsResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieves the basic, technical details of the Server
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
GetDetails(): Promise<GetDetailsResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* Retrieves technical details of the Server's resources
|
|
101
|
+
* (CPU, Memory, Disk, Network)
|
|
102
|
+
*
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
GetResources(): Promise<GetResourcesResponse>;
|
|
106
|
+
/**
|
|
107
|
+
* Instructs the Server to start up, shut down, restart, or force quit
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* Example of stopping the server
|
|
111
|
+
* ```
|
|
112
|
+
* await wisp.api.PowerRequest("stop");
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @param action The power action to send. One of: ["start", "stop", "restart", "kill"]
|
|
116
|
+
*
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
PowerRequest(action: PowerRequest): Promise<void>;
|
|
120
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles generic Server interaction, such as Sending Commands, managing Power State, and getting Details
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class ServersAPI {
|
|
7
|
+
constructor(core) {
|
|
8
|
+
this.core = core;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Sends a command to the Server
|
|
12
|
+
*
|
|
13
|
+
* @param command The full command string to send to the Server
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
async SendCommand(command) {
|
|
18
|
+
await this.core.makeRequest("POST", "command", { command: command });
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets the Websocket connection (and upload) details for the Server
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
async GetWebsocketDetails() {
|
|
26
|
+
const response = await this.core.makeRequest("GET", "websocket");
|
|
27
|
+
return await response.json();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Sets the name of the Server as it appears in the panel
|
|
31
|
+
* (Same thing as setting the name in the "Server Details" menu)
|
|
32
|
+
*
|
|
33
|
+
* @param name The new name of the server
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
async SetName(name) {
|
|
38
|
+
const response = await this.core.makeRequest("PATCH", "details", { name: name });
|
|
39
|
+
return await response.json();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves the basic, technical details of the Server
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
async GetDetails() {
|
|
47
|
+
const response = await this.core.makeRequest("GET", "");
|
|
48
|
+
return await response.json();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves technical details of the Server's resources
|
|
52
|
+
* (CPU, Memory, Disk, Network)
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
async GetResources() {
|
|
57
|
+
const response = await this.core.makeRequest("GET", "resources");
|
|
58
|
+
return await response.json();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Instructs the Server to start up, shut down, restart, or force quit
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* Example of stopping the server
|
|
65
|
+
* ```
|
|
66
|
+
* await wisp.api.PowerRequest("stop");
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param action The power action to send. One of: ["start", "stop", "restart", "kill"]
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
async PowerRequest(action) {
|
|
74
|
+
await this.core.makeRequest("POST", "power", { signal: action });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { WispAPICore } from "./index";
|
|
2
|
+
export interface UpdateStartup {
|
|
3
|
+
environment: {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export interface StartupDetail {
|
|
8
|
+
object: "server_variable";
|
|
9
|
+
attributes: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
env_variable: string;
|
|
13
|
+
default_value: string;
|
|
14
|
+
tickable: boolean;
|
|
15
|
+
user_editable: boolean;
|
|
16
|
+
rules: string;
|
|
17
|
+
server_value: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface StartupDetails {
|
|
21
|
+
object: "list";
|
|
22
|
+
data: StartupDetail[];
|
|
23
|
+
meta: {
|
|
24
|
+
startup_command: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Handles interaction with Server Startup information
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare class StartupAPI {
|
|
33
|
+
private core;
|
|
34
|
+
constructor(core: WispAPICore);
|
|
35
|
+
/**
|
|
36
|
+
* Gets all Startup details for the Server
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
Get(): Promise<StartupDetails>;
|
|
41
|
+
/**
|
|
42
|
+
* Updates the Startup details for the Server
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* ℹ️ Pass the variables with their new value to update them. Response will contain the new updated startup
|
|
46
|
+
*
|
|
47
|
+
* @param startup The Startup values to update
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
Update(startup: UpdateStartup): Promise<StartupDetails>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles interaction with Server Startup information
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class StartupAPI {
|
|
7
|
+
constructor(core) {
|
|
8
|
+
this.core = core;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Gets all Startup details for the Server
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
async Get() {
|
|
16
|
+
const response = await this.core.makeRequest("GET", "startup");
|
|
17
|
+
const startupDetails = await response.json();
|
|
18
|
+
return startupDetails;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Updates the Startup details for the Server
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* ℹ️ Pass the variables with their new value to update them. Response will contain the new updated startup
|
|
25
|
+
*
|
|
26
|
+
* @param startup The Startup values to update
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
async Update(startup) {
|
|
31
|
+
const response = await this.core.makeRequest("PUT", "startup", startup);
|
|
32
|
+
const data = await response.json();
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
}
|