api

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UIAssets embed.FS

UIAssets holds the embedded UI files (set from main)

View Source
var Version = "dev"

Version is the operator version (set at build time)

Functions

This section is empty.

Types

type ActiveJobItem

type ActiveJobItem struct {
	Name            string    `json:"name"`
	StartTime       time.Time `json:"startTime"`
	RunningDuration string    `json:"runningDuration,omitempty"`
	PodPhase        string    `json:"podPhase,omitempty"`
	PodName         string    `json:"podName,omitempty"`
	Ready           string    `json:"ready,omitempty"`
}

ActiveJobItem represents a currently running job

type AlertContextResponse

type AlertContextResponse struct {
	ExitCode     int32  `json:"exitCode,omitempty"`
	Reason       string `json:"reason,omitempty"`
	SuggestedFix string `json:"suggestedFix,omitempty"`
}

AlertContextResponse contains context data for an alert (suggested fixes, exit codes, etc.)

type AlertHistoryItem

type AlertHistoryItem struct {
	ID               string         `json:"id"`
	Type             string         `json:"type"`
	Severity         string         `json:"severity"`
	Title            string         `json:"title"`
	Message          string         `json:"message"`
	CronJob          *NamespacedRef `json:"cronjob,omitempty"`
	OccurredAt       time.Time      `json:"occurredAt"`
	ResolvedAt       *time.Time     `json:"resolvedAt,omitempty"`
	ChannelsNotified []string       `json:"channelsNotified"`
	// Context fields for failure alerts
	ExitCode     int32  `json:"exitCode,omitempty"`
	Reason       string `json:"reason,omitempty"`
	SuggestedFix string `json:"suggestedFix,omitempty"`
}

AlertHistoryItem is a single historical alert

type AlertHistoryResponse

type AlertHistoryResponse struct {
	Items      []AlertHistoryItem `json:"items"`
	Pagination Pagination         `json:"pagination"`
}

AlertHistoryResponse is the response for GET /api/v1/alerts/history

type AlertItem

type AlertItem struct {
	ID           string                `json:"id"`
	Type         string                `json:"type"`
	Severity     string                `json:"severity"`
	Title        string                `json:"title"`
	Message      string                `json:"message"`
	CronJob      *NamespacedRef        `json:"cronjob,omitempty"`
	Monitor      *NamespacedRef        `json:"monitor,omitempty"`
	Since        time.Time             `json:"since"`
	LastNotified *time.Time            `json:"lastNotified,omitempty"`
	Context      *AlertContextResponse `json:"context,omitempty"`
}

AlertItem is a single alert

type AlertListResponse

type AlertListResponse struct {
	Items      []AlertItem    `json:"items"`
	Total      int            `json:"total"`
	BySeverity map[string]int `json:"bySeverity"`
}

AlertListResponse is the response for GET /api/v1/alerts

type ChannelListItem

type ChannelListItem struct {
	Name     string         `json:"name"`
	Type     string         `json:"type"`
	Ready    bool           `json:"ready"`
	Config   map[string]any `json:"config,omitempty"`
	Stats    ChannelStats   `json:"stats"`
	LastTest *TestResult    `json:"lastTest,omitempty"`
}

ChannelListItem is a single channel in the list

type ChannelListResponse

type ChannelListResponse struct {
	Items   []ChannelListItem `json:"items"`
	Summary ChannelSummary    `json:"summary"`
}

ChannelListResponse is the response for GET /api/v1/channels

type ChannelStats

type ChannelStats struct {
	AlertsSentTotal     int64      `json:"alertsSentTotal"`
	AlertsFailedTotal   int64      `json:"alertsFailedTotal"`
	LastAlertTime       *time.Time `json:"lastAlertTime,omitempty"`
	LastFailedTime      *time.Time `json:"lastFailedTime,omitempty"`
	LastFailedError     string     `json:"lastFailedError,omitempty"`
	ConsecutiveFailures int32      `json:"consecutiveFailures"`
}

ChannelStats contains channel statistics

type ChannelSummary

