Added missing relations to server db model. Started with server crud. Removed unused relations from detail responses

This commit is contained in:
2024-12-17 22:52:09 +01:00
parent 747712c5c4
commit a34a3ba8b4
20 changed files with 1131 additions and 40 deletions

View File

@@ -0,0 +1,35 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Http.Requests.Admin.Servers;
public class CreateServerRequest
{
[Required(ErrorMessage = "You need to provide a name for the server")]
public string Name { get; set; }
public int OwnerId { get; set; }
[Range(1, int.MaxValue, ErrorMessage = "You need to provide a valid cpu percent amount")]
public int Cpu { get; set; }
[Range(1, int.MaxValue, ErrorMessage = "You need to provide a valid memory amount")]
public int Memory { get; set; }
[Range(1, int.MaxValue, ErrorMessage = "You need to provide a valid disk amount")]
public int Disk { get; set; }
public bool UseVirtualDisk { get; set; }
[Range(0, int.MaxValue, ErrorMessage = "You need to provide a valid bandwidth amount")]
public int Bandwidth { get; set; }
public string? StartupOverride { get; set; }
public int DockerImageIndex { get; set; }
public int StarId { get; set; }
public int NodeId { get; set; }
public int[] AllocationIds { get; set; } = [];
public Dictionary<string, string> Variables { get; set; } = new();
}

View File

@@ -0,0 +1,35 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Http.Requests.Admin.Servers;
public class UpdateServerRequest
{
[Required(ErrorMessage = "You need to provide a name for the server")]
public string Name { get; set; }
public int OwnerId { get; set; }
[Range(1, int.MaxValue, ErrorMessage = "You need to provide a valid cpu percent amount")]
public int Cpu { get; set; }
[Range(1, int.MaxValue, ErrorMessage = "You need to provide a valid memory amount")]
public int Memory { get; set; }
[Range(1, int.MaxValue, ErrorMessage = "You need to provide a valid disk amount")]
public int Disk { get; set; }
public bool UseVirtualDisk { get; set; }
[Range(0, int.MaxValue, ErrorMessage = "You need to provide a valid bandwidth amount")]
public int Bandwidth { get; set; }
public string? StartupOverride { get; set; }
public int DockerImageIndex { get; set; }
public int StarId { get; set; }
public int NodeId { get; set; }
public int[] AllocationIds { get; set; } = [];
public Dictionary<string, string> Variables { get; set; } = new();
}

View File

@@ -5,9 +5,6 @@ namespace MoonlightServers.Shared.Http.Responses.Admin.Nodes;
public class NodeDetailResponse
{
public int Id { get; set; }
//public List<Server> Servers { get; set; } = new();
public NodeAllocationDetailResponse[] Allocations { get; set; }
public string Name { get; set; }

View File

@@ -0,0 +1,8 @@
namespace MoonlightServers.Shared.Http.Responses.Admin.ServerVariables;
public class ServerVariableDetailResponse
{
public int Id { get; set; }
public string Key { get; set; }
public string Value { get; set; }
}

View File

@@ -0,0 +1,25 @@
using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations;
using MoonlightServers.Shared.Http.Responses.Admin.ServerVariables;
namespace MoonlightServers.Shared.Http.Responses.Admin.Servers;
public class ServerDetailResponse
{
public int Id { get; set; }
public string Name { get; set; }
public int OwnerId { get; set; }
public int Cpu { get; set; }
public int Memory { get; set; }
public int Disk { get; set; }
public bool UseVirtualDisk { get; set; }
public int Bandwidth { get; set; }
public string? StartupOverride { get; set; }
public int DockerImageIndex { get; set; }
public int StarId { get; set; }
public int NodeId { get; set; }
}

View File

@@ -6,10 +6,6 @@ namespace MoonlightServers.Shared.Http.Responses.Admin.Stars;
public class StarDetailResponse
{
public int Id { get; set; }
// References
public StarVariableDetailResponse[] Variables { get; set; }
public StarDockerImageDetailResponse[] DockerImages { get; set; }
// Meta
public string Name { get; set; }