Get Event¶
通过 eventId
获取事件的详细信息。
请求格式¶
GET https://{apigw-address}/connect-service/v2.1/events?action=get
请求参数(URI)¶
名称 | 位置(Path/Query) | 必需/可选 | 数据类型 | 描述 |
---|---|---|---|---|
orgId | Query | 必需 | String | 资产所属的组织 ID。 如何获取 orgId 信息>> |
eventId | Query | 必需 | String | 事件标识符。 |
resolveName | Query | 可选 | Boolean |
|
响应参数¶
名称 | 数据类型 | 描述 |
---|---|---|
data | Event 结构体 | 有关 Event 结构体的定义,见 Event 结构体。 |
Event 结构体 ¶
名称 | 数据类型 | 描述 |
---|---|---|
orgId | String | 资产所属的组织 ID。 |
eventId | String | 事件 ID。 |
productKey | String | Product Key。 |
deviceKey | String | Device Key。 |
assetId | String | 资产 ID。 |
tslEventKey | String | TSL 模型中的事件 Key。 |
tslEventType | String | TSL 模型中定义的事件类型。 |
output | String | 事件的输出。 |
outputData | Map(Key 为 String,Value 为 Object) | 事件的输出 JSON 格式。 |
timestamp | Long | 事件发生时间戳。 |
localtime | String | 事件发生本地时间。 |
eventName | StringI18n | 事件的名称。结构参见 国际化名称结构体。 |
outputNames | Map(Key 为 String,Value 为 StringI18n) | 事件的输出名称。 |
示例¶
请求示例¶
url: https://{apigw-address}/connect-service/v2.1/events?action=get&eventId=yourEventId&orgId=yourOrgId&resolveName=true
method: GET
返回示例¶
{
"code": 0,
"msg": "OK",
"requestId": "437f3075-448c-4995-9bf5-81e15382615c",
"data": {
"eventId": "20210323d3a7738134ae8a33f569d4fea8f4d57c",
"orgId": "yourOrgId",
"productKey": "yourProductKey",
"deviceKey": "yourDeviceKey",
"assetId": "yourAssetId",
"tslEventKey": "yourEventKey",
"tslEventType": "INFO",
"output": "{\"test\":12,\"branchCurr\":[1.1,2.1,3.1],\"Power\":11.1}",
"outputData": {
"test": 12,
"branchCurr": [
1.1,
2.1,
3.1
],
"Power": 11.1
},
"timestamp": 1616493875000,
"localtime": "2021-03-23 18:04:35",
"eventName": {
"defaultValue": "电流阈值",
"i18nValue": {
"en_US": "",
"zh_CN": ""
}
},
"outputNames": {
"test": {
"defaultValue": "test",
"i18nValue": {
"en_US": "test",
"zh_CN": "测试"
}
},
"branchCurr": {
"defaultValue": "branchCurr",
"i18nValue": {
"en_US": "branchCurr",
"zh_CN": "当前分支"
}
},
"Power": {
"defaultValue": "Power",
"i18nValue": {
"en_US": "Power",
"zh_CN": "电量"
}
}
}
}
}
Java SDK 调用示例¶
package com.envisioniot.enos.api.sample.connect_service.event;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.connect_service.v2_1.event.GetEventRequest;
import com.envisioniot.enos.connect_service.v2_1.event.GetEventResponse;
import com.google.gson.Gson;
public class GetEvent {
public static void main(String[] args) {
String appKey = "yourAppKey";
String appSecret = "yourAppSecret";
GetEventRequest request = new GetEventRequest();
request.setOrgId("yourOrgId");
request.setEventId("yourEventId");
request.setResolveName(true);
try {
GetEventResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
.url("yourServerUrl")
.getResponse(request, GetEventResponse.class);
Gson gson = new Gson();
System.out.println(gson.toJson(response));
} catch (Exception e) {
System.out.print(e);
}
}
}