1.1.0 • Published 5 years ago
solusvm v1.1.0
SolusVM
A SolusVM Admin API Wrapper
Installation
This module can be install via npm:
$ npm install --save solusvm
Usage
The solusvm.call()
method accepts three arguments:
1. The name of the SolusVM API action to call
2. An object with the variables for the API call
3. An optional callback function
If no callback function is passed to the call then a promise is returned. To use a callback instead, pass a callback function as the third argument.
var solusvm = require('solusvm');
//Configrure the API client with the URL, API ID and API KEY of the SolusVM Master Instance
solusvm.configure('url', 'apiId', 'apiKey');
//Example of a promise-based call to the client
solusvm.call('node-idlist', {
type: 'openvz'
})
.then(function(data) {
console.log(data);
})
.catch(function(err) {
console.log(err);
});
//Example of a callback-based call to the client
solusvm.call('node-idlist', {
type: 'openvz'
}, function(err, data) {
if (err) {
console.log(err);
} else {
console.log(data);
}
});