aeza-net-sdk
Advanced tools
Comparing version
{ | ||
"name": "aeza-net-sdk", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "A library that allows you to work with the AEZA.NET hosting API", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -65,2 +65,13 @@ > **AEZA-NET-SDK** - This is a [Node.js](https://nodejs.org) module that makes it easy to interact with the AEZA API. 🚀 | ||
#### Products: | ||
```javascript | ||
import AezaAPI from 'aeza-net-sdk'; | ||
const api = new AezaAPI(process.env.TOKEN); | ||
const list = await api.products(); | ||
console.log(list) // Displays all products | ||
``` | ||
#### Charts Info: | ||
@@ -104,2 +115,18 @@ | ||
#### Reinstall Server: | ||
```javascript | ||
import AezaAPI from 'aeza-net-sdk'; | ||
const api = new AezaAPI(process.env.TOKEN); | ||
const service = await api.reinstall({ | ||
id: YOU_SERVER_ID, | ||
recipe: RECIPE, | ||
password: YOU_NEW_PASSWORD, | ||
os: NEW_OS | ||
}); | ||
console.log(service) // Displays information about server deletion | ||
``` | ||
#### Delete Server: | ||
@@ -116,3 +143,3 @@ | ||
#### Restart Server: | ||
#### Server Management: | ||
@@ -123,3 +150,3 @@ ```javascript | ||
const api = new AezaAPI(process.env.TOKEN); | ||
const service = await api.restart(YOU_SERVER_ID); | ||
const service = await api.ctl(YOU_SERVER_ID, ACTION); //Possible actions: resume/suspend/restart | ||
@@ -126,0 +153,0 @@ console.log(service) // Displays information about server restart |
@@ -44,2 +44,15 @@ import IQuery from './interface/IQuery'; | ||
}>; | ||
products(): Promise<{ | ||
slug: any; | ||
message: any; | ||
data: any; | ||
response?: undefined; | ||
} | { | ||
response: { | ||
items: any; | ||
}; | ||
slug?: undefined; | ||
message?: undefined; | ||
data?: undefined; | ||
}>; | ||
charts(id: number): Promise<{ | ||
@@ -69,3 +82,3 @@ slug: any; | ||
}>; | ||
restart(id: number): Promise<{ | ||
ctl(id: number, action: "suspend" | "resume" | "restart"): Promise<{ | ||
slug: any; | ||
@@ -83,2 +96,21 @@ message: any; | ||
}>; | ||
reinstall(params: { | ||
id: number; | ||
recipe: number | null; | ||
os: number; | ||
password: string; | ||
}): Promise<{ | ||
slug: any; | ||
message: any; | ||
data: any; | ||
response?: undefined; | ||
} | { | ||
response: { | ||
status: any; | ||
items: any; | ||
}; | ||
slug?: undefined; | ||
message?: undefined; | ||
data?: undefined; | ||
}>; | ||
delete(id: number): Promise<{ | ||
@@ -85,0 +117,0 @@ slug: any; |
@@ -62,2 +62,27 @@ import axios from 'axios'; | ||
} | ||
async products() { | ||
const { data, error } = await this.query({ | ||
token: this.token, | ||
method: "GET", | ||
route: `products`, | ||
}); | ||
if (error) { | ||
return { | ||
slug: error.slug, | ||
message: error.message, | ||
data: error.data || {} | ||
}; | ||
} | ||
return { | ||
response: { | ||
items: data.items.map((items, i) => { | ||
return { | ||
title: items[i].name, | ||
configurations: items[i].configurations, | ||
price: items[i].price | ||
}; | ||
}) | ||
} | ||
}; | ||
} | ||
async charts(id) { | ||
@@ -100,3 +125,3 @@ const { data, error } = await this.query({ | ||
} | ||
async restart(id) { | ||
async ctl(id, action) { | ||
const { data, error } = await this.query({ | ||
@@ -107,3 +132,3 @@ token: this.token, | ||
data: { | ||
action: 'reboot' | ||
action | ||
} | ||
@@ -124,2 +149,27 @@ }); | ||
} | ||
async reinstall(params) { | ||
const { data, error } = await this.query({ | ||
token: this.token, | ||
method: "POST", | ||
route: `services/${params.id}/reinstall`, | ||
data: { | ||
os: params.os, | ||
recipe: params.recipe, | ||
password: params.password | ||
} | ||
}); | ||
if (error) { | ||
return { | ||
slug: error.slug, | ||
message: error.message, | ||
data: error.data || {} | ||
}; | ||
} | ||
return { | ||
response: { | ||
status: data.status || 'error', | ||
items: data.items || {} | ||
} | ||
}; | ||
} | ||
async delete(id) { | ||
@@ -126,0 +176,0 @@ const { data, error } = await this.query({ |
Sorry, the diff of this file is not supported yet
24468
19.65%489
20.15%175
18.24%