handlers

package
v0.0.0-...-7c12fc0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Pages = []*components.Page{
	{Path: "/", Title: "Status", Breadcrumb: "Status"},
	{Path: "/incidents", Title: "Incidents", Breadcrumb: "Incidents"},
	{Path: "/settings", Title: "Settings", Breadcrumb: "Settings"},
}
View Source
var SettingsPages = []*components.Page{
	{Path: "/settings", Title: "Home", Breadcrumb: "Home"},
	{Path: "/settings/incidents", Title: "Incidents", Breadcrumb: "Incidents"},
	{Path: "/settings/targets", Title: "Targets", Breadcrumb: "Targets"},
	{Path: "/settings/targets/create", Title: "Targets Create", Breadcrumb: "Create"},
	{Path: "/settings/hooks", Title: "Hooks", Breadcrumb: "Hooks"},
	{Path: "/settings/hooks/create", Title: "Hooks Create", Breadcrumb: "Create"},
	{Path: "/settings/checks", Title: "Checks", Breadcrumb: "Checks"},
	{Path: "/settings/checks/create", Title: "Checks Create", Breadcrumb: "Create"},
	{Path: "/settings/worker-groups", Title: "Worker Groups", Breadcrumb: "Worker Groups"},
	{Path: "/settings/worker-groups/create", Title: "Worker Groups Create", Breadcrumb: "Create"},
	{Path: "/settings/notifications", Title: "Notifications", Breadcrumb: "Notifications"},
	{Path: "/settings/notifications/create", Title: "Notifications Create", Breadcrumb: "Create"},
	{Path: "/settings/triggers", Title: "Triggers", Breadcrumb: "Triggers"},
	{Path: "/settings/triggers/create", Title: "Triggers Create", Breadcrumb: "Create"},
	{Path: "/settings/temporal", Title: "Temporal", Breadcrumb: "Temporal"},
	{Path: "/oauth2/logout", Title: "Logout", Breadcrumb: "Logout"},
}
View Source
var SettingsSidebar = []SettingsSidebarGroup{
	{
		Group: "Overview",
		Pages: []*components.Page{
			GetPageByTitle(SettingsPages, "Home"),
		},
	},
	{
		Group: "Monitor",
		Pages: []*components.Page{
			GetPageByTitle(SettingsPages, "Targets"),
			GetPageByTitle(SettingsPages, "Checks"),
			GetPageByTitle(SettingsPages, "Hooks"),
		},
	},
	{
		Group: "Alert",
		Pages: []*components.Page{
			GetPageByTitle(SettingsPages, "Triggers"),
		},
	},
	{
		Group: "Notify",
		Pages: []*components.Page{
			GetPageByTitle(SettingsPages, "Incidents"),
			GetPageByTitle(SettingsPages, "Notifications"),
		},
	},
	{
		Group: "Manage",
		Pages: []*components.Page{
			GetPageByTitle(SettingsPages, "Worker Groups"),
			GetPageByTitle(SettingsPages, "Temporal"),
			GetPageByTitle(SettingsPages, "Logout"),
		},
	},
}

Functions

func GetPageByTitle

func GetPageByTitle(pages []*components.Page, title string) *components.Page

func WithUser

func WithUser(ctx context.Context, user *AuthenticatedUser) context.Context

Types

type ApiV1WorkersConnectGETResponse

type ApiV1WorkersConnectGETResponse struct {
	Endpoint string `json:"endpoint"`
	Group    string `json:"group"`
}

type AuthenticatedContext

type AuthenticatedContext struct {
	echo.Context
	Principal *AuthenticatedPrincipal
}

type AuthenticatedHandler

type AuthenticatedHandler func(http.ResponseWriter, *http.Request, *AuthenticatedPrincipal)

type AuthenticatedPrincipal

type AuthenticatedPrincipal struct {
	User   *AuthenticatedUser
	Worker *AuthenticatedWorker
}

type AuthenticatedUser

type AuthenticatedUser struct {
	ID                 string
	Email              string
	OAuth2AccessToken  string
	OAuth2RefreshToken string
	OAuth2TokenType    string
	OAuth2Expiry       time.Time
}

func GetUser

func GetUser(ctx context.Context) *AuthenticatedUser

type AuthenticatedWorker

type AuthenticatedWorker struct {
	Group string
}

type BaseHandler

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

func NewBaseHandler

func NewBaseHandler(db *sqlx.DB, kvStore database.KeyValueStore, temporal client.Client, config *config.ServerConfig, logger *slog.Logger) *BaseHandler

func (*BaseHandler) ApiV1WorkersConnectGET

func (h *BaseHandler) ApiV1WorkersConnectGET(c echo.Context) error

func (*BaseHandler) AuthenticateRequestWithCookies

func (h *BaseHandler) AuthenticateRequestWithCookies(r *http.Request) (*AuthenticatedUser, error)

func (*BaseHandler) AuthenticateRequestWithToken

func (h *BaseHandler) AuthenticateRequestWithToken(r *http.Request) (*AuthenticatedPrincipal, error)

func (*BaseHandler) Authenticated

func (h *BaseHandler) Authenticated(next echo.HandlerFunc) echo.HandlerFunc

func (*BaseHandler) AuthenticatedUserToOAuth2Token

func (h *BaseHandler) AuthenticatedUserToOAuth2Token(user *AuthenticatedUser) *oauth2.Token

func (*BaseHandler) ClearAuthenticatedUserForRequest

func (h *BaseHandler) ClearAuthenticatedUserForRequest(w http.ResponseWriter, r *http.Request) error

func (*BaseHandler) Error404

func (h *BaseHandler) Error404(c echo.Context) error

func (*BaseHandler) Incidents

func (h *BaseHandler) Incidents(c echo.Context) error

func (*BaseHandler) Index

func (h *BaseHandler) Index(c echo.Context) error

func (*BaseHandler) OAuth2CallbackGET

func (h *BaseHandler) OAuth2CallbackGET(c echo.Context) error

func (*BaseHandler) OAuth2LoginGET

func (h *BaseHandler) OAuth2LoginGET(c echo.Context) error

func (*BaseHandler) OAuth2LogoutGET

func (h *BaseHandler) OAuth2LogoutGET(c echo.Context) error

func (*BaseHandler) RefreshToken

func (*BaseHandler) SetAuthenticatedUserForRequest

func (h *BaseHandler) SetAuthenticatedUserForRequest(w http.ResponseWriter, r *http.Request, user *AuthenticatedUser) error

func (*BaseHandler) SettingsChecksCreateGET

func (h *BaseHandler) SettingsChecksCreateGET(c echo.Context) error

func (*BaseHandler) SettingsChecksCreatePOST

func (h *BaseHandler) SettingsChecksCreatePOST(c echo.Context) error

func (*BaseHandler) SettingsChecksDescribeDELETE

func (h *BaseHandler) SettingsChecksDescribeDELETE(c echo.Context) error

func (*BaseHandler) SettingsChecksDescribeGET

func (h *BaseHandler) SettingsChecksDescribeGET(c echo.Context) error

func (*BaseHandler) SettingsChecksDescribePOST

func (h *BaseHandler) SettingsChecksDescribePOST(c echo.Context) error

func (*BaseHandler) SettingsChecksDisableGET

func (h *BaseHandler) SettingsChecksDisableGET(c echo.Context) error

func (*BaseHandler) SettingsChecksEnableGET

func (h *BaseHandler) SettingsChecksEnableGET(c echo.Context) error

func (*BaseHandler) SettingsChecksGET

func (h *BaseHandler) SettingsChecksGET(c echo.Context) error

func (*BaseHandler) SettingsHomeGET

func (h *BaseHandler) SettingsHomeGET(c echo.Context) error

