feat(xo-server/rest-api): expose backup logs (#6711)

This commit is contained in:
Julien Fontanet
2023-03-13 09:10:15 +01:00
committed by GitHub
parent 36fabe194f
commit 35f6476d0f
2 changed files with 33 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
> Users must be able to say: “I had this issue, happy to know it's fixed” > Users must be able to say: “I had this issue, happy to know it's fixed”
- [Backup/Restore] Fix restore via a proxy showing as interupted (PR [#6702](https://github.com/vatesfr/xen-orchestra/pull/6702)) - [Backup/Restore] Fix restore via a proxy showing as interupted (PR [#6702](https://github.com/vatesfr/xen-orchestra/pull/6702))
- [REST API] Backup logs are now available at `/rest/v0/backups/logs`
### Packages to release ### Packages to release
@@ -30,7 +31,7 @@
<!--packages-start--> <!--packages-start-->
- @xen-orchestra/backups minor - @xen-orchestra/backups minor
- xo-server patch - xo-server minor
- xo-web patch - xo-web patch
<!--packages-end--> <!--packages-end-->

View File

@@ -119,6 +119,9 @@ export default class RestApi {
}) })
) )
collections.backups = { id: 'backups' }
collections.restore = { id: 'restore' }
collections.vms.actions = { collections.vms.actions = {
__proto__: null, __proto__: null,
@@ -159,6 +162,34 @@ export default class RestApi {
}) })
api.get('/', (req, res) => sendObjects(collections, req, res)) api.get('/', (req, res) => sendObjects(collections, req, res))
api
.get(['/backups', '/restore'], (req, res) => {
sendObjects([{ id: 'logs' }], req, res)
})
.get(
'/backups/logs',
wrap(async (req, res) => {
const logs = await app.getBackupNgLogsSorted({
filter: ({ message: m }) => m === 'backup' || m === 'metadata',
})
sendObjects(logs, req, res)
})
)
.get(
'/restore/logs',
wrap(async (req, res) => {
const logs = await app.getBackupNgLogsSorted({ filter: _ => _.message === 'restore' })
sendObjects(logs, req, res)
})
)
.get(
['/backups/logs/:id', '/restore/logs/:id'],
wrap(async (req, res) => {
res.json(await app.getBackupNgLogs(req.params.id))
})
)
api.get( api.get(
'/:collection', '/:collection',
wrap(async (req, res) => { wrap(async (req, res) => {