feat(xo-server/rest-api): /backups → /backup

This commit is contained in:
Julien Fontanet 2023-12-08 15:03:51 +01:00
parent f0da94081b
commit 037e1c1dfa
2 changed files with 13 additions and 5 deletions

View File

@ -8,6 +8,7 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it”
- [Forget SR] Changed the modal message and added a confirmation text to be sure the action is understood by the user [#7148](https://github.com/vatesfr/xen-orchestra/issues/7148) (PR [#7155](https://github.com/vatesfr/xen-orchestra/pull/7155))
- [REST API] `/backups` has been renamed to `/backup` (redirections are in place for compatibility)
### Bug fixes
@ -29,4 +30,6 @@
<!--packages-start-->
- xo-server minor
<!--packages-end-->

View File

@ -175,7 +175,7 @@ export default class RestApi {
})
)
collections.backups = { id: 'backups' }
collections.backup = { id: 'backup' }
collections.restore = { id: 'restore' }
collections.tasks = { id: 'tasks' }
collections.users = { id: 'users' }
@ -280,23 +280,28 @@ export default class RestApi {
wrap((req, res) => sendObjects(collections, req, res))
)
// For compatibility redirect from /backups* to /backup
api.get('/backups*', (req, res) => {
res.redirect(308, req.baseUrl + '/backup' + req.params[0])
})
api
.get(
'/backups',
'/backup',
wrap((req, res) => sendObjects([{ id: 'jobs' }, { id: 'logs' }], req, res))
)
.get(
'/backups/jobs',
'/backup/jobs',
wrap(async (req, res) => sendObjects(await app.getAllJobs('backup'), req, res))
)
.get(
'/backups/jobs/:id',
'/backup/jobs/:id',
wrap(async (req, res) => {
res.json(await app.getJob(req.params.id, 'backup'))
})
)
.get(
'/backups/logs',
'/backup/logs',
wrap(async (req, res) => {
const { filter, limit } = req.query
const logs = await app.getBackupNgLogsSorted({