topic.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. // Copyright 2019 Yunion
  15. // Licensed under the Apache License, Version 2.0 (the "License");
  16. // you may not use this file except in compliance with the License.
  17. // You may obtain a copy of the License at
  18. //
  19. // http://www.apache.org/licenses/LICENSE-2.0
  20. //
  21. // Unless required by applicable law or agreed to in writing, software
  22. // distributed under the License is distributed on an "AS IS" BASIS,
  23. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  24. // See the License for the specific language governing permissions and
  25. // limitations under the License.
  26. package notify
  27. import (
  28. "yunion.io/x/jsonutils"
  29. "yunion.io/x/onecloud/pkg/mcclient/options"
  30. )
  31. type TopicListOptions struct {
  32. options.BaseListOptions
  33. }
  34. func (opts *TopicListOptions) Params() (jsonutils.JSONObject, error) {
  35. return options.ListStructToParams(opts)
  36. }
  37. type TopicOptions struct {
  38. ID string `help:"Id or Name of topic"`
  39. }
  40. func (so *TopicOptions) GetId() string {
  41. return so.ID
  42. }
  43. func (so *TopicOptions) Params() (jsonutils.JSONObject, error) {
  44. return nil, nil
  45. }
  46. type TopicUpdateOptions struct {
  47. ID string
  48. AdvanceDays []int
  49. Name string
  50. Resources []string
  51. Actions []string
  52. Results *bool
  53. TitleCn string
  54. TitleEn string
  55. ContentCn string
  56. ContentEn string
  57. }
  58. func (opts *TopicUpdateOptions) Params() (jsonutils.JSONObject, error) {
  59. return jsonutils.Marshal(opts), nil
  60. }
  61. func (so *TopicUpdateOptions) GetId() string {
  62. return so.ID
  63. }
  64. type STopicAddActionInput struct {
  65. ID string
  66. ACTION_ID string
  67. }
  68. func (opt *STopicAddActionInput) GetId() string {
  69. return opt.ID
  70. }
  71. func (rl *STopicAddActionInput) Params() (jsonutils.JSONObject, error) {
  72. return options.ListStructToParams(rl)
  73. }
  74. type STopicAddResourceInput struct {
  75. ID string
  76. RESOURCE_ID string
  77. }
  78. func (opt *STopicAddResourceInput) GetId() string {
  79. return opt.ID
  80. }
  81. func (rl *STopicAddResourceInput) Params() (jsonutils.JSONObject, error) {
  82. return options.ListStructToParams(rl)
  83. }
  84. type TopicCreateOptions struct {
  85. NAME string
  86. Enabled bool
  87. Type string `choices:"resource|automated_process|security"`
  88. Results bool
  89. TitleCn string
  90. TitleEn string
  91. ContentCn string
  92. ContentEn string
  93. GroupKeys []string
  94. AdvanceDays []int
  95. Actions []string
  96. Resources []string
  97. }
  98. func (rl *TopicCreateOptions) Params() (jsonutils.JSONObject, error) {
  99. return jsonutils.Marshal(rl), nil
  100. }
  101. type TopicAddActionInput struct {
  102. TopicOptions
  103. Actions []string `json:"actions"`
  104. }
  105. func (rl *TopicAddActionInput) Params() (jsonutils.JSONObject, error) {
  106. return jsonutils.Marshal(rl), nil
  107. }
  108. type TopicAddResourcesInput struct {
  109. TopicOptions
  110. Resources []string `json:"resources"`
  111. }
  112. func (rl *TopicAddResourcesInput) Params() (jsonutils.JSONObject, error) {
  113. return jsonutils.Marshal(rl), nil
  114. }