Browse Source

Init MQTT SDK .

sdk-team 5 years ago
parent
commit
07fdde6eb0

+ 3 - 0
ChangeLog.txt

@@ -1,3 +1,6 @@
+2020-02-13 Version: v1.60.361
+- Init MQTT SDK .
+
 2020-02-12 Version: v1.60.360
 - Generated 2020-01-21 for `DemoCenter`.
 - Support to create, describe and expire demo access token.

+ 107 - 0
services/onsmqtt/apply_token.go

@@ -0,0 +1,107 @@
+package onsmqtt
+
+//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"
+)
+
+// ApplyToken invokes the onsmqtt.ApplyToken API synchronously
+// api document: https://help.aliyun.com/api/onsmqtt/applytoken.html
+func (client *Client) ApplyToken(request *ApplyTokenRequest) (response *ApplyTokenResponse, err error) {
+	response = CreateApplyTokenResponse()
+	err = client.DoAction(request, response)
+	return
+}
+
+// ApplyTokenWithChan invokes the onsmqtt.ApplyToken API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/applytoken.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) ApplyTokenWithChan(request *ApplyTokenRequest) (<-chan *ApplyTokenResponse, <-chan error) {
+	responseChan := make(chan *ApplyTokenResponse, 1)
+	errChan := make(chan error, 1)
+	err := client.AddAsyncTask(func() {
+		defer close(responseChan)
+		defer close(errChan)
+		response, err := client.ApplyToken(request)
+		if err != nil {
+			errChan <- err
+		} else {
+			responseChan <- response
+		}
+	})
+	if err != nil {
+		errChan <- err
+		close(responseChan)
+		close(errChan)
+	}
+	return responseChan, errChan
+}
+
+// ApplyTokenWithCallback invokes the onsmqtt.ApplyToken API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/applytoken.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) ApplyTokenWithCallback(request *ApplyTokenRequest, callback func(response *ApplyTokenResponse, err error)) <-chan int {
+	result := make(chan int, 1)
+	err := client.AddAsyncTask(func() {
+		var response *ApplyTokenResponse
+		var err error
+		defer close(result)
+		response, err = client.ApplyToken(request)
+		callback(response, err)
+		result <- 1
+	})
+	if err != nil {
+		defer close(result)
+		callback(nil, err)
+		result <- 0
+	}
+	return result
+}
+
+// ApplyTokenRequest is the request struct for api ApplyToken
+type ApplyTokenRequest struct {
+	*requests.RpcRequest
+	ExpireTime requests.Integer `position:"Query" name:"ExpireTime"`
+	Resources  string           `position:"Query" name:"Resources"`
+	InstanceId string           `position:"Query" name:"InstanceId"`
+	Actions    string           `position:"Query" name:"Actions"`
+}
+
+// ApplyTokenResponse is the response struct for api ApplyToken
+type ApplyTokenResponse struct {
+	*responses.BaseResponse
+	Token     string `json:"Token" xml:"Token"`
+	RequestId string `json:"RequestId" xml:"RequestId"`
+}
+
+// CreateApplyTokenRequest creates a request to invoke ApplyToken API
+func CreateApplyTokenRequest() (request *ApplyTokenRequest) {
+	request = &ApplyTokenRequest{
+		RpcRequest: &requests.RpcRequest{},
+	}
+	request.InitWithApiInfo("OnsMqtt", "2019-12-11", "ApplyToken", "onsmqtt", "openAPI")
+	return
+}
+
+// CreateApplyTokenResponse creates a response to parse from ApplyToken response
+func CreateApplyTokenResponse() (response *ApplyTokenResponse) {
+	response = &ApplyTokenResponse{
+		BaseResponse: &responses.BaseResponse{},
+	}
+	return
+}

+ 105 - 0
services/onsmqtt/batch_query_session_by_client_ids.go