func (*BaseHandler) SettingsHooksCreateGET

func (h *BaseHandler) SettingsHooksCreateGET(c echo.Context) error

func (*BaseHandler) SettingsHooksCreatePOST

func (h *BaseHandler) SettingsHooksCreatePOST(c echo.Context) error

func (*BaseHandler) SettingsHooksDescribeDELETE

func (h *BaseHandler) SettingsHooksDescribeDELETE(c echo.Context) error

func (*BaseHandler) SettingsHooksDescribeGET

func (h *BaseHandler) SettingsHooksDescribeGET(c echo.Context) error

func (*BaseHandler) SettingsHooksDescribePOST

func (h *BaseHandler) SettingsHooksDescribePOST(c echo.Context) error

func (*BaseHandler) SettingsHooksDisableGET

func (h *BaseHandler) SettingsHooksDisableGET(c echo.Context) error

func (*BaseHandler) SettingsHooksEnableGET

func (h *BaseHandler) SettingsHooksEnableGET(c echo.Context) error

func (*BaseHandler) SettingsHooksGET

func (h *BaseHandler) SettingsHooksGET(c echo.Context) error

func (*BaseHandler) SettingsIncidentsGET

func (h *BaseHandler) SettingsIncidentsGET(c echo.Context) error

func (*BaseHandler) SettingsNotificationsGET

func (h *BaseHandler) SettingsNotificationsGET(c echo.Context) error

func (*BaseHandler) SettingsTargetsCreateGET

func (h *BaseHandler) SettingsTargetsCreateGET(c echo.Context) error

func (*BaseHandler) SettingsTargetsCreatePOST

func (h *BaseHandler) SettingsTargetsCreatePOST(c echo.Context) error

func (*BaseHandler) SettingsTargetsDescribeDELETE

func (h *BaseHandler) SettingsTargetsDescribeDELETE(c echo.Context) error

func (*BaseHandler) SettingsTargetsDescribeGET

func (h *BaseHandler) SettingsTargetsDescribeGET(c echo.Context) error

func (*BaseHandler) SettingsTargetsDescribePOST

func (h *BaseHandler) SettingsTargetsDescribePOST(c echo.Context) error

func (*BaseHandler) SettingsTargetsDisableGET

func (h *BaseHandler) SettingsTargetsDisableGET(c echo.Context) error

func (*BaseHandler) SettingsTargetsEnableGET

func (h *BaseHandler) SettingsTargetsEnableGET(c echo.Context) error

func (*BaseHandler) SettingsTargetsGET

func (h *BaseHandler) SettingsTargetsGET(c echo.Context) error

func (*BaseHandler) SettingsTriggersCreateGET

func (h *BaseHandler) SettingsTriggersCreateGET(c echo.Context) error

func (*BaseHandler) SettingsTriggersCreatePOST

func (h *BaseHandler) SettingsTriggersCreatePOST(c echo.Context) error

func (*BaseHandler) SettingsTriggersDescribeDELETE

func (h *BaseHandler) SettingsTriggersDescribeDELETE(c echo.Context) error

func (*BaseHandler) SettingsTriggersDescribeGET

func (h *BaseHandler) SettingsTriggersDescribeGET(c echo.Context) error

func (*BaseHandler) SettingsTriggersDescribePOST

func (h *BaseHandler) SettingsTriggersDescribePOST(c echo.Context) error

func (*BaseHandler) SettingsTriggersDisableGET

func (h *BaseHandler) SettingsTriggersDisableGET(c echo.Context) error

func (*BaseHandler) SettingsTriggersEnableGET

func (h *BaseHandler) SettingsTriggersEnableGET(c echo.Context) error

func (*BaseHandler) SettingsTriggersGET

func (h *BaseHandler) SettingsTriggersGET(c echo.Context) error

func (*BaseHandler) SettingsWorkerGroupsCreateGET

func (h *BaseHandler) SettingsWorkerGroupsCreateGET(c echo.Context) error

