42#pragma warning disable CA1506
115 authenticationContext,
166 .Select(
x =>
new Models.Instance
244 AdditionalData = e.Message,
249 "{userName} {attachedOrCreated} instance {instanceName}: {instanceId} ({instancePath})",
262 return attached ? Json(api) : this.Created(api);
310 .Where(
x =>
x.Job!.Instance!.Id ==
id)
315 .Where(
x =>
x.RevisionInformation.InstanceId ==
id)
320 .Where(
x =>
x.InstanceId ==
id)
357#pragma warning disable CA1502
368 .SelectMany(
x =>
x.Jobs)
369 .Where(
x => !
x.StoppedAt.HasValue &&
x.JobCode ==
JobCode.Move)
370 .Select(
x =>
new Job(
x.Id!.Value))
382 .Include(
x =>
x.RepositorySettings)
383 .Include(
x =>
x.ChatSettings)
384 .ThenInclude(
x =>
x.Channels)
385 .Include(
x =>
x.DreamDaemonSettings)
412 if (
model.Path !=
null)
459 if (
model.ChatBotLimit.HasValue)
506 Logger.LogError(
e,
"Error changing instance online state!");
525 var description =
$"Move instance ID {originalModel.Id} from {originalModelPath} to {normalizedPath}";
564 return moving ? Accepted(api) : Json(api);
566#pragma warning restore CA1502
606 .SelectMany(
x =>
x.Jobs)
607 .Where(
x => !
x.StoppedAt.HasValue &&
x.JobCode ==
JobCode.Move)
608 .Include(
x =>
x.StartedBy!)
609 .ThenInclude(
x =>
x.CreatedBy)
610 .Include(
x =>
x.Instance)
664 if (instance ==
null)
680 var api = instance.ToApi();
683 .SelectMany(
x =>
x.Jobs)
684 .Where(
x => !
x.StoppedAt.HasValue &&
x.JobCode ==
JobCode.Move)
685 .Include(
x =>
x.StartedBy!)
686 .ThenInclude(
x =>
x.CreatedBy)
687 .Include(
x =>
x.Instance)
714 .SelectMany(
x =>
x.InstancePermissionSets)
773 AllowWebClient =
false,
776 OpenDreamTopicPort = 0,
780 HealthCheckSeconds = 60,
781 DumpOnHealthCheckRestart =
false,
783 AdditionalParameters =
String.Empty,
784 StartProfiler =
false,
791 ApiValidationPort =
dmPort,
795 CompilerAdditionalArguments =
null,
807 CommitterEmail = Components.Repository.Repository.DefaultCommitterEmail,
808 CommitterName = Components.Repository.Repository.DefaultCommitterName,
809 PushTestMergeCommits =
false,
810 ShowTestMergeCommitters =
false,
811 AutoUpdatesKeepTestMerges =
false,
812 AutoUpdatesSynchronize =
false,
813 PostTestMergeComment =
false,
814 CreateGitHubDeployments =
false,
815 UpdateSubmodules =
true,
886 if (!
String.IsNullOrWhiteSpace(instance.AutoUpdateCron))
888 if ((instance.AutoUpdateInterval.HasValue && instance.AutoUpdateInterval.Value != 0)
890 instance.AutoUpdateCron,
893 IncludingSeconds = true,
string? Identifier
The server's identifier.
Represents a set of server permissions.
InstanceManagerRights? InstanceManagerRights
The Rights.InstanceManagerRights for the user.
Represents configurable settings for a git repository.
A request to create an Instance.
A request to update an Instance.
Represents an error message returned by the server.
Server response for Instances.
Represents a paginated set of models.
Routes to a server actions.
const string InstanceManager
The Models.Instance controller.
const string List
The postfix for list operations.
Extension methods for the ValueTask and ValueTask<TResult> classes.
static async ValueTask WhenAll(IEnumerable< ValueTask > tasks)
Fully await a given list of tasks .
General configuration options.
uint ByondTopicTimeout
The timeout in milliseconds for sending and receiving topics to/from DreamDaemon. Note that a single ...
Configuration for the server swarm system.
ILogger< ApiController > Logger
The ILogger for the ApiController.
ApiController for operations on IInstanceCores.
async ValueTask< IActionResult?> WithComponentInstanceNullable(Func< IInstanceCore, ValueTask< IActionResult?> > action, Models.Instance? instance=null)
Run a given action with the relevant IInstance.
IInstanceOperations InstanceOperations
Access the IInstanceOperations instance.
readonly IInstanceManager instanceManager
The IInstanceManager for the ComponentInterfacingController.
bool ValidateInstanceOnlineStatus(Api.Models.Instance metadata)
Corrects discrepencies between the Api.Models.Instance.Online status of IInstances in the database vs...
ApiController for managing Components.Instances.
async ValueTask< Models.Instance?> CreateDefaultInstance(InstanceCreateRequest initialSettings, CancellationToken cancellationToken)
Creates a default Models.Instance from initialSettings .
async ValueTask< IActionResult > GetId(long id, CancellationToken cancellationToken)
Get a specific Api.Models.Instance.
InstanceController(IDatabaseContext databaseContext, IAuthenticationContext authenticationContext, ILogger< InstanceController > logger, IInstanceManager instanceManager, IJobManager jobManager, IIOManager ioManager, IPlatformIdentifier platformIdentifier, IPortAllocator portAllocator, IPermissionsUpdateNotifyee permissionsUpdateNotifyee, IOptions< GeneralConfiguration > generalConfigurationOptions, IOptions< SwarmConfiguration > swarmConfigurationOptions, IApiHeadersProvider apiHeaders)
Initializes a new instance of the InstanceController class.
readonly IJobManager jobManager
The IJobManager for the InstanceController.
readonly GeneralConfiguration generalConfiguration
The GeneralConfiguration for the InstanceController.
BadRequestObjectResult? ValidateCronSetting(Api.Models.Instance instance)
Validates a given instance 's Api.Models.Instance.AutoUpdateCron setting.
string? NormalizePath(string? path)
Normalize a given path for an instance.
readonly IPortAllocator portAllocator
The IPortAllocator for the InstanceController.
async ValueTask< IActionResult > Update([FromBody] InstanceUpdateRequest model, CancellationToken cancellationToken)
Modify an Api.Models.Instance's settings.
InstancePermissionSet InstanceAdminPermissionSet(InstancePermissionSet? permissionSetToModify)
Generate an InstancePermissionSet with full rights.
readonly SwarmConfiguration swarmConfiguration
The SwarmConfiguration for the InstanceController.
async ValueTask< IActionResult > List([FromQuery] int? page, [FromQuery] int? pageSize, CancellationToken cancellationToken)
List Api.Models.Instances.
const string InstanceAttachFileName
File name to allow attaching instances.
async ValueTask< IActionResult > Create([FromBody] InstanceCreateRequest model, CancellationToken cancellationToken)
Create or attach an Api.Models.Instance.
readonly IPlatformIdentifier platformIdentifier
The IPlatformIdentifier for the InstanceController.
readonly IPermissionsUpdateNotifyee permissionsUpdateNotifyee
The IPermissionsUpdateNotifyee for the InstanceController.
async ValueTask< IActionResult > Delete(long id, CancellationToken cancellationToken)
Detach an Api.Models.Instance with the given id .
async ValueTask CheckAccessible(InstanceResponse instanceResponse, CancellationToken cancellationToken)
Populate the InstanceResponse.Accessible property of a given instanceResponse .
readonly IIOManager ioManager
The IIOManager for the InstanceController.
async ValueTask< IActionResult > GrantPermissions(long id, CancellationToken cancellationToken)
Gives the current user full permissions on a given instance id .
Helper for returning paginated models.
Backend abstract implementation of IDatabaseContext.
DbSet< Instance > Instances
The Instances in the DatabaseContext.
DbSet< InstancePermissionSet > InstancePermissionSets
The InstancePermissionSets in the DatabaseContext.
DbSet< CompileJob > CompileJobs
The CompileJobs in the DatabaseContext.
Task Save(CancellationToken cancellationToken)
Saves changes made to the IDatabaseContext.A Task representing the running operation.
DbSet< ChatBot > ChatBots
The ChatBots in the DatabaseContext.
DbSet< RevInfoTestMerge > RevInfoTestMerges
The RevInfoTestMerges in the DatabaseContext.
DbSet< RevisionInformation > RevisionInformations
The RevisionInformations in the DatabaseContext.
IIOManager that resolves paths to Environment.CurrentDirectory.
const string CurrentDirectory
Path to the current working directory for the IIOManager.
Instance? Instance
The parent Models.Instance.
Represents an Api.Models.Instance in the database.
const ushort DefaultChatBotLimit
Default for Api.Models.Instance.ChatBotLimit.
static Job Create(JobCode code, User? startedBy, Api.Models.Instance instance)
Creates a new job for registering in the Jobs.IJobService.
User User
The authenticated user.
PermissionSet PermissionSet
The User's effective PermissionSet.
ulong GetRight(RightsType rightsType)
Get the value of a given rightsType .The value of rightsType . Note that if InstancePermissionSet is ...
ValueTask OnlineInstance(Models.Instance metadata, CancellationToken cancellationToken)
Online an IInstance.
ValueTask MoveInstance(Models.Instance metadata, string oldPath, CancellationToken cancellationToken)
Move an IInstance.
ValueTask OfflineInstance(Models.Instance metadata, User user, CancellationToken cancellationToken)
Offline an IInstance.
Interface for using filesystems.
Task< IReadOnlyList< string > > GetFiles(string path, CancellationToken cancellationToken)
Returns full file names in a given path .
Task< bool > PathIsChildOf(string parentPath, string childPath, CancellationToken cancellationToken)
Check if a given parentPath is a parent of a given parentPath .
string ResolvePath()
Retrieve the full path of the current working directory.
string ConcatPath(params string[] paths)
Combines an array of strings into a path.
Task< IReadOnlyList< string > > GetDirectories(string path, CancellationToken cancellationToken)
Returns full directory names in a given path .
Task CreateDirectory(string path, CancellationToken cancellationToken)
Create a directory at path .
Task DeleteFile(string path, CancellationToken cancellationToken)
Deletes a file at path .
ValueTask WriteAllBytes(string path, byte[] contents, CancellationToken cancellationToken)
Writes some contents to a file at path overwriting previous content.
Task< bool > FileExists(string path, CancellationToken cancellationToken)
Check that the file at path exists.
Task< bool > DirectoryExists(string path, CancellationToken cancellationToken)
Check that the directory at path exists.
Manages the runtime of Jobs.
ValueTask< Job?> CancelJob(Job job, User? user, bool blocking, CancellationToken cancellationToken)
Cancels a give job .
ValueTask RegisterOperation(Job job, JobEntrypoint operation, CancellationToken cancellationToken)
Registers a given Job and begins running it.
For creating and accessing authentication contexts.
Receives notifications about permissions updates.
ValueTask InstancePermissionSetCreated(InstancePermissionSet instancePermissionSet, CancellationToken cancellationToken)
Called when a given instancePermissionSet is successfully created.
Gets unassigned ports for use by TGS.
ValueTask< ushort?> GetAvailablePort(ushort basePort, bool checkOne, CancellationToken cancellationToken)
Gets a port not currently in use by TGS.
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.
DreamDaemonVisibility
The visibility setting for DreamDaemon.
JobCode
The different types of Response.JobResponse.
ConfigurationType
The type of configuration allowed on an Instance.
@ Online
The watchdog is online and DreamDaemon is running.
DreamDaemonSecurity
DreamDaemon's security level.
DMApiValidationMode
The DMAPI validation setting for deployments.
ChatBotRights
Rights for chat bots.
ConfigurationRights
Rights for Models.IConfigurationFiles.
@ List
User may list files if the Models.Instance allows it.
DreamMakerRights
Rights for deployment.
RightsType
The type of rights a model uses.
EngineRights
Rights for engine version management.
RepositoryRights
Rights for the git repository.
InstancePermissionSetRights
Rights for an Models.Instance.
DreamDaemonRights
Rights for managing DreamDaemon.
InstanceManagerRights
Rights for managing Models.Instances.
@ Api
The ApiHeaders.ApiVersionHeader header is missing or invalid.