@@ -0,0 +1,105 @@
+package onsmqtt
+
+//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"
+)
+
+// BatchQuerySessionByClientIds invokes the onsmqtt.BatchQuerySessionByClientIds API synchronously
+// api document: https://help.aliyun.com/api/onsmqtt/batchquerysessionbyclientids.html
+func (client *Client) BatchQuerySessionByClientIds(request *BatchQuerySessionByClientIdsRequest) (response *BatchQuerySessionByClientIdsResponse, err error) {
+	response = CreateBatchQuerySessionByClientIdsResponse()
+	err = client.DoAction(request, response)
+	return
+}
+
+// BatchQuerySessionByClientIdsWithChan invokes the onsmqtt.BatchQuerySessionByClientIds API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/batchquerysessionbyclientids.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) BatchQuerySessionByClientIdsWithChan(request *BatchQuerySessionByClientIdsRequest) (<-chan *BatchQuerySessionByClientIdsResponse, <-chan error) {
+	responseChan := make(chan *BatchQuerySessionByClientIdsResponse, 1)
+	errChan := make(chan error, 1)
+	err := client.AddAsyncTask(func() {
+		defer close(responseChan)
+		defer close(errChan)
+		response, err := client.BatchQuerySessionByClientIds(request)
+		if err != nil {
+			errChan <- err
+		} else {
+			responseChan <- response
+		}
+	})
+	if err != nil {
+		errChan <- err
+		close(responseChan)
+		close(errChan)
+	}
+	return responseChan, errChan
+}
+
+// BatchQuerySessionByClientIdsWithCallback invokes the onsmqtt.BatchQuerySessionByClientIds API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/batchquerysessionbyclientids.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) BatchQuerySessionByClientIdsWithCallback(request *BatchQuerySessionByClientIdsRequest, callback func(response *BatchQuerySessionByClientIdsResponse, err error)) <-chan int {
+	result := make(chan int, 1)
+	err := client.AddAsyncTask(func() {
+		var response *BatchQuerySessionByClientIdsResponse
+		var err error
+		defer close(result)
+		response, err = client.BatchQuerySessionByClientIds(request)
+		callback(response, err)
+		result <- 1
+	})
+	if err != nil {
+		defer close(result)
+		callback(nil, err)
+		result <- 0
+	}
+	return result
+}
+
+// BatchQuerySessionByClientIdsRequest is the request struct for api BatchQuerySessionByClientIds
+type BatchQuerySessionByClientIdsRequest struct {
+	*requests.RpcRequest
+	ClientIdList *[]string `position:"Query" name:"ClientIdList"  type:"Repeated"`
+	InstanceId   string    `position:"Query" name:"InstanceId"`
+}
+
+// BatchQuerySessionByClientIdsResponse is the response struct for api BatchQuerySessionByClientIds
+type BatchQuerySessionByClientIdsResponse struct {
+	*responses.BaseResponse
+	RequestId        string                 `json:"RequestId" xml:"RequestId"`
+	OnlineStatusList []OnlineStatusListItem `json:"OnlineStatusList" xml:"OnlineStatusList"`
+}
+
+// CreateBatchQuerySessionByClientIdsRequest creates a request to invoke BatchQuerySessionByClientIds API
+func CreateBatchQuerySessionByClientIdsRequest() (request *BatchQuerySessionByClientIdsRequest) {
+	request = &BatchQuerySessionByClientIdsRequest{
+		RpcRequest: &requests.RpcRequest{},
+	}
+	request.InitWithApiInfo("OnsMqtt", "2019-12-11", "BatchQuerySessionByClientIds", "onsmqtt", "openAPI")
+	return
+}
+
+// CreateBatchQuerySessionByClientIdsResponse creates a response to parse from BatchQuerySessionByClientIds response
+func CreateBatchQuerySessionByClientIdsResponse() (response *BatchQuerySessionByClientIdsResponse) {
+	response = &BatchQuerySessionByClientIdsResponse{
+		BaseResponse: &responses.BaseResponse{},
+	}
+	return
+}

+ 114 - 0
services/onsmqtt/batch_send_messages.go