func (*BaseHandler) SettingsWorkerGroupsCreatePOST

func (h *BaseHandler) SettingsWorkerGroupsCreatePOST(c echo.Context) error

func (*BaseHandler) SettingsWorkerGroupsDescribeDELETE

func (h *BaseHandler) SettingsWorkerGroupsDescribeDELETE(c echo.Context) error

func (*BaseHandler) SettingsWorkerGroupsDescribeGET

func (h *BaseHandler) SettingsWorkerGroupsDescribeGET(c echo.Context) error

func (*BaseHandler) SettingsWorkerGroupsGET

func (h *BaseHandler) SettingsWorkerGroupsGET(c echo.Context) error

func (*BaseHandler) Temporal

func (h *BaseHandler) Temporal(c echo.Context) error

type CheckWithWorkerGroupsAndState

type CheckWithWorkerGroupsAndState struct {
	*models.CheckWithWorkerGroups
	State models.CheckState
}

type CreateCheck

type CreateCheck struct {
	Name         string `validate:"required"`
	WorkerGroups string `validate:"required"`
	Schedule     string `validate:"required,cron"`
	Script       string `validate:"required"`
	Filter       string `validate:"required"`
}

type CreateHook

type CreateHook struct {
	Name     string `validate:"required"`
	Schedule string `validate:"required,cron"`
	Script   string `validate:"required"`
}

type CreateTarget

type CreateTarget struct {
	Name       string `validate:"required"`
	Group      string `validate:"required"`
	Visibility string `validate:"required,oneof=PUBLIC PRIVATE"`
	Metadata   string `validate:"required"`
}

type CreateTrigger

type CreateTrigger struct {
	Name   string `validate:"required"`
	Script string `validate:"required"`
}

type History

type History struct {
	List   []*HistoryItem
	Uptime float64
}

type HistoryItem

type HistoryItem struct {
	Outcome      HistoryOutcome
	StatusCounts map[models.TargetStatus]int
	Counts       int
	Date         time.Time
	Checks       []*HistoryItemCheck
	SuccessRate  float64
}

type HistoryItemCheck

type HistoryItemCheck struct {
	Name            string
	WorkerGroupName string
	Status          models.TargetStatus
	StatusCounts    map[models.TargetStatus]int
	Counts          int
	SuccessRate     float64
}

type HistoryOutcome

type HistoryOutcome string
const (
	HistoryOutcomeHealthy  HistoryOutcome = "HEALTHY"
	HistoryOutcomeDegraded HistoryOutcome = "DEGRADED"
	HistoryOutcomeUnknown  HistoryOutcome = "UNKNOWN"
	HistoryOutcomeDown     HistoryOutcome = "DOWN"
)

func TargetStatusToHistoryOutcome

func TargetStatusToHistoryOutcome(status models.TargetStatus) HistoryOutcome

type HookWithState

type HookWithState struct {
	*models.Hook
	State models.HookState
}

type Incident

type Incident struct{}

type IndexData

type IndexData struct {
	*components.Base
	Targets       map[string]TargetsAndStatus
	TargetsLength int
	TimeRange     string
	Outcome       HistoryOutcome
}

type Notification

type Notification struct{}

type Settings

type Settings struct {
	*components.Base
	SettingsGroupName     string
	SettingsSidebarActive *components.Page
	SettingsSidebar       []SettingsSidebarGroup
	User                  *AuthenticatedUser
	SettingsBreadcrumbs   []*components.Page
}

func NewSettings

func NewSettings(user *AuthenticatedUser, page *components.Page, breadCrumbs []*components.Page) *Settings

type SettingsCheck

type SettingsCheck struct {
	*Settings
	Check   *CheckWithWorkerGroupsAndState
	History []*services.CheckHistory
}

type SettingsCheckCreate

type SettingsCheckCreate struct {
	*Settings
	ExampleScript string
	ExampleFilter string
}

