import api from "./client"; import type { HostPathResult, PruneStatus, VolumeInfo } from "@/types"; const base = "/api/volumes"; export const volumesApi = { list: () => api.get(base).then((r) => r.data), sizes: (force = false) => api .get>(`${base}/sizes`, { params: { force } }) .then((r) => r.data), remove: (name: string, force = false) => api.delete(`${base}/${name}?force=${force}`).then((r) => r.data), // Runs in the background on the server; poll pruneStatus() for progress. startPrune: (allUnused: boolean) => api .post(`${base}/prune`, null, { params: { all: allUnused, background: true }, }) .then((r) => r.data), pruneStatus: () => api.get(`${base}/prune-status`).then((r) => r.data), generateYaml: (spec: Record) => api .post<{ yaml: string }>("/api/volumes/generate-yaml", spec) .then((r) => r.data.yaml), hostPaths: (path: string, showHidden = false) => api .get( `/api/host/paths?path=${encodeURIComponent(path)}&show_hidden=${showHidden}` ) .then((r) => r.data), };