lxc_manager_node/doapi.js
2016-05-20 09:11:31 -04:00

30 lines
624 B
JavaScript

var request = require('request');
api = function(key){
key = key || require('./secrets.js').doAPI;
this.BASEURL = 'https://api.digitalocean.com/v2/';
this.headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer '+key
}
this.byTag = function(tag, callback){
var options = {
url: this.BASEURL+'droplets?tag_name='+tag,
headers: this.headers
}
return request.get(options, function(error, response, body){
return callback(body, response, error);
})
};
// this.setTag = function(id, tag, callback){
// return request.post(url+)
// };
return this;
}
module.exports = api;