package dyvmsapi

//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"
)

// SmartCallOperate invokes the dyvmsapi.SmartCallOperate API synchronously
func (client *Client) SmartCallOperate(request *SmartCallOperateRequest) (response *SmartCallOperateResponse, err error) {
	response = CreateSmartCallOperateResponse()
	err = client.DoAction(request, response)
	return
}

// SmartCallOperateWithChan invokes the dyvmsapi.SmartCallOperate API asynchronously
func (client *Client) SmartCallOperateWithChan(request *SmartCallOperateRequest) (<-chan *SmartCallOperateResponse, <-chan error) {
	responseChan := make(chan *SmartCallOperateResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.SmartCallOperate(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// SmartCallOperateWithCallback invokes the dyvmsapi.SmartCallOperate API asynchronously
func (client *Client) SmartCallOperateWithCallback(request *SmartCallOperateRequest, callback func(response *SmartCallOperateResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *SmartCallOperateResponse
		var err error
		defer close(result)
		response, err = client.SmartCallOperate(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// SmartCallOperateRequest is the request struct for api SmartCallOperate
type SmartCallOperateRequest struct {
	*requests.RpcRequest
	CallId               string           `position:"Query" name:"CallId"`
	ResourceOwnerId      requests.Integer `position:"Query" name:"ResourceOwnerId"`
	Param                string           `position:"Query" name:"Param"`
	ResourceOwnerAccount string           `position:"Query" name:"ResourceOwnerAccount"`
	OwnerId              requests.Integer `position:"Query" name:"OwnerId"`
	Command              string           `position:"Query" name:"Command"`
}

// SmartCallOperateResponse is the response struct for api SmartCallOperate
type SmartCallOperateResponse struct {
	*responses.BaseResponse
	RequestId string `json:"RequestId" xml:"RequestId"`
	Status    bool   `json:"Status" xml:"Status"`
	Code      string `json:"Code" xml:"Code"`
	Message   string `json:"Message" xml:"Message"`
}

// CreateSmartCallOperateRequest creates a request to invoke SmartCallOperate API
func CreateSmartCallOperateRequest() (request *SmartCallOperateRequest) {
	request = &SmartCallOperateRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("Dyvmsapi", "2017-05-25", "SmartCallOperate", "dyvms", "openAPI")
	request.Method = requests.POST
	return
}

// CreateSmartCallOperateResponse creates a response to parse from SmartCallOperate response
func CreateSmartCallOperateResponse() (response *SmartCallOperateResponse) {
	response = &SmartCallOperateResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
