Refactor getAppBackupCredentials()

This commit is contained in:
Johannes Zellner
2016-09-16 11:21:08 +02:00
parent 96c8f96c52
commit 2ce768e29a
5 changed files with 89 additions and 54 deletions

View File

@@ -2,6 +2,8 @@
exports = module.exports = {
getBackupDetails: getBackupDetails,
getAppBackupDetails: getAppBackupDetails,
getAllPaged: getAllPaged,
getRestoreUrl: getRestoreUrl,
@@ -59,6 +61,28 @@ function getBackupDetails(apiConfig, id, callback) {
});
}
function getAppBackupDetails(apiConfig, appId, dataId, configId, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof appId, 'string');
assert.strictEqual(typeof dataId, 'string');
assert.strictEqual(typeof configId, '');
assert.strictEqual(typeof callback, 'function');
getBackupCredentials(apiConfig, function (error, result) {
if (error) return callback(error);
var s3DataUrl = 's3://' + apiConfig.bucket + '/' + apiConfig.prefix + '/' + dataId;
var s3ConfigUrl = 's3://' + apiConfig.bucket + '/' + apiConfig.prefix + '/' + configId;
var region = apiConfig.region || 'us-east-1';
var details = {
backupScriptArguments: [ 's3', appId, s3ConfigUrl, s3DataUrl, apiConfig.accessKeyId, apiConfig.secretAccessKey, region, apiConfig.key, result.sessionToken ]
};
callback(null, details);
});
}
function getAllPaged(apiConfig, page, perPage, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof page, 'number');