type ChannelSummary struct {
	Total    int `json:"total"`
	Ready    int `json:"ready"`
	NotReady int `json:"notReady"`
}

ChannelSummary contains channel summary

type ConfigResponse

type ConfigResponse struct {
	LogLevel         string                        `json:"logLevel"`
	Storage          config.StorageConfig          `json:"storage"`
	HistoryRetention config.HistoryRetentionConfig `json:"historyRetention"`
	RateLimits       config.RateLimitsConfig       `json:"rateLimits"`
	UI               config.UIConfig               `json:"ui"`
	Scheduler        config.SchedulerConfig        `json:"scheduler"`
}

ConfigResponse represents the operator configuration for the API

type CronJobDetailResponse

type CronJobDetailResponse struct {
	Name          string            `json:"name"`
	Namespace     string            `json:"namespace"`
	Status        string            `json:"status"`
	Schedule      string            `json:"schedule"`
	Timezone      string            `json:"timezone,omitempty"`
	Suspended     bool              `json:"suspended"`
	MonitorRef    *NamespacedRef    `json:"monitorRef,omitempty"`
	Metrics       *CronJobMetrics   `json:"metrics,omitempty"`
	LastExecution *ExecutionSummary `json:"lastExecution,omitempty"`
	NextRun       *time.Time        `json:"nextRun,omitempty"`
	ActiveJobs    []ActiveJobItem   `json:"activeJobs,omitempty"`
	ActiveAlerts  []AlertItem       `json:"activeAlerts"`
}

CronJobDetailResponse is the response for GET /api/v1/cronjobs/:namespace/:name

type CronJobListItem

type CronJobListItem struct {
	Name            string          `json:"name"`
	Namespace       string          `json:"namespace"`
	Status          string          `json:"status"`
	Schedule        string          `json:"schedule"`
	Timezone        string          `json:"timezone,omitempty"`
	Suspended       bool            `json:"suspended"`
	SuccessRate     float64         `json:"successRate"`
	LastSuccess     *time.Time      `json:"lastSuccess,omitempty"`
	LastRunDuration string          `json:"lastRunDuration,omitempty"`
	NextRun         *time.Time      `json:"nextRun,omitempty"`
	ActiveJobs      []ActiveJobItem `json:"activeJobs,omitempty"`
	ActiveAlerts    int             `json:"activeAlerts"`
	MonitorRef      *NamespacedRef  `json:"monitorRef,omitempty"`
}

CronJobListItem is a single CronJob in the list

type CronJobListResponse

type CronJobListResponse struct {
	Items   []CronJobListItem `json:"items"`
	Summary SummaryStats      `json:"summary"`
}

CronJobListResponse is the response for GET /api/v1/cronjobs

type CronJobMetrics

type CronJobMetrics struct {
	SuccessRate7d      float64 `json:"successRate7d"`
	SuccessRate30d     float64 `json:"successRate30d"`
	TotalRuns7d        int32   `json:"totalRuns7d"`
	SuccessfulRuns7d   int32   `json:"successfulRuns7d"`
	FailedRuns7d       int32   `json:"failedRuns7d"`
	AvgDurationSeconds float64 `json:"avgDurationSeconds"`
	P50DurationSeconds float64 `json:"p50DurationSeconds"`
	P95DurationSeconds float64 `json:"p95DurationSeconds"`
	P99DurationSeconds float64 `json:"p99DurationSeconds"`
}

CronJobMetrics contains SLA metrics

type DeleteHistoryResponse

type DeleteHistoryResponse struct {
	Success        bool   `json:"success"`
	RecordsDeleted int64  `json:"recordsDeleted"`
	Message        string `json:"message"`
}

DeleteHistoryResponse is the response for DELETE /api/v1/cronjobs/:namespace/:name/history

type ErrorDetail

type ErrorDetail struct {
	Code    string         `json:"code"`
	Message string         `json:"message"`
	Details map[string]any `json:"details,omitempty"`
}

ErrorDetail contains error details

type ErrorResponse

type ErrorResponse struct {
	Error ErrorDetail `json:"error"`
}

ErrorResponse is the standard error response

