cloudevents.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 cloudevent
  15. import (
  16. "yunion.io/x/jsonutils"
  17. "yunion.io/x/onecloud/pkg/mcclient"
  18. "yunion.io/x/onecloud/pkg/mcclient/modules/cloudevent"
  19. "yunion.io/x/onecloud/pkg/mcclient/options"
  20. )
  21. func init() {
  22. type CloudeventListOptions struct {
  23. options.BaseListOptions
  24. Since string `help:"since time"`
  25. Until string `hlep:"until time"`
  26. }
  27. R(&CloudeventListOptions{}, "cloud-event-list", "List cloud events", func(s *mcclient.ClientSession, opts *CloudeventListOptions) error {
  28. params, err := options.ListStructToParams(opts)
  29. if err != nil {
  30. return err
  31. }
  32. result, err := cloudevent.Cloudevents.List(s, params)
  33. if err != nil {
  34. return err
  35. }
  36. printList(result, cloudevent.Cloudevents.GetColumns(s))
  37. return nil
  38. })
  39. type CloudeventSplitTableOptions struct {
  40. }
  41. R(&CloudeventSplitTableOptions{}, "cloud-event-splitable", "Show obsolete cloud event logs", func(s *mcclient.ClientSession, opts *CloudeventSplitTableOptions) error {
  42. resp, err := cloudevent.Cloudevents.Get(s, "splitable", nil)
  43. if err != nil {
  44. return err
  45. }
  46. printObject(resp)
  47. return nil
  48. })
  49. type CloudeventLogsPurgeOptions struct {
  50. Tables []string
  51. }
  52. R(&CloudeventLogsPurgeOptions{}, "cloud-event-purge-splitable", "Purge obsolete cloud event logs", func(s *mcclient.ClientSession, opts *CloudeventLogsPurgeOptions) error {
  53. resp, err := cloudevent.Cloudevents.PerformClassAction(s, "purge-splitable", jsonutils.Marshal(opts))
  54. if err != nil {
  55. return err
  56. }
  57. printObject(resp)
  58. return nil
  59. })
  60. }