ThingDatapoint Struct
Unit Struct
Multiplier
Error Codes
Samples
Other References
- Documentation
- Update Thing Model
-
Update Thing Model
Update a model. This API is only available if 2.3 Cumulative Update 2 has been applied to your environment. For the full change list of 2.3 Cumulative Update 2, see Cumulative Update 2.
Operation Permissions
Required Authorization |
Required Operation Permission |
Model Management |
Full Access |
Request Parameters (URI)
Name |
Location (Path/Query) |
Mandatory/Optional |
Data Type |
Description |
orgId |
Query |
Mandatory |
String |
The organization ID which the model belongs to. How to get orgId>> |
isPatchUpdate |
Query |
Optional |
Boolean |
true (default): Only the fields specified in the parameters are updated. The values of those fields not specified will be retained.
false : The fields specified in the parameters are updated. Those fields not specified will have their existing values (if any) deleted.
|
Request Parameters (Body)
Name |
Mandatory/Optional |
Data Type |
Description |
modelId |
Mandatory |
String |
The model ID. |
name |
Mandatory if isPatchUpdate is true |
StringI18n |
The model name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
desc |
Optional |
String |
The model description. |
category |
Optional |
String |
The model category. |
tags |
Optional |
Map (Key and Value are of String type) |
User-defined tags. |
featuresToDelete |
Optional |
String Array |
The features to delete from the model, identified using the feature identifier. Applicable only when isPatchUpdate is true . If any of the features in the array are listed in attributes , measurepoints , events , or services , they will not be deleted. |
attributes |
Optional |
Map (Key is of String type, and Value is of the ThingAttribute Struct) |
The attributes of the model. The key is the static attribute ID. For more information, see ThingAttribute Struct.
Note: Attributes that already exist in the parent or child model cannot be added.
|
measurepoints |
Optional |
Map (Key is of String type, and Value is of the ThingMeasurepoint Struct) |
The measurement points of the model. The key is the measurement point ID, of String type. For more information, see ThingMeasurepoint Struct.
Note: Measurement points that already exist in the parent or child model cannot be added.
|
services |
Optional |
Map (Key is of String type, and Value is of the ThingService Struct) |
The services of the model. The key is the service ID. For more information, see ThingService Struct.
Note: Services that already exist in the parent or child model cannot be added.
|
events |
Optional |
Map (Key is of String type, and Value is of the ThingEvent Struct) |
The events of the model. The key is the event ID. For more information, see ThingEvent Struct.
Note: Events that already exist in the parent or child model cannot be added.
|
ThingAttribute Struct
Name |
Mandatory/Optional |
Data Type |
Description |
identifier |
Optional |
String |
The attribute ID. |
dataType |
Optional |
String |
The data type. E.g.: ARRAY, BOOL, DATE, ENUM, INT, FLOAT, DOUBLE, STRUCT, STRING, TIMESTAMP, FILE |
dataDefinition |
Optional |
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 |
Optional |
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 |
Optional |
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 |
Optional |
StringI18n |
The attribute name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
desc |
Optional |
String |
The attribute description. |
i18nDesc |
Optional |
StringI18n |
The attribute description, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
tags |
Optional |
Map (The Key and Value are of String type.) |
User-defined tags. |
isStdElement |
Optional |
Boolean |
Note: EnOS Edge does not support this parameter.
|
stdElementId |
Optional |
String |
The URN of the element if isStdElement is true . The format is urn:enos:modelelement:std: <id> : <version> . id is the standard ID. <version> is the version of the element.
If isStdElement is false , then stdElementId is null .
If stdElementId is provided, the element definition will be taken from the standard element definition and the dataDefinition parameter will be ignored.
Note: EnOS Edge does not support this parameter.
|
unit |
Optional |
Unit Struct |
For more information, see Unit Struct. |
ThingMeasurepoint Struct
Name |
Mandatory/Optional |
Data Type |
Description |
identifier |
Optional |
String |
The ID of the measurement point. |
dataType |
Optional |
String |
Data type. E.g.: ARRAY, DATE, ENUM, INT, FLOAT, DOUBLE, STRUCT, STRING, TIMESTAMP, FILE |
dataDefinition |
Optional |
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 |
Optional |
StringI18n |
The measurement point name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
desc |
Optional |
String |
The measurement point description. |
i18nDesc |
Optional |
StringI18n |
The measurement point description, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
tags |
Optional |
Map |
User-defined tags. (The Key and Value are of String type.) |
isStdElement |
Optional |
Boolean |
Note: EnOS Edge does not support this parameter.
|
stdElementId |
Optional |
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 .
If stdElementId is provided, the element definition will be taken from the standard element definition and the dataDefinition parameter will be ignored.
Note: EnOS Edge does not support this parameter.
|
hasQuality |
Optional |
Boolean |
|
signalType |
Optional |
String |
The signal/point type. E.g.: Generic, AI, PI, DI |
unit |
Optional |
Unit Struct |
For more information, see Unit Struct. |
ThingService Struct
Name |
Mandatory/Optional |
Data Type |
Description |
identifier |
Optional |
String |
The service ID. |
name |
Optional |
StringI18n |
The service name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
desc |
Optional |
String |
The service description. |
i18nDesc |
Optional |
StringI18n |
The service description, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
tags |
Optional |
Map |
User-defined tags. (The Key and Value are of String type.) |
isStdElement |
Optional |
Boolean |
Note: EnOS Edge does not support this parameter.
|
stdElementId |
Optional |
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 .
If stdElementId is provided, the element definition will be taken from the standard element definition and the dataDefinition parameter will be ignored.
Note: EnOS Edge does not support this parameter.
|
inputData |
Optional |
ThingDatapoint Struct |
The service’s input parameters list. For more information, see ThingDatapoint Struct. |
outputData |
Optional |
ThingDatapoint Struct |
The service’s output parameters list. For more information, see ThingDatapoint Struct. |
callType |
Optional |
String |
The calling type. This parameter will be deprecated.
ASYNC : Asynchronous.
SYNC : Synchronous.
|
ThingEvent Struct
Name |
Mandatory/Optional |
Data Type |
Description |
identifier |
Optional |
String |
The event ID. |
name |
Optional |
StringI18n |
The event name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
desc |
Optional |
String |
The event description. |
i18nDesc |
Optional |
StringI18n |
The event description, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
tags |
Optional |
Map |
User-defined tags. (The Key and Value are of String type.) |
isStdElement |
Optional |
Boolean |
Note: EnOS Edge does not support this parameter.
|
stdElementId |
Optional |
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 .
If stdElementId is provided, the element definition will be taken from the standard element definition and the dataDefinition parameter will be ignored.
Note: EnOS Edge does not support this parameter.
|
outputData |
Optional |
ThingDatapoint Struct |
The event’s output parameters list. For more information, see ThingDatapoint Struct. |
eventType |
Optional |
String |
Event type. E.g.: INFO, WARN, ERROR |
ThingDatapoint Struct
Name |
Mandatory/Optional |
Data Type |
Description |
identifier |
Optional |
String |
The data point ID. |
dataType |
Optional |
String |
Data type. E.g.: ARRAY, DATE, ENUM, INT, FLOAT, DOUBLE, STRUCT, STRING, TIMESTAMP, FILE |
dataDefinition |
Optional |
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 |
Optional |
StringI18n |
The data point name, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
desc |
Optional |
String |
The data point description. |
i18nDesc |
Optional |
StringI18n |
The data point description, supports internationalization. For more details on the structure and locales supported, see Internationalized name struct. |
tags |
Optional |
Map |
User-defined tags. (The Key and Value are of String type.) |
isStdElement |
Optional |
Boolean |
Note: EnOS Edge does not support this parameter.
|
stdElementId |
Optional |
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 .
If stdElementId is provided, the element definition will be taken from the standard element definition and the dataDefinition parameter will be ignored.
Note: EnOS Edge does not support this parameter.
|
unit |
Optional |
Unit Struct |
For more information, see Unit Struct. |
Unit Struct
Name |
Mandatory/Optional |
Data Type |
Description |
unitId |
Optional |
String |
The unit ID. |
multiplier |
Optional |
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
Code |
Description |
10404 |
Model does not exist. |
10945 |
Model element conflicts with parent-child model. |
10952 |
Total number of elements (attribute, measurement points, events, and services) for the model exceeds the limit. |
Samples
Request Sample
url: https://{apigw-address}/model-service/v2.1/thing-models?action=update&orgId=yourOrgId&isPatchUpdate=true
method: POST
requestBody:
{
"modelId": "yourModelId",
"name": {
"defaultValue": "Device Name",
"i18nValue": {
"zh_CN": "设备名称",
"en_US": "Device Name"
}
},
"desc": "jw-1112",
"category": "system",
"tags": {
"group": "1"
},
"attributes": {
"capacity": {
"identifier": "capacity",
"name": {
"defaultValue": "capacity",
"i18nValue": {
"en_US": "capacity",
"zh_CN": "容量"
}
},
"desc": "Capacity",
"i18nDesc": {
"defaultValue": "Capacity description",
"i18nValue": {
"en_US": "Capacity description",
"zh_CN": "容量描述"
}
},
"tags": {
"cap": "1"
},
"stdElementId": "urn:user:modelelement:std:atom-property-int:1.0",
"isStdElement": true,
"dataType": "INT",
"unit": {
"unitId": "G",
"multiplier": "ONE"
},
"dataDefinition": null,
"isRequired": true,
"defaultValue": 111
}
},
"measurepoints": {
"ActiveSC": {
"identifier": "ActiveSC",
"name": {
"defaultValue": "活动状态字",
"i18nValue": {
"en_US": "ActiveSC_Name"
}
},
"desc": "ActiveSC desc",
"i18nDesc": {
"defaultValue": "ActiveSC desc",
"i18nValue": {
"en_US": "ActiveSC desc",
"zh_CN": "活动状态描述"
}
},
"tags": {},
"stdElementId": null,
"isStdElement": false,
"dataType": "INT",
"unit": null,
"dataDefinition": null,
"hasQuality": false,
"signalType": "DI"
}
},
"services": {
"speedup": {
"identifier": "speedup",
"name": {
"defaultValue": "speedup",
"i18nValue": {
"en_US": "speedup"
}
},
"desc": "Speedup",
"i18nDesc": {
"defaultValue": "Speedup",
"i18nValue": {
"en_US": "Speedup",
"zh_CN": "加速"
}
},
"tags": null,
"stdElementId": null,
"isStdElement": false,
"outputData": [
{
"identifier": "delta",
"name": {
"defaultValue": "delta",
"i18nValue": {
"en_US": "delta"
}
},
"desc": "Delta",
"i18nDesc": {
"defaultValue": "Delta",
"i18nValue": {
"en_US": "Delta",
"zh_CN": "Delta 描述"
}
},
"tags": {},
"stdElementId": null,
"isStdElement": false,
"dataType": "INT",
"unit": null,
"dataDefinition": null
}
],
"inputData": [
{
"identifier": "delta",
"name": {
"defaultValue": "delta",
"i18nValue": {
"en_US": "delta"
}
},
"desc": "Delta",
"i18nDesc": {
"defaultValue": "Delta",
"i18nValue": {
"en_US": "Delta",
"zh_CN": "Delta 描述"
}
},
"tags": {},
"stdElementId": null,
"isStdElement": false,
"dataType": "INT",
"unit": {
"unitId": "rpm",
"multiplier": "ONE"
},
"dataDefinition": null
}
],
"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": null,
"stdElementId": null,
"isStdElement": false,
"outputData": [
{
"identifier": "event1",
"name": {
"defaultValue": "event1",
"i18nValue": {
"en_US": "event1"
}
},
"desc": "Event 1",
"i18nDesc": {
"defaultValue": "Event 1",
"i18nValue": {
"en_US": "Event 1",
"zh_CN": "事件"
}
},
"tags": {},
"stdElementId": null,
"isStdElement": false,
"dataType": "INT",
"unit": null,
"dataDefinition": null
}
],
"eventType": "ERROR"
}
}
}
Response Sample
{
"code": 0,
"msg": "OK",
"requestId": "fa11232e-7e45-4176-a382-963c1240a27f"
}
Java SDK Sample
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.api.common.constant.common.StringI18n;
import com.envisioniot.enos.model_service.v2_1.UpdateThingModelRequest;
import com.envisioniot.enos.model_service.v2_1.UpdateThingModelResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class UpdateThingModel {
public static void main(String[] args) {
String appKey = "yourAppAccessKey";
String appSecret = "yourAppSecretKey";
String serverUrl = "https://{apigw-address}";
String orgId = "yourOrgId";
UpdateThingModelRequest request = new UpdateThingModelRequest();
request.setModelId("yourModelId");
request.setIsPatchUpdate(true);
StringI18n i18n = new StringI18n();
i18n.setDefaultValue("Device Name");
request.setName(i18n);
Map<String, String> tags = new HashMap<>();
tags.put("group", "1");
request.setTags(tags);
request.setDesc("jw-1112");
request.setOrgId(orgId);
List<String> featuresToDelete = new ArrayList<>();
featuresToDelete.add("test_measure_point");
request.setFeaturesToDelete(featuresToDelete);
UpdateThingModelResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
.url(serverUrl)
.getResponse(request, request.getResponseClass());
if (response.success()) {
System.out.println("update is successful!");
}else{
System.out.println(response.toString());
}
}
}
| |