controller

package
v0.0.0-...-34aea0c Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package controller is the interface to handling with REST API actions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	// MQTT handlers
	HealthHandler(client MQTT.Client, msg MQTT.Message)
	ActionHandler(client MQTT.Client, msg MQTT.Message)

	// Passthrough to the device twin service
	DeviceSnaps(orgID, clientID string) ([]messages.DeviceSnap, error)
	DeviceList(orgID string) ([]messages.Device, error)
	DeviceDelete(deviceID string) error
	DeviceGet(orgID, clientID string) (messages.Device, error)
	DeviceUnregister(orgID, clientID string) error
	DeviceLogs(orgID, clientID string, logData *messages.DeviceLogs) error
	GroupCreate(orgID, name string) error
	GroupList(orgID string) ([]domain.Group, error)
	GroupGet(orgID, name string) (domain.Group, error)
	GroupLinkDevice(orgID, name, clientID string) error
	GroupUnlinkDevice(orgID, name, clientID string) error
	GroupGetDevices(orgID, name string) ([]messages.Device, error)
	GroupGetExcludedDevices(orgID, name string) ([]messages.Device, error)

	// Actions on a device
	DeviceSnapList(orgID, clientID string) error
	DeviceSnapInstall(orgID, clientID, snap string) error
	DeviceSnapServiceAction(orgID, clientID, snap, action string, services *messages.SnapService) error
	DeviceSnapRemove(orgID, clientID, snap string) error
	DeviceSnapUpdate(orgID, clientID, snap, action string, snapUpdate *messages.SnapUpdate) error
	DeviceSnapConf(orgID, clientID, snap, settings string) error
	DeviceSnapSnapshot(orgID, clientID, snap string, s3data *messages.SnapSnapshot) error
	ActionList(orgID, clientID string) ([]domain.Action, error)
	User(orgID, clientID string, user *messages.DeviceUser) error
}

Controller interface for the service

type Service

type Service struct {
	MQTT       mqtt.Connect
	DeviceTwin devicetwin.DeviceTwin
}

Service implementation of the devicetwin service use cases

func NewService

func NewService(url, port string, connect *config.MQTTConnect, twin devicetwin.DeviceTwin) *Service

NewService creates an implementation of the devicetwin use cases

func (*Service) ActionHandler

func (srv *Service) ActionHandler(client MQTT.Client, msg MQTT.Message)

ActionHandler is the handler for the main subscription topic

func (*Service) ActionList

func (srv *Service) ActionList(orgID, clientID string) ([]domain.Action, error)

ActionList gets the action log for a device

func (*Service) DeviceDelete

func (srv *Service) DeviceDelete(deviceID string) error

DeviceDelete deletes the device from the database cache

func (*Service) DeviceGet

func (srv *Service) DeviceGet(orgID, clientID string) (messages.Device, error)

DeviceGet gets the device from the database cache

func (*Service) DeviceList

func (srv *Service) DeviceList(orgID string) ([]messages.Device, error)

DeviceList gets the devices from the database cache

func (*Service) DeviceLogs

func (srv *Service) DeviceLogs(orgID, clientID string, logData *messages.DeviceLogs) error

DeviceLogs triggers an upload of snapd logs to S3

func (*Service) DeviceSnapConf

func (srv *Service) DeviceSnapConf(orgID, clientID, snap, settings string) error

DeviceSnapConf triggers a snap settings update on a device

func (*Service) DeviceSnapInstall

func (srv *Service) DeviceSnapInstall(orgID, clientID, snap string) error

DeviceSnapInstall triggers installing a snap on a device

func (*Service) DeviceSnapList

func (srv *Service) DeviceSnapList(orgID, clientID string) error

DeviceSnapList triggers listing snaps on a device

func (*Service) DeviceSnapRemove

func (srv *Service) DeviceSnapRemove(orgID, clientID, snap string) error

DeviceSnapRemove triggers uninstalling a snap on a device

func (*Service) DeviceSnapServiceAction

func (srv *Service) DeviceSnapServiceAction(orgID, clientID, snap, action string, services *messages.SnapService) error

DeviceSnapServiceAction triggers stop,`start, or restart for a snap on a device

func (*Service) DeviceSnapSnapshot

func (srv *Service) DeviceSnapSnapshot(orgID, clientID, snap string, snapshotData *messages.SnapSnapshot) error

DeviceSnapSnapshot triggers uploading a snapshot of a snap on a device to S3

func (*Service) DeviceSnapUpdate

func (srv *Service) DeviceSnapUpdate(orgID, clientID, snap, action string, snapUpdate *messages.SnapUpdate) error

DeviceSnapUpdate triggers a snap update on a device

func (*Service) DeviceSnaps

func (srv *Service) DeviceSnaps(orgID, clientID string) ([]messages.DeviceSnap, error)

DeviceSnaps gets the device's snaps from the database cache

func (*Service) DeviceUnregister

func (srv *Service) DeviceUnregister(orgID, clientID string) error

DeviceUnregister triggers unregister action on a device

func (*Service) GroupCreate

func (srv *Service) GroupCreate(orgID, name string) error

GroupCreate creates a device group

func (*Service) GroupGet

func (srv *Service) GroupGet(orgID, name string) (domain.Group, error)

GroupGet retrieves a device group

func (*Service) GroupGetDevices

func (srv *Service) GroupGetDevices(orgID, name string) ([]messages.Device, error)

GroupGetDevices retrieves the devices from a group

func (*Service) GroupGetExcludedDevices

func (srv *Service) GroupGetExcludedDevices(orgID, name string) ([]messages.Device, error)

GroupGetExcludedDevices retrieves the devices not in a group

func (*Service) GroupLinkDevice

func (srv *Service) GroupLinkDevice(orgID, name, clientID string) error

GroupLinkDevice links a device to a group

func (*Service) GroupList

func (srv *Service) GroupList(orgID string) ([]domain.Group, error)

GroupList lists the groups for an organization

func (*Service) GroupUnlinkDevice

func (srv *Service) GroupUnlinkDevice(orgID, name, clientID string) error

GroupUnlinkDevice unlinks a device from a group

func (*Service) HealthHandler

func (srv *Service) HealthHandler(client MQTT.Client, msg MQTT.Message)

HealthHandler is the handler for the devices health messages

func (*Service) SubscribeToActions

func (srv *Service) SubscribeToActions() error

SubscribeToActions subscribes to the published topics from the devices

func (*Service) User

func (srv *Service) User(orgID, clientID string, user *messages.DeviceUser) error

User sends a user action to the device, which will eithe add or remove a user.

Jump to

Keyboard shortcuts

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