feat: view and edit server tags

This commit is contained in:
2026-08-04 13:38:42 +01:00
parent d1b3cd2f74
commit fa1fd14ed1
3 changed files with 145 additions and 2 deletions
+16 -2
View File
@@ -32,6 +32,7 @@ export interface Server {
updates_checked_at?: string;
console_protocols?: string[];
inventory?: Inventory;
tags?: Record<string, string>;
}
export type MonitorType = "http" | "tcp" | "icmp" | "tls";
@@ -248,6 +249,7 @@ export interface Workflow {
workflow_id: string;
name: string;
target_server_ids: string[];
target_tags?: Record<string, string>;
steps: WorkflowStepRef[];
}
@@ -539,8 +541,20 @@ export const api = {
return request<{ acknowledged: boolean }>(`/auth/providers/${id}/ack-notice`, { method: "POST" });
},
listServers(): Promise<Server[]> {
return request<Server[]>("/servers");
listServers(tags?: Record<string, string>): Promise<Server[]> {
const params = Object.entries(tags ?? {}).map(([k, v]) => `tag=${encodeURIComponent(`${k}:${v}`)}`);
return request<Server[]>(`/servers${params.length ? `?${params.join("&")}` : ""}`);
},
listKnownTags(): Promise<Record<string, string[]>> {
return request<Record<string, string[]>>("/servers/tags");
},
setServerTags(serverId: string, tags: Record<string, string>): Promise<{ tags: Record<string, string> }> {
return request<{ tags: Record<string, string> }>(`/servers/${serverId}/tags`, {
method: "PUT",
body: JSON.stringify({ tags }),
});
},
getServer(serverId: string): Promise<ServerWithKeys> {