export type Topology = {[key: string]: string}; export type ClusterVolumeSpec = {Group?: string | undefined, AccessMode?: ({Scope?: ('single' | 'multi') | undefined, Sharing?: ('none' | 'readonly' | 'onewriter' | 'all') | undefined, MountVolume?: Record | undefined, Secrets?: (Array<{Key?: string | undefined, Secret?: string | undefined}>) | undefined, AccessibilityRequirements?: ({Requisite?: Array | undefined, Preferred?: Array | undefined}) | undefined, CapacityRange?: ({RequiredBytes?: number | undefined, LimitBytes?: number | undefined}) | undefined, Availability?: ('active' | 'pause' | 'drain') | undefined}) | undefined}; export type UpdateApiVolumesNameArgs = {name: string, version: number, body: {Spec?: ClusterVolumeSpec | undefined}}; export type UpdateApiVolumesNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * "Update a volume. Valid only for Swarm cluster volumes" * * * PUT /volumes/{name} */ export const updateApiVolumesName = async (args: UpdateApiVolumesNameArgs, options: UpdateApiVolumesNameOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.version != null) query.append("version", String(args.version)) const url = `${baseUrl.replace(/\/+$/, '')}/volumes/${encodeURIComponent(String(args.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 };