type ExecutionDetailResponse

type ExecutionDetailResponse struct {
	ID               int64      `json:"id"`
	CronJobNamespace string     `json:"cronJobNamespace"`
	CronJobName      string     `json:"cronJobName"`
	CronJobUID       string     `json:"cronJobUID,omitempty"`
	JobName          string     `json:"jobName"`
	Status           string     `json:"status"`
	StartTime        time.Time  `json:"startTime"`
	CompletionTime   *time.Time `json:"completionTime,omitempty"`
	Duration         string     `json:"duration"`
	ExitCode         int32      `json:"exitCode"`
	Reason           string     `json:"reason,omitempty"`
	IsRetry          bool       `json:"isRetry"`
	RetryOf          string     `json:"retryOf,omitempty"`
	StoredLogs       string     `json:"storedLogs,omitempty"`
	StoredEvents     string     `json:"storedEvents,omitempty"`
}

ExecutionDetailResponse is the response for GET /api/v1/cronjobs/:namespace/:name/executions/:jobName

type ExecutionItem

type ExecutionItem struct {
	ID             int64      `json:"id"`
	JobName        string     `json:"jobName"`
	Status         string     `json:"status"`
	StartTime      time.Time  `json:"startTime"`
	CompletionTime *time.Time `json:"completionTime,omitempty"`
	Duration       string     `json:"duration"`
	ExitCode       int32      `json:"exitCode"`
	Reason         string     `json:"reason,omitempty"`
	IsRetry        bool       `json:"isRetry"`
}

ExecutionItem is a single execution in the list

type ExecutionListResponse

type ExecutionListResponse struct {
	Items      []ExecutionItem `json:"items"`
	Pagination Pagination      `json:"pagination"`
}

ExecutionListResponse is the response for GET /api/v1/cronjobs/:namespace/:name/executions

type ExecutionSummary

type ExecutionSummary struct {
	JobName        string     `json:"jobName"`
	Status         string     `json:"status"`
	StartTime      time.Time  `json:"startTime"`
	CompletionTime *time.Time `json:"completionTime,omitempty"`
	Duration       string     `json:"duration"`
	ExitCode       int32      `json:"exitCode"`
}

ExecutionSummary contains execution details

type ExitCodeRangeInput

type ExitCodeRangeInput struct {
	Min int32 `json:"min"`
	Max int32 `json:"max"`
}

ExitCodeRangeInput represents an exit code range

type Handlers

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

Handlers contains all API handlers

func NewHandlers

func NewHandlers(c client.Client, cs *kubernetes.Clientset, s store.Store, cfg *config.Config, ad alerting.Dispatcher, startTime time.Time, leaderCheck func() bool) *Handlers

NewHandlers creates a new Handlers instance

func (*Handlers) DeleteCronJobHistory

func (h *Handlers) DeleteCronJobHistory(w http.ResponseWriter, r *http.Request)

DeleteCronJobHistory handles DELETE /api/v1/cronjobs/:namespace/:name/history @Summary Delete CronJob history @Description Deletes all execution history for a specific CronJob @Tags CronJobs @Produce json @Param namespace path string true "CronJob namespace" @Param name path string true "CronJob name" @Success 200 {object} DeleteHistoryResponse @Failure 503 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /cronjobs/{namespace}/{name}/history [delete]

func (*Handlers) GetAlertHistory

func (h *Handlers) GetAlertHistory(w http.ResponseWriter, r *http.Request)

GetAlertHistory handles GET /api/v1/alerts/history @Summary Get alert history @Description Returns paginated history of past alerts from the store @Tags Alerts @Produce json @Param limit query int false "Page size" default(50) @Param offset query int false "Page offset" default(0) @Param severity query string false "Filter by severity" @Param since query string false "Filter since timestamp (RFC3339)" @Success 200 {object} AlertHistoryResponse @Failure 500 {object} ErrorResponse @Router /alerts/history [get]

func (*Handlers) GetChannel

func (h *Handlers) GetChannel(w http.ResponseWriter, r *http.Request)

GetChannel handles GET /api/v1/channels/:name @Summary Get channel details @Description Returns details for a specific alert channel @Tags Channels @Produce json @Param name path string true "Channel name" @Success 200 {object} guardianv1alpha1.AlertChannel @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /channels/{name} [get]

func (*Handlers) GetConfig

func (h *Handlers) GetConfig(w http.ResponseWriter, _ *http.Request)

GetConfig handles GET /api/v1/config @Summary Get operator configuration @Description Returns the current operator configuration (sensitive values redacted) @Tags Config @Produce json @Success 200 {object} ConfigResponse @Router /config [get]

func (*Handlers) GetCronJob

func (h *Handlers) GetCronJob(w http.ResponseWriter, r *http.Request)

GetCronJob handles GET /api/v1/cronjobs/:namespace/:name @Summary Get CronJob details @Description Returns detailed information about a specific CronJob @Tags CronJobs @Produce json @Param namespace path string true "CronJob namespace" @Param name path string true "CronJob name" @Success 200 {object} CronJobDetailResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /cronjobs/{namespace}/{name} [get]

func (*Handlers) GetExecutionWithLogs

func (h *Handlers) GetExecutionWithLogs(w http.ResponseWriter, r *http.Request)

GetExecutionWithLogs handles GET /api/v1/cronjobs/:namespace/:name/executions/:jobName @Summary Get execution details with logs @Description Returns full execution details including stored logs and events @Tags CronJobs @Produce json @Param namespace path string true "CronJob namespace" @Param name path string true "CronJob name" @Param jobName path string true "Job name (execution ID)" @Success 200 {object} ExecutionDetailResponse @Failure 404 {object} ErrorResponse @Failure 503 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /cronjobs/{namespace}/{name}/executions/{jobName} [get]

func (*Handlers) GetExecutions

func (h *Handlers) GetExecutions(w http.ResponseWriter, r *http.Request)

GetExecutions handles GET /api/v1/cronjobs/:namespace/:name/executions @Summary Get execution history @Description Returns paginated execution history for a CronJob @Tags CronJobs @Produce json @Param namespace path string true "CronJob namespace" @Param name path string true "CronJob name" @Param limit query int false "Page size" default(50) @Param offset query int false "Page offset" default(0) @Param status query string false "Filter by status (success, failed)" @Param since query string false "Filter since timestamp (RFC3339)" @Success 200 {object} ExecutionListResponse @Failure 500 {object} ErrorResponse @Router /cronjobs/{namespace}/{name}/executions [get]

func (*Handlers) GetHealth

func (h *Handlers) GetHealth(w http.ResponseWriter, r *http.Request)

GetHealth handles GET /api/v1/health @Summary Health check @Description Returns the health status of the Guardian operator @Tags System @Produce json @Success 200 {object} HealthResponse @Router /health [get]

func (*Handlers) GetLogs

func (h *Handlers) GetLogs(w http.ResponseWriter, r *http.Request)

GetLogs handles GET /api/v1/cronjobs/:namespace/:name/executions/:jobName/logs @Summary Get execution logs @Description Returns container logs from a job execution @Tags CronJobs @Produce json @Param namespace path string true "CronJob namespace" @Param name path string true "CronJob name" @Param jobName path string true "Job name" @Success 200 {object} LogsResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /cronjobs/{namespace}/{name}/executions/{jobName}/logs [get]

func (*Handlers) GetMonitor

func (h *Handlers) GetMonitor(w http.ResponseWriter, r *http.Request)

GetMonitor handles GET /api/v1/monitors/:namespace/:name @Summary Get monitor details @Description Returns detailed information about a specific CronJobMonitor @Tags Monitors @Produce json @Param namespace path string true "Monitor namespace" @Param name path string true "Monitor name" @Success 200 {object} object "Monitor details (CRD format)" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /monitors/{namespace}/{name} [get]

func (*Handlers) GetStats

func (h *Handlers) GetStats(w http.ResponseWriter, r *http.Request)

