Home / API Documentation / Operations center / Templates / Update notification template

Update notification template

Requests

HTTP request

PUT /apis/aiops.alauda.io/v1beta1/notificationtemplates/{name}

replace the specified NotificationTemplate

Path parameters

Name Type Required Description
name string Truename of the NotificationTemplate

Query parameters

Name Type Required Description
dryRun string FalseWhen present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
fieldManager string FalsefieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint.
pretty string FalseIf 'true', then the output is pretty printed.

Request body

Content-Type application/json, application/yaml

Sample request

NotificationTemplate is the Schema for the templates API NotificationTemplate define a notification template to template notification

{
   "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}}"
   }
 }

Parmeters

Name Type Required Description
apiVersion string TrueSee common parameters
kind string TrueSee common parameters
metadata object TrueSee common parameters
spec object True Spec define the content of a template
Path: spec
spec.content string True Content template to render notification message
Path: spec.content
spec.subject string True Subject template to render notification message
Path: spec.subject

Responses

Content-Type application/json, application/yaml

Status code: 200

OK

Sample response

NotificationTemplate is the Schema for the templates API NotificationTemplate define a notification template to template notification

{
   "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}}"
   }
 }

Parameters

Name Type Description
apiVersion string See common parameters
kind string See common parameters
metadata object See common parameters
spec object Spec define the content of a template
Path: spec
spec.content string Content template to render notification message
Path: spec.content

Other status codes

Status code: 201

Created

Status code: 401

Unauthorized