feat(@xen-orchestra/rest-api): expose create network

This commit is contained in:
mathieuRA
2025-06-04 11:03:01 +02:00
committed by Florent BEAUCHAMP
parent d47fa03ec8
commit 94db22f7b0
11 changed files with 127 additions and 11 deletions

View File

@@ -5,4 +5,8 @@ import tseslint from 'typescript-eslint'
export default tseslint.config(eslint.configs.recommended, tseslint.configs.recommended, {
ignores: ['dist'],
rules: {
// Allow empty interface for recursive generic typing (E.g. interface XenApiNetworkWrapped)
'@typescript-eslint/no-empty-object-type': 'off',
},
})

View File

@@ -64,6 +64,7 @@ import type {
VTPM_OPERATIONS,
VUSB_OPERATIONS,
} from './common.mjs'
import type { XoPif } from './xo.mjs'
// types automatically generated by the @ByScripts script.
// https://github.com/vatesfr/xen-orchestra/tree/wip-xapi-types-generator/%40xen-orchestra/xapi-generator
@@ -87,6 +88,23 @@ type WrapperXenApi<T, Type extends string, Fn = { (): void }> = T & {
call: <ReturnType>(...args: unknown[]) => Promise<ReturnType>
callAsync: <ReturnType>(...args: unknown[]) => Promise<ReturnType>
getField<T extends XenApiRecord, K extends keyof T>(type: Type, ref: T['$ref'], field: K): Promise<T[K]>
createNetwork(
params:
| {
name: string
description?: string
mtu?: number
}
| {
name: string
description?: string
pifId: XoPif['id']
mtu?: number
/* between 0 and 4094 */
vlan: number
}
): Promise<XenApiNetworkWrapped>
}
}
@@ -632,6 +650,7 @@ export interface XenApiNetwork {
uuid: string
VIFs: XenApiVif['$ref'][]
}
export interface XenApiNetworkWrapped extends WrapperXenApi<XenApiNetwork, 'network'> {}
export interface XenApiVif {
$ref: Branded<'VIF'>
@@ -1348,6 +1367,7 @@ export type XenApiRecord =
export type WrappedXenApiRecord =
| XenApiHostWrapped
| XenApiNetworkWrapped
| XenApiPifWrapped
| XenApiPoolWrapped
| XenApiSrWrapped