app: add export route
Currently, the export route only creates the snapshot (the other side of in-place import). In the future, the export route can export to a custom backup config (like import).
This commit is contained in:
21
src/apps.js
21
src/apps.js
@@ -33,6 +33,7 @@ exports = module.exports = {
|
||||
|
||||
restore,
|
||||
importApp,
|
||||
exportApp,
|
||||
clone,
|
||||
|
||||
update,
|
||||
@@ -1549,6 +1550,26 @@ function importApp(app, data, auditSource, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function exportApp(app, data, auditSource, callback) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
const appId = app.id;
|
||||
|
||||
let error = checkAppState(app, exports.ISTATE_PENDING_BACKUP);
|
||||
if (error) return callback(error);
|
||||
|
||||
const task = {
|
||||
args: { snapshotOnly: true },
|
||||
values: {}
|
||||
};
|
||||
addTask(appId, exports.ISTATE_PENDING_BACKUP, task, (error, result) => {
|
||||
if (error) return callback(error);
|
||||
|
||||
callback(null, { taskId: result.taskId });
|
||||
});
|
||||
}
|
||||
|
||||
function purchaseApp(data, callback) {
|
||||
assert.strictEqual(typeof data, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
Reference in New Issue
Block a user