com

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const Seperator = "$"

Variables

View Source
var ResourcesEffectedByUserDelete_BATCH_SIZE = 1000

Functions

func PreventIdModifier

func PreventIdModifier(id string) error

func RemoveDuplicates

func RemoveDuplicates[T comparable](slice []T) []T

Types

type Com

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

func New

func New(config config.Config) *Com

func (*Com) DeviceLocalIdToId

func (this *Com) DeviceLocalIdToId(token auth.Token, localId string) (id string, err error, code int)

func (*Com) DevicesOfTypeExist

func (this *Com) DevicesOfTypeExist(token auth.Token, deviceTypeId string) (result bool, err error, code int)

func (*Com) GetAspect

func (this *Com) GetAspect(token auth.Token, id string) (aspect models.Aspect, err error, code int)

func (*Com) GetCharacteristic

func (this *Com) GetCharacteristic(token auth.Token, id string) (concept models.Characteristic, err error, code int)

func (*Com) GetConcept

func (this *Com) GetConcept(token auth.Token, id string) (concept models.Concept, err error, code int)

func (*Com) GetDevice

func (this *Com) GetDevice(token auth.Token, id string) (device models.Device, err error, code int)

expects previous permission check and use own admin jwt to access device

func (*Com) GetDeviceClass

func (this *Com) GetDeviceClass(token auth.Token, id string) (deviceClass models.DeviceClass, err error, code int)

func (*Com) GetDeviceType

func (this *Com) GetDeviceType(token auth.Token, id string) (dt models.DeviceType, err error, code int)

func (*Com) GetFunction

func (this *Com) GetFunction(token auth.Token, id string) (function models.Function, err error, code int)

func (*Com) GetHub

func (this *Com) GetHub(token auth.Token, id string) (hub models.Hub, err error, code int)

expects previous permission check and use own admin jwt to access hub

func (*Com) GetLocation

func (this *Com) GetLocation(token auth.Token, id string) (Location models.Location, err error, code int)

func (*Com) GetPermissions

func (this *Com) GetPermissions(token auth.Token, kind string, id string) (permmodel.ResourceRights, error)

func (*Com) GetProtocol

func (this *Com) GetProtocol(token auth.Token, id string) (protocol models.Protocol, err error, code int)

func (*Com) GetResourceOwner

func (this *Com) GetResourceOwner(token auth.Token, kind string, id string, rights string) (owner string, found bool, err error)

GetResourceOwner queries the permission-search service for the entity identified by kind and id and extracts its owner the rights parameter is a mandatory part of the permission-search api it is used to identify which rights the user (token) must have for the entity, to get the entity as a result for example, if a user has 'r' rights to an entity, the query will find the entity, if requested with rights="r" but not with rights="w" or rights="rw"

func (*Com) GetTechnicalDeviceGroup

func (this *Com) GetTechnicalDeviceGroup(token auth.Token, id string) (dt models.DeviceGroup, err error, code int)

func (*Com) PermissionCheck

func (this *Com) PermissionCheck(token auth.Token, id string, permission string, resource string) (err error, code int)

func (*Com) PermissionCheckForCharacteristic

func (this *Com) PermissionCheckForCharacteristic(token auth.Token, id string, permission string) (err error, code int)

func (*Com) PermissionCheckForConcept

func (this *Com) PermissionCheckForConcept(token auth.Token, id string, permission string) (err error, code int)

func (*Com) PermissionCheckForDevice

func (this *Com) PermissionCheckForDevice(token auth.Token, id string, permission string) (err error, code int)

func (*Com) PermissionCheckForDeviceGroup

func (this *Com) PermissionCheckForDeviceGroup(token auth.Token, id string, permission string) (err error, code int)

func (*Com) PermissionCheckForDeviceList

func (this *Com) PermissionCheckForDeviceList(token auth.Token, ids []string, rights string) (result map[string]bool, err error, code int)

func (*Com) PermissionCheckForDeviceType

func (this *Com) PermissionCheckForDeviceType(token auth.Token, id string, permission string) (err error, code int)

func (*Com) PermissionCheckForHub

func (this *Com) PermissionCheckForHub(token auth.Token, id string, permission string) (err error, code int)

func (*Com) PermissionCheckForLocation

func (this *Com) PermissionCheckForLocation(token auth.Token, id string, permission string) (err error, code int)

func (*Com) QueryPermissionsSearch

func (this *Com) QueryPermissionsSearch(token string, query QueryMessage, result interface{}) (err error, code int)

func (*Com) ResourcesEffectedByUserDelete

func (this *Com) ResourcesEffectedByUserDelete(token auth.Token, resource string) (deleteResourceIds []string, deleteUserFromResourceIds []string, err error)

