Documentation ¶
Overview ¶
Package ipso_registry provides methods to create and control OMA IPSO registry.
Index ¶
- Constants
- func DefaultSanitizer() []string
- type Configuration
- type DifferenceType
- type InstanceType
- type Lwm2M
- type MandatoryType
- type Object
- type ObjectComparison
- type ObjectMeta
- type ObjectResources
- type OperationType
- type Reg
- func (r *Reg) Compare(reg *Reg) []ObjectComparison
- func (r *Reg) Export(filename string) error
- func (r *Reg) Find(o Object) (Object, error)
- func (r *Reg) FindObjectByIDAndVer(id int32, ver string) (Object, error)
- func (r *Reg) FindObjectsByID(id int32) ([]Object, error)
- func (r *Reg) FindResourceByOIR(oir string) (Resource, error)
- func (r *Reg) FindResourceByObjIDObjVerResID(objID int32, objVer string, resID int32) (Resource, error)
- func (r *Reg) FindResourcesByID(id int32) ([]Resource, error)
- func (r *Reg) FindResourcesByObjResIDs(objID, resID int32) ([]Resource, error)
- func (r *Reg) GetObjects() []Object
- func (r *Reg) GetRegistry() *Reg
- func (r *Reg) Import(filename string) error
- func (r *Reg) ImportFromAPI() ([]Object, error)
- func (r *Reg) Sanitize(sanitizer []string)
- type Registry
- type Resource
- type ResourceType
Constants ¶
const ( DefaultLwM2MVersion = "1.0" DefaultObjectVersion = "1.0" )
Variables ¶
This section is empty.
Functions ¶
func DefaultSanitizer ¶
func DefaultSanitizer() []string
DefaultSanitizer returns an array with default sanitizer strings.
Types ¶
type Configuration ¶
type Configuration struct { InitOnNew bool // indicates whether registry should be initialized from API on creation SkipInitErrors bool // indicates whether to ignore particular resource or object initialization errors Sanitize bool // whether objects and Resources description should be cleaned up on registry init Sanitizer []string // strings that should be removed from resource and object description }
Configuration to control the registry.
func DefaultConfiguration ¶
func DefaultConfiguration() Configuration
DefaultConfiguration creates a Configuration with the default settings.
type DifferenceType ¶
type DifferenceType string
DifferenceType represents the objects difference explanation.
const ( DifferenceTypeUnknown DifferenceType = "Unknown reason" DifferenceTypeNewObject DifferenceType = "New object added" DifferenceTypeObjectRemoved DifferenceType = "Object was removed" )
DifferenceType constants.
type InstanceType ¶
type InstanceType string
InstanceType represents the type of data.
const ( InstanceTypeSingle InstanceType = "Single" InstanceTypeMultiple InstanceType = "Multiple" )
InstanceType constants.
type Lwm2M ¶
type Lwm2M struct {
Object Object `json:"Object,omitempty" xml:"Object"`
}
Lwm2M struct for Lwm2M wrapper entry.
type MandatoryType ¶
type MandatoryType string
MandatoryType represents the type of data.
const ( MandatoryTypeOptional MandatoryType = "Optional" MandatoryTypeMandatory MandatoryType = "Mandatory" )
MandatoryType constants.
type Object ¶
type Object struct { Name string `json:"Name" xml:"Name" yaml:"Name"` Description1 string `json:"Description1,omitempty" xml:"Description1" yaml:"Description1"` Description2 string `json:"Description2,omitempty" xml:"Description2" yaml:"Description2"` ObjectID int32 `json:"ObjectID" xml:"ObjectID" yaml:"ObjectID"` ObjectURN string `json:"ObjectURN,omitempty" xml:"ObjectURN" yaml:"ObjectURN"` LWM2MVersion string `json:"LWM2MVersion,omitempty" xml:"LWM2MVersion" yaml:"LWM2MVersion"` ObjectVersion string `json:"ObjectVersion,omitempty" xml:"ObjectVersion" yaml:"ObjectVersion"` MultipleInstances InstanceType `json:"MultipleInstances" xml:"MultipleInstances" yaml:"MultipleInstances"` Mandatory MandatoryType `json:"Mandatory" xml:"Mandatory" yaml:"Mandatory"` Resources ObjectResources `json:"Resources" xml:"Resources" yaml:"Resources"` }
Object structure represents OMA Object entity.
type ObjectComparison ¶
type ObjectComparison struct { Difference DifferenceType Object Object // object in existing registry ObjectComp Object // object in compared registry, which is passed as parameter to Compare function }
ObjectComparison contains details of two objects comparison.
type ObjectMeta ¶
type ObjectMeta struct { ObjectID int32 `json:"ObjectID" xml:"ObjectID" yaml:"ObjectID"` Ver string `json:"Ver,omitempty" xml:"Ver" yaml:"Ver"` URN string `json:"URN,omitempty" xml:"URN" yaml:"URN"` Name string `json:"Name" xml:"Name" yaml:"Name"` Description string `json:"Description,omitempty" xml:"Description" yaml:"Description"` Owner string `json:"Owner,omitempty" xml:"Owner" yaml:"Owner"` Label string `json:"Label,omitempty" xml:"Label" yaml:"Label"` ObjectLink string `json:"ObjectLink" xml:"ObjectLink" yaml:"ObjectLink"` ObjectLinkVisible string `json:"ObjectLinkVisible,omitempty" xml:"ObjectLinkVisible" yaml:"ObjectLinkVisible"` SpecLink string `json:"SpecLink,omitempty" xml:"SpecLink" yaml:"SpecLink"` SpecLinkVisible string `json:"SpecLinkVisible,omitempty" xml:"SpecLinkVisible" yaml:"SpecLinkVisible"` VortoLink string `json:"VortoLink,omitempty" xml:"VortoLink" yaml:"VortoLink"` }
ObjectMeta struct for ObjectMeta.
type ObjectResources ¶
type ObjectResources struct {
Item []Resource `json:"Item,omitempty" xml:"Item" yaml:"Item,omitempty"`
}
ObjectResources struct for ObjectResources field.
type OperationType ¶
type OperationType string
OperationType represents the type of data.
const ( OperationTypeRead OperationType = "R" OperationTypeWrite OperationType = "W" OperationTypeReadWrite OperationType = "RW" OperationTypeExecute OperationType = "E" )
OperationType constants.
type Reg ¶
type Reg struct { Config Configuration Objects []Object // contains filtered or unexported fields }
Reg contains registry objects and settings.
func (*Reg) Compare ¶
func (r *Reg) Compare(reg *Reg) []ObjectComparison
Compare r and reg registries. Return a list of non-equal objects with difference explanation.
func (*Reg) Export ¶
Export store registry objects and resources in a specified file in YAML format.
func (*Reg) Find ¶
Find look for an object in the current registry. Return an empty object and error, when the object not found.
func (*Reg) FindObjectByIDAndVer ¶
FindObjectByIDAndVer find an object in the registry by ID and version. Return an empty object and error, when the object not found.
func (*Reg) FindObjectsByID ¶
FindObjectsByID find objects in the registry by ID. Multiple objects with same ID and different versions could be returned. Return an error, when no objects found.
func (*Reg) FindResourceByOIR ¶
FindResourceByOIR find specific resource in registry by OIR string (i.e. "3303/0/5700" - object/instance/resource). Use latest object version. Return a single matching resource of specific object. Return an empty resource and error, when resource or object not found.
func (*Reg) FindResourceByObjIDObjVerResID ¶
func (r *Reg) FindResourceByObjIDObjVerResID(objID int32, objVer string, resID int32) (Resource, error)
FindResourceByObjIDObjVerResID find specific resource in registry by object ID, object version and resource ID. Return a single matching resource of specific object. Return an empty resource and error, when resource or object not found.
func (*Reg) FindResourcesByID ¶
FindResourcesByID find resources in registry by ID. Return matching resources from all objects of all versions. Return an error, when resource not found.
func (*Reg) FindResourcesByObjResIDs ¶
FindResourcesByObjResIDs find resources in registry by object ID and resource ID. Return matching resources from all versions of specific object. Return an error, when resource or object not found.
func (*Reg) GetObjects ¶
GetObjects return all objects from registry.
func (*Reg) GetRegistry ¶
GetRegistry returns internal registry structure. Temporary solution, will be removed in next releases.
func (*Reg) Import ¶
Import load objects and resources from file. Overwrite current registry objects and resources.
func (*Reg) ImportFromAPI ¶
ImportFromAPI initialize the registry from official OMA API. Overwrite current registry objects and resources. Fill empty object and LwM2M versions with default values "1.0".
func (*Reg) Sanitize ¶
Sanitize removes unwanted strings from objects and resources description fields using sanitizer strings from registry configuration. Also removes leading and trailing spaces. Description fields in objects and resources do not follow any single format or convention in regard to line breaks, lists presentation, special characters escaping etc. thus in some cases cannot be used directly in external applications (i.e. properly displayed in browser).
type Registry ¶
type Registry interface { Import(filename string) error ImportFromAPI() ([]Object, error) Export(filename string) error Compare(reg *Reg) []ObjectComparison Find(o Object) (Object, error) FindObjectsByID(id int32) ([]Object, error) FindObjectByIDAndVer(id int32, ver string) (Object, error) FindResourcesByID(id int32) ([]Resource, error) FindResourcesByObjResIDs(objID, resID int32) ([]Resource, error) FindResourceByObjIDObjVerResID(objID int32, objVer string, resID int32) (Resource, error) FindResourceByOIR(oir string) (Resource, error) GetObjects() []Object Sanitize(sanitizer []string) GetRegistry() *Reg }
Registry an interface defining public library functions.
func New ¶
func New(cfg Configuration) (Registry, error)
New create a new registry, using provided or default configuration.
type Resource ¶
type Resource struct { ID int32 `json:"ID" xml:"ID,attr"` Name string `json:"Name" xml:"Name"` Operations OperationType `json:"Operations" xml:"Operations"` MultipleInstances InstanceType `json:"MultipleInstances" xml:"MultipleInstances"` Mandatory MandatoryType `json:"Mandatory" xml:"Mandatory"` Type ResourceType `json:"Type" xml:"Type"` RangeEnumeration string `json:"RangeEnumeration,omitempty" xml:"RangeEnumeration"` Units string `json:"Units,omitempty" xml:"Units"` Description string `json:"Description,omitempty" xml:"Description"` }
Resource structure represents OMA Resource entity.
type ResourceType ¶
type ResourceType string
ResourceType represents the type of data.
const ( ResourceTypeString ResourceType = "String" ResourceTypeInteger ResourceType = "Integer" ResourceTypeUnsignedInteger ResourceType = "Unsigned Integer" ResourceTypeFloat ResourceType = "Float" ResourceTypeBoolean ResourceType = "Boolean" ResourceTypeOpaque ResourceType = "Opaque" ResourceTypeTime ResourceType = "Time" ResourceTypeObjLink ResourceType = "Objlnk" ResourceTypeCoreLink ResourceType = "Corelnk" ResourceTypeNone ResourceType = "none" )
ResourceType constants according to OMA-TS-LightweightM2M_Core-V1_2-20201110-A Appendix C. Data types (Normative).