|
@@ -16,6 +16,8 @@ package pvtz
|
|
|
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
|
+ "reflect"
|
|
|
|
|
+
|
|
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
|
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
|
|
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
|
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
|
|
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider"
|
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider"
|
|
@@ -26,10 +28,25 @@ type Client struct {
|
|
|
sdk.Client
|
|
sdk.Client
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// SetClientProperty Set Property by Reflect
|
|
|
|
|
+func SetClientProperty(client *Client, propertyName string, propertyValue interface{}) {
|
|
|
|
|
+ v := reflect.ValueOf(client).Elem()
|
|
|
|
|
+ if v.FieldByName(propertyName).IsValid() && v.FieldByName(propertyName).CanSet() {
|
|
|
|
|
+ v.FieldByName(propertyName).Set(reflect.ValueOf(propertyValue))
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// SetEndpointDataToClient Set EndpointMap and ENdpointType
|
|
|
|
|
+func SetEndpointDataToClient(client *Client) {
|
|
|
|
|
+ SetClientProperty(client, "EndpointMap", GetEndpointMap())
|
|
|
|
|
+ SetClientProperty(client, "EndpointType", GetEndpointType())
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// NewClient creates a sdk client with environment variables
|
|
// NewClient creates a sdk client with environment variables
|
|
|
func NewClient() (client *Client, err error) {
|
|
func NewClient() (client *Client, err error) {
|
|
|
client = &Client{}
|
|
client = &Client{}
|
|
|
err = client.Init()
|
|
err = client.Init()
|
|
|
|
|
+ SetEndpointDataToClient(client)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -44,6 +61,7 @@ func NewClientWithProvider(regionId string, providers ...provider.Provider) (cli
|
|
|
pc = provider.NewProviderChain(providers)
|
|
pc = provider.NewProviderChain(providers)
|
|
|
}
|
|
}
|
|
|
err = client.InitWithProviderChain(regionId, pc)
|
|
err = client.InitWithProviderChain(regionId, pc)
|
|
|
|
|
+ SetEndpointDataToClient(client)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -52,6 +70,7 @@ func NewClientWithProvider(regionId string, providers ...provider.Provider) (cli
|
|
|
func NewClientWithOptions(regionId string, config *sdk.Config, credential auth.Credential) (client *Client, err error) {
|
|
func NewClientWithOptions(regionId string, config *sdk.Config, credential auth.Credential) (client *Client, err error) {
|
|
|
client = &Client{}
|
|
client = &Client{}
|
|
|
err = client.InitWithOptions(regionId, config, credential)
|
|
err = client.InitWithOptions(regionId, config, credential)
|
|
|
|
|
+ SetEndpointDataToClient(client)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -60,6 +79,7 @@ func NewClientWithOptions(regionId string, config *sdk.Config, credential auth.C
|
|
|
func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (client *Client, err error) {
|
|
func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (client *Client, err error) {
|
|
|
client = &Client{}
|
|
client = &Client{}
|
|
|
err = client.InitWithAccessKey(regionId, accessKeyId, accessKeySecret)
|
|
err = client.InitWithAccessKey(regionId, accessKeyId, accessKeySecret)
|
|
|
|
|
+ SetEndpointDataToClient(client)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -68,6 +88,7 @@ func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (clie
|
|
|
func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken string) (client *Client, err error) {
|
|
func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken string) (client *Client, err error) {
|
|
|
client = &Client{}
|
|
client = &Client{}
|
|
|
err = client.InitWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken)
|
|
err = client.InitWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken)
|
|
|
|
|
+ SetEndpointDataToClient(client)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -76,6 +97,7 @@ func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToke
|
|
|
func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
|
|
func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
|
|
|
client = &Client{}
|
|
client = &Client{}
|
|
|
err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
|
|
err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
|
|
|
|
|
+ SetEndpointDataToClient(client)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -84,6 +106,7 @@ func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, role
|
|
|
func NewClientWithRamRoleArnAndPolicy(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string) (client *Client, err error) {
|
|
func NewClientWithRamRoleArnAndPolicy(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string) (client *Client, err error) {
|
|
|
client = &Client{}
|
|
client = &Client{}
|
|
|
err = client.InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy)
|
|
err = client.InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy)
|
|
|
|
|
+ SetEndpointDataToClient(client)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -92,6 +115,7 @@ func NewClientWithRamRoleArnAndPolicy(regionId string, accessKeyId, accessKeySec
|
|
|
func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) {
|
|
func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) {
|
|
|
client = &Client{}
|
|
client = &Client{}
|
|
|
err = client.InitWithEcsRamRole(regionId, roleName)
|
|
err = client.InitWithEcsRamRole(regionId, roleName)
|
|
|
|
|
+ SetEndpointDataToClient(client)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -100,5 +124,6 @@ func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client,
|
|
|
func NewClientWithRsaKeyPair(regionId string, publicKeyId, privateKey string, sessionExpiration int) (client *Client, err error) {
|
|
func NewClientWithRsaKeyPair(regionId string, publicKeyId, privateKey string, sessionExpiration int) (client *Client, err error) {
|
|
|
client = &Client{}
|
|
client = &Client{}
|
|
|
err = client.InitWithRsaKeyPair(regionId, publicKeyId, privateKey, sessionExpiration)
|
|
err = client.InitWithRsaKeyPair(regionId, publicKeyId, privateKey, sessionExpiration)
|
|
|
|
|
+ SetEndpointDataToClient(client)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|