client.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package dns
  2. import (
  3. "os"
  4. "github.com/denverdino/aliyungo/common"
  5. )
  6. type Client struct {
  7. common.Client
  8. }
  9. const (
  10. // DNSDefaultEndpoint is the default API endpoint of DNS services
  11. DNSDefaultEndpoint = "http://dns.aliyuncs.com"
  12. DNSAPIVersion = "2015-01-09"
  13. DNSDefaultEndpointNew = "http://alidns.aliyuncs.com"
  14. )
  15. // NewClient creates a new instance of DNS client
  16. func NewClient(accessKeyId, accessKeySecret string) *Client {
  17. endpoint := os.Getenv("DNS_ENDPOINT")
  18. if endpoint == "" {
  19. endpoint = DNSDefaultEndpoint
  20. }
  21. return NewClientWithEndpoint(endpoint, accessKeyId, accessKeySecret)
  22. }
  23. // NewClientNew creates a new instance of DNS client, with http://alidns.aliyuncs.com as default endpoint
  24. func NewClientNew(accessKeyId, accessKeySecret string) *Client {
  25. endpoint := os.Getenv("DNS_ENDPOINT")
  26. if endpoint == "" {
  27. endpoint = DNSDefaultEndpointNew
  28. }
  29. return NewClientWithEndpoint(endpoint, accessKeyId, accessKeySecret)
  30. }
  31. // NewCustomClient creates a new instance of ECS client with customized API endpoint
  32. func NewCustomClient(accessKeyId, accessKeySecret string, endpoint string) *Client {
  33. client := &Client{}
  34. client.Init(endpoint, DNSAPIVersion, accessKeyId, accessKeySecret)
  35. return client
  36. }
  37. func NewClientWithEndpoint(endpoint string, accessKeyId, accessKeySecret string) *Client {
  38. client := &Client{}
  39. client.Init(endpoint, DNSAPIVersion, accessKeyId, accessKeySecret)
  40. return client
  41. }