GetStats handles GET /api/v1/stats @Summary Get statistics @Description Returns aggregate statistics for all monitored CronJobs @Tags System @Produce json @Success 200 {object} StatsResponse @Failure 500 {object} ErrorResponse @Router /stats [get]

func (*Handlers) GetStorageStats

func (h *Handlers) GetStorageStats(w http.ResponseWriter, r *http.Request)

GetStorageStats handles GET /api/v1/admin/storage-stats @Summary Get storage statistics @Description Returns storage backend statistics and health @Tags Admin @Produce json @Success 200 {object} StorageStatsResponse @Failure 503 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /admin/storage-stats [get]

func (*Handlers) ListAlerts

func (h *Handlers) ListAlerts(w http.ResponseWriter, r *http.Request)

ListAlerts handles GET /api/v1/alerts @Summary List active alerts @Description Returns all active alerts across all monitored CronJobs @Tags Alerts @Produce json @Param severity query string false "Filter by severity (critical, warning)" @Param type query string false "Filter by alert type" @Param namespace query string false "Filter by CronJob namespace" @Param cronjob query string false "Filter by CronJob name" @Success 200 {object} AlertListResponse @Failure 500 {object} ErrorResponse @Router /alerts [get]

func (*Handlers) ListChannels

func (h *Handlers) ListChannels(w http.ResponseWriter, r *http.Request)

ListChannels handles GET /api/v1/channels @Summary List alert channels @Description Returns all configured alert channels with their status and stats @Tags Channels @Produce json @Success 200 {object} ChannelListResponse @Failure 500 {object} ErrorResponse @Router /channels [get]

func (*Handlers) ListCronJobs

func (h *Handlers) ListCronJobs(w http.ResponseWriter, r *http.Request)

ListCronJobs handles GET /api/v1/cronjobs @Summary List CronJobs @Description Returns all monitored CronJobs with their status @Tags CronJobs @Produce json @Param namespace query string false "Filter by namespace" @Param status query string false "Filter by status (healthy, warning, critical)" @Success 200 {object} CronJobListResponse @Failure 500 {object} ErrorResponse @Router /cronjobs [get]

func (*Handlers) ListMonitors

func (h *Handlers) ListMonitors(w http.ResponseWriter, r *http.Request)

ListMonitors handles GET /api/v1/monitors @Summary List monitors @Description Returns all CronJobMonitor resources @Tags Monitors @Produce json @Param namespace query string false "Filter by namespace" @Success 200 {object} MonitorListResponse @Failure 500 {object} ErrorResponse @Router /monitors [get]

func (*Handlers) ResumeCronJob

func (h *Handlers) ResumeCronJob(w http.ResponseWriter, r *http.Request)

ResumeCronJob handles POST /api/v1/cronjobs/:namespace/:name/resume @Summary Resume CronJob @Description Resumes a suspended CronJob to allow scheduled runs @Tags CronJobs @Produce json @Param namespace path string true "CronJob namespace" @Param name path string true "CronJob name" @Success 200 {object} SimpleResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /cronjobs/{namespace}/{name}/resume [post]

func (*Handlers) SetAnalyzerEnabled

func (h *Handlers) SetAnalyzerEnabled(enabled bool)

SetAnalyzerEnabled sets whether the SLA analyzer is enabled

func (*Handlers) SetSchedulersRunning

func (h *Handlers) SetSchedulersRunning(schedulers []string)

SetSchedulersRunning sets the list of running scheduler names

func (*Handlers) SuspendCronJob

func (h *Handlers) SuspendCronJob(w http.ResponseWriter, r *http.Request)

SuspendCronJob handles POST /api/v1/cronjobs/:namespace/:name/suspend @Summary Suspend CronJob @Description Suspends a CronJob to prevent scheduled runs @Tags CronJobs @Produce json @Param namespace path string true "CronJob namespace" @Param name path string true "CronJob name" @Success 200 {object} SimpleResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /cronjobs/{namespace}/{name}/suspend [post]

func (*Handlers) TestChannel

func (h *Handlers) TestChannel(w http.ResponseWriter, r *http.Request)

