namespace SQLInsight.Connectivity;
///
/// How to reach one monitored instance.
///
public sealed record ConnectionTarget
{
/// Server name, host\instance or host,port.
public required string Server { get; init; }
public AuthenticationMode Authentication { get; init; } = AuthenticationMode.Windows;
/// SQL login name. Only used with .
public string? UserName { get; init; }
/// SQL login password. Only used with .
public string? Password { get; init; }
public ConnectionProvider Provider { get; init; } = ConnectionProvider.Auto;
///
/// Whether the connection must be encrypted. Mandatory is the default; old unpatched instances that only speak
/// TLS 1.0 need , which the agent reports as a warning.
///
public EncryptionMode Encryption { get; init; } = EncryptionMode.Mandatory;
/// Skip certificate validation. Off by default; must be a deliberate choice.
public bool TrustServerCertificate { get; init; }
/// ODBC driver used for legacy instances.
public string OdbcDriver { get; init; } = "ODBC Driver 18 for SQL Server";
public TimeSpan ConnectTimeout { get; init; } = TimeSpan.FromSeconds(15);
/// Entra tenant id, for .
public string? TenantId { get; init; }
public bool UsesEntra => Authentication is AuthenticationMode.EntraManagedIdentity or AuthenticationMode.EntraServicePrincipal or AuthenticationMode.EntraDefault;
}
public enum AuthenticationMode
{
/// Integrated security. Preferred on-prem; run the agent as a gMSA.
Windows,
SqlLogin,
/// Microsoft Entra ID with the agent's managed identity (Azure VM). may hold a user-assigned identity's client id.
EntraManagedIdentity,
/// Microsoft Entra ID service principal: = client id, = secret.
EntraServicePrincipal,
/// Microsoft Entra ID via the default credential chain (environment, managed identity, Azure CLI …).
EntraDefault,
}
public enum ConnectionProvider
{
/// Try Microsoft.Data.SqlClient, fall back to ODBC when the instance is too old for it.
Auto,
SqlClient,
Odbc,
}
public enum EncryptionMode
{
Mandatory,
Optional,
}