Browse Source

Support continuous pushing.

sdk-team 6 years ago
parent
commit
b87d983ceb

+ 3 - 0
ChangeLog.txt

@@ -1,3 +1,6 @@
+2019-10-14 Version: 1.60.196
+- Support continuous pushing.
+
 2019-10-13 Version: 1.60.195
 - Add instance relevant interface.
 

+ 25 - 0
services/push/client.go

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

+ 105 - 0
services/push/complete_continuously_push.go

@@ -0,0 +1,105 @@
+package push
+
+//Licensed under the Apache License, Version 2.0 (the "License");
+//you may not use this file except in compliance with the License.
+//You may obtain a copy of the License at
+//
+//http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing, software
+//distributed under the License is distributed on an "AS IS" BASIS,
+//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//See the License for the specific language governing permissions and
+//limitations under the License.
+//
+// Code generated by Alibaba Cloud SDK Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+import (
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
+)
+
+// CompleteContinuouslyPush invokes the push.CompleteContinuouslyPush API synchronously
+// api document: https://help.aliyun.com/api/push/completecontinuouslypush.html
+func (client *Client) CompleteContinuouslyPush(request *CompleteContinuouslyPushRequest) (response *CompleteContinuouslyPushResponse, err error) {
+	response = CreateCompleteContinuouslyPushResponse()
+	err = client.DoAction(request, response)
+	return
+}
+
+// CompleteContinuouslyPushWithChan invokes the push.CompleteContinuouslyPush API asynchronously
+// api document: https://help.aliyun.com/api/push/completecontinuouslypush.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) CompleteContinuouslyPushWithChan(request *CompleteContinuouslyPushRequest) (<-chan *CompleteContinuouslyPushResponse, <-chan error) {
+	responseChan := make(chan *CompleteContinuouslyPushResponse, 1)
+	errChan := make(chan error, 1)
+	err := client.AddAsyncTask(func() {
+		defer close(responseChan)
+		defer close(errChan)
+		response, err := client.CompleteContinuouslyPush(request)
+		if err != nil {
+			errChan <- err
+		} else {
+			responseChan <- response
+		}
+	})
+	if err != nil {
+		errChan <- err
+		close(responseChan)
+		close(errChan)
+	}
+	return responseChan, errChan
+}
+
+// CompleteContinuouslyPushWithCallback invokes the push.CompleteContinuouslyPush API asynchronously
+// api document: https://help.aliyun.com/api/push/completecontinuouslypush.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) CompleteContinuouslyPushWithCallback(request *CompleteContinuouslyPushRequest, callback func(response *CompleteContinuouslyPushResponse, err error)) <-chan int {
+	result := make(chan int, 1)
+	err := client.AddAsyncTask(func() {
+		var response *CompleteContinuouslyPushResponse
+		var err error
+		defer close(result)
+		response, err = client.CompleteContinuouslyPush(request)
+		callback(response, err)
+		result <- 1
+	})
+	if err != nil {
+		defer close(result)
+		callback(nil, err)
+		result <- 0
+	}
+	return result
+}
+
+// CompleteContinuouslyPushRequest is the request struct for api CompleteContinuouslyPush
+type CompleteContinuouslyPushRequest struct {
+	*requests.RpcRequest
+	MessageId string           `position:"Query" name:"MessageId"`
+	AppKey    requests.Integer `position:"Query" name:"AppKey"`
+}
+
+// CompleteContinuouslyPushResponse is the response struct for api CompleteContinuouslyPush
+type CompleteContinuouslyPushResponse struct {
+	*responses.BaseResponse
+	RequestId string `json:"RequestId" xml:"RequestId"`
+	MessageId string `json:"MessageId" xml:"MessageId"`
+}
+
+// CreateCompleteContinuouslyPushRequest creates a request to invoke CompleteContinuouslyPush API
+func CreateCompleteContinuouslyPushRequest() (request *CompleteContinuouslyPushRequest) {
+	request = &CompleteContinuouslyPushRequest{
+		RpcRequest: &requests.RpcRequest{},
+	}
+	request.InitWithApiInfo("Push", "2016-08-01", "CompleteContinuouslyPush", "", "")
+	return
+}
+
+// CreateCompleteContinuouslyPushResponse creates a response to parse from CompleteContinuouslyPush response
+func CreateCompleteContinuouslyPushResponse() (response *CompleteContinuouslyPushResponse) {
+	response = &CompleteContinuouslyPushResponse{
+		BaseResponse: &responses.BaseResponse{},
+	}
+	return
+}

