alertresource.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. "yunion.io/x/jsonutils"
  17. "yunion.io/x/onecloud/pkg/mcclient/options"
  18. )
  19. type AlertResourceListOptions struct {
  20. options.BaseListOptions
  21. Type string `json:"type"`
  22. }
  23. func (o AlertResourceListOptions) Params() (jsonutils.JSONObject, error) {
  24. params, err := o.BaseListOptions.Params()
  25. if err != nil {
  26. return nil, err
  27. }
  28. if o.Type != "" {
  29. params.Add(jsonutils.NewString(o.Type), "type")
  30. }
  31. return params, nil
  32. }
  33. type AlertResourceShowOptions struct {
  34. ID string `help:"ID or name of the alert resource" json:"-"`
  35. }
  36. func (o AlertResourceShowOptions) GetId() string {
  37. return o.ID
  38. }
  39. func (o AlertResourceShowOptions) Params() (jsonutils.JSONObject, error) {
  40. return nil, nil
  41. }
  42. type AlertResourceDeleteOptions struct {
  43. ID []string `help:"ID of alert resource to delete"`
  44. }
  45. func (o AlertResourceDeleteOptions) GetIds() []string {
  46. return o.ID
  47. }
  48. func (o AlertResourceDeleteOptions) Params() (jsonutils.JSONObject, error) {
  49. return nil, nil
  50. }
  51. type AlertResourceAlertListOptions struct {
  52. options.BaseListOptions
  53. Resource string `help:"ID or name of alert resource"`
  54. Alert string `help:"ID or name of alert"`
  55. }
  56. func (o AlertResourceAlertListOptions) GetMasterOpt() string {
  57. return o.Resource
  58. }
  59. func (o AlertResourceAlertListOptions) GetSlaveOpt() string {
  60. return o.Alert
  61. }
  62. func (o AlertResourceAlertListOptions) Params() (jsonutils.JSONObject, error) {
  63. return o.BaseListOptions.Params()
  64. }