Files
cloudron-box/src/storage/interface.js

95 lines
2.7 KiB
JavaScript
Raw Normal View History

2016-09-16 12:55:45 +02:00
'use strict';
// -------------------------------------------
// This file just describes the interface
//
// New backends can start from here
// -------------------------------------------
exports = module.exports = {
2017-04-18 14:55:22 +02:00
backup: backup,
restore: restore,
copyBackup: copyBackup,
removeBackup: removeBackup,
2017-04-18 14:55:22 +02:00
getDownloadStream: getDownloadStream,
2017-01-04 16:22:58 -08:00
backupDone: backupDone,
testConfig: testConfig
2016-09-16 12:55:45 +02:00
};
var assert = require('assert');
2017-04-18 14:55:22 +02:00
function backup(apiConfig, backupId, sourceDirectories, callback) {
2016-09-16 12:55:45 +02:00
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof backupId, 'string');
2017-04-18 14:55:22 +02:00
assert(Array.isArray(sourceDirectories));
2016-09-16 12:55:45 +02:00
assert.strictEqual(typeof callback, 'function');
// Result: none
2016-09-16 12:55:45 +02:00
callback(new Error('not implemented'));
}
2017-04-18 14:55:22 +02:00
function restore(apiConfig, backupId, destinationDirectories, callback) {
2016-09-16 12:55:45 +02:00
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof backupId, 'string');
2017-04-18 14:55:22 +02:00
assert(Array.isArray(destinationDirectories));
2016-09-16 12:55:45 +02:00
assert.strictEqual(typeof callback, 'function');
// Result: none
callback(new Error('not implemented'));
}
2017-04-18 14:55:22 +02:00
function copyBackup(apiConfig, oldBackupId, newBackupId, callback) {
assert.strictEqual(typeof apiConfig, 'object');
2017-04-18 14:55:22 +02:00
assert.strictEqual(typeof oldBackupId, 'string');
assert.strictEqual(typeof newBackupId, 'string');
assert.strictEqual(typeof callback, 'function');
// Result: none
2016-09-16 12:55:45 +02:00
callback(new Error('not implemented'));
}
2017-04-18 14:55:22 +02:00
function removeBackup(apiConfig, backupId, appBackupIds, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof backupId, 'string');
2017-04-18 14:55:22 +02:00
assert(Array.isArray(appBackupIds));
2016-09-16 12:55:45 +02:00
assert.strictEqual(typeof callback, 'function');
// Result: none
callback(new Error('not implemented'));
}
2017-04-18 14:55:22 +02:00
function getDownloadStream(apiConfig, backupId, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof backupId, 'string');
assert.strictEqual(typeof callback, 'function');
2017-04-18 14:55:22 +02:00
// Result: ReadStream to a tar.gz (not encrypted)
callback(new Error('not implemented'));
}
function testConfig(apiConfig, callback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof callback, 'function');
2017-04-18 14:55:22 +02:00
// Result: none - first callback argument error if config does not pass the test
callback(new Error('not implemented'));
}
2017-01-04 16:22:58 -08:00
function backupDone(filename, app, appBackupIds, callback) {
assert.strictEqual(typeof filename, 'string');
assert(!app || typeof app === 'object');
assert(!appBackupIds || Array.isArray(appBackupIds));
assert.strictEqual(typeof callback, 'function');
callback(new Error('not implemented'));
}