More model shennanigans

This commit is contained in:
Cyberboss
2018-04-07 13:05:39 -04:00
parent 394afb4b30
commit 970ace54a6
7 changed files with 138 additions and 80 deletions
+5 -49
View File
@@ -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
/// </summary>
[Model(RightsType.DreamDaemon, CanCrud = true, RequiresInstance = true)]
public sealed class DreamDaemon
public sealed class DreamDaemon : DreamDaemonSettings
{
/// <summary>
/// When the live revision was compiled
/// </summary>
[Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadRevision)]
public CompileJob CompileJob { get; set; }
/// <summary>
/// If <see cref="DreamDaemon"/> starts when it's <see cref="Instance"/> starts
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetAutoStart)]
public bool? AutoStart { get; set; }
/// <summary>
/// The current status of <see cref="DreamDaemon"/>
/// </summary>
[Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadMetadata)]
public DreamDaemonStatus? Status { get; set; }
/// <summary>
/// If the BYOND web client can be used to connect to the game server
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetWebClient)]
public bool? AllowWebClient { get; set; }
/// <summary>
/// If the server is undergoing a soft reset. This may be automatically set by changes to other fields
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftRestart)]
public bool? SoftRestart { get; set; }
/// <summary>
/// If the server is undergoing a soft shutdown
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftShutdown)]
public bool? SoftShutdown { get; set; }
/// <summary>
/// The <see cref="DreamDaemonSecurity"/> level of <see cref="DreamDaemon"/>
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetSecurity)]
public DreamDaemonSecurity? SecurirtyLevel { get; set; }
/// <summary>
/// The first port <see cref="DreamDaemon"/> uses. This should be the publically advertised port
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)]
public ushort? PrimaryPort { get; set; }
/// <summary>
/// The second port <see cref="DreamDaemon"/> uses
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)]
public ushort? SecondaryPort { get; set; }
[Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadMetadata)]
public DreamDaemonSecurity? CurrentSecurityLevel { get; set; }
/// <summary>
/// The port the running <see cref="DreamDaemon"/> instance is set to
/// </summary>
[Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadMetadata)]
public bool CurrentPort { get; set; }
public ushort? CurrentPort { get; set; }
}
}
@@ -0,0 +1,63 @@
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Api.Rights;
namespace Tgstation.Server.Api.Models.Internal
{
public class DreamDaemonSettings
{
/// <summary>
/// When the live revision was compiled
/// </summary>
[Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadRevision)]
public CompileJob CompileJob { get; set; }
/// <summary>
/// If <see cref="DreamDaemon"/> starts when it's <see cref="Instance"/> starts
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetAutoStart)]
[Required]
public bool? AutoStart { get; set; }
/// <summary>
/// If the BYOND web client can be used to connect to the game server
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetWebClient)]
[Required]
public bool? AllowWebClient { get; set; }
/// <summary>
/// If the server is undergoing a soft reset. This may be automatically set by changes to other fields
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftRestart)]
[Required]
public bool? SoftRestart { get; set; }
/// <summary>
/// If the server is undergoing a soft shutdown
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftShutdown)]
[Required]
public bool? SoftShutdown { get; set; }
/// <summary>
/// The <see cref="DreamDaemonSecurity"/> level of <see cref="DreamDaemon"/>
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetSecurity)]
[Required]
public DreamDaemonSecurity? SecurityLevel { get; set; }
/// <summary>
/// The first port <see cref="DreamDaemon"/> uses. This should be the publically advertised port
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)]
[Required]
public ushort? PrimaryPort { get; set; }
/// <summary>
/// The second port <see cref="DreamDaemon"/> uses
/// </summary>
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)]
[Required]
public ushort? SecondaryPort { get; set; }
}
}
@@ -0,0 +1,37 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models.Internal
{
public class Job
{
/// <summary>
/// The <see cref="Job"/> ID
/// </summary>
public long Id { get; set; }
/// <summary>
/// Human readable description of the <see cref="Job"/>
/// </summary>
[Required]
public string Description { get; set; }
/// <summary>
/// When the <see cref="Job"/> was started
/// </summary>
[Required]
public DateTimeOffset StartedAt { get; set; }
public User StartedBy { get; set; }
/// <summary>
/// When the <see cref="Job"/> stopped
/// </summary>
public DateTimeOffset StoppedAt { get; set; }
/// <summary>
/// If the <see cref="Job"/> was cancelled
/// </summary>
public bool Cancelled { get; set; }
}
}
+4 -31
View File
@@ -1,46 +1,19 @@
using System;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Represents a long running job on the server. Model is read-only, updates attempt to cancel the job
/// </summary>
[Model]
public sealed class Job
public sealed class Job : Internal.Job
{
/// <summary>
/// The <see cref="Job"/> ID
/// </summary>
public long Id { get; set; }
/// <summary>
/// Human readable description of the <see cref="Job"/>
/// </summary>
public string Description { get; set; }
/// <summary>
/// When the <see cref="Job"/> was started
/// </summary>
public DateTimeOffset StartedAt { get; set; }
/// <summary>
/// When the <see cref="Job"/> stopped
/// </summary>
public DateTimeOffset StoppedAt { get; set; }
/// <summary>
/// If the <see cref="Job"/> was cancelled
/// </summary>
public bool Cancelled { get; set; }
/// <summary>
/// If the <see cref="Job"/> has incremental progress, this will range from 1 - 100. 0 otherwise
/// </summary>
public int Progress { get; set; }
/// <summary>
/// If the current user has permission to cancel the job. Will be <see langword="null"/> if <see cref="StoppedAt"/> isn't
/// If the current user has permission to cancel the job
/// </summary>
public bool? UserCanCancel { get; set; }
public bool UserCanCancel { get; set; }
}
}
@@ -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; }
}
}
@@ -21,6 +21,9 @@ namespace Tgstation.Server.Host.Models
[Required]
DreamMakerSettings DreamMakerSettings { get; set; }
[Required]
DreamDaemonSettings DreamDaemonSettings { get; set; }
/// <summary>
/// The <see cref="InstanceUser"/>s in the <see cref="Instance"/>
/// </summary>
+10
View File
@@ -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; }
}
}