export type BareosFlag = 'yes' | 'no'; export type VolumeRelabelDef = {volume: string, storage: string, pool: string, encrypt?: BareosFlag | undefined}; export type UpdateApiControlVolumesVolumeNameArgs = {volume_name: string, body: VolumeRelabelDef}; export type UpdateApiControlVolumesVolumeNameOptions = {baseUrl: string, OAuth2PasswordBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Relabel Volume * * PUT /control/volumes/{volume_name} */ export const updateApiControlVolumesVolumeName = async (args: UpdateApiControlVolumesVolumeNameArgs, options: UpdateApiControlVolumesVolumeNameOptions) => { 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/${encodeURIComponent(String(args.volume_name))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };