nickname
This commit is contained in:
1 parent
8948171ae7
commit
f034fc5afd
11 files changed
+303
-18
No files matched your search
+25
-1
@@ -1,4 +1,8 @@
|
||||
export type Agent = { agent_id: string; connected: boolean };
|
||||
export type Agent = {
|
||||
agent_id: string;
|
||||
connected: boolean;
|
||||
nickname?: string | null;
|
||||
};
|
||||
|
||||
export type Alert = {
|
||||
alert_id: string;
|
||||
@@ -62,6 +66,12 @@ export type RevokeAgentResponse = {
|
||||
revoked: boolean;
|
||||
};
|
||||
|
||||
export type SetAgentNicknameResponse = {
|
||||
agent_id: string;
|
||||
nickname: string | null;
|
||||
updated: boolean;
|
||||
};
|
||||
|
||||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const res = await fetch(path, {
|
||||
...init,
|
||||
@@ -134,6 +144,20 @@ export function revokeAgent(agentId: string): Promise<RevokeAgentResponse> {
|
||||
);
|
||||
}
|
||||
|
||||
export function setAgentNickname(
|
||||
agentId: string,
|
||||
nickname: string | null,
|
||||
): Promise<SetAgentNicknameResponse> {
|
||||
const normalized = nickname?.trim() ?? "";
|
||||
return request<SetAgentNicknameResponse>(
|
||||
`/api/v1/control/agents/${encodeURIComponent(agentId)}/nickname`,
|
||||
{
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({ nickname: normalized ? normalized : null }),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function runCommand(
|
||||
agentId: string,
|
||||
kind: CommandKind,
|
||||
|
||||
Reference in new issue
Block a user