controller

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DisplayNameAttributeName = "shared/nickname"
View Source
const FilterDevicesOfGroupByAccess = true
View Source
const ServiceGroupSelectionIdModifier = "service_group_selection"

Variables

This section is empty.

Functions

func CreateAspectNodes

func CreateAspectNodes(db database.Database, aspect models.Aspect, rootId string, parentId string, ancestors []string) (descendents []string, err error)

func DeviceGroupFilterGenericDuplicateCriteria added in v0.0.3

func DeviceGroupFilterGenericDuplicateCriteria(dg models.DeviceGroup, aspectNodeProvider AspectNodeProvider) (result models.DeviceGroup, err error)

DeviceGroupFilterGenericDuplicateCriteria removes criteria without aspect, that are already present with an aspect ref: https://bitnify.atlassian.net/browse/SNRGY-3027

func ValidateCharacteristicsWithoutDbAccess

func ValidateCharacteristicsWithoutDbAccess(characteristic models.Characteristic) (err error, code int)

func ValidateDeviceName

func ValidateDeviceName(device models.Device) (err error)

func ValidateName

func ValidateName(name string) (err error, code int)

func ValidateServiceGroups

func ValidateServiceGroups(groups []models.ServiceGroup, services []models.Service) error

func ValidateVariableName

func ValidateVariableName(name string) (err error, code int)

Types

type AspectNodeProvider added in v0.0.3

type AspectNodeProvider interface {
	ListAspectNodesByIdList(ctx context.Context, ids []string) ([]models.AspectNode, error)
}

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func New

func New(config config.Config, db database.Database, security Security, producer Producer) (ctrl *Controller, err error)

func (*Controller) CheckAccessToDevicesOfGroup

func (this *Controller) CheckAccessToDevicesOfGroup(token string, group models.DeviceGroup) (err error, code int)

only the first element of group.Devices is checked. this should be enough because every used device should be referenced in each element of group.Devices use ValidateDeviceGroup() to ensure that this constraint is adhered to

func (*Controller) DeleteAspect

func (this *Controller) DeleteAspect(id string) error

func (*Controller) DeleteCharacteristic

func (this *Controller) DeleteCharacteristic(id string) error

func (*Controller) DeleteConcept

func (this *Controller) DeleteConcept(id string) error

func (*Controller) DeleteDevice

func (this *Controller) DeleteDevice(id string) error

func (*Controller) DeleteDeviceClass

func (this *Controller) DeleteDeviceClass(id string) error

func (*Controller) DeleteDeviceGroup

func (this *Controller) DeleteDeviceGroup(id string) error

func (*Controller) DeleteDeviceType

func (this *Controller) DeleteDeviceType(id string) error

func (*Controller) DeleteFunction

func (this *Controller) DeleteFunction(id string) error

func (*Controller) DeleteHub

func (this *Controller) DeleteHub(id string) error

func (*Controller) DeleteLocation

func (this *Controller) DeleteLocation(id string) error

func (*Controller) DeleteProtocol

func (this *Controller) DeleteProtocol(id string) error

func (*Controller) FilterDevicesOfGroupByAccess

func (this *Controller) FilterDevicesOfGroupByAccess(token string, group models.DeviceGroup) (result models.DeviceGroup, err error, code int)

func (*Controller) GetAspect

func (this *Controller) GetAspect(id string) (result models.Aspect, err error, code int)

func (*Controller) GetAspectNode

func (this *Controller) GetAspectNode(id string) (result models.AspectNode, err error, code int)

func (*Controller) GetAspectNodes

func (this *Controller) GetAspectNodes() (result []models.AspectNode, err error, code int)

func (*Controller) GetAspectNodesByIdList

func (this *Controller) GetAspectNodesByIdList(ids []string) (result []models.AspectNode, err error, code int)

func (*Controller) GetAspectNodesMeasuringFunctions

func (this *Controller) GetAspectNodesMeasuringFunctions(aspect string, ancestors bool, descendants bool) (result []models.Function, err error, code int)

returns all measuring functions used in combination with given aspect (and optional its descendants and ancestors)

func (*Controller) GetAspectNodesWithMeasuringFunction

func (this *Controller) GetAspectNodesWithMeasuringFunction(ancestors bool, descendants bool) (result []models.AspectNode, err error, code int)

func (*Controller) GetAspects

func (this *Controller) GetAspects() (result []models.Aspect, err error, code int)

func (*Controller) GetAspectsWithMeasuringFunction

