Add new endpoint for the agent status
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user