feat(@xen-orchestra/rest-api): expose pools/:id/tags/:tag (#9088)

This commit is contained in:
MlssFrncJrg
2025-10-09 14:40:04 +02:00
committed by GitHub
parent 1d8ae5eea8
commit 8a70196fa9
4 changed files with 32 additions and 1 deletions

View File

@@ -167,6 +167,8 @@ export interface XenApiEvent {
timestamp?: string
}
type XenApiPoolCallMethods = TagCallMethods & {}
export interface XenApiPool {
$ref: Branded<'pool'>
allowed_operations: POOL_ALLOWED_OPERATIONS[]
@@ -229,7 +231,7 @@ export interface XenApiPool {
/** @deprecated */
wlb_verify_cert?: boolean
}
export type XenApiPoolWrapped = WrapperXenApi<XenApiPool, 'pool'>
export type XenApiPoolWrapped = WrapperXenApi<XenApiPool, 'pool', XenApiPoolCallMethods>
/** @deprecated */
export interface XenApiPoolPatch {

View File

@@ -12,6 +12,8 @@ import {
Middlewares,
Body,
SuccessResponse,
Put,
Delete,
} from 'tsoa'
import { inject } from 'inversify'
import { PassThrough } from 'node:stream'
@@ -433,4 +435,28 @@ export class PoolController extends XapiXoController<XoPool> {
return this.sendObjects(Object.values(messages), req, 'messages')
}
/**
* @example id "355ee47d-ff4c-4924-3db2-fd86ae629676"
* @example tag "from-rest-api"
*/
@Put('{id}/tags/{tag}')
@SuccessResponse(noContentResp.status, noContentResp.description)
@Response(notFoundResp.status, notFoundResp.description)
async putPoolTag(@Path() id: string, @Path() tag: string): Promise<void> {
const pool = this.getXapiObject(id as XoPool['id'])
await pool.$call('add_tags', tag)
}
/**
* @example id "355ee47d-ff4c-4924-3db2-fd86ae629676"
* @example tag "from-rest-api"
*/
@Delete('{id}/tags/{tag}')
@SuccessResponse(noContentResp.status, noContentResp.description)
@Response(notFoundResp.status, notFoundResp.description)
async deletePoolTag(@Path() id: string, @Path() tag: string): Promise<void> {
const pool = this.getXapiObject(id as XoPool['id'])
await pool.$call('remove_tags', tag)
}
}

View File

@@ -35,6 +35,8 @@
- `DELETE /rest/v0/hosts/<host-id>/tags/:tag` (PR [#9037](https://github.com/vatesfr/xen-orchestra/pull/9037))
- `PUT /rest/v0/networks/<network-id>/tags/:tag` (PR [#9087](https://github.com/vatesfr/xen-orchestra/pull/9087))
- `DELETE /rest/v0/networks/<network-id>/tags/:tag` (PR [#9087](https://github.com/vatesfr/xen-orchestra/pull/9087))
- `PUT /rest/v0/pools/<pool-id>/tags/:tag` (PR [#9088](https://github.com/vatesfr/xen-orchestra/pull/9088))
- `DELETE /rest/v0/pools/<pool-id>/tags/:tag` (PR [#9088](https://github.com/vatesfr/xen-orchestra/pull/9088))
### Bug fixes

View File

@@ -252,6 +252,7 @@ export default class RestApi {
alarms: true,
missing_patches: true,
messages: true,
tags: true,
},
},
groups: {