Documentation
¶
Index ¶
- Constants
- Variables
- func FormatBytes(bytes int64) string
- func ValidateDiscordConfig(config *models.DiscordChannelConfig) error
- func ValidatePagerDutyConfig(config *models.PagerDutyChannelConfig) error
- func ValidateSlackConfig(config *models.SlackChannelConfig) error
- func ValidateTeamsConfig(config *models.TeamsChannelConfig) error
- func ValidateWebhookConfig(config *models.WebhookChannelConfig) error
- func ValidateWebhookURL(urlStr string, requireHTTPS bool) error
- func ValidatingDialer() func(ctx context.Context, network, addr string) (net.Conn, error)
- type AgentOfflineData
- type BackupFailedData
- type BackupResult
- type BackupSuccessData
- type DiscordEmbed
- type DiscordEmbedField
- type DiscordEmbedFooter
- type DiscordMessage
- type DiscordSender
- type DiscordService
- func (s *DiscordService) Send(msg *DiscordMessage) error
- func (s *DiscordService) SendMaintenanceScheduled(data MaintenanceScheduledData) error
- func (s *DiscordService) SendTestRestoreFailed(data TestRestoreFailedData) error
- func (s *DiscordService) SendValidationFailed(data ValidationFailedData) error
- func (s *DiscordService) TestConnection() error
- type EmailService
- func (s *EmailService) SendAgentOffline(to []string, data AgentOfflineData) error
- func (s *EmailService) SendBackupFailed(to []string, data BackupFailedData) error
- func (s *EmailService) SendBackupSuccess(to []string, data BackupSuccessData) error
- func (s *EmailService) SendEmailVerification(to string, data EmailVerificationData) error
- func (s *EmailService) SendInvitation(to []string, data InvitationData) error
- func (s *EmailService) SendMaintenanceScheduled(to []string, data MaintenanceScheduledData) error
- func (s *EmailService) SendPasswordResetRequest(to []string, data PasswordResetRequestData) error
- func (s *EmailService) SendPasswordResetSuccess(to []string, data PasswordResetSuccessData) error
- func (s *EmailService) SendReport(to []string, data ReportEmailData) error
- func (s *EmailService) SendTestRestoreFailed(to []string, data TestRestoreFailedData) error
- func (s *EmailService) SendValidationFailed(to []string, data ValidationFailedData) error
- type EmailVerificationData
- type EventContext
- type InvitationData
- type MaintenanceScheduledData
- type NotificationMessage
- type NotificationStore
- type PagerDutyEvent
- type PagerDutyEventAction
- type PagerDutyPayload
- type PagerDutySender
- type PagerDutyService
- func (s *PagerDutyService) ResolveAgent(agentID, hostname string) error
- func (s *PagerDutyService) Send(event *PagerDutyEvent) error
- func (s *PagerDutyService) SendAgentOffline(data AgentOfflineData) error
- func (s *PagerDutyService) SendBackupFailed(data BackupFailedData) error
- func (s *PagerDutyService) SendBackupSuccess(data BackupSuccessData) error
- func (s *PagerDutyService) SendMaintenanceScheduled(data MaintenanceScheduledData) error
- func (s *PagerDutyService) SendTestRestoreFailed(data TestRestoreFailedData) error
- func (s *PagerDutyService) SendValidationFailed(data ValidationFailedData) error
- func (s *PagerDutyService) TestConnection() error
- type PagerDutySeverity
- type PasswordResetRequestData
- type PasswordResetSuccessData
- type ReportAgentSummary
- type ReportAlertSummary
- type ReportBackupSummary
- type ReportData
- type ReportEmailData
- type ReportIssue
- type ReportStorageSummary
- type RuleEngine
- type RuleStore
- type SMTPConfig
- type Service
- func (s *Service) NotifyAgentOffline(ctx context.Context, agent *models.Agent, orgID uuid.UUID, ...)
- func (s *Service) NotifyBackupComplete(ctx context.Context, result BackupResult)
- func (s *Service) NotifyMaintenanceScheduled(ctx context.Context, window *models.MaintenanceWindow)
- func (s *Service) NotifyTestRestoreFailed(ctx context.Context, result *models.TestRestoreResult, repo *models.Repository, ...)
- func (s *Service) NotifyValidationFailed(ctx context.Context, result ValidationFailedResult)
- func (s *Service) TestChannel(channel *models.NotificationChannel) error
- type SlackAttachment
- type SlackField
- type SlackMessage
- type SlackSender
- type SlackService
- func (s *SlackService) Send(msg *SlackMessage) error
- func (s *SlackService) SendAgentOffline(data AgentOfflineData) error
- func (s *SlackService) SendBackupFailed(data BackupFailedData) error
- func (s *SlackService) SendBackupSuccess(data BackupSuccessData) error
- func (s *SlackService) SendMaintenanceScheduled(data MaintenanceScheduledData) error
- func (s *SlackService) SendTestRestoreFailed(data TestRestoreFailedData) error
- func (s *SlackService) SendValidationFailed(data ValidationFailedData) error
- func (s *SlackService) TestConnection() error
- type TeamsAttachment
- type TeamsCardBody
- type TeamsCardContent
- type TeamsCardFact
- type TeamsMessage
- type TeamsSender
- type TeamsService
- func (s *TeamsService) Send(msg *TeamsMessage) error
- func (s *TeamsService) SendMaintenanceScheduled(data MaintenanceScheduledData) error
- func (s *TeamsService) SendTestRestoreFailed(data TestRestoreFailedData) error
- func (s *TeamsService) SendValidationFailed(data ValidationFailedData) error
- func (s *TeamsService) TestConnection() error
- type TestRestoreFailedData
- type ValidationFailedData
- type ValidationFailedResult
- type WebhookPayload
- type WebhookSender
- type WebhookService
Constants ¶
const ( DiscordColorGreen = 0x22c55e DiscordColorRed = 0xdc2626 DiscordColorBlue = 0x3b82f6 DiscordColorAmber = 0xf59e0b )
Discord embed color constants.
Variables ¶
var ErrAirGapBlocked = errors.New("external webhooks are disabled in air-gap mode")
ErrAirGapBlocked is returned when webhooks are blocked by air-gap mode.
Functions ¶
func FormatBytes ¶
FormatBytes formats bytes into a human-readable string
func ValidateDiscordConfig ¶
func ValidateDiscordConfig(config *models.DiscordChannelConfig) error
ValidateDiscordConfig validates the Discord configuration.
func ValidatePagerDutyConfig ¶
func ValidatePagerDutyConfig(config *models.PagerDutyChannelConfig) error
ValidatePagerDutyConfig validates the PagerDuty configuration.
func ValidateSlackConfig ¶
func ValidateSlackConfig(config *models.SlackChannelConfig) error
ValidateSlackConfig validates the Slack configuration.
func ValidateTeamsConfig ¶
func ValidateTeamsConfig(config *models.TeamsChannelConfig) error
ValidateTeamsConfig validates the Teams configuration.
func ValidateWebhookConfig ¶
func ValidateWebhookConfig(config *models.WebhookChannelConfig) error
ValidateWebhookConfig validates the webhook configuration.
func ValidateWebhookURL ¶
ValidateWebhookURL validates that a webhook URL is safe to call. It blocks private IP ranges, localhost, link-local addresses, and cloud metadata endpoints. When requireHTTPS is true, only HTTPS URLs are allowed.
func ValidatingDialer ¶
ValidatingDialer returns a DialContext function that resolves hostnames and checks every resolved IP against blocked ranges before connecting. This prevents DNS rebinding attacks where a hostname resolves to a safe IP during pre-flight validation but to a private IP at connection time.
Types ¶
type AgentOfflineData ¶
type AgentOfflineData struct {
Hostname string
LastSeen time.Time
OfflineSince string
AgentID string
}
AgentOfflineData holds data for agent offline email template
type BackupFailedData ¶
type BackupFailedData struct {
Hostname string
ScheduleName string
StartedAt time.Time
FailedAt time.Time
ErrorMessage string
}
BackupFailedData holds data for backup failed email template
type BackupResult ¶
type BackupResult struct {
OrgID uuid.UUID
ScheduleID uuid.UUID
ScheduleName string
AgentID uuid.UUID
Hostname string
SnapshotID string
StartedAt time.Time
CompletedAt time.Time
SizeBytes int64
FilesNew int
FilesChanged int
Success bool
ErrorMessage string
}
BackupResult contains information about a completed backup.
type BackupSuccessData ¶
type BackupSuccessData struct {
Hostname string
ScheduleName string
SnapshotID string
StartedAt time.Time
CompletedAt time.Time
Duration string
SizeBytes int64
FilesNew int
FilesChanged int
}
BackupSuccessData holds data for backup success email template
type DiscordEmbed ¶
type DiscordEmbed struct {
Title string `json:"title"`
Description string `json:"description"`
Color int `json:"color"`
Fields []DiscordEmbedField `json:"fields,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
}
DiscordEmbed represents a Discord embed.
type DiscordEmbedField ¶
type DiscordEmbedField struct {
Name string `json:"name"`
Value string `json:"value"`
Inline bool `json:"inline,omitempty"`
}
DiscordEmbedField represents a field in a Discord embed.
type DiscordEmbedFooter ¶
type DiscordEmbedFooter struct {
}
DiscordEmbedFooter represents a footer in a Discord embed.
type DiscordMessage ¶
type DiscordMessage struct {
Embeds []DiscordEmbed `json:"embeds"`
}
DiscordMessage represents a Discord webhook message with embeds.
type DiscordSender ¶
type DiscordSender struct {
// contains filtered or unexported fields
}
DiscordSender sends notifications via Discord webhooks.
func NewDiscordSender ¶
func NewDiscordSender(logger zerolog.Logger) *DiscordSender
NewDiscordSender creates a new Discord sender.
func (*DiscordSender) Send ¶
func (d *DiscordSender) Send(ctx context.Context, webhookURL string, msg NotificationMessage) error
Send sends a notification message to a Discord webhook URL.
type DiscordService ¶
type DiscordService struct {
// contains filtered or unexported fields
}
DiscordService handles sending Discord notifications via webhooks for maintenance, validation, etc.
func NewDiscordService ¶
func NewDiscordService(cfg models.DiscordChannelConfig, logger zerolog.Logger) (*DiscordService, error)
NewDiscordService creates a new Discord notification service.
func NewDiscordServiceWithProxy ¶
func NewDiscordServiceWithProxy(cfg models.DiscordChannelConfig, proxyConfig *config.ProxyConfig, logger zerolog.Logger) (*DiscordService, error)
NewDiscordServiceWithProxy creates a Discord notification service with proxy support.
func (*DiscordService) Send ¶
func (s *DiscordService) Send(msg *DiscordMessage) error
Send sends a Discord message via the configured webhook URL.
func (*DiscordService) SendMaintenanceScheduled ¶
func (s *DiscordService) SendMaintenanceScheduled(data MaintenanceScheduledData) error
SendMaintenanceScheduled sends a maintenance scheduled notification to Discord.
func (*DiscordService) SendTestRestoreFailed ¶
func (s *DiscordService) SendTestRestoreFailed(data TestRestoreFailedData) error
SendTestRestoreFailed sends a test restore failed notification to Discord.
func (*DiscordService) SendValidationFailed ¶
func (s *DiscordService) SendValidationFailed(data ValidationFailedData) error
SendValidationFailed sends a backup validation failed notification to Discord.
func (*DiscordService) TestConnection ¶
func (s *DiscordService) TestConnection() error
TestConnection sends a test message to verify the Discord webhook is working.
type EmailService ¶
type EmailService struct {
// contains filtered or unexported fields
}
EmailService handles sending email notifications
func NewEmailService ¶
func NewEmailService(config SMTPConfig, logger zerolog.Logger) (*EmailService, error)
NewEmailService creates a new email service
func (*EmailService) SendAgentOffline ¶
func (s *EmailService) SendAgentOffline(to []string, data AgentOfflineData) error
SendAgentOffline sends an agent offline notification email
func (*EmailService) SendBackupFailed ¶
func (s *EmailService) SendBackupFailed(to []string, data BackupFailedData) error
SendBackupFailed sends a backup failed notification email
func (*EmailService) SendBackupSuccess ¶
func (s *EmailService) SendBackupSuccess(to []string, data BackupSuccessData) error
SendBackupSuccess sends a backup success notification email
func (*EmailService) SendEmailVerification ¶
func (s *EmailService) SendEmailVerification(to string, data EmailVerificationData) error
SendEmailVerification sends an email verification notification
func (*EmailService) SendInvitation ¶
func (s *EmailService) SendInvitation(to []string, data InvitationData) error
SendInvitation sends an organization invitation email
func (*EmailService) SendMaintenanceScheduled ¶
func (s *EmailService) SendMaintenanceScheduled(to []string, data MaintenanceScheduledData) error
SendMaintenanceScheduled sends a maintenance scheduled notification email
func (*EmailService) SendPasswordResetRequest ¶
func (s *EmailService) SendPasswordResetRequest(to []string, data PasswordResetRequestData) error
SendPasswordResetRequest sends a password reset request email
func (*EmailService) SendPasswordResetSuccess ¶
func (s *EmailService) SendPasswordResetSuccess(to []string, data PasswordResetSuccessData) error
SendPasswordResetSuccess sends a password reset success notification email
func (*EmailService) SendReport ¶
func (s *EmailService) SendReport(to []string, data ReportEmailData) error
SendReport sends a report summary email
func (*EmailService) SendTestRestoreFailed ¶
func (s *EmailService) SendTestRestoreFailed(to []string, data TestRestoreFailedData) error
SendTestRestoreFailed sends a test restore failed notification email
func (*EmailService) SendValidationFailed ¶
func (s *EmailService) SendValidationFailed(to []string, data ValidationFailedData) error
SendValidationFailed sends a validation failed notification email
type EmailVerificationData ¶
type EmailVerificationData struct {
UserName string
Email string
VerificationURL string
ExpiresAt time.Time
}
EmailVerificationData holds data for email verification template
type EventContext ¶
type EventContext struct {
OrgID uuid.UUID
TriggerType models.RuleTriggerType
ResourceType string
ResourceID *uuid.UUID
Severity string
EventData map[string]any
}
EventContext contains context about the event being processed.
type InvitationData ¶
type InvitationData struct {
OrgName string
InviterName string
Role string
InviteLink string
ExpiresAt time.Time
ExpiresIn string
}
InvitationData holds data for invitation email template
type MaintenanceScheduledData ¶
type MaintenanceScheduledData struct {
Title string
Message string
StartsAt time.Time
EndsAt time.Time
Duration string
}
MaintenanceScheduledData holds data for maintenance scheduled email template
type NotificationMessage ¶
type NotificationMessage struct {
Title string
Body string
EventType string
Severity string // info, warning, error, critical
}
NotificationMessage represents a generic notification message for non-email senders.
type NotificationStore ¶
type NotificationStore interface {
GetEnabledPreferencesForEvent(ctx context.Context, orgID uuid.UUID, eventType models.NotificationEventType) ([]*models.NotificationPreference, error)
GetNotificationChannelByID(ctx context.Context, id uuid.UUID) (*models.NotificationChannel, error)
CreateNotificationLog(ctx context.Context, log *models.NotificationLog) error
UpdateNotificationLog(ctx context.Context, log *models.NotificationLog) error
GetAgentByID(ctx context.Context, id uuid.UUID) (*models.Agent, error)
GetScheduleByID(ctx context.Context, id uuid.UUID) (*models.Schedule, error)
}
NotificationStore defines the interface for notification data access.
type PagerDutyEvent ¶
type PagerDutyEvent struct {
Summary string // Used by the simple Sender
Source string
Severity string // info, warning, error, critical
Group string
EventAction PagerDutyEventAction // Used by the Service
DedupKey string
Payload PagerDutyPayload
}
PagerDutyEvent represents the data needed to create a PagerDuty event.
type PagerDutyEventAction ¶
type PagerDutyEventAction string
PagerDutyEventAction represents the action to take on an event.
const ( PagerDutyEventTrigger PagerDutyEventAction = "trigger" PagerDutyEventAcknowledge PagerDutyEventAction = "acknowledge" PagerDutyEventResolve PagerDutyEventAction = "resolve" )
type PagerDutyPayload ¶
type PagerDutyPayload struct {
Summary string `json:"summary"`
Source string `json:"source"`
Severity PagerDutySeverity `json:"severity"`
Timestamp string `json:"timestamp,omitempty"`
CustomDetails map[string]interface{} `json:"custom_details,omitempty"`
}
PagerDutyPayload represents the payload in a PagerDuty event.
type PagerDutySender ¶
type PagerDutySender struct {
// contains filtered or unexported fields
}
PagerDutySender sends notifications via PagerDuty Events API v2.
func NewPagerDutySender ¶
func NewPagerDutySender(logger zerolog.Logger) *PagerDutySender
NewPagerDutySender creates a new PagerDuty sender.
func (*PagerDutySender) Send ¶
func (p *PagerDutySender) Send(ctx context.Context, routingKey string, event PagerDutyEvent) error
Send sends a PagerDuty event using the Events API v2.
type PagerDutyService ¶
type PagerDutyService struct {
// contains filtered or unexported fields
}
PagerDutyService handles sending notifications via PagerDuty Events API v2.
func NewPagerDutyService ¶
func NewPagerDutyService(cfg models.PagerDutyChannelConfig, logger zerolog.Logger) (*PagerDutyService, error)
NewPagerDutyService creates a new PagerDuty notification service.
func NewPagerDutyServiceWithProxy ¶
func NewPagerDutyServiceWithProxy(cfg models.PagerDutyChannelConfig, proxyConfig *config.ProxyConfig, logger zerolog.Logger) (*PagerDutyService, error)
NewPagerDutyServiceWithProxy creates a PagerDuty notification service with proxy support.
func (*PagerDutyService) ResolveAgent ¶
func (s *PagerDutyService) ResolveAgent(agentID, hostname string) error
ResolveAgent sends a resolve event for an agent that has come back online.
func (*PagerDutyService) Send ¶
func (s *PagerDutyService) Send(event *PagerDutyEvent) error
Send sends a PagerDuty event via the Events API v2.
func (*PagerDutyService) SendAgentOffline ¶
func (s *PagerDutyService) SendAgentOffline(data AgentOfflineData) error
SendAgentOffline sends an agent offline notification to PagerDuty.
func (*PagerDutyService) SendBackupFailed ¶
func (s *PagerDutyService) SendBackupFailed(data BackupFailedData) error
SendBackupFailed sends a backup failed notification to PagerDuty.
func (*PagerDutyService) SendBackupSuccess ¶
func (s *PagerDutyService) SendBackupSuccess(data BackupSuccessData) error
SendBackupSuccess sends a backup success notification to PagerDuty. Note: Backup success typically resolves any previous backup failure alerts.
func (*PagerDutyService) SendMaintenanceScheduled ¶
func (s *PagerDutyService) SendMaintenanceScheduled(data MaintenanceScheduledData) error
SendMaintenanceScheduled sends a maintenance scheduled notification to PagerDuty.
func (*PagerDutyService) SendTestRestoreFailed ¶
func (s *PagerDutyService) SendTestRestoreFailed(data TestRestoreFailedData) error
SendTestRestoreFailed sends a test restore failed notification to PagerDuty.
func (*PagerDutyService) SendValidationFailed ¶
func (s *PagerDutyService) SendValidationFailed(data ValidationFailedData) error
SendValidationFailed sends a backup validation failed notification to PagerDuty.
func (*PagerDutyService) TestConnection ¶
func (s *PagerDutyService) TestConnection() error
TestConnection sends a test event to verify the PagerDuty integration is working.
type PagerDutySeverity ¶
type PagerDutySeverity string
PagerDutySeverity represents the severity of an event.
const ( PagerDutySeverityInfo PagerDutySeverity = "info" PagerDutySeverityWarning PagerDutySeverity = "warning" PagerDutySeverityError PagerDutySeverity = "error" PagerDutySeverityCritical PagerDutySeverity = "critical" )
type PasswordResetRequestData ¶
type PasswordResetRequestData struct {
UserName string
UserEmail string
ResetURL string
ExpiresAt time.Time
}
PasswordResetRequestData holds data for password reset request email template
type PasswordResetSuccessData ¶
PasswordResetSuccessData holds data for password reset success email template
type ReportAgentSummary ¶
type ReportAgentSummary struct {
TotalAgents int `json:"total_agents"`
ActiveAgents int `json:"active_agents"`
OfflineAgents int `json:"offline_agents"`
PendingAgents int `json:"pending_agents"`
}
ReportAgentSummary contains agent health statistics
type ReportAlertSummary ¶
type ReportAlertSummary struct {
TotalAlerts int `json:"total_alerts"`
CriticalAlerts int `json:"critical_alerts"`
WarningAlerts int `json:"warning_alerts"`
AcknowledgedAlerts int `json:"acknowledged_alerts"`
ResolvedAlerts int `json:"resolved_alerts"`
}
ReportAlertSummary contains alert statistics
type ReportBackupSummary ¶
type ReportBackupSummary struct {
TotalBackups int `json:"total_backups"`
SuccessfulBackups int `json:"successful_backups"`
FailedBackups int `json:"failed_backups"`
SuccessRate float64 `json:"success_rate"`
TotalDataBacked int64 `json:"total_data_backed"`
SchedulesActive int `json:"schedules_active"`
}
ReportBackupSummary contains backup statistics for the report period
type ReportData ¶
type ReportData struct {
BackupSummary ReportBackupSummary `json:"backup_summary"`
StorageSummary ReportStorageSummary `json:"storage_summary"`
AgentSummary ReportAgentSummary `json:"agent_summary"`
AlertSummary ReportAlertSummary `json:"alert_summary"`
TopIssues []ReportIssue `json:"top_issues,omitempty"`
}
ReportData contains the aggregated data for a report
type ReportEmailData ¶
type ReportEmailData struct {
OrgName string
Frequency string
FrequencyLower string
PeriodStart time.Time
PeriodEnd time.Time
Data *ReportData
TotalDataFormatted string
RawSizeFormatted string
RestoreSizeFormatted string
SpaceSavedFormatted string
}
ReportEmailData holds data for report summary email template
type ReportIssue ¶
type ReportIssue struct {
Type string `json:"type"`
Severity string `json:"severity"`
Title string `json:"title"`
Description string `json:"description"`
OccurredAt time.Time `json:"occurred_at"`
}
ReportIssue represents a notable issue to highlight in the report
type ReportStorageSummary ¶
type ReportStorageSummary struct {
TotalRawSize int64 `json:"total_raw_size"`
TotalRestoreSize int64 `json:"total_restore_size"`
SpaceSaved int64 `json:"space_saved"`
SpaceSavedPct float64 `json:"space_saved_pct"`
RepositoryCount int `json:"repository_count"`
TotalSnapshots int `json:"total_snapshots"`
}
ReportStorageSummary contains storage statistics
type RuleEngine ¶
type RuleEngine struct {
// contains filtered or unexported fields
}
RuleEngine evaluates notification rules and executes actions.
func NewRuleEngine ¶
func NewRuleEngine(store RuleStore, logger zerolog.Logger) *RuleEngine
NewRuleEngine creates a new rule engine.
func (*RuleEngine) EvaluateEvent ¶
func (e *RuleEngine) EvaluateEvent(ctx context.Context, eventCtx EventContext) error
EvaluateEvent processes an event against all matching rules.
func (*RuleEngine) TestRule ¶
func (e *RuleEngine) TestRule(ctx context.Context, rule *models.NotificationRule, eventData map[string]any) (*models.NotificationRuleExecution, error)
TestRule tests a rule with sample event data without persisting.
type RuleStore ¶
type RuleStore interface {
// Rules
GetNotificationRulesByOrgID(ctx context.Context, orgID uuid.UUID) ([]*models.NotificationRule, error)
GetNotificationRuleByID(ctx context.Context, id uuid.UUID) (*models.NotificationRule, error)
GetEnabledRulesByTriggerType(ctx context.Context, orgID uuid.UUID, triggerType models.RuleTriggerType) ([]*models.NotificationRule, error)
CreateNotificationRule(ctx context.Context, rule *models.NotificationRule) error
UpdateNotificationRule(ctx context.Context, rule *models.NotificationRule) error
DeleteNotificationRule(ctx context.Context, id uuid.UUID) error
// Events
CreateNotificationRuleEvent(ctx context.Context, event *models.NotificationRuleEvent) error
CountEventsInTimeWindow(ctx context.Context, orgID uuid.UUID, triggerType models.RuleTriggerType, resourceID *uuid.UUID, windowStart time.Time) (int, error)
GetRecentEventsForRule(ctx context.Context, ruleID uuid.UUID, limit int) ([]*models.NotificationRuleEvent, error)
// Executions
CreateNotificationRuleExecution(ctx context.Context, execution *models.NotificationRuleExecution) error
GetRecentExecutionsForRule(ctx context.Context, ruleID uuid.UUID, limit int) ([]*models.NotificationRuleExecution, error)
// Notification channels for actions
GetNotificationChannelByID(ctx context.Context, id uuid.UUID) (*models.NotificationChannel, error)
}
RuleStore defines the interface for notification rule data access.
type SMTPConfig ¶
type SMTPConfig struct {
Host string `yaml:"host" json:"host"`
Port int `yaml:"port" json:"port"`
Username string `yaml:"username" json:"username"`
Password string `yaml:"password" json:"-"`
From string `yaml:"from" json:"from"`
TLS bool `yaml:"tls" json:"tls"`
}
SMTPConfig holds SMTP server configuration
func (*SMTPConfig) Validate ¶
func (c *SMTPConfig) Validate() error
Validate checks if the SMTP configuration is valid
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles sending notifications for backup events.
func NewService ¶
func NewService(store NotificationStore, keyManager *crypto.KeyManager, logger zerolog.Logger) *Service
NewService creates a new notification service.
func (*Service) NotifyAgentOffline ¶
func (s *Service) NotifyAgentOffline(ctx context.Context, agent *models.Agent, orgID uuid.UUID, offlineSince time.Duration)
NotifyAgentOffline sends notifications when an agent goes offline.
func (*Service) NotifyBackupComplete ¶
func (s *Service) NotifyBackupComplete(ctx context.Context, result BackupResult)
NotifyBackupComplete sends notifications for a completed backup.
func (*Service) NotifyMaintenanceScheduled ¶
func (s *Service) NotifyMaintenanceScheduled(ctx context.Context, window *models.MaintenanceWindow)
NotifyMaintenanceScheduled sends notifications for an upcoming maintenance window.
func (*Service) NotifyTestRestoreFailed ¶
func (s *Service) NotifyTestRestoreFailed(ctx context.Context, result *models.TestRestoreResult, repo *models.Repository, consecutiveFails int)
NotifyTestRestoreFailed sends notifications when a test restore fails.
func (*Service) NotifyValidationFailed ¶
func (s *Service) NotifyValidationFailed(ctx context.Context, result ValidationFailedResult)
NotifyValidationFailed sends notifications when a backup validation fails.
func (*Service) TestChannel ¶
func (s *Service) TestChannel(channel *models.NotificationChannel) error
TestChannel sends a test notification to verify the channel configuration is working.
type SlackAttachment ¶
type SlackAttachment struct {
Color string `json:"color,omitempty"`
Title string `json:"title,omitempty"`
Fallback string `json:"fallback,omitempty"`
Text string `json:"text,omitempty"`
Fields []SlackField `json:"fields,omitempty"`
Timestamp int64 `json:"ts,omitempty"`
}
SlackAttachment represents a Slack message attachment.
type SlackField ¶
type SlackField struct {
Title string `json:"title"`
Value string `json:"value"`
Short bool `json:"short,omitempty"`
}
SlackField represents a field in a Slack attachment.
type SlackMessage ¶
type SlackMessage struct {
Text string `json:"text,omitempty"`
Attachments []SlackAttachment `json:"attachments,omitempty"`
}
SlackMessage represents a Slack webhook message with attachments.
type SlackSender ¶
type SlackSender struct {
// contains filtered or unexported fields
}
SlackSender sends notifications via Slack incoming webhooks.
func NewSlackSender ¶
func NewSlackSender(logger zerolog.Logger) *SlackSender
NewSlackSender creates a new Slack sender.
func (*SlackSender) Send ¶
func (s *SlackSender) Send(ctx context.Context, webhookURL string, msg NotificationMessage) error
Send sends a notification message to a Slack webhook URL.
type SlackService ¶
type SlackService struct {
// contains filtered or unexported fields
}
SlackService handles sending Slack notifications via webhooks for maintenance, validation, etc.
func NewSlackService ¶
func NewSlackService(cfg models.SlackChannelConfig, logger zerolog.Logger) (*SlackService, error)
NewSlackService creates a new Slack notification service.
func NewSlackServiceWithProxy ¶
func NewSlackServiceWithProxy(cfg models.SlackChannelConfig, proxyConfig *config.ProxyConfig, logger zerolog.Logger) (*SlackService, error)
NewSlackServiceWithProxy creates a Slack notification service with proxy support.
func (*SlackService) Send ¶
func (s *SlackService) Send(msg *SlackMessage) error
Send sends a Slack message via the configured webhook URL.
func (*SlackService) SendAgentOffline ¶
func (s *SlackService) SendAgentOffline(data AgentOfflineData) error
SendAgentOffline sends an agent offline notification to Slack.
func (*SlackService) SendBackupFailed ¶
func (s *SlackService) SendBackupFailed(data BackupFailedData) error
SendBackupFailed sends a backup failed notification to Slack.
func (*SlackService) SendBackupSuccess ¶
func (s *SlackService) SendBackupSuccess(data BackupSuccessData) error
SendBackupSuccess sends a backup success notification to Slack.
func (*SlackService) SendMaintenanceScheduled ¶
func (s *SlackService) SendMaintenanceScheduled(data MaintenanceScheduledData) error
SendMaintenanceScheduled sends a maintenance scheduled notification to Slack.
func (*SlackService) SendTestRestoreFailed ¶
func (s *SlackService) SendTestRestoreFailed(data TestRestoreFailedData) error
SendTestRestoreFailed sends a test restore failed notification to Slack.
func (*SlackService) SendValidationFailed ¶
func (s *SlackService) SendValidationFailed(data ValidationFailedData) error
SendValidationFailed sends a backup validation failed notification to Slack.
func (*SlackService) TestConnection ¶
func (s *SlackService) TestConnection() error
TestConnection sends a test message to verify the Slack webhook is working.
type TeamsAttachment ¶
type TeamsAttachment struct {
ContentType string `json:"contentType"`
ContentURL *string `json:"contentUrl"`
Content TeamsCardContent `json:"content"`
}
TeamsAttachment represents an attachment in a Teams message.
type TeamsCardBody ¶
type TeamsCardBody struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Size string `json:"size,omitempty"`
Weight string `json:"weight,omitempty"`
Color string `json:"color,omitempty"`
Wrap bool `json:"wrap,omitempty"`
Facts []TeamsCardFact `json:"facts,omitempty"`
}
TeamsCardBody represents a body element in an Adaptive Card.
type TeamsCardContent ¶
type TeamsCardContent struct {
Schema string `json:"$schema"`
Type string `json:"type"`
Version string `json:"version"`
Body []TeamsCardBody `json:"body"`
}
TeamsCardContent represents the Adaptive Card content.
type TeamsCardFact ¶
TeamsCardFact represents a fact in a FactSet.
type TeamsMessage ¶
type TeamsMessage struct {
Type string `json:"type"`
Attachments []TeamsAttachment `json:"attachments"`
}
TeamsMessage represents a Teams webhook message using Adaptive Cards.
func NewTeamsMessage ¶
func NewTeamsMessage() *TeamsMessage
NewTeamsMessage creates a new Teams message with Adaptive Card structure.
func (*TeamsMessage) AddFactSet ¶
func (m *TeamsMessage) AddFactSet(facts []TeamsCardFact)
AddFactSet adds a fact set to the message.
func (*TeamsMessage) AddHeader ¶
func (m *TeamsMessage) AddHeader(text, color string)
AddHeader adds a header text block to the message.
func (*TeamsMessage) AddText ¶
func (m *TeamsMessage) AddText(text string, wrap bool)
AddText adds a text block to the message.
type TeamsSender ¶
type TeamsSender struct {
// contains filtered or unexported fields
}
TeamsSender sends notifications via Microsoft Teams incoming webhooks.
func NewTeamsSender ¶
func NewTeamsSender(logger zerolog.Logger) *TeamsSender
NewTeamsSender creates a new Teams sender.
func (*TeamsSender) Send ¶
func (t *TeamsSender) Send(ctx context.Context, webhookURL string, msg NotificationMessage) error
Send sends a notification message to a Teams webhook URL.
type TeamsService ¶
type TeamsService struct {
// contains filtered or unexported fields
}
TeamsService handles sending Microsoft Teams notifications via webhooks.
func NewTeamsService ¶
func NewTeamsService(cfg models.TeamsChannelConfig, logger zerolog.Logger) (*TeamsService, error)
NewTeamsService creates a new Microsoft Teams notification service.
func NewTeamsServiceWithProxy ¶
func NewTeamsServiceWithProxy(cfg models.TeamsChannelConfig, proxyConfig *config.ProxyConfig, logger zerolog.Logger) (*TeamsService, error)
NewTeamsServiceWithProxy creates a Teams notification service with proxy support.
func (*TeamsService) Send ¶
func (s *TeamsService) Send(msg *TeamsMessage) error
Send sends a Teams message via the configured webhook URL.
func (*TeamsService) SendMaintenanceScheduled ¶
func (s *TeamsService) SendMaintenanceScheduled(data MaintenanceScheduledData) error
SendMaintenanceScheduled sends a maintenance scheduled notification to Teams.
func (*TeamsService) SendTestRestoreFailed ¶
func (s *TeamsService) SendTestRestoreFailed(data TestRestoreFailedData) error
SendTestRestoreFailed sends a test restore failed notification to Teams.
func (*TeamsService) SendValidationFailed ¶
func (s *TeamsService) SendValidationFailed(data ValidationFailedData) error
SendValidationFailed sends a backup validation failed notification to Teams.
func (*TeamsService) TestConnection ¶
func (s *TeamsService) TestConnection() error
TestConnection sends a test message to verify the Teams webhook is working.
type TestRestoreFailedData ¶
type TestRestoreFailedData struct {
RepositoryName string
RepositoryID string
SnapshotID string
SamplePercentage int
StartedAt time.Time
FailedAt time.Time
FilesRestored int
FilesVerified int
ErrorMessage string
ConsecutiveFails int
}
TestRestoreFailedData holds data for test restore failed email template
type ValidationFailedData ¶
type ValidationFailedData struct {
Hostname string
ScheduleName string
SnapshotID string
BackupCompletedAt time.Time
ValidationFailedAt time.Time
ErrorMessage string
ValidationSummary string
ValidationDetails string
}
ValidationFailedData holds data for validation failed email template
type ValidationFailedResult ¶
type ValidationFailedResult struct {
OrgID uuid.UUID
ScheduleID uuid.UUID
ScheduleName string
AgentID uuid.UUID
Hostname string
SnapshotID string
BackupCompletedAt time.Time
ValidationFailedAt time.Time
ErrorMessage string
ValidationSummary string
ValidationDetails string
}
ValidationFailedResult contains information about a failed backup validation.
type WebhookPayload ¶
type WebhookPayload struct {
EventType string `json:"event_type"`
Timestamp time.Time `json:"timestamp,omitempty"`
EventTime time.Time `json:"event_time,omitempty"`
Data interface{} `json:"data,omitempty"`
Source string `json:"source,omitempty"`
Summary string `json:"summary,omitempty"`
Severity string `json:"severity,omitempty"`
Details map[string]interface{} `json:"details,omitempty"`
}
WebhookPayload represents the payload sent to generic webhook endpoints.
type WebhookSender ¶
type WebhookSender struct {
// contains filtered or unexported fields
}
WebhookSender sends notifications via generic webhooks with HMAC signing and retry.
func NewWebhookSender ¶
func NewWebhookSender(logger zerolog.Logger) *WebhookSender
NewWebhookSender creates a new webhook sender.
func (*WebhookSender) Send ¶
func (w *WebhookSender) Send(ctx context.Context, url string, payload WebhookPayload, secret string) error
Send sends a webhook payload to the given URL with HMAC signature and retry. URLs should be validated with ValidateWebhookURL before being stored.
func (*WebhookSender) SetAirGapMode ¶
func (w *WebhookSender) SetAirGapMode(enabled bool)
SetAirGapMode enables or disables air-gap mode on the webhook sender.
type WebhookService ¶
type WebhookService struct {
// contains filtered or unexported fields
}
WebhookService handles sending webhook notifications for maintenance, validation, etc.
func NewWebhookService ¶
func NewWebhookService(cfg models.WebhookChannelConfig, logger zerolog.Logger) (*WebhookService, error)
NewWebhookService creates a new generic webhook notification service.
func NewWebhookServiceWithProxy ¶
func NewWebhookServiceWithProxy(cfg models.WebhookChannelConfig, proxyConfig *config.ProxyConfig, logger zerolog.Logger) (*WebhookService, error)
NewWebhookServiceWithProxy creates a webhook service with proxy support.
func (*WebhookService) Send ¶
func (s *WebhookService) Send(payload *WebhookPayload) error
Send sends a webhook payload via the configured URL.
func (*WebhookService) SendTestRestoreFailed ¶
func (s *WebhookService) SendTestRestoreFailed(data TestRestoreFailedData) error
SendTestRestoreFailed sends a test restore failed notification via webhook.
func (*WebhookService) SendValidationFailed ¶
func (s *WebhookService) SendValidationFailed(data ValidationFailedData) error
SendValidationFailed sends a backup validation failed notification via webhook.
func (*WebhookService) TestConnection ¶
func (s *WebhookService) TestConnection() error
TestConnection sends a test event to verify the webhook is working.