@@ -0,0 +1,114 @@
+package onsmqtt
+
+//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"
+)
+
+// BatchSendMessages invokes the onsmqtt.BatchSendMessages API synchronously
+// api document: https://help.aliyun.com/api/onsmqtt/batchsendmessages.html
+func (client *Client) BatchSendMessages(request *BatchSendMessagesRequest) (response *BatchSendMessagesResponse, err error) {
+	response = CreateBatchSendMessagesResponse()
+	err = client.DoAction(request, response)
+	return
+}
+
+// BatchSendMessagesWithChan invokes the onsmqtt.BatchSendMessages API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/batchsendmessages.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) BatchSendMessagesWithChan(request *BatchSendMessagesRequest) (<-chan *BatchSendMessagesResponse, <-chan error) {
+	responseChan := make(chan *BatchSendMessagesResponse, 1)
+	errChan := make(chan error, 1)
+	err := client.AddAsyncTask(func() {
+		defer close(responseChan)
+		defer close(errChan)
+		response, err := client.BatchSendMessages(request)
+		if err != nil {
+			errChan <- err
+		} else {
+			responseChan <- response
+		}
+	})
+	if err != nil {
+		errChan <- err
+		close(responseChan)
+		close(errChan)
+	}
+	return responseChan, errChan
+}
+
+// BatchSendMessagesWithCallback invokes the onsmqtt.BatchSendMessages API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/batchsendmessages.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) BatchSendMessagesWithCallback(request *BatchSendMessagesRequest, callback func(response *BatchSendMessagesResponse, err error)) <-chan int {
+	result := make(chan int, 1)
+	err := client.AddAsyncTask(func() {
+		var response *BatchSendMessagesResponse
+		var err error
+		defer close(result)
+		response, err = client.BatchSendMessages(request)
+		callback(response, err)
+		result <- 1
+	})
+	if err != nil {
+		defer close(result)
+		callback(nil, err)
+		result <- 0
+	}
+	return result
+}
+
+// BatchSendMessagesRequest is the request struct for api BatchSendMessages
+type BatchSendMessagesRequest struct {
+	*requests.RpcRequest
+	NoPersistFlag requests.Boolean             `position:"Query" name:"NoPersistFlag"`
+	InstanceId    string                       `position:"Query" name:"InstanceId"`
+	Messages      *[]BatchSendMessagesMessages `position:"Query" name:"Messages"  type:"Repeated"`
+}
+
+// BatchSendMessagesMessages is a repeated param struct in BatchSendMessagesRequest
+type BatchSendMessagesMessages struct {
+	Payload   string    `name:"Payload"`
+	Topics    *[]string `name:"Topics" type:"Repeated"`
+	Id        string    `name:"Id"`
+	ReceiptId string    `name:"ReceiptId"`
+}
+
+// BatchSendMessagesResponse is the response struct for api BatchSendMessages
+type BatchSendMessagesResponse struct {
+	*responses.BaseResponse
+	RequestId string          `json:"RequestId" xml:"RequestId"`
+	Responses []ResponsesItem `json:"Responses" xml:"Responses"`
+}
+
+// CreateBatchSendMessagesRequest creates a request to invoke BatchSendMessages API
+func CreateBatchSendMessagesRequest() (request *BatchSendMessagesRequest) {
+	request = &BatchSendMessagesRequest{
+		RpcRequest: &requests.RpcRequest{},
+	}
+	request.InitWithApiInfo("OnsMqtt", "2019-12-11", "BatchSendMessages", "onsmqtt", "openAPI")
+	return
+}
+
+// CreateBatchSendMessagesResponse creates a response to parse from BatchSendMessages response
+func CreateBatchSendMessagesResponse() (response *BatchSendMessagesResponse) {
+	response = &BatchSendMessagesResponse{
+		BaseResponse: &responses.BaseResponse{},
+	}
+	return
+}

+ 104 - 0
services/onsmqtt/client.go

