config.go raw

   1  package dns
   2  
   3  import (
   4  	"net/http"
   5  	"os"
   6  	"time"
   7  
   8  	"github.com/volcengine/volc-sdk-golang/base"
   9  )
  10  
  11  const (
  12  	DefaultRegion  = "cn-beijing"
  13  	ServiceVersion = "2018-08-01"
  14  	ServiceName    = "dns"
  15  	Timeout        = 15
  16  
  17  	xTopAccountID = ""
  18  )
  19  
  20  var (
  21  	ServiceInfo = &base.ServiceInfo{
  22  		Timeout: Timeout * time.Second,
  23  		Host:    "open.volcengineapi.com",
  24  		Header: http.Header{
  25  			"Accept": []string{"application/json"},
  26  		},
  27  		Scheme: "http",
  28  		Credentials: base.Credentials{
  29  			Service:         ServiceName,
  30  			Region:          DefaultRegion,
  31  			AccessKeyID:     os.Getenv("VOLC_ACCESSKEY"),
  32  			SecretAccessKey: os.Getenv("VOLC_SECRETKEY"),
  33  		},
  34  	}
  35  )
  36  
  37  // SDKClient .
  38  type SDKClient struct {
  39  	Client *base.Client
  40  }
  41  
  42  // GetServiceInfo interface
  43  func (p *SDKClient) GetServiceInfo() *base.ServiceInfo {
  44  	return p.Client.ServiceInfo
  45  }
  46  
  47  func (p *SDKClient) SetRegion(region string) {
  48  	p.Client.ServiceInfo.Credentials.Region = region
  49  }
  50  
  51  func (p *SDKClient) SetHost(host string) {
  52  	p.Client.ServiceInfo.Host = host
  53  }
  54  
  55  func (p *SDKClient) SetSchema(schema string) {
  56  	p.Client.ServiceInfo.Scheme = schema
  57  }
  58