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

// GetCandidateInstanceList invokes the drds.GetCandidateInstanceList API synchronously
// api document: https://help.aliyun.com/api/drds/getcandidateinstancelist.html
func (client *Client) GetCandidateInstanceList(request *GetCandidateInstanceListRequest) (response *GetCandidateInstanceListResponse, err error) {
	response = CreateGetCandidateInstanceListResponse()
	err = client.DoAction(request, response)
	return
}

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

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

// GetCandidateInstanceListRequest is the request struct for api GetCandidateInstanceList
type GetCandidateInstanceListRequest struct {
	*requests.RpcRequest
	Search         string           `position:"Query" name:"Search"`
	DbName         string           `position:"Query" name:"DbName"`
	AcrossZone     requests.Boolean `position:"Query" name:"AcrossZone"`
	PageSize       requests.Integer `position:"Query" name:"PageSize"`
	DrdsInstanceId string           `position:"Query" name:"DrdsInstanceId"`
	PageNumber     requests.Integer `position:"Query" name:"PageNumber"`
}

// GetCandidateInstanceListResponse is the response struct for api GetCandidateInstanceList
type GetCandidateInstanceListResponse struct {
	*responses.BaseResponse
	RequestId string `json:"RequestId" xml:"RequestId"`
	Success   bool   `json:"Success" xml:"Success"`
}

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

// CreateGetCandidateInstanceListResponse creates a response to parse from GetCandidateInstanceList response
func CreateGetCandidateInstanceListResponse() (response *GetCandidateInstanceListResponse) {
	response = &GetCandidateInstanceListResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
