web

package
v0.0.0-...-cc86588 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const JSONHeader = "application/json; charset=UTF-8"

JSONHeader is the header for JSON responses

Variables

This section is empty.

Functions

func Logger

func Logger(start time.Time, r *http.Request)

Logger Handle logging for the web service

func Middleware

func Middleware(inner http.Handler) http.Handler

Middleware to pre-process web service requests

Types

type ActionsResponse

type ActionsResponse struct {
	StandardResponse
	Actions []domain.Action `json:"actions"`
}

ActionsResponse is the JSON response to list actions for a device

type DeviceResponse

type DeviceResponse struct {
	StandardResponse
	Device domain.Device `json:"device"`
}

DeviceResponse is the JSON response to get a device

type DevicesResponse

type DevicesResponse struct {
	StandardResponse
	Devices []domain.Device `json:"devices"`
}

DevicesResponse is the JSON response to list devices

type GroupResponse

type GroupResponse struct {
	StandardResponse
	Group domain.Group `json:"group"`
}

GroupResponse is the JSON response to list groups

type GroupsResponse

type GroupsResponse struct {
	StandardResponse
	Groups []domain.Group `json:"groups"`
}

GroupsResponse is the JSON response to list groups

type Service

type Service struct {
	Settings   *config.Settings
	Controller controller.Controller
}

Service is the implementation of the web API

func NewService

func NewService(settings *config.Settings, ctrl controller.Controller) *Service

NewService returns a new web controller

func (Service) ActionList

func (wb Service) ActionList(w http.ResponseWriter, r *http.Request)

ActionList is the API call to list actions for a device

func (Service) DeviceGet

func (wb Service) DeviceGet(w http.ResponseWriter, r *http.Request)

DeviceGet is the API call to get a device

func (Service) DeviceList

func (wb Service) DeviceList(w http.ResponseWriter, r *http.Request)

DeviceList is the API call to get devices

func (Service) GroupCreate

func (wb Service) GroupCreate(w http.ResponseWriter, r *http.Request)

GroupCreate is the API call to create a group

func (Service) GroupGet

func (wb Service) GroupGet(w http.ResponseWriter, r *http.Request)

GroupGet is the API call to retrieve a group

func (Service) GroupGetDevices

func (wb Service) GroupGetDevices(w http.ResponseWriter, r *http.Request)

GroupGetDevices is the API call to get the devices for a group

func (Service) GroupGetExcludedDevices

func (wb Service) GroupGetExcludedDevices(w http.ResponseWriter, r *http.Request)

GroupGetExcludedDevices is the API call to get the devices not in a group

func (Service) GroupLinkDevice

func (wb Service) GroupLinkDevice(w http.ResponseWriter, r *http.Request)

GroupLinkDevice is the API call to link a device to a group

func (Service) GroupList

func (wb Service) GroupList(w http.ResponseWriter, r *http.Request)

GroupList is the API call to list groups

func (Service) GroupUnlinkDevice

func (wb Service) GroupUnlinkDevice(w http.ResponseWriter, r *http.Request)

GroupUnlinkDevice is the API call to unlink a device from a group

func (Service) Router

func (wb Service) Router() *mux.Router

Router returns the application router

func (Service) Run

func (wb Service) Run() error

Run starts the web service

func (Service) SnapInstall

func (wb Service) SnapInstall(w http.ResponseWriter, r *http.Request)

SnapInstall is the API call to install a snap for a device

func (Service) SnapList

func (wb Service) SnapList(w http.ResponseWriter, r *http.Request)

SnapList is the API call to list snaps for a device

func (Service) SnapListPublish

func (wb Service) SnapListPublish(w http.ResponseWriter, r *http.Request)

SnapListPublish is the API call to trigger a snap list on a device

func (Service) SnapRemove

func (wb Service) SnapRemove(w http.ResponseWriter, r *http.Request)

SnapRemove is the API call to uninstall a snap for a device

func (Service) SnapUpdateAction

func (wb Service) SnapUpdateAction(w http.ResponseWriter, r *http.Request)

SnapUpdateAction is the API call to update a snap for a device (enable, disable, refresh)

func (Service) SnapUpdateConf

func (wb Service) SnapUpdateConf(w http.ResponseWriter, r *http.Request)

SnapUpdateConf is the API call to update a snap for a device (settings)

type SnapsResponse

type SnapsResponse struct {
	StandardResponse
	Snaps []domain.DeviceSnap `json:"snaps"`
}

SnapsResponse is the JSON response to list snaps

type StandardResponse

type StandardResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

StandardResponse is the JSON response from an API method, indicating success or failure.

Jump to

Keyboard shortcuts

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