Update Alert Content¶
更新告警内容。需要校验的字段为modelId和alertTypeId。
请求格式¶
POST https://{apigw-address}/event-service/v2.1/alert-contents?action=update
请求参数(URI)¶
名称  | 
位置(Path/Query)  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|---|
orgId  | 
Query  | 
必需  | 
String  | 
资产所属的组织ID。 如何获取orgId信息>>  | 
isPatchUpdate  | 
Query  | 
必需  | 
Boolean  | 
是否全量更新。
+ 当其值为   | 
请求参数(Body)¶
名称  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|
alertContent  | 
必需  | 
GenerateContent结构体  | 
告警内容,见 generateContent结构体>>  | 
generateContent结构体  ¶
名称  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|
contentId  | 
必需  | 
String  | 
告警内容编号。  | 
contentDesc  | 
必需  | 
String  | 
告警内容描述。  | 
modelId  | 
必需  | 
String  | 
告警内容所适用模型的ID。 如何获取modelId信息>>  | 
alertTypeId  | 
必需  | 
String  | 
关联的告警类型编号。  | 
tags  | 
可选  | 
Map  | 
标签,只支持全量更新。 详情见 标签的作用与表示方法>>  | 
示例¶
请求示例¶
url: https://{apigw-address}/event-service/v2.1/alert-contents?action=update&orgId=yourOrgId&isPatchUpdate=false
method: POST
requestBody:
{
    "alertContent": {
        "contentId": "planetTemperature",
        "contentDesc": {
            "defaultValue": "Grid is connected from converter",
            "i18nValue": {
                "en_US": "Grid is connected from converter",
                "zh_CN": "风机已并网"
            }
        },
        "modelId": "WindDev-E0",
        "alertTypeId": "9001",
        "tags": {
            "year": "2000",
            "author": "cshan"
        }
    },
  "action": "update"
}
返回示例¶
{
    "code": 0,
    "msg": "OK",
    "requestId": "4873095e-621d-4cfd-bc2c-edb520f574ea",
    "data": null
}
Java SDK 调用示例¶
public void testUpdateAlertContent() {
    private static String accessKey = "yourAppAccessKey";
    private static String secretKey = "yourAppSecretKey";
    private static String orgId = "yourOrgId";
    private static String url = "https://{apigw-address}";
    UpdateAlertContentRequest request = new UpdateAlertContentRequest();
    request.setOrgId(orgId);
    GenerateContent generateContent = new GenerateContent();
    generateContent.setContentId("yourContentId");
    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);
    generateContent.setContentDesc(desc);
    Map < String, String > tags = new HashMap < > ();
    tags.put("yourTagKey", "yourTagValue");
    generateContent.setTags(tags);
    request.setAlertContent(generateContent);
    request.setIsPatchUpdate(true);
    try {
        UpdateAlertContentResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
            .url(url)
            .getResponse(request, UpdateAlertContentResponse.class);
        Gson gson = new Gson();
        System.out.println(gson.toJson(response));
    } catch (Exception e) {
        e.printStackTrace();
    }
}