virtualizorjs 1.0.0-beta → 1.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.
@@ -0,0 +1,36 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: 16
18
+ - run: npm ci
19
+ - run: npm test
20
+
21
+ publish-gpr:
22
+ needs: build
23
+ runs-on: ubuntu-latest
24
+ permissions:
25
+ contents: read
26
+ packages: write
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ - uses: actions/setup-node@v3
30
+ with:
31
+ node-version: 16
32
+ registry-url: https://npm.pkg.github.com/
33
+ - run: npm ci
34
+ - run: npm publish
35
+ env:
36
+ NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -0,0 +1,46 @@
1
+ name: Release Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout Repository
14
+ uses: actions/checkout@v2
15
+
16
+ - name: Set up Node.js
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '14'
20
+
21
+ - name: Install Dependencies
22
+ run: npm install
23
+
24
+ - name: Build Release Package
25
+ run: npm run build
26
+
27
+ - name: Create Release
28
+ id: create_release
29
+ uses: actions/create-release@v1
30
+ env:
31
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32
+ with:
33
+ files: |
34
+ dist/*
35
+ release_name: Release ${{ github.event_name }} ${{ github.sha }}
36
+
37
+ - name: Upload Release Asset
38
+ id: upload-release-asset
39
+ uses: actions/upload-release-asset@v1
40
+ env:
41
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42
+ with:
43
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
44
+ asset_path: dist/*
45
+ asset_name: virtualizorjs-${{ github.sha }}.zip
46
+ asset_content_type: application/zip
package/README.md CHANGED
@@ -4,16 +4,17 @@ Since there is no SDK's for Node.js for the Virtualizor API, I decided to create
4
4
 
5
5
  VirtualizorJS simplifies the management of Virtualizor servers with a streamlined and developer-friendly API for Node.js. Perform actions such as creating, starting, stopping, and restarting virtual servers effortlessly. Ideal for seamless integration into your Node.js applications, providing a powerful toolkit for Virtualizor server management.
6
6
 
7
- [![npm version](https://badge.fury.io/js/virtualizorjs.svg)](https://badge.fury.io/js/virtualizorjs)
7
+ [![npm version](https://badge.fury.io/js/virtualizorjs.png)](https://badge.fury.io/js/virtualizorjs)
8
8
 
9
9
  ## Important
10
- - As of `19 January 2024` Not all Virtualizor API functions are tested fully. ( i m busy (just lazy lmao))
10
+ - This library is still in development and there is more to add but for now it's stable and ready to use, all the methods have been tested and work as expected.
11
11
 
12
12
  ## Table of Contents
13
13
  - [Installation](#installation)
14
14
  - [Usage](#usage)
15
15
  - [Examples](#examples)
16
16
  - [API Documentation](#api-documentation)
17
+ - [Roadmap](#roadmap)
17
18
  - [Contributing](#contributing)
18
19
  - [License](#license)
19
20
 
@@ -33,8 +34,8 @@ const VirtualizorClient = require('virtualizorjs');
33
34
  const { ListVPS } = new VirtualizorClient({
34
35
  host: '< IP or Hostname of Virtualizor Server >',
35
36
  port: 4083,
36
- key: "< Your API KEY >",
37
- pass: "< Your API PASS >",
37
+ adminapikey: "< Your API KEY >",
38
+ adminapipass: "< Your API PASS >",
38
39
  });
39
40
 
40
41
  // Using const client = new VirtualizorClient({ ... }) is also valid, but you will have to use client.ListVPS() instead of ListVPS() which just looks ugly.
@@ -60,8 +61,8 @@ const VirtualizorClient = require('virtualizorjs');
60
61
  const { on: eventOn } = new VirtualizorClient({
61
62
  host: '< IP or Hostname of Virtualizor Server >',
62
63
  port: 4083,
63
- key: "< Your API KEY >",
64
- pass: "< Your API PASS >",
64
+ adminapikey: "< Your API KEY >",
65
+ adminapipass: "< Your API PASS >",
65
66
  });
66
67
 
67
68
  // - Event Types - :
@@ -106,6 +107,7 @@ eventOn('vpsRestarted', (response) => {
106
107
  ## Documentation
107
108
 
108
109
  - Check the [Wiki](https://github.com/kkMihai/virtualizorjs/wiki) for detailed documentation.
110
+ - If you use frameworks such as [Next.js](https://nextjs.org/) make sure to use it only Server-Side for security reasons.
109
111
 
110
112
  ## Roadmap
111
113
  - [ ] Add Proxmox KVM Support
package/SECURITY.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  | Version | Supported |
6
6
  | ------- | ------------------ |
7
- | 1.0.0 | :white_check_mark: |
7
+ | 1.0.0-beta | :white_check_mark: |
8
8
 
9
9
  ## Reporting a Vulnerability
10
10
 
@@ -3,8 +3,8 @@ const VirtualizorClient = require("virtualizorjs");
3
3
  const { CreateVPS } = new VirtualizorClient({
4
4
  host: "< IP or Hostname of Virtualizor Server >",
5
5
  port: 4083, // Default port for Virtualizor API
6
- key: "< Your API KEY >",
7
- pass: "< Your API PASS >",
6
+ adminapikey: "< Your API KEY >",
7
+ adminapipass: "< Your API PASS >",
8
8
  });
9
9
 
10
10
  async function exampleUsage() {
@@ -3,8 +3,8 @@ const VirtualizorClient = require('virtualizorjs');
3
3
  const { on: eventOn } = new VirtualizorClient({
4
4
  host: '< IP or Hostname of Virtualizor Server >',
5
5
  port: 4083,
6
- key: "< Your API KEY >",
7
- pass: "< Your API PASS >",
6
+ adminapikey: "< Your API KEY >",
7
+ adminapipass: "< Your API PASS >",
8
8
  });
9
9
 
10
10
  // Event listener for when a virtual server is created
@@ -3,8 +3,8 @@ const VirtualizorClient = require("virtualizorjs");
3
3
  const { ListVPS } = new VirtualizorClient({
4
4
  host: "< IP or Hostname of Virtualizor Server >",
5
5
  port: 4083, // Default port for Virtualizor API
6
- key: "< Your API KEY >",
7
- pass: "< Your API PASS >",
6
+ adminapikey: "< Your API KEY >",
7
+ adminapipass: "< Your API PASS >",
8
8
  });
9
9
 
10
10
  async function exampleUsage() {
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "virtualizorjs",
3
- "version": "1.0.0-beta",
3
+ "version": "1.0.0",
4
4
  "description": "VirtualizorJS simplifies the management of Virtualizor servers with a streamlined and developer-friendly API for Node.js. Perform actions such as creating, starting, stopping, and restarting virtual servers effortlessly. Ideal for seamless integration into your Node.js applications, providing a powerful toolkit for Virtualizor server management.",
5
- "main": "/src/VirtualizorClient.js",
5
+ "main": "./src/VirtualizorClient.js",
6
+ "scripts": {},
6
7
  "keywords": [
7
8
  "virtualizor",
8
9
  "api",
@@ -21,12 +22,15 @@
21
22
  "powerful",
22
23
  "fast"
23
24
  ],
25
+ "publishConfig": {
26
+ "@kkMihai:registry": "https://npm.pkg.github.com"
27
+ },
24
28
  "author": "kkMihai",
25
29
  "license": "MIT",
26
30
  "github": "https://github.com/kkMihai/virtualizorjs",
27
31
  "repository": {
28
32
  "type": "git",
29
- "url": "https://github.com/kkMihai/virtualizorjs.git"
33
+ "url": "git+https://github.com/kkMihai/virtualizorjs.git"
30
34
  },
31
35
  "bugs": {
32
36
  "url": "https://github.com/kkMihai/virtualizorjs/issues"
package/src/Actions.js CHANGED
@@ -15,12 +15,18 @@ module.exports = {
15
15
  * @type {string}
16
16
  */
