| 1 |
package slb |
| 2 |
|
| 3 |
import ( |
| 4 |
"os" |
| 5 |
|
| 6 |
"github.com/denverdino/aliyungo/common" |
| 7 |
) |
| 8 |
|
| 9 |
type Client struct { |
| 10 |
common.Client |
| 11 |
} |
| 12 |
|
| 13 |
const ( |
| 14 |
|
| 15 |
SLBDefaultEndpoint = "https://slb.aliyuncs.com" |
| 16 |
SLBAPIVersion = "2014-05-15" |
| 17 |
|
| 18 |
SLBServiceCode = "slb" |
| 19 |
) |
| 20 |
|
| 21 |
|
| 22 |
func NewClient(accessKeyId, accessKeySecret string) *Client { |
| 23 |
endpoint := os.Getenv("SLB_ENDPOINT") |
| 24 |
if endpoint == "" { |
| 25 |
endpoint = SLBDefaultEndpoint |
| 26 |
} |
| 27 |
return NewClientWithEndpoint(endpoint, accessKeyId, accessKeySecret) |
| 28 |
} |
| 29 |
|
| 30 |
func NewClientWithEndpoint(endpoint string, accessKeyId, accessKeySecret string) *Client { |
| 31 |
client := &Client{} |
| 32 |
client.Init(endpoint, SLBAPIVersion, accessKeyId, accessKeySecret) |
| 33 |
return client |
| 34 |
} |
| 35 |
|
| 36 |
func NewSLBClient(accessKeyId, accessKeySecret string, regionID common.Region) *Client { |
| 37 |
endpoint := os.Getenv("SLB_ENDPOINT") |
| 38 |
if endpoint == "" { |
| 39 |
endpoint = SLBDefaultEndpoint |
| 40 |
} |
| 41 |
|
| 42 |
return NewClientWithRegion(endpoint, accessKeyId, accessKeySecret, regionID) |
| 43 |
} |
| 44 |
|
| 45 |
func NewClientWithRegion(endpoint string, accessKeyId, accessKeySecret string, regionID common.Region) *Client { |
| 46 |
client := &Client{} |
| 47 |
client.NewInit(endpoint, SLBAPIVersion, accessKeyId, accessKeySecret, SLBServiceCode, regionID) |
| 48 |
return client |
| 49 |
} |
| 50 |
|
| 51 |
func NewSLBClientWithSecurityToken(accessKeyId string, accessKeySecret string, securityToken string, regionID common.Region) *Client { |
| 52 |
endpoint := os.Getenv("SLB_ENDPOINT") |
| 53 |
if endpoint == "" { |
| 54 |
endpoint = SLBDefaultEndpoint |
| 55 |
} |
| 56 |
|
| 57 |
return NewSLBClientWithEndpointAndSecurityToken(endpoint, accessKeyId, accessKeySecret, securityToken, regionID) |
| 58 |
} |
| 59 |
|
| 60 |
func NewSLBClientWithEndpointAndSecurityToken(endpoint string, accessKeyId string, accessKeySecret string, securityToken string, regionID common.Region) *Client { |
| 61 |
client := &Client{} |
| 62 |
client.WithEndpoint(endpoint). |
| 63 |
WithVersion(SLBAPIVersion). |
| 64 |
WithAccessKeyId(accessKeyId). |
| 65 |
WithAccessKeySecret(accessKeySecret). |
| 66 |
WithSecurityToken(securityToken). |
| 67 |
WithServiceCode(SLBServiceCode). |
| 68 |
WithRegionID(regionID). |
| 69 |
InitClient() |
| 70 |
return client |
| 71 |
} |