Move Asset Node¶
Move an asset node, together with all its descendant nodes, to a specified location.
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 |
---|---|
Asset Tree Management |
Full Access |
Request Format¶
POST https://{apigw-address}/asset-tree-service/v2.1/asset-nodes?action=move
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>> |
treeId |
Query |
Mandatory |
String |
The asset tree ID. How to get treeID>> |
parentAssetId |
Query |
Mandatory |
String |
The asset ID of the parent node of |
preAssetId |
Query |
Optional |
String |
The asset ID of the sibling node prior to the |
assetId |
Query |
Mandatory |
String |
The asset ID of the asset node to be moved. How to get assetId>> |
Examples¶
Assuming an asset tree has the following structure.
Scenario 1: If parentAssetId
is 7, preAssetId
is 13, and assetId
is 10, the new tree structure will be as per the below after the move.
Scenario 2: If parentAssetId
is 3, preAssetId
is null, and assetId
is 10, the new tree structure will be as per the below after the move.
Scenario 3: If parentAssetId
is 5, preAssetId
is null, and assetId
is 10, the new tree structure will be as per the below after the move.
Error Codes¶
Code |
Message |
Description |
---|---|---|
99400 |
|
|
99500 |
System error |
Internal server error. Contact EnOS support. |
17404 |
Asset is not exist in the tree |
The asset does not exist in this tree. |
17762 |
The tree is locked |
The asset tree cannot be modified/deleted for the time being as someone is currently accessing the asset tree. Please try again later. |
17764 |
The root asset node can not be moved or deleted: or tree is not exist |
The root asset node cannot be moved or the tree does not exist. |
17768 |
Can not move to descendant node |
Unable to move under one’s descendant. |
17770 |
Exceeding the layer limit(7) |
The tree exceeds the maximum number of layers (7 layers). |
17777 |
Parent asset is invalid |
The |
Samples¶
Request Sample¶
url: https://{apigw-address}/asset-tree-service/v2.1/asset-nodes?parentAssetId=yourParrentAssetId&assetId=yourAssetId&preAssetId=yourPreAssetId&orgId=yourOrgId&treeId=yourTreeId&action=move
method: POST
Return Sample¶
{
"code": 0,
"msg": null,
"requestId": "8d0b2297-4dce-48b5-b685-3bd30e4c4636",
"data": null
}
Java SDK Sample¶
package com.envision.energy.asset_tree_service.service;
import org.junit.Test;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envision.eos.commons.utils.GsonUtil;
import com.envisioniot.enos.asset_tree_service.v2_1.MoveAssetNodeRequest;
import com.envisioniot.enos.asset_tree_service.v2_1.MoveAssetNodeResponse;
public class AssetNodExceptionTest {
private static String AccessKey = "yourAccessKey";
private static String SecretKey = "yourSecretKey";
private static String OrgId = "yourOrgId";
private static String ServerUrl = "yourServerUrl";
@Test
public void testAssociateAssetNode() {
MoveAssetNodeRequest request = new MoveAssetNodeRequest();
request.setOrgId(OrgId);
request.setTreeId("yourTreeId");
request.setParentAssetId("yourParentAssetId");
request.setAssetId("yourAssetId");
request.setPreAssetId("yourPreAssetId");
MoveAssetNodeResponse response = Poseidon.config(PConfig.init().appKey(AccessKey).appSecret(SecretKey).debug())
.url(ServerUrl).getResponse(request, MoveAssetNodeResponse.class);
System.out.println(GsonUtil.toJson(response));
}
}