Merge pull request #1225 from tgstation/FixSetupWizardSwarm

Redoing request/response models to cleanup swagger nullability
This commit is contained in:
Jordan Brown
2021-02-11 13:57:31 -05:00
committed by GitHub
241 changed files with 5482 additions and 1899 deletions
+4 -4
View File
@@ -3,14 +3,14 @@
<!-- Integration tests will ensure they match across the board -->
<Import Project="ControlPanelVersion.props" />
<PropertyGroup>
<TgsCoreVersion>4.9.2</TgsCoreVersion>
<TgsCoreVersion>4.10.0</TgsCoreVersion>
<TgsConfigVersion>3.0.0</TgsConfigVersion>
<TgsApiVersion>8.3.0</TgsApiVersion>
<TgsClientVersion>9.2.0</TgsClientVersion>
<TgsApiVersion>9.0.0</TgsApiVersion>
<TgsApiLibraryVersion>9.0.0</TgsApiLibraryVersion>
<TgsClientVersion>10.0.0</TgsClientVersion>
<TgsDmapiVersion>6.0.2</TgsDmapiVersion>
<TgsInteropVersion>5.3.0</TgsInteropVersion>
<TgsHostWatchdogVersion>1.1.1</TgsHostWatchdogVersion>
<TgsContainerScriptVersion>1.2.0</TgsContainerScriptVersion>
</PropertyGroup>
</Project>
+2 -1
View File
@@ -9,6 +9,7 @@ using System.Net.Mime;
using System.Reflection;
using System.Text;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Properties;
namespace Tgstation.Server.Api
{
@@ -55,7 +56,7 @@ namespace Tgstation.Server.Api
/// <summary>
/// Get the version of the <see cref="Api"/> the caller is using
/// </summary>
public static readonly Version Version = AssemblyName.Version.Semver();
public static readonly Version Version = Version.Parse(ApiVersionAttribute.Instance.RawApiVersion);
/// <summary>
/// The instance <see cref="EntityId.Id"/> being accessed
@@ -0,0 +1,18 @@
namespace Tgstation.Server.Api
{
/// <summary>
/// Represents initial credentials used by the server.
/// </summary>
public static class DefaultCredentials
{
/// <summary>
/// The name of the default admin user
/// </summary>
public static readonly string AdminUserName = "Admin";
/// <summary>
/// The default admin password
/// </summary>
public static readonly string DefaultAdminUserPassword = "ISolemlySwearToDeleteTheDataDirectory";
}
}
-25
View File
@@ -1,25 +0,0 @@
using System;
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Represents a BYOND installation. <see cref="FileTicketResult.FileTicket"/> is used to upload custom BYOND version zip files, though <see cref="Version"/> must still be set.
/// </summary>
public sealed class Byond : FileTicketResult
{
/// <summary>
/// The <see cref="System.Version"/> of the <see cref="Byond"/> installation used for new compiles. Will be <see langword="null"/> if the user does not have permission to view it or there is no BYOND version installed. Only considers the <see cref="Version.Major"/> and <see cref="Version.Minor"/> numbers.
/// </summary>
public Version? Version { get; set; }
/// <summary>
/// The <see cref="Job"/> being used to install a new <see cref="Version"/>
/// </summary>
public Job? InstallJob { get; set; }
/// <summary>
/// If a custom BYOND version is to be uploaded.
/// </summary>
public bool? UploadCustomZip { get; set; }
}
}
@@ -11,12 +11,14 @@ namespace Tgstation.Server.Api.Models
/// The IRC channel name. Also potentially contains the channel passsword (if separated by a colon).
/// If multiple copies of the same channel with different keys are added to the server, the one that will be used is undefined.
/// </summary>
[ResponseOptions]
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
public string? IrcChannel { get; set; }
/// <summary>
/// The Discord channel ID
/// </summary>
[ResponseOptions]
public ulong? DiscordChannelId { get; set; }
/// <summary>
@@ -40,6 +42,7 @@ namespace Tgstation.Server.Api.Models
/// <summary>
/// A custom tag users can define to group channels together
/// </summary>
[ResponseOptions]
[StringLength(Limits.MaximumStringLength)]
public string? Tag { get; set; }
}
@@ -1,58 +0,0 @@
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Represents an instance of BYOND's DreamDaemon game server. Create action starts the server. Delete action shuts down the server
/// </summary>
public sealed class DreamDaemon : DreamDaemonSettings
{
/// <summary>
/// The live revision
/// </summary>
public CompileJob? ActiveCompileJob { get; set; }
/// <summary>
/// The next revision to go live
/// </summary>
public CompileJob? StagedCompileJob { get; set; }
/// <summary>
/// The current <see cref="WatchdogStatus"/>.
/// </summary>
[EnumDataType(typeof(WatchdogStatus))]
public WatchdogStatus? Status { get; set; }
/// <summary>
/// The current <see cref="DreamDaemonSecurity"/> of <see cref="DreamDaemon"/>. May be downgraded due to requirements of <see cref="ActiveCompileJob"/>
/// </summary>
[EnumDataType(typeof(DreamDaemonSecurity))]
public DreamDaemonSecurity? CurrentSecurity { get; set; }
/// <summary>
/// The port the running <see cref="DreamDaemon"/> instance is set to
/// </summary>
public ushort? CurrentPort { get; set; }
/// <summary>
/// The webclient status the running <see cref="DreamDaemon"/> instance is set to
/// </summary>
public bool? CurrentAllowWebclient { get; set; }
/// <summary>
/// If the server is undergoing a soft reset. This may be automatically set by changes to other fields
/// </summary>
public bool? SoftRestart { get; set; }
/// <summary>
/// If the server is undergoing a soft shutdown
/// </summary>
public bool? SoftShutdown { get; set; }
/// <summary>
/// If a dump of the active DreamDaemon executable should be created.
/// </summary>
public bool? CreateDump { get; set; }
}
}
+5 -3
View File
@@ -1,13 +1,15 @@
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Common base of <see cref="Instance"/>s, <see cref="CompileJob"/>s, and <see cref="Job"/>s.
/// Common base of entities with IDs.
/// </summary>
public class EntityId
{
/// <summary>
/// The ID of the entity.
/// </summary>
public long Id { get; set; }
[RequestOptions(FieldPresence.Required)]
[RequestOptions(FieldPresence.Ignored, PutOnly = true)]
public virtual long? Id { get; set; }
}
}
+48 -45
View File
@@ -4,7 +4,7 @@ using System.ComponentModel;
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Types of <see cref="ErrorMessage"/>s that the API may return.
/// Types of <see cref="Response.ErrorMessageResponse"/>s that the API may return.
/// </summary>
/// <remarks>Entries marked with the <see cref="ObsoleteAttribute"/> are no longer in use but kept for reference.</remarks>
public enum ErrorCode : uint
@@ -40,7 +40,7 @@ namespace Tgstation.Server.Api.Models
BadHeaders,
/// <summary>
/// Attempted to request a <see cref="Token"/> with an existing <see cref="Token"/>.
/// Attempted to request a <see cref="Response.TokenResponse"/> with an existing <see cref="Response.TokenResponse"/>.
/// </summary>
[Description("Cannot generate a bearer token using a bearer token!")]
TokenWithToken,
@@ -76,43 +76,43 @@ namespace Tgstation.Server.Api.Models
ServerUpdateInProgress,
/// <summary>
/// Attempted to change something other than the capitalization of a <see cref="Internal.UserBase.Name"/>.
/// Attempted to change something other than the capitalization of a <see cref="UserName.Name"/> for a user.
/// </summary>
[Description("Can only change the capitalization of a user's name!")]
UserNameChange,
/// <summary>
/// Attempted to change a <see cref="Internal.User.SystemIdentifier"/>.
/// Attempted to change a <see cref="Internal.UserModelBase.SystemIdentifier"/>.
/// </summary>
[Description("Cannot change a user's systemIdentifier!")]
UserSidChange,
/// <summary>
/// Attempted to create a <see cref="User"/> with a <see cref="Internal.UserBase.Name"/> and <see cref="Internal.User.SystemIdentifier"/>.
/// Attempted to create a user with a <see cref="UserName.Name"/> and <see cref="Internal.UserModelBase.SystemIdentifier"/>.
/// </summary>
[Description("A user cannot have both a name and systemIdentifier!")]
UserMismatchNameSid,
/// <summary>
/// Attempted to create a <see cref="User"/> with a <see cref="UserUpdate.Password"/> and <see cref="Internal.User.SystemIdentifier"/>.
/// Attempted to create a user with a <see cref="Request.UserUpdateRequest.Password"/> and <see cref="Internal.UserModelBase.SystemIdentifier"/>.
/// </summary>
[Description("A user cannot have both a password and systemIdentifier!")]
UserMismatchPasswordSid,
/// <summary>
/// The given <see cref="UserUpdate.Password"/> length was less than the server's configured minimum.
/// The given <see cref="Request.UserUpdateRequest.Password"/> length was less than the server's configured minimum.
/// </summary>
[Description("The given password is less than the server's configured minimum password length!")]
UserPasswordLength,
/// <summary>
/// Attempted to create a <see cref="User"/> with a ':' in the <see cref="Internal.UserBase.Name"/>.
/// Attempted to create a user with a ':' character in the <see cref="UserName.Name"/>.
/// </summary>
[Description("User names cannot contain the ':' character!")]
UserColonInName,
/// <summary>
/// Attempted to create a <see cref="User"/> with a <see langword="null"/> or whitespace <see cref="Internal.UserBase.Name"/>.
/// Attempted to create a user with a <see langword="null"/> or whitespace <see cref="UserName.Name"/>.
/// </summary>
[Description("User's name is missing or invalid whitespace!")]
UserMissingName,
@@ -148,7 +148,7 @@ namespace Tgstation.Server.Api.Models
InstanceLimitReached,
/// <summary>
/// Attempted to create an <see cref="Instance"/> with a whitespace <see cref="Instance.Name"/>.
/// Attempted to create an <see cref="Instance"/> with a whitespace <see cref="NamedEntity.Name"/>.
/// </summary>
[Description("Instance names cannot be whitespace!")]
InstanceWhitespaceName,
@@ -166,7 +166,7 @@ namespace Tgstation.Server.Api.Models
RequiresPosixSystemIdentity,
/// <summary>
/// A <see cref="ConfigurationFile"/> was updated.
/// A <see cref="IConfigurationFile"/> was updated.
/// </summary>
[Description("This existing file hash does not match, the file has beeen updated!")]
ConfigurationFileUpdated,
@@ -178,10 +178,11 @@ namespace Tgstation.Server.Api.Models
ConfigurationDirectoryNotEmpty,
/// <summary>
/// Tried to clone a repository with a missing <see cref="Repository.Origin"/> property.
/// Currently unused.
/// </summary>
[Description("Cannot clone repository with missing origin field!")]
RepoMissingOrigin,
[Obsolete("Unused", true)]
[Description("Unknown error code.")]
UnusedErrorCode1,
/// <summary>
/// One of <see cref="Internal.RepositorySettings.AccessUser"/> and <see cref="Internal.RepositorySettings.AccessToken"/> is set while the other isn't.
@@ -214,25 +215,26 @@ namespace Tgstation.Server.Api.Models
RepoMissing,
/// <summary>
/// Attempted to <see cref="Repository.CheckoutSha"/> and set <see cref="Repository.Reference"/> at the same time.
/// Attempted to <see cref="Request.RepositoryUpdateRequest.CheckoutSha"/> and set <see cref="Internal.RepositoryApiBase.Reference"/> at the same time.
/// </summary>
[Description("Cannot checkoutSha and set reference at the same time!")]
RepoMismatchShaAndReference,
/// <summary>
/// Attempted to <see cref="Repository.CheckoutSha"/> and <see cref="Repository.UpdateFromOrigin"/> at the same time.
/// Attempted to <see cref="Request.RepositoryUpdateRequest.CheckoutSha"/> and <see cref="Request.RepositoryUpdateRequest.UpdateFromOrigin"/> at the same time.
/// </summary>
[Description("Cannot checkoutSha and updateFromOrigin at the same time!")]
RepoMismatchShaAndUpdate,
/// <summary>
/// Attempted to change the origin of an existing repository.
/// Currently unused.
/// </summary>
[Description("Cannot change the origin of an existing repository, delete and recreate it instead!")]
RepoCantChangeOrigin,
[Obsolete("Unused", true)]
[Description("Unknown error code.")]
UnusedErrorCode2,
/// <summary>
/// <see cref="Repository.NewTestMerges"/> contained duplicate <see cref="TestMergeParameters.Number"/>s.
/// <see cref="Request.RepositoryUpdateRequest.NewTestMerges"/> contained duplicate <see cref="TestMergeParameters.Number"/>s.
/// </summary>
[Description("The same test merge was present more than once or is already merged!")]
RepoDuplicateTestMerge,
@@ -262,43 +264,44 @@ namespace Tgstation.Server.Api.Models
ApiInvalidPageOrPageSize,
/// <summary>
/// A requested <see cref="ChatChannel"/>'s data does not match with its <see cref="Internal.ChatBot.Provider"/>.
/// A requested <see cref="ChatChannel"/>'s data does not match with its <see cref="Internal.ChatBotSettings.Provider"/>.
/// </summary>
[Description("One or more of the channels for one or more of the provided chat bots do not have the correct channel data for their provider!")]
ChatBotWrongChannelType,
/// <summary>
/// <see cref="Internal.ChatBot.ConnectionString"/> was whitespace.
/// <see cref="Internal.ChatBotSettings.ConnectionString"/> was whitespace.
/// </summary>
[Description("A chat bot's connection string cannot be whitespace!")]
ChatBotWhitespaceConnectionString,
/// <summary>
/// <see cref="Internal.ChatBot.Name"/> was whitespace.
/// Chat bot <see cref="NamedEntity.Name"/> was whitespace.
/// </summary>
[Description("A chat bot's name cannot be whitespace!")]
ChatBotWhitespaceName,
/// <summary>
/// <see cref="Internal.ChatBot.Provider"/> was <see langword="null"/> during creation.
/// <see cref="Internal.ChatBotSettings.Provider"/> was <see langword="null"/> during creation.
/// </summary>
[Description("Missing chat bot provider!")]
ChatBotProviderMissing,
/// <summary>
/// Tried to edit <see cref="UserGroup"/> membership using <see cref="Routes.UserGroup"/>.
/// Currently unused.
/// </summary>
[Description("The " + Routes.UserGroup + " endpoint cannot edit group members. Please update each member user individually.")]
UserGroupControllerCantEditMembers,
[Obsolete("Unused", true)]
[Description("Unknown error code.")]
UnusedErrorCode3,
/// <summary>
/// Attempted to add a <see cref="ChatBot"/> when at or above the <see cref="Instance.ChatBotLimit"/> or it was set to something lower than the existing amount of <see cref="ChatBot"/>.
/// Attempted to add a chat bot when at or above the <see cref="Instance.ChatBotLimit"/> or it was set to something lower than the existing amount of chat bots.
/// </summary>
[Description("Performing this operation would violate the instance's configured chatBotLimit!")]
ChatBotMax,
/// <summary>
/// Attempted to configure a <see cref="ChatBot"/> with more <see cref="ChatChannel"/>s than the configured limit
/// Attempted to configure a chat bot with more <see cref="ChatChannel"/>s than the configured <see cref="Internal.ChatBotSettings.ChannelLimit"/>.
/// </summary>
[Description("Set amount of chatChannels exceeds the configured channelLimit!")]
ChatBotMaxChannels,
@@ -334,7 +337,7 @@ namespace Tgstation.Server.Api.Models
DreamMakerInvalidValidation,
/// <summary>
/// Tried to remove the last <see cref="OAuthConnection"/> for a passwordless <see cref="User"/>.
/// Tried to remove the last <see cref="OAuthConnection"/> for a passwordless user.
/// </summary>
[Description("This user is passwordless and removing their oAuthConnections would leave them with no authentication method!")]
CannotRemoveLastAuthenticationOption,
@@ -364,19 +367,19 @@ namespace Tgstation.Server.Api.Models
DreamMakerCompileJobInProgress,
/// <summary>
/// Missing <see cref="DreamDaemon"/> settings in database.
/// Missing <see cref="Internal.DreamDaemonSettings"/> in database.
/// </summary>
[Description("Could not retrieve DreamDaemon settings from the database!")]
InstanceMissingDreamDaemonSettings,
/// <summary>
/// Missing <see cref="DreamMaker"/> settings in database.
/// Missing <see cref="Internal.DreamMakerSettings"/> in database.
/// </summary>
[Description("Could not retrieve DreamMaker settings from the database!")]
InstanceMissingDreamMakerSettings,
/// <summary>
/// Missing <see cref="Repository"/> settings in database.
/// Missing <see cref="Internal.RepositorySettings"/> in database.
/// </summary>
[Description("Could not retrieve Repository settings from the database!")]
InstanceMissingRepositorySettings,
@@ -400,7 +403,7 @@ namespace Tgstation.Server.Api.Models
RepoCannotAuthenticate,
/// <summary>
/// Cannot perform operation while not on a <see cref="Repository.Reference"/>.
/// Cannot perform operation while not on a <see cref="Internal.RepositoryApiBase.Reference"/>.
/// </summary>
[Description("This git operation requires the repository HEAD to currently be on a tracked reference!")]
RepoReferenceRequired,
@@ -412,7 +415,7 @@ namespace Tgstation.Server.Api.Models
WatchdogRunning,
/// <summary>
/// Attempted to start the watchdog with a corrupted <see cref="CompileJob"/>.
/// Attempted to start the watchdog with a corrupted <see cref="Internal.CompileJob"/>.
/// </summary>
[Description("Cannot launch active compile job as it is missing or corrupted!")]
WatchdogCompileJobCorrupted,
@@ -436,7 +439,7 @@ namespace Tgstation.Server.Api.Models
RepoUnsupportedTestMergeRemote,
/// <summary>
/// Either <see cref="Repository.CheckoutSha"/> or <see cref="Repository.Reference"/> was in one when it should have been the other.
/// Either <see cref="Request.RepositoryUpdateRequest.CheckoutSha"/> or <see cref="Internal.RepositoryApiBase.Reference"/> was in one when it should have been the other.
/// </summary>
[Description("The value set for checkoutSha or reference should be in the other field!")]
RepoSwappedShaOrReference,
@@ -448,7 +451,7 @@ namespace Tgstation.Server.Api.Models
RepoMergeConflict,
/// <summary>
/// The current <see cref="Repository.Reference"/> does not track a remote reference.
/// The current <see cref="Internal.RepositoryApiBase.Reference"/> does not track a remote reference.
/// </summary>
[Description("The repository's current reference is unsuitable for this operation as it does not track a remote reference!")]
RepoReferenceNotTracking,
@@ -460,13 +463,13 @@ namespace Tgstation.Server.Api.Models
RepoTestMergeConflict,
/// <summary>
/// Attempted to create an instance outside of the <see cref="Internal.ServerInformation.ValidInstancePaths"/>.
/// Attempted to create an instance outside of the <see cref="Internal.ServerInformationBase.ValidInstancePaths"/>.
/// </summary>
[Description("The new instance's path is not under a white-listed path.")]
InstanceNotAtWhitelistedPath,
/// <summary>
/// Attempted to make a DreamDaemon update with both <see cref="DreamDaemon.SoftRestart"/> and <see cref="DreamDaemon.SoftShutdown"/> set.
/// Attempted to make a DreamDaemon update with both <see cref="Internal.DreamDaemonApiBase.SoftRestart"/> and <see cref="Internal.DreamDaemonApiBase.SoftShutdown"/> set.
/// </summary>
[Description("Cannot set both softShutdown and softReboot at once!")]
DreamDaemonDoubleSoft,
@@ -580,7 +583,7 @@ namespace Tgstation.Server.Api.Models
PortNotAvailable,
/// <summary>
/// Attempted to set <see cref="User.OAuthConnections"/> for the admin user.
/// Attempted to set <see cref="Internal.UserApiBase.OAuthConnections"/> for the admin user.
/// </summary>
[Description("The admin user cannot use OAuth connections!")]
AdminUserCannotOAuth,
@@ -592,31 +595,31 @@ namespace Tgstation.Server.Api.Models
OAuthProviderDisabled,
/// <summary>
/// A <see cref="Job"/> requiring a file upload did not receive it before timing out.
/// A job requiring a file upload did not receive it before timing out.
/// </summary>
[Description("The job did not receive a required upload before timing out!")]
FileUploadExpired,
/// <summary>
/// Tried to update a <see cref="User"/> to have both a <see cref="User.Group"/> and <see cref="User.PermissionSet"/>
/// Tried to update a user to have both a <see cref="Internal.UserApiBase.Group"/> and <see cref="Internal.UserApiBase.PermissionSet"/>
/// </summary>
[Description("A user may not have both a permissionSet and group!")]
UserGroupAndPermissionSet,
/// <summary>
/// Tried to delete a non-empty <see cref="UserGroup"/>.
/// Tried to delete a non-empty user group.
/// </summary>
[Description("Cannot delete the user group as it is not empty!")]
UserGroupNotEmpty,
/// <summary>
/// Attempted to create an <see cref="User"/> but the configured limit has been reached.
/// Attempted to create a user but the configured limit has been reached.
/// </summary>
[Description("The user cannot be created because the configured limit has been reached!")]
UserLimitReached,
/// <summary>
/// Attempted to create an <see cref="UserGroup"/> but the configured limit has been reached.
/// Attempted to create a user group but the configured limit has been reached.
/// </summary>
[Description("The user group cannot be created because the configured limit has been reached!")]
UserGroupLimitReached,
@@ -0,0 +1,23 @@
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Indicates whether a request field is <see cref="Required"/> or <see cref="Ignored"/>.
/// </summary>
public enum FieldPresence
{
/// <summary>
/// The field is optional
/// </summary>
Optional,
/// <summary>
/// The field is required.
/// </summary>
Required,
/// <summary>
/// The field is ignored or should not appear.
/// </summary>
Ignored
}
}
@@ -5,27 +5,18 @@ namespace Tgstation.Server.Api.Models
/// <summary>
/// Represents a game configuration file. Create and delete actions uncerimonuously overwrite/delete files
/// </summary>
public sealed class ConfigurationFile : FileTicketResult
public interface IConfigurationFile
{
/// <summary>
/// The path to the <see cref="ConfigurationFile"/> file
/// The path to the <see cref="IConfigurationFile"/> file.
/// </summary>
[StringLength(Limits.MaximumStringLength)]
public string? Path { get; set; }
/// <summary>
/// If access to the <see cref="ConfigurationFile"/> file was denied for the operation
/// </summary>
public bool? AccessDenied { get; set; }
/// <summary>
/// If <see cref="Path"/> represents a directory
/// </summary>
public bool? IsDirectory { get; set; }
/// <summary>
/// The MD5 hash of the file when last read by the user. If this doesn't match during update actions, the write will be denied with <see cref="System.Net.HttpStatusCode.Conflict"/>
/// </summary>
[ResponseOptions]
public string? LastReadHash { get; set; }
}
}
+6 -33
View File
@@ -1,34 +1,28 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Metadata about a server instance
/// </summary>
public class Instance : EntityId
public abstract class Instance : NamedEntity
{
/// <summary>
/// The name of the <see cref="Instance"/>
/// </summary>
[Required]
[StringLength(Limits.MaximumStringLength)]
public string? Name { get; set; }
/// <summary>
/// The path to where the <see cref="Instance"/> is located. Can only be changed while the <see cref="Instance"/> is offline. Must not exist when the instance is created
/// </summary>
[Required]
[RequestOptions(FieldPresence.Required, PutOnly = true)]
public string? Path { get; set; }
/// <summary>
/// If the <see cref="Instance"/> is online
/// </summary>
[Required]
[RequestOptions(FieldPresence.Ignored, PutOnly = true)]
public bool? Online { get; set; }
/// <summary>
/// If <see cref="ConfigurationFile"/> can be used on the <see cref="Instance"/>
/// If <see cref="IConfigurationFile"/>s can be used on the <see cref="Instance"/>
/// </summary>
[Required]
[EnumDataType(typeof(ConfigurationType))]
@@ -41,30 +35,9 @@ namespace Tgstation.Server.Api.Models
public uint? AutoUpdateInterval { get; set; }
/// <summary>
/// The maximum number of <see cref="ChatBot"/>s the <see cref="Instance"/> may contain.
/// The maximum number of chat bots the <see cref="Instance"/> may contain.
/// </summary>
[Required]
public ushort? ChatBotLimit { get; set; }
/// <summary>
/// The <see cref="Job"/> representing a change of <see cref="Path"/>
/// </summary>
/// <remarks>Due to how <see cref="Job"/>s are children of <see cref="Instance"/>s but moving one requires the <see cref="Instance"/> to be offline, interactions with this <see cref="Job"/> are performed in a non-standard fashion. The <see cref="Job"/> is read by querying the <see cref="Instance"/> again (either via list or ID lookup) and cancelled by making any sort of update to the <see cref="Instance"/>. Once the <see cref="Instance"/> comes back <see cref="Online"/> it can be queried like a normal job</remarks>
[NotMapped]
public Job? MoveJob { get; set; }
/// <summary>
/// Create a clone of the essential <see cref="Instance"/> metadata
/// </summary>
/// <returns>A clone of the essential <see cref="Instance"/> metadata</returns>
public Instance CloneMetadata() => new Instance
{
Id = Id,
Name = Name,
Path = Path,
Online = Online,
ConfigurationType = ConfigurationType,
AutoUpdateInterval = AutoUpdateInterval
};
}
}
@@ -1,11 +1,11 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Internal
{
/// <inheritdoc />
public sealed class ChatBot : Internal.ChatBot
public abstract class ChatBotApiBase : ChatBotSettings
{
/// <summary>
/// Channels the Discord bot should listen/announce in
@@ -13,9 +13,9 @@ namespace Tgstation.Server.Api.Models
public ICollection<ChatChannel>? Channels { get; set; }
/// <summary>
/// Validates <see cref="Channels"/> are correct for the <see cref="Internal.ChatBot.Provider"/>
/// Validates <see cref="Channels"/> are correct for the <see cref="ChatBotSettings.Provider"/>
/// </summary>
/// <returns><see langword="true"/> if the <see cref="Channels"/> are valid for the <see cref="Internal.ChatBot.Provider"/>, <see langword="false"/> otherwise</returns>
/// <returns><see langword="true"/> if the <see cref="Channels"/> are valid for the <see cref="ChatBotSettings.Provider"/>, <see langword="false"/> otherwise</returns>
public bool ValidateProviderChannelTypes()
{
if (!Provider.HasValue)
@@ -6,15 +6,8 @@ namespace Tgstation.Server.Api.Models.Internal
/// <summary>
/// Manage the server chat bots
/// </summary>
public class ChatBot : EntityId
public abstract class ChatBotSettings : NamedEntity
{
/// <summary>
/// The name of the connection
/// </summary>
[Required]
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
public string? Name { get; set; }
/// <summary>
/// If the connection is enabled
/// </summary>
@@ -28,7 +21,7 @@ namespace Tgstation.Server.Api.Models.Internal
public uint? ReconnectionInterval { get; set; }
/// <summary>
/// The maximum number of <see cref="ChatChannel"/>s the <see cref="ChatBot"/> may contain.
/// The maximum number of <see cref="ChatChannel"/>s the <see cref="ChatBotSettings"/> may contain.
/// </summary>
[Required]
public ushort? ChannelLimit { get; set; }
@@ -37,6 +30,7 @@ namespace Tgstation.Server.Api.Models.Internal
/// The <see cref="ChatProvider"/> used for the connection
/// </summary>
[Required]
[RequestOptions(FieldPresence.Required, PutOnly = true)]
[EnumDataType(typeof(ChatProvider))]
public ChatProvider? Provider { get; set; }
@@ -44,13 +38,15 @@ namespace Tgstation.Server.Api.Models.Internal
/// The information used to connect to the <see cref="Provider"/>
/// </summary>
[Required]
[RequestOptions(FieldPresence.Required, PutOnly = true)]
[ResponseOptions]
[StringLength(Limits.MaximumStringLength)]
public string? ConnectionString { get; set; }
/// <summary>
/// Get the <see cref="ChatConnectionStringBuilder"/> which maps to the <see cref="ConnectionString"/>.
/// </summary>
/// <returns>A <see cref="ChatConnectionStringBuilder"/> for the <see cref="ChatBot"/>.</returns>
/// <returns>A <see cref="ChatConnectionStringBuilder"/> for the <see cref="ChatBotSettings"/>.</returns>
public ChatConnectionStringBuilder? CreateConnectionStringBuilder()
{
if (ConnectionString == null)
@@ -64,7 +60,7 @@ namespace Tgstation.Server.Api.Models.Internal
}
/// <summary>
/// Set the <see cref="ChatConnectionStringBuilder"/> for the <see cref="ChatBot"/>. Also updates the <see cref="ConnectionString"/>.
/// Set the <see cref="ChatConnectionStringBuilder"/> for the <see cref="ChatBotSettings"/>. Also updates the <see cref="ConnectionString"/>.
/// </summary>
/// <param name="stringBuilder">The optional <see cref="ChatConnectionStringBuilder"/>.</param>
public void SetConnectionStringBuilder(ChatConnectionStringBuilder stringBuilder)
@@ -1,19 +1,19 @@
namespace Tgstation.Server.Api.Models.Internal
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Helper for building <see cref="ChatBot.ConnectionString"/>s
/// Helper for building <see cref="ChatBotSettings.ConnectionString"/>s
/// </summary>
public abstract class ChatConnectionStringBuilder
{
/// <summary>
/// If the <see cref="ChatConnectionStringBuilder"/> evaluates to a valid <see cref="ChatBot.ConnectionString"/>
/// If the <see cref="ChatConnectionStringBuilder"/> evaluates to a valid <see cref="ChatBotSettings.ConnectionString"/>
/// </summary>
public abstract bool Valid { get; }
/// <summary>
/// Gets the <see cref="ChatBot.ConnectionString"/> associated with the <see cref="ChatConnectionStringBuilder"/>
/// Gets the <see cref="ChatBotSettings.ConnectionString"/> associated with the <see cref="ChatConnectionStringBuilder"/>
/// </summary>
/// <returns>The <see cref="ChatBot.ConnectionString"/> associated with the <see cref="ChatConnectionStringBuilder"/></returns>
/// <returns>The <see cref="ChatBotSettings.ConnectionString"/> associated with the <see cref="ChatConnectionStringBuilder"/></returns>
public abstract override string ToString();
}
}
}
@@ -5,9 +5,9 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Represents a run of <see cref="DreamMaker"/>
/// Represents a deployment run.
/// </summary>
public class CompileJob : EntityId
public abstract class CompileJob : EntityId
{
/// <summary>
/// The .dme file used for compilation
@@ -28,14 +28,16 @@ namespace Tgstation.Server.Api.Models.Internal
public Guid? DirectoryName { get; set; }
/// <summary>
/// The minimum <see cref="DreamDaemonSecurity"/> required to run the <see cref="CompileJob"/>'s output
/// The minimum <see cref="DreamDaemonSecurity"/> required to run the <see cref="CompileJob"/>'s output.
/// </summary>
[ResponseOptions]
public DreamDaemonSecurity? MinimumSecurityLevel { get; set; }
/// <summary>
/// The DMAPI <see cref="Version"/>.
/// </summary>
[NotMapped]
[ResponseOptions]
public virtual Version? DMApiVersion { get; set; }
}
}
@@ -0,0 +1,20 @@
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Base class for DreamDaemon API models.
/// </summary>
public abstract class DreamDaemonApiBase : DreamDaemonSettings
{
/// <summary>
/// If the server is undergoing a soft reset. This may be automatically set by changes to other fields
/// </summary>
[ResponseOptions]
public bool? SoftRestart { get; set; }
/// <summary>
/// If the server is undergoing a soft shutdown
/// </summary>
[ResponseOptions]
public bool? SoftShutdown { get; set; }
}
}
@@ -12,19 +12,22 @@ namespace Tgstation.Server.Api.Models.Internal
/// If the BYOND web client can be used to connect to the game server
/// </summary>
[Required]
[ResponseOptions]
public bool? AllowWebClient { get; set; }
/// <summary>
/// The <see cref="DreamDaemonSecurity"/> level of <see cref="DreamDaemon"/>
/// The <see cref="DreamDaemonSecurity"/> level of DreamDaemon.
/// </summary>
[Required]
[ResponseOptions]
[EnumDataType(typeof(DreamDaemonSecurity))]
public DreamDaemonSecurity? SecurityLevel { get; set; }
/// <summary>
/// The first port <see cref="DreamDaemon"/> uses. This should be the publically advertised port
/// The port DreamDaemon uses. This should be publically accessible.
/// </summary>
[Required]
[ResponseOptions]
[Range(1, UInt16.MaxValue)]
public ushort? Port { get; set; }
@@ -32,6 +35,7 @@ namespace Tgstation.Server.Api.Models.Internal
/// The DreamDaemon startup timeout in seconds
/// </summary>
[Required]
[ResponseOptions]
[Range(1, UInt32.MaxValue)]
public uint? StartupTimeout { get; set; }
@@ -39,12 +43,14 @@ namespace Tgstation.Server.Api.Models.Internal
/// The number of seconds between each watchdog heartbeat. 0 disables.
/// </summary>
[Required]
[ResponseOptions]
public uint? HeartbeatSeconds { get; set; }
/// <summary>
/// The timeout for sending and receiving BYOND topics in milliseconds.
/// </summary>
[Required]
[ResponseOptions]
[Range(1, UInt32.MaxValue)]
public uint? TopicRequestTimeout { get; set; }
@@ -52,6 +58,7 @@ namespace Tgstation.Server.Api.Models.Internal
/// Parameters string for DreamDaemon.
/// </summary>
[Required]
[ResponseOptions]
[StringLength(Limits.MaximumStringLength)]
public string? AdditionalParameters { get; set; }
@@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Configurable settings for <see cref="DreamDaemon"/>
/// Configurable settings for DreamDaemon.
/// </summary>
public class DreamDaemonSettings : DreamDaemonLaunchParameters
{
/// <summary>
/// If <see cref="DreamDaemon"/> starts when it's <see cref="Instance"/> starts
/// If the watchdog starts when it's <see cref="Instance"/> starts
/// </summary>
[Required]
[ResponseOptions]
public bool? AutoStart { get; set; }
}
}
@@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Represents the state of the DreamMaker compiler. Create action starts a new compile. Delete action cancels the current compile
/// </summary>
public class DreamMaker
public abstract class DreamMakerSettings
{
/// <summary>
/// The .dme file <see cref="DreamMaker"/> tries to compile with without the extension
/// The name of the .dme file the server tries to compile with without the extension.
/// </summary>
[StringLength(Limits.MaximumStringLength)]
[ResponseOptions]
public string? ProjectName { get; set; }
/// <summary>
@@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Api.Rights;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Represents a <see cref="PermissionSet"/>s permissions in an <see cref="Instance"/>
/// </summary>
public class InstancePermissionSet
public abstract class InstancePermissionSet
{
/// <summary>
/// The <see cref="EntityId.Id"/> of the <see cref="PermissionSet"/> the <see cref="InstancePermissionSet"/> belongs to
/// </summary>
[RequestOptions(FieldPresence.Required)]
public long PermissionSetId { get; set; }
/// <summary>
@@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Api.Rights;
@@ -18,11 +18,13 @@ namespace Tgstation.Server.Api.Models.Internal
/// <summary>
/// The <see cref="Models.ErrorCode"/> associated with the <see cref="Job"/> if any.
/// </summary>
[ResponseOptions]
public ErrorCode? ErrorCode { get; set; }
/// <summary>
/// Details of any exceptions caught during the <see cref="Job"/>
/// </summary>
[ResponseOptions]
public string? ExceptionDetails { get; set; }
/// <summary>
@@ -34,6 +36,7 @@ namespace Tgstation.Server.Api.Models.Internal
/// <summary>
/// When the <see cref="Job"/> stopped
/// </summary>
[ResponseOptions]
public DateTimeOffset? StoppedAt { get; set; }
/// <summary>
@@ -45,11 +48,13 @@ namespace Tgstation.Server.Api.Models.Internal
/// <summary>
/// The <see cref="RightsType"/> of <see cref="CancelRight"/> if it can be cancelled
/// </summary>
[ResponseOptions]
public RightsType? CancelRightsType { get; set; }
/// <summary>
/// The <see cref="Rights"/> required to cancel the <see cref="Job"/>
/// </summary>
[ResponseOptions]
public ulong? CancelRight { get; set; }
}
}
}
@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Base <see langword="class"/> for repository models.
/// </summary>
public class RepositoryApiBase : RepositorySettings
{
/// <summary>
/// The branch or tag HEAD points to.
/// </summary>
[StringLength(Limits.MaximumStringLength)]
[ResponseOptions]
public string? Reference { get; set; }
}
}
@@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Represents configurable settings for a <see cref="Repository"/>
/// Represents configurable settings for a git repository.
/// </summary>
public class RepositorySettings
{
@@ -26,12 +26,14 @@ namespace Tgstation.Server.Api.Models.Internal
/// The username to access the git repository with
/// </summary>
[StringLength(Limits.MaximumStringLength)]
[ResponseOptions]
public string? AccessUser { get; set; }
/// <summary>
/// The token/password to access the git repository with
/// </summary>
[StringLength(Limits.MaximumStringLength)]
[ResponseOptions(Presence = FieldPresence.Ignored)]
public string? AccessToken { get; set; }
/// <summary>
@@ -3,9 +3,9 @@ using System.Collections.Generic;
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Base class for <see cref="Models.ServerInformation"/>.
/// Base class for <see cref="Response.ServerInformationResponse"/>.
/// </summary>
public abstract class ServerInformation
public abstract class ServerInformationBase
{
/// <summary>
/// Minimum length of database user passwords.
@@ -18,18 +18,19 @@ namespace Tgstation.Server.Api.Models.Internal
public uint InstanceLimit { get; set; }
/// <summary>
/// The maximum number of <see cref="Models.User"/>s allowed.
/// The maximum number of users allowed.
/// </summary>
public uint UserLimit { get; set; }
/// <summary>
/// The maximum number of <see cref="Models.UserGroup"/>s allowed.
/// The maximum number of user groups allowed.
/// </summary>
public uint UserGroupLimit { get; set; }
/// <summary>
/// Limits the locations instances may be created or attached from.
/// </summary>
[ResponseOptions]
public ICollection<string>? ValidInstancePaths { get; set; }
}
}
@@ -0,0 +1,7 @@
namespace Tgstation.Server.Api.Models.Request
{
/// <inheritdoc />
public sealed class ServerUpdateRequest : ServerUpdate
{
}
}
@@ -6,15 +6,15 @@ namespace Tgstation.Server.Api.Models.Internal
/// <summary>
/// Represents a test merge of a remote "pull request".
/// </summary>
public class TestMerge : TestMergeBase
public class TestMergeApiBase : TestMergeModelBase
{
/// <summary>
/// The ID of the <see cref="TestMerge"/>
/// The ID of the <see cref="TestMergeApiBase"/>
/// </summary>
public long Id { get; set; }
/// <summary>
/// When the <see cref="TestMerge"/> was created
/// When the <see cref="TestMergeApiBase"/> was created
/// </summary>
[Required]
public DateTimeOffset MergedAt { get; set; }
@@ -6,7 +6,7 @@ namespace Tgstation.Server.Api.Models.Internal
/// <summary>
/// Layer of test merge data required internally
/// </summary>
public abstract class TestMergeBase : TestMergeParameters
public abstract class TestMergeModelBase : TestMergeParameters
{
/// <summary>
/// The title of the test merge source.
@@ -35,15 +35,15 @@ namespace Tgstation.Server.Api.Models.Internal
public string? Author { get; set; }
/// <summary>
/// Construct a <see cref="TestMergeBase"/>
/// Construct a <see cref="TestMergeModelBase"/>
/// </summary>
protected TestMergeBase() { }
protected TestMergeModelBase() { }
/// <summary>
/// Construct a <see cref="TestMergeBase"/> from a <paramref name="copy"/>
/// Construct a <see cref="TestMergeModelBase"/> from a <paramref name="copy"/>
/// </summary>
/// <param name="copy">The <see cref="TestMergeBase"/> to copy data from</param>
protected TestMergeBase(TestMergeBase copy)
/// <param name="copy">The <see cref="TestMergeModelBase"/> to copy data from</param>
protected TestMergeModelBase(TestMergeModelBase copy)
{
if (copy == null)
throw new ArgumentNullException(nameof(copy));
@@ -0,0 +1,25 @@
using System.Collections.Generic;
namespace Tgstation.Server.Api.Models.Internal
{
/// <inheritdoc />
public abstract class UserApiBase : UserModelBase
{
/// <summary>
/// List of <see cref="OAuthConnection"/>s associated with the user.
/// </summary>
public ICollection<OAuthConnection>? OAuthConnections { get; set; }
/// <summary>
/// The <see cref="Models.PermissionSet"/> directly associated with the user.
/// </summary>
[ResponseOptions]
public PermissionSet? PermissionSet { get; set; }
/// <summary>
/// The <see cref="UserGroup"/> asociated with the user, if any.
/// </summary>
[ResponseOptions]
public UserGroup? Group { get; set; }
}
}
@@ -1,23 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Base class for <see cref="User"/>.
/// </summary>
public class UserBase
{
/// <summary>
/// The ID of the <see cref="User"/>
/// </summary>
[Required]
public long? Id { get; set; }
/// <summary>
/// The name of the <see cref="User"/>
/// </summary>
[Required]
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
public string? Name { get; set; }
}
}
@@ -1,9 +1,9 @@
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Represents a group of <see cref="Models.User"/>s.
/// Represents a group of users.
/// </summary>
public class UserGroup : UserGroupBase
public class UserGroup : NamedEntity
{
/// <summary>
/// The <see cref="Models.PermissionSet"/> of the <see cref="UserGroup"/>.
@@ -1,17 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Base class for <see cref="UserGroup"/>.
/// </summary>
public abstract class UserGroupBase : EntityId
{
/// <summary>
/// The name of the <see cref="UserGroup"/>.
/// </summary>
[Required]
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
public string? Name { get; set; }
}
}
@@ -4,25 +4,27 @@ using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models.Internal
{
/// <summary>
/// Represents a server <see cref="User"/>
/// Represents a server user.
/// </summary>
public abstract class User : UserBase
public abstract class UserModelBase : UserName
{
/// <summary>
/// If the <see cref="User"/> is enabled since users cannot be deleted. System users cannot be disabled
/// If the <see cref="UserModelBase"/> is enabled since users cannot be deleted. System users cannot be disabled
/// </summary>
[Required]
public bool? Enabled { get; set; }
/// <summary>
/// When the <see cref="User"/> was created
/// When the <see cref="UserModelBase"/> was created
/// </summary>
[Required]
[RequestOptions(FieldPresence.Ignored)]
public DateTimeOffset? CreatedAt { get; set; }
/// <summary>
/// The SID/UID of the <see cref="User"/> on Windows/POSIX respectively
/// The SID/UID of the <see cref="UserModelBase"/> on Windows/POSIX respectively
/// </summary>
[ResponseOptions]
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
public string? SystemIdentifier { get; set; }
}
-23
View File
@@ -1,23 +0,0 @@
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>
public sealed class Job : Internal.Job
{
/// <summary>
/// The <see cref="User"/> that started the job
/// </summary>
public User? StartedBy { get; set; }
/// <summary>
/// The <see cref="User"/> that cancelled the job
/// </summary>
public User? CancelledBy { get; set; }
/// <summary>
/// Optional progress between 0 and 100 inclusive
/// </summary>
public int? Progress { get; set; }
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ namespace Tgstation.Server.Api.Models
public const int MaximumStringLength = 10000;
/// <summary>
/// Length limit for <see cref="Internal.ChatBot.Name"/>s.
/// Length limit for <see cref="NamedEntity.Name"/>s.
/// </summary>
public const int MaximumIndexableStringLength = 100;
@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Base class for named entities.
/// </summary>
public abstract class NamedEntity : EntityId
{
/// <summary>
/// The name of the entity represented by the <see cref="NamedEntity"/>.
/// </summary>
[Required]
[RequestOptions(FieldPresence.Required, PutOnly = true)]
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
public virtual string? Name { get; set; }
}
}
@@ -18,6 +18,7 @@ namespace Tgstation.Server.Api.Models
/// The ID of the user in the <see cref="Provider"/>.
/// </summary>
[Required]
[RequestOptions(FieldPresence.Required)]
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
public string? ExternalUserId { get; set; }
}
@@ -20,6 +20,7 @@ namespace Tgstation.Server.Api.Models
/// <summary>
/// The server URL.
/// </summary>
[ResponseOptions]
public Uri? ServerUrl { get; set; }
}
}
@@ -6,22 +6,24 @@ namespace Tgstation.Server.Api.Models
/// <summary>
/// Represents a set of server permissions.
/// </summary>
public class PermissionSet
public class PermissionSet : EntityId
{
/// <summary>
/// The ID of the <see cref="PermissionSet"/>.
/// </summary>
[Required]
public long? Id { get; set; }
/// <inheritdoc />
[RequestOptions(FieldPresence.Ignored)]
public override long? Id
{
get => base.Id;
set => base.Id = value;
}
/// <summary>
/// The <see cref="Rights.AdministrationRights"/> for the <see cref="User"/>
/// The <see cref="Rights.AdministrationRights"/> for the user.
/// </summary>
[Required]
public AdministrationRights? AdministrationRights { get; set; }
/// <summary>
/// The <see cref="Rights.InstanceManagerRights"/> for the <see cref="User"/>
/// The <see cref="Rights.InstanceManagerRights"/> for the user.
/// </summary>
[Required]
public InstanceManagerRights? InstanceManagerRights { get; set; }
@@ -1,64 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Represents a git repository
/// </summary>
public sealed class Repository : RepositorySettings, IGitRemoteInformation
{
/// <summary>
/// The origin URL. If <see langword="null"/>, the <see cref="Repository"/> does not exist
/// </summary>
public Uri? Origin { get; set; }
/// <summary>
/// If submodules should be recursively cloned.
/// </summary>
public bool? RecurseSubmodules { get; set; }
/// <summary>
/// The commit HEAD should point to. Not populated in responses, use <see cref="RevisionInformation"/> instead for retrieval
/// </summary>
[StringLength(Limits.MaximumCommitShaLength)]
public string? CheckoutSha { get; set; }
/// <summary>
/// The current <see cref="Models.RevisionInformation"/> for the <see cref="Repository"/>
/// </summary>
public RevisionInformation? RevisionInformation { get; set; }
/// <inheritdoc />
public RemoteGitProvider? RemoteGitProvider { get; set; }
/// <inheritdoc />
public string? RemoteRepositoryOwner { get; set; }
/// <inheritdoc />
public string? RemoteRepositoryName { get; set; }
/// <summary>
/// The <see cref="Job"/> started by the <see cref="Repository"/> if any
/// </summary>
public Job? ActiveJob { get; set; }
/// <summary>
/// Do the equivalent of a git pull. Will attempt to merge unless <see cref="Reference"/> is also specified in which case a hard reset will be performed after checking out
/// </summary>
public bool? UpdateFromOrigin { get; set; }
/// <summary>
/// The branch or tag HEAD points to
/// </summary>
[StringLength(Limits.MaximumStringLength)]
public string? Reference { get; set; }
/// <summary>
/// <see cref="TestMergeParameters"/> for new <see cref="TestMerge"/>s. Note that merges that conflict will not be performed
/// </summary>
public ICollection<TestMergeParameters>? NewTestMerges { get; set; }
}
}
@@ -0,0 +1,21 @@
using System;
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// A request to install a BYOND <see cref="Version"/>.
/// </summary>
public sealed class ByondVersionRequest
{
/// <summary>
/// The BYOND version to install.
/// </summary>
[RequestOptions(FieldPresence.Required)]
public Version? Version { get; set; }
/// <summary>
/// If a custom BYOND version is to be uploaded.
/// </summary>
public bool? UploadCustomZip { get; set; }
}
}
@@ -0,0 +1,11 @@
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// Represents a request to update a chat bot.
/// </summary>
public sealed class ChatBotCreateRequest : ChatBotApiBase
{
}
}
@@ -0,0 +1,11 @@
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// Represents a request to update a chat bot.
/// </summary>
public class ChatBotUpdateRequest : ChatBotApiBase
{
}
}
@@ -0,0 +1,15 @@
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// Represents a request to update a configuration file.
/// </summary>
public sealed class ConfigurationFileRequest : IConfigurationFile
{
/// <inheritdoc />
[RequestOptions(FieldPresence.Required)]
public string? Path { get; set; }
/// <inheritdoc />
public string? LastReadHash { get; set; }
}
}
@@ -0,0 +1,11 @@
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// A request to update <see cref="DreamDaemonSettings"/>.
/// </summary>
public sealed class DreamDaemonRequest : DreamDaemonApiBase
{
}
}
@@ -0,0 +1,11 @@
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// A request to the DreamMaker controller.
/// </summary>
public sealed class DreamMakerRequest : DreamMakerSettings
{
}
}
@@ -0,0 +1,9 @@
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// A request to create an <see cref="Instance"/>.
/// </summary>
public sealed class InstanceCreateRequest : Instance
{
}
}
@@ -0,0 +1,11 @@
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// A request to update an instance permission set.
/// </summary>
public sealed class InstancePermissionSetRequest : InstancePermissionSet
{
}
}
@@ -0,0 +1,9 @@
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// A request to update an <see cref="Instance"/>.
/// </summary>
public class InstanceUpdateRequest : Instance
{
}
}
@@ -0,0 +1,22 @@
using System;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// Represents a request to clone the repository.
/// </summary>
public sealed class RepositoryCreateRequest : RepositoryApiBase
{
/// <summary>
/// The origin URL to clone.
/// </summary>
[RequestOptions(FieldPresence.Required)]
public Uri? Origin { get; set; }
/// <summary>
/// If submodules should be recursively cloned.
/// </summary>
public bool? RecurseSubmodules { get; set; }
}
}
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// Represents a request to change the repository.
/// </summary>
public sealed class RepositoryUpdateRequest : RepositoryApiBase
{
/// <summary>
/// The commit HEAD should point to.
/// </summary>
[StringLength(Limits.MaximumCommitShaLength)]
public string? CheckoutSha { get; set; }
/// <summary>
/// Do the equivalent of a git pull. Will attempt to merge unless <see cref="RepositoryApiBase.Reference"/> is also specified in which case a hard reset will be performed after checking out
/// </summary>
public bool? UpdateFromOrigin { get; set; }
/// <summary>
/// <see cref="TestMergeParameters"/> for new <see cref="TestMerge"/>s. Note that merges that conflict will not be performed
/// </summary>
public ICollection<TestMergeParameters>? NewTestMerges { get; set; }
}
}
@@ -0,0 +1,10 @@
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// For creating a user.
/// </summary>
#pragma warning disable CA1501
public sealed class UserCreateRequest : UserUpdateRequest
{
}
}
@@ -0,0 +1,9 @@
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// Request to create a user group.
/// </summary>
public sealed class UserGroupCreateRequest : UserGroupUpdateRequest
{
}
}
@@ -0,0 +1,11 @@
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// Request to update a user group.
/// </summary>
public class UserGroupUpdateRequest : UserGroup
{
}
}
@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Request
{
/// <summary>
/// For editing a given user.
/// </summary>
public class UserUpdateRequest : UserApiBase
{
/// <summary>
/// Cleartext password of the user.
/// </summary>
[Required]
public string? Password { get; set; }
}
}
@@ -0,0 +1,30 @@
using System;
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Indicates the <see cref="FieldPresence"/> for fields in models.
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
public sealed class RequestOptionsAttribute : Attribute
{
/// <summary>
/// The <see cref="FieldPresence"/>.
/// </summary>
public FieldPresence Presence { get; }
/// <summary>
/// If this only applies to HTTP PUT requests with the model.
/// </summary>
public bool PutOnly { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="RequestOptionsAttribute"/> <see langword="class"/>.
/// </summary>
/// <param name="presence">The value of <see cref="Presence"/>.</param>
public RequestOptionsAttribute(FieldPresence presence)
{
Presence = presence;
}
}
}
@@ -1,11 +1,11 @@
using System;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents administrative server information
/// </summary>
public sealed class Administration
public sealed class AdministrationResponse
{
/// <summary>
/// The GitHub repository the server is built to recieve updates from
@@ -13,13 +13,8 @@ namespace Tgstation.Server.Api.Models
public Uri? TrackedRepositoryUrl { get; set; }
/// <summary>
/// The latest available version of the Tgstation.Server.Host assembly from the upstream repository. If <see cref="Version.Major"/> is higher than <see cref="NewVersion"/>'s the update cannot be applied due to API changes
/// The latest available version of the Tgstation.Server.Host assembly from the upstream repository. If <see cref="Version.Major"/> is not equal to 4 the update cannot be applied due to API changes
/// </summary>
public Version? LatestVersion { get; set; }
/// <summary>
/// Changes the version of Tgstation.Server.Host to the given version from the upstream repository
/// </summary>
public Version? NewVersion { get; set; }
}
}
@@ -0,0 +1,24 @@
using System;
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents a BYOND installation. <see cref="FileTicketResponse.FileTicket"/> is used to upload custom BYOND version zip files, though <see cref="Version"/> must still be set.
/// </summary>
public sealed class ByondInstallResponse : FileTicketResponse
{
/// <summary>
/// The <see cref="JobResponse"/> being used to install a new <see cref="Version"/>.
/// </summary>
[ResponseOptions]
public JobResponse? InstallJob { get; set; }
/// <inheritdoc />
[ResponseOptions]
public override string? FileTicket
{
get => base.FileTicket;
set => base.FileTicket = value;
}
}
}
@@ -0,0 +1,16 @@
using System;
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents an installed BYOND <see cref="Version"/>.
/// </summary>
public sealed class ByondResponse
{
/// <summary>
/// The installed BYOND <see cref="System.Version"/>. If there is no BYOND version installed. Only considers the <see cref="Version.Major"/> and <see cref="Version.Minor"/> numbers.
/// </summary>
[ResponseOptions]
public Version? Version { get; set; }
}
}
@@ -0,0 +1,11 @@
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents a chat bot response.
/// </summary>
public sealed class ChatBotResponse : ChatBotApiBase
{
}
}
@@ -1,22 +1,22 @@
using System;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Response
{
/// <inheritdoc />
public sealed class CompileJob : Internal.CompileJob
public sealed class CompileJobResponse : Internal.CompileJob
{
/// <summary>
/// The <see cref="Job"/> relating to this job
/// The <see cref="Job"/> relating to this job.
/// </summary>
public Job? Job { get; set; }
public JobResponse? Job { get; set; }
/// <summary>
/// Git revision the compiler ran on. Not modifiable
/// Git revision the compiler ran on.
/// </summary>
public RevisionInformation? RevisionInformation { get; set; }
/// <summary>
/// The <see cref="Byond.Version"/> the <see cref="CompileJob"/> was made with
/// The <see cref="ByondResponse.Version"/> the <see cref="CompileJobResponse"/> was made with.
/// </summary>
public Version? ByondVersion { get; set; }
@@ -0,0 +1,26 @@
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Response when reading configuration files.
/// </summary>
public sealed class ConfigurationFileResponse : FileTicketResponse, IConfigurationFile
{
/// <inheritdoc />
public string? Path { get; set; }
/// <inheritdoc />
[ResponseOptions]
public string? LastReadHash { get; set; }
/// <summary>
/// If <see cref="Path"/> represents a directory
/// </summary>
public bool? IsDirectory { get; set; }
/// <summary>
/// If access to the <see cref="IConfigurationFile"/> file was denied for the operation
/// </summary>
[ResponseOptions]
public bool? AccessDenied { get; set; }
}
}
@@ -0,0 +1,49 @@
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents an instance of BYOND's DreamDaemon game server. Create action starts the server. Delete action shuts down the server
/// </summary>
public sealed class DreamDaemonResponse : DreamDaemonApiBase
{
/// <summary>
/// The live revision.
/// </summary>
[ResponseOptions]
public CompileJobResponse? ActiveCompileJob { get; set; }
/// <summary>
/// The next revision to go live.
/// </summary>
[ResponseOptions]
public CompileJobResponse? StagedCompileJob { get; set; }
/// <summary>
/// The current <see cref="WatchdogStatus"/>.
/// </summary>
[EnumDataType(typeof(WatchdogStatus))]
[ResponseOptions]
public WatchdogStatus? Status { get; set; }
/// <summary>
/// The current <see cref="DreamDaemonSecurity"/> of <see cref="DreamDaemonResponse"/>. May be downgraded due to requirements of <see cref="ActiveCompileJob"/>
/// </summary>
[EnumDataType(typeof(DreamDaemonSecurity))]
[ResponseOptions]
public DreamDaemonSecurity? CurrentSecurity { get; set; }
/// <summary>
/// The port the running <see cref="DreamDaemonResponse"/> instance is set to
/// </summary>
[ResponseOptions]
public ushort? CurrentPort { get; set; }
/// <summary>
/// The webclient status the running <see cref="DreamDaemonResponse"/> instance is set to
/// </summary>
[ResponseOptions]
public bool? CurrentAllowWebclient { get; set; }
}
}
@@ -0,0 +1,11 @@
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// A request to the DreamMaker controller.
/// </summary>
public sealed class DreamMakerResponse : DreamMakerSettings
{
}
}
@@ -1,46 +1,45 @@
using System;
using System;
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents an error message returned by the server
/// </summary>
public sealed class ErrorMessage
public sealed class ErrorMessageResponse
{
/// <summary>
/// The version of the API the server is using
/// </summary>
[Required]
public Version? ServerApiVersion { get; set; }
/// <summary>
/// A human readable description of the error
/// </summary>
[Required]
public string? Message { get; set; }
/// <summary>
/// Additional data associated with the error message.
/// </summary>
[ResponseOptions]
public string? AdditionalData { get; set; }
/// <summary>
/// The <see cref="ErrorCode"/> of the <see cref="ErrorMessage"/>.
/// The <see cref="ErrorCode"/> of the <see cref="ErrorMessageResponse"/>.
/// </summary>
[EnumDataType(typeof(ErrorCode))]
public ErrorCode ErrorCode { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ErrorMessage"/> <see langword="class"/>.
/// Initializes a new instance of the <see cref="ErrorMessageResponse"/> <see langword="class"/>.
/// </summary>
public ErrorMessage() { }
public ErrorMessageResponse() { }
/// <summary>
/// Initializes a new instance of the <see cref="ErrorMessage"/> <see langword="class"/>.
/// Initializes a new instance of the <see cref="ErrorMessageResponse"/> <see langword="class"/>.
/// </summary>
/// <param name="errorCode">The <see cref="ErrorMessage"/>.</param>
public ErrorMessage(ErrorCode errorCode)
/// <param name="errorCode">The <see cref="ErrorMessageResponse"/>.</param>
public ErrorMessageResponse(ErrorCode errorCode)
{
ErrorCode = errorCode;
Message = errorCode.Describe();
@@ -1,13 +1,13 @@
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Response for when file transfers are necessary.
/// </summary>
public class FileTicketResult
public class FileTicketResponse
{
/// <summary>
/// The ticket to use to access the <see cref="Routes.Transfer"/> controller.
/// </summary>
public string? FileTicket { get; set; }
public virtual string? FileTicket { get; set; }
}
}
@@ -0,0 +1,11 @@
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// A response containing an instance permission set.
/// </summary>
public sealed class InstancePermissionSetResponse : InstancePermissionSet
{
}
}
@@ -0,0 +1,15 @@
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Server response for <see cref="Instance"/>s.
/// </summary>
public sealed class InstanceResponse : Instance
{
/// <summary>
/// The <see cref="JobResponse"/> representing a change of <see cref="Instance.Path"/>.
/// </summary>
/// <remarks>Due to how <see cref="JobResponse"/>s are children of <see cref="Instance"/>s but moving one requires the <see cref="Instance"/> to be offline, interactions with this <see cref="JobResponse"/> are performed in a non-standard fashion. The <see cref="JobResponse"/> is read by querying the <see cref="Instance"/> again (either via list or ID lookup) and cancelled by making any sort of update to the <see cref="Instance"/>. Once the <see cref="Instance"/> comes back <see cref="Instance.Online"/> it can be queried like a normal job.</remarks>
[ResponseOptions]
public JobResponse? MoveJob { get; set; }
}
}
@@ -0,0 +1,25 @@
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents a long running job on the server. Model is read-only, updates attempt to cancel the job
/// </summary>
public sealed class JobResponse : Internal.Job
{
/// <summary>
/// The <see cref="UserResponse"/> that started the job
/// </summary>
public UserName? StartedBy { get; set; }
/// <summary>
/// The <see cref="UserResponse"/> that cancelled the job
/// </summary>
[ResponseOptions]
public UserName? CancelledBy { get; set; }
/// <summary>
/// Optional progress between 0 and 100 inclusive
/// </summary>
[ResponseOptions]
public int? Progress { get; set; }
}
}
@@ -1,16 +1,16 @@
using System;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents a server log file.
/// </summary>
public sealed class LogFile : FileTicketResult
public sealed class LogFileResponse : FileTicketResponse
{
/// <summary>
/// The name of the log file.
/// </summary>
public string Name { get; set; } = String.Empty;
public string? Name { get; set; }
/// <summary>
/// The <see cref="DateTimeOffset"/> of when the log file was modified.
@@ -1,13 +1,13 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents a paginated set of models.
/// </summary>
/// <typeparam name="TModel">The <see cref="System.Type"/> of the returned model.</typeparam>
public sealed class Paginated<TModel>
public sealed class PaginatedResponse<TModel>
{
/// <summary>
/// The <see cref="ICollection{T}"/> of the returned <typeparamref name="TModel"/>s.
@@ -0,0 +1,41 @@
using System;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents a git repository
/// </summary>
public sealed class RepositoryResponse : RepositoryApiBase, IGitRemoteInformation
{
/// <summary>
/// The origin URL. If <see langword="null"/>, the git repository does not currently exist on the server.
/// </summary>
[ResponseOptions]
public Uri? Origin { get; set; }
/// <summary>
/// The current <see cref="Models.RevisionInformation"/>.
/// </summary>
[ResponseOptions]
public RevisionInformation? RevisionInformation { get; set; }
/// <inheritdoc />
[ResponseOptions]
public RemoteGitProvider? RemoteGitProvider { get; set; }
/// <inheritdoc />
[ResponseOptions]
public string? RemoteRepositoryOwner { get; set; }
/// <inheritdoc />
[ResponseOptions]
public string? RemoteRepositoryName { get; set; }
/// <summary>
/// The <see cref="JobResponse"/> started by the request, if any.
/// </summary>
[ResponseOptions]
public JobResponse? ActiveJob { get; set; }
}
}
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents basic server information.
/// </summary>
public sealed class ServerInformation : Internal.ServerInformation
public sealed class ServerInformationResponse : Internal.ServerInformationBase
{
/// <summary>
/// The version of the host
@@ -34,9 +34,10 @@ namespace Tgstation.Server.Api.Models
public bool UpdateInProgress { get; set; }
/// <summary>
/// A <see cref="ICollection{T}"/> of connected <see cref="SwarmServer"/>s.
/// A <see cref="ICollection{T}"/> of connected <see cref="SwarmServerResponse"/>s.
/// </summary>
public ICollection<SwarmServer>? SwarmServers { get; set; }
[ResponseOptions]
public ICollection<SwarmServerResponse>? SwarmServers { get; set; }
/// <summary>
/// Map of <see cref="OAuthProvider"/> to the <see cref="OAuthProviderInfo"/> for them.
@@ -0,0 +1,7 @@
namespace Tgstation.Server.Api.Models.Response
{
/// <inheritdoc />
public sealed class ServerUpdateResponse : ServerUpdate
{
}
}
@@ -0,0 +1,13 @@
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Response
{
/// <inheritdoc />
public sealed class SwarmServerResponse : SwarmServer
{
/// <summary>
/// If the <see cref="SwarmServerResponse"/> is the controller.
/// </summary>
public bool Controller { get; set; }
}
}
@@ -1,11 +1,11 @@
using System;
using System;
namespace Tgstation.Server.Api.Models
namespace Tgstation.Server.Api.Models.Response
{
/// <summary>
/// Represents a JWT returned by the API
/// </summary>
public sealed class Token
public sealed class TokenResponse
{
/// <summary>
/// The value of the JWT
@@ -13,7 +13,7 @@ namespace Tgstation.Server.Api.Models
public string? Bearer { get; set; }
/// <summary>
/// When the <see cref="Token"/> expires
/// When the <see cref="TokenResponse"/> expires
/// </summary>
public DateTimeOffset ExpiresAt { get; set; }
}
@@ -0,0 +1,14 @@
using System.Collections.Generic;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Response
{
/// <inheritdoc />
public sealed class UserGroupResponse : UserGroup
{
/// <summary>
/// The <see cref="NamedEntity"/>s the <see cref="UserGroupResponse"/> has.
/// </summary>
public ICollection<UserName>? Users { get; set; }
}
}
@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models.Response
{
/// <inheritdoc />
public class UserResponse : UserApiBase
{
/// <summary>
/// The <see cref="UserResponse"/> who created this <see cref="UserResponse"/>
/// </summary>
[Required]
public UserName? CreatedBy { get; set; }
}
}
@@ -0,0 +1,16 @@
using System;
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Indicates the response <see cref="FieldPresence"/> of API fields. Changes it from <see cref="FieldPresence.Required"/> to <see cref="FieldPresence.Optional"/> by default.
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class ResponseOptionsAttribute : Attribute
{
/// <summary>
/// The <see cref="FieldPresence"/>.
/// </summary>
public FieldPresence Presence { get; set; }
}
}
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace Tgstation.Server.Api.Models
{
@@ -8,6 +8,7 @@ namespace Tgstation.Server.Api.Models
/// <summary>
/// The <see cref="TestMerge"/> that was created with this <see cref="RevisionInformation"/>
/// </summary>
[ResponseOptions]
public TestMerge? PrimaryTestMerge { get; set; }
/// <summary>
@@ -16,7 +17,7 @@ namespace Tgstation.Server.Api.Models
public ICollection<TestMerge>? ActiveTestMerges { get; set; }
/// <summary>
/// The <see cref="CompileJob"/>s made from the <see cref="RevisionInformation"/>
/// The <see cref="Internal.CompileJob"/>s made from the <see cref="RevisionInformation"/>
/// </summary>
public ICollection<EntityId>? CompileJobs { get; set; }
}
@@ -0,0 +1,16 @@
using System;
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Represents a request to update TGS.
/// </summary>
public abstract class ServerUpdate
{
/// <summary>
/// Changes the version of tgstation-server to the given version from the upstream repository.
/// </summary>
[RequestOptions(FieldPresence.Required)]
public Version? NewVersion { get; set; }
}
}
@@ -1,11 +0,0 @@
namespace Tgstation.Server.Api.Models
{
/// <inheritdoc />
public sealed class SwarmServer : Internal.SwarmServer
{
/// <summary>
/// If the <see cref="SwarmServer"/> is the controller.
/// </summary>
public bool Controller { get; set; }
}
}
+7 -5
View File
@@ -1,11 +1,13 @@
namespace Tgstation.Server.Api.Models
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Api.Models
{
/// <inheritdoc />
public sealed class TestMerge : Internal.TestMerge
public sealed class TestMerge : TestMergeApiBase
{
/// <summary>
/// The <see cref="User"/> who created the <see cref="TestMerge"/>
/// The <see cref="NamedEntity"/> of the user who created the <see cref="TestMerge"/>.
/// </summary>
public User? MergedBy { get; set; }
public UserName? MergedBy { get; set; }
}
}
}
@@ -22,6 +22,7 @@ namespace Tgstation.Server.Api.Models
/// <summary>
/// Optional comment about the test
/// </summary>
[ResponseOptions]
[StringLength(Limits.MaximumStringLength)]
public string? Comment { get; set; }
}
-40
View File
@@ -1,40 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models
{
/// <inheritdoc />
public class User : Internal.User
{
/// <summary>
/// The name of the default admin user
/// </summary>
public static readonly string AdminName = "Admin";
/// <summary>
/// The default admin password
/// </summary>
public static readonly string DefaultAdminPassword = "ISolemlySwearToDeleteTheDataDirectory";
/// <summary>
/// The <see cref="User"/> who created this <see cref="User"/>
/// </summary>
[Required]
public Internal.UserBase? CreatedBy { get; set; }
/// <summary>
/// List of <see cref="OAuthConnection"/>s associated with the <see cref="User"/>.
/// </summary>
public ICollection<OAuthConnection>? OAuthConnections { get; set; }
/// <summary>
/// The <see cref="Models.PermissionSet"/> directly associated with the <see cref="User"/>.
/// </summary>
public PermissionSet? PermissionSet { get; set; }
/// <summary>
/// The <see cref="Internal.UserGroup"/> asociated with the <see cref="User"/>, if any.
/// </summary>
public Internal.UserGroup? Group { get; set; }
}
}
@@ -1,13 +0,0 @@
using System.Collections.Generic;
namespace Tgstation.Server.Api.Models
{
/// <inheritdoc />
public sealed class UserGroup : Internal.UserGroup
{
/// <summary>
/// The <see cref="User"/>s the <see cref="UserGroup"/> has.
/// </summary>
public ICollection<Internal.UserBase>? Users { get; set; }
}
}
@@ -0,0 +1,33 @@
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// Base class for user names.
/// </summary>
public class UserName : NamedEntity
{
/// <inheritdoc />
[RequestOptions(FieldPresence.Optional)]
public override string? Name
{
get => base.Name;
set => base.Name = value;
}
/// <summary>
/// Create a copy of the <see cref="UserName"/> as a given <typeparamref name="TResultType"/>.
/// </summary>
/// <typeparam name="TResultType">The child of <see cref="UserName"/> to create.</typeparam>
/// <returns>A new <typeparamref name="TResultType"/> copied from <see langword="this"/>.</returns>
protected virtual TResultType CreateUserName<TResultType>() where TResultType : UserName, new() => new TResultType
{
Id = Id,
Name = Name
};
/// <summary>
/// Create a copy of the <see cref="UserName"/>.
/// </summary>
/// <returns>A new <see cref="UserName"/> copied from <see langword="this"/>.</returns>
public UserName CreateUserName() => CreateUserName<UserName>();
}
}
@@ -1,16 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models
{
/// <summary>
/// For editing a given <see cref="User"/>. Will never be returned by the API
/// </summary>
public sealed class UserUpdate : User
{
/// <summary>
/// Cleartext password of the <see cref="User"/>
/// </summary>
[Required]
public string? Password { get; set; }
}
}
@@ -0,0 +1,34 @@
using System;
using System.Reflection;
namespace Tgstation.Server.Api.Properties
{
/// <summary>
/// Attribute for bringing in the HTTP API version from MSBuild.
/// </summary>
[AttributeUsage(AttributeTargets.Assembly)]
sealed class ApiVersionAttribute : Attribute
{
/// <summary>
/// Return the <see cref="Assembly"/>'s instance of the <see cref="ApiVersionAttribute"/>.
/// </summary>
public static ApiVersionAttribute Instance => Assembly
.GetExecutingAssembly()
.GetCustomAttribute<ApiVersionAttribute>();
/// <summary>
/// The <see cref="Version"/> <see cref="string"/> of the TGS API definition.
/// </summary>
public string RawApiVersion { get; }
/// <summary>
/// Initializes a new instance of the <see cref="ApiVersionAttribute"/> <see langword="class"/>.
/// </summary>
/// <param name="rawApiVersion">The value of <see cref="RawApiVersion"/>.</param>
public ApiVersionAttribute(
string rawApiVersion)
{
RawApiVersion = rawApiVersion ?? throw new ArgumentNullException(nameof(rawApiVersion));
}
}
}
@@ -3,7 +3,7 @@ using System;
namespace Tgstation.Server.Api.Rights
{
/// <summary>
/// Rights for <see cref="Models.Administration"/>
/// Administration rights for the server.
/// </summary>
[Flags]
public enum AdministrationRights : ulong
@@ -14,7 +14,7 @@ namespace Tgstation.Server.Api.Rights
None = 0,
/// <summary>
/// User has complete control over creating/editing <see cref="Models.User"/>s and <see cref="Models.UserGroup"/>s (and deleting in the case of the latter).
/// User has complete control over creating/editing <see cref="Models.Response.UserResponse"/>s and <see cref="Models.Response.UserGroupResponse"/>s (and deleting in the case of the latter).
/// </summary>
WriteUsers = 1,
@@ -24,7 +24,7 @@ namespace Tgstation.Server.Api.Rights
RestartHost = 2,
/// <summary>
/// User can read <see cref="Models.Administration"/> and upgrade/downgrade TGS through the API.
/// User can read <see cref="Models.Response.AdministrationResponse"/> and upgrade/downgrade TGS through the API.
/// </summary>
ChangeVersion = 4,
@@ -39,12 +39,12 @@ namespace Tgstation.Server.Api.Rights
ReadUsers = 16,
/// <summary>
/// User can list and download <see cref="Models.LogFile"/>s.
/// User can list and download <see cref="Models.Response.LogFileResponse"/>s.
/// </summary>
DownloadLogs = 32,
/// <summary>
/// User can modify their own <see cref="Models.User.OAuthConnections"/>.
/// User can modify their own <see cref="Models.Internal.UserApiBase.OAuthConnections"/>.
/// </summary>
EditOwnOAuthConnections = 64,
}
@@ -3,7 +3,7 @@ using System;
namespace Tgstation.Server.Api.Rights
{
/// <summary>
/// Rights for <see cref="Models.Byond"/>
/// Rights for BYOND version management.
/// </summary>
[Flags]
public enum ByondRights : ulong
@@ -3,7 +3,7 @@ using System;
namespace Tgstation.Server.Api.Rights
{
/// <summary>
/// Rights for <see cref="Models.ChatBot"/>
/// Rights for chat bots.
/// </summary>
[Flags]
public enum ChatBotRights : ulong
@@ -14,57 +14,57 @@ namespace Tgstation.Server.Api.Rights
None = 0,
/// <summary>
/// User can change <see cref="Models.Internal.ChatBot.Enabled"/>.
/// User can change <see cref="Models.Internal.ChatBotSettings.Enabled"/>.
/// </summary>
WriteEnabled = 1,
/// <summary>
/// User can change <see cref="Models.Internal.ChatBot.Provider"/>.
/// User can change <see cref="Models.Internal.ChatBotSettings.Provider"/>.
/// </summary>
WriteProvider = 2,
/// <summary>
/// User can change <see cref="Models.ChatBot.Channels"/>.
/// User can change <see cref="Models.Internal.ChatBotApiBase.Channels"/>.
/// </summary>
WriteChannels = 4,
/// <summary>
/// User can change <see cref="Models.Internal.ChatBot.ConnectionString"/>
/// User can change <see cref="Models.Internal.ChatBotSettings.ConnectionString"/>
/// </summary>
WriteConnectionString = 8,
/// <summary>
/// User can read <see cref="Models.Internal.ChatBot.ConnectionString"/> requires the <see cref="Read"/> permission.
/// User can read <see cref="Models.Internal.ChatBotSettings.ConnectionString"/> requires the <see cref="Read"/> permission.
/// </summary>
ReadConnectionString = 16,
/// <summary>
/// User can read all <see cref="Models.ChatBot"/> properties except <see cref="Models.Internal.ChatBot.ConnectionString"/>
/// User can read all chat bot properties except <see cref="Models.Internal.ChatBotSettings.ConnectionString"/>
/// </summary>
Read = 32,
/// <summary>
/// User can create new <see cref="Models.ChatBot"/>s.
/// User can create new chat bots.
/// </summary>
Create = 64,
/// <summary>
/// User can delete <see cref="Models.ChatBot"/>s.
/// User can delete chat bots.
/// </summary>
Delete = 128,
/// <summary>
/// User can change <see cref="Models.Internal.ChatBot.Name"/>.
/// User can change <see cref="Models.NamedEntity.Name"/>.
/// </summary>
WriteName = 256,
/// <summary>
/// User can change <see cref="Models.Internal.ChatBot.ReconnectionInterval"/>.
/// User can change <see cref="Models.Internal.ChatBotSettings.ReconnectionInterval"/>.
/// </summary>
WriteReconnectionInterval = 512,
/// <summary>
/// User can change <see cref="Models.Internal.ChatBot.ChannelLimit"/>.
/// User can change <see cref="Models.Internal.ChatBotSettings.ChannelLimit"/>.
/// </summary>
WriteChannelLimit = 1024,
}
@@ -3,7 +3,7 @@ using System;
namespace Tgstation.Server.Api.Rights
{
/// <summary>
/// Rights for <see cref="Models.ConfigurationFile"/>
/// Rights for <see cref="Models.IConfigurationFile"/>s.
/// </summary>
[Flags]
public enum ConfigurationRights : ulong
@@ -3,7 +3,7 @@ using System;
namespace Tgstation.Server.Api.Rights
{
/// <summary>
/// Rights for <see cref="Models.DreamDaemon"/>
/// Rights for managing DreamDaemon.
/// </summary>
[Flags]
public enum DreamDaemonRights : ulong
@@ -14,7 +14,7 @@ namespace Tgstation.Server.Api.Rights
None = 0,
/// <summary>
/// User can read <see cref="Models.DreamDaemon.ActiveCompileJob"/> and <see cref="Models.DreamDaemon.StagedCompileJob"/>
/// User can read <see cref="Models.Response.DreamDaemonResponse.ActiveCompileJob"/> and <see cref="Models.Response.DreamDaemonResponse.StagedCompileJob"/>
/// </summary>
ReadRevision = 1,
@@ -34,7 +34,7 @@ namespace Tgstation.Server.Api.Rights
SetSecurity = 8,
/// <summary>
/// User can read every propery of <see cref="Models.DreamDaemon"/> except <see cref="Models.DreamDaemon.ActiveCompileJob"/> and <see cref="Models.DreamDaemon.StagedCompileJob"/>.
/// User can read every property of <see cref="Models.Response.DreamDaemonResponse"/> except <see cref="Models.Response.DreamDaemonResponse.ActiveCompileJob"/> and <see cref="Models.Response.DreamDaemonResponse.StagedCompileJob"/>.
/// </summary>
ReadMetadata = 16,
@@ -44,12 +44,12 @@ namespace Tgstation.Server.Api.Rights
SetWebClient = 32,
/// <summary>
/// User can change <see cref="Models.DreamDaemon.SoftRestart"/>.
/// User can change <see cref="Models.Internal.DreamDaemonApiBase.SoftRestart"/>.
/// </summary>
SoftRestart = 64,
/// <summary>
/// User can change <see cref="Models.DreamDaemon.SoftShutdown"/>.
/// User can change <see cref="Models.Internal.DreamDaemonApiBase.SoftShutdown"/>.
/// </summary>
SoftShutdown = 128,
@@ -3,7 +3,7 @@ using System;
namespace Tgstation.Server.Api.Rights
{
/// <summary>
/// Rights for <see cref="Models.DreamMaker"/>
/// Rights for deployment.
/// </summary>
[Flags]
public enum DreamMakerRights : ulong
@@ -14,7 +14,7 @@ namespace Tgstation.Server.Api.Rights
None = 0,
/// <summary>
/// User may read all properties of <see cref="Models.DreamMaker"/>.
/// User may read all properties of <see cref="Models.Internal.DreamMakerSettings"/>.
/// </summary>
Read = 1,
@@ -29,27 +29,27 @@ namespace Tgstation.Server.Api.Rights
CancelCompile = 4,
/// <summary>
/// User may modify <see cref="Models.DreamMaker.ProjectName"/>.
/// User may modify <see cref="Models.Internal.DreamMakerSettings.ProjectName"/>.
/// </summary>
SetDme = 8,
/// <summary>
/// User may modify <see cref="Models.DreamMaker.ApiValidationPort"/>.
/// User may modify <see cref="Models.Internal.DreamMakerSettings.ApiValidationPort"/>.
/// </summary>
SetApiValidationPort = 16,
/// <summary>
/// User may list and read all <see cref="Models.CompileJob"/>s.
/// User may list and read all <see cref="Models.Internal.CompileJob"/>s.
/// </summary>
CompileJobs = 32,
/// <summary>
/// User may modify <see cref="Models.DreamMaker.ApiValidationSecurityLevel"/>.
/// User may modify <see cref="Models.Internal.DreamMakerSettings.ApiValidationSecurityLevel"/>.
/// </summary>
SetSecurityLevel = 64,
/// <summary>
/// User may modify <see cref="Models.DreamMaker.RequireDMApiValidation"/>.
/// User may modify <see cref="Models.Internal.DreamMakerSettings.RequireDMApiValidation"/>.
/// </summary>
SetApiValidationRequirement = 128,
}
@@ -14,7 +14,7 @@ namespace Tgstation.Server.Api.Rights
None = 0,
/// <summary>
/// User can view <see cref="Models.Instance"/>s which they have an <see cref="Models.InstancePermissionSet"/> for.
/// User can view <see cref="Models.Instance"/>s which they have an <see cref="Models.Internal.InstancePermissionSet"/> for.
/// </summary>
Read = 1,
@@ -64,7 +64,7 @@ namespace Tgstation.Server.Api.Rights
SetChatBotLimit = 512,
/// <summary>
/// User can give themselves or their group full <see cref="Models.InstancePermissionSet"/> rights on ALL instances.
/// User can give themselves or their group full <see cref="InstancePermissionSetRights"/> on ALL instances.
/// </summary>
GrantPermissions = 1024,
}
@@ -14,17 +14,17 @@ namespace Tgstation.Server.Api.Rights
None = 0,
/// <summary>
/// Allow read access to all <see cref="Models.InstancePermissionSet"/>s in the <see cref="Models.Instance"/>.
/// Allow read access to all <see cref="Models.Internal.InstancePermissionSet"/>s in the <see cref="Models.Instance"/>.
/// </summary>
Read = 1,
/// <summary>
/// Allow write and delete access to all <see cref="Models.InstancePermissionSet"/> for the <see cref="Models.Instance"/>.
/// Allow write and delete access to all <see cref="Models.Internal.InstancePermissionSet"/> for the <see cref="Models.Instance"/>.
/// </summary>
Write = 2,
/// <summary>
/// Allow adding additional <see cref="Models.InstancePermissionSet"/>s to the <see cref="Models.Instance"/>.
/// Allow adding additional <see cref="Models.Internal.InstancePermissionSet"/>s to the <see cref="Models.Instance"/>.
/// </summary>
Create = 4
}
@@ -3,7 +3,7 @@ using System;
namespace Tgstation.Server.Api.Rights
{
/// <summary>
/// Rights for a <see cref="Models.Repository"/>
/// Rights for the git repository.
/// </summary>
[Flags]
public enum RepositoryRights : ulong
@@ -19,12 +19,12 @@ namespace Tgstation.Server.Api.Rights
CancelPendingChanges = 1,
/// <summary>
/// User may clone the <see cref="Models.Repository"/> if it does not exist.
/// User may clone the repository if it does not exist.
/// </summary>
SetOrigin = 2,
/// <summary>
/// User may directly checkout a git SHA that the <see cref="Models.Repository"/>'s HEAD will point to.
/// User may directly checkout a git SHA that the repository's HEAD will point to.
/// </summary>
SetSha = 4,
@@ -54,12 +54,12 @@ namespace Tgstation.Server.Api.Rights
ChangeCredentials = 128,
/// <summary>
/// User may set <see cref="Models.Repository.Reference"/> to another git branch or tag (not a SHA).
/// User may set <see cref="Models.Internal.RepositoryApiBase.Reference"/> to another git branch or tag (not a SHA).
/// </summary>
SetReference = 256,
/// <summary>
/// User may read all fields in the <see cref="Models.Repository"/> with the exception of <see cref="Models.Internal.RepositorySettings.AccessToken"/>.
/// User may read repository information.
/// </summary>
Read = 512,
@@ -69,7 +69,7 @@ namespace Tgstation.Server.Api.Rights
ChangeAutoUpdateSettings = 1024,
/// <summary>
/// User may delete the <see cref="Models.Repository"/> and allow it to be cloned again.
/// User may delete the repository and allow it to be cloned again.
/// </summary>
Delete = 2048,
+25 -25
View File
@@ -14,44 +14,44 @@ namespace Tgstation.Server.Api
public const string Root = "/";
/// <summary>
/// The <see cref="Models.Administration"/> controller
/// The server administration controller.
/// </summary>
public const string Administration = Root + nameof(Models.Administration);
public const string Administration = Root + "Administration";
/// <summary>
/// The <see cref="Models.Administration"/> controller
/// The endpoint to download server logs.
/// </summary>
public const string Logs = Administration + "/Logs";
/// <summary>
/// The <see cref="Models.User"/> controller
/// The user controller.
/// </summary>
public const string User = Root + nameof(Models.User);
public const string User = Root + "User";
/// <summary>
/// The <see cref="Models.UserGroup"/> controller.
/// The user group controller.
/// </summary>
public const string UserGroup = Root + nameof(Models.UserGroup);
public const string UserGroup = Root + "UserGroup";
/// <summary>
/// The <see cref="Models.Instance"/> controller
/// The <see cref="Models.Instance"/> controller.
/// </summary>
public const string InstanceManager = Root + nameof(Models.Instance);
public const string InstanceManager = Root + "Instance";
/// <summary>
/// The <see cref="Models.Byond"/> controller
/// The BYOND controller.
/// </summary>
public const string Byond = Root + nameof(Models.Byond);
public const string Byond = Root + "Byond";
/// <summary>
/// The <see cref="Models.Repository"/> controller
/// The git repository controller.
/// </summary>
public const string Repository = Root + nameof(Models.Repository);
public const string Repository = Root + "Repository";
/// <summary>
/// The <see cref="Models.DreamDaemon"/> controller
/// The DreamDaemon controller
/// </summary>
public const string DreamDaemon = Root + nameof(Models.DreamDaemon);
public const string DreamDaemon = Root + "DreamDaemon";
/// <summary>
/// For accessing DD diagnostics
@@ -59,12 +59,12 @@ namespace Tgstation.Server.Api
public const string Diagnostics = DreamDaemon + "/Diagnostics";
/// <summary>
/// The <see cref="Models.ConfigurationFile"/> controller
/// The configuration controller
/// </summary>
public const string Configuration = Root + "Config";
/// <summary>
/// To be paired with <see cref="Configuration"/> for accessing <see cref="Models.ConfigurationFile"/>s
/// To be paired with <see cref="Configuration"/> for accessing <see cref="Models.IConfigurationFile"/>s.
/// </summary>
public const string File = "File";
@@ -74,24 +74,24 @@ namespace Tgstation.Server.Api
public const string ConfigurationFile = Configuration + "/" + File;
/// <summary>
/// The <see cref="Models.InstancePermissionSet"/> controller
/// The instance permission set controller.
/// </summary>
public const string InstancePermissionSet = Root + nameof(Models.InstancePermissionSet);
public const string InstancePermissionSet = Root + "InstancePermissionSet";
/// <summary>
/// The <see cref="Models.ChatBot"/> controller
/// The chat bot controller
/// </summary>
public const string Chat = Root + "Chat";
/// <summary>
/// The <see cref="Models.DreamMaker"/> controller
/// The deployment controller
/// </summary>
public const string DreamMaker = Root + nameof(Models.DreamMaker);
public const string DreamMaker = Root + "DreamMaker";
/// <summary>
/// The <see cref="Models.Job"/> controller
/// The jobs controller
/// </summary>
public const string Jobs = Root + nameof(Models.Job);
public const string Jobs = Root + "Job";
/// <summary>
/// The transfer controller.
@@ -119,7 +119,7 @@ namespace Tgstation.Server.Api
public static string ListRoute(string route) => String.Format(CultureInfo.InvariantCulture, "{0}/{1}", route, List);
/// <summary>
/// Sanitize a <see cref="Models.FileTicketResult"/> path for use in a GET <see cref="Uri"/>.
/// Sanitize a <see cref="Models.Response.FileTicketResponse"/> path for use in a GET <see cref="Uri"/>.
/// </summary>
/// <param name="path">The path to sanitize.</param>
/// <returns>The sanitized path.</returns>
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../../build/Version.props" />
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<DebugType>Full</DebugType>
<Version>$(TgsApiVersion)</Version>
<Version>$(TgsApiLibraryVersion)</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Cyberboss</Authors>
<Company>/tg/station 13</Company>
@@ -32,6 +32,19 @@
<WarningsAsErrors />
</PropertyGroup>
<Target Name="ApplyApiVersionAttribute" BeforeTargets="CoreCompile">
<ItemGroup>
<AssemblyAttributes Include="Tgstation.Server.Api.Properties.ApiVersionAttribute">
<_Parameter1>$(TgsApiVersion)</_Parameter1>
</AssemblyAttributes>
</ItemGroup>
<WriteCodeFragment AssemblyAttributes="@(AssemblyAttributes)" Language="C#" OutputDirectory="$(IntermediateOutputPath)" OutputFile="ApiVersionAssemblyInfo.cs">
<Output TaskParameter="OutputFile" ItemName="Compile" />
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
</WriteCodeFragment>
</Target>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.2.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.1">
@@ -5,7 +5,8 @@ using System.Threading;
using System.Threading.Tasks;
using System.Web;
using Tgstation.Server.Api;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Models.Request;
using Tgstation.Server.Api.Models.Response;
namespace Tgstation.Server.Client
{
@@ -21,22 +22,22 @@ namespace Tgstation.Server.Client
{ }
/// <inheritdoc />
public Task<Administration> Read(CancellationToken cancellationToken) => ApiClient.Read<Administration>(Routes.Administration, cancellationToken);
public Task<AdministrationResponse> Read(CancellationToken cancellationToken) => ApiClient.Read<AdministrationResponse>(Routes.Administration, cancellationToken);
/// <inheritdoc />
public Task Update(Administration administration, CancellationToken cancellationToken) => ApiClient.Update(Routes.Administration, administration ?? throw new ArgumentNullException(nameof(administration)), cancellationToken);
public Task<ServerUpdateResponse> Update(ServerUpdateRequest updateRequest, CancellationToken cancellationToken) => ApiClient.Update<ServerUpdateRequest, ServerUpdateResponse>(Routes.Administration, updateRequest ?? throw new ArgumentNullException(nameof(updateRequest)), cancellationToken);
/// <inheritdoc />
public Task Restart(CancellationToken cancellationToken) => ApiClient.Delete(Routes.Administration, cancellationToken);
/// <inheritdoc />
public Task<IReadOnlyList<LogFile>> ListLogs(PaginationSettings? paginationSettings, CancellationToken cancellationToken)
=> ReadPaged<LogFile>(paginationSettings, Routes.Logs, null, cancellationToken);
public Task<IReadOnlyList<LogFileResponse>> ListLogs(PaginationSettings? paginationSettings, CancellationToken cancellationToken)
=> ReadPaged<LogFileResponse>(paginationSettings, Routes.Logs, null, cancellationToken);
/// <inheritdoc />
public async Task<Tuple<LogFile, Stream>> GetLog(LogFile logFile, CancellationToken cancellationToken)
public async Task<Tuple<LogFileResponse, Stream>> GetLog(LogFileResponse logFile, CancellationToken cancellationToken)
{
var resultFile = await ApiClient.Read<LogFile>(
var resultFile = await ApiClient.Read<LogFileResponse>(
Routes.Logs + Routes.SanitizeGetPath(
HttpUtility.UrlEncode(
logFile?.Name ?? throw new ArgumentNullException(nameof(logFile)))),

Some files were not shown because too many files have changed in this diff Show More