handlers

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2026 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APILogout

func APILogout(samlMiddleware *samlsp.Middleware, localAuth services.LocalAuthService) gin.HandlerFunc

APILogout handles POST /api/v1/auth/logout — called from the SPA via fetch. Returns JSON so the frontend can handle navigation itself.

func AcknowledgeAlert

func AcknowledgeAlert(
	alertRepo repository.AlertRepository,
	escalationEngine services.EscalationEngine,
	incidentRepo repository.IncidentRepository,
	timelineRepo repository.TimelineRepository,
) gin.HandlerFunc

AcknowledgeAlert handles POST /api/v1/alerts/:id/acknowledge.

Marks the alert as acknowledged (stopping further escalation) and appends a timeline entry to the linked incident (if any). Idempotent.

func CreateActionItem

func CreateActionItem(incidentSvc services.IncidentService, pmSvc services.PostMortemService) gin.HandlerFunc

CreateActionItem handles POST /api/v1/incidents/:id/postmortem/action-items

func CreateEscalationPolicy

func CreateEscalationPolicy(repo repository.EscalationPolicyRepository) gin.HandlerFunc

CreateEscalationPolicy handles POST /api/v1/escalation-policies

func CreateEscalationTier

func CreateEscalationTier(repo repository.EscalationPolicyRepository) gin.HandlerFunc

CreateEscalationTier handles POST /api/v1/escalation-policies/:id/tiers

func CreateFirstUser

func CreateFirstUser(localAuth services.LocalAuthService) gin.HandlerFunc

CreateFirstUser handles POST /api/v1/auth/bootstrap — creates the initial admin account. Returns 409 if any users already exist. This endpoint is unauthenticated on purpose.

func CreateGroupingRule

func CreateGroupingRule(ruleRepo repository.GroupingRuleRepository, onRuleMutate func()) gin.HandlerFunc

CreateGroupingRule handles POST /api/v1/grouping-rules onRuleMutate is called after successful creation to invalidate caches (e.g., grouping engine)

func CreateIncident

func CreateIncident(incidentSvc services.IncidentService) gin.HandlerFunc

CreateIncident handles POST /api/v1/incidents

func CreateLayer

func CreateLayer(repo repository.ScheduleRepository) gin.HandlerFunc

CreateLayer handles POST /api/v1/schedules/:id/layers Accepts the layer definition plus an inline participants array. Participants are bulk-inserted after the layer is created.

func CreateOverride

func CreateOverride(repo repository.ScheduleRepository) gin.HandlerFunc

CreateOverride handles POST /api/v1/schedules/:id/overrides

func CreatePostMortem

func CreatePostMortem(incidentSvc services.IncidentService, pmSvc services.PostMortemService) gin.HandlerFunc

CreatePostMortem handles POST /api/v1/incidents/:id/postmortem Creates a blank draft post-mortem for manual authoring.

func CreatePostMortemComment

func CreatePostMortemComment(incidentSvc services.IncidentService, pmSvc services.PostMortemService) gin.HandlerFunc

CreatePostMortemComment handles POST /api/v1/incidents/:id/postmortem/comments

func CreatePostMortemTemplate

func CreatePostMortemTemplate(svc services.PostMortemService) gin.HandlerFunc

CreatePostMortemTemplate handles POST /api/v1/post-mortem-templates

func CreateRoutingRule

func CreateRoutingRule(ruleRepo repository.RoutingRuleRepository, onRuleMutate func()) gin.HandlerFunc

CreateRoutingRule handles POST /api/v1/routing-rules onRuleMutate is called after successful creation to invalidate the routing engine cache.

func CreateSchedule

func CreateSchedule(repo repository.ScheduleRepository) gin.HandlerFunc

CreateSchedule handles POST /api/v1/schedules

func CreateTimelineEntry

func CreateTimelineEntry(incidentSvc services.IncidentService, userRepo repository.UserRepository) gin.HandlerFunc

CreateTimelineEntry handles POST /api/v1/incidents/:id/timeline

func CreateUnavailability

func CreateUnavailability(repo repository.ScheduleRepository) gin.HandlerFunc

CreateUnavailability handles POST /api/v1/schedules/:id/unavailabilities

func CreateUser