type SettingsChecks

type SettingsChecks struct {
	*Settings
	Checks  []*CheckWithWorkerGroupsAndState
	History []struct {
		CreatedAt time.Time
		Status    string
		Note      string
	}
}

type SettingsHome

type SettingsHome struct {
	*Settings
	WorkerGroupsCount  int
	ChecksCount        int
	NotificationsCount int
	History            []*services.CheckHistory
}

type SettingsHook

type SettingsHook struct {
	*Settings
	Hook    *HookWithState
	History []*services.HookHistory
}

type SettingsHookCreate

type SettingsHookCreate struct {
	*Settings
	ExampleScript string
	ExampleFilter string
}

type SettingsHooks

type SettingsHooks struct {
	*Settings
	Hooks   []*HookWithState
	History []struct {
		CreatedAt time.Time
		Status    string
		Note      string
	}
}

type SettingsIncidents

type SettingsIncidents struct {
	*Settings
	Incidents []*Incident
}

type SettingsNotifications

type SettingsNotifications struct {
	*Settings
	Notifications []*Notification
}

type SettingsSidebarGroup

type SettingsSidebarGroup struct {
	Group string
	Pages []*components.Page
}

type SettingsTarget

type SettingsTarget struct {
	*Settings
	Target  *models.Target
	History []*services.TargetHistory
}

type SettingsTargetCreate

type SettingsTargetCreate struct {
	*Settings
	Example string
}

type SettingsTargets

type SettingsTargets struct {
	*Settings
	Targets      map[string][]*models.Target
	TargetGroups []string
}

type SettingsTrigger

type SettingsTrigger struct {
	*Settings
	Trigger *TriggerWithState
	History []*services.TriggerHistory
}

type SettingsTriggerCreate

type SettingsTriggerCreate struct {
	*Settings
	Example string
}

type SettingsTriggers

type SettingsTriggers struct {
	*Settings
	Triggers []*TriggerWithState
}

type SettingsWorker

type SettingsWorker struct {
	*Settings
	Worker *WorkerWithTokenAndActiveWorkers
}

type SettingsWorkerGroups

type SettingsWorkerGroups struct {
	*Settings
	WorkerGroups []*WorkerGroupWithActiveWorkers
}

type Target

type Target struct {
	Name       string
	Visibility models.TargetVisibility
	Group      string
	Outcome    HistoryOutcome
	History    []*HistoryItem
	Uptime     float64
}

type TargetsAndStatus

type TargetsAndStatus struct {
	Outcome HistoryOutcome
	Targets []*Target
}

type TriggerWithState

type TriggerWithState struct {
	*models.Trigger
	State models.TriggerState
}

type UpdateCheck

type UpdateCheck struct {
	WorkerGroups string `validate:"required"`
	Schedule     string `validate:"required,cron"`
	Script       string `validate:"required"`
	Filter       string `validate:"required"`
}

type UpdateHook

type UpdateHook struct {
	Schedule string `validate:"required,cron"`
	Script   string `validate:"required"`
}

type UpdateTarget

type UpdateTarget struct {
	Group      string `validate:"required"`
	Visibility string `validate:"required,oneof=PUBLIC PRIVATE"`
	Metadata   string `validate:"required"`
}

type UpdateTrigger

type UpdateTrigger struct {
	Script string `validate:"required"`
}

type UserInfo

type UserInfo struct {
	Id    int    `json:"id"` // FIXME: This might not always be int?
	Sub   string `json:"sub"`
	Email string `json:"email"`
}

type WorkerGroupWithActiveWorkers

type WorkerGroupWithActiveWorkers struct {
	*models.WorkerGroupWithChecks
	ActiveWorkers []string
}

type WorkerWithTokenAndActiveWorkers

type WorkerWithTokenAndActiveWorkers struct {
	*models.WorkerGroup
	Token         string
	ActiveWorkers []string
}

Jump to

Keyboard shortcuts

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