Search Asset Node¶
Search for assets based on the search criteria.
Request Format¶
POST https://{apigw-address}/asset-tree-service/v2.1/asset-nodes?action=searchAsset
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 fields that are supported for query include:
Do not use this with |
filter |
Optional |
AssetSearchVo Struct |
The conditions used for the search. Do not use this with 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 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?
|
AssetSearchVo Struct ¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
assetIds |
Optional |
String Array |
The list of asset IDs. |
modelIds |
Optional |
String Array |
The list of model IDs. |
rootModelIds |
Optional |
String Array |
The list of root model IDs. |
attributes |
Optional |
Map (Key is of String type, Value is of Object type) |
The attributes of the model which the asset belongs to. |
tags |
Optional |
Map (Key and Value are of String type) |
The user-defined tags. |
nameLike |
Optional |
I18nSearchVo Struct |
The asset name, which supports fuzzy query. For more details on the structure and locales supported, see I18nSearchVo Struct. |
I18nSearchVo Struct ¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
locale |
Optional |
String |
The locale language, currently supporting:
|
value |
Optional |
String |
The corresponding asset name for the locale. If null, no data will be returned. If blank, the data under the specified locale will be returned. |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
Array |
A list of the assets. Information include |
Error Codes¶
Code |
Message |
Description |
---|---|---|
99400 |
Invalid arguments |
The request parameter is invalid. Check the request parameters. |
99500 |
System error |
Internal server error. Contact EnOS support. |
Samples¶
Request Sample¶
url: https://{apigw-address}/asset-tree-service/v2.1/asset-nodes?action=searchAsset&orgId=yourOrgId
method: POST
requestBody:
{
"projection": ["attributes", "assetId", "name"]
}
Return Sample¶
{
"code": 0,
"msg": "OK",
"requestId": "cf08e75c-325a-429f-bdb9-ec5d6a1250d7",
"pagination": {
"pageNo": 1,
"pageSize": 10,
"totalSzie": 10,
"sortedBy": null
},
"data": [{
"assetId": "f1Y6KiOr",
"name": {
"i18nValue": {},
"defaultValue": "earth"
},
"attributes": {
"starsystem": "Solar System",
"de001": 123
}
}, {
"assetId": "WHIFQDEZ",
"name": {
"i18nValue": {},
"defaultValue": "earth"
},
"attributes": {
"starsystem": "Solar System",
"de001": 123
}
}, {
"assetId": "TdqGOisO",
"name": {
"i18nValue": {},
"defaultValue": "earth"
},
"attributes": {
"starsystem": "Solar System",
"de001": 123
}
}, {
"assetId": "T9VewFFA",
"name": {
"i18nValue": {},
"defaultValue": "venus"
},
"attributes": {
"starsystem": "Solar System",
"de001": 123
}
}, {
"assetId": "NU3EbpXK",
"name": {
"i18nValue": {},
"defaultValue": "1559140566137"
},
"attributes": {
"starsystem": "Solar System",
"de001": 123
}
}, {
"assetId": "9AE1XYBl",
"name": {
"i18nValue": {},
"defaultValue": "earth"
},
"attributes": {
"starsystem": "Solar System",
"de001": 123
}
}, {
"assetId": "ZPuCIbDw",
"name": {
"i18nValue": {},
"defaultValue": "earth"
},
"attributes": {
"starsystem": "Solar System",
"de001": 123
}
}]
}
Java SDK Sample¶
package com.envisioniot.enos.asset_tree_service;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
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.AssetSearchVo;
import com.envisioniot.enos.asset_tree_service.vo.RelatedAssetSearchVo;
import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class SearchNodeTest {
private static String AccessKey = "yourAccessKey";
private static String SecretKey = "yourSecretKey";
private static String OrgId = "yourOrgId";
private static String ServerUrl = "yourServerUrl";
@Test
public void testSearchAssetNode() {
SearchAssetNodeRequest request = new SearchAssetNodeRequest();
request.setOrgId(OrgId);
request.setExpression("name.default like'assetDefaultName'");
Projection projection = new Projection();
projection.addAll(Arrays.asList("attributes", "assetId", "name"));
request.setProjection(projection);
SearchAssetNodeResponse response = Poseidon.config(PConfig.init().appKey(AccessKey).appSecret(SecretKey).debug())
.url(ServerUrl).getResponse(request, SearchAssetNodeResponse.class);
}
}