This is an example of how to use the Memset API with node.js and node-xmlrpc module.
Substitute API_KEY_HEX with a valid API key.
//
// Memset API example using node.js and node-xmlrpc.
//
var xmlrpc = require('xmlrpc');
var cliOps = {
host: 'api.memset.com',
port: 443,
path: '/v1/xmlrpc',
basic_auth: {
user: 'API_KEY_HEX',
pass: '',
}
};
var client = xmlrpc.createSecureClient(cliOps);
client.methodCall('system.listMethods', null, function(error, value) {
if(error) {
console.log("Error: " + error);
return;
}
console.log('Method list: ' + value);
});
client.methodCall('service.info', [ { name: 'myserver1', } ], function(error, value) {
if(error) {
console.log("Error: " + error);
return;
}
console.log('service.info: ');
for(prop in value) {
console.log(prop + " = " + value[prop]);
}
});
client.methodCall('server.reboot', [ { name: 'myserver1', } ], function(error, value) {
if(error) {
console.log("Error: " + error);
return;
}
console.log('service.reboot result (new job): ');
for(prop in value) {
console.log(prop + " = " + value[prop]);
}
});