Search Product¶
搜索满足条件的产品。
请求格式¶
POST https://{apigw-address}/connect-service/v2.1/products?action=search
请求参数(URI)¶
名称 |
位置(Path/Query) |
必需/可选 |
数据类型 |
描述 |
---|---|---|---|---|
orgId |
Query |
必需 |
String |
资产所属的组织 ID。 如何获取 orgId 信息>> |
请求参数(Body)¶
名称 |
必需/可选 |
数据类型 |
描述 |
---|---|---|---|
expression |
可选 |
String |
查询表达式,支持类 SQL 的查询。目前支持查询的字段是
|
pagination |
可选 |
String |
分页参数。如未指定,默认每页 10 条。每页最大记录数为 1,000 条,但为获得最佳性能,建议每页不超过 50 条。不支持使用 |
响应参数¶
名称 |
数据类型 |
描述 |
---|---|---|
data |
Product 结构体数组 |
查询得到的产品列表,按照创建时间由新至旧排列。见 Product 结构体>> |
示例¶
请求示例¶
url: https://{apigw-address}/connect-service/v2.1/products?action=search&orgId=yourOrgId
method: POST
requestBody:
{
"expression":"modelId=\"AlterTest0615\"",
"pagination":{
"pageNo":1,
"pageSize":5
}
}
返回示例¶
{
"code":0,
"msg":"OK",
"requestId":"a82752bb-9eb0-4cd5-b0c6-0c1aeb35f6d2",
"data":[
{
"orgId":"yourOrgId",
"productKey":"yourProductKey",
"productName":{
"defaultValue":"openapi_sdk_8",
"i18nValue":{}
},
"productSecret":"yourProductSecret",
"productDesc":"test_sdk_update",
"productType":"Device",
"dataFormat":"Custom",
"productTags":{},
"modelId":"AlterTest0615",
"dynamicActiveEnabled":false,
"biDirectionalAuth":true,
"createBy": null,
"createTime": null,
"updateBy": null,
"updateTime": 1589767858113
},
{
"orgId":"yourOrgId",
"productKey":"yourProductKey",
"productName":{
"defaultValue":"AlterTest0615_Product",
"i18nValue":{}
},
"productSecret":"yourProductSecret",
"productDesc":"",
"productType":"Device",
"dataFormat":"Json",
"productTags":{},
"modelId":"AlterTest0615",
"dynamicActiveEnabled":false,
"biDirectionalAuth":false,
"createBy": null,
"createTime": null,
"updateBy": null,
"updateTime": 1589767858113,
"defaultValidDay":null,
"maxValidDay":null
}
],
"pagination":{
"sortedBy":null,
"pageNo":1,
"pageSize":5,
"totalSize":2
}
}
Java SDK 调用示例¶
package com.envisioniot.enos.api.sample.connect_service.product;
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.product.SearchProductRequest;
import com.envisioniot.enos.connect_service.v2_1.product.SearchProductResponse;
public class SearchProduct {
public static void main(String[] args) {
String appKey = "yourAppKey";
String appSecret = "yourAppSecret";
String serverUrl = "yourServerUrl";
String orgId = "yourOrgId";
SearchProductRequest request = new SearchProductRequest();
request.setOrgId(orgId);
request.setExpression("modelId='yourModelId'"); // or productKey = 'yourProductKey'
request.setPagination(new Pagination(5, 1, null));
Projection projection = new Projection();
projection.add("productName");
request.setProjection(projection);
SearchProductResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
.url(serverUrl)
.getResponse(request, SearchProductResponse.class);
}
}