Update Logical Asset (Preview)¶
Update all or selected details of a logical asset.
Operation Permissions¶
Required Authorization |
Required Operation Permission |
---|---|
Asset Tree Management |
Full Access |
Prerequisite¶
The logical asset to be updated must exist.
The selected details to be updated must exist.
Request Format¶
POST https://{apigw-address}/asset-service/v2.1/logical-assets?action=update
Request Parameters (URI)¶
Name |
Location (Path/Query) |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|---|
orgId |
Query |
Mandatory |
String |
The organization ID which the asset belongs to. How to get orgId>> |
isPatchUpdate |
Query |
Optional |
Boolean |
|
Request Parameters (Body)¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
assetUpdateVo |
Mandatory |
AssetUpdateVo Struct |
Used for asset update.
For more information, see AssetUpdateVo Struct. |
AssetUpdateVo Struct ¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
assetId |
Mandatory |
String |
The asset ID. How to get assetId>> |
name |
Optional |
StringI18n |
Specify the asset’s name in its respective locale’s language. For more details on the structure and locales supported, see Internationalized name struct. |
description |
Optional |
String |
The asset description. |
attributes |
|
Map (Key is of String type, and Value depends on the attribute defined in the model) |
Attributes of the model which the asset belongs to. Key is the attribute ID. For more information, see attributes representation. |
timezone |
Optional |
String |
For details, see Timezone representation. |
tags |
Optional |
Map (Key and Value are of String type) |
User-defined tags. For more information, see How to use tag. |
Error Codes¶
Code |
Message |
Description |
---|---|---|
17404 |
Logical asset does not exist |
The |
17958 |
Asset validation failed |
Failed to verify assets based on model. |
Samples¶
Request Sample¶
url: https://{apigw-address}/asset-service/v2.1/logical-asset?action=update&orgId=yourOrgId&isPatchUpdate=true
method: POST
requestBody:
{
"assetUpdateVo":{
"assetId":"yourAssetId",
"name":{
"defaultValue":"instanceName",
"i18nValue":{
"en_US":"English name ",
"zh_CN":"Chinese name"
}
},
"description":"description",
"attributes":{
"color": "blue",
"number": 135
},
"timezone":"+08:00",
"tags":{
"year":"2000",
"author":"authorName"
}
}
}
Return Sample¶
{
"code": 0,
"msg": "OK",
"requestId": "fa11232e-7e45-4176-a382-963c1240a27f"
}
Java SDK Sample¶
public class UpdateLogicAssetTest {
private static String accessKey = "yourAccessKey";
private static String secretKey = "yourSecretKey";
private static String orgId = "yourOrgId";
private static String serverUrl = "https://{apigw-address}";
@Test
public void testCreateAssetNode() {
UpdateLogicAssetRequest request = new UpdateLogicAssetRequest();
request.setOrgId(orgId);
AssetUpdateVo assetUpdateVo = new AssetUpdateVo();
assetUpdateVo.setAssetId("yourAssetId");//The logical asset ID to be updated. Using a device asset ID will fail.
I18nVo name = new I18nVo();
name.setDefaultValue("instanceName");
assetUpdateVo.setName(name);
request.setAsset(assetUpdateVo);
UpdateLogicAssetResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
.url(serverUrl).getResponse(request, UpdateLogicAssetResponse.class);
}
}