using SQLInsight.Core.Findings;
namespace SQLInsight.Notifications;
public enum NotificationKind
{
FindingOpened,
FindingResolved,
InstanceUnreachable,
InstanceRecovered,
}
///
/// Something worth telling a person about. Carries no query text or evidence values, only what is needed to decide
/// whether to open the web UI.
///
public sealed record Notification
{
public required NotificationKind Kind { get; init; }
public required string Instance { get; init; }
public required string Title { get; init; }
public Severity Severity { get; init; }
public string? RuleId { get; init; }
public string? Subject { get; init; }
/// The first sentence of the explanation.
public string? Summary { get; init; }
/// Link to the finding or instance in the web UI, when a base URL is configured.
public Uri? Url { get; init; }
public required DateTimeOffset At { get; init; }
}
public interface INotificationChannel
{
string Name { get; }
/// Lowest severity this channel wants for new findings. Instance outages are always sent.
Severity MinSeverity { get; }
Task SendAsync(IReadOnlyList notifications, CancellationToken cancellationToken);
}