packer-cn/vendor/github.com/denverdino/aliyungo/ram/client.go

46 lines
1.3 KiB
Go
Raw Normal View History

2017-03-04 05:06:32 -05:00
package ram
import (
"os"
"github.com/denverdino/aliyungo/common"
2017-03-04 05:06:32 -05:00
)
const (
// RAMDefaultEndpoint is the default API endpoint of RAM services
RAMDefaultEndpoint = "https://ram.aliyuncs.com"
RAMAPIVersion = "2015-05-01"
)
type RamClient struct {
common.Client
}
func NewClient(accessKeyId string, accessKeySecret string) RamClientInterface {
return NewClientWithSecurityToken(accessKeyId, accessKeySecret, "")
}
func NewClientWithSecurityToken(accessKeyId string, accessKeySecret string, securityToken string) RamClientInterface {
2017-03-04 05:06:32 -05:00
endpoint := os.Getenv("RAM_ENDPOINT")
if endpoint == "" {
endpoint = RAMDefaultEndpoint
}
return NewClientWithEndpointAndSecurityToken(endpoint, accessKeyId, accessKeySecret, securityToken)
2017-03-04 05:06:32 -05:00
}
func NewClientWithEndpoint(endpoint string, accessKeyId string, accessKeySecret string) RamClientInterface {
return NewClientWithEndpointAndSecurityToken(endpoint, accessKeyId, accessKeySecret, "")
}
func NewClientWithEndpointAndSecurityToken(endpoint string, accessKeyId string, accessKeySecret string, securityToken string) RamClientInterface {
2017-03-04 05:06:32 -05:00
client := &RamClient{}
client.WithEndpoint(endpoint).
WithVersion(RAMAPIVersion).
WithAccessKeyId(accessKeyId).
WithAccessKeySecret(accessKeySecret).
WithSecurityToken(securityToken).
InitClient()
2017-03-04 05:06:32 -05:00
return client
}