Create Alert Type

Create a new alert type.

Request Format

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

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
type Mandatory GenerateType Struct The details of the alert type. For more information, see GenerateType Struct>>

GenerateType Struct

Name Mandatory/Optional Data Type Description
typeId Mandatory String The alert type ID.
typeDesc Mandatory StringI18n Specify the alert type’s description in its respective locale’s language. For more details on the structure and locales supported, see Internationalized name struct>>
tags Optional Map User-defined tags. (The Key and Value are of String type.) For details, see How to use tags>>
parentTypeId Optional String The alert type ID of the parent alert.

Response Parameters

Name Data Type Description
data String The alert type ID.

Samples

Request Sample

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

Return Sample

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

Java SDK Sample

public void testCreateAlertType() {
    private static String accessKey = "yourAppAccessKey";
    private static String secretKey = "yourAppSecretKey";
    private static String orgId = "yourOrgId";
    private static String url = "https://{apigw-address}";
    CreateAlertTypeRequest request = new CreateAlertTypeRequest();
    request.setOrgId(orgId);
    GenerateType type = new GenerateType();
    type.setTypeId("yourAlertTypeId");
    type.setParentTypeId("yourParentTypeId");
    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);
    type.setTypeDesc(desc);
    Map < String, String > tags = new HashMap < > ();
    tags.put("yourTagKey", "yourTagValue");
    type.setTags(tags);
    request.setType(type);
    try {
        CreateAlertTypeResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
            .url(url)
            .getResponse(request, CreateAlertTypeResponse.class);
        Gson gson = new Gson();
        System.out.println(gson.toJson(response));
    } catch (Exception e) {
        e.printStackTrace();
    }
}