Add API to set and transfer ownership

This commit is contained in:
Girish Ramakrishnan
2018-06-28 16:48:04 -07:00
parent ff5bd42bef
commit 9978dff627
6 changed files with 111 additions and 3 deletions
+28
View File
@@ -42,6 +42,9 @@ exports = module.exports = {
downloadFile: downloadFile,
uploadFile: uploadFile,
setOwner: setOwner,
transferOwnership: transferOwnership,
// exported for testing
_validateHostname: validateHostname,
_validatePortBindings: validatePortBindings,
@@ -1357,3 +1360,28 @@ function uploadFile(appId, sourceFilePath, destFilePath, callback) {
callback(null);
});
}
function setOwner(appId, ownerId, callback) {
assert.strictEqual(typeof appId, 'string');
assert.strictEqual(typeof callback, 'function');
appdb.setOwner(appId, ownerId, function (error) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.NOT_FOUND, error.message));
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
callback();
});
}
function transferOwnership(oldOwnerId, newOwnerId, callback) {
assert.strictEqual(typeof oldOwnerId, 'string');
assert.strictEqual(typeof newOwnerId, 'string');
assert.strictEqual(typeof callback, 'function');
appdb.transferOwnership(oldOwnerId, newOwnerId, function (error) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.NOT_FOUND, error.message));
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
callback();
});
}