devicetwin

package
v0.0.0-...-73fe611 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceTwin

type DeviceTwin interface {
	HealthHandler(payload domain.Health) error
	ActionResponse(clientID, actionID, action string, payload []byte) error // process a response from a device

	ActionCreate(orgID, deviceID string, act domain.SubscribeAction) error
	ActionUpdate(actionID, status, message string) error
	ActionList(orgID, deviceID string) ([]domain.Action, error)

	DeviceSnaps(orgID, clientID string) ([]domain.DeviceSnap, error)

	DeviceList(orgID string) ([]domain.Device, error)
	DeviceGet(orgID, clientID string) (domain.Device, 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) ([]domain.Device, error)
	GroupGetExcludedDevices(orgID, name string) ([]domain.Device, error)
}

DeviceTwin interface for the service

type MockDeviceTwin

type MockDeviceTwin struct {
	Actions []string
}

MockDeviceTwin mocks a device twin service

func (*MockDeviceTwin) ActionCreate

func (twin *MockDeviceTwin) ActionCreate(orgID, deviceID string, act domain.SubscribeAction) error

ActionCreate mocks the action log creation

func (*MockDeviceTwin) ActionList

func (twin *MockDeviceTwin) ActionList(orgID, clientID string) ([]domain.Action, error)

ActionList mocks the action log list

func (*MockDeviceTwin) ActionResponse

func (twin *MockDeviceTwin) ActionResponse(clientID, actionID, action string, payload []byte) error

ActionResponse mocks the action handler

func (*MockDeviceTwin) ActionUpdate

func (twin *MockDeviceTwin) ActionUpdate(actionID, status, message string) error

ActionUpdate mocks the action log update

func (*MockDeviceTwin) DeviceGet

func (twin *MockDeviceTwin) DeviceGet(orgID, clientID string) (domain.Device, error)

DeviceGet mocks fetching a device

func (*MockDeviceTwin) DeviceList

func (twin *MockDeviceTwin) DeviceList(orgID string) ([]domain.Device, error)

DeviceList mocks fetching devices for an organization

func (*MockDeviceTwin) DeviceSnaps

func (twin *MockDeviceTwin) DeviceSnaps(orgID, clientID string) ([]domain.DeviceSnap, error)

DeviceSnaps mocks the snap list

func (*MockDeviceTwin) GroupCreate

func (twin *MockDeviceTwin) GroupCreate(orgID, name string) error

GroupCreate mocks creating a group

func (*MockDeviceTwin) GroupGet

func (twin *MockDeviceTwin) GroupGet(orgID, name string) (domain.Group, error)

GroupGet mocks fetching a group

func (*MockDeviceTwin) GroupGetDevices

func (twin *MockDeviceTwin) GroupGetDevices(orgID, name string) ([]domain.Device, error)

GroupGetDevices mocks retrieving the devices for a group

func (*MockDeviceTwin) GroupGetExcludedDevices

func (twin *MockDeviceTwin) GroupGetExcludedDevices(orgID, name string) ([]domain.Device, error)

GroupGetExcludedDevices mocks retrieving the devices not in a group

func (*MockDeviceTwin) GroupLinkDevice

func (twin *MockDeviceTwin) GroupLinkDevice(orgID, name, clientID string) error

GroupLinkDevice mocks linking a device to a group

func (*MockDeviceTwin) GroupList

func (twin *MockDeviceTwin) GroupList(orgID string) ([]domain.Group, error)

GroupList mocks listing groups

func (*MockDeviceTwin) GroupUnlinkDevice

func (twin *MockDeviceTwin) GroupUnlinkDevice(orgID, name, clientID string) error

GroupUnlinkDevice mocks unlinking a device from a group

func (*MockDeviceTwin) HealthHandler

func (twin *MockDeviceTwin) HealthHandler(payload domain.Health) error

HealthHandler mocks the health handler

type Service

type Service struct {
	Settings *config.Settings
	DB       datastore.DataStore
}

Service implementation of the identity use cases

func NewService

func NewService(settings *config.Settings, db datastore.DataStore) *Service

NewService creates an implementation of the device twin use cases

func (*Service) ActionCreate

func (srv *Service) ActionCreate(orgID, deviceID string, action domain.SubscribeAction) error

ActionCreate logs an action

func (*Service) ActionList

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

ActionList lists actions for a device

func (*Service) ActionResponse

func (srv *Service) ActionResponse(clientID, actionID, action string, payload []byte) error

ActionResponse handles action response from a device

func (*Service) ActionUpdate

func (srv *Service) ActionUpdate(actionID, status, message string) error

ActionUpdate updates action

func (*Service) DeviceGet

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

DeviceGet fetches a device details from the database cache

func (*Service) DeviceList

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

DeviceList fetches devices from the database cache

func (*Service) DeviceSnaps

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

DeviceSnaps fetches the snaps for 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) ([]domain.Device, error)

GroupGetDevices retrieves the devices from a group

func (*Service) GroupGetExcludedDevices

func (srv *Service) GroupGetExcludedDevices(orgID, name string) ([]domain.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 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(payload domain.Health) error

HealthHandler handles a health update from a device

Jump to

Keyboard shortcuts

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