feat: add volume, images and networks
This commit is contained in:
@ -118,6 +118,71 @@ export async function containerAction(
|
||||
return r.json();
|
||||
}
|
||||
|
||||
export interface ImageEntry {
|
||||
agent_id: string;
|
||||
hostname: string;
|
||||
alias: string;
|
||||
id: string;
|
||||
tags: string[];
|
||||
size: number;
|
||||
created_at: number;
|
||||
}
|
||||
|
||||
export interface VolumeEntry {
|
||||
agent_id: string;
|
||||
hostname: string;
|
||||
alias: string;
|
||||
name: string;
|
||||
driver: string;
|
||||
mountpoint: string;
|
||||
}
|
||||
|
||||
export interface NetworkEntry {
|
||||
agent_id: string;
|
||||
hostname: string;
|
||||
alias: string;
|
||||
id: string;
|
||||
name: string;
|
||||
driver: string;
|
||||
scope: string;
|
||||
}
|
||||
|
||||
export async function fetchImages(): Promise<ImageEntry[]> {
|
||||
const ac = new AbortController();
|
||||
const t = setTimeout(() => ac.abort(), 8000);
|
||||
try {
|
||||
const r = await apiFetch(`${BASE}/images`, { signal: ac.signal });
|
||||
if (!r.ok) throw new Error(`images: ${r.status}`);
|
||||
return r.json();
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchVolumes(): Promise<VolumeEntry[]> {
|
||||
const ac = new AbortController();
|
||||
const t = setTimeout(() => ac.abort(), 8000);
|
||||
try {
|
||||
const r = await apiFetch(`${BASE}/volumes`, { signal: ac.signal });
|
||||
if (!r.ok) throw new Error(`volumes: ${r.status}`);
|
||||
return r.json();
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchNetworks(): Promise<NetworkEntry[]> {
|
||||
const ac = new AbortController();
|
||||
const t = setTimeout(() => ac.abort(), 8000);
|
||||
try {
|
||||
const r = await apiFetch(`${BASE}/networks`, { signal: ac.signal });
|
||||
if (!r.ok) throw new Error(`networks: ${r.status}`);
|
||||
return r.json();
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
export function connectLogs(
|
||||
agentId: string,
|
||||
containerId: string,
|
||||
|
||||
Reference in New Issue
Block a user