소스 검색

Generated 2018-01-01 for pvtz.

sdk-team 5 년 전
부모
커밋
538eb00246
4개의 변경된 파일63개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      ChangeLog.txt
  2. 2 0
      go.mod
  3. 25 0
      services/pvtz/client.go
  4. 32 0
      services/pvtz/endpoint.go

+ 4 - 0
ChangeLog.txt

@@ -1,3 +1,7 @@
+2020-02-11 Version: v1.60.355
+- Generated 2018-01-01 for `pvtz`.
+- Update default endpoints.
+
 2020-02-10 Version: v1.60.354
 - Generated 2017-09-06 for `imm`.
 - Supported address for GetMediaMeta.

+ 2 - 0
go.mod

@@ -11,3 +11,5 @@ require (
 	github.com/stretchr/testify v1.3.0
 	gopkg.in/ini.v1 v1.42.0
 )
+
+go 1.13

+ 25 - 0
services/pvtz/client.go

@@ -16,6 +16,8 @@ package pvtz
 // Changes may cause incorrect behavior and will be lost if the code is regenerated.
 
 import (
+	"reflect"
+
 	"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/credentials/provider"
@@ -26,10 +28,25 @@ type Client struct {
 	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
 func NewClient() (client *Client, err error) {
 	client = &Client{}
 	err = client.Init()
+	SetEndpointDataToClient(client)
 	return
 }
 
@@ -44,6 +61,7 @@ func NewClientWithProvider(regionId string, providers ...provider.Provider) (cli
 		pc = provider.NewProviderChain(providers)
 	}
 	err = client.InitWithProviderChain(regionId, pc)
+	SetEndpointDataToClient(client)
 	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) {
 	client = &Client{}
 	err = client.InitWithOptions(regionId, config, credential)
+	SetEndpointDataToClient(client)
 	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) {
 	client = &Client{}
 	err = client.InitWithAccessKey(regionId, accessKeyId, accessKeySecret)
+	SetEndpointDataToClient(client)
 	return
 }
 
@@ -68,6 +88,7 @@ func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (clie
 func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken string) (client *Client, err error) {
 	client = &Client{}
 	err = client.InitWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken)
+	SetEndpointDataToClient(client)
 	return
 }
 
@@ -76,6 +97,7 @@ func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToke
 func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
 	client = &Client{}
 	err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
+	SetEndpointDataToClient(client)
 	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) {
 	client = &Client{}
 	err = client.InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy)
+	SetEndpointDataToClient(client)
 	return
 }
 
@@ -92,6 +115,7 @@ func NewClientWithRamRoleArnAndPolicy(regionId string, accessKeyId, accessKeySec
 func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) {
 	client = &Client{}
 	err = client.InitWithEcsRamRole(regionId, roleName)
+	SetEndpointDataToClient(client)
 	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) {
 	client = &Client{}
 	err = client.InitWithRsaKeyPair(regionId, publicKeyId, privateKey, sessionExpiration)
+	SetEndpointDataToClient(client)
 	return
 }

+ 32 - 0
services/pvtz/endpoint.go

@@ -0,0 +1,32 @@
+package pvtz
+
+// EndpointMap Endpoint Data
+var EndpointMap map[string]string
+
+// EndpointType regional or central
+var EndpointType = "central"
+
+// GetEndpointMap Get Endpoint Data Map
+func GetEndpointMap() map[string]string {
+	if EndpointMap == nil {
+		EndpointMap = map[string]string{
+			"cn-shenzhen":    "pvtz.cn-shenzhen.aliyuncs.com",
+			"cn-beijing":     "pvtz.cn-beijing.aliyuncs.com",
+			"cn-shanghai":    "pvtz.cn-shanghai.aliyuncs.com",
+			"cn-hongkong":    "pvtz.cn-hongkong.aliyuncs.com",
+			"ap-southeast-1": "pvtz.ap-southeast-1.aliyuncs.com",
+			"ap-southeast-3": "pvtz.ap-southeast-3.aliyuncs.com",
+			"eu-central-1":   "pvtz.eu-central-1.aliyuncs.com",
+			"cn-huhehaote":   "pvtz.cn-huhehaote.aliyuncs.com",
+			"ap-southeast-5": "pvtz.ap-southeast-5.aliyuncs.com",
+			"cn-zhangjiakou": "pvtz.cn-zhangjiakou.aliyuncs.com",
+			"cn-chengdu":     "pvtz.cn-chengdu.aliyuncs.com",
+		}
+	}
+	return EndpointMap
+}
+
+// GetEndpointType Get Endpoint Type Value
+func GetEndpointType() string {
+	return EndpointType
+}