+ 107 - 0
services/push/continuously_push.go

@@ -0,0 +1,107 @@
+package push
+
+//Licensed under the Apache License, Version 2.0 (the "License");
+//you may not use this file except in compliance with the License.
+//You may obtain a copy of the License at
+//
+//http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing, software
+//distributed under the License is distributed on an "AS IS" BASIS,
+//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//See the License for the specific language governing permissions and
+//limitations under the License.
+//
+// Code generated by Alibaba Cloud SDK Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+import (
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
+)
+
+// ContinuouslyPush invokes the push.ContinuouslyPush API synchronously
+// api document: https://help.aliyun.com/api/push/continuouslypush.html
+func (client *Client) ContinuouslyPush(request *ContinuouslyPushRequest) (response *ContinuouslyPushResponse, err error) {
+	response = CreateContinuouslyPushResponse()
+	err = client.DoAction(request, response)
+	return
+}
+
+// ContinuouslyPushWithChan invokes the push.ContinuouslyPush API asynchronously
+// api document: https://help.aliyun.com/api/push/continuouslypush.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) ContinuouslyPushWithChan(request *ContinuouslyPushRequest) (<-chan *ContinuouslyPushResponse, <-chan error) {
+	responseChan := make(chan *ContinuouslyPushResponse, 1)
+	errChan := make(chan error, 1)
+	err := client.AddAsyncTask(func() {
+		defer close(responseChan)
+		defer close(errChan)
+		response, err := client.ContinuouslyPush(request)
+		if err != nil {
+			errChan <- err
+		} else {
+			responseChan <- response
+		}
+	})
+	if err != nil {
+		errChan <- err
+		close(responseChan)
+		close(errChan)
+	}
+	return responseChan, errChan
+}
+
+// ContinuouslyPushWithCallback invokes the push.ContinuouslyPush API asynchronously
+// api document: https://help.aliyun.com/api/push/continuouslypush.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) ContinuouslyPushWithCallback(request *ContinuouslyPushRequest, callback func(response *ContinuouslyPushResponse, err error)) <-chan int {
+	result := make(chan int, 1)
+	err := client.AddAsyncTask(func() {
+		var response *ContinuouslyPushResponse
+		var err error
+		defer close(result)
+		response, err = client.ContinuouslyPush(request)
+		callback(response, err)
+		result <- 1
+	})
+	if err != nil {
+		defer close(result)
+		callback(nil, err)
+		result <- 0
+	}
+	return result
+}
+
+// ContinuouslyPushRequest is the request struct for api ContinuouslyPush
+type ContinuouslyPushRequest struct {
+	*requests.RpcRequest
+	MessageId   string           `position:"Query" name:"MessageId"`
+	Target      string           `position:"Query" name:"Target"`
+	AppKey      requests.Integer `position:"Query" name:"AppKey"`
+	TargetValue string           `position:"Query" name:"TargetValue"`
+}
+
+// ContinuouslyPushResponse is the response struct for api ContinuouslyPush
+type ContinuouslyPushResponse struct {
+	*responses.BaseResponse
+	RequestId string `json:"RequestId" xml:"RequestId"`
+	MessageId string `json:"MessageId" xml:"MessageId"`
+}
+
+// CreateContinuouslyPushRequest creates a request to invoke ContinuouslyPush API
+func CreateContinuouslyPushRequest() (request *ContinuouslyPushRequest) {
+	request = &ContinuouslyPushRequest{
+		RpcRequest: &requests.RpcRequest{},
+	}
+	request.InitWithApiInfo("Push", "2016-08-01", "ContinuouslyPush", "", "")
+	return
+}
+
+// CreateContinuouslyPushResponse creates a response to parse from ContinuouslyPush response
+func CreateContinuouslyPushResponse() (response *ContinuouslyPushResponse) {
+	response = &ContinuouslyPushResponse{
+		BaseResponse: &responses.BaseResponse{},
+	}
+	return
+}

+ 75 - 0
services/push/endpoint.go