func (*Com) ValidateAspect

func (this *Com) ValidateAspect(token auth.Token, aspect models.Aspect) (err error, code int)

func (*Com) ValidateAspectDelete

func (this *Com) ValidateAspectDelete(token auth.Token, id string) (err error, code int)

func (*Com) ValidateCharacteristic

func (this *Com) ValidateCharacteristic(token auth.Token, characteristic models.Characteristic) (err error, code int)

func (*Com) ValidateCharacteristicDelete

func (this *Com) ValidateCharacteristicDelete(token auth.Token, id string) (err error, code int)

func (*Com) ValidateConcept

func (this *Com) ValidateConcept(token auth.Token, concept models.Concept) (err error, code int)

func (*Com) ValidateConceptDelete

func (this *Com) ValidateConceptDelete(token auth.Token, id string) (err error, code int)

func (*Com) ValidateDevice

func (this *Com) ValidateDevice(token auth.Token, device models.Device) (err error, code int)

func (*Com) ValidateDeviceClass

func (this *Com) ValidateDeviceClass(token auth.Token, deviceClass models.DeviceClass) (err error, code int)

func (*Com) ValidateDeviceClassDelete

func (this *Com) ValidateDeviceClassDelete(token auth.Token, id string) (err error, code int)

func (*Com) ValidateDeviceGroup

func (this *Com) ValidateDeviceGroup(token auth.Token, dg models.DeviceGroup) (err error, code int)

func (*Com) ValidateDeviceType

func (this *Com) ValidateDeviceType(token auth.Token, dt models.DeviceType) (err error, code int)

func (*Com) ValidateFunction

func (this *Com) ValidateFunction(token auth.Token, function models.Function) (err error, code int)

func (*Com) ValidateFunctionDelete

func (this *Com) ValidateFunctionDelete(token auth.Token, id string) (err error, code int)

func (*Com) ValidateHub

func (this *Com) ValidateHub(token auth.Token, hub models.Hub) (err error, code int)

func (*Com) ValidateLocation

func (this *Com) ValidateLocation(token auth.Token, location models.Location) (err error, code int)

func (*Com) ValidateProtocol

func (this *Com) ValidateProtocol(token auth.Token, protocol models.Protocol) (err error, code int)

type ConditionConfig

type ConditionConfig struct {
	Feature   string             `json:"feature"`
	Operation QueryOperationType `json:"operation"`
	Value     interface{}        `json:"value"`
	Ref       string             `json:"ref"`
}

type ListAfter

type ListAfter struct {
	SortFieldValue interface{} `json:"sort_field_value"`
	Id             string      `json:"id"`
}

type PermSearchElement

type PermSearchElement struct {
	Id                string            `json:"id"`
	Name              string            `json:"name"`
	Shared            bool              `json:"shared"`
	Creator           string            `json:"creator"`
	PermissionHolders PermissionHolders `json:"permission_holders"`
}

type PermissionHolders

type PermissionHolders struct {
	AdminUsers   []string `json:"admin_users"`
	ReadUsers    []string `json:"read_users"`
	WriteUsers   []string `json:"write_users"`
	ExecuteUsers []string `json:"execute_users"`
}

type QueryCheckIds

type QueryCheckIds struct {
	Ids    []string `json:"ids"`
	Rights string   `json:"rights"`
}

type QueryFind

type QueryFind struct {
	QueryListCommons
	Search string     `json:"search"`
	Filter *Selection `json:"filter"`
}

type QueryListCommons

type QueryListCommons struct {
	Limit    int        `json:"limit"`
	Offset   int        `json:"offset"`
	After    *ListAfter `json:"after"`
	Rights   string     `json:"rights"`
	SortBy   string     `json:"sort_by"`
	SortDesc bool       `json:"sort_desc"`
}

type QueryListIds

type QueryListIds struct {
	QueryListCommons
	Ids []string `json:"ids"`
}

type QueryMessage

type QueryMessage struct {
	Resource string         `json:"resource"`
	Find     *QueryFind     `json:"find"`
	ListIds  *QueryListIds  `json:"list_ids"`
	CheckIds *QueryCheckIds `json:"check_ids"`
}

type QueryOperationType

type QueryOperationType string
const (
	QueryEqualOperation             QueryOperationType = "=="
	QueryUnequalOperation           QueryOperationType = "!="
	QueryAnyValueInFeatureOperation QueryOperationType = "any_value_in_feature"
)

type Selection

type Selection struct {
	And       []Selection     `json:"and"`
	Or        []Selection     `json:"or"`
	Not       *Selection      `json:"not"`
	Condition ConditionConfig `json:"condition"`
}

Jump to

Keyboard shortcuts

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