17
17
  VPSManage: "vpsmanage",
18
+
19
+ /**
20
+ * Action to get a VPS Info
21
+ * @type {string}
22
+ */
23
+ GetVPS: "vs",
18
24
 
19
25
  /**
20
26
  * Action to list all VPS.
21
27
  * @type {string}
22
28
  */
23
- ListVPS: "vs",
29
+ ListVPS: "listvs",
24
30
 
25
31
  /**
26
32
  * Action to start a VPS.
@@ -16,24 +16,22 @@ const Actions = require("./actions");
16
16
  /**
17
17
  * @class VirtualizorClient
18
18
  * @description - This class is used to make http requests to Virtualizor API
19
- * @version 1.0.0
20
19
  * @author kkMihai <kkmihai@duck.com>
21
- * @param {Object} optionsv - Options for VirtualizorClient
22
- * @param {String} options.host - Hostname of the Virtualizor server (IP or domain)
23
- * @param {String} options.port - Port of the Virtualizor server (default: 4083)
24
- * @param {String} options.key - API key
25
- * @param {String} options.pass - API password
26
- * @param {Boolean} options.isRawResponse - If true, the response will be the raw response from the API, Recommended to set this to false
20
+ * @param {String} host - Hostname of the Virtualizor server (IP or domain)
21
+ * @param {String} port - Port of the Virtualizor server (default: 4083)
22
+ * @param {String} adminapikey - API admin api key
23
+ * @param {String} adminapipass - API admin api pass
24
+ * @param {Boolean} isRawResponse - If true, the response will be the raw response from the API, Recommended to set this to false
27
25
  * @returns {VirtualizorClient} VirtualizorClient
28
26
  */
