notification.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package monitor
  15. import (
  16. "time"
  17. "yunion.io/x/jsonutils"
  18. "yunion.io/x/onecloud/pkg/apis"
  19. )
  20. type AlertNotificationStateType string
  21. var (
  22. AlertNotificationStatePending = AlertNotificationStateType("pending")
  23. AlertNotificationStateCompleted = AlertNotificationStateType("completed")
  24. AlertNotificationStateUnknown = AlertNotificationStateType("unknown")
  25. )
  26. const (
  27. AlertNotificationTypeOneCloud = "onecloud"
  28. AlertNotificationTypeDingding = "dingding"
  29. AlertNotificationTypeFeishu = "feishu"
  30. AlertNotificationTypeAutoScaling = "autoscaling"
  31. AlertNotificationTypeAutoMigration = "automigration"
  32. )
  33. type NotificationCreateInput struct {
  34. apis.Meta
  35. // 报警通知名称
  36. Name string `json:"name"`
  37. // 类型
  38. Type string `json:"type"`
  39. // 是否为默认通知配置
  40. IsDefault bool `json:"is_default"`
  41. // 是否一直提醒
  42. SendReminder *bool `json:"send_reminder"`
  43. // 是否禁用报警恢复提醒
  44. DisableResolveMessage *bool `json:"disable_resolve_message"`
  45. // 发送频率 单位:s
  46. Frequency time.Duration `json:"frequency"`
  47. // 通知配置
  48. Settings jsonutils.JSONObject `json:"settings"`
  49. }
  50. type NotificationUpdateInput struct {
  51. apis.Meta
  52. // 报警通知名称
  53. Name string `json:"name"`
  54. // 是否为默认通知配置
  55. IsDefault *bool `json:"is_default"`
  56. // 是否一直提醒
  57. SendReminder *bool `json:"send_reminder"`
  58. // 是否禁用报警恢复提醒
  59. DisableResolveMessage *bool `json:"disable_resolve_message"`
  60. // 发送频率
  61. Frequency *time.Duration `json:"frequency"`
  62. }
  63. type NotificationListInput struct {
  64. apis.VirtualResourceListInput
  65. // 类型
  66. Type string `json:"type"`
  67. }
  68. type NotificationSettingOneCloud struct {
  69. Channel string `json:"channel"`
  70. UserIds []string `json:"user_ids"`
  71. RobotIds []string `json:"robot_ids"`
  72. RoleIds []string `json:"role_ids"`
  73. }
  74. type SendWebhookSync struct {
  75. Url string `json:"url"`
  76. User string `json:"user"`
  77. Password string `json:"password"`
  78. Body string `json:"body"`
  79. HttpMethod string `json:"http_method"`
  80. HttpHeader map[string]string `json:"http_header"`
  81. ContentType string `json:"content_type"`
  82. }
  83. type NotificationSettingDingding struct {
  84. Url string `json:"url"`
  85. MessageType string `json:"message_type"`
  86. }
  87. type NotificationSettingFeishu struct {
  88. // Url string `json:"url"`
  89. AppId string `json:"app_id"`
  90. AppSecret string `json:"app_secret"`
  91. }
  92. type NotificationSettingAutoMigration struct {
  93. AlertId string `json:"alert_id"`
  94. }