Previewing the Email Format of a Message Template
Function
This API is used to preview the email format of a notification template.
URI
POST /v2/{project_id}/{domain_id}/lts/events/notification/templates/view
Parameter | Mandatory | Type | Description |
---|---|---|---|
project_id | Yes | String | Project ID. For details about how to obtain a project ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID. Minimum: 32 Maximum: 32 |
domain_id | Yes | String | Account ID. For details about how to obtain an account ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID. Minimum: 32 Maximum: 32 |
Request Parameters
Parameter | Mandatory | Type | Description |
---|---|---|---|
X-Auth-Token | Yes | String | User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token. Minimum: 1000 Maximum: 2000 |
Content-Type | Yes | String | Set this parameter to application/json;charset=UTF-8. Minimum: 30 Maximum: 30 |
Parameter | Mandatory | Type | Description |
---|---|---|---|
templates | Yes | String | Email template content. Minimum: 2 Maximum: 1024 |
language | Yes | String | Language type, for example, en-us. |
source | Yes | String | Source. The value can only be LTS. Minimum: 3 Maximum: 3 |
subject | No | String | The content of this field is rendered to be used as the title of the message template. |
Response Parameters
Status code: 200
Parameter | Type | Description |
---|---|---|
template | String | The value is an HTML text and needs to be parsed before being displayed. |
subject | String | The title displayed after the field is parsed. It is displayed at the top of the returned HTML text. |
Status code: 500
Parameter | Type | Description |
---|---|---|
error_code | String | Error code. |
error_msg | String | Error message. |
Example Requests
Previewing the email format of a message template
POST https://{endpoint}/v2/{project_id}/{domain_id}/lts/events/notification/templates/view{"templates" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nAlarm source: $event.metadata.resource_provider;\nResource type: $event.metadata.resource_type;\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;\nQuery time: $event.annotations.results[0].time;\nQuery log: $event.annotations.results[0].raw_results;","language" : "en-us","source" : "LTS","subject" : "${region_name}[${event_severity}_${event_type}_${clear_type}] generated an alarm at ${starts_at}"}
Example Responses
Status code: 200
The request is successful.
{"template" : "<style>\n span {\n display: inline-block;\n float: left;\n font-size: 14px;\n }\n\n b {\n display: inline-block;\n float: left;\n color: #252B3A;\n font-size: 14px\n }\n</style>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"\n style=\"font-family:Helvetica,Arial,PingFangSC-Regular,Hiragino Sans GB;border-spacing:0px 14px;font-size:14px;padding-left: 30px;line-height:25px;\">\n <thead>\n <tr style=\"font-size:14px;\">\n <td colspan=\"2\" style=\"line-height:28px;color:#6e6e6e;font-size:14px\">\n <b>Dear </b>\n <b>users</b>\n <b> , </b>\n </td>\n </tr>\n </thead>\n <tr>\n <td colspan=\"2\">\n <span>1 notification has been </span>\n <span>add</span>\n <span> in region </span>\n <span> based on </span>\n <span>alarm rule </span>\n <b>action_rule</b>\n <span>. For more information, go to the LTS console.</span>\n <br>\n <br>\n </td>\n </tr>\n\n <tr style=\"font-size:14px;\">\n <td colspan=\"2\">\n <p style=\"margin-top: -26px;margin-bottom: -20px;\">\n <br>\n <span style=\"color:#252B3A;line-height:24px\">Here are the details.</span>\n </p>\n </td>\n </tr>\n <td><div>Severity: Major;<br>Occurred: 2022-03-21 18:23:20 GMT+08:00;<br>Alarm source: N/A;<br>Resource type: N/A;<br>Resource ID: CCE;<br>Statistical type: by keyword;<br>Expression: N/A;<br>Current value: N/A;<br>Statistical period: N/A;<br>Query time: N/A;<br>Query log: N/A;<br><div/></td>\n </table>","subject" : "[Major_alarm_add] generated an alarm at 2022-03-21 18:23:20 GMT+08:00","header" : {"dingding" : " \n[Major_alarm_add]have a new alert at 2022-03-21 18:23:20 GMT+08:00"}}
Status code: 500
An error is reported when an incorrect domain ID is entered.
{"error_code" : "LTS.2019","error_msg" : "Failed to preview notification template."}
Status Codes
Status Code | Description |
---|---|
200 | The request is successful. |
500 | An error is reported when an incorrect domain ID is entered. |
Error Codes
See Error Codes.
- Function
- URI
- Request Parameters
- Response Parameters
- Example Requests
- Example Responses
- Status Codes
- Error Codes