29
27
 
30
28
  class VirtualizorClient extends EventEmitter {
31
- constructor({ host, port, key, pass, isRawResponse = false }) {
29
+ constructor({ host, port, adminapikey, adminapipass, isRawResponse = false }) {
32
30
  super();
33
31
  this.host = host;
34
32
  this.port = port;
35
- this.key = key;
36
- this.pass = pass;
33
+ this.adminapikey = adminapikey;
34
+ this.adminapipass = adminapipass;
37
35
  this.isRawResponse = isRawResponse
38
36
 
39
37
  /**
@@ -49,7 +47,7 @@ class VirtualizorClient extends EventEmitter {
49
47
  this.GetVPSRam = this.GetVPSRam.bind(this);
50
48
  this.GetVPSCPU = this.GetVPSCPU.bind(this);
51
49
  this.GetVPSDisk = this.GetVPSDisk.bind(this);
52
- this.GetServerBandwidth = this.GetServerBandwidth.bind(this);
50
+ this.GetVPSBandwidth = this.GetVPSBandwidth.bind(this);
53
51
  this.GetPlans = this.GetPlans.bind(this);
54
52
  }
55
53
 
@@ -62,15 +60,20 @@ class VirtualizorClient extends EventEmitter {
62
60
  */
63
61
  buildQueryString(params) {
64
62
  params.api = "json";
63
+ Object.keys(params).forEach((key) => {
64
+ if (params[key] === undefined) {
65
+ delete params[key];
66
+ }
67
+ });
65
68
  const queryParams = new URLSearchParams(params);
66
69
  return `?${queryParams.toString()}`;
67
70
  }
68
71
 
69
72
  /**
70
73
  * @description - This method is used to make http/s request and should not be used externally
71
- * @param {String} path
72
- * @param {String} method
73
- * @param {String} postData
74
+ * @param {String} path - Path of the request
75
+ * @param {String} method - Method of the request
76
+ * @param {String} postData - This is used to send data in POST request in the form of query string
74
77
  * @returns {Promise} Promise
75
78
  * @memberof VirtualizorClient
76
79
  * @private
@@ -79,17 +82,21 @@ class VirtualizorClient extends EventEmitter {
79
82
  const options = {
80
83
  host: this.host,
81
84
  port: this.port,
85
+ protocol: "https:",
82
86
  path: path,
83
87
  method: method,
84
88
  headers: {
85
89
  "Content-Type": "application/x-www-form-urlencoded",
86
90
  },
87
- agent: new https.Agent({ rejectUnauthorized: false }),
91
+ agent: new https.Agent({ rejectUnauthorized: false ,requestCert: false }),
88
92
  };
89
93
 
90
94
  return new Promise((resolve, reject) => {
91
95
  const req = https.request(options, (res) => {
92
96
  let data = "";
97
+
98
+ console.log(data);
99
+
93
100
 
94
101
  res.on("data", (chunk) => {
95
102
  data += chunk;
@@ -128,9 +135,9 @@ class VirtualizorClient extends EventEmitter {
128
135
  virtualizationType,
129
136
  nodeSelection,
130
137
  userEmail,
131
- userPassword,
138
+ userpassword,
132
139
  serverHostname,
133
- rootPassword,
140
+ rootpassword,
134
141
  osId,
135
142
  ipAddress,
136
143
  storageSpace,
@@ -158,17 +165,17 @@ class VirtualizorClient extends EventEmitter {
158
165
  virt: virtualizationType,
159
166
  node_select: nodeSelection,
160
167
  user_email: userEmail,
161
- user_pass: userPassword,
168
+ user_pass: userpassword,
162
169
  hostname: serverHostname,
163
- root_pass: rootPassword,
170
+ root_pass: rootpassword,
164
171
  os_id: osId,
165
172
  ips: ipAddress,
166
173
  space: handleDiskSpace(storageSpace),
167
174
  ram: serverRam,
168
175
  bandwidth: bandwidthLimit,
169
176
  cores: cpuCores,
170
- key: this.key,
171
- pass: this.pass,
177
+ adminapikey: this.adminapikey,
178
+ adminapipass: this.adminapipass,
172
179
  };
173
180
 
174
181
  const path = `/index.php${this.buildQueryString(queryParams)}`;
@@ -190,40 +197,33 @@ class VirtualizorClient extends EventEmitter {
190
197
  * @param {String} id - ID of the virtual server
191
198
  * @returns {Promise} Promise
192
199
  * @memberof VirtualizorClient
200
+ * @Tested - Yes
193
201
  */
194
202
  async GetVPS(id) {
195
203
  const queryParams = {
196
- act: Actions.VPSManage,
197
- changeserid: id,
198
- key: this.key,
199
- pass: this.pass,
204
+ act: Actions.GetVPS,
205
+ vpsid: id,
206
+ adminapikey: this.adminapikey,
207
+ adminapipass: this.adminapipass,
200
208
  };
201
209
 
202
210
  const path = `/index.php${this.buildQueryString(queryParams)}`;
203
211
 
204
212
  try {
205
- const res = await this.makeHttpRequest(path);
213
+
214
+ if (!id) {
215
+ return Promise.reject(new Error("vpsid is required"));
216
+ }
217
+
218
+ const res = await this.makeHttpRequest(path, "POST");
206
219
  let resData = res;
207
220
 
208
221
  if (!this.isRawResponse) {
209
- resData = {
210
- ip: res.info.ip,
211
- hostname: res.info.hostname,
212
- status: res.info.status,
213
- os: res.info.vps.os_name,
214
- cores: res.info.vps.cores,
215
- ram: res.info.vps.ram,
216
- space: res.info.vps.space,
217
- bandwidth: {
218
- limit: res.info.bandwidth.limit,
219
- used: res.info.bandwidth.used,
220
- free: res.info.bandwidth.free,
221
- },
222
- datacenter: res.info.server_name,
223
- };
222
+ resData = res.vs[id];
224
223
  }
225
224
 
226
225
  return Promise.resolve(resData);
226
+
227
227
  } catch (err) {
228
228
  return Promise.reject(err);
229
229
  }
@@ -232,92 +232,29 @@ class VirtualizorClient extends EventEmitter {
232
232
  /**
233
233
  * @description - This method is used to list all virtual servers
234
234
  * @returns {Promise} Promise
235
- * @param {Number} [vpsid] - Search using id
236
- * @param {String} [vpsname] - Search using vid
237
- * @param {String} [vpsip] - Results will be returned on the basis of the ip
238
- * @param {String} [vpshostname] - VPS is searched on the basis of the hostname passed
239
- * @param {String} [vpsstatus] - VPS is searched on the basis of the status of the vps
240
- * (type 's' for suspended, type 'u' for unsuspended)
241
- * @param {String} [vstype] - VPS is searched on the basis of the type of virtualization,
242
- * refer below table for valid values
243
- * @param {String} [speedcap] - VPS is searched on the basis of the type of speed cap
244
- * (type 1 for enabled, 2 for disabled)
245
- * @param {String} [user] - Search for the vps according to the user
246
- * @param {String} [vsgid] - Search for the vps according to the server group
247
- * @param {String} [vserid] - VPS is searched on the basis of the server
248
- * @param {String} [plid] - VPS is searched on the basis of plan that it has been assigned
249
- * @param {String} [bpid] - VPS is searched on the basis of backup plan that it has been assigned
250
- * @param {Number} [reslen] - Number of records to be returned, default is 50
251
- * @param {Number} [page] - Page number, each page show 50 records
252
235
  * @memberof VirtualizorClient
236
+ * @Tested - Yes
253
237
  */
254
- async ListVPS(
255
- vpsid,
256
- vpsname,
257
- vpsip,
258
- vpshostname,
259
- vpsstatus,
260
- vstype,
261
- speedcap,
262
- user,
263
- vsgid,
264
- vserid,
265
- plid,
266
- bpid,
267
- reslen,
268
- page
269
- ) {
238
+ async ListVPS() {
270
239
  const queryParams = {
271
- act: Actions.ListVPS,
272
- key: this.key,
273
- pass: this.pass,
274
- vpsid,
275
- vpsname,
276
- vpsip,
277
- vpshostname,
278
- vpsstatus,
279
- vstype,
280
- speedcap,
281
- user,
282
- vsgid,
283
- vserid,
284
- plid,
285
- bpid,
286
- reslen,
287
- page,
240
+ act: Actions.GetVPS,
241
+ adminapikey: this.adminapikey,
242
+ adminapipass: this.adminapipass,
288
243
  };
289
244
 
290
245
  const path = `/index.php${this.buildQueryString(queryParams)}`;
291
246
 
292
247
  try {
293
- const res = await this.makeHttpRequest(path, "POST");
248
+
249
+ const res = await this.makeHttpRequest(path, "GET");
294
250
  let resData = res;
295
251
 
296
- if (!this.isRawResponse && res.data.vs) {
297
- resData = Object.keys(res.data.vs).reduce((acc, key) => {
298
- const vps = res.data.vs[key];
299
-
300
- if (vps && vps.vpsid && vps.hostname && vps.os_name) {
301
- acc.push({
302
- id: vps.vpsid,
303
- name: vps.vps_name,
304
- hostname: vps.hostname,
305
- os: vps.os_name,
306
- cores: vps.cores,
307
- ram: vps.ram,
308
- space: vps.space,
309
- bandwidth: vps.bandwidth,
310
- serverName: vps.server_name,
311
- status: vps.status,
312
- ip: vps.ips,
313
- });
314
- }
315
-
316
- return acc;
317
- }, []);
252
+ if (!this.isRawResponse) {
253
+ resData = res.vs
318
254
  }
319
255
 
320
256
  return Promise.resolve(resData);
257
+
321
258
  } catch (err) {
322
259
  return Promise.reject(err);
323
260
  }
@@ -329,24 +266,32 @@ async ListVPS(
329
266
  * @param {String} vpsId - ID of the virtual server
330
267
  * @returns {Promise} Promise
331
268
  * @memberof VirtualizorClient
269
+ * @Tested - Yes
332
270
  */
333
271
  async StartVPS(vpsId) {
334
272
  const queryParams = {
335
- act: Actions.StartVPS,
273
+ action: Actions.StartVPS,
336
274
  vpsid: vpsId,
337
- key: this.key,
338
- pass: this.pass,
275
+ adminapikey: this.adminapikey,
276
+ adminapipass: this.adminapipass,
339
277
  };
340
278
 
341
- const path = `/index.php${this.buildQueryString(queryParams)}&action=vs`;
279
+ const path = `/index.php${this.buildQueryString(queryParams)}`;
342
280
 
343
281
  try {
344
- const res = await this.makeHttpRequest(path);
282
+
283
+ if (!vpsId) {
284
+ return Promise.reject(new Error("vpsid is required"));
285
+ }
286
+
287
+ const res = await this.makeHttpRequest(path, "GET", `act=vs`);
345
288
  this.emit("vpsStarted", res);
289
+
346
290
  return Promise.resolve({
347
- message: res.done && res.done.msg,
348
- time_taken: res.time_taken,
349
- });
291
+ message: res.done && res.done_msg,
292
+ error: res.error_msg || false
293
+ })
294
+
350
295
  } catch (err) {
351
296
  return Promise.reject(err);
352
297
  }
@@ -357,24 +302,25 @@ async ListVPS(
357
302
  * @param {String} vpsId - ID of the virtual server
358
303
  * @returns {Promise} Promise
359
304
  * @memberof VirtualizorClient
305
+ * @Tested - Yes
360
306
  */
361
307
  async StopVPS(vpsId) {
362
308
  const queryParams = {
363
- act: Actions.StopVPS,
309
+ action: Actions.StopVPS,
364
310
  vpsid: vpsId,
365
- key: this.key,
366
- pass: this.pass,
311
+ adminapikey: this.adminapikey,
312
+ adminapipass: this.adminapipass,
367
313
  };
368
314
 
369
- const path = `/index.php${this.buildQueryString(queryParams)}&action=vs`;
315
+ const path = `/index.php${this.buildQueryString(queryParams)}`;
370
316
 
371
317
  try {
372
- const res = await this.makeHttpRequest(path);
318
+ const res = await this.makeHttpRequest(path, "GET", `act=vs`);
373
319
  this.emit("vpsStopped", res);
374
320
  return Promise.resolve({
375
- message: res.done && res.done.msg,
376
- time_taken: res.time_taken,
377
- });
321
+ message: res.done && res.done_msg,
322
+ error: res.error_msg || false,
323
+ })
378
324
  } catch (err) {
379
325
  return Promise.reject(err);
380
326
  }
@@ -388,21 +334,21 @@ async ListVPS(
388
334
  */
389
335
  async RestartVPS(vpsId) {
390
336
  const queryParams = {
391
- act: Actions.RestartVPS,
337
+ action: Actions.RestartVPS,
392
338
  vpsid: vpsId,
393
- key: this.key,
394
- pass: this.pass,
339
+ adminapikey: this.adminapikey,
340
+ adminapipass: this.adminapipass,
395
341
  };
396
342
 
397
- const path = `/index.php${this.buildQueryString(queryParams)}&action=vs`;
343
+ const path = `/index.php${this.buildQueryString(queryParams)}`;
398
344
 
399
345
  try {
400
- const res = await this.makeHttpRequest(path);
346
+ const res = await this.makeHttpRequest(path, "GET", `act=vs`);
401
347
  this.emit("vpsRestarted", res);
402
348
  return Promise.resolve({
403
- message: res.done && res.done.msg,
404
- time_taken: res.time_taken,
405
- });
349
+ message: res.done && res.done_msg,
350
+ error: res.error_msg || false
351
+ })
406
352
  } catch (err) {
407
353
  return Promise.reject(err);
408
354
  }
@@ -417,9 +363,9 @@ async ListVPS(
417
363
  async GetVPSRam(vpsId) {
418
364
  const queryParams = {
419
365
  act: Actions.GetVPSRam,
420
- changeserid: vpsId,
421
- key: this.key,
422
- pass: this.pass,
366
+ svs: vpsId,
367
+ adminapikey: this.adminapikey,
368
+ adminapipass: this.adminapipass,
423
369
  };
424
370
 
425
371
  const path = `/index.php${this.buildQueryString(queryParams)}`;
@@ -444,15 +390,16 @@ async ListVPS(
444
390
  async GetVPSCPU(vpsId) {
445
391
  const queryParams = {
446
392
  act: Actions.GetVPSCPU,
447
- changeserid: vpsId,
448
- key: this.key,
449
- pass: this.pass,
393
+ svs: vpsId,
394
+ adminapikey: this.adminapikey,
395
+ adminapipass: this.adminapipass,
450
396
  };
451
397
 
452
398
  const path = `/index.php${this.buildQueryString(queryParams)}`;
453
399
 
454
400
  try {
455
401
  const res = await this.makeHttpRequest(path);
402
+
456
403
  return Promise.resolve({
457
404
  cpu: res.cpu,
458
405
  time_taken: res.time_taken,
@@ -472,18 +419,21 @@ async ListVPS(
472
419
  const queryParams = {
473
420
  act: Actions.GetVPSDisk,
474
421
  changeserid: vpsId,
475
- key: this.key,
476
- pass: this.pass,
422
+ adminapikey: this.adminapikey,
423
+ adminapipass: this.adminapipass,
477
424
  };
478
425
 
479
426
  const path = `/index.php${this.buildQueryString(queryParams)}`;
480
427
 
481
428
  try {
482
429
  const res = await this.makeHttpRequest(path);
430
+
483
431
  return Promise.resolve({
484
- disk: res.disk,
432
+ info: res.disk,
485
433
  time_taken: res.time_taken,
486
434
  });
435
+
436
+
487
437
  } catch (err) {
488
438
  return Promise.reject(err);
489
439
  }
@@ -491,15 +441,17 @@ async ListVPS(
491
441
 
492
442
  /**
493
443
  * @description - This method is used to get bandwidth information of a virtual server
444
+ * @param {String} vpsId - ID of the virtual server
494
445
  * @param {String} month - Month for which bandwidth information is required (YYYY-MM)
495
446
  * @returns {Promise} Promise
496
447
  * @memberof VirtualizorClient
497
448
  */
498
- async GetServerBandwidth(month) {
449
+ async GetVPSBandwidth({vpsId, month}) {
499
450
  const queryParams = {
500
451
  act: Actions.GetServerBandwidth,
501
- key: this.key,
502
- pass: this.pass,
452
+ changeserid: vpsId,
453
+ adminapikey: this.adminapikey,
454
+ adminapipass: this.adminapipass,
503
455
  };
504
456
 
505
457
  const path = `/index.php${this.buildQueryString(queryParams)}`;
@@ -518,15 +470,18 @@ async ListVPS(
518
470
  async GetPlans() {
519
471
  const queryParams = {
520
472
  act: Actions.GetPlans,
521
- key: this.key,
522
- pass: this.pass,
473
+ adminapikey: this.adminapikey,
474
+ adminapipass: this.adminapipass,
523
475
  };
524
476
 
525
477
  const path = `/index.php${this.buildQueryString(queryParams)}`;
526
478
 
527
479
  try {
528
480
  const res = await this.makeHttpRequest(path);
529
- return Promise.resolve(res);
481
+ return Promise.resolve({
482
+ plans: res.plans,
483
+ time_taken: res.time_taken,
484
+ });
530
485
  } catch (err) {
531
486
  return Promise.reject(err);
532
487
  }