Debian Codegraph @

ram/client.go

raw symbols SCIP
1 package ram
2
3 import (
4 "os"
5
6 "github.com/denverdino/aliyungo/common"
7 )
8
9 const (
10 // RAMDefaultEndpoint is the default API endpoint of RAM services
11 RAMDefaultEndpoint = "https://ram.aliyuncs.com"
12 RAMAPIVersion = "2015-05-01"
13 )
14
15 type RamClient struct {
16 common.Client
17 }
18
19 func NewClient(accessKeyId string, accessKeySecret string) RamClientInterface {
20 return NewClientWithSecurityToken(accessKeyId, accessKeySecret, "")
21 }
22
23 func NewClientWithSecurityToken(accessKeyId string, accessKeySecret string, securityToken string) RamClientInterface {
24 endpoint := os.Getenv("RAM_ENDPOINT")
25 if endpoint == "" {
26 endpoint = RAMDefaultEndpoint
27 }
28
29 return NewClientWithEndpointAndSecurityToken(endpoint, accessKeyId, accessKeySecret, securityToken)
30 }
31
32 func NewClientWithEndpoint(endpoint string, accessKeyId string, accessKeySecret string) RamClientInterface {
33 return NewClientWithEndpointAndSecurityToken(endpoint, accessKeyId, accessKeySecret, "")
34 }
35
36 func NewClientWithEndpointAndSecurityToken(endpoint string, accessKeyId string, accessKeySecret string, securityToken string) RamClientInterface {
37 client := &RamClient{}
38 client.WithEndpoint(endpoint).
39 WithVersion(RAMAPIVersion).
40 WithAccessKeyId(accessKeyId).
41 WithAccessKeySecret(accessKeySecret).
42 WithSecurityToken(securityToken).
43 InitClient()
44 return client
45 }