Documentation ¶
Overview ¶
Package web contains the code for handling the REST API
Index ¶
- Constants
- type ActionsResponse
- type DeviceResponse
- type DevicesResponse
- type GroupResponse
- type GroupsResponse
- type Service
- func (wb Service) ActionList(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) AddRoutes(engine *gin.Engine)
- func (wb Service) DeviceDelete(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) DeviceGet(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) DeviceList(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) DeviceLogs(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) DeviceUnregister(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) GroupCreate(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) GroupGet(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) GroupGetDevices(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) GroupGetExcludedDevices(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) GroupLinkDevice(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) GroupList(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) GroupUnlinkDevice(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) Run() error
- func (wb Service) SnapInstall(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) SnapList(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) SnapListPublish(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) SnapRemove(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) SnapServiceAction(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) SnapSnapshot(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) SnapUpdateAction(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) SnapUpdateConf(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) UserAdd(w http.ResponseWriter, r *http.Request, vars varLookup)
- func (wb Service) UserRemove(w http.ResponseWriter, r *http.Request, vars varLookup)
- type SnapsResponse
- type StandardResponse
Constants ¶
const JSONHeader = "application/json; charset=UTF-8"
JSONHeader is the header for JSON responses
const UserCreateAction = "create"
UserCreateAction represents the action of creating a user. This constant is used with the snapd api.
const UserRemoveAction = "remove"
UserRemoveAction represents the action of removing a user. This constant is used with the snapd api.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 messages.Device `json:"device"` }
DeviceResponse is the JSON response to get a device
type DevicesResponse ¶
type DevicesResponse struct { StandardResponse Devices []messages.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 { Controller controller.Controller // contains filtered or unexported fields }
Service is the implementation of the web API
func NewService ¶
func NewService(port string, ctrl controller.Controller) *Service
NewService returns a new web controller
func (Service) ActionList ¶
func (wb Service) ActionList(w http.ResponseWriter, r *http.Request, vars varLookup)
ActionList is the API call to list actions for a device
func (Service) DeviceDelete ¶
func (wb Service) DeviceDelete(w http.ResponseWriter, r *http.Request, vars varLookup)
DeviceDelete is the API call to delete devices
func (Service) DeviceGet ¶
func (wb Service) DeviceGet(w http.ResponseWriter, r *http.Request, vars varLookup)
DeviceGet is the API call to get a device
func (Service) DeviceList ¶
func (wb Service) DeviceList(w http.ResponseWriter, r *http.Request, vars varLookup)
DeviceList is the API call to get devices
func (Service) DeviceLogs ¶
func (wb Service) DeviceLogs(w http.ResponseWriter, r *http.Request, vars varLookup)
DeviceLogs is the API call to upload syslog logs from a device to S3
func (Service) DeviceUnregister ¶
func (wb Service) DeviceUnregister(w http.ResponseWriter, r *http.Request, vars varLookup)
DeviceUnregister is the API call to send unregister event to the device
func (Service) GroupCreate ¶
func (wb Service) GroupCreate(w http.ResponseWriter, r *http.Request, vars varLookup)
GroupCreate is the API call to create a group
func (Service) GroupGet ¶
func (wb Service) GroupGet(w http.ResponseWriter, r *http.Request, vars varLookup)
GroupGet is the API call to retrieve a group
func (Service) GroupGetDevices ¶
func (wb Service) GroupGetDevices(w http.ResponseWriter, r *http.Request, vars varLookup)
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, vars varLookup)
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, vars varLookup)
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, vars varLookup)
GroupList is the API call to list groups
func (Service) GroupUnlinkDevice ¶
func (wb Service) GroupUnlinkDevice(w http.ResponseWriter, r *http.Request, vars varLookup)
GroupUnlinkDevice is the API call to unlink a device from a group
func (Service) SnapInstall ¶
func (wb Service) SnapInstall(w http.ResponseWriter, r *http.Request, vars varLookup)
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, vars varLookup)
SnapList is the API call to list snaps for a device
func (Service) SnapListPublish ¶
func (wb Service) SnapListPublish(w http.ResponseWriter, r *http.Request, vars varLookup)
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, vars varLookup)
SnapRemove is the API call to uninstall a snap for a device
func (Service) SnapServiceAction ¶
func (wb Service) SnapServiceAction(w http.ResponseWriter, r *http.Request, vars varLookup)
SnapServiceAction is the API call to start,stop, or restart a snap for a device
func (Service) SnapSnapshot ¶
func (wb Service) SnapSnapshot(w http.ResponseWriter, r *http.Request, vars varLookup)
SnapSnapshot is the API call to upload a snapshot of a snap to S3 storage
func (Service) SnapUpdateAction ¶
func (wb Service) SnapUpdateAction(w http.ResponseWriter, r *http.Request, vars varLookup)
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, vars varLookup)
SnapUpdateConf is the API call to update a snap for a device (settings)
func (Service) UserAdd ¶
func (wb Service) UserAdd(w http.ResponseWriter, r *http.Request, vars varLookup)
UserAdd is the API call to create a user on a device
func (Service) UserRemove ¶
func (wb Service) UserRemove(w http.ResponseWriter, r *http.Request, vars varLookup)
UserRemove is the API call to remove a user on a device
type SnapsResponse ¶
type SnapsResponse struct { StandardResponse Snaps []messages.DeviceSnap `json:"snaps"` }
SnapsResponse is the JSON response to list snaps
type StandardResponse ¶
StandardResponse is the JSON response from an API method, indicating success or failure.