Re-organised statistic endpoints and services/helpers
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MoonlightServers.Daemon.Services;
|
||||
using MoonlightServers.DaemonShared.Http.Responses.Statistics;
|
||||
|
||||
namespace MoonlightServers.Daemon.Http.Controllers.Statistics;
|
||||
|
||||
// This controller hosts endpoints for the statistics for the docker environment
|
||||
|
||||
[ApiController]
|
||||
[Route("api/statistics/docker")]
|
||||
public class StatisticsDockerController : Controller
|
||||
{
|
||||
private readonly DockerInfoService DockerInfoService;
|
||||
|
||||
public StatisticsDockerController(DockerInfoService dockerInfoService)
|
||||
{
|
||||
DockerInfoService = dockerInfoService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<StatisticsDockerResponse> Get()
|
||||
{
|
||||
var usage = await DockerInfoService.GetDataUsage();
|
||||
|
||||
return new StatisticsDockerResponse
|
||||
{
|
||||
Version = await DockerInfoService.GetDockerVersion(),
|
||||
ContainersReclaimable = usage.Containers.Reclaimable,
|
||||
ContainersUsed = usage.Containers.Used,
|
||||
BuildCacheReclaimable = usage.BuildCache.Reclaimable,
|
||||
BuildCacheUsed = usage.BuildCache.Used,
|
||||
ImagesUsed = usage.Images.Used,
|
||||
ImagesReclaimable = usage.Images.Reclaimable
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user