更新通知模板
请求信息
请求行
PUT /apis/aiops.alauda.io/v1beta1/notificationtemplates/{name}
更新指定的通知模板。
请求行参数
名称 | 类型 | 是否必填项 | 描述 |
---|---|---|---|
name | string | 是 | 通知模板的名称。 |
请求参数
名称 | 类型 | 是否必填项 | 描述 |
---|---|---|---|
dryRun | string | 否 | 当该参数出现时,表示不应该持久化修改。一个无效的或无法识别的 dryRun 指令将导致错误响应,并且不会进一步处理请求。有效值为:All,将处理所有的试运行阶段。 |
fieldManager | string | 否 | fieldManager 是与正在进行这些更改的参与者或实体相关联的名称。值必须少于 128 字符,且仅包含可打印字符,参见 https://golang.org/pkg/unicode/#IsPrint。 |
pretty | string | 否 | 如果为 true,则会将返回结果输出成适合打印的格式。 |
请求体
Content-Type
application/json
,
application/yaml
请求体示例
NotificationTemplate 是NotificationTemplate API 的结构,定义了一个通知模板。
{
"apiVersion": "aiops.alauda.io/v1beta1",
"kind": "NotificationTemplate",
"metadata": {
"annotations": {
"cpaas.io/creator": "admin@cpaas.io",
"cpaas.io/description": "template",
"cpaas.io/display-name": "template",
"cpaas.io/updated-at": "2021-06-23T10:01:40Z"
},
"creationTimestamp": "2021-06-23T10:01:40Z",
"generation": 1,
"labels": {
"cpaas.io/message-type": "html",
"cpaas.io/type": "email"
},
"managedFields": [
{
"apiVersion": "aiops.alauda.io/v1beta1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:annotations": {
".": {},
"f:cpaas.io/description": {},
"f:cpaas.io/display-name": {}
},
"f:labels": {
".": {},
"f:cpaas.io/message-type": {},
"f:cpaas.io/type": {}
}
},
"f:spec": {
".": {},
"f:content": {},
"f:subject": {}
}
},
"manager": "Mozilla",
"operation": "Update",
"time": "2021-06-23T10:01:40Z"
}
],
"name": "template",
"resourceVersion": "25995530",
"selfLink": "/apis/aiops.alauda.io/v1beta1/notificationtemplates/template",
"uid": "7a6512c5-fe53-46db-8f08-7b20de605a41"
},
"spec": {
"content": "{{- if eq .externalLabels.status \"告警中\" }}\n\u003cdiv\u003e\u003cfont\u003e\n \u003cdiv style=\"font-family: \"lucida Grande\", Verdana;\"\u003e\n \u003cdiv\u003e告警状态:\u003cfont color=\"#FF0000\"\u003e{{ .externalLabels.status }}\u003c/font\u003e\u003c/div\u003e\n \u003cdiv\u003e告警等级:{{ .externalLabels.severity }}\u003c/div\u003e\n \u003cdiv\u003e告警集群:{{ .labels.alert_cluster }}\u003c/div\u003e\n \u003cdiv\u003e告警对象:{{ .externalLabels.object }}\u003c/div\u003e\n \u003cdiv\u003e策略名称:{{ .labels.alert_resource }}\u003c/div\u003e\n \u003cdiv\u003e告警描述:{{ .externalLabels.summary }}\u003c/div\u003e\n \u003cdiv\u003e触发数值:\u003cfont color=\"#FF0000\"\u003e{{ .externalLabels.currentValue }}\u003c/font\u003e\u003c/div\u003e\n \u003cdiv\u003e告警时间:{{ dateFormatWithZone .startsAt \"2006-01-02 15:04:05\" \"Asia/Chongqing\" }}\u003c/div\u003e\n \u003c/div\u003e\n \u003c/font\u003e\n\u003c/div\u003e\n{{- else }}\n\u003cdiv\u003e\u003cfont\u003e\n \u003cdiv style=\"font-family: \"lucida Grande\", Verdana;\"\u003e\n \u003cdiv\u003e告警状态:\u003cfont color=\"##00FF00\"\u003e{{ .externalLabels.status }}\u003c/font\u003e\u003c/div\u003e\n \u003cdiv\u003e告警等级:{{ .externalLabels.severity }}\u003c/div\u003e\n \u003cdiv\u003e告警集群:{{ .labels.alert_cluster }}\u003c/div\u003e\n \u003cdiv\u003e告警对象:{{ .externalLabels.object }}\u003c/div\u003e\n \u003cdiv\u003e策略名称:{{ .labels.alert_resource }}\u003c/div\u003e\n \u003cdiv\u003e告警描述:{{ .externalLabels.summary }}\u003c/div\u003e\n \u003cdiv\u003e触发数值:\u003cfont color=\"###00FF00\"\u003e{{ .externalLabels.currentValue }}\u003c/font\u003e\u003c/div\u003e\n \u003cdiv\u003e告警时间:{{ dateFormatWithZone .startsAt \"2006-01-02 15:04:05\" \"Asia/Chongqing\" }}\u003c/div\u003e\n \u003cdiv\u003e恢复时间:{{ dateFormatWithZone .endsAt \"2006-01-02 15:04:05\" \"Asia/Chongqing\" }}\u003c/div\u003e\n \u003c/div\u003e\n \u003c/font\u003e\n\u003c/div\u003e\n{{- end}}\n\u003cdiv\u003e\u003cincludetail\u003e\u003c!--\u003c![endif]--\u003e\u003c/includetail\u003e\u003c/div\u003e",
"subject": "【{{.externalLabels.status}}】PAAS 平台告警:{{.externalLabels.object}}的{{.externalLabels.summary}}"
}
}
请求体说明
名称 | 类型 | 是否必填项 | 描述 |
---|---|---|---|
apiVersion | string | 是 | 查看公共参数 |
kind | string | 是 | 查看公共参数 |
metadata | object | 是 | 查看公共参数 |
spec | object | 是 |
Spec 定义了模板的内容。
字段路径:spec |
spec.content | string | 是 |
显示通知消息的内容模板。
字段路径:spec.content |
spec.subject | string | 是 |
渲染通知消息的主题模板。
字段路径:spec.subject |
返回信息
Content-Type
application/json
,
application/yaml
状态码: 200
OK
返回体示例
NotificationTemplate 是NotificationTemplate API 的结构,定义了一个通知模板。
{
"apiVersion": "aiops.alauda.io/v1beta1",
"kind": "NotificationTemplate",
"metadata": {
"annotations": {
"cpaas.io/description": "sms-notice-temp-update",
"cpaas.io/display-name": "sms-notice-temp-update",
"cpaas.io/operator": "huzl",
"cpaas.io/updated-at": "2021-06-17T09:50:09Z"
},
"creationTimestamp": "2021-06-17T09:48:05Z",
"generation": 1,
"labels": {
"cpaas.io/type": "sms"
},
"managedFields": [
{
"apiVersion": "aiops.alauda.io/v1beta1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:annotations": {
".": {},
"f:cpaas.io/description": {},
"f:cpaas.io/display-name": {}
},
"f:labels": {
".": {},
"f:cpaas.io/type": {}
}
},
"f:spec": {
".": {},
"f:content": {}
}
},
"manager": "Mozilla",
"operation": "Update",
"time": "2021-06-17T09:48:05Z"
}
],
"name": "sms-notice-temp",
"resourceVersion": "97181",
"selfLink": "/apis/aiops.alauda.io/v1beta1/notificationtemplates/sms-notice-temp",
"uid": "f06c1835-eba7-4251-b459-62eeb800a31e"
},
"spec": {
"content": "{{- if eq .externalLabels.status \"告警中\" }}\n告警状态:{{ .externalLabels.status }}\n告警等级:{{ .externalLabels.severity }}\n告警集群:{{ .labels.alert_cluster }}\n告警对象:{{ .externalLabels.object }}\n策略名称:{{ .labels.alert_resource }}\n告警描述:{{ .externalLabels.summary }}\n触发数值:{{ .externalLabels.currentValue }}\n告警时间:{{ dateFormatWithZone .startsAt \"2006-01-02 15:04:05\" \"Asia/Chongqing\" }}\n{{- else }}\n告警状态:{{ .externalLabels.status }}\n告警等级:{{ .externalLabels.severity }}\n告警集群:{{ .labels.alert_cluster }}\n告警对象:{{ .externalLabels.object }}\n策略名称:{{ .labels.alert_resource }}\n告警描述:{{ .externalLabels.summary }}\n触发数值:{{ .externalLabels.currentValue }}\n告警时间:{{ dateFormatWithZone .startsAt \"2006-01-02 15:04:05\" \"Asia/Chongqing\" }}\n恢复时间:{{ dateFormatWithZone .endsAt \"2006-01-02 15:04:05\" \"Asia/Chongqing\" }}\n{{- end}}"
}
}
返回体说明
名称 | 类型 | 描述 |
---|---|---|
apiVersion | string | 查看公共参数 |
kind | string | 查看公共参数 |
metadata | object | 查看公共参数 |
spec | object |
Spec 定义了模板的内容。
字段路径:spec |
spec.content | string |
显示通知消息的内容模板。
字段路径:spec.content |