// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Text.Json.Serialization;
#pragma warning disable CA1056 // Change string to URI
namespace EpicGames.Horde.Server
{
///
/// Server Info
///
public class GetServerInfoResponse
{
///
/// Current API version number of the server
///
[JsonConverter(typeof(HordeApiVersionConverter))]
public HordeApiVersion ApiVersion { get; set; }
///
/// Server version info
///
public string ServerVersion { get; set; } = String.Empty;
///
/// The current agent version string
///
public string? AgentVersion { get; set; }
///
/// List of plugins
///
public ServerPluginInfoResponse[] Plugins { get; set; } = Array.Empty();
}
///
/// Gets connection information to the server
///
public class GetConnectionResponse
{
///
/// Public IP address of the remote machine
///
public string? Ip { get; set; }
///
/// Public port of the connecting machine
///
public int Port { get; set; }
}
///
/// Gets ports configured for this server
///
public class GetPortsResponse
{
///
/// Port for HTTP communication
///
public int? Http { get; set; }
///
/// Port number for HTTPS communication
///
public int? Https { get; set; }
///
/// Port number for unencrpyted HTTPS communication
///
public int? UnencryptedHttp2 { get; set; }
}
///
/// Authentication method used for logging users in
///
public enum AuthMethod
{
///
/// No authentication enabled. *Only* for demo and testing purposes.
///
Anonymous,
///
/// OpenID Connect authentication, tailored for Okta
///
Okta,
///
/// Generic OpenID Connect authentication, recommended for most
///
OpenIdConnect,
///
/// Authenticate using username and password credentials stored in Horde
/// OpenID Connect (OIDC) is first and foremost recommended.
/// But if you have a small installation (less than ~10 users) or lacking an OIDC provider, this is an option.
///
Horde,
}
///
/// Describes the auth config for this server
///
public class GetAuthConfigResponse
{
///
/// Issuer for tokens from the auth provider
///
public AuthMethod Method { get; set; }
///
/// Optional profile name used by OidcToken
///
public string? ProfileName { get; set; }
///
/// Issuer for tokens from the auth provider
///
public string? ServerUrl { get; set; }
///
/// Client id for the OIDC authority
///
public string? ClientId { get; set; }
///
/// Optional redirect url provided to OIDC login for external tools (typically to a local server)
///
public string[]? LocalRedirectUrls { get; set; }
///
/// Optional OIDC scopes for authorizing API requests from external tools
///
public string[]? Scopes { get; set; }
}
///
/// Request to validate server configuration with the given files replacing their checked-in counterparts.
///
public class PreflightConfigRequest
{
///
/// Perforce cluster to retrieve from
///
public string? Cluster { get; set; }
///
/// Change to test
///
public int ShelvedChange { get; set; }
}
///
/// Response from validating config files
///
public class PreflightConfigResponse
{
///
/// Whether the files were validated successfully
///
public bool Result { get; set; }
///
/// Output message from validation
///
public string? Message { get; set; }
///
/// Detailed response
///
public string? Detail { get; set; }
}
///
/// Status for a subsystem within Horde
///
public class ServerStatusSubsystem
{
///
/// Name of the subsystem
///
public string Name { get; init; } = "";
///
/// List of updates
///
public ServerStatusUpdate[] Updates { get; set; } = Array.Empty();
}
///
/// Type of status result for a single update
///
public enum ServerStatusResult
{
///
/// Indicates that the health check determined that the subsystem was unhealthy
///
Unhealthy,
///
/// Indicates that the health check determined that the component was in a subsystem state
///
Degraded,
///
/// Indicates that the health check determined that the subsystem was healthy
///
Healthy,
}
///
/// A single status update
///
public class ServerStatusUpdate
{
///
/// Result of status update
///
public ServerStatusResult Result { get; set; }
///
/// Optional message describing the result
///
public string? Message { get; set; }
///
/// Time this update was created
///
public DateTimeOffset UpdatedAt { get; set; }
}
///
/// Response from server status controller
///
public class ServerStatusResponse
{
///
/// List of subsystem statuses
///
public ServerStatusSubsystem[] Statuses { get; set; } = Array.Empty();
}
///
/// Information about a server plugin
///
/// Name of the plugin
/// Optional description of the plugin
/// Whether the plugin is loaded
/// The version of the plugin assembly
public record ServerPluginInfoResponse(string Name, string? Description, bool Loaded, string? Version = null);
}