notification.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 notify
  15. import (
  16. "time"
  17. "yunion.io/x/jsonutils"
  18. "yunion.io/x/onecloud/pkg/apis"
  19. )
  20. type NotificationCreateInput struct {
  21. apis.StatusStandaloneResourceCreateInput
  22. // description: ids or names of receiver
  23. // required: false
  24. // example: {"adfb720ccdd34c638346ea4fa7a713a8", "zhangsan"}
  25. Receivers []string `json:"receivers"`
  26. // description: direct contact, admin privileges required
  27. // required: false
  28. Contacts []string `json:"contacts"`
  29. // description: robots
  30. // example: feishu robot
  31. Robots []string `json:"robots"`
  32. // description: contact type
  33. // required: ture
  34. // example: email
  35. ContactType string `json:"contact_type"`
  36. // description: notification topic
  37. // required: true
  38. // example: IMAGE_ACTIVE
  39. Topic string `json:"topic"`
  40. // description: notification priority
  41. // required: false
  42. // enum: ["fatal","important","nomal"]
  43. // example: normal
  44. Priority string `json:"priority"`
  45. // description: message content or jsonobject
  46. // required: ture
  47. Message string `json:"message"`
  48. // description: notification tag
  49. // required: false
  50. // example: alert
  51. Tag string `json:"tag"`
  52. IgnoreNonexistentReceiver bool `json:"ignore_nonexistent_receiver"`
  53. }
  54. type ReceiveDetail struct {
  55. ReceiverId string `json:"receiver_id"`
  56. ReceiverName string `json:"receiver_name"`
  57. Contact string `json:"contact"`
  58. ReceiverType string `json:"receiver_type"`
  59. SendAt time.Time `json:"sendAt"`
  60. SendBy string `json:"send_by"`
  61. Status string `json:"status"`
  62. FailedReason string `json:"failed_reason"`
  63. }
  64. type NotificationDetails struct {
  65. apis.StatusStandaloneResourceDetails
  66. SNotification
  67. Title string `json:"title"`
  68. Content string `json:"content"`
  69. ReceiveDetails []ReceiveDetail `json:"receive_details"`
  70. TopicType string `json:"topic_type"`
  71. }
  72. type NotificationListInput struct {
  73. apis.StatusStandaloneResourceListInput
  74. ContactType string `json:"contact_type"`
  75. ReceiverId string `json:"receiver_id"`
  76. Tag string `json:"tag"`
  77. TopicType string `json:"topic_type"`
  78. }
  79. type SContact struct {
  80. Contact string `json:"contact"`
  81. ContactType string `json:"contact_type"`
  82. }
  83. type NotificationManagerEventNotifyInput struct {
  84. // description: ids or names of receiver
  85. // required: false
  86. // example: {"adfb720ccdd34c638346ea4fa7a713a8"}
  87. ReceiverIds []string `json:"receiver_ids"`
  88. // description: direct contact, admin privileges required
  89. // required: false
  90. Contacts []SContact `json:"contacts"`
  91. // 消息机器人列表
  92. RobotIds []string `json:"robot_ids"`
  93. // description: contact types
  94. // required: false
  95. // example: email
  96. ContactTypes []string `json:"contact_type"`
  97. // description: notification priority
  98. // required: false
  99. // enum: ["fatal","important","nomal"]
  100. // example: normal
  101. Priority string `json:"priority"`
  102. // description: resource details
  103. // required: ture
  104. ResourceDetails *jsonutils.JSONDict `json:"resource_details"`
  105. // description: event trigger sending notification
  106. // required: true
  107. // example: SERVER_DELETE
  108. Event string `json:"event"`
  109. ResourceType string `json:"resource_type"`
  110. CloudAccountName string `json:"cloud_account_name"`
  111. Action SAction `json:"action"`
  112. // failed,succeed
  113. Result SResult `json:"result"`
  114. // description: day left before the event
  115. // required: false
  116. // example: 0
  117. AdvanceDays int `json:"advance_days"`
  118. // description: domainId of the resource that triggered the event notification
  119. // required: false
  120. // example: default
  121. ProjectDomainId string `json:"project_domain_id"`
  122. // description: projectId of the resource that triggered the event notification
  123. // required: false
  124. // example: f627e09f038645f08ce6880c8d9cb8fd
  125. ProjectId string `json:"project_id"`
  126. IsFailed SResult `json:"is_failed"`
  127. }
  128. type NotificationManagerEventNotifyOutput struct {
  129. FailedList []FailedElem `json:"failed_list"`
  130. }
  131. type FailedElem struct {
  132. ContactType string `json:"contact_type"`
  133. Reason string `json:"reason"`
  134. }
  135. type NotificationManagerContactNotifyInput struct {
  136. // description: ids or names of receiver
  137. // required: false
  138. // example: {"adfb720ccdd34c638346ea4fa7a713a8"}
  139. ReceiverIds []string `json:"receiver_ids"`
  140. // description: contact types
  141. // required: false
  142. // example: email
  143. ContactTypes []string `json:"contact_type"`
  144. // description: resource details
  145. // required: ture
  146. // description: ids of robot
  147. // required: false
  148. // example: {"adfb720ccdd34c638346ea4fa7a713a8"}
  149. RobotIds []string `json:"robot_ids"`
  150. RoleIds []string `json:"role_ids"`
  151. Subject string `json:"subject"`
  152. Body string `json:"body"`
  153. }