Update Alert Tags


Update history and active alert tags.

Request Format

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

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
alertId Mandatory String The alert ID.
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 Integer The number of updated entries.

Samples

Request Sample

url: https://{apigw-address}/alert-service/v2.1/alerts?action=updateTags&orgId=yourOrgId
method: POST
{
    "alertId":"20201109a7451eac2ef7b562bd673198e55d0019",
    "isPatchUpdate":true,
    "tags":{
        "tag2":"ok"
    }
}

Return Sample

{
    "code":0,
    "msg":"OK",
    "requestId":"4c69be41-c8b8-4e48-9a79-16af759c35e7",
    "data":1
}

Java SDK Sample

public void testUpdateAlertRecordTags(){

  UpdateAlertTagsRequest request = new UpdateAlertTagsRequest();
  request.setOrgId(orgId);
  request.setAlertId("20201109a7451eac2ef7b562bd673198e55d0019");
  Map<String,String> map = new HashMap<>();
  map.put("tag2","ok");
  request.setTags(map);
  request.setIsPatchUpdate(true);
  try {
      UpdateAlertTagsResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
              .url(url)
              .getResponse(request, UpdateAlertTagsRequest.class);
      System.out.println(response);
  }
  catch(Exception e){
      System.out.print(e);
  }
}