@@ -0,0 +1,104 @@
+package onsmqtt
+
+//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"
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider"
+)
+
+// Client is the sdk client struct, each func corresponds to an OpenAPI
+type Client struct {
+	sdk.Client
+}
+
+// NewClient creates a sdk client with environment variables
+func NewClient() (client *Client, err error) {
+	client = &Client{}
+	err = client.Init()
+	return
+}
+
+// NewClientWithProvider creates a sdk client with providers
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
+func NewClientWithProvider(regionId string, providers ...provider.Provider) (client *Client, err error) {
+	client = &Client{}
+	var pc provider.Provider
+	if len(providers) == 0 {
+		pc = provider.DefaultChain
+	} else {
+		pc = provider.NewProviderChain(providers)
+	}
+	err = client.InitWithProviderChain(regionId, pc)
+	return
+}
+
+// NewClientWithOptions creates a sdk client with regionId/sdkConfig/credential
+// this is the common api to create a sdk client
+func NewClientWithOptions(regionId string, config *sdk.Config, credential auth.Credential) (client *Client, err error) {
+	client = &Client{}
+	err = client.InitWithOptions(regionId, config, credential)
+	return
+}
+
+// NewClientWithAccessKey is a shortcut to create sdk client with accesskey
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
+func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (client *Client, err error) {
+	client = &Client{}
+	err = client.InitWithAccessKey(regionId, accessKeyId, accessKeySecret)
+	return
+}
+
+// NewClientWithStsToken is a shortcut to create sdk client with sts token
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
+func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken string) (client *Client, err error) {
+	client = &Client{}
+	err = client.InitWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken)
+	return
+}
+
+// NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
+func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
+	client = &Client{}
+	err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
+	return
+}
+
+// NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn and policy
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
+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)
+	return
+}
+
+// NewClientWithEcsRamRole is a shortcut to create sdk client with ecs ram role
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
+func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) {
+	client = &Client{}
+	err = client.InitWithEcsRamRole(regionId, roleName)
+	return
+}
+
+// NewClientWithRsaKeyPair is a shortcut to create sdk client with rsa key pair
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
+func NewClientWithRsaKeyPair(regionId string, publicKeyId, privateKey string, sessionExpiration int) (client *Client, err error) {
+	client = &Client{}
+	err = client.InitWithRsaKeyPair(regionId, publicKeyId, privateKey, sessionExpiration)
+	return
+}

+ 105 - 0
services/onsmqtt/query_session_by_client_id.go

@@ -0,0 +1,105 @@
+package onsmqtt
+
+//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"
+)
+
+// QuerySessionByClientId invokes the onsmqtt.QuerySessionByClientId API synchronously
+// api document: https://help.aliyun.com/api/onsmqtt/querysessionbyclientid.html
+func (client *Client) QuerySessionByClientId(request *QuerySessionByClientIdRequest) (response *QuerySessionByClientIdResponse, err error) {
+	response = CreateQuerySessionByClientIdResponse()
+	err = client.DoAction(request, response)
+	return
+}
+
+// QuerySessionByClientIdWithChan invokes the onsmqtt.QuerySessionByClientId API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/querysessionbyclientid.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) QuerySessionByClientIdWithChan(request *QuerySessionByClientIdRequest) (<-chan *QuerySessionByClientIdResponse, <-chan error) {
+	responseChan := make(chan *QuerySessionByClientIdResponse, 1)
+	errChan := make(chan error, 1)
+	err := client.AddAsyncTask(func() {
+		defer close(responseChan)
+		defer close(errChan)
+		response, err := client.QuerySessionByClientId(request)
+		if err != nil {
+			errChan <- err
+		} else {
+			responseChan <- response
+		}
+	})
+	if err != nil {
+		errChan <- err
+		close(responseChan)
+		close(errChan)
+	}
+	return responseChan, errChan
+}
+
+// QuerySessionByClientIdWithCallback invokes the onsmqtt.QuerySessionByClientId API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/querysessionbyclientid.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) QuerySessionByClientIdWithCallback(request *QuerySessionByClientIdRequest, callback func(response *QuerySessionByClientIdResponse, err error)) <-chan int {
+	result := make(chan int, 1)
+	err := client.AddAsyncTask(func() {
+		var response *QuerySessionByClientIdResponse
+		var err error
+		defer close(result)
+		response, err = client.QuerySessionByClientId(request)
+		callback(response, err)
+		result <- 1
+	})
+	if err != nil {
+		defer close(result)
+		callback(nil, err)
+		result <- 0
+	}
+	return result
+}
+
+// QuerySessionByClientIdRequest is the request struct for api QuerySessionByClientId
+type QuerySessionByClientIdRequest struct {
+	*requests.RpcRequest
+	ClientId   string `position:"Query" name:"ClientId"`
+	InstanceId string `position:"Query" name:"InstanceId"`
+}
+
+// QuerySessionByClientIdResponse is the response struct for api QuerySessionByClientId
+type QuerySessionByClientIdResponse struct {
+	*responses.BaseResponse
+	RequestId    string `json:"RequestId" xml:"RequestId"`
+	OnlineStatus bool   `json:"OnlineStatus" xml:"OnlineStatus"`
+}
+
+// CreateQuerySessionByClientIdRequest creates a request to invoke QuerySessionByClientId API
+func CreateQuerySessionByClientIdRequest() (request *QuerySessionByClientIdRequest) {
+	request = &QuerySessionByClientIdRequest{
+		RpcRequest: &requests.RpcRequest{},
+	}
+	request.InitWithApiInfo("OnsMqtt", "2019-12-11", "QuerySessionByClientId", "onsmqtt", "openAPI")
+	return
+}
+
+// CreateQuerySessionByClientIdResponse creates a response to parse from QuerySessionByClientId response
+func CreateQuerySessionByClientIdResponse() (response *QuerySessionByClientIdResponse) {
+	response = &QuerySessionByClientIdResponse{
+		BaseResponse: &responses.BaseResponse{},
+	}
+	return
+}

