feat: add one pull plug and play feature
This commit is contained in:
@ -58,6 +58,21 @@ async function apiFetch(input: string, init: RequestInit = {}): Promise<Response
|
||||
return r;
|
||||
}
|
||||
|
||||
export async function createAgentToken(hostname: string): Promise<{ agent_id: string; token: string }> {
|
||||
const r = await apiFetch(`${BASE}/agents/token`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ hostname }),
|
||||
});
|
||||
if (!r.ok) throw new Error(`create token: ${r.status}`);
|
||||
return r.json();
|
||||
}
|
||||
|
||||
export async function deleteAgent(id: string): Promise<void> {
|
||||
const r = await apiFetch(`${BASE}/agents/${id}`, { method: "DELETE" });
|
||||
if (!r.ok) throw new Error(`delete agent: ${r.status}`);
|
||||
}
|
||||
|
||||
export async function fetchAgents(): Promise<Agent[]> {
|
||||
const r = await apiFetch(`${BASE}/agents`);
|
||||
if (!r.ok) throw new Error(`agents: ${r.status}`);
|
||||
|
||||
Reference in New Issue
Block a user