proxysettings.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 compute
  15. import (
  16. "yunion.io/x/jsonutils"
  17. "yunion.io/x/onecloud/pkg/mcclient"
  18. modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
  19. "yunion.io/x/onecloud/pkg/mcclient/options"
  20. )
  21. func init() {
  22. R(&options.ProxySettingCreateOptions{}, "proxysetting-create", "Create proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingCreateOptions) error {
  23. params, err := options.StructToParams(opts)
  24. if err != nil {
  25. return err
  26. }
  27. proxysetting, err := modules.ProxySettings.Create(s, params)
  28. if err != nil {
  29. return err
  30. }
  31. printObject(proxysetting)
  32. return nil
  33. })
  34. R(&options.ProxySettingGetOptions{}, "proxysetting-show", "Show proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingGetOptions) error {
  35. proxysetting, err := modules.ProxySettings.Get(s, opts.ID, nil)
  36. if err != nil {
  37. return err
  38. }
  39. printObject(proxysetting)
  40. return nil
  41. })
  42. R(&options.ProxySettingListOptions{}, "proxysetting-list", "List proxysettings", func(s *mcclient.ClientSession, opts *options.ProxySettingListOptions) error {
  43. params, err := options.ListStructToParams(opts)
  44. if err != nil {
  45. return err
  46. }
  47. result, err := modules.ProxySettings.List(s, params)
  48. if err != nil {
  49. return err
  50. }
  51. printList(result, modules.ProxySettings.GetColumns(s))
  52. return nil
  53. })
  54. R(&options.ProxySettingUpdateOptions{}, "proxysetting-update", "Update proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingUpdateOptions) error {
  55. params, err := options.StructToParams(opts)
  56. proxysetting, err := modules.ProxySettings.Update(s, opts.ID, params)
  57. if err != nil {
  58. return err
  59. }
  60. printObject(proxysetting)
  61. return nil
  62. })
  63. R(&options.ProxySettingDeleteOptions{}, "proxysetting-delete", "Delete proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingDeleteOptions) error {
  64. proxysetting, err := modules.ProxySettings.Delete(s, opts.ID, nil)
  65. if err != nil {
  66. return err
  67. }
  68. printObject(proxysetting)
  69. return nil
  70. })
  71. R(&options.ProxySettingTestOptions{}, "proxysetting-test", "Test proxysetting", func(s *mcclient.ClientSession, opts *options.ProxySettingTestOptions) error {
  72. proxysetting, err := modules.ProxySettings.PerformAction(s, opts.ID, "test", nil)
  73. if err != nil {
  74. return err
  75. }
  76. printObject(proxysetting)
  77. return nil
  78. })
  79. R(&options.ProxySettingPublicOptions{}, "proxysetting-public", "Make proxysetting public", func(s *mcclient.ClientSession, opts *options.ProxySettingPublicOptions) error {
  80. params := jsonutils.Marshal(opts)
  81. result, err := modules.ProxySettings.PerformAction(s, opts.ID, "public", params)
  82. if err != nil {
  83. return err
  84. }
  85. printObject(result)
  86. return nil
  87. })
  88. R(&options.ProxySettingPrivateOptions{}, "proxysetting-private", "Make proxysetting private", func(s *mcclient.ClientSession, opts *options.ProxySettingPrivateOptions) error {
  89. params := jsonutils.Marshal(opts)
  90. result, err := modules.ProxySettings.PerformAction(s, opts.ID, "private", params)
  91. if err != nil {
  92. return err
  93. }
  94. printObject(result)
  95. return nil
  96. })
  97. }