virtualizorjs 1.0.5 → 2.0.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/README.md +211 -126
- package/dist/index.d.mts +245 -0
- package/dist/index.d.ts +245 -0
- package/dist/index.js +272 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +262 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +49 -44
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -28
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/workflows/npm-publish-github-packages.yml +0 -36
- package/.github/workflows/release-package.yml +0 -33
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -92
- package/SECURITY.md +0 -26
- package/examples/createvps.js +0 -33
- package/examples/eventhandling.js +0 -36
- package/examples/listvps.js +0 -117
- package/src/Actions.js +0 -79
- package/src/VirtualizorClient.js +0 -491
package/README.md
CHANGED
|
@@ -1,126 +1,211 @@
|
|
|
1
|
-
# VirtualizorJS
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
1
|
+
# VirtualizorJS
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/virtualizorjs)
|
|
4
|
+
[](https://github.com/kkMihai/virtualizorjs/actions)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
A **TypeScript-first** SDK for the [Virtualizor](https://www.virtualizor.com/) server management API. Manage VPS instances, users, and plans with a clean, namespaced interface and zero production dependencies.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- ✅ **TypeScript-first**: Full type safety and IDE autocomplete
|
|
12
|
+
- ✅ **Namespaced API**: Logical organization (`client.vps.*`, `client.users.*`, `client.plans.*`, `client.tasks.*`)
|
|
13
|
+
- ✅ **SHA-256 Authentication**: Secure API communication
|
|
14
|
+
- ✅ **Zero Production Dependencies**: Lightweight and fast
|
|
15
|
+
- ✅ **Async Task Polling**: Built-in support for long-running operations
|
|
16
|
+
- ✅ **Self-signed SSL Ready**: Pre-configured for Virtualizor's typical certificate setup
|
|
17
|
+
- ✅ **Dual Output**: Outputs both CommonJS and ESM modules
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
**npm:**
|
|
22
|
+
```bash
|
|
23
|
+
npm install virtualizorjs
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**bun:**
|
|
27
|
+
```bash
|
|
28
|
+
bun add virtualizorjs
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
### Create a Client
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { createVirtualizorClient } from 'virtualizorjs';
|
|
37
|
+
|
|
38
|
+
const client = createVirtualizorClient({
|
|
39
|
+
host: 'virtualizor.example.com',
|
|
40
|
+
apiKey: 'your-api-key',
|
|
41
|
+
apiPass: 'your-api-pass',
|
|
42
|
+
// Optional: port (default 4085), https (default true),
|
|
43
|
+
// rejectUnauthorized (default false), timeout (default 30000ms)
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### List All VPS
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
const vpsList = await client.vps.list();
|
|
51
|
+
|
|
52
|
+
for (const [vpsId, vps] of Object.entries(vpsList)) {
|
|
53
|
+
console.log(`${vpsId}: ${vps.hostname} (${vps.status})`);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Start a VPS and Wait for Completion
|
|
58
|
+
|
|
59
|
+
Many Virtualizor operations are asynchronous. Use `client.tasks.wait()` to poll for completion:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const result = await client.vps.start('123');
|
|
63
|
+
const task = await client.tasks.wait(result.taskid!);
|
|
64
|
+
|
|
65
|
+
console.log(`VPS started! Task status: ${task.status}`);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Error Handling
|
|
69
|
+
|
|
70
|
+
All SDK errors are instances of `VirtualizorApiError`. Catch and inspect them:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { VirtualizorApiError } from 'virtualizorjs';
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
await client.vps.start('invalid-id');
|
|
77
|
+
} catch (err) {
|
|
78
|
+
if (err instanceof VirtualizorApiError) {
|
|
79
|
+
console.error(`API Error [${err.code}]: ${err.message}`);
|
|
80
|
+
} else {
|
|
81
|
+
console.error('Unexpected error:', err);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## API Reference
|
|
87
|
+
|
|
88
|
+
### VPS Management
|
|
89
|
+
|
|
90
|
+
| Method | Parameters | Returns | Notes |
|
|
91
|
+
|--------|-----------|---------|-------|
|
|
92
|
+
| `list()` | — | `Record<string, VPS>` | List all VPS |
|
|
93
|
+
| `get(vpsId)` | `vpsId: string` | `VPS` | Get a single VPS |
|
|
94
|
+
| `create(params)` | `CreateVPSParams` | `AsyncTaskResult` | Async |
|
|
95
|
+
| `delete(vpsId)` | `vpsId: string` | `AsyncTaskResult` | Async |
|
|
96
|
+
| `start(vpsId)` | `vpsId: string` | `AsyncTaskResult` | Async |
|
|
97
|
+
| `stop(vpsId)` | `vpsId: string` | `AsyncTaskResult` | Async |
|
|
98
|
+
| `restart(vpsId)` | `vpsId: string` | `AsyncTaskResult` | Async |
|
|
99
|
+
| `poweroff(vpsId)` | `vpsId: string` | `AsyncTaskResult` | Async |
|
|
100
|
+
| `suspend(vpsId)` | `vpsId: string` | `AsyncTaskResult` | Async |
|
|
101
|
+
| `unsuspend(vpsId)` | `vpsId: string` | `AsyncTaskResult` | Async |
|
|
102
|
+
| `rebuild(vpsId, params)` | `vpsId: string, RebuildVPSParams` | `AsyncTaskResult` | Async |
|
|
103
|
+
| `clone(vpsId, params)` | `vpsId: string, CloneVPSParams` | `AsyncTaskResult` | Async |
|
|
104
|
+
| `migrate(vpsId, params)` | `vpsId: string, MigrateVPSParams` | `AsyncTaskResult` | Async |
|
|
105
|
+
| `status(vpsId)` | `vpsId: string` | `unknown` | Current status snapshot |
|
|
106
|
+
| `vnc(vpsId)` | `vpsId: string` | `VNCInfo` | Get VNC connection details |
|
|
107
|
+
| `stats(vpsId)` | `vpsId: string` | `VPSStatsResponse` | Get resource usage statistics |
|
|
108
|
+
|
|
109
|
+
### User Management
|
|
110
|
+
|
|
111
|
+
| Method | Parameters | Returns | Notes |
|
|
112
|
+
|--------|-----------|---------|-------|
|
|
113
|
+
| `list()` | — | `Record<string, User>` | List all users |
|
|
114
|
+
| `create(params)` | `CreateUserParams` | `AsyncTaskResult` | Async |
|
|
115
|
+
| `delete(uid)` | `uid: string` | `AsyncTaskResult` | Async |
|
|
116
|
+
| `suspend(uid)` | `uid: string` | `AsyncTaskResult` | Async |
|
|
117
|
+
| `unsuspend(uid)` | `uid: string` | `AsyncTaskResult` | Async |
|
|
118
|
+
|
|
119
|
+
### Plan Management
|
|
120
|
+
|
|
121
|
+
| Method | Parameters | Returns | Notes |
|
|
122
|
+
|--------|-----------|---------|-------|
|
|
123
|
+
| `list()` | — | `Record<string, Plan>` | List all plans |
|
|
124
|
+
| `create(params)` | `CreatePlanParams` | `AsyncTaskResult` | Async |
|
|
125
|
+
| `delete(planId)` | `planId: string` | `AsyncTaskResult` | Async |
|
|
126
|
+
|
|
127
|
+
### Task Polling
|
|
128
|
+
|
|
129
|
+
| Method | Parameters | Returns | Notes |
|
|
130
|
+
|--------|-----------|---------|-------|
|
|
131
|
+
| `get(taskId)` | `taskId: string` | `Task \| undefined` | Get task status once |
|
|
132
|
+
| `wait(taskId, options?)` | `taskId: string, { pollIntervalMs?, timeoutMs? }?` | `Promise<Task>` | Poll until complete or timeout |
|
|
133
|
+
|
|
134
|
+
## Task Polling Pattern
|
|
135
|
+
|
|
136
|
+
Many API calls return `AsyncTaskResult` with a `taskid` field. Poll for completion:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
// Example: Create a VPS and wait for it to be ready
|
|
140
|
+
const createResult = await client.vps.create({
|
|
141
|
+
hostname: 'my-vps.example.com',
|
|
142
|
+
// ... other params
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const completedTask = await client.tasks.wait(createResult.taskid!, {
|
|
146
|
+
pollIntervalMs: 5000, // Check every 5 seconds (default: 2000ms)
|
|
147
|
+
timeoutMs: 300000, // Give up after 5 minutes (default: 120000ms)
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
if (completedTask.status === '1' || completedTask.status === 'done') {
|
|
151
|
+
console.log('VPS creation completed successfully');
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Configuration
|
|
156
|
+
|
|
157
|
+
When creating a client, the following options are available:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
interface VirtualizorConfig {
|
|
161
|
+
host: string; // Virtualizor server hostname or IP
|
|
162
|
+
apiKey: string; // API key from Virtualizor panel
|
|
163
|
+
apiPass: string; // API password from Virtualizor panel
|
|
164
|
+
port?: number; // Server port (default: 4085)
|
|
165
|
+
https?: boolean; // Use HTTPS (default: true)
|
|
166
|
+
rejectUnauthorized?: boolean; // Reject self-signed certs (default: false)
|
|
167
|
+
timeout?: number; // Request timeout in ms (default: 30000)
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Self-Signed SSL Certificates
|
|
172
|
+
|
|
173
|
+
Virtualizor typically uses self-signed SSL certificates. The SDK handles this by default with `rejectUnauthorized: false`. If you need to enforce certificate validation, set `rejectUnauthorized: true` and ensure your Virtualizor instance has a valid certificate.
|
|
174
|
+
|
|
175
|
+
## TypeScript Types
|
|
176
|
+
|
|
177
|
+
All resources are fully typed. Import types as needed:
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import type {
|
|
181
|
+
VPS,
|
|
182
|
+
CreateVPSParams,
|
|
183
|
+
RebuildVPSParams,
|
|
184
|
+
CloneVPSParams,
|
|
185
|
+
MigrateVPSParams,
|
|
186
|
+
User,
|
|
187
|
+
CreateUserParams,
|
|
188
|
+
Plan,
|
|
189
|
+
CreatePlanParams,
|
|
190
|
+
Task,
|
|
191
|
+
AsyncTaskResult,
|
|
192
|
+
} from 'virtualizorjs';
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Contributing
|
|
196
|
+
|
|
197
|
+
We welcome contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to help.
|
|
198
|
+
|
|
199
|
+
## Security
|
|
200
|
+
|
|
201
|
+
Please report security vulnerabilities to the maintainers privately. See [SECURITY.md](./SECURITY.md) for more details.
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
**Author**: [kkMihai](https://github.com/kkMihai)
|
|
210
|
+
**Package**: [npm/virtualizorjs](https://www.npmjs.com/package/virtualizorjs)
|
|
211
|
+
**Repository**: [github.com/kkMihai/virtualizorjs](https://github.com/kkMihai/virtualizorjs)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
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 VPS {
|
|
120
|
+
vpsid: string;
|
|
121
|
+
hostname: string;
|
|
122
|
+
status: string;
|
|
123
|
+
ram: string;
|
|
124
|
+
hdd: string;
|
|
125
|
+
bandwidth: string;
|
|
126
|
+
os_name: string;
|
|
127
|
+
ip: string;
|
|
128
|
+
serid?: string;
|
|
129
|
+
virt?: VirtType;
|
|
130
|
+
cpu?: string;
|
|
131
|
+
}
|
|
132
|
+
interface ListVPSParams {
|
|
133
|
+
user?: string | number;
|
|
134
|
+
vpsid?: string | number;
|
|
135
|
+
vpsname?: string;
|
|
136
|
+
vpsip?: string;
|
|
137
|
+
vpshostname?: string;
|
|
138
|
+
vsstatus?: string;
|
|
139
|
+
vstype?: VirtType;
|
|
140
|
+
serid?: number;
|
|
141
|
+
plid?: number;
|
|
142
|
+
bpid?: number;
|
|
143
|
+
}
|
|
144
|
+
interface CreateVPSParams {
|
|
145
|
+
hostname: string;
|
|
146
|
+
rootpass: string;
|
|
147
|
+
osid: number;
|
|
148
|
+
plid?: number;
|
|
149
|
+
user_email?: string;
|
|
150
|
+
ips?: number;
|
|
151
|
+
ips_int?: number;
|
|
152
|
+
space?: number;
|
|
153
|
+
ram?: number;
|
|
154
|
+
burst?: number;
|
|
155
|
+
bandwidth?: number;
|
|
156
|
+
cpu?: number;
|
|
157
|
+
cpu_percent?: number;
|
|
158
|
+
virt?: VirtType;
|
|
159
|
+
serid?: number;
|
|
160
|
+
node_select?: 0 | 1;
|
|
161
|
+
recipe?: number;
|
|
162
|
+
sshkey?: string;
|
|
163
|
+
nopassword?: 0 | 1;
|
|
164
|
+
}
|
|
165
|
+
interface RebuildVPSParams {
|
|
166
|
+
/** OS template ID to rebuild with */
|
|
167
|
+
osid: number;
|
|
168
|
+
/** New root password for the VPS */
|
|
169
|
+
newpass: string;
|
|
170
|
+
/** Must be set to 1 to confirm the rebuild */
|
|
171
|
+
conf: 1;
|
|
172
|
+
/** Format primary disk (0 = no, 1 = yes); defaults to 0 */
|
|
173
|
+
format_primary?: 0 | 1;
|
|
174
|
+
/** Send rebuild notification email (0 = no, 1 = yes) */
|
|
175
|
+
eu_send_rebuild_email?: 0 | 1;
|
|
176
|
+
/** Recipe ID to apply post-rebuild */
|
|
177
|
+
recipe?: number;
|
|
178
|
+
/** SSH key to inject */
|
|
179
|
+
sshkey?: string;
|
|
180
|
+
}
|
|
181
|
+
interface CloneVPSParams {
|
|
182
|
+
/** Hostname for the new cloned VPS */
|
|
183
|
+
hostname: string;
|
|
184
|
+
/** Root password for the new cloned VPS */
|
|
185
|
+
rootpass: string;
|
|
186
|
+
/** Source server ID (server where the VPS lives) */
|
|
187
|
+
from_server: number;
|
|
188
|
+
/** Destination server ID (server to clone into) */
|
|
189
|
+
to_server: number;
|
|
190
|
+
}
|
|
191
|
+
interface MigrateVPSParams {
|
|
192
|
+
/** Destination server ID */
|
|
193
|
+
serid: number;
|
|
194
|
+
/** Source server IP address */
|
|
195
|
+
from_ip: string;
|
|
196
|
+
/** Source server API/root password */
|
|
197
|
+
from_pass: string;
|
|
198
|
+
/** 0 = ignore VDF conflicts, 1 = error on conflict */
|
|
199
|
+
ignore_if_vdfconflict?: 0 | 1;
|
|
200
|
+
/** 0 = use gzip compression, 1 = disable gzip */
|
|
201
|
+
disable_gzip?: 0 | 1;
|
|
202
|
+
/** 0 = offline migration, 1 = live migration */
|
|
203
|
+
online?: 0 | 1;
|
|
204
|
+
}
|
|
205
|
+
interface VPSStatsResponse extends VirtualizorResponse {
|
|
206
|
+
vs_stats?: unknown;
|
|
207
|
+
vs_bandwidth?: unknown;
|
|
208
|
+
time_taken?: string;
|
|
209
|
+
}
|
|
210
|
+
interface VNCInfo extends VirtualizorResponse {
|
|
211
|
+
novnc?: string;
|
|
212
|
+
[key: string]: unknown;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
declare class VpsResource {
|
|
216
|
+
private readonly http;
|
|
217
|
+
constructor(http: HttpClient);
|
|
218
|
+
list(filters?: ListVPSParams): Promise<Record<string, VPS>>;
|
|
219
|
+
get(vpsId: string): Promise<VPS>;
|
|
220
|
+
create(params: CreateVPSParams): Promise<AsyncTaskResult>;
|
|
221
|
+
delete(vpsId: string): Promise<AsyncTaskResult>;
|
|
222
|
+
start(vpsId: string): Promise<AsyncTaskResult>;
|
|
223
|
+
stop(vpsId: string): Promise<AsyncTaskResult>;
|
|
224
|
+
restart(vpsId: string): Promise<AsyncTaskResult>;
|
|
225
|
+
poweroff(vpsId: string): Promise<AsyncTaskResult>;
|
|
226
|
+
suspend(vpsId: string): Promise<AsyncTaskResult>;
|
|
227
|
+
unsuspend(vpsId: string): Promise<AsyncTaskResult>;
|
|
228
|
+
rebuild(vpsId: string, params: RebuildVPSParams): Promise<AsyncTaskResult>;
|
|
229
|
+
clone(vpsId: string, params: CloneVPSParams): Promise<AsyncTaskResult>;
|
|
230
|
+
migrate(vpsId: string, params: MigrateVPSParams): Promise<AsyncTaskResult>;
|
|
231
|
+
status(vpsId: string): Promise<unknown>;
|
|
232
|
+
vnc(vpsId: string): Promise<VNCInfo>;
|
|
233
|
+
stats(vpsId: string): Promise<VPSStatsResponse>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
declare class VirtualizorClient {
|
|
237
|
+
readonly vps: VpsResource;
|
|
238
|
+
readonly users: UsersResource;
|
|
239
|
+
readonly plans: PlansResource;
|
|
240
|
+
readonly tasks: TasksResource;
|
|
241
|
+
constructor(config: VirtualizorConfig);
|
|
242
|
+
}
|
|
243
|
+
declare function createVirtualizorClient(config: VirtualizorConfig): VirtualizorClient;
|
|
244
|
+
|
|
245
|
+
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 };
|