@@ -0,0 +1,75 @@
+package push
+
+// 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": "cloudpush.aliyuncs.com",
+			"cn-shenzhen-su18-b01":        "cloudpush.aliyuncs.com",
+			"cn-beijing":                  "cloudpush.aliyuncs.com",
+			"cn-shanghai-inner":           "cloudpush.aliyuncs.com",
+			"cn-hangzhou-internal-prod-1": "cloudpush.aliyuncs.com",
+			"cn-north-2-gov-1":            "cloudpush.aliyuncs.com",
+			"cn-yushanfang":               "cloudpush.aliyuncs.com",
+			"cn-qingdao-nebula":           "cloudpush.aliyuncs.com",
+			"cn-beijing-finance-pop":      "cloudpush.aliyuncs.com",
+			"cn-wuhan":                    "cloudpush.aliyuncs.com",
+			"cn-zhangjiakou":              "cloudpush.aliyuncs.com",
+			"us-west-1":                   "cloudpush.aliyuncs.com",
+			"rus-west-1-pop":              "cloudpush.aliyuncs.com",
+			"cn-shanghai-et15-b01":        "cloudpush.aliyuncs.com",
+			"cn-hangzhou-bj-b01":          "cloudpush.aliyuncs.com",
+			"cn-zhangbei-na61-b01":        "cloudpush.aliyuncs.com",
+			"ap-northeast-1":              "cloudpush.aliyuncs.com",
+			"cn-shanghai-et2-b01":         "cloudpush.aliyuncs.com",
+			"ap-southeast-1":              "cloudpush.aliyuncs.com",
+			"ap-southeast-2":              "cloudpush.aliyuncs.com",
+			"ap-southeast-3":              "cloudpush.aliyuncs.com",
+			"ap-southeast-5":              "cloudpush.aliyuncs.com",
+			"us-east-1":                   "cloudpush.aliyuncs.com",
+			"cn-shenzhen-inner":           "cloudpush.aliyuncs.com",
+			"cn-zhangjiakou-na62-a01":     "cloudpush.aliyuncs.com",
+			"cn-beijing-gov-1":            "cloudpush.aliyuncs.com",
+			"ap-south-1":                  "cloudpush.aliyuncs.com",
+			"cn-shenzhen-st4-d01":         "cloudpush.aliyuncs.com",
+			"cn-haidian-cm12-c01":         "cloudpush.aliyuncs.com",
+			"cn-qingdao":                  "cloudpush.aliyuncs.com",
+			"cn-hongkong-finance-pop":     "cloudpush.aliyuncs.com",
+			"cn-shanghai":                 "cloudpush.aliyuncs.com",
+			"cn-shanghai-finance-1":       "cloudpush.aliyuncs.com",
+			"cn-hongkong":                 "cloudpush.aliyuncs.com",
+			"eu-central-1":                "cloudpush.aliyuncs.com",
+			"cn-shenzhen":                 "cloudpush.aliyuncs.com",
+			"cn-zhengzhou-nebula-1":       "cloudpush.aliyuncs.com",
+			"eu-west-1":                   "cloudpush.aliyuncs.com",
+			"cn-hangzhou-internal-test-1": "cloudpush.aliyuncs.com",
+			"eu-west-1-oxs":               "cloudpush.aliyuncs.com",
+			"cn-beijing-finance-1":        "cloudpush.aliyuncs.com",
+			"cn-hangzhou-internal-test-3": "cloudpush.aliyuncs.com",
+			"cn-hangzhou-internal-test-2": "cloudpush.aliyuncs.com",
+			"cn-shenzhen-finance-1":       "cloudpush.aliyuncs.com",
+			"me-east-1":                   "cloudpush.aliyuncs.com",
+			"cn-chengdu":                  "cloudpush.aliyuncs.com",
+			"cn-hangzhou-test-306":        "cloudpush.aliyuncs.com",
+			"cn-hangzhou-finance":         "cloudpush.aliyuncs.com",
+			"cn-beijing-nu16-b01":         "cloudpush.aliyuncs.com",
+			"cn-edge-1":                   "cloudpush.aliyuncs.com",
+			"cn-huhehaote":                "cloudpush.aliyuncs.com",
+			"cn-fujian":                   "cloudpush.aliyuncs.com",
+			"ap-northeast-2-pop":          "cloudpush.aliyuncs.com",
+			"cn-hangzhou":                 "cloudpush.aliyuncs.com",
+		}
+	}
+	return EndpointMap
+}
+
+// GetEndpointType Get Endpoint Type Value
+func GetEndpointType() string {
+	return EndpointType
+}