func CreateUser(localAuth services.LocalAuthService, userLimit int) gin.HandlerFunc

CreateUser handles POST /api/v1/settings/users

func DeactivateUser

func DeactivateUser(localAuth services.LocalAuthService) gin.HandlerFunc

DeactivateUser handles DELETE /api/v1/settings/users/:id

func DeleteActionItem

func DeleteActionItem(incidentSvc services.IncidentService, pmSvc services.PostMortemService) gin.HandlerFunc

DeleteActionItem handles DELETE /api/v1/incidents/:id/postmortem/action-items/:itemId

func DeleteEscalationPolicy

func DeleteEscalationPolicy(repo repository.EscalationPolicyRepository) gin.HandlerFunc

DeleteEscalationPolicy handles DELETE /api/v1/escalation-policies/:id

func DeleteEscalationTier

func DeleteEscalationTier(repo repository.EscalationPolicyRepository) gin.HandlerFunc

DeleteEscalationTier handles DELETE /api/v1/escalation-policies/:id/tiers/:tier_id

func DeleteGroupingRule

func DeleteGroupingRule(ruleRepo repository.GroupingRuleRepository, onRuleMutate func()) gin.HandlerFunc

DeleteGroupingRule handles DELETE /api/v1/grouping-rules/:id onRuleMutate is called after successful deletion to invalidate caches

func DeleteLayer

func DeleteLayer(repo repository.ScheduleRepository) gin.HandlerFunc

DeleteLayer handles DELETE /api/v1/schedules/:id/layers/:layer_id

func DeleteOverride

func DeleteOverride(repo repository.ScheduleRepository) gin.HandlerFunc

DeleteOverride handles DELETE /api/v1/schedules/:id/overrides/:override_id

func DeletePostMortemComment

func DeletePostMortemComment(incidentSvc services.IncidentService, pmSvc services.PostMortemService) gin.HandlerFunc

DeletePostMortemComment handles DELETE /api/v1/incidents/:id/postmortem/comments/:commentId

func DeletePostMortemTemplate

func DeletePostMortemTemplate(svc services.PostMortemService) gin.HandlerFunc

DeletePostMortemTemplate handles DELETE /api/v1/post-mortem-templates/:id

func DeleteRoutingRule

func DeleteRoutingRule(ruleRepo repository.RoutingRuleRepository, onRuleMutate func()) gin.HandlerFunc

DeleteRoutingRule handles DELETE /api/v1/routing-rules/:id onRuleMutate is called after successful deletion to invalidate the routing engine cache.

func DeleteSchedule

func DeleteSchedule(repo repository.ScheduleRepository) gin.HandlerFunc

DeleteSchedule handles DELETE /api/v1/schedules/:id

func DeleteSeverityRule

func DeleteSeverityRule(repo repository.EscalationPolicyRepository) gin.HandlerFunc

DeleteSeverityRule handles DELETE /api/v1/escalation-policies/severity-rules/:severity

func DeleteSlackConfig

func DeleteSlackConfig(repo repository.SlackConfigRepository) gin.HandlerFunc

DeleteSlackConfig removes the Slack integration.

func DeleteTeamsConfig

func DeleteTeamsConfig(repo repository.TeamsConfigRepository) gin.HandlerFunc

DeleteTeamsConfig removes the Teams integration.

func DeleteTelegramConfig

func DeleteTelegramConfig(repo repository.TelegramConfigRepository, incidentSvc services.IncidentService) gin.HandlerFunc

DeleteTelegramConfig removes the Telegram integration and disables the in-memory service.

func DeleteUnavailability

func DeleteUnavailability(repo repository.ScheduleRepository) gin.HandlerFunc

DeleteUnavailability handles DELETE /api/v1/schedules/:id/unavailabilities/:uid

func DownloadTeamsAppPackage

func DownloadTeamsAppPackage(repo repository.TeamsConfigRepository) gin.HandlerFunc

DownloadTeamsAppPackage generates and streams a sideloadable Teams app zip. The package contains manifest.json (with the stored bot App ID) and two icons.

func EnhanceIncidentDraft

func EnhanceIncidentDraft(aiSvc services.AIService) gin.HandlerFunc

EnhanceIncidentDraft handles POST /api/v1/ai/enhance-draft

