Search Alert Type


分页查询告警类型。

请求格式

POST https://{apigw-address}/event-service/v2.1/alert-types?action=search

请求参数(URI)

名称 位置(Path/Query) 必需/可选 数据类型 描述
orgId Query 必需 String 资产所属的组织 ID。 如何获取 orgId 信息>>

请求参数(Body)

名称 必需/可选 数据类型 描述
expression 可选 String

查询表达式,支持类 SQL 的查询。目前支持的逻辑运算是 and 和 or,查询的字段和对应的运算符清单如下。

  • typeIdparentTypeId: = 和 in。
  • tags.*: =。注:EnOS Edge 不支持 tag 相关的查询。

字段描述参见 AlertType 结构体

如何使用查询表达式>>

pagination 可选 Pagination 请求结构体 分页的参数。如未指定,默认每页 10 条。每页最大记录数为 1000 条,但为获得最佳性能,建议每页不超过 50 条。默认按照 updateTime ,最近创建的告警类型靠前排列。支持使用 sorters 参数,按照 typeIdparentTypeId 对结果进行排序。Pagination 请求结构体>>

响应参数

名称 数据类型 描述
data AlertType 结构体数组 告警类型数组。有关 AlertType 结构体的定义,AlertType 结构体>>

AlertType 结构体

名称 数据类型 描述
typeId String 告警类型 ID。
typeDesc StringI18n 告警类型描述。
orgId String 资产所属的组织 ID。
parentTypeId String 父告警类型编号。如果为 null ,那么它本身就是父类型告警类型。
tags Tag 结构体 标签。
updatePerson String 更新人。
updateTime Long 更新的 UTC 时间。

输入输出示例

请求示例

url: https://{apigw-address}/event-service/v2.1/alert-types?action=search&orgId=yourOrgId
method: POST
requestBody:
{
    "pagination": {
        "pageNo": 1,
        "pageSize": 1,
        "sorters": [{
            "field": "typeId",
            "order": "DESC"
        }]
    },
  "action": "search"
}

返回示例

{
    "pagination": {
        "pageNo": 1,
        "pageSize": 1,
        "totalSize": 14,
        "sortedBy": [{
            "field": "typeId",
            "order": "DESC"
        }]
    },
    "code": 0,
    "msg": "OK",
    "requestId": "c1be09d8-a6f2-4647-92e1-3c545fa1b3dd",
    "data": [{
        "typeId": "dateType",
        "orgId": "yourOrgId",
        "typeDesc": {
            "i18nValue": {
        "defaultValue": null,
                "en_US": "dateType desc",
                "zh_CN": ""
            }
        },
        "tags": {
        },
        "updatePerson": "yj_test_customer",
        "updateTime": 1546612655000
    }]
}

Java SDK 调用示例

public void testSearchAlertType() {
    SearchAlertTypeRequest request = new SearchAlertTypeRequest();
    request.setOrgId(orgId);
    Pagination pagination = new Pagination();
    pagination.setPageNo(1);
    pagination.setPageSize(1);
    List < Sorter > sorterList = new ArrayList < > ();
    sorterList.add(new Sorter("typeId", Sorter.Order.DESC));
    pagination.setSorters(sorterList);
    request.setPagination(pagination);
    try {
        SearchAlertTypeResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
            .url("https://{apigw-address}")
            .getResponse(request, SearchAlertTypeResponse.class);
        Gson gson = new Gson();
        System.out.println(gson.toJson(response));
    } catch (Exception e) {
        e.printStackTrace();
    }
}