dnszone.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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/options"
  18. )
  19. type SDnsZoneListOptions struct {
  20. options.BaseListOptions
  21. VpcId string `help:"Filter dns zone by vpc"`
  22. ZoneType string `help:"Filter dns zone by zone type" choices:"PublicZone|PrivateZone"`
  23. WithCache bool `help:"Whether to bring cache information"`
  24. }
  25. func (opts *SDnsZoneListOptions) Params() (jsonutils.JSONObject, error) {
  26. return options.ListStructToParams(opts)
  27. }
  28. type SDnsZoneIdOptions struct {
  29. ID string `help:"Dns zone Id or Name"`
  30. }
  31. func (opts *SDnsZoneIdOptions) GetId() string {
  32. return opts.ID
  33. }
  34. func (opts *SDnsZoneIdOptions) Params() (jsonutils.JSONObject, error) {
  35. return nil, nil
  36. }
  37. type DnsZoneCreateOptions struct {
  38. options.EnabledStatusCreateOptions
  39. ZoneType string `choices:"PublicZone|PrivateZone" metavar:"zone_type" default:"PrivateZone"`
  40. VpcIds []string `help:"Vpc Ids"`
  41. ManagerId string `help:"Manager id"`
  42. }
  43. func (opts *DnsZoneCreateOptions) Params() (jsonutils.JSONObject, error) {
  44. return jsonutils.Marshal(opts), nil
  45. }
  46. type DnsZoneCapabilitiesOptions struct {
  47. }
  48. func (opts *DnsZoneCapabilitiesOptions) GetId() string {
  49. return "capability"
  50. }
  51. func (opts *DnsZoneCapabilitiesOptions) Params() (jsonutils.JSONObject, error) {
  52. return nil, nil
  53. }
  54. type DnsZoneAddVpcsOptions struct {
  55. SDnsZoneIdOptions
  56. VPC_IDS string
  57. }
  58. func (opts *DnsZoneAddVpcsOptions) Params() (jsonutils.JSONObject, error) {
  59. return jsonutils.Marshal(map[string]string{"vpc_ids": opts.VPC_IDS}), nil
  60. }
  61. type DnsZoneRemoveVpcsOptions struct {
  62. SDnsZoneIdOptions
  63. VPC_IDS string
  64. }
  65. func (opts *DnsZoneRemoveVpcsOptions) Params() (jsonutils.JSONObject, error) {
  66. return jsonutils.Marshal(map[string]string{"vpc_ids": opts.VPC_IDS}), nil
  67. }