added createRole, updateRole and deleteRole

This commit is contained in:
hydrabolt
2015-11-05 17:37:27 +00:00
parent ca6f582853
commit e54da00282
6 changed files with 310 additions and 21 deletions

View File

@@ -325,6 +325,46 @@ var Client = (function (_EventEmitter) {
});
};
//def createRole
Client.prototype.createRole = function createRole(server) {
var data = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var callback = arguments.length <= 2 || arguments[2] === undefined ? function (err, res) {} : arguments[2];
var self = this;
return new Promise(function (resolve, reject) {
if (typeof data === "function") {
// data is the callback
callback = data;
}
self.internal.createRole(server, data).then(function (role) {
callback(null, role);
resolve(role);
})["catch"](function (e) {
callback(e);
reject(e);
});
});
};
//def deleteRole
Client.prototype.deleteRole = function deleteRole(role) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function (err) {} : arguments[1];
var self = this;
return new Promise(function (resolve, reject) {
self.internal.deleteRole(role).then(function () {
callback();
resolve();
})["catch"](function (e) {
callback(e);
reject(e);
});
});
};
return Client;
})(EventEmitter);