namespace StellaOps.Plugin.Abstractions.Capabilities;
///
/// Base capability for external system connectors.
///
public interface IConnectorCapability
{
///
/// Connector type identifier, e.g., "scm.github", "registry.ecr", "vault.hashicorp".
///
string ConnectorType { get; }
///
/// Human-readable display name.
///
string DisplayName { get; }
///
/// Test the connection to the external system.
///
/// Cancellation token.
/// Result of the connection test.
Task TestConnectionAsync(CancellationToken ct);
///
/// Get current connection status and metadata.
///
/// Cancellation token.
/// Connection information.
Task GetConnectionInfoAsync(CancellationToken ct);
}
///
/// Result of a connection test.
///
/// Whether the connection was successful.
/// Optional message describing the result.
/// Round-trip latency if measured.
/// Additional diagnostic details.
public sealed record ConnectionTestResult(
bool Success,
string? Message = null,
TimeSpan? Latency = null,
IReadOnlyDictionary? Details = null)
{
///
/// Creates a successful connection test result.
///
/// Optional measured latency.
/// A success result.
public static ConnectionTestResult Succeeded(TimeSpan? latency = null) =>
new(true, "Connection successful", latency);
///
/// Creates a failed connection test result.
///
/// Description of the failure.
/// Optional exception.
/// A failure result.
public static ConnectionTestResult Failed(string message, Exception? ex = null) =>
new(false, message, Details: ex != null ? new Dictionary
{
["exception"] = ex.GetType().Name,
["exceptionMessage"] = ex.Message
} : null);
}
///
/// Information about the current connection state.
///
/// The endpoint URL.
/// The authenticated identity, if any.
/// When the connection was established.
/// Additional connection metadata.
public sealed record ConnectionInfo(
string EndpointUrl,
string? AuthenticatedAs = null,
DateTimeOffset? ConnectedSince = null,
IReadOnlyDictionary? Metadata = null);