Update Alert Type


更新告警类型。需要校验的字段为typeId。如果告警类型已经有了父告警类型(parentTypeId),则该父告警类型不能被修改。

请求格式

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

请求参数(URI)

名称 位置(Path/Query) 必需/可选 数据类型 描述
orgId Query 必需 String 资产所属的组织ID。如何获取orgId信息>>
isPatchUpdate Query 必需 Boolean 是否全量更新。 当其值为 true 时,只更新参数中指定字段的值; 当其值为 false 时,更新所有字段的值,即未指定值的字段将被置空。

请求参数(Body)

名称 必需/可选 数据类型 描述
type 必需 GenerateType结构体 告警类型,见 GenerateType结构体

GenerateType结构体

名称 必需/可选 数据类型 描述
typeId 必需 String 告警类型编号
typeDesc 必需 StringI18n 国际化告警类型描述,其中default必填。结构请见 国际化名称结构体>>
tags 可选 tags数据类型 告警类型的标签。详见 标签的作用与表示方法>>
parentTypeId 可选 String 父告警类型编号。如果为 null ,那么它本身就是父类型告警类型。

示例

请求示例

url: https://{apigw-address}/event-service/v2.1/alert-types?action=update&orgId=yourOrgId&isPatchUpdate=false
method: POST
requestBody:
{
  "action": "update",
    "type":{
        "typeId":"planetTemperature",
        "typeDesc":{
            "defaultValue":"OverLimit",
            "parentTypeId":"parent",
            "i18nValue":{
                "en_US":"OverLimit",
                "zh_CN":"超限"
            }
        },
        "tags":{
            "year":"2000",
            "author":"cshan"
        },
    "parentTypeId": "chenchen_test_documentation"
    }
}

返回示例

{
    "code": 0,
    "msg": "OK",
    "requestId": "4873095e-621d-4cfd-bc2c-edb520f574ea",
    "data": null
}

Java SDK调用示例

public void testUpdateAlertType() {
    UpdateAlertTypeRequest request = new UpdateAlertTypeRequest();
    request.setOrgId(orgId);
    GenerateType generateType = new GenerateType();
    generateType.setParentTypeId("yourParentTypeId"); //如果该告警已有父类型,则不能修改其父类型
    generateType.setTypeId("yourTypeId");
    StringI18n desc = new StringI18n();
    desc.setDefaultValue("default");
    Map < String, String > map = new HashMap < > ();
    map.put("zh_CN", "中文");
    map.put("en_US", "english");
    desc.setI18nValue(map);
    generateType.setTypeDesc(desc);
    Map < String, String > tags = new HashMap < > ();
    tags.put("yourTagKey", "yourTagValue");
    generateType.setTags(tags);
    request.setType(generateType);
    request.setIsPatchUpdate(true);
    try {
        UpdateAlertTypeResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
            .url(url)
            .getResponse(request, UpdateAlertTypeResponse.class);
        Gson gson = new Gson();
        System.out.println(gson.toJson(response));
    } catch (Exception e) {
        e.printStackTrace();
    }
}