Added node server sync and delete sync. Cleaned up codebase and extracted calls to apis to services
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MoonCore.Exceptions;
|
||||
using MoonlightServers.Daemon.Enums;
|
||||
@@ -5,6 +6,7 @@ using MoonlightServers.Daemon.Services;
|
||||
|
||||
namespace MoonlightServers.Daemon.Http.Controllers.Servers;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/servers")]
|
||||
public class ServerPowerController : Controller
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MoonCore.Exceptions;
|
||||
using MoonlightServers.Daemon.Services;
|
||||
@@ -6,6 +7,7 @@ using MoonlightServers.DaemonShared.Enums;
|
||||
|
||||
namespace MoonlightServers.Daemon.Http.Controllers.Servers;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/servers")]
|
||||
public class ServersController : Controller
|
||||
@@ -17,18 +19,32 @@ public class ServersController : Controller
|
||||
ServerService = serverService;
|
||||
}
|
||||
|
||||
[HttpPost("{serverId:int}/sync")]
|
||||
public async Task Sync([FromRoute] int serverId)
|
||||
{
|
||||
await ServerService.Sync(serverId);
|
||||
}
|
||||
|
||||
[HttpDelete("{serverId:int}")]
|
||||
public async Task Delete([FromRoute] int serverId)
|
||||
{
|
||||
await ServerService.Delete(serverId);
|
||||
}
|
||||
|
||||
[HttpGet("{serverId:int}/status")]
|
||||
public async Task<ServerStatusResponse> GetStatus(int serverId)
|
||||
public Task<ServerStatusResponse> GetStatus([FromRoute] int serverId)
|
||||
{
|
||||
var server = ServerService.GetServer(serverId);
|
||||
|
||||
if (server == null)
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
|
||||
return new ServerStatusResponse()
|
||||
var result = new ServerStatusResponse()
|
||||
{
|
||||
State = (ServerState)server.State
|
||||
};
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
[HttpGet("{serverId:int}/logs")]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MoonlightServers.Daemon.Helpers;
|
||||
using MoonlightServers.DaemonShared.DaemonSide.Http.Responses.Statistics;
|
||||
@@ -6,6 +7,7 @@ namespace MoonlightServers.Daemon.Http.Controllers.Statistics;
|
||||
|
||||
// This controller hosts endpoints for the statistics for the daemon application itself
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/statistics/application")]
|
||||
public class StatisticsApplicationController : Controller
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MoonlightServers.Daemon.Services;
|
||||
using MoonlightServers.DaemonShared.DaemonSide.Http.Responses.Statistics;
|
||||
@@ -6,6 +7,7 @@ namespace MoonlightServers.Daemon.Http.Controllers.Statistics;
|
||||
|
||||
// This controller hosts endpoints for the statistics for the docker environment
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/statistics/docker")]
|
||||
public class StatisticsDockerController : Controller
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MoonlightServers.Daemon.Helpers;
|
||||
using MoonlightServers.DaemonShared.DaemonSide.Http.Responses.Statistics;
|
||||
@@ -6,6 +7,7 @@ namespace MoonlightServers.Daemon.Http.Controllers.Statistics;
|
||||
|
||||
// This controller hosts endpoints for the statistics for host system the daemon runs on
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/statistics/host")]
|
||||
public class StatisticsHostController : Controller
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MoonlightServers.Daemon.Services;
|
||||
using MoonlightServers.DaemonShared.DaemonSide.Http.Responses.Sys;
|
||||
|
||||
namespace MoonlightServers.Daemon.Http.Controllers.Sys;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/system/status")]
|
||||
public class SystemStatusController : Controller
|
||||
|
||||
Reference in New Issue
Block a user