2016-09-15 11:29:45 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
exports = module.exports = {
|
2016-09-16 11:22:04 +02:00
|
|
|
getBoxBackupDetails: getBoxBackupDetails,
|
2016-09-16 11:21:08 +02:00
|
|
|
getAppBackupDetails: getAppBackupDetails,
|
|
|
|
|
|
2016-09-15 11:29:45 +02:00
|
|
|
getAllPaged: getAllPaged,
|
|
|
|
|
|
2016-09-16 10:59:17 +02:00
|
|
|
getRestoreUrl: getRestoreUrl,
|
|
|
|
|
|
|
|
|
|
copyObject: copyObject
|
2016-09-15 11:29:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var assert = require('assert');
|
|
|
|
|
|
2016-09-16 11:22:04 +02:00
|
|
|
function getBoxBackupDetails(apiConfig, id, callback) {
|
2016-09-15 11:29:45 +02:00
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
2016-09-16 10:58:34 +02:00
|
|
|
assert.strictEqual(typeof id, 'string');
|
2016-09-15 11:29:45 +02:00
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
2016-09-16 10:58:34 +02:00
|
|
|
var backupFolder = apiConfig.backupFolder || '/tmp/backups';
|
|
|
|
|
|
|
|
|
|
var details = {
|
|
|
|
|
backupScriptArguments: [ 'filesystem', backupFolder, id, apiConfig.key ]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
callback(null, details);
|
2016-09-15 11:29:45 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-16 11:21:08 +02:00
|
|
|
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');
|
|
|
|
|
|
|
|
|
|
var backupFolder = apiConfig.backupFolder || '/tmp/backups';
|
|
|
|
|
|
|
|
|
|
var details = {
|
|
|
|
|
backupScriptArguments: [ 'filesystem', appId, backupFolder, configId, dataId, apiConfig.key ]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
callback(null, details);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-15 11:29:45 +02:00
|
|
|
function getAllPaged(apiConfig, page, perPage, callback) {
|
|
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof page, 'number');
|
|
|
|
|
assert.strictEqual(typeof perPage, 'number');
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
|
|
|
|
return callback(null, []);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getRestoreUrl(apiConfig, filename, callback) {
|
|
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof filename, 'string');
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
|
|
|
|
callback(null, { url: '' });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function copyObject(apiConfig, from, to, callback) {
|
|
|
|
|
assert.strictEqual(typeof apiConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof from, 'string');
|
|
|
|
|
assert.strictEqual(typeof to, 'string');
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
|
|
|
|
callback(null);
|
|
|
|
|
}
|