feat(@xen-orchestra/rest-api): expose vdi-snapshots/:id/tags/:tag (#9091)

This commit is contained in:
MlssFrncJrg
2025-10-10 10:31:03 +02:00
committed by GitHub
parent e1ecc2d6d4
commit 938b34343d
4 changed files with 31 additions and 2 deletions

View File

@@ -841,6 +841,8 @@ export interface XenApiLvhd {
uuid: string
}
type XenApiVdiCallMethods = TagCallMethods & {}
export interface XenApiVdi {
$ref: Branded<'VDI'>
allow_caching: boolean
@@ -877,7 +879,7 @@ export interface XenApiVdi {
virtual_size: number
xenstore_data: Record<string, string>
}
export type XenApiVdiWrapped = WrapperXenApi<XenApiVdi, 'VDI'>
export type XenApiVdiWrapped = WrapperXenApi<XenApiVdi, 'VDI', XenApiVdiCallMethods>
export interface XenApiVbd {
$ref: Branded<'VBD'>

View File

@@ -1,4 +1,4 @@
import { Delete, Example, Get, Path, Query, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa'
import { Delete, Example, Get, Path, Put, Query, Request, Response, Route, Security, SuccessResponse, Tags } from 'tsoa'
import { inject } from 'inversify'
import { provide } from 'inversify-binding-decorators'
import type { Readable } from 'node:stream'
@@ -172,4 +172,28 @@ export class VdiSnapshotController extends XapiXoController<XoVdiSnapshot> {
const tasks = await this.getTasksForObject(id as XoVdiSnapshot['id'], { filter, limit })
return this.sendObjects(Object.values(tasks), req, 'tasks')
}
/**
* @example id "d2727772-735b-478f-b6f9-11e7db56dfd0"
* @example tag "from-rest-api"
*/
@Put('{id}/tags/{tag}')
@SuccessResponse(noContentResp.status, noContentResp.description)
@Response(notFoundResp.status, notFoundResp.description)
async putVdiSnapshotTag(@Path() id: string, @Path() tag: string): Promise<void> {
const vdiSnapshot = this.getXapiObject(id as XoVdiSnapshot['id'])
await vdiSnapshot.$call('add_tags', tag)
}
/**
* @example id "d2727772-735b-478f-b6f9-11e7db56dfd0"
* @example tag "from-rest-api"
*/
@Delete('{id}/tags/{tag}')
@SuccessResponse(noContentResp.status, noContentResp.description)
@Response(notFoundResp.status, notFoundResp.description)
async deleteVdiSnapshotTag(@Path() id: string, @Path() tag: string): Promise<void> {
const vdiSnapshot = this.getXapiObject(id as XoVdiSnapshot['id'])
await vdiSnapshot.$call('remove_tags', tag)
}
}

View File

@@ -46,6 +46,8 @@
- **removed** `DELETE /rest/v0/vbds/<vbd-id>/tags/:tag` (PR [#9090](https://github.com/vatesfr/xen-orchestra/pull/9090))
- **removed** `PUT /rest/v0/vifs/<vif-id>/tags/:tag` (PR [#9096](https://github.com/vatesfr/xen-orchestra/pull/9096))
- **removed** `DELETE /rest/v0/vifs/<vif-id>/tags/:tag` (PR [#9096](https://github.com/vatesfr/xen-orchestra/pull/9096))
- `PUT /rest/v0/vdi-snapshots/<vdi-snapshot-id>/tags/:tag` (PR [#9091](https://github.com/vatesfr/xen-orchestra/pull/9087))
- `DELETE /rest/v0/vdi-snapshots/<vdi-snapshot-id>/tags/:tag` (PR [#9091](https://github.com/vatesfr/xen-orchestra/pull/9091))
### Bug fixes

View File

@@ -355,6 +355,7 @@ export default class RestApi {
alarms: true,
messages: true,
tasks: true,
tags: true,
},
},
servers: {