package amqp_open

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

// DeleteExchange invokes the amqp_open.DeleteExchange API synchronously
// api document: https://help.aliyun.com/api/amqp-open/deleteexchange.html
func (client *Client) DeleteExchange(request *DeleteExchangeRequest) (response *DeleteExchangeResponse, err error) {
	response = CreateDeleteExchangeResponse()
	err = client.DoAction(request, response)
	return
}

// DeleteExchangeWithChan invokes the amqp_open.DeleteExchange API asynchronously
// api document: https://help.aliyun.com/api/amqp-open/deleteexchange.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) DeleteExchangeWithChan(request *DeleteExchangeRequest) (<-chan *DeleteExchangeResponse, <-chan error) {
	responseChan := make(chan *DeleteExchangeResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.DeleteExchange(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// DeleteExchangeWithCallback invokes the amqp_open.DeleteExchange API asynchronously
// api document: https://help.aliyun.com/api/amqp-open/deleteexchange.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) DeleteExchangeWithCallback(request *DeleteExchangeRequest, callback func(response *DeleteExchangeResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *DeleteExchangeResponse
		var err error
		defer close(result)
		response, err = client.DeleteExchange(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// DeleteExchangeRequest is the request struct for api DeleteExchange
type DeleteExchangeRequest struct {
	*requests.RpcRequest
	ExchangeName string `position:"Body" name:"ExchangeName"`
	InstanceId   string `position:"Body" name:"InstanceId"`
	VirtualHost  string `position:"Body" name:"VirtualHost"`
}

// DeleteExchangeResponse is the response struct for api DeleteExchange
type DeleteExchangeResponse struct {
	*responses.BaseResponse
	RequestId string `json:"RequestId" xml:"RequestId"`
}

// CreateDeleteExchangeRequest creates a request to invoke DeleteExchange API
func CreateDeleteExchangeRequest() (request *DeleteExchangeRequest) {
	request = &DeleteExchangeRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("amqp-open", "2019-12-12", "DeleteExchange", "onsproxy", "openAPI")
	request.Method = requests.POST
	return
}

// CreateDeleteExchangeResponse creates a response to parse from DeleteExchange response
func CreateDeleteExchangeResponse() (response *DeleteExchangeResponse) {
	response = &DeleteExchangeResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
