@@ -21,6 +21,7 @@ exports = module.exports = {
|
||||
setIcon: setIcon,
|
||||
setMemoryLimit: setMemoryLimit,
|
||||
setCpuShares: setCpuShares,
|
||||
setVolumes: setVolumes,
|
||||
setAutomaticBackup: setAutomaticBackup,
|
||||
setAutomaticUpdate: setAutomaticUpdate,
|
||||
setReverseProxyConfig: setReverseProxyConfig,
|
||||
@@ -238,6 +239,24 @@ function setCpuShares(req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
function setVolumes(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
assert.strictEqual(typeof req.resource, 'object');
|
||||
|
||||
if (!Array.isArray(req.body.volumes)) return next(new HttpError(400, 'volumes should be an array'));
|
||||
for (let v of req.body.volumes) {
|
||||
if (!v || typeof v !== 'object') return next(new HttpError(400, 'volume must be a {id, readOnly}'));
|
||||
if (typeof v.id !== 'string') return next(new HttpError(400, 'id must be a string'));
|
||||
if (typeof v.readOnly !== 'boolean') return next(new HttpError(400, 'readOnly must be a boolean'));
|
||||
}
|
||||
|
||||
apps.setVolumes(req.resource, req.body.volumes, auditSource.fromRequest(req), function (error, result) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(202, { taskId: result.taskId }));
|
||||
});
|
||||
}
|
||||
|
||||
function setAutomaticBackup(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
assert.strictEqual(typeof req.resource, 'object');
|
||||
|
||||
Reference in New Issue
Block a user