创建通知模板
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
cms:CreateAlertNotifyTemplate |
create |
*全部资源
|
无 | 无 |
请求语法
POST /alertNotifyTemplate HTTP/1.1
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| body |
object |
否 |
请求体。 |
|
| alertNotifyTemplateName |
string |
否 |
通知模板名称。 |
test |
| alertNotifyTemplateId |
string |
否 |
通知模板 ID。 |
test |
| type |
string |
否 |
通知渠道类型。支持:
枚举值:
|
DING |
| programLang |
string |
否 |
模板语法类型。当前支持 GO,title、content 中的模板使用 Go template 语法。 |
GO |
| templates |
object |
否 |
多语言通知模板。key 为语言代码:zh(中文)、en(英文);value 为该语言的模板配置对象。发送通知时按收件人语言选择对应模板。正文格式随 type 不同:DING、WEIXIN、FEISHU 为 Markdown,EMAIL 为 HTML,SMS、CALL、SLACK 为纯文本,CUSTOM 为 JSON。 |
{"zh":{"title":"云监控报警: {{.incident.title}}","content":"**报警标题:** {{.incident.title}}\n**级别:** {{.incident.severity}}\n**事件数:** {{len .events}}","incidentLifeCycleNotifyTemplates":"{\"IncidentCreationNotify\":{\"title\":\"云监控报警: {{.incident.title}}\",\"content\":\"**报警标题:** {{.incident.title}}\\n**级别:** {{.incident.severity}}\",\"enable\":true},\"IncidentResolutionNotify\":{\"title\":\"云监控报警已解决: {{.incident.title}}\",\"content\":\"**报警标题:** {{.incident.title}}\\n**级别:** {{.incident.severity}}\",\"enable\":true}}"},"en":{"title":"CloudMonitor Alert: {{.incident.title}}","content":"**Alert Title:** {{.incident.title}}\n**Severity:** {{.incident.severity}}\n**Events:** {{len .events}}","incidentLifeCycleNotifyTemplates":"{\"IncidentCreationNotify\":{\"title\":\"CloudMonitor Alert: {{.incident.title}}\",\"content\":\"**Alert Title:** {{.incident.title}}\\n**Severity:** {{.incident.severity}}\",\"enable\":true},\"IncidentResolutionNotify\":{\"title\":\"CloudMonitor Alert Resolved: {{.incident.title}}\",\"content\":\"**Alert Title:** {{.incident.title}}\\n**Severity:** {{.incident.severity}}\",\"enable\":true}}"}} |
|
object |
否 |
指定语言的模板配置对象,可包含 title(标题模板)、content(正文模板)和 incidentLifeCycleNotifyTemplates(按问题生命周期事件配置的 JSON 字符串)。事件类型支持 IncidentCreationNotify(问题创建)、IncidentCycleNotify(问题未恢复期间按重复通知间隔发送)、IncidentResolutionNotify(问题恢复)、IncidentEscalationNotify(问题升级)。未配置的字段或事件使用系统默认模板。 |
{"title":"云监控报警: {{.incident.title}}","content":"**报警标题:** {{.incident.title}}\n**级别:** {{.incident.severity}}\n**事件数:** {{len .events}}","incidentLifeCycleNotifyTemplates":"{\"IncidentCreationNotify\":{\"title\":\"云监控报警: {{.incident.title}}\",\"content\":\"**报警标题:** {{.incident.title}}\\n**级别:** {{.incident.severity}}\",\"enable\":true},\"IncidentResolutionNotify\":{\"title\":\"云监控报警已解决: {{.incident.title}}\",\"content\":\"**报警标题:** {{.incident.title}}\\n**级别:** {{.incident.severity}}\",\"enable\":true}}"} |
|
|
string |
否 |
模板字段值,均为字符串。title、content 直接填写 Go template 模板;incidentLifeCycleNotifyTemplates 填写 JSON 字符串,例如 {"IncidentCreationNotify":{"title":"...","content":"...","enable":true}},每个事件包含 title、content 和 enable。事件未配置或 enable 为 false 时,回退使用同语言的 title、content,仍为空时使用系统默认模板。可用 Go template 变量如 {{.incident.title}}、{{.incident.severity}}、{{.incident.state}}、{{len .events}}。 |
云监控报警: {{.incident.title}} |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
响应内容结构 |
||
| requestId |
string |
请求 ID。 |
8A33DBEA-*****-*****-*****-***** |
| alertNotifyTemplateId |
string |
通知模板 ID。 |
testId |
示例
正常返回示例
JSON格式
{
"requestId": "8A33DBEA-*****-*****-*****-*****",
"alertNotifyTemplateId": "testId"
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | ResourceExist | Resource already exist . | 资源已经存在。 |
| 400 | InvalidParameter | %s is missing or invalid. | 参数%s缺失或不合法。 |
| 400 | InvalidParameterValue | Invalid request: %s | |
| 500 | InternalUnknownError | The request processing has failed due to some unknown error. | 服务运行错误。 |
| 404 | ResourceNotFound | The specified resource is not found. | 未找到指定资源。 |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。