Search Asset Tree¶
Search for asset trees based on the query criterion.
Request Format¶
POST https://{apigw-address}/asset-tree-service/v2.1/asset-trees?action=search
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>> |
Request Parameters (Body)¶
Note
Use either expression
or filter
to search, but not both together. EnOS Cloud only supports searching by expression
while EnOS Edge supports expression
or filter
.
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
expression |
Optional |
String |
The conditions used for the search. The use of |
filter |
Optional |
Filter Struct |
The conditions used for the search. The use of Note: EnOS Cloud does not support this parameter. |
pagination |
Optional |
Pagination Request Struct |
Lists the paging requirements in a request. When not specified, 100 records are displayed per page by default. The maximum records per page is 1000 but for optimal performance, it is recommended to have not more than 50 records per page. |
projection |
Optional |
Projection struct |
Enables you to crop the data result set returned in the interface 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. For more details, see How does projection crop the result set>> |
Filter Struct ¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
tags |
Optional |
Map (Key and Value are of String type) |
User-defined tags. For details, see How to use tag >> |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
Array of AssetTree Structs |
Details of the asset tree based on the assetId. For the definition of an AssetTree Struct, see the table below. |
Name |
Data Type |
Description |
---|---|---|
treeId |
String |
The asset tree ID. |
name |
StringI18n |
The asset tree name. For more details on the structure and locales supported, see Internationalized name struct>> |
tags |
Tag struct |
The user-defined tags. |
asset |
Asset Struct |
The details of an asset. For more information, see Asset struct>> |
Samples¶
Request Sample¶
url: https://{apigw-address}/asset-tree-service/v2.1/asset-trees?action=search&orgId=yourOrgId
method: POST
requestBody:
{
"expression":"tags.k1 ='v1' ",
"pagination": {
"pageNo": 1,
"pageSize": 10
},
"projection": ["asset"]
}
Return Sample¶
{
"code":0,
"msg":"OK",
"requestId":"82248518-6da4-49d2-8d07-cf7a0ff55b60",
"data":{
"BtsYmF2r":[
{
"treeId":"yourTreeId",
"tags":{
},
"asset":{
"modelId":"yourModelId",
"assetId":"BtsYmF2r",
"timezone":"+08:00",
"name":{
"i18nValue":{
"en_US":"zmTree604111zzz"
},
"defaultValue":"zmTree604"
},
"description":"",
"attributes":{
},
"inValid":false,
"label":"1",
"modelIdPath":"/NULLMODEL",
"tags":{
}
}
}
]
}
}
Java SDK Sample¶
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.api.common.constant.request.Pagination;
import com.envisioniot.enos.api.common.constant.request.Projection;
import com.envisioniot.enos.asset_tree_service.v2_1.*;
import com.envisioniot.enos.asset_tree_service.vo.AssetCreateVo;
import com.envisioniot.enos.asset_tree_service.vo.I18nVo;
import com.envisioniot.enos.asset_tree_service.vo.TreeCreateVo;
import com.envisioniot.enos.asset_tree_service.vo.TreeUpdateVo;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
public class AssetTreeTest {
private static String AccessKey = "yourAccessKey";
private static String SecretKey = "yourSecretKey";
private static String OrgId = "yourOrgId";
private static String ServerUrl = "yourServerUrl";
@Test
public void testSearchTree() {
SearchAssetTreeRequest request = new SearchAssetTreeRequest();
request.setOrgId(OrgId);
request.setExpression("tags.k1 ='v1'");
Pagination pagination = new Pagination(3, 1, null);
Projection projection = new Projection();
projection.add("asset");
request.setPagination(pagination);
request.setProjection(projection);
SearchAssetTreeResponse response = Poseidon.config(PConfig.init().appKey(AccessKey).appSecret(SecretKey).debug())
.url(ServerUrl)
.getResponse(request, SearchAssetTreeResponse.class);
}
}