+ 105 - 0
services/onsmqtt/query_token.go

@@ -0,0 +1,105 @@
+package onsmqtt
+
+//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"
+)
+
+// QueryToken invokes the onsmqtt.QueryToken API synchronously
+// api document: https://help.aliyun.com/api/onsmqtt/querytoken.html
+func (client *Client) QueryToken(request *QueryTokenRequest) (response *QueryTokenResponse, err error) {
+	response = CreateQueryTokenResponse()
+	err = client.DoAction(request, response)
+	return
+}
+
+// QueryTokenWithChan invokes the onsmqtt.QueryToken API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/querytoken.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) QueryTokenWithChan(request *QueryTokenRequest) (<-chan *QueryTokenResponse, <-chan error) {
+	responseChan := make(chan *QueryTokenResponse, 1)
+	errChan := make(chan error, 1)
+	err := client.AddAsyncTask(func() {
+		defer close(responseChan)
+		defer close(errChan)
+		response, err := client.QueryToken(request)
+		if err != nil {
+			errChan <- err
+		} else {
+			responseChan <- response
+		}
+	})
+	if err != nil {
+		errChan <- err
+		close(responseChan)
+		close(errChan)
+	}
+	return responseChan, errChan
+}
+
+// QueryTokenWithCallback invokes the onsmqtt.QueryToken API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/querytoken.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) QueryTokenWithCallback(request *QueryTokenRequest, callback func(response *QueryTokenResponse, err error)) <-chan int {
+	result := make(chan int, 1)
+	err := client.AddAsyncTask(func() {
+		var response *QueryTokenResponse
+		var err error
+		defer close(result)
+		response, err = client.QueryToken(request)
+		callback(response, err)
+		result <- 1
+	})
+	if err != nil {
+		defer close(result)
+		callback(nil, err)
+		result <- 0
+	}
+	return result
+}
+
+// QueryTokenRequest is the request struct for api QueryToken
+type QueryTokenRequest struct {
+	*requests.RpcRequest
+	Token      string `position:"Query" name:"Token"`
+	InstanceId string `position:"Query" name:"InstanceId"`
+}
+
+// QueryTokenResponse is the response struct for api QueryToken
+type QueryTokenResponse struct {
+	*responses.BaseResponse
+	TokenStatus bool   `json:"TokenStatus" xml:"TokenStatus"`
+	RequestId   string `json:"RequestId" xml:"RequestId"`
+}
+
+// CreateQueryTokenRequest creates a request to invoke QueryToken API
+func CreateQueryTokenRequest() (request *QueryTokenRequest) {
+	request = &QueryTokenRequest{
+		RpcRequest: &requests.RpcRequest{},
+	}
+	request.InitWithApiInfo("OnsMqtt", "2019-12-11", "QueryToken", "onsmqtt", "openAPI")
+	return
+}
+
+// CreateQueryTokenResponse creates a response to parse from QueryToken response
+func CreateQueryTokenResponse() (response *QueryTokenResponse) {
+	response = &QueryTokenResponse{
+		BaseResponse: &responses.BaseResponse{},
+	}
+	return
+}

+ 104 - 0
services/onsmqtt/revoke_token.go

@@ -0,0 +1,104 @@
+package onsmqtt
+
+//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"
+)
+
+// RevokeToken invokes the onsmqtt.RevokeToken API synchronously
+// api document: https://help.aliyun.com/api/onsmqtt/revoketoken.html
+func (client *Client) RevokeToken(request *RevokeTokenRequest) (response *RevokeTokenResponse, err error) {
+	response = CreateRevokeTokenResponse()
+	err = client.DoAction(request, response)
+	return
+}
+
+// RevokeTokenWithChan invokes the onsmqtt.RevokeToken API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/revoketoken.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) RevokeTokenWithChan(request *RevokeTokenRequest) (<-chan *RevokeTokenResponse, <-chan error) {
+	responseChan := make(chan *RevokeTokenResponse, 1)
+	errChan := make(chan error, 1)
+	err := client.AddAsyncTask(func() {
+		defer close(responseChan)
+		defer close(errChan)
+		response, err := client.RevokeToken(request)
+		if err != nil {
+			errChan <- err
+		} else {
+			responseChan <- response
+		}
+	})
+	if err != nil {
+		errChan <- err
+		close(responseChan)
+		close(errChan)
+	}
+	return responseChan, errChan
+}
+
+// RevokeTokenWithCallback invokes the onsmqtt.RevokeToken API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/revoketoken.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) RevokeTokenWithCallback(request *RevokeTokenRequest, callback func(response *RevokeTokenResponse, err error)) <-chan int {
+	result := make(chan int, 1)
+	err := client.AddAsyncTask(func() {
+		var response *RevokeTokenResponse
+		var err error
+		defer close(result)
+		response, err = client.RevokeToken(request)
+		callback(response, err)
+		result <- 1
+	})
+	if err != nil {
+		defer close(result)
+		callback(nil, err)
+		result <- 0
+	}
+	return result
+}
+
+// RevokeTokenRequest is the request struct for api RevokeToken
+type RevokeTokenRequest struct {
+	*requests.RpcRequest
+	Token      string `position:"Query" name:"Token"`
+	InstanceId string `position:"Query" name:"InstanceId"`
+}
+
+// RevokeTokenResponse is the response struct for api RevokeToken
+type RevokeTokenResponse struct {
+	*responses.BaseResponse
+	RequestId string `json:"RequestId" xml:"RequestId"`
+}
+
+// CreateRevokeTokenRequest creates a request to invoke RevokeToken API
+func CreateRevokeTokenRequest() (request *RevokeTokenRequest) {
+	request = &RevokeTokenRequest{
+		RpcRequest: &requests.RpcRequest{},
+	}
+	request.InitWithApiInfo("OnsMqtt", "2019-12-11", "RevokeToken", "onsmqtt", "openAPI")
+	return
+}
+
+// CreateRevokeTokenResponse creates a response to parse from RevokeToken response
+func CreateRevokeTokenResponse() (response *RevokeTokenResponse) {
+	response = &RevokeTokenResponse{
+		BaseResponse: &responses.BaseResponse{},
+	}
+	return
+}

+ 108 - 0
services/onsmqtt/send_message.go

