# Model Query

Use this API to request models from the cloud.

Topic format: {topics_messages_out}/type=modelQuery

Payload:

{
    "query": "{DSL query}"
}

The payload contains just one field - query - and it should contain a DSL query that you want to invoke.

# Examples

# Get the module's models

The following request will result in all models of the module (typically "abb.ability.device" and "abb.ability.configuration") to be delivered to the module:

Topic: {topics_messages_out}/type=modelQuery

Payload:

{
    "query": "models().hasObjectId('{MODULE_OBJECT_ID}')"
}

The {MODULE_OBJECT_ID} is a placeholder. Replace it with the module's objectId (you can find it in the object_id environment variable).

# Get the module and its children

For the following request:

Topic: {topics_messages_out}/type=modelQuery

Payload:

{
    "query": "models('abb.ability.device').hasObjectId('{MODULE_OBJECT_ID}').union(selectModels().emit().repeat(outReference('devices').toModel()),selectModels().otherModels('abb.ability.configuration'))"
}

models of the module itself, and all its children (assuming that they are connected via the "devices" reference) will be delivered on {topics_model_in}.

# Legacy "model" message

Edge Module API also supports type=model message, which is limited compared to type=modelQuery.

WARNING

type=model message is considered legacy, and we advice against using it in your project. Instead, use the type=modelQuery as was presented above in this article.

Topic: {topics_messages_out}/type=model&objectId={objectId}&model={model definition}

if a module is requesting its own model, objectId may be omitted - {topics_messages_out}/type=model&model={model definition}

Payload is optional, if not provided - only the object model of the objectId and a model specified in the topic will be returned. Payload's format:

{
    "references": ["list of outgoing reference types to follow and collect models for"],
    "contained": true/false,
    "recursive": true/false,
    "related": ["list of model identifiers to collect as a part of this request"]
}

If references are specified, include specified {model} of each object targeted by outgoing references of these types (either in same message or split into multiple, depending on the size. If contained is true, include specified {model} of each object targeted by an outgoing reference with isContained=true (either in same message or split into multiple, depending on the size. References will be ignored in this case. If recursive is true, traverse the references recursively, i.e. for each model targeted by an outgoing reference, repeat the above steps. If related is specified, include requested models for this objectId (if contained=true, include models for those objectIds as well). Requested models are delivered via {topics_model_in}/{model}/{objectId (if different from the module object id)}.

Last updated: 10/20/2021, 9:08:02 AM
Feedback