Search Thing Model


Search models based on expressions or on the relationship between models.

Request Format

POST https://{apigw-address}/model-service/v2.1/thing-models?action=search

Request Parameters (URI)

Name Location (Path/Query) Required/Optional Data Type Description
orgId Query Required String The organization ID which the model belongs to. How to get orgId>>
scope Query Optional Integer
  • 0: Only search from the organization specified by the orgId.
  • 1 (default): Search from the organization specified by the orgId as well as the organizations with public models.
  • 2: Only search from public models.

Request Header


Name Required/Optional Data Type Description
response-format-type Optional String

Specified the structure type of the response parameters.

  • Only when the value is response-format-type, the response parameters will be returned as an array of ThingModel structure. For the return sample, see ThingModel Struct.
  • If a value other than response-format-type is provided or no value is provided, the response parameters will be returned as an array of Items structure. For the return sample, see Items Struct.

Request Parameters (Body)


Note

Use either expression or relationFilter to search, but not both together.

Name Required/Optional Data Type Description
expression Optional String

The query expression, which supports sql-like query. The fields that are supported for query include: modelId, tags, attribute_tags, measurepoint_tags, service_tags, and event_tags. Supports fuzzy query and logical operators “and” and “or”. How to use expression>>

  • modelId: supports arithmetic operator “in”.
  • tags, attribute_tags, measurepoint_tags, service_tags, and event_tags: supports arithmetic operator “=”, “exists”, “not exists”, and “like”. Note: EnOS Edge does not support tag queries.
projection Optional Projection Struct

Enables you to crop the data result set returned in the request if needed. Only the specified fields will be returned in the data result set if this parameter is used. Otherwise all fields are returned. The supported fields are: modelId, modelIdPath, orgId, name, desc, tags, attributes, measurepoints, services, and events. For more details, see How does projection crop the result set.

Note: EnOS Edge does not support this parameter.
pagination Optional Pagination Request Struct Lists the paging requirements in a request. When not specified, 10 records are displayed per page by default. Note that if the pageSize number is big, the API response time will increase significantly for large models. For optimal performance, it is recommended to have not more than 25 records per page. sorters is not supported to sort the response. For more details, see Pagination Request Struct.
relationFilter Optional RelationFilter Struct Query based on the relationship between models. For more information, see RelationFilter Struct.

Response Parameters

Name Data Type Description
data Array of ThingModel Struct or Items Struct
  • ThingModel Struct: a list of the thing models returned. For details of a Thingmodel Struct, see ThingModel Struct.
  • Items Struct: an overall structure that contains ThingModel Struct.

ThingModel Struct

Name Data Type Description
modelId String The model ID.
modelIdPath String The model ID path.
orgId String The OU ID that created this model. For example, if a model in OU B is created by sharing from OU A, when you query the information of that model in OU B, the returned ID will be from OU A.
name StringI18n The model name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
desc String The model description.
category String The model category.
tags Map User-defined tags. (The Key and Value are of String type.)
attributes Map The key is the static attribute ID, of String type, and the value is of the ThingAttribute Struct. For more information, see ThingAttribute Struct.
measurepoints Map The key is the measurement point ID, of String type, and the value is of the ThingMeasurepoint Struct. For more information, see ThingMeasurepoint Struct.
services Map The key is the service ID, of String type, and the value is of the ThingService Struct. For more information, see ThingService Struct.
events Map The key is the event ID, of String type, and the value is of the ThingEvent Struct. For more information, see ThingEvent Struct.

ThingAttribute Struct

Name Data Type Description
identifier String The attribute ID.
dataType String The data type. E.g.: ARRAY, BOOL, DATE, ENUM, INT, FLOAT, DOUBLE, STRUCT, STRING, TIMESTAMP, FILE
dataDefinition String The data definition of the dataType in this structure, which is a JSON string. For example, when the dataType is “STRING”, it defines the string length; when the dataType is “ENUM”, it defines the value and description. How to use dataDefinition>>
isRequired Boolean If true, the value of this attribute must be set when the asset is instantiated; otherwise the asset will return a validation failure error when it is created.
defaultValue As defined in the thing model The default value of the attribute. If the attribute has no default value, defaultValue would be null . Note: EnOS Edge does not support this parameter.
name StringI18n The attribute name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
desc String The attribute description.
i18nDesc StringI18n The attribute description, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
tags Map User-defined tags. (The Key and Value are of String type.)
isStdElement Boolean
  • true: This is an industry standard element.
  • false: This is not an industry standard element.

Note: EnOS Edge does not support this parameter.

stdElementId String

