Documentation
¶
Index ¶
- Variables
- func HMACPreview(secret string) string
- func NormalizeChannelConfig(channelType ChannelType, raw map[string]any) (map[string]any, error)
- func RedactedConfig(channelType ChannelType, raw map[string]any) map[string]any
- type Channel
- type ChannelConfig
- type ChannelInput
- type ChannelPatchInput
- type ChannelType
- type ChannelUsageConflict
- type ChannelUsageRuleReference
- type CreateChannelInput
- type CreateRuleInput
- type Message
- type Optional
- type ProjectRef
- type Rule
- type RuleEventCatalogEntry
- type RuleEventType
- type RuleInput
- type RulePatchInput
- type SlackConfig
- type TelegramConfig
- type UpdateChannelInput
- type UpdateRuleInput
- type WeComConfig
- type WebhookConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrOrganizationNotFound reports a missing organization. ErrOrganizationNotFound = errors.New("organization not found") // ErrProjectNotFound reports a missing project. ErrProjectNotFound = errors.New("project not found") // ErrChannelNotFound reports a missing notification channel. ErrChannelNotFound = errors.New("notification channel not found") // ErrChannelInUse reports that a notification channel is still referenced by rules. ErrChannelInUse = errors.New("notification channel is still referenced by notification rules") // ErrDuplicateChannelName reports duplicate channel names within the same organization. ErrDuplicateChannelName = errors.New("notification channel name already exists in organization") // ErrRuleNotFound reports a missing notification rule. ErrRuleNotFound = errors.New("notification rule not found") // ErrDuplicateRuleName reports duplicate notification rule names within the same project. ErrDuplicateRuleName = errors.New("notification rule name already exists in project") )
var ( // ErrChannelTypeUnsupported reports unsupported notification channel types. ErrChannelTypeUnsupported = errors.New("notification channel type is not supported") )
Functions ¶
func HMACPreview ¶
HMACPreview returns a deterministic header-safe signature preview for masked responses.
func NormalizeChannelConfig ¶
NormalizeChannelConfig validates and normalizes raw config before persistence.
func RedactedConfig ¶
func RedactedConfig(channelType ChannelType, raw map[string]any) map[string]any
RedactedConfig returns a response-safe config snapshot.
Types ¶
type Channel ¶
type Channel struct {
ID uuid.UUID
OrganizationID uuid.UUID
Name string
Type ChannelType
Config map[string]any
IsEnabled bool
CreatedAt time.Time
}
Channel stores the persisted notification channel aggregate.
type ChannelConfig ¶
type ChannelConfig interface {
// contains filtered or unexported methods
}
ChannelConfig is the marker interface for validated adapter configuration.
func ParseChannelConfig ¶
func ParseChannelConfig(channelType ChannelType, raw map[string]any) (ChannelConfig, error)
ParseChannelConfig turns raw persisted config into a validated typed config.
type ChannelInput ¶
type ChannelInput struct {
Name string `json:"name"`
Type string `json:"type"`
Config map[string]any `json:"config"`
IsEnabled *bool `json:"is_enabled"`
}
ChannelInput carries raw create/update request values before parsing.
type ChannelPatchInput ¶
type ChannelPatchInput struct {
Name *string `json:"name"`
Type *string `json:"type"`
Config *map[string]any `json:"config"`
IsEnabled *bool `json:"is_enabled"`
}
ChannelPatchInput carries raw patch values before parsing.
type ChannelType ¶
type ChannelType string
ChannelType identifies a notification delivery integration.
const ( ChannelTypeWebhook ChannelType = "webhook" ChannelTypeTelegram ChannelType = "telegram" ChannelTypeSlack ChannelType = "slack" ChannelTypeWeCom ChannelType = "wecom" )
func ParseChannelType ¶
func ParseChannelType(raw string) (ChannelType, error)
ParseChannelType validates a raw channel type string.
func (ChannelType) String ¶
func (t ChannelType) String() string
type ChannelUsageConflict ¶
type ChannelUsageConflict struct {
ChannelID uuid.UUID `json:"channel_id"`
Rules []ChannelUsageRuleReference `json:"rules"`
}
func (*ChannelUsageConflict) Error ¶
func (e *ChannelUsageConflict) Error() string
func (*ChannelUsageConflict) Unwrap ¶
func (e *ChannelUsageConflict) Unwrap() error
type CreateChannelInput ¶
type CreateChannelInput struct {
OrganizationID uuid.UUID
Name string
Type ChannelType
Config map[string]any
IsEnabled bool
}
CreateChannelInput is the validated create command input.
func ParseCreateChannel ¶
func ParseCreateChannel(organizationID uuid.UUID, raw ChannelInput) (CreateChannelInput, error)
ParseCreateChannel validates an incoming channel create request.
type CreateRuleInput ¶
type CreateRuleInput struct {
ProjectID uuid.UUID
Name string
EventType RuleEventType
Filter map[string]any
ChannelID uuid.UUID
Template string
IsEnabled bool
}
CreateRuleInput is the parsed create command.
func ParseCreateRule ¶
func ParseCreateRule(projectID uuid.UUID, raw RuleInput) (CreateRuleInput, error)
ParseCreateRule validates an incoming rule create request.
type Message ¶
type Message struct {
Title string
Body string
Level string
Link string
Metadata map[string]string
}
Message is the adapter-facing notification payload.
type ProjectRef ¶
ProjectRef carries the minimal project data needed by the notification service.
type Rule ¶
type Rule struct {
ID uuid.UUID
ProjectID uuid.UUID
ChannelID uuid.UUID
Name string
EventType RuleEventType
Filter map[string]any
Template string
IsEnabled bool
CreatedAt time.Time
Channel Channel
}
Rule stores a persisted notification subscription.
type RuleEventCatalogEntry ¶
type RuleEventCatalogEntry struct {
EventType RuleEventType
Label string
DefaultTemplate string
}
RuleEventCatalogEntry describes a selectable event type for UI/API consumers.
func SupportedRuleEvents ¶
func SupportedRuleEvents() []RuleEventCatalogEntry
SupportedRuleEvents returns the event catalog that UI/API clients can use.
type RuleEventType ¶
type RuleEventType string
RuleEventType identifies a supported notification subscription event.
const ( RuleEventTypeTicketCreated RuleEventType = RuleEventType(activityevent.TypeTicketCreated) RuleEventTypeTicketUpdated RuleEventType = RuleEventType(activityevent.TypeTicketUpdated) RuleEventTypeTicketStatusChanged RuleEventType = RuleEventType(activityevent.TypeTicketStatusChanged) RuleEventTypeTicketCompleted RuleEventType = RuleEventType(activityevent.TypeTicketCompleted) RuleEventTypeTicketCancelled RuleEventType = RuleEventType(activityevent.TypeTicketCancelled) RuleEventTypeTicketRetryScheduled RuleEventType = RuleEventType(activityevent.TypeTicketRetryScheduled) RuleEventTypeTicketRetryPaused RuleEventType = RuleEventType(activityevent.TypeTicketRetryPaused) RuleEventTypeTicketBudgetExhausted RuleEventType = RuleEventType(activityevent.TypeTicketBudgetExhausted) RuleEventTypeAgentClaimed RuleEventType = RuleEventType(activityevent.TypeAgentClaimed) RuleEventTypeAgentFailed RuleEventType = RuleEventType(activityevent.TypeAgentFailed) RuleEventTypeHookFailed RuleEventType = RuleEventType(activityevent.TypeHookFailed) RuleEventTypeHookPassed RuleEventType = RuleEventType(activityevent.TypeHookPassed) RuleEventTypePROpened RuleEventType = RuleEventType(activityevent.TypePROpened) RuleEventTypePRMerged RuleEventType = RuleEventType(activityevent.TypePRMerged) RuleEventTypePRClosed RuleEventType = RuleEventType(activityevent.TypePRClosed) RuleEventTypeTicketStalled RuleEventType = "ticket.stalled" RuleEventTypeTicketErrorRateHigh RuleEventType = "ticket.error_rate_high" RuleEventTypeMachineOffline RuleEventType = "machine.offline" RuleEventTypeMachineOnline RuleEventType = "machine.online" RuleEventTypeMachineDegraded RuleEventType = "machine.degraded" RuleEventTypeConnectorSyncError RuleEventType = "connector.sync_error" RuleEventTypeBudgetThreshold RuleEventType = "budget.threshold" )
func ParseRuleEventType ¶
func ParseRuleEventType(raw string) (RuleEventType, error)
ParseRuleEventType validates a raw event type string against the supported catalog.
func (RuleEventType) DefaultTemplate ¶
func (t RuleEventType) DefaultTemplate() string
DefaultTemplate returns the built-in template for the event type.
func (RuleEventType) String ¶
func (t RuleEventType) String() string
type RuleInput ¶
type RuleInput struct {
Name string `json:"name"`
EventType string `json:"event_type"`
Filter map[string]any `json:"filter"`
ChannelID string `json:"channel_id"`
Template string `json:"template"`
IsEnabled *bool `json:"is_enabled"`
}
RuleInput carries raw rule create values before parsing.
type RulePatchInput ¶
type RulePatchInput struct {
Name *string `json:"name"`
EventType *string `json:"event_type"`
Filter *map[string]any `json:"filter"`
ChannelID *string `json:"channel_id"`
Template *string `json:"template"`
IsEnabled *bool `json:"is_enabled"`
}
RulePatchInput carries raw rule patch values before parsing.
type SlackConfig ¶
type SlackConfig struct {
WebhookURL string
}
SlackConfig holds Slack incoming webhook settings.
type TelegramConfig ¶
TelegramConfig holds Bot API credentials.
type UpdateChannelInput ¶
type UpdateChannelInput struct {
ChannelID uuid.UUID
Name Optional[string]
Type Optional[ChannelType]
Config Optional[map[string]any]
IsEnabled Optional[bool]
}
UpdateChannelInput is the validated patch command input.
func ParseUpdateChannel ¶
func ParseUpdateChannel(channelID uuid.UUID, raw ChannelPatchInput) (UpdateChannelInput, error)
ParseUpdateChannel validates a raw patch request into a typed update command.
type UpdateRuleInput ¶
type UpdateRuleInput struct {
RuleID uuid.UUID
Name Optional[string]
EventType Optional[RuleEventType]
Filter Optional[map[string]any]
ChannelID Optional[uuid.UUID]
Template Optional[string]
IsEnabled Optional[bool]
}
UpdateRuleInput is the parsed patch command.
func ParseUpdateRule ¶
func ParseUpdateRule(ruleID uuid.UUID, raw RulePatchInput) (UpdateRuleInput, error)
ParseUpdateRule validates a raw rule patch request.
type WeComConfig ¶
type WeComConfig struct {
WebhookKey string
}
WeComConfig holds WeCom robot webhook settings.