Create Alert Content

Create a new alert content.

Prerequisite

Ensure the alert type that the alert content would belong to exists.

Request Format

POST https://{apigw-address}/event-service/v2.1/alert-contents?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

alertContent

Mandatory

GenerateContent Struct

The details of the alert content. For more information, see generateContent Struct>>

GenerateContent Struct

Name

Mandatory/Optional

Data Type

Description

contentId

Mandatory

String

The alert content ID.

contentDesc

Mandatory

StringI18n

Specify the alert content’s description in its respective locale’s language. For more details on the structure and locales supported, see Internationalized name struct>>

modelId

Mandatory

String

The model ID. How to get modelID>>

alertTypeId

Mandatory

String

The alert type ID.

tags

Optional

Map

User-defined tags. (The Key and Value are of String type.) For details, see How to use tags>>

Response Parameters

Name

Data Type

Description

data

String

The alert content ID.

Samples

Request Sample

url: https://{apigw-address}/event-service/v2.1/alert-contents?action=create&orgId=yourOrgId
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": "create"
}

Return Sample

{
    "code": 0,
    "msg": "OK",
    "requestId": "94e0e6e5-10dd-4fcb-a013-331d5869975a",
    "data": "planetTemperature"
}

Java SDK Sample

public void testCreateAlertContent() {
    private static String accessKey = "yourAppAccessKey";
    private static String secretKey = "yourAppSecretKey";
    private static String orgId = "yourOrgId";
    private static String url = "https://{apigw-address}";
    CreateAlertContentRequest request = new CreateAlertContentRequest();
    request.setOrgId(orgId);
    GenerateContent alertContent = new GenerateContent();
    alertContent.setContentId("yourContentId");
    alertContent.setAlertTypeId("yourAlertTypeId");
    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);
    alertContent.setContentDesc(desc);
    Map < String, String > tags = new HashMap < > ();
    tags.put("yourTagKey", "yourTagValue");
    alertContent.setTags(tags);
    alertContent.setModelId("yourModelId");
    request.setAlertContent(alertContent);
    try {
        CreateAlertContentResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
            .url(url)
            .getResponse(request, CreateAlertContentResponse.class);
        Gson gson = new Gson();
        System.out.println(gson.toJson(response));
    } catch (Exception e) {
        e.printStackTrace();
    }
}