TestChannel handles POST /api/v1/channels/:name/test @Summary Test alert channel @Description Sends a test alert to verify channel configuration @Tags Channels @Produce json @Param name path string true "Channel name" @Success 200 {object} SimpleResponse @Failure 503 {object} ErrorResponse @Router /channels/{name}/test [post]

func (*Handlers) TestPattern

func (h *Handlers) TestPattern(w http.ResponseWriter, r *http.Request)

TestPattern handles POST /api/v1/patterns/test @Summary Test suggested fix pattern @Description Tests a suggested fix pattern against sample data to verify matching @Tags Patterns @Accept json @Produce json @Param request body PatternTestRequest true "Pattern and test data" @Success 200 {object} PatternTestResponse @Failure 400 {object} ErrorResponse @Router /patterns/test [post]

func (*Handlers) TriggerCronJob

func (h *Handlers) TriggerCronJob(w http.ResponseWriter, r *http.Request)

TriggerCronJob handles POST /api/v1/cronjobs/:namespace/:name/trigger @Summary Trigger CronJob @Description Manually triggers a CronJob to run immediately @Tags CronJobs @Produce json @Param namespace path string true "CronJob namespace" @Param name path string true "CronJob name" @Success 200 {object} TriggerResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /cronjobs/{namespace}/{name}/trigger [post]

func (*Handlers) TriggerPrune

func (h *Handlers) TriggerPrune(w http.ResponseWriter, r *http.Request)

TriggerPrune handles POST /api/v1/admin/prune @Summary Trigger history pruning @Description Manually triggers pruning of old execution records @Tags Admin @Accept json @Produce json @Param request body PruneRequest false "Prune options" @Success 200 {object} PruneResponse @Failure 503 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /admin/prune [post]

type HealthResponse

type HealthResponse struct {
	Status            string   `json:"status"`
	Storage           string   `json:"storage"`
	Leader            bool     `json:"leader"`
	Version           string   `json:"version"`
	Uptime            string   `json:"uptime"`
	AnalyzerEnabled   bool     `json:"analyzerEnabled"`
	SchedulersRunning []string `json:"schedulersRunning"`
}

HealthResponse is the response for GET /api/v1/health

type LogsResponse

type LogsResponse struct {
	JobName   string `json:"jobName"`
	Container string `json:"container"`
	Logs      string `json:"logs"`
	Truncated bool   `json:"truncated"`
}

LogsResponse is the response for GET /api/v1/cronjobs/:namespace/:name/executions/:jobName/logs

type MonitorListItem

type MonitorListItem struct {
	Name          string       `json:"name"`
	Namespace     string       `json:"namespace"`
	CronJobCount  int32        `json:"cronJobCount"`
	Summary       SummaryStats `json:"summary"`
	ActiveAlerts  int32        `json:"activeAlerts"`
	LastReconcile *time.Time   `json:"lastReconcile,omitempty"`
	Phase         string       `json:"phase"`
}

MonitorListItem is a single monitor in the list

type MonitorListResponse

type MonitorListResponse struct {
	Items []MonitorListItem `json:"items"`
}

MonitorListResponse is the response for GET /api/v1/monitors

type NamespacedRef

type NamespacedRef struct {
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
}

NamespacedRef is a reference to a namespaced resource with proper JSON tags

type Pagination

type Pagination struct {
	Total   int64 `json:"total"`
	Limit   int   `json:"limit"`
	Offset  int   `json:"offset"`
	HasMore bool  `json:"hasMore"`
}

Pagination contains pagination info

type PatternInput

type PatternInput struct {
	Name       string            `json:"name"`
	Match      PatternMatchInput `json:"match"`
	Suggestion string            `json:"suggestion"`
	Priority   *int32            `json:"priority,omitempty"`
}

PatternInput represents a pattern to test

type PatternMatchInput

type PatternMatchInput struct {
	ExitCode      *int32              `json:"exitCode,omitempty"`
	ExitCodeRange *ExitCodeRangeInput `json:"exitCodeRange,omitempty"`
	Reason        string              `json:"reason,omitempty"`
	ReasonPattern string              `json:"reasonPattern,omitempty"`
	LogPattern    string              `json:"logPattern,omitempty"`
	EventPattern  string              `json:"eventPattern,omitempty"`
}

