Documentation
¶
Index ¶
Constants ¶
View Source
const ( BroadcastWoLSentMessage = "Wake on LAN packets sent to all available broadcast addresses" WoLSentMessage = "Wake on LAN packet sent" )
Variables ¶
View Source
var ( ErrorBindingRequest = errors.New("failed to parse request body") ErrorValidatingRequest = errors.New("failed to validate request body") ErrorCreatingTargetServer = errors.New("failed to create target server") ErrorBroadcastAddress = errors.New("no broadcast addresses available or invalid broadcast address encountered") ErrorSendingWoLPacket = errors.New("failed to send wake on LAN packet") )
Functions ¶
This section is empty.
Types ¶
type BroadcastWakeRequest ¶
type BroadcastWakeRequest struct {
Mac string `json:"mac" validate:"required,mac" example:"00:11:22:33:44:55"`
Port int `json:"port" validate:"gte=1,lte=65535" example:"9"`
}
func NewBroadcastWakeRequest ¶
func NewBroadcastWakeRequest() *BroadcastWakeRequest
type ProfilerHandler ¶ added in v1.2.0
type ProfilerHandler struct{}
func NewProfilerHandler ¶ added in v1.2.0
func NewProfilerHandler() *ProfilerHandler
func (*ProfilerHandler) Register ¶ added in v1.2.0
func (*ProfilerHandler) Register(group *echo.Group)
Register middleware for net/http/pprof Inspired by https://github.com/labstack/echo-contrib/blob/master/pprof/pprof.go
type RootHandler ¶
type RootHandler struct {
// contains filtered or unexported fields
}
func NewRootHandler ¶
func NewRootHandler(cfg *entity.Config, rulesFS afero.Fs, upsRepo repository.UPSRepository) *RootHandler
NewRootHandler constructs a RootHandler with the provided configuration, rules filesystem and UPS repository. The returned handler holds the dependencies used by the package's HTTP handlers, including the repository for querying UPS/NUT servers.
@Title UPSWake @Version 1.0 @Description UPSWake reads data from a UPS Nut Server and uses it to dynamically send Wake on Lan packets to servers
func (*RootHandler) Health ¶
func (h *RootHandler) Health(c *echo.Context) error
Health godoc
@Summary Health check
@Description Health check
@Tags root
@Accept json
@Produce json
@Success 200 {object} Response "OK"
@Failure 500 {object} Response
@Router /health [get]
func (*RootHandler) Register ¶
func (h *RootHandler) Register(g *echo.Group)
type ServerHandler ¶
type ServerHandler struct {
// contains filtered or unexported fields
}
func NewServerHandler ¶
func NewServerHandler() *ServerHandler
func (*ServerHandler) BroadcastWakeServer ¶
func (s *ServerHandler) BroadcastWakeServer(c *echo.Context) error
BroadcastWakeServer godoc
@Summary Wake a server using just a MAC
@Description Wake a server using Wake on LAN by using the MAC and enumerating all available broadcast addresses
@Tags servers
@Accept json
@Produce json
@Param broadcastWakeRequest body BroadcastWakeRequest true "Broadcast wake request"
@Success 201 {object} Response "Wake on LAN packets successfully sent to all available broadcast addresses"
@Failure 400 {object} Response "Input validation failed"
@Failure 500 {object} Response "Wake on LAN packet failed to send"
@Router /api/servers/broadcastwake [post]
func (*ServerHandler) Register ¶
func (s *ServerHandler) Register(g *echo.Group)
func (*ServerHandler) WakeServer ¶
func (s *ServerHandler) WakeServer(c *echo.Context) error
WakeServer godoc
@Summary Wake a server using a MAC and a broadcast address
@Description Wake a server using Wake on LAN using the MAC and broadcast address provided
@Tags servers
@Accept json
@Produce json
@Param wakeServerRequest body WakeServerRequest true "Wake server request"
@Success 201 {object} Response "Wake on LAN packet sent"
@Failure 400 {object} Response "Input validation failed"
@Failure 500 {object} Response "Wake on LAN packet failed to send"
@Router /api/servers/wake [post]
type UPSWakeHandler ¶
type UPSWakeHandler struct {
// contains filtered or unexported fields
}
func NewUPSWakeHandler ¶
func NewUPSWakeHandler(cfg *entity.Config, upsRepo repository.UPSRepository, ruleRepo repository.RuleRepository) *UPSWakeHandler
NewUPSWakeHandler creates a UPSWakeHandler configured with the supplied server configuration and repositories. The returned handler holds cfg, upsRepo and ruleRepo for use by its HTTP endpoints.
func (*UPSWakeHandler) ListNutServerMappings ¶
func (h *UPSWakeHandler) ListNutServerMappings(c *echo.Context) error
ListNutServerMappings godoc
@Summary List NUT server mappings
@Description List NUT server mappings using the config stored in the server
@Tags UPSWake
@Accept json
@Produce json
@Success 200 {object} []viper.NutServer
@Router /api/upswake [get]
func (*UPSWakeHandler) Register ¶
func (h *UPSWakeHandler) Register(g *echo.Group)
func (*UPSWakeHandler) RunWakeEvaluation ¶
func (h *UPSWakeHandler) RunWakeEvaluation(c *echo.Context) error
RunWakeEvaluation godoc
@Summary Run wake evaluation
@Description Run wake evaluation using the config and rules stored in the server
@Tags UPSWake
@Accept json
@Produce json
@Param request body WakeEvaluationRequest true "the mac address of the target to wake"
@Success 200 {object} UpsWakeResponse "Wake on LAN sent"
@Success 304 {object} UpsWakeResponse "No rule evaluated to true"
@Failure 400 {object} UpsWakeResponse "Bad request"
@Failure 404 {object} UpsWakeResponse "MAC address not found in the config"
@Failure 500 {object} UpsWakeResponse "Internal server error"
@Router /api/upswake [post]
type UpsWakeResponse ¶ added in v1.2.0
type WakeEvaluationRequest ¶ added in v1.2.0
type WakeEvaluationRequest struct {
Mac string `json:"mac" example:"00:11:22:33:44:55"`
}
type WakeServerRequest ¶
type WakeServerRequest struct {
Broadcast string `json:"broadcast" validate:"required,ip" example:"192.168.1.13"`
Mac string `json:"mac" validate:"required,mac" example:"00:11:22:33:44:55"`
Port int `json:"port" validate:"gte=1,lte=65535" example:"9"`
}
func NewWakeServerRequest ¶
func NewWakeServerRequest() *WakeServerRequest
Click to show internal directories.
Click to hide internal directories.