Updated to latest moonlight and mooncore version. Done refactoring to async scheme and other changes. Recreated database migrations and cleaned models

This commit is contained in:
2025-09-22 12:13:57 +02:00
parent 91fb15a03e
commit 85392208c4
150 changed files with 2722 additions and 2726 deletions

View File

@@ -15,19 +15,19 @@ public class NodeService
HttpApiClient = httpApiClient;
}
public async Task<NodeSystemStatusResponse> GetSystemStatus(int nodeId)
public async Task<NodeSystemStatusResponse> GetSystemStatusAsync(int nodeId)
{
return await HttpApiClient.GetJson<NodeSystemStatusResponse>($"api/admin/servers/nodes/{nodeId}/system/status");
}
public async Task<StatisticsResponse> GetStatistics(int nodeId)
public async Task<StatisticsResponse> GetStatisticsAsync(int nodeId)
{
return await HttpApiClient.GetJson<StatisticsResponse>(
$"api/admin/servers/nodes/{nodeId}/statistics"
);
}
public async Task<DockerStatisticsResponse> GetDockerStatistics(int nodeId)
public async Task<DockerStatisticsResponse> GetDockerStatisticsAsync(int nodeId)
{
return await HttpApiClient.GetJson<DockerStatisticsResponse>(
$"api/admin/servers/nodes/{nodeId}/statistics/docker"

View File

@@ -1,4 +1,3 @@
using System.Net;
using MoonCore.Attributes;
using MoonCore.Helpers;
using MoonlightServers.Shared.Http.Requests.Client.Servers.Files;
@@ -16,56 +15,56 @@ public class ServerFileSystemService
ApiClient = apiClient;
}
public async Task<ServerFilesEntryResponse[]> List(int serverId, string path)
public async Task<ServerFilesEntryResponse[]> ListAsync(int serverId, string path)
{
return await ApiClient.GetJson<ServerFilesEntryResponse[]>(
$"api/client/servers/{serverId}/files/list?path={path}"
);
}
public async Task Move(int serverId, string oldPath, string newPath)
public async Task MoveAsync(int serverId, string oldPath, string newPath)
{
await ApiClient.Post(
$"api/client/servers/{serverId}/files/move?oldPath={oldPath}&newPath={newPath}"
);
}
public async Task Delete(int serverId, string path)
public async Task DeleteAsync(int serverId, string path)
{
await ApiClient.Delete(
$"api/client/servers/{serverId}/files/delete?path={path}"
);
}
public async Task Mkdir(int serverId, string path)
public async Task MkdirAsync(int serverId, string path)
{
await ApiClient.Post(
$"api/client/servers/{serverId}/files/mkdir?path={path}"
);
}
public async Task Touch(int serverId, string path)
public async Task TouchAsync(int serverId, string path)
{
await ApiClient.Post(
$"api/client/servers/{serverId}/files/touch?path={path}"
);
}
public async Task<ServerFilesUploadResponse> Upload(int serverId)
public async Task<ServerFilesUploadResponse> UploadAsync(int serverId)
{
return await ApiClient.GetJson<ServerFilesUploadResponse>(
$"api/client/servers/{serverId}/files/upload"
);
}
public async Task<ServerFilesDownloadResponse> Download(int serverId, string path)
public async Task<ServerFilesDownloadResponse> DownloadAsync(int serverId, string path)
{
return await ApiClient.GetJson<ServerFilesDownloadResponse>(
$"api/client/servers/{serverId}/files/download?path={path}"
);
}
public async Task Compress(int serverId, string type, string[] items, string destination)
public async Task CompressAsync(int serverId, string type, string[] items, string destination)
{
await ApiClient.Post(
$"api/client/servers/{serverId}/files/compress",
@@ -78,7 +77,7 @@ public class ServerFileSystemService
);
}
public async Task Decompress(int serverId, string type, string path, string destination)
public async Task DecompressAsync(int serverId, string type, string path, string destination)
{
await ApiClient.Post(
$"api/client/servers/{serverId}/files/decompress",

View File

@@ -18,49 +18,49 @@ public class ServerService
HttpApiClient = httpApiClient;
}
public async Task<PagedData<ServerDetailResponse>> GetServers(int page, int perPage)
public async Task<CountedData<ServerDetailResponse>> GetServersAsync(int startIndex, int count)
{
return await HttpApiClient.GetJson<PagedData<ServerDetailResponse>>(
$"api/client/servers?page={page}&pageSize={perPage}"
return await HttpApiClient.GetJson<CountedData<ServerDetailResponse>>(
$"api/client/servers?startIndex={startIndex}&count={count}"
);
}
public async Task<PagedData<ServerDetailResponse>> GetSharedServers(int page, int perPage)
public async Task<CountedData<ServerDetailResponse>> GetSharedServersAsync(int startIndex, int count)
{
return await HttpApiClient.GetJson<PagedData<ServerDetailResponse>>(
$"api/client/servers/shared?page={page}&pageSize={perPage}"
return await HttpApiClient.GetJson<CountedData<ServerDetailResponse>>(
$"api/client/servers/shared?startIndex={startIndex}&count={count}"
);
}
public async Task<ServerDetailResponse> GetServer(int serverId)
public async Task<ServerDetailResponse> GetServerAsync(int serverId)
{
return await HttpApiClient.GetJson<ServerDetailResponse>(
$"api/client/servers/{serverId}"
);
}
public async Task<ServerStatusResponse> GetStatus(int serverId)
public async Task<ServerStatusResponse> GetStatusAsync(int serverId)
{
return await HttpApiClient.GetJson<ServerStatusResponse>(
$"api/client/servers/{serverId}/status"
);
}
public async Task<ServerLogsResponse> GetLogs(int serverId)
public async Task<ServerLogsResponse> GetLogsAsync(int serverId)
{
return await HttpApiClient.GetJson<ServerLogsResponse>(
$"api/client/servers/{serverId}/logs"
);
}
public async Task<ServerStatsResponse> GetStats(int serverId)
public async Task<ServerStatsResponse> GetStatsAsync(int serverId)
{
return await HttpApiClient.GetJson<ServerStatsResponse>(
$"api/client/servers/{serverId}/stats"
);
}
public async Task RunCommand(int serverId, string command)
public async Task RunCommandAsync(int serverId, string command)
{
await HttpApiClient.Post(
$"api/client/servers/{serverId}/command",
@@ -71,14 +71,14 @@ public class ServerService
);
}
public async Task<ServerWebSocketResponse> GetWebSocket(int serverId)
public async Task<ServerWebSocketResponse> GetWebSocketAsync(int serverId)
{
return await HttpApiClient.GetJson<ServerWebSocketResponse>(
$"api/client/servers/{serverId}/ws"
);
}
public async Task Install(int serverId)
public async Task InstallAsync(int serverId)
{
await HttpApiClient.Post(
$"api/client/servers/{serverId}/install"
@@ -87,21 +87,21 @@ public class ServerService
#region Power actions
public async Task Start(int serverId)
public async Task StartAsync(int serverId)
{
await HttpApiClient.Post(
$"api/client/servers/{serverId}/start"
);
}
public async Task Stop(int serverId)
public async Task StopAsync(int serverId)
{
await HttpApiClient.Post(
$"api/client/servers/{serverId}/stop"
);
}
public async Task Kill(int serverId)
public async Task KillAsync(int serverId)
{
await HttpApiClient.Post(
$"api/client/servers/{serverId}/kill"
@@ -112,14 +112,14 @@ public class ServerService
#region Variables
public async Task<PagedData<ServerVariableDetailResponse>> GetVariables(int serverId, int page, int pageSize)
public async Task<CountedData<ServerVariableDetailResponse>> GetVariablesAsync(int serverId, int startIndex, int count)
{
return await HttpApiClient.GetJson<PagedData<ServerVariableDetailResponse>>(
$"api/client/servers/{serverId}/variables?page={page}&pageSize={pageSize}"
return await HttpApiClient.GetJson<CountedData<ServerVariableDetailResponse>>(
$"api/client/servers/{serverId}/variables?startIndex={startIndex}&count={count}"
);
}
public async Task UpdateVariables(int serverId, UpdateServerVariableRangeRequest request)
public async Task UpdateVariablesAsync(int serverId, UpdateServerVariableRangeRequest request)
{
await HttpApiClient.Patch(
$"api/client/servers/{serverId}/variables",
@@ -127,7 +127,7 @@ public class ServerService
);
}
public async Task UpdateVariable(int serverId, UpdateServerVariableRequest request)
public async Task UpdateVariableAsync(int serverId, UpdateServerVariableRequest request)
{
await HttpApiClient.Put(
$"api/client/servers/{serverId}/variables",

View File

@@ -16,19 +16,19 @@ public class ServerShareService
ApiClient = apiClient;
}
public async Task<PagedData<ServerShareResponse>> Get(int id, int page, int pageSize)
=> await ApiClient.GetJson<PagedData<ServerShareResponse>>(
$"api/client/servers/{id}/shares?page={page}&pageSize={pageSize}");
public async Task<CountedData<ServerShareResponse>> GetAsync(int id, int startIndex, int count)
=> await ApiClient.GetJson<CountedData<ServerShareResponse>>(
$"api/client/servers/{id}/shares?startIndex={startIndex}&count={count}");
public async Task<ServerShareResponse> Get(int id, int shareId)
public async Task<ServerShareResponse> GetAsync(int id, int shareId)
=> await ApiClient.GetJson<ServerShareResponse>($"api/client/servers/{id}/shares/{shareId}");
public async Task<ServerShareResponse> Create(int id, CreateShareRequest request)
public async Task<ServerShareResponse> CreateAsync(int id, CreateShareRequest request)
=> await ApiClient.PostJson<ServerShareResponse>($"api/client/servers/{id}/shares", request);
public async Task<ServerShareResponse> Update(int id, int shareId, UpdateShareRequest request)
public async Task<ServerShareResponse> UpdateAsync(int id, int shareId, UpdateShareRequest request)
=> await ApiClient.PatchJson<ServerShareResponse>($"api/client/servers/{id}/shares/{shareId}", request);
public async Task Delete(int id, int shareId)
public async Task DeleteAsync(int id, int shareId)
=> await ApiClient.Delete($"api/client/servers/{id}/shares/{shareId}");
}