func (this *Controller) GetAspectsWithMeasuringFunction(ancestors bool, descendants bool) (result []models.Aspect, err error, code int)

func (*Controller) GetCharacteristic

func (this *Controller) GetCharacteristic(id string) (result models.Characteristic, err error, errCode int)

func (*Controller) GetConceptWithCharacteristics

func (this *Controller) GetConceptWithCharacteristics(id string) (result models.ConceptWithCharacteristics, err error, code int)

func (*Controller) GetConceptWithoutCharacteristics

func (this *Controller) GetConceptWithoutCharacteristics(id string) (result models.Concept, err error, code int)

func (*Controller) GetDeviceClass

func (this *Controller) GetDeviceClass(id string) (result models.DeviceClass, err error, errCode int)

func (*Controller) GetDeviceClasses

func (this *Controller) GetDeviceClasses() (result []models.DeviceClass, err error, code int)

func (*Controller) GetDeviceClassesControllingFunctions

func (this *Controller) GetDeviceClassesControllingFunctions(deviceClass string) (result []models.Function, err error, code int)

func (*Controller) GetDeviceClassesFunctions

func (this *Controller) GetDeviceClassesFunctions(deviceClass string) (result []models.Function, err error, code int)

func (*Controller) GetDeviceClassesWithControllingFunctions

func (this *Controller) GetDeviceClassesWithControllingFunctions() (result []models.DeviceClass, err error, code int)

func (*Controller) GetDeviceTypeSelectables

func (this *Controller) GetDeviceTypeSelectables(query []model.FilterCriteria, pathPrefix string, interactionsFilter []string, includeModified bool) (result []model.DeviceTypeSelectable, err error, code int)

func (*Controller) GetDeviceTypeSelectablesV2

func (this *Controller) GetDeviceTypeSelectablesV2(query []model.FilterCriteria, pathPrefix string, includeModified bool, servicesMustMatchAllCriteria bool) (result []model.DeviceTypeSelectable, err error, code int)

func (*Controller) GetFunction

func (this *Controller) GetFunction(id string) (result models.Function, err error, code int)

func (*Controller) GetFunctionsByType

func (this *Controller) GetFunctionsByType(rdfType string) (result []models.Function, err error, code int)

func (*Controller) GetLeafCharacteristics

func (this *Controller) GetLeafCharacteristics() (result []models.Characteristic, err error, code int)

func (*Controller) GetLocation

func (this *Controller) GetLocation(id string, token string) (result models.Location, err error, code int)

func (*Controller) GetService

func (this *Controller) GetService(id string) (result models.Service, err error, code int)

func (*Controller) GetUsedInDeviceType added in v0.0.6

func (this *Controller) GetUsedInDeviceType(query model.UsedInDeviceTypeQuery) (result model.UsedInDeviceTypeResponse, err error, errCode int)

func (*Controller) ListDeviceTypes

func (this *Controller) ListDeviceTypes(token string, limit int64, offset int64, sort string, filter []model.FilterCriteria, interactionsFilter []string, includeModified bool, includeUnmodified bool) (result []models.DeviceType, err error, errCode int)

func (*Controller) ListDeviceTypesV2

func (this *Controller) ListDeviceTypesV2(token string, limit int64, offset int64, sort string, filter []model.FilterCriteria, includeModified bool, includeUnmodified bool) (result []models.DeviceType, err error, errCode int)

func (*Controller) ListDevices added in v0.0.20

func (this *Controller) ListDevices(token string, options model.DeviceListOptions) (result []models.Device, err error, errCode int)

func (*Controller) ListExtendedDevices added in v0.1.0

func (this *Controller) ListExtendedDevices(token string, options model.DeviceListOptions) (result []models.ExtendedDevice, err error, errCode int)

func (*Controller) ListExtendedHubs added in v0.1.0

func (this *Controller) ListExtendedHubs(token string, options model.HubListOptions) (result []models.ExtendedHub, err error, errCode int)

func (*Controller) ListHubDeviceIds

func (this *Controller) ListHubDeviceIds(id string, token string, action model.AuthAction, asLocalId bool) (result []string, err error, errCode int)

func (*Controller) ListHubs added in v0.1.0

func (this *Controller) ListHubs(token string, options model.HubListOptions) (result []models.Hub, err error, errCode int)

func (*Controller) ListProtocols

func (this *Controller) ListProtocols(token string, limit int64, offset int64, sort string) (result []models.Protocol, err error, errCode int)

func (*Controller) PublishDeviceDelete

func (this *Controller) PublishDeviceDelete(id string, owner string) error

func (*Controller) ReadDevice

func (this *Controller) ReadDevice(id string, token string, action model.AuthAction) (result models.Device, err error, errCode int)

func (*Controller) ReadDeviceByLocalId

func (this *Controller) ReadDeviceByLocalId(ownerId string, localId string, token string, action model.AuthAction) (result models.Device, err error, errCode int)

func (*Controller) ReadDeviceGroup

func (this *Controller) ReadDeviceGroup(id string, token string, filterGenericDuplicateCriteria bool) (result models.DeviceGroup, err error, errCode int)

func (*Controller) ReadDeviceType

func (this *Controller) ReadDeviceType(id string, token string) (result models.DeviceType, err error, errCode int)

func (*Controller) ReadExtendedDevice added in v0.1.0

func (this *Controller) ReadExtendedDevice(id string, token string, action model.AuthAction) (result models.ExtendedDevice, err error, errCode int)

func (*Controller) ReadExtendedDeviceByLocalId added in v0.1.0

func (this *Controller) ReadExtendedDeviceByLocalId(ownerId string, localId string, token string, action model.AuthAction) (result models.ExtendedDevice, err error, errCode int)

func (*Controller) ReadExtendedHub added in v0.1.0

func (this *Controller) ReadExtendedHub(id string, token string, action model.AuthAction) (result models.ExtendedHub, err error, errCode int)

func (*Controller) ReadHub

func (this *Controller) ReadHub(id string, token string, action model.AuthAction) (result models.Hub, err error, errCode int)

func (*Controller) ReadProtocol

func (this *Controller) ReadProtocol(id string, token string) (result models.Protocol, err error, errCode int)

func (*Controller) RunStartupMigrations added in v0.0.15

func (this *Controller) RunStartupMigrations() error

func (*Controller) SendDone added in v0.0.11

func (this *Controller) SendDone(done donewait.DoneMsg) error

func (*Controller) SetAspect

func (this *Controller) SetAspect(aspect models.Aspect, owner string) error

func (*Controller) SetCharacteristic

func (this *Controller) SetCharacteristic(characteristic models.Characteristic, owner string) error

func (*Controller) SetConcept

func (this *Controller) SetConcept(concept models.Concept, owner string) error

func (*Controller) SetDevice

func (this *Controller) SetDevice(device models.Device, owner string) (err error)

func (*Controller) SetDeviceClass

func (this *Controller) SetDeviceClass(class models.DeviceClass, owner string) error

func (*Controller) SetDeviceConnectionState added in v0.1.0

func (this *Controller) SetDeviceConnectionState(id string, connected bool) error

func (*Controller) SetDeviceGroup

func (this *Controller) SetDeviceGroup(deviceGroup models.DeviceGroup, owner string) (err error)

func (*Controller) SetDeviceType

func (this *Controller) SetDeviceType(deviceType models.DeviceType, owner string) (err error)

func (*Controller) SetFunction

func (this *Controller) SetFunction(function models.Function, owner string) error

func (*Controller) SetHub

func (this *Controller) SetHub(hub models.Hub, owner string) (err error)

func (*Controller) SetHubConnectionState added in v0.1.0

func (this *Controller) SetHubConnectionState(id string, connected bool) error

func (*Controller) SetLocation

func (this *Controller) SetLocation(location models.Location, owner string) error

func (*Controller) SetProtocol

func (this *Controller) SetProtocol(protocol models.Protocol, owner string) (err error)

func (*Controller) ValidateAspect

func (this *Controller) ValidateAspect(aspect models.Aspect) (err error, code int)

func (*Controller) ValidateAspectDelete

func (this *Controller) ValidateAspectDelete(id string) (err error, code int)

func (*Controller) ValidateCharacteristicDelete

func (this *Controller) ValidateCharacteristicDelete(id string) (err error, code int)

func (*Controller) ValidateCharacteristics

func (this *Controller) ValidateCharacteristics(characteristic models.Characteristic) (err error, code int)

func (*Controller) ValidateConcept

func (this *Controller) ValidateConcept(concept models.Concept) (err error, code int)

func (*Controller) ValidateConceptDelete

func (this *Controller) ValidateConceptDelete(id string) (err error, code int)

func (*Controller) ValidateContent

func (this *Controller) ValidateContent(content models.Content, protocol models.Protocol, options model.ValidationOptions) (err error, code int)

func (*Controller) ValidateDevice

