Started implementing star crud

This commit is contained in:
2024-12-05 17:27:17 +01:00
parent 3b77b3df1e
commit 291b80cc60
13 changed files with 342 additions and 79 deletions

View File

@@ -0,0 +1,45 @@
using System.ComponentModel.DataAnnotations;
namespace MoonlightServers.Shared.Http.Requests.Admin.Stars;
public class CreateStarRequest
{
[Required(ErrorMessage = "You need to specify a name")]
public string Name { get; set; }
[Required(ErrorMessage = "You need to specify a author")]
public string Author { get; set; }
public string? UpdateUrl { get; set; }
public string? DonateUrl { get; set; }
[Required(ErrorMessage = "You need to specify a startup command")]
public string StartupCommand { get; set; } = "echo Starting up :)";
[Required(ErrorMessage = "You need to specify a stop command")]
public string StopCommand { get; set; } = "^C";
[Required(ErrorMessage = "You need to specify a online detection string")]
public string OnlineDetection { get; set; }
[Required(ErrorMessage = "You need to specify an install shell")]
public string InstallShell { get; set; } = "/bin/bash";
[Required(ErrorMessage = "You need to specify an install docker image")]
[RegularExpression("^(?:(?=[^:\\/]{1,253})(?!-)[a-zA-Z0-9-]{1,63}(?<!-)(?:\\.(?!-)[a-zA-Z0-9-]{1,63}(?<!-))*(?::[0-9]{1,5})?\\/)?((?![._-])(?:[a-z0-9._-]*)(?<![._-])(?:\\/(?![._-])[a-z0-9._-]*(?<![._-]))*)(?::(?![.-])[a-zA-Z0-9_.-]{1,128})?$", ErrorMessage = "You need to specify a valid docker image")]
public string InstallDockerImage { get; set; } = "debian:latest";
[Required(ErrorMessage = "You need to specify an install script")]
public string InstallScript { get; set; } = "echo Installing...";
[Range(0, 20, ErrorMessage = "You need to provide a valid amount of allocations")]
public int RequiredAllocations { get; set; } = 1;
public bool AllowDockerImageChange { get; set; } = false;
[Required(ErrorMessage = "You need to provide parse configuration")]
public string ParseConfiguration { get; set; } = "[]";
}

View File

@@ -0,0 +1,6 @@
namespace MoonlightServers.Shared.Http.Requests.Admin.Stars;
public class UpdateStarRequest
{
}

View File

@@ -0,0 +1,10 @@
namespace MoonlightServers.Shared.Http.Responses.Admin.StarDockerImages;
public class StarDockerImageDetailResponse
{
public int Id { get; set; }
public string DisplayName { get; set; }
public string Identifier { get; set; }
public bool AutoPulling { get; set; }
}

View File

@@ -0,0 +1,20 @@
using MoonlightServers.Shared.Enums;
namespace MoonlightServers.Shared.Http.Responses.Admin.StarVariables;
public class StarVariableDetailResponse
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Key { get; set; }
public string DefaultValue { get; set; }
public bool AllowViewing { get; set; }
public bool AllowEditing { get; set; }
public StarVariableType Type { get; set; }
public string? Filter { get; set; }
}

View File

@@ -0,0 +1,34 @@
using MoonlightServers.Shared.Http.Responses.Admin.StarDockerImages;
using MoonlightServers.Shared.Http.Responses.Admin.StarVariables;
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; }
public string Author { get; set; }
public string? UpdateUrl { get; set; }
public string? DonateUrl { get; set; }
// Start and stop
public string StartupCommand { get; set; }
public string StopCommand { get; set; }
public string OnlineDetection { get; set; }
// Install
public string InstallShell { get; set; }
public string InstallDockerImage { get; set; }
public string InstallScript { get; set; }
// Misc
public int RequiredAllocations { get; set; }
public bool AllowDockerImageChange { get; set; }
public string ParseConfiguration { get; set; }
}

View File

@@ -1,6 +0,0 @@
namespace MoonlightServers.Shared.Http.Responses;
public class ExampleResponse
{
public int Number { get; set; }
}

View File

@@ -6,8 +6,4 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Http\Requests\"/>
</ItemGroup>
</Project>