-
Notifications
You must be signed in to change notification settings - Fork 245
/
Copy pathrpc_client.go
51 lines (43 loc) · 1.43 KB
/
rpc_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package ros
import (
"github.com/denverdino/aliyungo/common"
"os"
)
const (
ROS_RPC_APIVersion = "2019-09-10"
ROSServiceCode = "ros"
)
type RpcClient struct {
common.Client
}
func NewRpcClient(accessKeyId, accessKeySecret string) *RpcClient {
endpoint := os.Getenv("ROS_ENDPOINT")
if endpoint == "" {
endpoint = ROSDefaultEndpoint
}
return NewRpcClientWithEndpoint(endpoint, accessKeyId, accessKeySecret)
}
func NewRpcClientWithEndpoint(endpoint string, accessKeyId string, accessKeySecret string) *RpcClient {
client := &RpcClient{}
client.Init(endpoint, ROS_RPC_APIVersion, accessKeyId, accessKeySecret)
return client
}
func NewRosRpcClientWithSecurityToken(accessKeyId string, accessKeySecret string, securityToken string, regionID common.Region) *RpcClient {
endpoint := os.Getenv("ROS_ENDPOINT")
if endpoint == "" {
endpoint = ROSDefaultEndpoint
}
return NewRosRpcClientWithEndpointAndSecurityToken(endpoint, accessKeyId, accessKeySecret, securityToken, regionID)
}
func NewRosRpcClientWithEndpointAndSecurityToken(endpoint string, accessKeyId string, accessKeySecret string, securityToken string, regionID common.Region) *RpcClient {
client := &RpcClient{}
client.WithEndpoint(endpoint).
WithVersion(ROS_RPC_APIVersion).
WithAccessKeyId(accessKeyId).
WithAccessKeySecret(accessKeySecret).
WithSecurityToken(securityToken).
WithServiceCode(ROSServiceCode).
WithRegionID(regionID).
InitClient()
return client
}