The URN of the element if isStdElement is true . The format is urn:enos:modelelement:std: <id> : <version> . id is the element ID. <version> is the version of the element.

If isStdElement is false , then stdElementId is null.

Note: EnOS Edge does not support this parameter.

unit Unit Struct For more information, see Unit Struct.

ThingMeasurepoint Struct

Name Data Type Description
identifier String The ID of the measurement point.
dataType String Data type. E.g.: ARRAY, DATE, ENUM, INT, FLOAT, DOUBLE, STRUCT, STRING, TIMESTAMP, FILE
dataDefinition String The data definition of the dataType in this structure, which is a JSON string. For example, when the dataType is “STRING”, it defines the string length; when the dataType is “ENUM”, it defines the value and description. How to use dataDefinition>>
name StringI18n The measurement point name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
desc String The measurement point description.
i18nDesc StringI18n The measurement point description, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
tags Map User-defined tags. (The Key and Value are of String type.)
isStdElement Boolean
  • true: This is an industry standard element.
  • false: This is not an industry standard element.

Note: EnOS Edge does not support this parameter.

stdElementId String

The URN of the element if isStdElement is true . The format is urn:enos:modelelement:std: <id> : <version> . id is the element ID. <version> is the version of the element.

If isStdElement is false , then stdElementId is null.

Note: EnOS Edge does not support this parameter.

hasQuality Boolean
  • true: Has the quality indicator.
  • false: Does not have the quality indicator.
signalType String The signal/point type. E.g.: Generic, AI, PI, DI
unit Unit Struct For more information, see Unit Struct.

ThingService Struct

Name Data Type Description
identifier String The service ID.
name StringI18n The service name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
desc String The service description.
i18nDesc StringI18n The service description, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
tags Map User-defined tags. (The Key and Value are of String type.)
isStdElement Boolean
  • true: This is an industry standard element.
  • false: This is not an industry standard element.

Note: EnOS Edge does not support this parameter.

stdElementId String

The URN of the element if isStdElement is true . The format is urn:enos:modelelement:std: <id> : <version> . id is the element ID. <version> is the version of the element.

If isStdElement is false , then stdElementId is null.

Note: EnOS Edge does not support this parameter.

inputData ThingDatapoint Struct The service’s input parameters list. For more information, see ThingDatapoint Struct.
outputData ThingDatapoint Struct The service’s output parameters list. For more information, see ThingDatapoint Struct.
callType String

The calling type. This parameter will be deprecated.

  • ASYNC: Asynchronous.
  • SYNC: Synchronous.

ThingEvent Struct

Name Data Type Description
identifier String The event ID.
name StringI18n The event name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
desc String The event description.
i18nDesc StringI18n The event description, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
tags Map User-defined tags. (The Key and Value are of String type.)
isStdElement Boolean
  • true: This is an industry standard element.
  • false: This is not an industry standard element.

Note: EnOS Edge does not support this parameter.

stdElementId String

The URN of the element if isStdElement is true . The format is urn:enos:modelelement:std: <id> : <version> . id is the element ID. <version> is the version of the element.

If isStdElement is false , then stdElementId is null.

Note: EnOS Edge does not support this parameter.

outputData ThingDatapoint Struct The event’s output parameters list. For more information, see ThingDatapoint Struct.
eventType String Event type. E.g.: INFO, WARN, ERROR

ThingDatapoint Struct

Name Data Type Description
identifier String The data point ID.
dataType String Data type. E.g.: ARRAY, DATE, ENUM, INT, FLOAT, DOUBLE, STRUCT, STRING, TIMESTAMP, FILE
dataDefinition String The data definition of the dataType in this structure, which is a JSON string. For example, when the dataType is “STRING”, it defines the string length; when the dataType is “ENUM”, it defines the value and description. How to use dataDefinition>>
name StringI18n The data point name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
desc String The data point description.
i18nDesc StringI18n The data point description, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct.
tags Map User-defined tags. (The Key and Value are of String type.)
isStdElement Boolean
  • true: This is an industry standard element.
  • false: This is not an industry standard element.

Note: EnOS Edge does not support this parameter.

stdElementId String

The URN of the element if isStdElement is true . The format is urn:enos:modelelement:std: <id> : <version> . id is the element ID. <version> is the version of the element.

If isStdElement is false , then stdElementId is null.

Note: EnOS Edge does not support this parameter.

unit Unit Struct For more information, see Unit Struct.

Unit Struct

Name Data Type Description
unitId String The unit ID.
multiplier String The multiplier of the unit. For more information, see Multiplier.

Multiplier

The multiplier of the unit can have the following values:

YOTTA ,//Y     10^24
ZETTA ,//Z     10^21
EXA   ,//E     10^18
PETA  ,//P     10^15
TERA  ,//T     10^12
GIGA  ,//G     10^9
MEGA  ,//M     10^6
KILO  ,//k     10^3
HECTO ,//h     10^2
DECA  ,//da    10^1
ONE   ,//      10^0
DECI  ,//d     10^-1
CENTI ,//c     10^-2
MILLI ,//m     10^-3
MICRO ,//μ     10^-6
NANO  ,//n     10^-9
PICO  ,//p     10^-12
FEMTO ,//f     10^-15
ATTO  ,//a     10^-18
ZEPTO ,//z     10^-21
YOCTO ,//y     10^-24

Samples

Request Sample

Search By Expression

url: https://{apigw-address}/model-service/v2.1/thing-models?action=search&orgId=yourOrgId&scope=1
method: POST
requestBody:
{
  "expression": "modelId in ('planet', 'noiseSensor')", // tags example: "tags.abc like '123'"
  "pagination": {
    "pageNo": 1,
    "pageSize": 10
    }
}

Search By Model Relationship

url: https://{apigw-address}/model-service/v2.1/thing-models?action=search&orgId=yourOrgId&scope=1
method: POST
requestBody:
{
    "relationFilter": {
        "relatedModelId": "modelId",
        "relationType": "childOfModel"
    },
    "pagination": {
        "pageNo": 1,
        "pageSize": 10
    }
}

Return Sample

ThingModel Struct


{
    "code":0,
    "msg":"OK",
    "requestId":"c6594307-bc30-4380-9869-b8a88b9494de",
    "data":[
        {
            "modelId":"planet",
            "modelIdPath":"/planet",
            "orgId":"yourOrgId",
            "name":{
                "defaultValue":"planet",
                "i18nValue":{
                    "en_US":"planet"
                }
            },
            "desc":"Planet",
            "category":"Planets",
            "tags":{

            },
            "attributes":{
                "starsystem":{
                    "identifier":"starsystem",
                    "name":{
                        "defaultValue":"star system",
                        "i18nValue":{
                            "en_US":"star system"
                        }
                    },
                    "desc":"Star system 1",
                    "i18nDesc":{
                        "defaultValue":"Star system 1",
                        "i18nValue":{
                            "en_US":"Star system 1",
                            "zh_CN":"星系 1"
                      }
                    },
                    "tags":{

                    },
                    "stdElementId":"urn:user:modelelement:std:atom-property-int:1.0",
                    "isStdElement":true,
                    "dataType":"STRING",
                    "unit":null,
                    "isRequired":false,
                    "defaultValue":null
                }
            },
            "measurepoints":{
                "temperature":{
                    "identifier":"temperature",
                    "name":{
                        "defaultValue":"temperature",
                        "i18nValue":{
                            "en_US":"temperature"
                        }
                    },
                    "desc":"Temperature",
                    "i18nDesc":{
                        "defaultValue":"Temperature",
                        "i18nValue":{
                            "en_US":"Temperature",
                            "zh_CN":"温度"
                      }
                    },
                    "tags":{

                    },
                    "stdElementId":"urn:user:modelelement:std:atom-property-int:1.0",
                    "isStdElement":true,
                    "dataType":"FLOAT",
                    "hasQuality":false,
                    "signalType":"Generic",
                    "unit":{
                        "unitId":"°C",
                        "multiplier":"ONE"
                    }
                }
            },
            "services":{
                "speedup":{
                    "identifier":"speedup",
                    "name":{
                        "defaultValue":"speedup",
                        "i18nValue":{
                            "en_US":"speedup"
                        }
                    },
                    "desc":"Speedup",
                    "i18nDesc":{
                        "defaultValue":"Speedup",
                        "i18nValue":{
                            "en_US":"Speedup",
                            "zh_CN":"加速"
                      }
                    },
                    "tags":{

                    },
                    "outputData":[
                        {
                            "identifier":"delta",
                            "name":{
                                "defaultValue":"delta",
                                "i18nValue":{
                                    "en_US":"delta"
                                }
                            },
                            "desc":"Delta",
                            "i18nDesc":{
                                "defaultValue":"Delta",
                                "i18nValue":{
                                    "en_US":"Delta",
                                    "zh_CN":"Delta 描述"
                                }
                            },
                            "tags":{

                            },
                            "dataType":"INT",
                            "unit":null
                        }
                    ],
                    "inputData":[
                        {
                            "identifier":"delta",
                            "name":{
                                "defaultValue":"delta",
                                "i18nValue":{
                                    "en_US":"delta"
                                }
                            },
                            "desc":"Delta",
                            "i18nDesc":{
                                "defaultValue":"Delta",
                                "i18nValue":{
                                    "en_US":"Delta",
                                    "zh_CN":"Delta 描述"
                                }
                            },
                            "tags":{

                            },
                            "dataType":"INT",
                            "unit":{
                                "unitId":"rpm",
                                "multiplier":"ONE"
                            },
                            "isRequired":false,
                            "defaultValue":3
                        }
                    ],
                    "callType":"ASYNC"
                }
            },
            "events":{
                "alert":{
                    "identifier":"alert",
                    "name":{
                        "defaultValue":"alert",
                        "i18nValue":{
                            "en_US":"alert"
                        }
                    },
                    "desc":"Alert",
                    "i18nDesc":{
                        "defaultValue":"Alert",
                        "i18nValue":{
                            "en_US":"Alert",
                            "zh_CN":"告警"
                      }
                    },
                    "tags":{

                    },
                    "outputData":[
                        {
                            "identifier":"event1",
                            "name":{
                                "defaultValue":"event1",
                                "i18nValue":{
                                    "en_US":"event1"
                                }
                            },
                            "desc":"Event 1",
                            "i18nDesc":{
                                "defaultValue":"Event 1",
                                "i18nValue":{
                                    "en_US":"Event 1",
                                    "zh_CN":"事件 1"
                                }
                            },
                            "tags":{

                            },
                            "dataType":"INT",
                            "unit":null
                        }
                    ],
                    "eventType":"ERROR"
                }
            }
        },
        {
            "modelId":"noiseSensor",
            "modelIdPath":"/noiseSensor",
            "orgId":"yourOrgId",
            "name":{
                "defaultValue":"Noise Sensor",
                "i18nValue":{
                    "en_US":"Noise Sensor"
                }
            },
            "desc":"Noise Sensor",
            "category":"Sensors",
            "tags":{
                "group":"1"
            },
            "attributes":{

            },
            "measurepoints":{

            },
            "services":{

            },
            "events":{

            }
        }
    ],
    "pagination":{
        "pageNo":1,
        "pageSize":10,
        "totalSize":2
    }
}

Items Struct


{
    "code": 0,
    "msg": "OK",
    "requestId": "f1364494-fda1-4d28-b1a3-bfbe88c743d7",
    "data": {
        "items": [
            {
            "modelId":"planet",
            "modelIdPath":"/planet",
            "orgId":"yourOrgId",
            "name":{
                "defaultValue":"planet",
                "i18nValue":{
                    "en_US":"planet"
                }
            },
            "desc":"Planet",
            "category":"Planets",
            "tags":{

            },
            "attributes":{
                "starsystem":{
                    "identifier":"starsystem",
                    "name":{
                        "defaultValue":"star system",
                        "i18nValue":{
                            "en_US":"star system"
                        }
                    },
                    "desc":"Star system 1",
                    "i18nDesc":{
                        "defaultValue":"Star system 1",
                        "i18nValue":{
                            "en_US":"Star system 1",
                            "zh_CN":"星系 1"
                      }
                    },
                    "tags":{

                    },
                    "stdElementId":"urn:user:modelelement:std:atom-property-int:1.0",
                    "isStdElement":true,
                    "dataType":"STRING",
                    "unit":null,
                    "isRequired":false,
                    "defaultValue":null
                }
            },
            "measurepoints":{
                "temperature":{
                    "identifier":"temperature",
                    "name":{
                        "defaultValue":"temperature",
                        "i18nValue":{
                            "en_US":"temperature"
                        }
                    },
                    "desc":"Temperature",
                    "i18nDesc":{
                        "defaultValue":"Temperature",
                        "i18nValue":{
                            "en_US":"Temperature",
                            "zh_CN":"温度"
                      }
                    },
                    "tags":{

                    },
                    "stdElementId":"urn:user:modelelement:std:atom-property-int:1.0",
                    "isStdElement":true,
                    "dataType":"FLOAT",
                    "hasQuality":false,
                    "signalType":"Generic",
                    "unit":{
                        "unitId":"°C",
                        "multiplier":"ONE"
                    }
                }
            },
            "services":{
                "speedup":{
                    "identifier":"speedup",
                    "name":{
                        "defaultValue":"speedup",
                        "i18nValue":{
                            "en_US":"speedup"
                        }
                    },
                    "desc":"Speedup",
                    "i18nDesc":{
                        "defaultValue":"Speedup",
                        "i18nValue":{
                            "en_US":"Speedup",
                            "zh_CN":"加速"
                      }
                    },
                    "tags":{

                    },
                    "outputData":[
                        {
                            "identifier":"delta",
                            "name":{
                                "defaultValue":"delta",
                                "i18nValue":{
                                    "en_US":"delta"
                                }
                            },
                            "desc":"Delta",
                            "i18nDesc":{
                                "defaultValue":"Delta",
                                "i18nValue":{
                                    "en_US":"Delta",
                                    "zh_CN":"Delta 描述"
                                }
                            },
                            "tags":{

                            },
                            "dataType":"INT",
                            "unit":null
                        }
                    ],
                    "inputData":[
                        {
                            "identifier":"delta",
                            "name":{
                                "defaultValue":"delta",
                                "i18nValue":{
                                    "en_US":"delta"
                                }
                            },
                            "desc":"Delta",
                            "i18nDesc":{
                                "defaultValue":"Delta",
                                "i18nValue":{
                                    "en_US":"Delta",
                                    "zh_CN":"Delta 描述"
                                }
                            },
                            "tags":{

                            },
                            "dataType":"INT",
                            "unit":{
                                "unitId":"rpm",
                                "multiplier":"ONE"
                            },
                            "isRequired":false,
                            "defaultValue":3
                        }
                    ],
                    "callType":"ASYNC"
                }
            },
            "events":{
                "alert":{
                    "identifier":"alert",
                    "name":{
                        "defaultValue":"alert",
                        "i18nValue":{
                            "en_US":"alert"
                        }
                    },
                    "desc":"Alert",
                    "i18nDesc":{
                        "defaultValue":"Alert",
                        "i18nValue":{
                            "en_US":"Alert",
                            "zh_CN":"告警"
                      }
                    },
                    "tags":{

                    },
                    "outputData":[
                        {
                            "identifier":"event1",
                            "name":{
                                "defaultValue":"event1",
                                "i18nValue":{
                                    "en_US":"event1"
                                }
                            },
                            "desc":"Event 1",
                            "i18nDesc":{
                                "defaultValue":"Event 1",
                                "i18nValue":{
                                    "en_US":"Event 1",
                                    "zh_CN":"事件 1"
                                }
                            },
                            "tags":{

                            },
                            "dataType":"INT",
                            "unit":null
                        }
                    ],
                    "eventType":"ERROR"
                }
            }
        },
        {
            "modelId":"noiseSensor",
            "modelIdPath":"/noiseSensor",
            "orgId":"yourOrgId",
            "name":{
                "defaultValue":"Noise Sensor",
                "i18nValue":{
                    "en_US":"Noise Sensor"
                }
            },
            "desc":"Noise Sensor",
            "category":"Sensors",
            "tags":{
                "group":"1"
            },
            "attributes":{

            },
            "measurepoints":{

            },
            "services":{

            },
            "events":{

            }
        }
        ],
        "sortedBy": null,
        "pageNo": 1,
        "pageSize": 10,
        "totalRecord": 2
    }
}

Java SDK Sample

Search By Expression

public class SearchThingModel {
    private static String accessKey = "yourAppAccessKey";
    private static String secretKey = "yourAppSecretKey";
    private static String orgId = "yourOrgId";
    private static String url = "https://{apigw-address}";
    public static void main(String[] args) {
        SearchThingModelRequest request = new SearchThingModelRequest();
        request.setOrgId(orgId);
        request.setExpression("modelId in ( \"planet\" )");
        Projection projection = new Projection();
        projection.add("modelId");
        projection.add("name");
        request.setProjection(projection);
        SearchThingModelResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
                .url(url)
                .getResponse(request, request.getResponseClass());
        System.out.println(response.getData());
    }
}

Search By Model Relationship

public class SearchModel {
    private static String accessKey = "yourAppAccessKey";
    private static String secretKey = "yourAppSecretKey";
    private static String orgId = "yourOrgId";
    private static String url = "https://{apigw-address}";
    public static void main(String[] args) {

        SearchThingModelRequest request = new SearchThingModelRequest();
        request.setOrgId(orgId);
        RelationFilter relationFilter = new RelationFilter();
        relationFilter.setRelatedModelId("yourModelId");
        relationFilter.setRelationType(RelationFilter.RELATION_TYPE_CHILD_OF_MODEL);
        request.setRelationFilter(relationFilter);
        Projection projection = new Projection();
        projection.add("modelId");
        projection.add("name");
        request.setProjection(projection);
        SearchThingModelResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
                .url(url)
                .getResponse(request, SearchThingModelResponse.class);
        System.out.println(response);
    }
}