package drds

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

// CreateDrdsDBPreCheck invokes the drds.CreateDrdsDBPreCheck API synchronously
// api document: https://help.aliyun.com/api/drds/createdrdsdbprecheck.html
func (client *Client) CreateDrdsDBPreCheck(request *CreateDrdsDBPreCheckRequest) (response *CreateDrdsDBPreCheckResponse, err error) {
	response = CreateCreateDrdsDBPreCheckResponse()
	err = client.DoAction(request, response)
	return
}

// CreateDrdsDBPreCheckWithChan invokes the drds.CreateDrdsDBPreCheck API asynchronously
// api document: https://help.aliyun.com/api/drds/createdrdsdbprecheck.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateDrdsDBPreCheckWithChan(request *CreateDrdsDBPreCheckRequest) (<-chan *CreateDrdsDBPreCheckResponse, <-chan error) {
	responseChan := make(chan *CreateDrdsDBPreCheckResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.CreateDrdsDBPreCheck(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

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

// CreateDrdsDBPreCheckRequest is the request struct for api CreateDrdsDBPreCheck
type CreateDrdsDBPreCheckRequest struct {
	*requests.RpcRequest
	Encode               string                                 `position:"Query" name:"Encode"`
	InstDbName           *[]CreateDrdsDBPreCheckInstDbName      `position:"Query" name:"InstDbName"  type:"Repeated"`
	Password             string                                 `position:"Query" name:"Password"`
	RdsSuperAccount      *[]CreateDrdsDBPreCheckRdsSuperAccount `position:"Query" name:"RdsSuperAccount"  type:"Repeated"`
	DbName               string                                 `position:"Query" name:"DbName"`
	AccountName          string                                 `position:"Query" name:"AccountName"`
	RdsInstance          *[]string                              `position:"Query" name:"RdsInstance"  type:"Repeated"`
	Type                 string                                 `position:"Query" name:"Type"`
	DbInstType           string                                 `position:"Query" name:"DbInstType"`
	DrdsInstanceId       string                                 `position:"Query" name:"DrdsInstanceId"`
	DbInstanceIsCreating requests.Boolean                       `position:"Query" name:"DbInstanceIsCreating"`
}

// CreateDrdsDBPreCheckInstDbName is a repeated param struct in CreateDrdsDBPreCheckRequest
type CreateDrdsDBPreCheckInstDbName struct {
	ShardDbName  *[]string `name:"ShardDbName" type:"Repeated"`
	DbInstanceId string    `name:"DbInstanceId"`
}

// CreateDrdsDBPreCheckRdsSuperAccount is a repeated param struct in CreateDrdsDBPreCheckRequest
type CreateDrdsDBPreCheckRdsSuperAccount struct {
	Password     string `name:"Password"`
	AccountName  string `name:"AccountName"`
	DbInstanceId string `name:"DbInstanceId"`
}

// CreateDrdsDBPreCheckResponse is the response struct for api CreateDrdsDBPreCheck
type CreateDrdsDBPreCheckResponse struct {
	*responses.BaseResponse
	RequestId string `json:"RequestId" xml:"RequestId"`
	Success   bool   `json:"Success" xml:"Success"`
	TaskId    int64  `json:"TaskId" xml:"TaskId"`
}

// CreateCreateDrdsDBPreCheckRequest creates a request to invoke CreateDrdsDBPreCheck API
func CreateCreateDrdsDBPreCheckRequest() (request *CreateDrdsDBPreCheckRequest) {
	request = &CreateDrdsDBPreCheckRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("Drds", "2019-01-23", "CreateDrdsDBPreCheck", "drds", "openAPI")
	return
}

// CreateCreateDrdsDBPreCheckResponse creates a response to parse from CreateDrdsDBPreCheck response
func CreateCreateDrdsDBPreCheckResponse() (response *CreateDrdsDBPreCheckResponse) {
	response = &CreateDrdsDBPreCheckResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