PatternMatchInput represents match criteria for a pattern

type PatternTestData

type PatternTestData struct {
	ExitCode  int32    `json:"exitCode"`
	Reason    string   `json:"reason"`
	Logs      string   `json:"logs"`
	Events    []string `json:"events"`
	Namespace string   `json:"namespace"`
	Name      string   `json:"name"`
	JobName   string   `json:"jobName"`
}

PatternTestData contains sample data to test against

type PatternTestRequest

type PatternTestRequest struct {
	Pattern  PatternInput    `json:"pattern"`
	TestData PatternTestData `json:"testData"`
}

PatternTestRequest is the request for POST /api/v1/patterns/test

type PatternTestResponse

type PatternTestResponse struct {
	Matched            bool   `json:"matched"`
	RenderedSuggestion string `json:"renderedSuggestion,omitempty"`
	Error              string `json:"error,omitempty"`
}

PatternTestResponse is the response for pattern testing

type PruneRequest

type PruneRequest struct {
	OlderThanDays int  `json:"olderThanDays"`
	DryRun        bool `json:"dryRun"`
	PruneLogsOnly bool `json:"pruneLogsOnly"`
}

PruneRequest represents a prune request body

type PruneResponse

type PruneResponse struct {
	Success       bool      `json:"success"`
	RecordsPruned int64     `json:"recordsPruned"`
	DryRun        bool      `json:"dryRun"`
	Cutoff        time.Time `json:"cutoff"`
	OlderThanDays int       `json:"olderThanDays"`
	Message       string    `json:"message"`
}

PruneResponse is the response for POST /api/v1/admin/prune

type Server

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

Server is the REST API server

func NewServer

func NewServer(opts ServerOptions) *Server

NewServer creates a new API server

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the API server

type ServerOptions

type ServerOptions struct {
	Client              client.Client
	Clientset           *kubernetes.Clientset
	Store               store.Store
	Config              *config.Config
	AlertDispatcher     alerting.Dispatcher
	Port                int
	LeaderElectionCheck func() bool
	AnalyzerEnabled     bool
	SchedulersRunning   []string
}

ServerOptions contains options for creating the server

type SimpleResponse

type SimpleResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
	Error   string `json:"error,omitempty"`
}

SimpleResponse is a simple success/error response

type StatsResponse

type StatsResponse struct {
	TotalMonitors         int32        `json:"totalMonitors"`
	TotalCronJobs         int32        `json:"totalCronJobs"`
	Summary               SummaryStats `json:"summary"`
	ActiveAlerts          int32        `json:"activeAlerts"`
	ExecutionsRecorded24h int64        `json:"executionsRecorded24h"`
}

StatsResponse is the response for GET /api/v1/stats

type StorageStatsResponse

type StorageStatsResponse struct {
	ExecutionCount    int64  `json:"executionCount"`
	StorageType       string `json:"storageType"`
	Healthy           bool   `json:"healthy"`
	RetentionDays     int    `json:"retentionDays"`
	LogStorageEnabled bool   `json:"logStorageEnabled"`
}

StorageStatsResponse is the response for GET /api/v1/admin/storage-stats

type SummaryStats

type SummaryStats struct {
	Healthy   int32 `json:"healthy"`
	Warning   int32 `json:"warning"`
	Critical  int32 `json:"critical"`
	Suspended int32 `json:"suspended"`
	Running   int32 `json:"running"`
}

SummaryStats contains aggregate status counts

type TestResult

type TestResult struct {
	Time   time.Time `json:"time"`
	Result string    `json:"result"`
}

TestResult contains test results

type TriggerResponse

type TriggerResponse struct {
	Success bool   `json:"success"`
	JobName string `json:"jobName,omitempty"`
	Message string `json:"message"`
}

TriggerResponse is the response for POST /api/v1/cronjobs/:namespace/:name/trigger

Jump to

Keyboard shortcuts

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