Search Event

Search for events based on the search criteria.

Operation Permissions

Required Authorization Required Operation Permission
Asset Read

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)

Name Mandatory/Optional Data Type Description
productKey Optional String The product key.
deviceKey Optional String The device key.
assetId Optional 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: productKey, deviceKey, assetId, tslEventKey, and tslEventType. The supported arithmetic operators are “=” and “in”, and the logical operator is “and” and “or”. How to use expression>>
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 createTime. For optimal performance, it is recommended to have not more than 50 records per page. sorters is not supported to sort the response. For more details, see Pagination Request Struct>>
resolveName Optional Boolean
  • true: Restructures the data from output and returns eventName and outputNames.
  • false (default): Does not restructure the data from output. eventName and outputNames values will be blank.

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

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
  }
}

Java SDK Sample

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.api.common.constant.request.Pagination;
import com.envisioniot.enos.connect_service.v2_1.event.SearchEventRequest;
import com.envisioniot.enos.connect_service.v2_1.event.SearchEventResponse;
import com.google.gson.Gson;

public class SearchEvent {
    public static void main(String[] args) {


        String appKey = "yourAppKey";
        String appSecret = "yourAppSecret";

        SearchEventRequest request = new SearchEventRequest();
        Pagination pagination = new Pagination();
        pagination.setPageNo(1);
        pagination.setPageSize(2);
        request.setPagination(pagination);
        request.setOrgId("yourOrgId");
        request.setResolveName(true);
        try {
            SearchEventResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
                    .url("yourServerUrl")
                    .getResponse(request, SearchEventResponse.class);
            Gson gson = new Gson();
            System.out.println(gson.toJson(response));
        } catch (Exception e) {
            System.out.print(e);
        }
    }
}