Converts a rough user-written brief into a professional incident title + summary. Does not create an incident — purely a pre-creation AI assist. Returns 503 if AI is not configured.

func EnhancePostMortem

func EnhancePostMortem(incidentSvc services.IncidentService, pmSvc services.PostMortemService, aiSvc services.AIService) gin.HandlerFunc

EnhancePostMortem handles POST /api/v1/incidents/:id/postmortem/enhance Takes existing content, runs it through AI to improve structure/clarity, saves as draft.

func EscalateIncident

func EscalateIncident(engine services.EscalationEngine) gin.HandlerFunc

EscalateIncident handles POST /api/v1/incidents/:id/escalate. Body: {"escalation_policy_id": "uuid"}

Manually triggers an escalation for an incident, independent of the alert processing pipeline. Idempotent — triggering again while one is active is a no-op.

func ExportPostMortem

func ExportPostMortem(incidentSvc services.IncidentService, pmSvc services.PostMortemService) gin.HandlerFunc

ExportPostMortem handles GET /api/v1/incidents/:id/postmortem/export Returns the post-mortem content as a downloadable Markdown file.

func FetchTelegramChatID

func FetchTelegramChatID() gin.HandlerFunc

FetchTelegramChatID calls getUpdates to discover the chat ID from recent messages.

func ForgotPassword

func ForgotPassword(localAuth services.LocalAuthService) gin.HandlerFunc

ForgotPassword handles POST /api/v1/auth/forgot-password. Generates a one-time setup token for the given email and returns it so the caller can share the reset link out-of-band (Slack, email, etc.). Always returns 200 regardless of whether the email exists to avoid user enumeration.

func GenerateHandoffDigest

func GenerateHandoffDigest(incidentSvc services.IncidentService, aiSvc services.AIService) gin.HandlerFunc

GenerateHandoffDigest handles POST /api/v1/incidents/:id/handoff-digest

Generates a structured shift handoff document for the incoming on-call engineer. The digest is not persisted — callers can post it to Slack or display in the UI.

func GeneratePostMortem

func GeneratePostMortem(incidentSvc services.IncidentService, pmSvc services.PostMortemService, aiSvc services.AIService) gin.HandlerFunc

GeneratePostMortem handles POST /api/v1/incidents/:id/postmortem/generate

func GetAISettings

func GetAISettings(aiSvc services.AIService) gin.HandlerFunc

GetAISettings handles GET /api/v1/settings/ai

Returns whether AI features are enabled. Frontend uses this to show/hide AI controls.

func GetAlert

func GetAlert(alertRepo repository.AlertRepository) gin.HandlerFunc

GetAlert handles GET /api/v1/alerts/:id.

func GetAnnouncements

func GetAnnouncements(getCached func() []byte) gin.HandlerFunc

GetAnnouncements handles GET /api/v1/announcements. It serves the cached announcement JSON fetched by the telemetry worker from api.fluidify.ai/regen/announcements. Returns an empty list when nothing is cached.

func GetCurrentUser

func GetCurrentUser(localAuth services.LocalAuthService, samlConfigured bool) gin.HandlerFunc

GetCurrentUser handles GET /api/v1/auth/me.

func GetEscalationPolicy

func GetEscalationPolicy(repo repository.EscalationPolicyRepository) gin.HandlerFunc

GetEscalationPolicy handles GET /api/v1/escalation-policies/:id

func GetEscalationSettings

func GetEscalationSettings(repo repository.SystemSettingsRepository) gin.HandlerFunc

GetEscalationSettings handles GET /api/v1/settings/escalation

func GetGroupingRule

func GetGroupingRule(ruleRepo repository.GroupingRuleRepository) gin.HandlerFunc

GetGroupingRule handles GET /api/v1/grouping-rules/:id

func GetHolidays

func GetHolidays(repo repository.ScheduleRepository) gin.HandlerFunc

GetHolidays handles GET /api/v1/schedules/:id/holidays

func GetIncident

func GetIncident(incidentSvc services.IncidentService, userRepo repository.UserRepository) gin.HandlerFunc

GetIncident handles GET /api/v1/incidents/:id

func GetIncidentTimeline

func GetIncidentTimeline(incidentSvc services.IncidentService, userRepo repository.UserRepository) gin.HandlerFunc

