Static Model API

The Lua Static Model makes the definition of all object classes and properties available using the Lua API. It allows to come up with custom generic operations, e.g., customized CRUD (create-read-update-delete) or automatic tests and migrations after a version upgrade. It enables Lua API users to have more autonomy and increases the possibilities for customization and automation within the Lua scripting environment.

Using the Lua Static Model, the following can be achieved:

  • Retrieve details about classes and properties

  • Determine which properties are available for each class

  • Determine which performance counters are available for each class

  • Various types of hierarchical relationships between objects and properties

The static model provides a read-only view of the underlying system model data.

Class

Class is a definition of an object; it is exposed as a userdata datatype in the Lua API. Its fields are described below. In order to obtain a class userdata, can index syslib.model.classes by a numeric code (see a full list of classes).

Fields

Name Type Description

code

integer

Class code

tag

string

Class name

version_major

integer

A version major component of the class definition

version_minor

integer

A version minor component of the class definition

sortorder

integer

Recommended position of objects of this class relative to sibling objects (in UI)

properties

userdata

A list of object properties

models

userdata

An object of this class can only belong to one of the models in this list.

tree_models

userdata

All models a class might appear in, due to parent-child relationships

attributes

userdata

class attributes

performance

userdata

A list of object performance counters

parents

userdata

Objects of these classes can be parents of an object of this class in a model hierarchy.

children

userdata

Objects of these classes can be children of an object of this class in a model hierarchy.

Property

Property is a definition of an object property; it is exposed a userdata datatype in the Lua API. Its fields are described below. In order to obtain a property userdata one can index syslib.model.properties by a numeric code (see a full list of properties).

Fields

Name Type Description

code

integer

Property code

tag

string

Property name

type

integer

Property type code from syslib.model.codes.PropertyTypes.

iscompound

Boolean

true if the property is a compound property.

flaggroup

integer

Code of corresponding flag group is returned if the PropertyTypes is equal to FLAGGROUP (otherwise nil is returned). The flag group can be obtained by indexing syslib.model.flags by the code value.

codegroup

integer

Code of corresponding flag group is returned if the PropertyTypes is equal to CODINGGROUP (otherwise nil is returned). The coding group can be obtained by indexing syslib.model.codes by the code value.

table

boolean

returns true if PropertyTypes is TABLESCHEMABOUND or TABLESCHEMALESS (otherwise nil is returned).

tableschema

string

returns the table schema if if PropertyTypes is TABLESCHEMABOUND (otherwise nil is returned).

default

variant

default data if specified, nil otherwise. NOTE: This is the specified default, not default value which is implicitly created if it’s not specified.

datatype

integer

returns a syslib.model.codes.VariantTypes. Warning: it can be ORed with syslib.model.flags.VariantTypeFlags.ARRAY

max

variant

returns the maximum value if specified, nil otherwise.

min

variant

returns the minimum value if specified, nil otherwise.

properties

userdata

returns properties userdata

attributes

userdata

returns attributes userdata

capabilities

userdata

returns capabilities userdata

Performance counter

Performance counter is a definition of an object performance counter; it is exposed a userdata datatype in the Lua API. Its fields are described below. In order to obtain a performance counter userdata one can index syslib.model.counters by a numeric code (see a full list of performance counters).

Fields

Name Type Description

code

integer

Performance counter code

tag

string

Performance counter name

meaning

string

Description of the performance counter

engunit_name

string

Measurement unit name

engunit_meaning

string

Description of the measurement unit

performancegroup_name

string

Performance counter belongs to this group, e.g., "Hardware", "Lua", "Objects", etc.

timebase_name

string

Timebase name, e.g., "SECOND"

show_timebase

boolean

true if it is a measure per time

Performance counter tag can be used in order to "create a performance counter generic item". E.g., CPU in the value /System/Core.Performance.CPU of a Performance Assignment property of a generic item.

Indexing and Iteration

The following table gives reference information on the indexing for entities in the Lua Static Model, the expected return values and what can be iterated using the Lua pairs function.

Entity Indexed by Return Value Pairs Iteration

class

field_string

depends on a field

-

property

field_string

depends on a field

-

class

property_userdata, class_userdata

property_userdata or class_userdata

-

property

property_userdata

property_userdata

-

property.propertiesclass.properties

code, property_name_string

property_userdata

<code,property_userdata>

class.parents class.children

code, class_userdata

class_userdata

<code,class_userdata>

class.models

code

model_name_string

<code,name_string>

class.performance

code

performance_counter_userdata

<code,performance_counter_userdata>

property.attributes class.attributes

number

boolean

syslib.model.properties

name_stringcode

codeproperty_userdata

<code,property_userdata>

syslib.model.classes

name_stringcode

codeclass_userdata

<code,class_userdata>

syslib.model.counters

name_stringcode

codeperformance_counter_userdata

<code,performance_counter_userdata>

syslib.model.codes

name_string

key-value lua table, where key is a coding name and value is it’s value

-

syslib.model.flags

name_string

key-value lua table, where key is a flag and value is it’s value (number)

-