Update Thing Model¶
Update a model.
Operation Permissions¶
Before invoking this API, ensure that the service account has been authorized the policy that includes the following service(s) and action permission(s). For how to authorize the service account, see Managing Service Accounts.
Required Authorization |
Required Operation Permission |
---|---|
Model |
Update |
Request Format¶
POST https://{apigw-address}/model-service/v2.1/thing-models?action=update
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>> |
isPatchUpdate |
Query |
Optional |
Boolean |
|
Request Parameters (Body)¶
Name |
Required/Optional |
Data Type |
Description |
---|---|---|---|
modelId |
Required |
String |
The model ID. |
name |
Required if |
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 |
attributes |
Optional |
Map (Key is of String type, and Value is of the |
The attributes of the model. The key is the static attribute ID. For more information, see ThingAttribute Struct.
|
measurepoints |
Optional |
Map (Key is of String type, and Value is of the |
The measurement points of the model. The key is the measurement point ID, of String type. For more information, see ThingMeasurepoint Struct.
|
services |
Optional |
Map (Key is of String type, and Value is of the |
The services of the model. The key is the service ID. For more information, see ThingService Struct.
|
events |
Optional |
Map (Key is of String type, and Value is of the |
The events of the model. The key is the event ID. For more information, see ThingEvent Struct.
|
ThingAttribute Struct ¶
Name |
Required/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 |
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, 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 If If Note: EnOS Edge does not support this parameter. |
unit |
Optional |
Unit Struct |
For more information, see Unit Struct. |
ThingMeasurepoint Struct ¶
Name |
Required/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 |
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 If If 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 |
Required/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 If If 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.
|
ThingEvent Struct ¶
Name |
Required/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 If If 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 |
Required/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 |
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 If If Note: EnOS Edge does not support this parameter. |
unit |
Optional |
Unit Struct |
For more information, see Unit Struct. |
isRequired |
Optional |
Boolean |
Applicable only for service Note: EnOS Edge does not support this parameter. |
defaultValue |
Optional |
Depends on the data type |
The default value of the data point. If the data point has no default value, Note: EnOS Edge does not support this parameter. |
Unit Struct ¶
Name |
Required/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,
"isRequired": false,
"defaultValue": 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"
}
SDK Samples¶
You can access the SDK samples for model service on GitHub: