using System.Text.Json.Serialization;
namespace StellaOps.Notifier.WebService.Contracts;
///
/// Request to create or update a notification rule.
///
public sealed record RuleCreateRequest
{
public required string RuleId { get; init; }
public required string Name { get; init; }
public string? Description { get; init; }
public bool Enabled { get; init; } = true;
public required RuleMatchRequest Match { get; init; }
public required List Actions { get; init; }
public Dictionary? Labels { get; init; }
public Dictionary? Metadata { get; init; }
}
///
/// Request to update an existing rule.
///
public sealed record RuleUpdateRequest
{
public string? Name { get; init; }
public string? Description { get; init; }
public bool? Enabled { get; init; }
public RuleMatchRequest? Match { get; init; }
public List? Actions { get; init; }
public Dictionary? Labels { get; init; }
public Dictionary? Metadata { get; init; }
}
///
/// Rule match criteria.
///
public sealed record RuleMatchRequest
{
public List? EventKinds { get; init; }
public List? Namespaces { get; init; }
public List? Repositories { get; init; }
public List? Digests { get; init; }
public List? Labels { get; init; }
public List? ComponentPurls { get; init; }
public string? MinSeverity { get; init; }
public List? Verdicts { get; init; }
public bool? KevOnly { get; init; }
}
///
/// Rule action configuration.
///
public sealed record RuleActionRequest
{
public required string ActionId { get; init; }
public required string Channel { get; init; }
public string? Template { get; init; }
public string? Digest { get; init; }
public string? Throttle { get; init; } // ISO 8601 duration
public string? Locale { get; init; }
public bool Enabled { get; init; } = true;
public Dictionary? Metadata { get; init; }
}
///
/// Rule response DTO.
///
public sealed record RuleResponse
{
public required string RuleId { get; init; }
public required string TenantId { get; init; }
public required string Name { get; init; }
public string? Description { get; init; }
public required bool Enabled { get; init; }
public required RuleMatchResponse Match { get; init; }
public required List Actions { get; init; }
public Dictionary? Labels { get; init; }
public Dictionary? Metadata { get; init; }
public string? CreatedBy { get; init; }
public DateTimeOffset CreatedAt { get; init; }
public string? UpdatedBy { get; init; }
public DateTimeOffset UpdatedAt { get; init; }
}
///
/// Rule match response.
///
public sealed record RuleMatchResponse
{
public List EventKinds { get; init; } = [];
public List Namespaces { get; init; } = [];
public List Repositories { get; init; } = [];
public List Digests { get; init; } = [];
public List Labels { get; init; } = [];
public List ComponentPurls { get; init; } = [];
public string? MinSeverity { get; init; }
public List Verdicts { get; init; } = [];
public bool KevOnly { get; init; }
}
///
/// Rule action response.
///
public sealed record RuleActionResponse
{
public required string ActionId { get; init; }
public required string Channel { get; init; }
public string? Template { get; init; }
public string? Digest { get; init; }
public string? Throttle { get; init; }
public string? Locale { get; init; }
public required bool Enabled { get; init; }
public Dictionary? Metadata { get; init; }
}