export type VolumeLabelDef = {volume: string, pool: string, storage?: string | undefined, slot?: number | undefined, drive?: number | undefined}; export type CreateApiControlVolumesArgs = {body: VolumeLabelDef}; export type CreateApiControlVolumesOptions = {baseUrl: string, OAuth2PasswordBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Label Volume * * POST /control/volumes */ export const createApiControlVolumes = async (args: CreateApiControlVolumesArgs, options: CreateApiControlVolumesOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2PasswordBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (OAuth2PasswordBearer !== undefined) headers.set('authorization', `Bearer ${OAuth2PasswordBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/control/volumes${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };