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 |
|
Request Header¶
Name |
Required/Optional |
Data Type |
Description |
---|---|---|---|
response-format-type |
Optional |
String |
Specified the structure type of the response parameters.
|
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:
|
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:
|
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 |
relationFilter |
Optional |
RelationFilter Struct |
Query based on the relationship between models. For more information, see RelationFilter Struct. |
RelationFilter Struct ¶
Name |
Required/Optional |
Data Type |
Description |
---|---|---|---|
relatedModelId |
Required |
String |
The model ID. |
relationType |
Required |
String |
The type of relationship with the model of the
|
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
Array of ThingModel Struct or Items 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 |
measurepoints |
Map |
The key is the measurement point ID, of String type, and the value is of the |
services |
Map |
The key is the service ID, of String type, and the value is of the |
events |
Map |
The key is the event ID, of String type, and the value is of the |
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 |
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, |
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 |
Note: EnOS Edge does not support this parameter. |
stdElementId |
String |
The URN of the element if If 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 |
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 |
Note: EnOS Edge does not support this parameter. |
stdElementId |
String |
The URN of the element if If Note: EnOS Edge does not support this parameter. |
hasQuality |
Boolean |
|
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 |
Note: EnOS Edge does not support this parameter. |
stdElementId |
String |
The URN of the element if If 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.
|
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 |
Note: EnOS Edge does not support this parameter. |
stdElementId |
String |
The URN of the element if If 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 |
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 |
Note: EnOS Edge does not support this parameter. |
stdElementId |
String |
The URN of the element if If 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
Error Codes¶
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);
}
}