GetIncidentTimeline handles GET /api/v1/incidents/:id/timeline

func GetLayerTimelines

func GetLayerTimelines(evaluator services.ScheduleEvaluator) gin.HandlerFunc

GetLayerTimelines handles GET /api/v1/schedules/:id/layer-timelines Returns per-layer on-call timelines plus the effective merged timeline. Query params: from, to (ISO 8601 / RFC3339 timestamps; default = next 7 days)

func GetOnCall

GetOnCall handles GET /api/v1/schedules/:id/oncall?at=<RFC3339> If `at` is omitted, uses time.Now().

func GetOnCallTimeline

func GetOnCallTimeline(evaluator services.ScheduleEvaluator) gin.HandlerFunc

GetOnCallTimeline handles GET /api/v1/schedules/:id/oncall/timeline?from=&to= Both `from` and `to` are optional RFC3339 strings; default window is next 7 days.

func GetPostMortem

func GetPostMortem(incidentSvc services.IncidentService, pmSvc services.PostMortemService) gin.HandlerFunc

GetPostMortem handles GET /api/v1/incidents/:id/postmortem

func GetPostMortemTemplate

func GetPostMortemTemplate(svc services.PostMortemService) gin.HandlerFunc

GetPostMortemTemplate handles GET /api/v1/post-mortem-templates/:id

func GetRoutingRule

func GetRoutingRule(ruleRepo repository.RoutingRuleRepository) gin.HandlerFunc

GetRoutingRule handles GET /api/v1/routing-rules/:id

func GetSchedule

func GetSchedule(repo repository.ScheduleRepository) gin.HandlerFunc

GetSchedule handles GET /api/v1/schedules/:id Returns the schedule with all layers and participants embedded.

func GetSetupStatus

func GetSetupStatus(
	incidentRepo repository.IncidentRepository,
	slackConfigRepo repository.SlackConfigRepository,
	scheduleRepo repository.ScheduleRepository,
) gin.HandlerFunc

GetSetupStatus handles GET /api/v1/setup/status.

func GetSlackConfig

func GetSlackConfig(repo repository.SlackConfigRepository) gin.HandlerFunc

GetSlackConfig returns Slack connection status (no token values).

func GetSlackOAuthConfig

func GetSlackOAuthConfig(repo repository.SlackConfigRepository) gin.HandlerFunc

GetSlackOAuthConfig returns whether Slack OAuth login is enabled (public endpoint — no auth required).

func GetStatusPage

func GetStatusPage(incidentRepo repository.IncidentRepository, settingsRepo repository.SystemSettingsRepository) gin.HandlerFunc

GetStatusPage returns an unauthenticated status page payload. Active = triggered or acknowledged. Recently resolved = resolved/canceled in last 7 days.

func GetSystemSettings

func GetSystemSettings(repo repository.SystemSettingsRepository, aiSvc services.AIService, telemetryDisabled bool) gin.HandlerFunc

GetSystemSettings handles GET /api/v1/settings/system telemetryDisabled reflects the REGEN_NO_TELEMETRY env var so the UI can show whether telemetry was disabled at the infrastructure level (not just via the toggle).

func GetTeamsConfig

func GetTeamsConfig(repo repository.TeamsConfigRepository) gin.HandlerFunc

GetTeamsConfig returns Teams connection status (no secret values).

func GetTeamsSettings

func GetTeamsSettings(teamsSvc *services.TeamsService) gin.HandlerFunc

GetTeamsSettings returns the current Teams integration configuration status. Does not expose credentials — only whether Teams is configured.

Route: GET /api/v1/settings/teams

func GetTelegramConfig

func GetTelegramConfig(repo repository.TelegramConfigRepository) gin.HandlerFunc

GetTelegramConfig returns Telegram connection status (never returns the token).

func GetUserLimit

func GetUserLimit(localAuth services.LocalAuthService, limit int) gin.HandlerFunc

GetUserLimit handles GET /api/v1/settings/users/limit Returns current user count, the OSS limit, and whether the install is at or near the limit.

func Health

func Health(db *gorm.DB) gin.HandlerFunc

Health returns a simple health check

func ImportOnCallMigration

func ImportOnCallMigration(
	localAuth services.LocalAuthService,
	scheduleRepo repository.ScheduleRepository,
	escalationRepo repository.EscalationPolicyRepository,
	cfg *config.Config,
) gin.HandlerFunc

ImportOnCallMigration handles POST /api/v1/migrations/oncall/import. It fetches, transforms, and persists all importable data, returning a summary.

func ImportOpsgenieMigration

func ImportOpsgenieMigration(
	scheduleRepo repository.ScheduleRepository,
	escalationRepo repository.EscalationPolicyRepository,
) gin.HandlerFunc

ImportOpsgenieMigration handles POST /api/v1/migrations/opsgenie/import.

func ImportPagerDutyMigration

func ImportPagerDutyMigration(
	scheduleRepo repository.ScheduleRepository,
	escalationRepo repository.EscalationPolicyRepository,
) gin.HandlerFunc

ImportPagerDutyMigration handles POST /api/v1/migrations/pagerduty/import. Validates the API key, fetches PD data, and persists schedules and escalation policies.

func InitSlackOAuth

func InitSlackOAuth(slackRepo repository.SlackConfigRepository) gin.HandlerFunc

InitSlackOAuth redirects the browser to Slack's OpenID Connect authorization endpoint.

func ListAlerts

func ListAlerts(alertRepo repository.AlertRepository) gin.HandlerFunc

ListAlerts handles GET /api/v1/alerts.

Returns a paginated list of alerts, optionally filtered by source, status, and severity.

func ListEscalationPolicies

func ListEscalationPolicies(repo repository.EscalationPolicyRepository) gin.HandlerFunc

ListEscalationPolicies handles GET /api/v1/escalation-policies

func ListGroupingRules

func ListGroupingRules(ruleRepo repository.GroupingRuleRepository) gin.HandlerFunc

ListGroupingRules handles GET /api/v1/grouping-rules

func ListIncidents

func ListIncidents(incidentSvc services.IncidentService) gin.HandlerFunc

ListIncidents handles GET /api/v1/incidents

func ListOverrides

func ListOverrides(repo repository.ScheduleRepository) gin.HandlerFunc

ListOverrides handles GET /api/v1/schedules/:id/overrides Returns all upcoming overrides (end_time > now) ordered by start_time ASC.

func ListPostMortemComments

func ListPostMortemComments(incidentSvc services.IncidentService, pmSvc services.PostMortemService) gin.HandlerFunc

ListPostMortemComments handles GET /api/v1/incidents/:id/postmortem/comments

func ListPostMortemTemplates

func ListPostMortemTemplates(svc services.PostMortemService) gin.HandlerFunc

ListPostMortemTemplates handles GET /api/v1/post-mortem-templates

func ListRoutingRules

func ListRoutingRules(ruleRepo repository.RoutingRuleRepository) gin.HandlerFunc

ListRoutingRules handles GET /api/v1/routing-rules

func ListSchedules

func ListSchedules(repo repository.ScheduleRepository) gin.HandlerFunc

ListSchedules handles GET /api/v1/schedules

func ListSeverityRules

func ListSeverityRules(repo repository.EscalationPolicyRepository) gin.HandlerFunc

ListSeverityRules handles GET /api/v1/escalation-policies/severity-rules

func ListSlackMembers

func ListSlackMembers(slackRepo repository.SlackConfigRepository, userRepo repository.UserRepository) gin.HandlerFunc

ListSlackMembers handles GET /api/v1/settings/slack/members. Returns all non-bot, non-deleted workspace members. Each member is annotated with already_imported=true if a user with that email exists in Fluidify Regen. Used by the "Import from Slack" modal in Settings → Users.

func ListTeamsMembers

func ListTeamsMembers(teamsConfigRepo repository.TeamsConfigRepository, userRepo repository.UserRepository) gin.HandlerFunc

ListTeamsMembers handles GET /api/v1/settings/teams/members. Returns all AAD members of the configured team. Each member is annotated with already_imported=true if a user with that email already exists in Fluidify Regen.

func ListUnavailabilities

func ListUnavailabilities(repo repository.ScheduleRepository) gin.HandlerFunc

ListUnavailabilities handles GET /api/v1/schedules/:id/unavailabilities

func ListUsers

func ListUsers(localAuth services.LocalAuthService) gin.HandlerFunc

ListUsers handles GET /api/v1/settings/users

func ListUsersForAssignment

func ListUsersForAssignment(userRepo repository.UserRepository) gin.HandlerFunc

ListUsersForAssignment returns minimal user info for all active users. Available to all authenticated users (not just admins) for commander assignment.

func Login

func Login(localAuth services.LocalAuthService) gin.HandlerFunc

Login handles POST /api/v1/auth/login — email/password authentication.

func Logout

func Logout(samlMiddleware *samlsp.Middleware, localAuth services.LocalAuthService) gin.HandlerFunc

Logout handles GET /auth/logout — browser redirect flow (kept for backwards compatibility).

func PatchTelemetrySettings

func PatchTelemetrySettings(repo repository.SystemSettingsRepository) gin.HandlerFunc

PatchTelemetrySettings handles PATCH /api/v1/settings/system/telemetry

func PreviewOnCallMigration

func PreviewOnCallMigration(
	localAuth services.LocalAuthService,
	scheduleRepo repository.ScheduleRepository,
	escalationRepo repository.EscalationPolicyRepository,
	cfg *config.Config,
) gin.HandlerFunc

PreviewOnCallMigration handles POST /api/v1/migrations/oncall/preview. It fetches all data from the remote Grafana OnCall instance, runs the transformation, and returns what would be created — without writing to the DB.

func PreviewOpsgenieMigration

func PreviewOpsgenieMigration(
	scheduleRepo repository.ScheduleRepository,
	escalationRepo repository.EscalationPolicyRepository,
) gin.HandlerFunc

PreviewOpsgenieMigration handles POST /api/v1/migrations/opsgenie/preview.

func PreviewPagerDutyMigration

func PreviewPagerDutyMigration(
	scheduleRepo repository.ScheduleRepository,
	escalationRepo repository.EscalationPolicyRepository,
) gin.HandlerFunc

PreviewPagerDutyMigration handles POST /api/v1/migrations/pagerduty/preview. Validates the API key, fetches PD data, and returns a summary without writing to the DB.

func PrometheusWebhook

func PrometheusWebhook(alertSvc services.AlertService) gin.HandlerFunc

PrometheusWebhook handles incoming Prometheus Alertmanager webhooks

func Ready

func Ready(db *gorm.DB) gin.HandlerFunc

Ready checks if the application is ready to serve requests

func ReorderRoutingRules

func ReorderRoutingRules(ruleRepo repository.RoutingRuleRepository, onRuleMutate func()) gin.HandlerFunc

ReorderRoutingRules handles PUT /api/v1/routing-rules/reorder Body: { "ids": ["uuid1", "uuid2", ...] } — ordered from first-evaluated to last. Assigns priorities 10, 20, 30 … in a single transaction.

func ResetUserPassword

func ResetUserPassword(localAuth services.LocalAuthService) gin.HandlerFunc

ResetUserPassword handles POST /api/v1/settings/users/:id/reset-password

func SaveSlackConfig

func SaveSlackConfig(repo repository.SlackConfigRepository) gin.HandlerFunc

SaveSlackConfig stores Slack tokens.

func SaveTeamsConfig

func SaveTeamsConfig(repo repository.TeamsConfigRepository) gin.HandlerFunc

SaveTeamsConfig stores Teams credentials.

func SaveTelegramConfig

func SaveTelegramConfig(repo repository.TelegramConfigRepository, incidentSvc services.IncidentService, appURL string) gin.HandlerFunc

SaveTelegramConfig stores bot token and chat ID and hot-reloads the in-memory service.

func SeedDemoData

SeedDemoData handles POST /api/v1/setup/demo-data. Admin-only. Creates a sample schedule, escalation policy, routing rule, and a pre-resolved incident so new installs feel populated out of the box. Returns 409 if demo data (or any real incident with number=1) already exists.

func SetupTokenLogin

func SetupTokenLogin(localAuth services.LocalAuthService) gin.HandlerFunc

SetupTokenLogin handles POST /api/v1/auth/login/setup-token. Exchanges a one-time setup token (generated by CreateUser or ResetPassword) for a live session cookie so the recipient of an invite link is logged in immediately without needing to know the password.

func SlackOAuthCallback

