Search Device¶
查询设备信息。
操作权限¶
需授权的资源 |
所需操作权限 |
---|---|
设备管理 |
Read |
请求格式¶
POST https://{apigw-address}/connect-service/v2.1/devices?action=search
请求参数(URI)¶
名称 |
位置(Path/Query) |
必需/可选 |
数据类型 |
描述 |
---|---|---|---|---|
orgId |
Query |
必需 |
String |
资产所属的组织 ID。如何获取 orgId 信息>> |
请求参数(Body)¶
名称 |
必需/可选 |
数据类型 |
描述 |
---|---|---|---|
expression |
可选 |
String |
查询表达式,目前支持的字段有
|
pagination |
可选 |
Pagination 请求结构体 |
随机分页。如未指定,默认每页10条。每页最大记录数为200条,但为获得最佳性能,建议每页不超过50条。不支持使用 |
projection |
可选 |
Projection 结构体 |
用于在接口请求中描述待返回的对象 projection。详见 参数如何对结果集做裁剪>> |
populateLastUpdateInfo |
可选 |
Boolean |
|
响应参数¶
名称 |
数据类型 |
描述 |
---|---|---|
data |
Device 结构体数组 |
有关 Device 结构体的定义,见 Device 结构体>> |
Device 结构体¶
名称 |
数据类型 |
描述 |
---|---|---|
orgId |
String |
资产所属的组织 ID。 |
assetId |
String |
资产 ID。 |
modelId |
String |
资产所属模型 ID。 |
modelIdPath |
String |
模型ID的路径。 |
productKey |
String |
Product Key. |
productName |
StringI18n |
产品名称。 |
productType |
String |
产品类型。 |
dataFormat |
String |
数据格式。 |
deviceKey |
String |
Device Key. |
deviceName |
StringI18n |
设备名称。 |
deviceSecret |
String |
设备的连接秘钥。 |
deviceDesc |
String |
设备描述。 |
timezone |
String |
设备所在时区。 |
deviceAttributes |
Map(Key 为 String,Value 为 String) |
设备的属性。 |
deviceTags |
Map(Key 为 String,Value 为 String) |
设备的标志。 |
createTime |
Long |
设备的创建时间。 |
status |
String |
设备的状态(online、offline、inactive、disable 或 mirror)。 |
activeTime |
Long |
设备的激活时间。 |
lastOnlineTime |
Long |
设备最后一次上线时间。 |
lastOfflineTime |
Long |
设备最后一次离线时间。 |
measurepointLastUpdate |
Long |
设备测点最近一次更新的时间。 |
eventLastUpdate |
Long |
设备事件最近一次更新的时间。 |
attributeLastUpdate |
Long |
设备属性最近一次更新的时间。 |
featureLastUpdate |
Long |
设备最近一次更新的时间,以上述三个时间( |
firmwareVersion |
String |
固件版本号。 |
示例¶
请求示例¶
url:https://{apigw-address}/connect-service/v2.1/devices?action=search&orgId=yourOrgId
method: POST
requestBody:
{
"pagination":{
"pageNo":2,
"pageSize":5
},
"populateLastUpdateInfo": true
}
返回示例¶
{
"code":0,
"msg":"OK",
"requestId":"59ecd409-7baa-4726-ba10-c0bde35ffb09",
"data":[
{
"orgId":"yourOrgId",
"assetId":"yourAssetId",
"modelId":"lxctimelooker",
"modelIdPath":"/lxctimelooker",
"productKey":"yourProductKey",
"productName":{
"defaultValue":"lxcpro",
"i18nValue":{
}
},
"productType":"Device",
"dataFormat":"Json",
"deviceKey":"yourDeviceKey",
"deviceName":{
"defaultValue":"time2dev11",
"i18nValue":{
}
},
"deviceSecret":"yourDeviceSecret",
"deviceDesc":null,
"timezone":"+09:00",
"deviceAttributes":{
},
"deviceTags":{
},
"createTime":1558421750575,
"status":"offline",
"activeTime":1558482329972,
"lastOnlineTime":1560743915454,
"lastOfflineTime":1560744095454,
"measurepointLastUpdate":null,
"eventLastUpdate":null,
"attributeLastUpdate":null,
"featureLastUpdate":null,
"firmwareVersion": "2.2"
},
{
"orgId":"yourOrgId",
"assetId":"Fi0HQ8FO",
"modelId":"AlterTest0615",
"modelIdPath":"/AlterTest0615",
"productKey":"yourProductKey",
"productName":{
"defaultValue":"AlterTest0615_Product",
"i18nValue":{
}
},
"productType":"Device",
"dataFormat":"Json",
"deviceKey":"yourDeviceKey",
"deviceName":{
"defaultValue":"AlterTest0615",
"i18nValue":{
}
},
"deviceSecret":"yourDeviceSecret",
"deviceDesc":null,
"timezone":"+08:00",
"deviceAttributes":{
},
"deviceTags":{
},
"createTime":1560564762147,
"status":"offline",
"activeTime":1560564838673,
"lastOnlineTime":1560743931247,
"lastOfflineTime":1560743931712,
"measurepointLastUpdate":null,
"eventLastUpdate":null,
"attributeLastUpdate":null,
"featureLastUpdate":null,
"firmwareVersion": "2.2"
},
{
"orgId":"yourOrgId",
"assetId":"6FytqleL",
"modelId":"AlterTest0614",
"modelIdPath":"/AlterTest0614",
"productKey":"yourProductKey",
"productName":{
"defaultValue":"AlterTest0614_Product",
"i18nValue":{
}
},
"productType":"Device",
"dataFormat":"Json",
"deviceKey":"yourDeviceKey",
"deviceName":{
"defaultValue":"AlterTest0614",
"i18nValue":{
}
},
"deviceSecret":"yourDeviceSecret",
"deviceDesc":null,
"timezone":"+08:00",
"deviceAttributes":{
"aaa":1,
"76":0
},
"deviceTags":{
},
"createTime":1560493341919,
"status":"offline",
"activeTime":1560493435761,
"lastOnlineTime":1560743930253,
"lastOfflineTime":1560743930346,
"measurepointLastUpdate":null,
"eventLastUpdate":null,
"attributeLastUpdate":null,
"featureLastUpdate":null,
"firmwareVersion": "2.2"
},
{
"orgId":"yourOrgId",
"assetId":"yourAssetId",
"modelId":"yourModelId",
"modelIdPath":"yourModelIdPath",
"productKey":"yourProductKey",
"productName":{
"defaultValue":"AlertTest0613_Product",
"i18nValue":{
}
},
"productType":"Device",
"dataFormat":"Json",
"deviceKey":"yourDeviceKey",
"deviceName":{
"defaultValue":"AlertTest0613",
"i18nValue":{
}
},
"deviceSecret":"yourDeviceSecret",
"deviceDesc":null,
"timezone":"+08:00",
"deviceAttributes":{
"aaa":1,
"76":0
},
"deviceTags":{
},
"createTime":1560389949661,
"status":"offline",
"activeTime":1560390227903,
"lastOnlineTime":1560743916848,
"lastOfflineTime":1560743929003,
"measurepointLastUpdate":null,
"eventLastUpdate":null,
"attributeLastUpdate":null,
"featureLastUpdate":null,
"firmwareVersion": "2.2"
},
{
"orgId":"yourOrgId",
"assetId":"yourAssetId",
"modelId":"yourModelId",
"modelIdPath":"yourModelIdPath",
"productKey":"yourProductKey",
"productName":{
"defaultValue":"zccp-----1",
"i18nValue":{
}
},
"productType":"Device",
"dataFormat":"Json",
"deviceKey":"yourDeviceKey",
"deviceName":{
"defaultValue":"zccp-----222",
"i18nValue":{
}
},
"deviceSecret":"yourDeviceSecret",
"deviceDesc":null,
"timezone":"+08:00",
"deviceAttributes":{
"timestamp1":1,
"float1":1.0,
"bool11":false,
"int1":1,
"string1":"1",
"double1":1.0,
"12221":false,
"array1":[
1
],
"stuct1":{
"int11":1
},
"file1":"ftp://a.com/demo.txt",
"enum":1,
"dete1":"2019-05-06"
},
"deviceTags":{
},
"createTime":1559294746435,
"status":"inactive",
"activeTime":0,
"lastOnlineTime":0,
"lastOfflineTime":0,
"measurepointLastUpdate":null,
"eventLastUpdate":null,
"attributeLastUpdate":null,
"featureLastUpdate":null,
"firmwareVersion": "2.2"
}
],
"pagination":{
"sortedBy":null,
"pageNo":2,
"pageSize":5,
"totalSize":6511
}
}
Java SDK 调用示例¶
package com.envisioniot.enos.api.sample.connect_service.device;
import com.envision.apim.poseidon.config.PConfig;
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.connect_service.v2_1.device.SearchDeviceRequest;
import com.envisioniot.enos.connect_service.v2_1.device.SearchDeviceResponse;
public class SearchDevice {
public static void main(String[] args) {
final String appKey = "yourAppKey";
final String appSecret = "yourAppSecret";
String serverUrl = "yourServerUrl";
String orgId = "yourOrgId";
String assetId = "yourAssetId";
SearchDeviceRequest request = new SearchDeviceRequest();
request.setOrgId(orgId);
String expression = "productKey='yourProductKey'";
request.setExpression(expression);
Pagination pagination = new Pagination();
pagination.setPageSize(5);
pagination.setPageNo(2);
Projection projection = new Projection();
projection.add(assetId);
projection.add("productName");
request.setPagination(pagination);
request.setProjection(projection);
SearchDeviceResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
.url(serverUrl)
.getResponse(request, SearchDeviceResponse.class);
}
}