查看通知模板列表
请求信息
请求行
GET /apis/aiops.alauda.io/v1beta1/notificationtemplates
查看类型为 NotificationTemplate 的资源对象的列表。
请求参数
名称 | 类型 | 是否必填项 | 描述 |
---|---|---|---|
allowWatchBookmarks | boolean | 否 | allowWatchBookmarks 请求使用 BOOKMARK 类型监视事件。没有实现书签的服务器可能会忽略此标志,而书签是由服务器自行发送的。客户端不应该假定书签在任何特定的间隔被返回,也不应该假定服务器将在会话期间发送任何 BOOKMARK 事件。如果这不是 watch 请求,这个字段将被忽略。如果在 apiserver 中未启用特性门 WatchBookmarks,则忽略该字段。 |
continue | string | 否 | 服务器定义的值,⽤于从服务器中查询更多的返回结果。客户端只能从上⼀个查询结果中获取该值。当查询列表时设置了limit 参数,返回结果未包含服务器上可以查询到的所有数据,此时,会返回 continue 参数,并为 continue 参数赋值⼀个 Token。需要查询更多返回结果时,可将 continue 参数及其值作为查询参数查询更多结果。说明:如果列表配置发⽣变化或查询过期,输⼊此查询参数后,会返回 410 错误码,如果继续输⼊该查询参数进⾏查询,返回的查询结果可能不是最新的数据。 |
fieldSelector | string | 否 | 字段选择器,可通过资源对象的字段过滤、筛选资源对象,默认返回所有资源对象。 |
labelSelector | string | 否 | 标签选择器,可通过标签过滤、筛选资源对象,默认返回所有资源对象。 |
limit | integer | 否 | limit 是查询列表请求返回的最大响应数。 如果存在更多项,则服务器会将列表元数据上的 “continue” 字段设置为一个值,该值可与相同的初始查询一起使用用来检索下一组结果。如果所有请求的对象都被过滤掉了,则设置的限制返回的项目数可能少于请求的项目数(最多为零),并且客户端应仅使用 continue 字段的存在来确定是否有更多结果可用。服务器可能选择不支持 limit 参数,并将返回所有可用结果。如果指定了限制,并且 continue 字段为空,则客户端可能会认为没有更多结果可用。如果 watch 为 true,则不支持此字段。 服务器保证使用 continue 时返回的对象与发出单个列表调用无限制地相同,也就是说,在发出第一个请求后,任何创建、修改或删除的对象都不会包含在任何后续的继续请求中。有时这被称为一致快照,并确保使用限制接收非常大结果的较小块的客户端可以确保它们看到所有可能的对象。如果在分块列表期间更新对象,则将返回在计算第一个列表结果时存在的对象版本。 |
resourceVersion | string | 否 | 当指定使用 watch 请求时,将显示在资源的特定版本之后发生的更改。默认从历史开始更改。当为 list 指定时:-如果未设置,则基于 quora -read 标志从远程存储返回结果;-如果它是 0,那么我们只是返回我们目前在缓存,没有保证;-如果设置为非零,那么结果至少与给定的 resourceVersion 一样为最新的值。 |
timeoutSeconds | integer | 否 | list/watch 方法的调用超时时长。这限制了调用的持续时间,不管是否活跃。 |
watch | boolean | 否 | 观察对所描述的资源的更改,并将其作为添加、更新和删除通知的流返回。需要指定 resourceVersion。 |
pretty | string | 否 | 如果为 true,则会将返回结果输出成适合打印的格式。 |
返回信息
Content-Type
application/json
,
application/yaml
状态码: 200
OK
返回体示例
通知模板列表。
{
"apiVersion": "aiops.alauda.io/v1beta1",
"items": [
{
"apiVersion": "aiops.alauda.io/v1beta1",
"kind": "NotificationTemplate",
"metadata": {
"annotations": {
"cpaas.io/creator": "huzl",
"cpaas.io/description": "mail-notice-temp",
"cpaas.io/display-name": "mail-notice-temp",
"cpaas.io/updated-at": "2021-06-17T09:47:44Z"
},
"creationTimestamp": "2021-06-17T09:47:44Z",
"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-17T09:47:44Z"
}
],
"name": "mail-notice-temp",
"resourceVersion": "94755",
"selfLink": "/apis/aiops.alauda.io/v1beta1/notificationtemplates/mail-notice-temp",
"uid": "dd0bdbb6-7af9-4839-8039-56d653547439"
},
"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": "aiops.alauda.io/v1beta1",
"kind": "NotificationTemplate",
"metadata": {
"annotations": {
"cpaas.io/display-name": "notificationtemplate-devops-default"
},
"creationTimestamp": "2021-06-17T08:25:54Z",
"generation": 1,
"labels": {
"cpaas.io/type": "email"
},
"managedFields": [
{
"apiVersion": "aiops.alauda.io/v1beta1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:annotations": {
".": {},
"f:cpaas.io/display-name": {}
},
"f:labels": {
".": {},
"f:cpaas.io/type": {}
}
},
"f:spec": {
".": {},
"f:content": {},
"f:subject": {}
}
},
"manager": "devops-apiserver",
"operation": "Update",
"time": "2021-06-17T08:25:54Z"
}
],
"name": "notificationtemplate-devops-default",
"resourceVersion": "18789",
"selfLink": "/apis/aiops.alauda.io/v1beta1/notificationtemplates/notificationtemplate-devops-default",
"uid": "3047aada-a614-47a2-bd71-00272b8af223"
},
"spec": {
"content": "\n{{- $status := \"SUCCESS\" }}\n{{- $pipelinename := .pipeline.metadata.name }}\n{{- $pipelinenamespace := .pipeline.metadata.namespace }}\n{{- $pipelineconfigname := .pipeline.spec.pipelineConfig.name }}\n{{- $items := .pipeline.status.information.items }}\n\n{{- range $_, $value := $items }}\n\t{{- if eq $value.type \"_Summary\" }}\n\t\t{{- $status = $value.value.status }}\n时间: {{- $value.value.create_date }}\n\t\t{{- if eq $value.value.status \"SUCCESS\" }}\n\n流水线执行成功\n\t\t{{- else if eq $value.value.status \"FAILURE\" }}\n\n流水线执行失败\n\t\t{{- else if eq $value.value.status \"ABORTED\" }}\n\n流水线被取消\n\t\t{{- end }}\n\t{{- end }}\n{{- end }}\n\n{{- if eq $status \"SUCCESS\" }}\n\t{{- range $_, $item := $items }}\n\t\t{{- if eq $item.type \"_Clone\"}}\n\n【{{$item.name}}】\n\ncommitID: {{$item.value.commit_id}}\n\t\t{{- else if eq $item.type \"_Sonar\"}}\n\n【{{$item.name}}】\n\n代码扫描结果: {{$item.value.sonar_url}}\n\t\t{{- else if eq $item.type \"_Maven_Deploy\"}}\n\n【{{$item.name}}】\n\n分发仓库: {{$item.value.maven_package}}\n\t\t{{- else if eq $item.type \"_Docker\"}}\n\n【{{$item.name}}】\n\n构建镜像: {{ range $index, $v := $item.value.build_image }}{{if ne $index 0}}\",\"{{end}}{{$v}}{{end}}\n\t\t{{- else if eq $item.type \"_Deploy\"}}\n\n【{{$item.name}}】\n\n{{if $item.value.createApp}}创建的应用{{else}}更新的应用{{end}}: {{$item.value.serviceName}}\n\t\t{{- else if eq $item.type \"_Sync\"}}\n\n【{{$item.name}}】\n\n同步的源镜像: {{$item.value.source_image}}\n同步的目标镜像: {{$item.value.target_image}}\n\t\t{{- end }}\n\t{{- end }}\n\t{{- range $_, $value := $items }}\n\t\t{{- if ne (printf \"%.1s\" $value.type) \"_\" }}\n\nname: {{$value.name}}\nvalue: {{$value.value}}\ntype: {{$value.type}}\ndesc: {{$value.description}}\n\t\t{{- end }}\n\t{{- end }}\n{{- end}}\n\n\nlink: https://acp35.alauda.cn:10443/console-devops/workspace/{{$pipelinenamespace}}/pipelines/all/{{$pipelineconfigname}}/{{$pipelinename}}",
"subject": "【流水线通知】来自 {{.pipeline.metadata.name}}"
}
},
{
"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": "aiops.alauda.io/v1beta1",
"kind": "NotificationTemplate",
"metadata": {
"annotations": {
"cpaas.io/creator": "huzl",
"cpaas.io/description": "",
"cpaas.io/display-name": "wechat-notice-temp",
"cpaas.io/updated-at": "2021-06-17T09:48:32Z"
},
"creationTimestamp": "2021-06-17T09:48:32Z",
"generation": 1,
"labels": {
"cpaas.io/type": "other"
},
"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:32Z"
}
],
"name": "wechat-notice-temp",
"resourceVersion": "95571",
"selfLink": "/apis/aiops.alauda.io/v1beta1/notificationtemplates/wechat-notice-temp",
"uid": "addab3d6-baa7-4cf8-a4bc-53ae8d4b887c"
},
"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}}"
}
}
],
"kind": "NotificationTemplateList",
"metadata": {
"continue": "",
"resourceVersion": "25881768",
"selfLink": "/apis/aiops.alauda.io/v1beta1/notificationtemplates"
}
}
返回体说明
名称 | 类型 | 描述 |
---|---|---|
apiVersion | string | 查看公共参数 |
items | array |
通知模板列表。更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md
字段路径:items |
items[] | object |
NotificationTemplate 是NotificationTemplate API 的结构,定义了一个通知模板。
字段路径:items[] |
items[].apiVersion | string | 查看公共参数 |
items[].kind | string | 查看公共参数 |
items[].metadata | object | 查看公共参数 |
items[].spec | object |
Spec 定义了模板的内容。
字段路径:items[].spec |
spec.content | string |
显示通知消息的内容模板。
字段路径:items[].spec.content |
spec.subject | string |
渲染通知消息的主题模板。
字段路径:items[].spec.subject |
kind | string | 查看公共参数 |
metadata | object | 查看公共参数 |