func SlackOAuthCallback(slackRepo repository.SlackConfigRepository, localAuth services.LocalAuthService) gin.HandlerFunc

SlackOAuthCallback handles Slack's redirect after the user approves the OAuth prompt. It exchanges the code for an ID token, looks up the user by email, and creates a session.

func SummarizeIncident

func SummarizeIncident(incidentSvc services.IncidentService, aiSvc services.AIService) gin.HandlerFunc

SummarizeIncident handles POST /api/v1/incidents/:id/summarize

Generates an AI-powered summary of the incident using timeline, alert, and Slack thread context. The summary is persisted on the incident and returned. Returns 503 if OpenAI is not configured (OPENAI_API_KEY not set).

func TeamsWebhook

func TeamsWebhook(handler *services.TeamsEventHandler) gin.HandlerFunc

TeamsWebhook receives Bot Framework activity payloads from Microsoft Teams and delegates processing to the TeamsEventHandler.

Route: POST /api/v1/webhooks/teams Auth: Handled by middleware.TeamsAuth before this handler

func TestAIKey

TestAIKey handles POST /api/v1/settings/system/ai/test Validates that the given provider credentials are sufficient to enable AI features.

func TestSlackConfig

func TestSlackConfig() gin.HandlerFunc

TestSlackConfig calls auth.test on the Slack API and returns workspace info.

func TestTeamsConfig

func TestTeamsConfig() gin.HandlerFunc

TestTeamsConfig validates Teams credentials against the Graph API.

func TestTelegramConfig

func TestTelegramConfig() gin.HandlerFunc

TestTelegramConfig validates the bot token and sends a test message.

func UpdateActionItem

func UpdateActionItem(incidentSvc services.IncidentService, pmSvc services.PostMortemService) gin.HandlerFunc

UpdateActionItem handles PATCH /api/v1/incidents/:id/postmortem/action-items/:itemId

func UpdateEscalationPolicy

func UpdateEscalationPolicy(repo repository.EscalationPolicyRepository) gin.HandlerFunc

UpdateEscalationPolicy handles PATCH /api/v1/escalation-policies/:id

func UpdateEscalationSettings

func UpdateEscalationSettings(repo repository.SystemSettingsRepository) gin.HandlerFunc

UpdateEscalationSettings handles PUT /api/v1/settings/escalation

func UpdateEscalationTier

func UpdateEscalationTier(repo repository.EscalationPolicyRepository) gin.HandlerFunc

UpdateEscalationTier handles PATCH /api/v1/escalation-policies/:id/tiers/:tier_id

func UpdateGroupingRule

func UpdateGroupingRule(ruleRepo repository.GroupingRuleRepository, onRuleMutate func()) gin.HandlerFunc

UpdateGroupingRule handles PUT /api/v1/grouping-rules/:id onRuleMutate is called after successful update to invalidate caches

func UpdateIncident

func UpdateIncident(incidentSvc services.IncidentService) gin.HandlerFunc

UpdateIncident handles PATCH /api/v1/incidents/:id

func UpdateLayer

func UpdateLayer(repo repository.ScheduleRepository) gin.HandlerFunc

UpdateLayer handles PATCH /api/v1/schedules/:id/layers/:layer_id Updates layer metadata and, if participants are provided, replaces them atomically.

func UpdateMe

func UpdateMe(localAuth services.LocalAuthService) gin.HandlerFunc

UpdateMe handles PATCH /api/v1/auth/me — lets the logged-in user update their own display name and/or password without admin privileges.

func UpdatePostMortem

func UpdatePostMortem(incidentSvc services.IncidentService, pmSvc services.PostMortemService) gin.HandlerFunc

UpdatePostMortem handles PATCH /api/v1/incidents/:id/postmortem

func UpdatePostMortemTemplate

func UpdatePostMortemTemplate(svc services.PostMortemService) gin.HandlerFunc

UpdatePostMortemTemplate handles PATCH /api/v1/post-mortem-templates/:id

func UpdateRoutingRule

func UpdateRoutingRule(ruleRepo repository.RoutingRuleRepository, onRuleMutate func()) gin.HandlerFunc

UpdateRoutingRule handles PATCH /api/v1/routing-rules/:id onRuleMutate is called after successful update to invalidate the routing engine cache.

func UpdateSchedule

func UpdateSchedule(repo repository.ScheduleRepository, holidaySvc *services.HolidayService) gin.HandlerFunc

UpdateSchedule handles PATCH /api/v1/schedules/:id

func UpdateSystemSettings

func UpdateSystemSettings(repo repository.SystemSettingsRepository, aiSvc services.AIService) gin.HandlerFunc

UpdateSystemSettings handles PATCH /api/v1/settings/system

func UpdateUser

func UpdateUser(localAuth services.LocalAuthService) gin.HandlerFunc

UpdateUser handles PATCH /api/v1/settings/users/:id

func UpsertSeverityRule

func UpsertSeverityRule(repo repository.EscalationPolicyRepository) gin.HandlerFunc

UpsertSeverityRule handles PUT /api/v1/escalation-policies/severity-rules/:severity

Types

type AgentsHandler

type AgentsHandler struct {
	// contains filtered or unexported fields
}

AgentsHandler manages AI agent endpoints.

func NewAgentsHandler

func NewAgentsHandler(userRepo repository.UserRepository) *AgentsHandler

NewAgentsHandler constructs an AgentsHandler backed by the given UserRepository.

func (*AgentsHandler) List

func (h *AgentsHandler) List(c *gin.Context)

List returns all AI agent users. GET /api/v1/agents

func (*AgentsHandler) SetStatus

func (h *AgentsHandler) SetStatus(c *gin.Context)

SetStatus enables or disables an AI agent. PATCH /api/v1/agents/:id/status Body: { "active": true|false }

type StatusIncident

type StatusIncident struct {
	IncidentNumber int        `json:"incident_number"`
	Title          string     `json:"title"`
	Severity       string     `json:"severity"`
	Status         string     `json:"status"`
	TriggeredAt    time.Time  `json:"triggered_at"`
	ResolvedAt     *time.Time `json:"resolved_at,omitempty"`
	DurationSecs   *int64     `json:"duration_seconds,omitempty"`
}

StatusIncident is the public-facing incident shape for the status page.

type StatusPageResponse

type StatusPageResponse struct {
	OrgName          string           `json:"org_name"`
	GeneratedAt      time.Time        `json:"generated_at"`
	ActiveIncidents  []StatusIncident `json:"active_incidents"`
	RecentlyResolved []StatusIncident `json:"recently_resolved"`
}

StatusPageResponse is the full status page payload.

type WebhookHandler

type WebhookHandler struct {
	// contains filtered or unexported fields
}

WebhookHandler is a unified handler for all webhook providers (v0.3+).

Instead of having separate handlers for Prometheus, Grafana, CloudWatch, and Generic, we use a single handler that delegates to the WebhookProvider interface. This makes the handler code source-agnostic.

Flow:

  1. Read raw request body (needed for signature validation)
  2. Provider.ValidatePayload() - check authentication
  3. Provider.ParsePayload() - normalize to []NormalizedAlert
  4. AlertService.ProcessNormalizedAlerts() - create/update alerts and incidents
  5. Return success response with statistics

Each webhook route (e.g., POST /webhooks/grafana) instantiates this handler with the appropriate provider (e.g., &webhooks.GrafanaProvider{}).

func NewWebhookHandler

func NewWebhookHandler(provider webhooks.WebhookProvider, alertService services.AlertService) *WebhookHandler

NewWebhookHandler creates a handler for a specific webhook provider.

Example usage in routes.go:

grafanaHandler := NewWebhookHandler(&webhooks.GrafanaProvider{}, alertService)
router.POST("/webhooks/grafana", grafanaHandler.Handle)

func (*WebhookHandler) Handle

func (h *WebhookHandler) Handle(c *gin.Context)

Handle processes an incoming webhook request from any monitoring source.

This is the unified entry point for Prometheus, Grafana, CloudWatch, and Generic webhooks. The provider parameter determines how the payload is validated and parsed.

func (*WebhookHandler) HandleSchema

func (h *WebhookHandler) HandleSchema(c *gin.Context)

HandleSchema returns the JSON Schema for the generic webhook format.

This is only used for the Generic webhook provider to provide self-documenting API. Served at GET /api/v1/webhooks/generic/schema

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL