Refactor getBackupCredentials()
This commit is contained in:
@@ -5,7 +5,7 @@ exports = module.exports = {
|
||||
|
||||
copyObject: copyObject,
|
||||
|
||||
getBackupCredentials: getBackupCredentials,
|
||||
getBackupDetails: getBackupDetails,
|
||||
|
||||
getAllPaged: getAllPaged
|
||||
};
|
||||
@@ -28,6 +28,7 @@ function getBackupCredentials(apiConfig, callback) {
|
||||
if (!result.body || !result.body.credentials) return callback(new Error('Unexpected response'));
|
||||
|
||||
var credentials = {
|
||||
signatureVersion: 'v4',
|
||||
accessKeyId: result.body.credentials.AccessKeyId,
|
||||
secretAccessKey: result.body.credentials.SecretAccessKey,
|
||||
sessionToken: result.body.credentials.SessionToken,
|
||||
@@ -40,6 +41,25 @@ function getBackupCredentials(apiConfig, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getBackupDetails(apiConfig, id, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof id, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
getBackupCredentials(apiConfig, function (error, result) {
|
||||
if (error) return callback(error);
|
||||
|
||||
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, result.sessionToken ]
|
||||
};
|
||||
|
||||
callback(null, details);
|
||||
});
|
||||
}
|
||||
|
||||
function getAllPaged(apiConfig, page, perPage, callback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof page, 'number');
|
||||
|
||||
Reference in New Issue
Block a user