package cloudapi

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

// ModifyCatalog invokes the cloudapi.ModifyCatalog API synchronously
// api document: https://help.aliyun.com/api/cloudapi/modifycatalog.html
func (client *Client) ModifyCatalog(request *ModifyCatalogRequest) (response *ModifyCatalogResponse, err error) {
	response = CreateModifyCatalogResponse()
	err = client.DoAction(request, response)
	return
}

// ModifyCatalogWithChan invokes the cloudapi.ModifyCatalog API asynchronously
// api document: https://help.aliyun.com/api/cloudapi/modifycatalog.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) ModifyCatalogWithChan(request *ModifyCatalogRequest) (<-chan *ModifyCatalogResponse, <-chan error) {
	responseChan := make(chan *ModifyCatalogResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.ModifyCatalog(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

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

// ModifyCatalogRequest is the request struct for api ModifyCatalog
type ModifyCatalogRequest struct {
	*requests.RpcRequest
	CatalogId     string `position:"Query" name:"CatalogId"`
	SecurityToken string `position:"Query" name:"SecurityToken"`
	CatalogName   string `position:"Query" name:"CatalogName"`
	Description   string `position:"Query" name:"Description"`
}

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

// CreateModifyCatalogRequest creates a request to invoke ModifyCatalog API
func CreateModifyCatalogRequest() (request *ModifyCatalogRequest) {
	request = &ModifyCatalogRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("CloudAPI", "2016-07-14", "ModifyCatalog", "apigateway", "openAPI")
	return
}

// CreateModifyCatalogResponse creates a response to parse from ModifyCatalog response
func CreateModifyCatalogResponse() (response *ModifyCatalogResponse) {
	response = &ModifyCatalogResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
