V2.1 Search Event¶
Search for events based on the search criteria.
This API is available in EnOS 2.1.0 and above.
If you need to invoke this API after performing bulk updates to relevant events using other APIs, it is recommended to wait for about 2 seconds to avoid obtaining unupdated data.
Request Format¶
POST https://{apigw-address}/connect-service/v2.1/events?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 one of the following methods to specify the device:
Include
assetId
in the requestInclude
productKey
+deviceKey
in the request
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
productKey |
Optional (See Note above) |
String |
The product key. To be used with |
deviceKey |
Optional (See Note above) |
String |
The device key. To be used with |
assetId |
Optional (See Note above) |
String |
The asset ID. How to get assetId>> |
tslEventKey |
Optional |
String |
The event key. |
tslEventType |
Optional |
String |
The event type. |
startTime |
Optional |
String |
The start time of the event. The format yyyy-MM-dd HH:mm:ss means local time, yyyy-MM-ddTHH:mm:ssZ means UTC time. If not specified, the data within the last week will be searched. |
endTime |
Optional |
String |
The end time of the event. The format yyyy-MM-dd HH:mm:ss means local time, yyyy-MM-ddTHH:mm:ssZ means UTC time. If not specified, the data within the last week will be searched. |
expression |
Optional |
String |
The query expression, which supports sql-like query. The fields that are supported for query include: |
pagination |
Optional |
Pagination Request Struct |
Lists the paging requirements in a request. When not specified, 10 records are displayed per page by default and sorted in descending order by |
resolveName |
Optional |
Boolean |
|
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
Array of Event Structs |
A list of the events returned. For details of an Event Struct, see Event Struct. |
Event Struct ¶
Name |
Data Type |
Description |
---|---|---|
orgId |
String |
The organization ID which the asset belongs to. |
eventId |
String |
The event ID. |
productKey |
String |
The product key. |
deviceKey |
String |
The device key. |
assetId |
String |
The asset ID. |
tslEventKey |
String |
The event key in the TSL model. |
tslEventType |
String |
The event type defined in the TSL model. |
output |
String |
The event output. |
outputData |
Map (Key is of String type, and Value is of Object) |
The output in JSON. |
timestamp |
Long |
The event timestamp. |
localtime |
String |
The local time when the event occurs. |
eventName |
StringI18n |
The event name. For more details on the structure and locales supported, see Internationalized name struct. |
outputNames |
Map (Key is of String type, and Value is of StringI18n) |
The names of the event output. |
Samples¶
Request Sample¶
url:https://{apigw-address}/connect-service/v2.1/events?action=search&orgId=yourOrgId
method: POST
requestBody:
{
"pagination":{
"pageNo":1,
"pageSize":2
},
"action":"search",
"resolveName":true
}
Return Sample¶
{
"code": 0,
"msg": "OK",
"requestId": "7b5d3c98-27bd-435c-a8e5-ffd0c91e679f",
"data": [
{
"eventId": "2021032347372528c9dd2035cdf169f6e60c6d1a",
"orgId": "yourOrgId",
"productKey": "yourProductKey",
"deviceKey": "yourDeviceKey",
"assetId": "yourAssetId",
"tslEventKey": "yourEventKey",
"tslEventType": "INFO",
"output": "{\"breakdown\":0}",
"outputData": {
"breakdown": 0
},
"timestamp": 1616495975000,
"localtime": "2021-03-23 18:39:35",
"eventName": {
"defaultValue": "event",
"i18nValue": {}
},
"outputNames": {
"breakdown": {
"defaultValue": "breakdown",
"i18nValue": {
"en_US": "breakdown",
"zh_CN": "分解"
}
}
}
}
],
"pagination": {
"pageNo": 1,
"pageSize": 2,
"totalSize": 1
}
}
SDK Samples¶
You can access the SDK samples for Connection Service on GitHub: