commonalertmetricfield.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 MonitorMetricFieldListOptions struct {
  20. options.BaseListOptions
  21. Names []string `help:"name of field"`
  22. Unit string `help:"Unit of Field " choices:"%|bps|Mbps|Bps|cps|count|ms|byte"`
  23. DisplayName string `help:"The name of the field customization"`
  24. }
  25. func (o *MonitorMetricFieldListOptions) Params() (jsonutils.JSONObject, error) {
  26. return options.ListStructToParams(o)
  27. }
  28. type MetricFieldUpdateOptions struct {
  29. ID string `help:"ID of Metric " required:"true" positional:"true"`
  30. DisplayName string `help:"The name of the field customization" required:"true"`
  31. Name string `help:"Name of Field" required:"true"`
  32. Unit string `help:"Unit of Field" choices:"%|bps|Mbps|Bps|cps|count|ms|byte" required:"true"`
  33. }
  34. func (o *MetricFieldUpdateOptions) GetId() string {
  35. return o.ID
  36. }
  37. func (o *MetricFieldUpdateOptions) Params() (jsonutils.JSONObject, error) {
  38. params, err := options.StructToParams(o)
  39. if err != nil {
  40. return nil, err
  41. }
  42. return params, nil
  43. }
  44. type MetricFieldShowOptions struct {
  45. ID string `help:"ID of Metric " json:"-"`
  46. }
  47. func (o *MetricFieldShowOptions) Params() (jsonutils.JSONObject, error) {
  48. return options.StructToParams(o)
  49. }
  50. func (o *MetricFieldShowOptions) GetId() string {
  51. return o.ID
  52. }
  53. type MetricFieldDeleteOptions struct {
  54. ID string `help:"ID of Metric " json:"-"`
  55. }
  56. func (o *MetricFieldDeleteOptions) GetId() string {
  57. return o.ID
  58. }
  59. func (o *MetricFieldDeleteOptions) Params() (jsonutils.JSONObject, error) {
  60. return options.StructToParams(o)
  61. }