volumes: update route

This commit is contained in:
Girish Ramakrishnan
2021-05-13 09:14:50 -07:00
parent ac4fa83080
commit 2c8e83dc6d
3 changed files with 13 additions and 7 deletions

View File

@@ -6,7 +6,7 @@ exports = module.exports = {
del,
list,
load,
setMountConfig,
update,
getMountStatus
};
@@ -61,13 +61,13 @@ async function list(req, res, next) {
next(new HttpSuccess(200, { volumes: result }));
}
async function setMountConfig(req, res, next) {
async function update(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
if (typeof req.body.mountType !== 'string') return next(new HttpError(400, 'mountType must be a string'));
if (typeof req.body.mountOptions !== 'object') return next(new HttpError(400, 'mountOptions must be a object'));
const [error] = await safe(volumes.setMountConfig(req.resource, req.body.mountType, req.body.mountOptions));
const [error] = await safe(volumes.update(req.resource, req.body.mountType, req.body.mountOptions));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));
}