client.go 923 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package ecs
  2. import (
  3. "github.com/denverdino/aliyungo/common"
  4. "os"
  5. )
  6. // Interval for checking status in WaitForXXX method
  7. const DefaultWaitForInterval = 5
  8. // Default timeout value for WaitForXXX method
  9. const DefaultTimeout = 60
  10. type Client struct {
  11. common.Client
  12. }
  13. const (
  14. // ECSDefaultEndpoint is the default API endpoint of ECS services
  15. ECSDefaultEndpoint = "https://ecs-cn-hangzhou.aliyuncs.com"
  16. ECSAPIVersion = "2014-05-26"
  17. )
  18. // NewClient creates a new instance of ECS client
  19. func NewClient(accessKeyId, accessKeySecret string) *Client {
  20. endpoint := os.Getenv("ECS_ENDPOINT")
  21. if endpoint == "" {
  22. endpoint = ECSDefaultEndpoint
  23. }
  24. return NewClientWithEndpoint(endpoint, accessKeyId, accessKeySecret)
  25. }
  26. func NewClientWithEndpoint(endpoint string, accessKeyId, accessKeySecret string) *Client {
  27. client := &Client{}
  28. client.Init(endpoint, ECSAPIVersion, accessKeyId, accessKeySecret)
  29. return client
  30. }