浏览代码

Add new api.

sdk-team 6 年之前
父节点
当前提交
9412d87843
共有 3 个文件被更改,包括 102 次插入0 次删除
  1. 3 0
      ChangeLog.txt
  2. 25 0
      services/qualitycheck/client.go
  3. 74 0
      services/qualitycheck/endpoint.go

+ 3 - 0
ChangeLog.txt

@@ -1,3 +1,6 @@
+2019-09-29 Version: 1.60.181
+- Add new api.
+
 2019-09-26 Version: 1.60.180
 - Update AHAS GetSentinelAppSumMetric API.
 

+ 25 - 0
services/qualitycheck/client.go

@@ -16,6 +16,8 @@ package qualitycheck
 // 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
 }

+ 74 - 0
services/qualitycheck/endpoint.go

@@ -0,0 +1,74 @@
+package qualitycheck
+
+// EndpointMap Endpoint Data
+var EndpointMap map[string]string
+
+// EndpointType regional or central
+var EndpointType = "regional"
+
+// GetEndpointMap Get Endpoint Data Map
+func GetEndpointMap() map[string]string {
+	if EndpointMap == nil {
+		EndpointMap = map[string]string{
+			"cn-shanghai-internal-test-1": "qualitycheck.aliyuncs.com",
+			"cn-shenzhen-su18-b01":        "qualitycheck.aliyuncs.com",
+			"cn-beijing":                  "qualitycheck.aliyuncs.com",
+			"cn-shanghai-inner":           "qualitycheck.aliyuncs.com",
+			"cn-hangzhou-internal-prod-1": "qualitycheck.aliyuncs.com",
+			"cn-north-2-gov-1":            "qualitycheck.aliyuncs.com",
+			"cn-yushanfang":               "qualitycheck.aliyuncs.com",
+			"cn-qingdao-nebula":           "qualitycheck.aliyuncs.com",
+			"cn-beijing-finance-pop":      "qualitycheck.aliyuncs.com",
+			"cn-wuhan":                    "qualitycheck.aliyuncs.com",
+			"cn-zhangjiakou":              "qualitycheck.aliyuncs.com",
+			"us-west-1":                   "qualitycheck.aliyuncs.com",
+			"rus-west-1-pop":              "qualitycheck.aliyuncs.com",
+			"cn-shanghai-et15-b01":        "qualitycheck.aliyuncs.com",
+			"cn-hangzhou-bj-b01":          "qualitycheck.aliyuncs.com",
+			"cn-zhangbei-na61-b01":        "qualitycheck.aliyuncs.com",
+			"ap-northeast-1":              "qualitycheck.aliyuncs.com",
+			"cn-shanghai-et2-b01":         "qualitycheck.aliyuncs.com",
+			"ap-southeast-1":              "qualitycheck.aliyuncs.com",
+			"ap-southeast-2":              "qualitycheck.aliyuncs.com",
+			"ap-southeast-3":              "qualitycheck.aliyuncs.com",
+			"ap-southeast-5":              "qualitycheck.aliyuncs.com",
+			"us-east-1":                   "qualitycheck.aliyuncs.com",
+			"cn-shenzhen-inner":           "qualitycheck.aliyuncs.com",
+			"cn-zhangjiakou-na62-a01":     "qualitycheck.aliyuncs.com",
+			"cn-beijing-gov-1":            "qualitycheck.aliyuncs.com",
+			"ap-south-1":                  "qualitycheck.aliyuncs.com",
+			"cn-shenzhen-st4-d01":         "qualitycheck.aliyuncs.com",
+			"cn-haidian-cm12-c01":         "qualitycheck.aliyuncs.com",
+			"cn-qingdao":                  "qualitycheck.aliyuncs.com",
+			"cn-hongkong-finance-pop":     "qualitycheck.aliyuncs.com",
+			"cn-shanghai":                 "qualitycheck.aliyuncs.com",
+			"cn-shanghai-finance-1":       "qualitycheck.aliyuncs.com",
+			"cn-hongkong":                 "qualitycheck.aliyuncs.com",
+			"eu-central-1":                "qualitycheck.aliyuncs.com",
+			"cn-shenzhen":                 "qualitycheck.aliyuncs.com",
+			"cn-zhengzhou-nebula-1":       "qualitycheck.aliyuncs.com",
+			"eu-west-1":                   "qualitycheck.aliyuncs.com",
+			"cn-hangzhou-internal-test-1": "qualitycheck.aliyuncs.com",
+			"eu-west-1-oxs":               "qualitycheck.aliyuncs.com",
+			"cn-beijing-finance-1":        "qualitycheck.aliyuncs.com",
+			"cn-hangzhou-internal-test-3": "qualitycheck.aliyuncs.com",
+			"cn-hangzhou-internal-test-2": "qualitycheck.aliyuncs.com",
+			"cn-shenzhen-finance-1":       "qualitycheck.aliyuncs.com",
+			"me-east-1":                   "qualitycheck.aliyuncs.com",
+			"cn-chengdu":                  "qualitycheck.aliyuncs.com",
+			"cn-hangzhou-test-306":        "qualitycheck.aliyuncs.com",
+			"cn-hangzhou-finance":         "qualitycheck.aliyuncs.com",
+			"cn-beijing-nu16-b01":         "qualitycheck.aliyuncs.com",
+			"cn-edge-1":                   "qualitycheck.aliyuncs.com",
+			"cn-huhehaote":                "qualitycheck.aliyuncs.com",
+			"cn-fujian":                   "qualitycheck.aliyuncs.com",
+			"ap-northeast-2-pop":          "qualitycheck.aliyuncs.com",
+		}
+	}
+	return EndpointMap
+}
+
+// GetEndpointType Get Endpoint Type Value
+func GetEndpointType() string {
+	return EndpointType
+}