Batch Update Alert Tags


Batch update the tags for the specified history and active alerts. The returned structure describes the update results of each alert. If an error message occurs, the error message will be recorded and the rest of the update will continue.

Request Format

POST https://{apigw-address}/alert-service/v2.1/alerts?action=batchUpdateTags

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
alertIds Mandatory String Array A list of the alert IDs.
tags Mandatory Map The user-defined tags to be modified. (The Key and Value are of String type.) For details, see How to use tags.
isPatchUpdate Mandatory Boolean
  • true (default) = Only the fields specified in the parameters are updated. The values of those fields not specified will be retained.
  • false = The fields specified in the parameters are updated. Those fields not specified will have their existing values (if any) deleted.

Response Parameters

Name Data Type Description
data Array of EnosBatchEachData Struct The list of success or failure messages. For the details of an EnosBatchEachData struct, see the table below.
successSize Integer The number of successfully updated active and history alerts.
totalSize Integer The total number of active and history alerts to be updated.

EnosBatchEachData Struct

Name Data Type Description
code Integer
Failed or succeeded to update an alert.
  • 0: succeeded
  • -1: failed
msg String The message will return “OK” if successful. Otherwise it will return the error message.

Samples

Request Sample

url: https://{apigw-address}/alert-service/v2.1/alerts?action=batchUpdateTags&orgId=yourOrgId
method: POST
requestBody:
{
    "alertIds": ["youralertId1", "youralertId2"],
  "isPatchUpdate":false,
    "tags": {
        "Tag999": "999"
    }
}

Return Sample

{
  "code":0,
  "msg":"OK",
  "requestId":"829db237-c850-4c58-a692-64ebe2105309",
  "data":[
    {
      "code":0,
      "msg":"OK",
      "data":null
    },
    {
      "code":0,
      "msg":"OK",
      "data":null
    }
  ],
  "successSize":2,
  "totalSize":2
}

Java SDK Sample

public void testBatchUpdateAlertRecordTags(){
  BatchUpdateAlertTagsRequest request = new BatchUpdateAlertTagsRequest();
  request.setOrgId(orgId);
  List<String> list=new LinkedList<>();
  list.add("20201109a7451eac2ef7b562bd673198e55d0019");
  list.add("20201109a5d050346415305a86a89c817dc1c83f");
  request.setAlertIds(list);

  Map<String,String> map = new HashMap<>();
  map.put("Tag999","88");
  request.setTags(map);
  request.setIsPatchUpdate(false);
  try {
      BatchUpdateAlertTagsResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
              .url(url)
              .getResponse(request, BatchUpdateAlertTagsResponse.class);
      System.out.println(response);
  }
  catch(Exception e){
      System.out.print(e);
  }
}