dnsrecords.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 DnsRecordListOptions struct {
  20. options.BaseListOptions
  21. DnsZoneId string `help:"DnsZone Id or Name"`
  22. }
  23. func (opts *DnsRecordListOptions) Params() (jsonutils.JSONObject, error) {
  24. return options.ListStructToParams(opts)
  25. }
  26. type DnsRecordCreateOptions struct {
  27. options.EnabledStatusCreateOptions
  28. DNS_ZONE_ID string `help:"Dns Zone Id"`
  29. DNS_TYPE string `choices:"A|AAAA|CAA|CNAME|MX|NS|SRV|SOA|TXT|PTR|DS|DNSKEY|IPSECKEY|NAPTR|SPF|SSHFP|TLSA|REDIRECT_URL|FORWARD_URL"`
  30. DNS_VALUE string `help:"Dns Value"`
  31. Ttl int64 `help:"Dns ttl" default:"300"`
  32. MxPriority int64 `help:"dns mx type mxpriority"`
  33. PolicyType string `choices:"Simple|ByCarrier|ByGeoLocation|BySearchEngine|IpRange|Weighted|Failover|MultiValueAnswer|Latency"`
  34. PolicyValue string `help:"Dns Traffic policy value"`
  35. }
  36. func (opts *DnsRecordCreateOptions) Params() (jsonutils.JSONObject, error) {
  37. params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
  38. return params, nil
  39. }
  40. type DnsRecordIdOptions struct {
  41. ID string
  42. }
  43. func (opts *DnsRecordIdOptions) GetId() string {
  44. return opts.ID
  45. }
  46. func (opts *DnsRecordIdOptions) Params() (jsonutils.JSONObject, error) {
  47. return nil, nil
  48. }
  49. type DnsRecordUpdateOptions struct {
  50. options.BaseUpdateOptions
  51. DnsType string `choices:"A|AAAA|CAA|CNAME|MX|NS|SRV|SOA|TXT|PRT|DS|DNSKEY|IPSECKEY|NAPTR|SPF|SSHFP|TLSA|REDIRECT_URL|FORWARD_URL"`
  52. DnsValue string
  53. Ttl *int64
  54. MxPriority *int64 `help:"dns mx type mxpriority"`
  55. PolicyType string `choices:"Simple|ByCarrier|ByGeoLocation|BySearchEngine|IpRange|Weighted|Failover|MultiValueAnswer|Latency"`
  56. PolicyValue string `help:"Dns Traffic policy value"`
  57. }
  58. func (opts *DnsRecordUpdateOptions) Params() (jsonutils.JSONObject, error) {
  59. params := jsonutils.Marshal(opts).(*jsonutils.JSONDict)
  60. params.Remove("id")
  61. return params, nil
  62. }