package rds

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

// PreCheckCreateOrderForRebuild invokes the rds.PreCheckCreateOrderForRebuild API synchronously
// api document: https://help.aliyun.com/api/rds/precheckcreateorderforrebuild.html
func (client *Client) PreCheckCreateOrderForRebuild(request *PreCheckCreateOrderForRebuildRequest) (response *PreCheckCreateOrderForRebuildResponse, err error) {
	response = CreatePreCheckCreateOrderForRebuildResponse()
	err = client.DoAction(request, response)
	return
}

// PreCheckCreateOrderForRebuildWithChan invokes the rds.PreCheckCreateOrderForRebuild API asynchronously
// api document: https://help.aliyun.com/api/rds/precheckcreateorderforrebuild.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) PreCheckCreateOrderForRebuildWithChan(request *PreCheckCreateOrderForRebuildRequest) (<-chan *PreCheckCreateOrderForRebuildResponse, <-chan error) {
	responseChan := make(chan *PreCheckCreateOrderForRebuildResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.PreCheckCreateOrderForRebuild(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// PreCheckCreateOrderForRebuildWithCallback invokes the rds.PreCheckCreateOrderForRebuild API asynchronously
// api document: https://help.aliyun.com/api/rds/precheckcreateorderforrebuild.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) PreCheckCreateOrderForRebuildWithCallback(request *PreCheckCreateOrderForRebuildRequest, callback func(response *PreCheckCreateOrderForRebuildResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *PreCheckCreateOrderForRebuildResponse
		var err error
		defer close(result)
		response, err = client.PreCheckCreateOrderForRebuild(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// PreCheckCreateOrderForRebuildRequest is the request struct for api PreCheckCreateOrderForRebuild
type PreCheckCreateOrderForRebuildRequest struct {
	*requests.RpcRequest
	OwnerId               requests.Integer `position:"Query" name:"OwnerId"`
	ResourceOwnerAccount  string           `position:"Query" name:"ResourceOwnerAccount"`
	ResourceOwnerId       requests.Integer `position:"Query" name:"ResourceOwnerId"`
	ClientToken           string           `position:"Query" name:"ClientToken"`
	CommodityCode         string           `position:"Query" name:"CommodityCode"`
	DBInstanceId          string           `position:"Query" name:"DBInstanceId"`
	ZoneId                string           `position:"Query" name:"ZoneId"`
	DBInstanceClass       string           `position:"Query" name:"DBInstanceClass"`
	PayType               string           `position:"Query" name:"PayType"`
	InstanceNetworkType   string           `position:"Query" name:"InstanceNetworkType"`
	UsedTime              string           `position:"Query" name:"UsedTime"`
	TimeType              string           `position:"Query" name:"TimeType"`
	AutoPay               requests.Boolean `position:"Query" name:"AutoPay"`
	Resource              string           `position:"Query" name:"Resource"`
	VPCId                 string           `position:"Query" name:"VPCId"`
	VSwitchId             string           `position:"Query" name:"VSwitchId"`
	AutoRenew             string           `position:"Query" name:"AutoRenew"`
	AgentId               string           `position:"Query" name:"AgentId"`
	PromotionCode         string           `position:"Query" name:"PromotionCode"`
	BusinessInfo          string           `position:"Query" name:"BusinessInfo"`
	DBInstanceDescription string           `position:"Query" name:"DBInstanceDescription"`
	OwnerAccount          string           `position:"Query" name:"OwnerAccount"`
	ResourceGroupId       string           `position:"Query" name:"ResourceGroupId"`
	RebuildInstanceFlag   requests.Boolean `position:"Query" name:"RebuildInstanceFlag"`
}

// PreCheckCreateOrderForRebuildResponse is the response struct for api PreCheckCreateOrderForRebuild
type PreCheckCreateOrderForRebuildResponse struct {
	*responses.BaseResponse
	RequestId      string                                  `json:"RequestId" xml:"RequestId"`
	PreCheckResult bool                                    `json:"PreCheckResult" xml:"PreCheckResult"`
	Failures       FailuresInPreCheckCreateOrderForRebuild `json:"Failures" xml:"Failures"`
}

// CreatePreCheckCreateOrderForRebuildRequest creates a request to invoke PreCheckCreateOrderForRebuild API
func CreatePreCheckCreateOrderForRebuildRequest() (request *PreCheckCreateOrderForRebuildRequest) {
	request = &PreCheckCreateOrderForRebuildRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("Rds", "2014-08-15", "PreCheckCreateOrderForRebuild", "rds", "openAPI")
	return
}

// CreatePreCheckCreateOrderForRebuildResponse creates a response to parse from PreCheckCreateOrderForRebuild response
func CreatePreCheckCreateOrderForRebuildResponse() (response *PreCheckCreateOrderForRebuildResponse) {
	response = &PreCheckCreateOrderForRebuildResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