func (this *Controller) ValidateDevice(token string, device models.Device) (err error, code int)

func (*Controller) ValidateDeviceClass

func (this *Controller) ValidateDeviceClass(deviceClass models.DeviceClass) (err error, code int)

func (*Controller) ValidateDeviceClassDelete

func (this *Controller) ValidateDeviceClassDelete(id string) (err error, code int)

func (*Controller) ValidateDeviceGroup

func (this *Controller) ValidateDeviceGroup(group models.DeviceGroup) (err error, code int)

func (*Controller) ValidateDeviceGroupSelection

func (this *Controller) ValidateDeviceGroupSelection(criteria []models.DeviceGroupFilterCriteria, devices []string) (error, int)

func (*Controller) ValidateDeviceType

func (this *Controller) ValidateDeviceType(dt models.DeviceType, options model.ValidationOptions) (err error, code int)

func (*Controller) ValidateFunction

func (this *Controller) ValidateFunction(function models.Function) (err error, code int)

func (*Controller) ValidateFunctionDelete

func (this *Controller) ValidateFunctionDelete(id string) (err error, code int)

func (*Controller) ValidateHub

func (this *Controller) ValidateHub(token string, hub models.Hub) (err error, code int)

func (*Controller) ValidateHubDevices added in v0.0.18

func (this *Controller) ValidateHubDevices(hub models.Hub) (err error, code int)

func (*Controller) ValidateListSubVariables

func (this *Controller) ValidateListSubVariables(variables []models.ContentVariable, serialization models.Serialization, options model.ValidationOptions) (err error, code int)

func (*Controller) ValidateLocation

func (this *Controller) ValidateLocation(location models.Location) (err error, code int)

func (*Controller) ValidateProtocol

func (this *Controller) ValidateProtocol(protocol models.Protocol) (err error, code int)

func (*Controller) ValidateService

func (this *Controller) ValidateService(service models.Service, protocolCache *map[string]models.Protocol, options model.ValidationOptions) (error, int)

func (*Controller) ValidateStructureSubVariables

func (this *Controller) ValidateStructureSubVariables(variables []models.ContentVariable, serialization models.Serialization, options model.ValidationOptions) (err error, code int)

func (*Controller) ValidateVariable

func (this *Controller) ValidateVariable(variable models.ContentVariable, serialization models.Serialization, options model.ValidationOptions) (err error, code int)

type ErrorProducer

type ErrorProducer struct{}

func (ErrorProducer) PublishAspectDelete

func (this ErrorProducer) PublishAspectDelete(id string, owner string) (err error)

func (ErrorProducer) PublishAspectUpdate

func (this ErrorProducer) PublishAspectUpdate(aspect models.Aspect, owner string) (err error)

func (ErrorProducer) PublishDevice added in v0.0.18

func (this ErrorProducer) PublishDevice(element models.Device, userId string) (err error)

func (ErrorProducer) PublishDeviceDelete

func (this ErrorProducer) PublishDeviceDelete(id string, owner string) (err error)

func (ErrorProducer) PublishDeviceRights added in v0.0.18

func (this ErrorProducer) PublishDeviceRights(deviceId string, userId string, rights model.ResourceRights) (err error)

func (ErrorProducer) PublishHub

func (this ErrorProducer) PublishHub(hub models.Hub, userId string) (err error)

func (ErrorProducer) SendDone added in v0.0.11

func (this ErrorProducer) SendDone(msg donewait.DoneMsg) (err error)

type Producer

type Producer interface {
	PublishDevice(element models.Device, userId string) error
	PublishDeviceRights(deviceId string, userId string, rights model.ResourceRights) (err error)
	PublishDeviceDelete(id string, owner string) error
	PublishHub(hub models.Hub, userId string) (err error)
	PublishAspectDelete(id string, owner string) error
	PublishAspectUpdate(aspect models.Aspect, owner string) error
	SendDone(msg donewait.DoneMsg) error
}

type Security

type Security interface {
	CheckBool(token string, kind string, id string, action model.AuthAction) (allowed bool, err error)
	CheckMultiple(token string, kind string, ids []string, action model.AuthAction) (map[string]bool, error)
	GetAdminUsers(token string, topic string, resourceId string) (admins []string, err error)
	ListAccessibleResourceIds(token string, topic string, limit int64, offset int64, action model.AuthAction) ([]string, error)
	GetPermissionsInfo(token string, kind string, id string) (requestingUser string, permissions models.Permissions, err error)
}

Jump to

Keyboard shortcuts

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