Context Masks

A context mask is a string that corresponds to one or more contexts. A mask is similar to a context path, but its segments (parts, separated by dots) may include wildcard ("*") characters instead of context names. They are quite similar to the filename masks (like "*.txt") which are often used in computing. Context masks may be resolved to a number of context paths that match to a context mask.

Here's an example of a context mask that should be read as "all devices of all users": users.*.devices.*

Groups provide special context mask syntax to access all group members. See Group Member Context Masks for details.

Resolving Masks

The context mask can be resolved to a list of context paths. For example, the mask users.* may be resolved to the following list of context paths:

users.admin

users.user1

users.user2

etc.

And the mask users.*.devices.* may be resolved to

users.admin.devices.thermometer1

users.admin.devices.thermometer2

users.admin.devices.thermometer3

users.user1.devices.gateway1

users.user1.devices.gateway2

users.user2.devices.plc

The mask resolution process always involves permission checking. For example, the users.* mask is resolved to the list of user contexts accessible with the permissions of the user that requested the operation. It will be resolved to the list of all users in the system only if the user originating the operation has permissions to access all user accounts.

Matching to Masks

A context path may match to a context mask. Also, context mask may extend a context path, or context path may extend a context mask.

To match a context mask, context path must contain the same number of segments (parts between ".") as mask. Also, if any context mask segment is not a wildcard ("*") segment, it should be equal to the correspondent segment of context path.

If a path extends a mask, the leading segments of the path must match the mask, but the path may contain any number of additional segments.

Similarly, if a mask extends a path, its beginning should match the path, but it will contain additional mask segments.

Mask Matching Examples

The users.admin path matches the users.* mask.

The users.admin path doesn't match the external_device_servers.* mask.

The users.admin.devices.c1 path extends the users.* mask. It is longer than the mask, so it matches the beginning and adds additional segments.

The users.admin.devices.c1 path doesn't extend the users.*.alerts mask. The mask doesn't match three leading segments of the path.

The users.*.devices.* mask extends the users.admin path because it adds additional information to it.

The users.*.devices.* mask doesn't extend the reports.impacts_report path because it doesn't match.

The devices.* mask doesn't match the users.user1.devices path. The mask contains non-existing leading segment devices. For example, the users.*.devices.* mask can be used to match this path.

Was this page helpful?