Skip to content

Commit 9b4745e

Browse files
committed
Add installation and usage details to README
1 parent af23e7b commit 9b4745e

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

README.md

+44-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,47 @@
44
[![Coverage Status](https://coveralls.io/repos/github/axeal/solusvm/badge.svg?branch=master)](https://coveralls.io/github/axeal/solusvm?branch=master)
55
[![Known Vulnerabilities](https://snyk.io/test/github/axeal/solusvm/badge.svg)](https://snyk.io/test/github/axeal/solusvm)
66

7-
A SolusVM Admin API Wrapper
7+
A SolusVM Admin API Wrapper
8+
9+
## Installation
10+
This module can be install via npm:
11+
```text
12+
$ npm install --save solusvm```
13+
14+
## Usage
15+
16+
The ```solusvm.call()``` method accepts three arguments:
17+
1. The name of the SolusVM API action to call
18+
2. An object with the variables for the API call
19+
3. An optional callback function
20+
21+
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.
22+
23+
```javascript
24+
var solusvm = require('solusvm');
25+
26+
//Configrure the API client with the URL, API ID and API KEY of the SolusVM Master Instance
27+
solusvm.configure('url', 'apiId', 'apiKey');
28+
29+
//Example of a promise-based call to the client
30+
solusvm.call('node-idlist', {
31+
type: 'openvz'
32+
})
33+
.then(function(data) {
34+
console.log(data);
35+
})
36+
.catch(function(err) {
37+
console.log(err);
38+
});
39+
40+
//Example of a callback-based call to the client
41+
solusvm.call('node-idlist', {
42+
type: 'openvz'
43+
}, function(err, data) {
44+
if (err) {
45+
console.log(err);
46+
} else {
47+
console.log(data);
48+
}
49+
});
50+
````

0 commit comments

Comments
 (0)