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

// PreCheckCreateOrderForDegrade invokes the rds.PreCheckCreateOrderForDegrade API synchronously
// api document: https://help.aliyun.com/api/rds/precheckcreateorderfordegrade.html
func (client *Client) PreCheckCreateOrderForDegrade(request *PreCheckCreateOrderForDegradeRequest) (response *PreCheckCreateOrderForDegradeResponse, err error) {
	response = CreatePreCheckCreateOrderForDegradeResponse()
	err = client.DoAction(request, response)
	return
}

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

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

// PreCheckCreateOrderForDegradeRequest is the request struct for api PreCheckCreateOrderForDegrade
type PreCheckCreateOrderForDegradeRequest struct {
	*requests.RpcRequest
	ResourceOwnerId      requests.Integer `position:"Query" name:"ResourceOwnerId"`
	DBInstanceStorage    requests.Integer `position:"Query" name:"DBInstanceStorage"`
	ClientToken          string           `position:"Query" name:"ClientToken"`
	EffectiveTime        string           `position:"Query" name:"EffectiveTime"`
	DBInstanceId         string           `position:"Query" name:"DBInstanceId"`
	BusinessInfo         string           `position:"Query" name:"BusinessInfo"`
	AutoPay              requests.Boolean `position:"Query" name:"AutoPay"`
	ResourceOwnerAccount string           `position:"Query" name:"ResourceOwnerAccount"`
	Resource             string           `position:"Query" name:"Resource"`
	CommodityCode        string           `position:"Query" name:"CommodityCode"`
	OwnerId              requests.Integer `position:"Query" name:"OwnerId"`
	UsedTime             string           `position:"Query" name:"UsedTime"`
	DBInstanceClass      string           `position:"Query" name:"DBInstanceClass"`
	PromotionCode        string           `position:"Query" name:"PromotionCode"`
	ZoneId               string           `position:"Query" name:"ZoneId"`
	TimeType             string           `position:"Query" name:"TimeType"`
	PayType              string           `position:"Query" name:"PayType"`
}

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

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

// CreatePreCheckCreateOrderForDegradeResponse creates a response to parse from PreCheckCreateOrderForDegrade response
func CreatePreCheckCreateOrderForDegradeResponse() (response *PreCheckCreateOrderForDegradeResponse) {
	response = &PreCheckCreateOrderForDegradeResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
