Add new endpoint for the agent status

This commit is contained in:
2025-07-30 22:36:49 +07:00
parent 4b0da0e864
commit c454e87d7a
6 changed files with 174 additions and 0 deletions

View File

@@ -902,6 +902,32 @@ public class DataController : ControllerBase
return Ok(response);
}
/// <summary>
/// Retrieves an array of agent names and their statuses
/// </summary>
/// <returns>An array of agent status information</returns>
[HttpGet("GetAgentStatuses")]
public async Task<ActionResult<List<AgentStatusResponse>>> GetAgentStatuses()
{
const string cacheKey = "AgentStatuses";
// Check if the agent statuses are already cached
var cachedStatuses = _cacheService.GetValue<List<AgentStatusResponse>>(cacheKey);
if (cachedStatuses != null)
{
return Ok(cachedStatuses);
}
// Get all agent statuses
var agentStatuses = await _mediator.Send(new GetAgentStatusesCommand());
// Cache the results for 2 minutes
_cacheService.SaveValue(cacheKey, agentStatuses, TimeSpan.FromMinutes(2));
return Ok(agentStatuses);
}
/// <summary>
/// Maps a ScenarioRequest to a domain Scenario object.
/// </summary>