virtualizorjs 1.0.5 → 2.1.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.
@@ -0,0 +1,383 @@
1
+ interface VirtualizorError {
2
+ code: number;
3
+ msg: string;
4
+ }
5
+ interface VirtualizorResponse {
6
+ title?: string;
7
+ timenow?: number;
8
+ time_taken?: string;
9
+ error?: VirtualizorError[];
10
+ }
11
+ interface AsyncTaskResult extends VirtualizorResponse {
12
+ done?: 1;
13
+ taskid?: string;
14
+ }
15
+ type VirtType = 'kvm' | 'xen' | 'openvz' | 'lxc' | 'proxmox' | 'virtuozzo' | 'xcp' | 'hyperv';
16
+
17
+ interface VirtualizorConfig {
18
+ host: string;
19
+ apiKey: string;
20
+ apiPass?: string;
21
+ port?: number;
22
+ https?: boolean;
23
+ rejectUnauthorized?: boolean;
24
+ timeout?: number;
25
+ }
26
+ interface ResolvedConfig {
27
+ host: string;
28
+ apiKey: string;
29
+ apiPass: string;
30
+ port: number;
31
+ https: boolean;
32
+ rejectUnauthorized: boolean;
33
+ timeout: number;
34
+ }
35
+
36
+ declare class VirtualizorApiError extends Error {
37
+ readonly code: number;
38
+ constructor(message: string, code: number);
39
+ }
40
+ type Params = Record<string, string | number | undefined>;
41
+ declare class HttpClient {
42
+ private readonly config;
43
+ constructor(config: ResolvedConfig);
44
+ parseResponse<T extends VirtualizorResponse>(data: T): T;
45
+ request<T extends VirtualizorResponse>(act: string, queryParams?: Params, bodyParams?: Params): Promise<T>;
46
+ private rawRequest;
47
+ }
48
+
49
+ interface Plan {
50
+ pid: string;
51
+ plan_name: string;
52
+ disk: string;
53
+ ram: string;
54
+ bandwidth: string;
55
+ cpu: string;
56
+ virt?: string;
57
+ }
58
+ interface CreatePlanParams {
59
+ plan_name: string;
60
+ disk: number;
61
+ ram: number;
62
+ bandwidth: number;
63
+ cpu: number;
64
+ virt?: string;
65
+ }
66
+
67
+ declare class PlansResource {
68
+ private readonly http;
69
+ constructor(http: HttpClient);
70
+ list(): Promise<Record<string, Plan>>;
71
+ create(params: CreatePlanParams): Promise<AsyncTaskResult>;
72
+ delete(planId: string): Promise<AsyncTaskResult>;
73
+ }
74
+
75
+ interface Task {
76
+ id: string;
77
+ action: string;
78
+ status: string;
79
+ vpsid?: string;
80
+ data?: unknown;
81
+ }
82
+
83
+ declare class TasksResource {
84
+ private readonly http;
85
+ constructor(http: HttpClient);
86
+ get(taskId: string): Promise<Task | undefined>;
87
+ wait(taskId: string, options?: {
88
+ pollIntervalMs?: number;
89
+ timeoutMs?: number;
90
+ }): Promise<Task>;
91
+ }
92
+
93
+ interface User {
94
+ uid: string;
95
+ email: string;
96
+ fname?: string;
97
+ lname?: string;
98
+ status: string;
99
+ type: string;
100
+ }
101
+ interface CreateUserParams {
102
+ email: string;
103
+ password: string;
104
+ fname?: string;
105
+ lname?: string;
106
+ acttype?: number;
107
+ }
108
+
109
+ declare class UsersResource {
110
+ private readonly http;
111
+ constructor(http: HttpClient);
112
+ list(): Promise<Record<string, User>>;
113
+ create(params: CreateUserParams): Promise<AsyncTaskResult>;
114
+ delete(uid: string): Promise<AsyncTaskResult>;
115
+ suspend(uid: string): Promise<AsyncTaskResult>;
116
+ unsuspend(uid: string): Promise<AsyncTaskResult>;
117
+ }
118
+
119
+ interface VPSData {
120
+ os_type?: number | string;
121
+ rtc?: number | string;
122
+ unprivileged?: number | string;
123
+ vnc_auto_port?: number | string;
124
+ nested_virt?: number | string;
125
+ vga_vram?: number | string;
126
+ discard?: number | string;
127
+ vlan_tag?: number | string;
128
+ enable_guest_agent?: number | string;
129
+ ssd_emulation?: number | string;
130
+ machine_type?: number | string;
131
+ bios?: string;
132
+ enable_tpm?: number | string;
133
+ disable_password?: string;
134
+ ssh_options?: string;
135
+ added_keys?: unknown[];
136
+ io_uring?: number | string;
137
+ min_ram?: number | string;
138
+ vga?: number | string;
139
+ vga_memory?: number | string;
140
+ cpu_flags?: number | string;
141
+ scsi_controller?: number | string;
142
+ demo?: string | null;
143
+ enable_cpu_threshold?: number | string;
144
+ cpu_threshold?: number | string;
145
+ cpu_threshold_time?: number | string;
146
+ disable_guest_agent?: number | string;
147
+ disable_autostart?: number | string;
148
+ iothread?: number | string;
149
+ nesting?: number | string;
150
+ suspended_time?: number | string;
151
+ multiqueue?: number | string;
152
+ freeze_fs_on_backup?: number | string;
153
+ enable_ver_scaling?: number | string;
154
+ ver_max_ram?: string | number;
155
+ ver_ram_threshold?: string | number;
156
+ ver_ram_inc_by?: string | number;
157
+ ver_max_cpu?: string | number;
158
+ ver_cpu_threshold?: string | number;
159
+ ver_cpu_inc_by?: string | number;
160
+ random_ipv6?: number | string;
161
+ encrypted_pass?: number | string;
162
+ vm_admin_name?: string;
163
+ crypted_pass?: string | null;
164
+ crypted_salt?: string | null;
165
+ custom_ipv6_on_edit?: number | string;
166
+ docker_info?: unknown | null;
167
+ }
168
+ interface VPS {
169
+ vpsid: string;
170
+ vps_name?: string;
171
+ uuid?: string;
172
+ serid?: string | number;
173
+ time?: string | number;
174
+ edittime?: string | number;
175
+ virt?: VirtType | string;
176
+ uid?: string | number;
177
+ plid?: string | number;
178
+ hostname: string;
179
+ osid?: string | number;
180
+ os_name: string;
181
+ iso?: string;
182
+ sec_iso?: string;
183
+ boot?: string;
184
+ space?: string | number;
185
+ inodes?: string | number;
186
+ ram: string;
187
+ burst?: string | number;
188
+ swap?: string | number;
189
+ cpu?: string | number;
190
+ cores?: string | number;
191
+ cpupin?: string | number;
192
+ cpu_percent?: string | number;
193
+ bandwidth: string;
194
+ network_speed?: string | number;
195
+ upload_speed?: string | number;
196
+ io?: string | number;
197
+ ubc?: string;
198
+ acpi?: string | number;
199
+ apic?: string | number;
200
+ pae?: string | number;
201
+ shadow?: string | number;
202
+ vnc?: string | number;
203
+ vncport?: string | number;
204
+ vnc_passwd?: string;
205
+ hvm?: string | number;
206
+ suspended?: string | number;
207
+ suspend_reason?: string | null;
208
+ nw_suspended?: string | null;
209
+ rescue?: string | number;
210
+ band_suspend?: string | number;
211
+ tuntap?: string | number;
212
+ ppp?: string | number;
213
+ ploop?: string | number;
214
+ dns_nameserver?: string;
215
+ osreinstall_limit?: string | number;
216
+ preferences?: unknown | null;
217
+ nic_type?: string;
218
+ vif_type?: string;
219
+ virtio?: string | number;
220
+ pv_on_hvm?: string | number;
221
+ disks?: unknown | null;
222
+ kvm_cache?: string | number;
223
+ io_mode?: string | number;
224
+ cpu_mode?: string;
225
+ total_iops_sec?: string | number;
226
+ read_bytes_sec?: string | number;
227
+ write_bytes_sec?: string | number;
228
+ kvm_vga?: string | number;
229
+ acceleration?: string | number;
230
+ vnc_keymap?: string;
231
+ routing?: string | number;
232
+ mg?: string;
233
+ used_bandwidth?: string | number;
234
+ cached_disk?: unknown;
235
+ webuzo?: string | number;
236
+ disable_ebtables?: string | number;
237
+ install_xentools?: string | number;
238
+ admin_managed?: string | number;
239
+ rdp?: string | number;
240
+ topology_sockets?: string | number;
241
+ topology_cores?: string | number;
242
+ topology_threads?: string | number;
243
+ mac?: string;
244
+ notes?: string | null;
245
+ disable_nw_config?: string | number;
246
+ locked?: string;
247
+ openvz_features?: string;
248
+ speed_cap?: string;
249
+ numa?: string | number;
250
+ bpid?: string | number;
251
+ bserid?: string | number;
252
+ timezone?: string | null;
253
+ ha?: string | number;
254
+ load_balancer?: string | number;
255
+ data?: VPSData;
256
+ fwid?: string | number;
257
+ admin_fwid?: string | number;
258
+ current_resource?: unknown | null;
259
+ plan_expiry?: string | number;
260
+ machine_status?: string | number;
261
+ tags?: string | null;
262
+ server_name?: string;
263
+ email?: string;
264
+ pid?: string | number;
265
+ type?: string | number;
266
+ os_distro?: string;
267
+ stid?: number[];
268
+ ips?: Record<string, string>;
269
+ }
270
+ interface ListVPSParams {
271
+ user?: string | number;
272
+ vpsid?: string | number;
273
+ vpsname?: string;
274
+ vpsip?: string;
275
+ vpshostname?: string;
276
+ vsstatus?: string;
277
+ vstype?: VirtType;
278
+ serid?: number;
279
+ plid?: number;
280
+ bpid?: number;
281
+ }
282
+ interface CreateVPSParams {
283
+ hostname: string;
284
+ rootpass: string;
285
+ osid: number;
286
+ plid?: number;
287
+ user_email?: string;
288
+ ips?: number;
289
+ ips_int?: number;
290
+ space?: number;
291
+ ram?: number;
292
+ burst?: number;
293
+ bandwidth?: number;
294
+ cpu?: number;
295
+ cpu_percent?: number;
296
+ virt?: VirtType;
297
+ serid?: number;
298
+ node_select?: 0 | 1;
299
+ recipe?: number;
300
+ sshkey?: string;
301
+ nopassword?: 0 | 1;
302
+ }
303
+ interface RebuildVPSParams {
304
+ /** OS template ID to rebuild with */
305
+ osid: number;
306
+ /** New root password for the VPS */
307
+ newpass: string;
308
+ /** Must be set to 1 to confirm the rebuild */
309
+ conf: 1;
310
+ /** Format primary disk (0 = no, 1 = yes); defaults to 0 */
311
+ format_primary?: 0 | 1;
312
+ /** Send rebuild notification email (0 = no, 1 = yes) */
313
+ eu_send_rebuild_email?: 0 | 1;
314
+ /** Recipe ID to apply post-rebuild */
315
+ recipe?: number;
316
+ /** SSH key to inject */
317
+ sshkey?: string;
318
+ }
319
+ interface CloneVPSParams {
320
+ /** Hostname for the new cloned VPS */
321
+ hostname: string;
322
+ /** Root password for the new cloned VPS */
323
+ rootpass: string;
324
+ /** Source server ID (server where the VPS lives) */
325
+ from_server: number;
326
+ /** Destination server ID (server to clone into) */
327
+ to_server: number;
328
+ }
329
+ interface MigrateVPSParams {
330
+ /** Destination server ID */
331
+ serid: number;
332
+ /** Source server IP address */
333
+ from_ip: string;
334
+ /** Source server API/root password */
335
+ from_pass: string;
336
+ /** 0 = ignore VDF conflicts, 1 = error on conflict */
337
+ ignore_if_vdfconflict?: 0 | 1;
338
+ /** 0 = use gzip compression, 1 = disable gzip */
339
+ disable_gzip?: 0 | 1;
340
+ /** 0 = offline migration, 1 = live migration */
341
+ online?: 0 | 1;
342
+ }
343
+ interface VPSStatsResponse extends VirtualizorResponse {
344
+ vs_stats?: unknown;
345
+ vs_bandwidth?: unknown;
346
+ time_taken?: string;
347
+ }
348
+ interface VNCInfo extends VirtualizorResponse {
349
+ novnc?: string;
350
+ [key: string]: unknown;
351
+ }
352
+
353
+ declare class VpsResource {
354
+ private readonly http;
355
+ constructor(http: HttpClient);
356
+ list(filters?: ListVPSParams): Promise<Record<string, VPS>>;
357
+ get(vpsId: string): Promise<VPS>;
358
+ create(params: CreateVPSParams): Promise<AsyncTaskResult>;
359
+ delete(vpsId: string): Promise<AsyncTaskResult>;
360
+ start(vpsId: string): Promise<AsyncTaskResult>;
361
+ stop(vpsId: string): Promise<AsyncTaskResult>;
362
+ restart(vpsId: string): Promise<AsyncTaskResult>;
363
+ poweroff(vpsId: string): Promise<AsyncTaskResult>;
364
+ suspend(vpsId: string): Promise<AsyncTaskResult>;
365
+ unsuspend(vpsId: string): Promise<AsyncTaskResult>;
366
+ rebuild(vpsId: string, params: RebuildVPSParams): Promise<AsyncTaskResult>;
367
+ clone(vpsId: string, params: CloneVPSParams): Promise<AsyncTaskResult>;
368
+ migrate(vpsId: string, params: MigrateVPSParams): Promise<AsyncTaskResult>;
369
+ status(vpsId: string): Promise<unknown>;
370
+ vnc(vpsId: string): Promise<VNCInfo>;
371
+ stats(vpsId: string): Promise<VPSStatsResponse>;
372
+ }
373
+
374
+ declare class VirtualizorClient {
375
+ readonly vps: VpsResource;
376
+ readonly users: UsersResource;
377
+ readonly plans: PlansResource;
378
+ readonly tasks: TasksResource;
379
+ constructor(config: VirtualizorConfig);
380
+ }
381
+ declare function createVirtualizorClient(config: VirtualizorConfig): VirtualizorClient;
382
+
383
+ export { type AsyncTaskResult, type CloneVPSParams, type CreatePlanParams, type CreateUserParams, type CreateVPSParams, type ListVPSParams, type MigrateVPSParams, type Plan, type RebuildVPSParams, type Task, type User, type VPS, type VirtType, VirtualizorApiError, VirtualizorClient, type VirtualizorConfig, createVirtualizorClient };