Refactor getBackupCredentials()

This commit is contained in:
Johannes Zellner
2016-09-16 10:58:34 +02:00
parent 5ac12452a1
commit 83ed87a8eb
4 changed files with 65 additions and 50 deletions

View File

@@ -6,7 +6,7 @@ exports = module.exports = {
copyObject: copyObject,
getAllPaged: getAllPaged,
getBackupCredentials: getBackupCredentials
getBackupDetails: getBackupDetails
};
var assert = require('assert'),
@@ -30,6 +30,21 @@ function getBackupCredentials(apiConfig, callback) {
callback(null, credentials);
}
function getBackupDetails(apiConfig, id, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof id, 'string');
assert.strictEqual(typeof callback, 'function');
var s3Url = 's3://' + apiConfig.bucket + '/' + apiConfig.prefix + '/' + id;
var region = apiConfig.region || 'us-east-1';
var details = {
backupScriptArguments: [ 's3', s3Url, apiConfig.accessKeyId, apiConfig.secretAccessKey, region, apiConfig.key ]
};
callback(null, details);
}
function getAllPaged(apiConfig, page, perPage, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof page, 'number');