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