dnszone.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. "fmt"
  17. "yunion.io/x/jsonutils"
  18. "yunion.io/x/log"
  19. "yunion.io/x/onecloud/cmd/climc/shell"
  20. modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
  21. "yunion.io/x/onecloud/pkg/mcclient/options"
  22. "yunion.io/x/onecloud/pkg/mcclient/options/compute"
  23. )
  24. func init() {
  25. cmd := shell.NewResourceCmd(&modules.DnsZones).WithKeyword("dns-zone")
  26. cmd.List(&compute.SDnsZoneListOptions{})
  27. cmd.Show(&compute.SDnsZoneIdOptions{})
  28. cmd.ClassShow(&compute.DnsZoneCapabilitiesOptions{})
  29. cmd.Delete(&compute.SDnsZoneIdOptions{})
  30. cmd.Create(&compute.DnsZoneCreateOptions{})
  31. cmd.Perform("public", &options.BasePublicOptions{})
  32. cmd.Perform("private", &options.BaseIdOptions{})
  33. cmd.Perform("syncstatus", &compute.SDnsZoneIdOptions{})
  34. cmd.Perform("purge", &compute.SDnsZoneIdOptions{})
  35. cmd.Perform("add-vpcs", &compute.DnsZoneAddVpcsOptions{})
  36. cmd.Perform("remove-vpcs", &compute.DnsZoneRemoveVpcsOptions{})
  37. cmd.GetWithCustomShow("exports", func(result jsonutils.JSONObject) {
  38. rr := make(map[string]string)
  39. err := result.Unmarshal(&rr)
  40. if err != nil {
  41. log.Errorf("error: %v", err)
  42. return
  43. }
  44. for _, v := range rr {
  45. fmt.Printf("%s\n", v)
  46. }
  47. }, &compute.SDnsZoneIdOptions{})
  48. }