handler

package
v0.0.0-...-07d49b8 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Key (Should come from somewhere else).
	Key = "secret"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	DB         *gorm.DB
	Dispatcher *monitor.Dispatcher
	Logger     *logrus.Logger
}

func NewHandler

func NewHandler(logger *logrus.Logger, db *gorm.DB, dispatcher *monitor.Dispatcher) *Handler

func (*Handler) ConfigureMiddleware

func (h *Handler) ConfigureMiddleware(e *echo.Echo)

func (*Handler) CreateNotification

func (h *Handler) CreateNotification(c echo.Context) error

CreateNotification godoc @Summary Create a new notification @Description Creates notifications @Tags notifications @Accept json @Produce json @Param body body model.AddNotification true "Add notification" @Success 200 {object} model.Notification @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/notifications [post]

func (*Handler) CreateService

func (h *Handler) CreateService(c echo.Context) error

CreateService godoc @Summary Create a new service @Description Creates a new service and starts monitor it @Tags services @Accept json @Produce json @Param body body model.AddService true "Add service" @Success 200 {object} model.Service @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/services [post]

func (*Handler) CreateToken

func (h *Handler) CreateToken(c echo.Context) (err error)

CreateService godoc @Summary Create an auth token @Description Create an auth token @Tags tokens @Accept json @Produce json @Param body body model.CreateToken true "Create an auth token" @Success 200 {object} model.Token @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Router /API/v1/tokens [post]

func (*Handler) DeleteNotification

func (h *Handler) DeleteNotification(c echo.Context) error

DeleteNotification godoc @Summary Delete a notification @Description Deletes notifications @Tags notifications @Accept json @Produce json @Param notification_name path string true "Delete by notification_name" @Success 200 {object} model.Notification @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/notifications/{notification_name} [delete]

func (*Handler) DeleteService

func (h *Handler) DeleteService(c echo.Context) error

DeleteService godoc @Summary Delete a service @Description Stops a service monitoring and deletes it @Tags services @Accept json @Produce json @Param service_id path string true "Delete by service_id" @Success 204 {object} model.Service @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/services/{service_id} [delete]

func (*Handler) DeleteToken

func (h *Handler) DeleteToken(c echo.Context) (err error)

DeleteToken godoc @Summary Delete an auth token @Description Delete an auth token @Tags tokens @Accept json @Produce json @Success 204 {object} model.Token @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/tokens [delete]

func (*Handler) GetHeartbeatStats

func (h *Handler) GetHeartbeatStats(c echo.Context) error

GetHeartbeatStats godoc @Summary GetHeartbeatStats stats @Description Returns heartbeats stats @Tags heartbeats @Accept json @Produce json @Param days path int true "Number of days to get stats for" @Success 200 {object} []model.HeartbeatStatsPoint @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/heartbeats/stats/{days} [get]

func (*Handler) GetHeartbeatsLastLatencies

func (h *Handler) GetHeartbeatsLastLatencies(c echo.Context) error

GetHeartbeatsLastLatencies godoc @Summary GetHeartbeatsLastLatencies stats @Description Returns last latencies @Tags heartbeats @Accept json @Produce json @Param size query string false "Size" @Success 200 {object} []model.HeartbeatPoint @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/heartbeats/latencies/last [get]

func (*Handler) GetHeartbeatsLatencies

func (h *Handler) GetHeartbeatsLatencies(c echo.Context) error

GetHeartbeats godoc @Summary Get all heartbeats @Description Returns all heartbeats @Tags heartbeats @Accept json @Produce json @Param service_id query string false "Filtering by service_id" @Param size query string false "Size" @Success 200 {object} []model.Heartbeat @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/heartbeats/latencies [get]

func (*Handler) GetNotification

func (h *Handler) GetNotification(c echo.Context) error

GetNotification godoc @Summary Get a notification @Description Returns a notification @Tags notifications @Accept json @Produce json @Param notification_name path string true "Get a notification by notification_name" @Success 200 {object} model.Notification @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/notifications/{notification_name} [get]

func (*Handler) GetNotifications

func (h *Handler) GetNotifications(c echo.Context) error

GetNotifications godoc @Summary Get notifications @Description Returns all notifications @Tags notifications @Accept json @Produce json @Success 200 {object} []model.Notification @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/notifications [get]

func (*Handler) GetService

func (h *Handler) GetService(c echo.Context) error

GetService godoc @Summary Get a service @Description Gets a service by its ID @Tags services @Accept json @Produce json @Param service_id path string true "Gets service by service_id" @Success 200 {object} model.Service @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/services/{service_id} [get]

func (*Handler) GetServices

func (h *Handler) GetServices(c echo.Context) error

GetServices godoc @Summary Get all services @Description Returns all services @Tags services @Accept json @Produce json @Success 200 {object} []model.Service @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/services [get]

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(e *echo.Echo)

func (*Handler) ServiceAddNotification

func (h *Handler) ServiceAddNotification(c echo.Context) error

ServiceAddNotification godoc @Summary Add a notification to a service @Description Adds a notification to a service @Tags services @Accept json @Produce json @Param service_id path string true "service_id" @Param notification_name path string true "notification_name" @Success 200 {object} model.ServiceNotification @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/services/{service_id}/notifications/{notification_name} [post]

func (*Handler) ServiceDeleteNotification

func (h *Handler) ServiceDeleteNotification(c echo.Context) error

ServiceDeleteNotification godoc @Summary Delete a notification to a service @Description Deletes a notification to a service @Tags services @Accept json @Produce json @Param service_id path string true "service_id" @Param notification_name path string true "notification_name" @Success 204 {object} model.ServiceNotification @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/services/{service_id}/notifications/{notification_name} [delete]

func (*Handler) UpdateNotification

func (h *Handler) UpdateNotification(c echo.Context) error

UpdateNotification godoc @Summary Update a notification @Description Updates a notification @Tags notifications @Accept json @Produce json @Param notification_name path string true "Updates a notification by notification_name" @Param body body model.UpdateNotification true "Update notification" @Success 200 {object} model.Notification @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/notifications/{notification_name} [patch]

func (*Handler) UpdateService

func (h *Handler) UpdateService(c echo.Context) error

UpdateService godoc @Summary Update a service @Description Updates an existing service and restarts monitoring for it @Tags services @Accept json @Produce json @Param service_id path string true "Updates by service_id" @Param body body model.UpdateService true "Update service" @Success 200 {object} model.Service @Failure 404 {object} echo.HTTPError @Failure 500 {object} echo.HTTPError @Security HttpBearer @Router /API/v1/services/{service_id} [patch]

type StackdriverFormatter

type StackdriverFormatter struct {
}

func (*StackdriverFormatter) Format

func (f *StackdriverFormatter) Format(entry *log.Entry) ([]byte, error)

type StackdriverPayload

type StackdriverPayload struct {
	Name      string               `json:"name"`
	Date      string               `json:"date"`
	Message   string               `json:"message"`
	Timestamp StackdriverTimestamp `json:"timestamp"`
	Severity  string               `json:"severity"`
	RequestID string               `json:"request_id"`
}

type StackdriverTimestamp

type StackdriverTimestamp struct {
	Seconds int64 `json:"seconds"`
	Nanos   int   `json:"nanos"`
}

Jump to

Keyboard shortcuts

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