scheduled_task.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 scheduledtask
  15. import (
  16. "time"
  17. "yunion.io/x/onecloud/pkg/apis"
  18. )
  19. type ScheduledTaskDetails struct {
  20. apis.VirtualResourceDetails
  21. SScheduledTask
  22. // 描述
  23. TimerDesc string `json:"timer_desc"`
  24. // 定时方式触发
  25. Timer TimerDetails `json:"timer"`
  26. // 周期方式触发
  27. CycleTimer CycleTimerDetails `json:"cycle_timer"`
  28. // 绑定的所有标示
  29. Labels []string `json:"labels,allowempty"`
  30. LabelDetails []LabelDetail `json:"label_details,allowempty"`
  31. }
  32. type TimerDetails struct {
  33. // description: 执行时间
  34. ExecTime time.Time `json:"exec_time"`
  35. }
  36. type CycleTimerDetails struct {
  37. // description: 周期类型:按天/周/月
  38. CycleType string `json:"cycle_type"`
  39. // description: 分钟
  40. Minute int `json:"minute"`
  41. // description: 小时
  42. Hour int `json:"hour"`
  43. // description: 每周的几天
  44. WeekDays []int `json:"week_days"`
  45. // description: 每月的几天
  46. MonthDays []int `json:"month_days"`
  47. // description: 此周期任务的开始时间
  48. StartTime time.Time `json:"start_time"`
  49. // description: 此周期任务的截止时间
  50. EndTime time.Time `json:"end_time"`
  51. }
  52. type LabelDetail struct {
  53. Label string `json:"label"`
  54. IsolatedTime time.Time `json:"isolated_time"`
  55. }
  56. type ScheduledTaskListInput struct {
  57. apis.VirtualResourceListInput
  58. apis.EnabledResourceBaseListInput
  59. // description: resource type
  60. // example: server
  61. // enum: ["server"]
  62. ResourceType string `json:"resource_type"`
  63. // description: label type
  64. // example: tag
  65. LabelType string `json:"label_type"`
  66. // description: filter scheduledtask binded with label
  67. // example: g-12345
  68. Label string `json:"label"`
  69. // description: operation
  70. // example: stop
  71. // enum: ["start","stop","restart"]
  72. Operation string `json:"operation"`
  73. }
  74. type ScheduledTaskCreateInput struct {
  75. apis.VirtualResourceCreateInput
  76. apis.EnabledBaseResourceCreateInput
  77. // description: scheduled type
  78. // enum: ["cycle","timing"]
  79. // example: timing
  80. ScheduledType string `json:"scheduled_type"`
  81. Timer TimerCreateInput `json:"timer"`
  82. CycleTimer CycleTimerCreateInput `json:"cycle_timer"`
  83. // description: resource type
  84. // enum: ["server"]
  85. // example: server
  86. ResourceType string `json:"resource_type"`
  87. // description: operation
  88. // enum: ["start","stop","restart"]
  89. // example: stop
  90. Operation string `json:"operation"`
  91. // description: label type
  92. // enum: ["tag","id"]
  93. // example: id
  94. LabelType string `json:"label_type"`
  95. // description: labels
  96. // example: {g-12345}
  97. Labels []string `json:"labels"`
  98. }
  99. type TimerCreateInput struct {
  100. // description: 执行时间
  101. ExecTime time.Time `json:"exec_time"`
  102. }
  103. type CycleTimerCreateInput struct {
  104. // description: 周期类型
  105. // enum: ["hour","day","week","month"]
  106. CycleType string `json:"cycle_type"`
  107. // description: 分(0-59)
  108. // example: 13
  109. Minute int `json:"minute"`
  110. // description: 时(0-23)
  111. // example: 13
  112. Hour int `json:"hour"`
  113. // 频率为小时或天时启用,泛指间隔单位
  114. // example: 2
  115. CycleNum int `json:"cycle_num"`
  116. // description: 每周的周几; 1-7, 1: Monday, 7: Sunday
  117. // example: [1,3,5,7]
  118. WeekDays []int `json:"week_days"`
  119. // description: 每月的哪几天; 1-31
  120. // example: [1,4,31]
  121. MonthDays []int `json:"month_days"`
  122. // description: 开始时间
  123. StartTime time.Time `json:"start_time"`
  124. // description: 截止时间
  125. EndTime time.Time `json:"end_time"`
  126. }
  127. type ScheduledTaskResourceInfo struct {
  128. // description: 定时任务名称
  129. // example: st-nihao
  130. ScheduledTask string `json:"scheduled_task"`
  131. // description: 定时任务ID
  132. // example: 1234
  133. ScheduledTaskId string `json:"scheduled_task_id"`
  134. }
  135. type ScheduledTaskFilterListInput struct {
  136. // description: 定时任务 Id or Name
  137. // example: st-1234
  138. ScheduledTask string `json:"scheduled_task"`
  139. }
  140. type ScheduledTaskActivityDetails struct {
  141. apis.StatusStandaloneResourceDetails
  142. SScheduledTaskActivity
  143. }
  144. type ScheduledTaskActivityListInput struct {
  145. apis.StatusStandaloneResourceListInput
  146. // description: 定时任务 ID or Name
  147. // example: st-11212
  148. ScheduledTask string `json:"scheduled_task"`
  149. }
  150. type ScheduledTaskSetLabelsInput struct {
  151. Labels []string `json:"labels"`
  152. }
  153. type ScheduledTaskTriggerInput struct {
  154. }