@@ -0,0 +1,108 @@
+package onsmqtt
+
+//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"
+)
+
+// SendMessage invokes the onsmqtt.SendMessage API synchronously
+// api document: https://help.aliyun.com/api/onsmqtt/sendmessage.html
+func (client *Client) SendMessage(request *SendMessageRequest) (response *SendMessageResponse, err error) {
+	response = CreateSendMessageResponse()
+	err = client.DoAction(request, response)
+	return
+}
+
+// SendMessageWithChan invokes the onsmqtt.SendMessage API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/sendmessage.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) SendMessageWithChan(request *SendMessageRequest) (<-chan *SendMessageResponse, <-chan error) {
+	responseChan := make(chan *SendMessageResponse, 1)
+	errChan := make(chan error, 1)
+	err := client.AddAsyncTask(func() {
+		defer close(responseChan)
+		defer close(errChan)
+		response, err := client.SendMessage(request)
+		if err != nil {
+			errChan <- err
+		} else {
+			responseChan <- response
+		}
+	})
+	if err != nil {
+		errChan <- err
+		close(responseChan)
+		close(errChan)
+	}
+	return responseChan, errChan
+}
+
+// SendMessageWithCallback invokes the onsmqtt.SendMessage API asynchronously
+// api document: https://help.aliyun.com/api/onsmqtt/sendmessage.html
+// asynchronous document: https://help.aliyun.com/document_detail/66220.html
+func (client *Client) SendMessageWithCallback(request *SendMessageRequest, callback func(response *SendMessageResponse, err error)) <-chan int {
+	result := make(chan int, 1)
+	err := client.AddAsyncTask(func() {
+		var response *SendMessageResponse
+		var err error
+		defer close(result)
+		response, err = client.SendMessage(request)
+		callback(response, err)
+		result <- 1
+	})
+	if err != nil {
+		defer close(result)
+		callback(nil, err)
+		result <- 0
+	}
+	return result
+}
+
+// SendMessageRequest is the request struct for api SendMessage
+type SendMessageRequest struct {
+	*requests.RpcRequest
+	NoPersistFlag requests.Boolean `position:"Query" name:"NoPersistFlag"`
+	MqttTopic     string           `position:"Query" name:"MqttTopic"`
+	InstanceId    string           `position:"Query" name:"InstanceId"`
+	Payload       string           `position:"Query" name:"Payload"`
+	ReceiptId     string           `position:"Query" name:"ReceiptId"`
+}
+
+// SendMessageResponse is the response struct for api SendMessage
+type SendMessageResponse struct {
+	*responses.BaseResponse
+	MsgId     string `json:"MsgId" xml:"MsgId"`
+	RequestId string `json:"RequestId" xml:"RequestId"`
+}
+
+// CreateSendMessageRequest creates a request to invoke SendMessage API
+func CreateSendMessageRequest() (request *SendMessageRequest) {
+	request = &SendMessageRequest{
+		RpcRequest: &requests.RpcRequest{},
+	}
+	request.InitWithApiInfo("OnsMqtt", "2019-12-11", "SendMessage", "onsmqtt", "openAPI")
+	return
+}
+
+// CreateSendMessageResponse creates a response to parse from SendMessage response
+func CreateSendMessageResponse() (response *SendMessageResponse) {
+	response = &SendMessageResponse{
+		BaseResponse: &responses.BaseResponse{},
+	}
+	return
+}

+ 21 - 0
services/onsmqtt/struct_online_status_list.go

@@ -0,0 +1,21 @@
+package onsmqtt
+
+//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.
+
+// OnlineStatusList is a nested struct in onsmqtt response
+type OnlineStatusList struct {
+	OnlineStatusListItem []OnlineStatusListItem `json:"OnlineStatusList" xml:"OnlineStatusList"`
+}

+ 22 - 0
services/onsmqtt/struct_online_status_list_item.go

@@ -0,0 +1,22 @@
+package onsmqtt
+
+//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.
+
+// OnlineStatusListItem is a nested struct in onsmqtt response
+type OnlineStatusListItem struct {
+	ClientId     string `json:"ClientId" xml:"ClientId"`
+	OnlineStatus bool   `json:"OnlineStatus" xml:"OnlineStatus"`
+}

+ 21 - 0
services/onsmqtt/struct_responses.go

@@ -0,0 +1,21 @@
+package onsmqtt
+
+//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.
+
+// Responses is a nested struct in onsmqtt response
+type Responses struct {
+	ResponsesItem []ResponsesItem `json:"Responses" xml:"Responses"`
+}

+ 24 - 0
services/onsmqtt/struct_responses_item.go

@@ -0,0 +1,24 @@
+package onsmqtt
+
+//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.
+
+// ResponsesItem is a nested struct in onsmqtt response
+type ResponsesItem struct {
+	Id           int    `json:"Id" xml:"Id"`
+	MsgId        string `json:"MsgId" xml:"MsgId"`
+	ErrorCode    int    `json:"ErrorCode" xml:"ErrorCode"`
+	ErrorMessage string `json:"ErrorMessage" xml:"ErrorMessage"`
+}