add labels

This commit is contained in:
Jicheng Lu 2025-01-31 10:26:16 -06:00
parent 1acee2b5b6
commit 6dba5cdd65

View file

@ -160,4 +160,20 @@ public class AgentController : ControllerBase
}
return utilities.Where(x => !string.IsNullOrWhiteSpace(x.Name)).OrderBy(x => x.Name).ToList();
}
[HttpGet("/agent/labels")]
public async Task<IEnumerable<string>> GetAgentLabels()
{
var agentService = _services.GetRequiredService<IAgentService>();
var agents = await agentService.GetAgents(new AgentFilter
{
Pager = new Pagination { Size = 1000 }
});
var labels = agents.Items?.SelectMany(x => x.Labels)
.Distinct()
.OrderBy(x => x)
.ToList() ?? [];
return labels;
}
}