diff --git a/src/Tgstation.Server.Api/Models/DreamDaemon.cs b/src/Tgstation.Server.Api/Models/DreamDaemon.cs index 6039fb4f34..b6fff22b40 100644 --- a/src/Tgstation.Server.Api/Models/DreamDaemon.cs +++ b/src/Tgstation.Server.Api/Models/DreamDaemon.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Api.Rights; namespace Tgstation.Server.Api.Models @@ -8,66 +9,21 @@ namespace Tgstation.Server.Api.Models /// Represents an instance of BYOND's DreamDaemon game server. Create action starts the server. Delete action shuts down the server /// [Model(RightsType.DreamDaemon, CanCrud = true, RequiresInstance = true)] - public sealed class DreamDaemon + public sealed class DreamDaemon : DreamDaemonSettings { - /// - /// When the live revision was compiled - /// - [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadRevision)] - public CompileJob CompileJob { get; set; } - - /// - /// If starts when it's starts - /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetAutoStart)] - public bool? AutoStart { get; set; } - /// /// The current status of /// [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadMetadata)] public DreamDaemonStatus? Status { get; set; } - /// - /// If the BYOND web client can be used to connect to the game server - /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetWebClient)] - public bool? AllowWebClient { get; set; } - - /// - /// If the server is undergoing a soft reset. This may be automatically set by changes to other fields - /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftRestart)] - public bool? SoftRestart { get; set; } - - /// - /// If the server is undergoing a soft shutdown - /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftShutdown)] - public bool? SoftShutdown { get; set; } - - /// - /// The level of - /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetSecurity)] - public DreamDaemonSecurity? SecurirtyLevel { get; set; } - - /// - /// The first port uses. This should be the publically advertised port - /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)] - public ushort? PrimaryPort { get; set; } - - /// - /// The second port uses - /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)] - public ushort? SecondaryPort { get; set; } + [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadMetadata)] + public DreamDaemonSecurity? CurrentSecurityLevel { get; set; } /// /// The port the running instance is set to /// [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadMetadata)] - public bool CurrentPort { get; set; } + public ushort? CurrentPort { get; set; } } } diff --git a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs new file mode 100644 index 0000000000..cdedd60a93 --- /dev/null +++ b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs @@ -0,0 +1,63 @@ +using System.ComponentModel.DataAnnotations; +using Tgstation.Server.Api.Rights; + +namespace Tgstation.Server.Api.Models.Internal +{ + public class DreamDaemonSettings + { + /// + /// When the live revision was compiled + /// + [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadRevision)] + public CompileJob CompileJob { get; set; } + + /// + /// If starts when it's starts + /// + [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetAutoStart)] + [Required] + public bool? AutoStart { get; set; } + + /// + /// If the BYOND web client can be used to connect to the game server + /// + [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetWebClient)] + [Required] + public bool? AllowWebClient { get; set; } + + /// + /// If the server is undergoing a soft reset. This may be automatically set by changes to other fields + /// + [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftRestart)] + [Required] + public bool? SoftRestart { get; set; } + + /// + /// If the server is undergoing a soft shutdown + /// + [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftShutdown)] + [Required] + public bool? SoftShutdown { get; set; } + + /// + /// The level of + /// + [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetSecurity)] + [Required] + public DreamDaemonSecurity? SecurityLevel { get; set; } + + /// + /// The first port uses. This should be the publically advertised port + /// + [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)] + [Required] + public ushort? PrimaryPort { get; set; } + + /// + /// The second port uses + /// + [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)] + [Required] + public ushort? SecondaryPort { get; set; } + } +} diff --git a/src/Tgstation.Server.Api/Models/Internal/Job.cs b/src/Tgstation.Server.Api/Models/Internal/Job.cs new file mode 100644 index 0000000000..387cfac884 --- /dev/null +++ b/src/Tgstation.Server.Api/Models/Internal/Job.cs @@ -0,0 +1,37 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace Tgstation.Server.Api.Models.Internal +{ + public class Job + { + /// + /// The ID + /// + public long Id { get; set; } + + /// + /// Human readable description of the + /// + [Required] + public string Description { get; set; } + + /// + /// When the was started + /// + [Required] + public DateTimeOffset StartedAt { get; set; } + + public User StartedBy { get; set; } + + /// + /// When the stopped + /// + public DateTimeOffset StoppedAt { get; set; } + + /// + /// If the was cancelled + /// + public bool Cancelled { get; set; } + } +} \ No newline at end of file diff --git a/src/Tgstation.Server.Api/Models/Job.cs b/src/Tgstation.Server.Api/Models/Job.cs index d0231963b4..e5c23eaa40 100644 --- a/src/Tgstation.Server.Api/Models/Job.cs +++ b/src/Tgstation.Server.Api/Models/Job.cs @@ -1,46 +1,19 @@ -using System; - -namespace Tgstation.Server.Api.Models +namespace Tgstation.Server.Api.Models { /// /// Represents a long running job on the server. Model is read-only, updates attempt to cancel the job /// [Model] - public sealed class Job + public sealed class Job : Internal.Job { - /// - /// The ID - /// - public long Id { get; set; } - - /// - /// Human readable description of the - /// - public string Description { get; set; } - - /// - /// When the was started - /// - public DateTimeOffset StartedAt { get; set; } - - /// - /// When the stopped - /// - public DateTimeOffset StoppedAt { get; set; } - - /// - /// If the was cancelled - /// - public bool Cancelled { get; set; } - /// /// If the has incremental progress, this will range from 1 - 100. 0 otherwise /// public int Progress { get; set; } /// - /// If the current user has permission to cancel the job. Will be if isn't + /// If the current user has permission to cancel the job /// - public bool? UserCanCancel { get; set; } + public bool UserCanCancel { get; set; } } } diff --git a/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs b/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs new file mode 100644 index 0000000000..9daccbbde5 --- /dev/null +++ b/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +namespace Tgstation.Server.Host.Models +{ + sealed class DreamDaemonSettings : Api.Models.Internal.DreamDaemonSettings + { + long Id { get; set; } + + int? ProcessId { get; set; } + + long InstanceId { get; set; } + + [Required] + Instance Instance { get; set; } + } +} diff --git a/src/Tgstation.Server.Host/Models/Instance.cs b/src/Tgstation.Server.Host/Models/Instance.cs index 174bf3d36f..859ceac3c2 100644 --- a/src/Tgstation.Server.Host/Models/Instance.cs +++ b/src/Tgstation.Server.Host/Models/Instance.cs @@ -21,6 +21,9 @@ namespace Tgstation.Server.Host.Models [Required] DreamMakerSettings DreamMakerSettings { get; set; } + [Required] + DreamDaemonSettings DreamDaemonSettings { get; set; } + /// /// The s in the /// diff --git a/src/Tgstation.Server.Host/Models/Job.cs b/src/Tgstation.Server.Host/Models/Job.cs new file mode 100644 index 0000000000..29c978ce2c --- /dev/null +++ b/src/Tgstation.Server.Host/Models/Job.cs @@ -0,0 +1,10 @@ +using System.ComponentModel.DataAnnotations; + +namespace Tgstation.Server.Host.Models +{ + sealed class Job : Api.Models.Internal.Job + { + [Required] + new public User StartedBy { get; set; } + } +}