package sgw

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

// DescribeGatewayBucketCaches invokes the sgw.DescribeGatewayBucketCaches API synchronously
func (client *Client) DescribeGatewayBucketCaches(request *DescribeGatewayBucketCachesRequest) (response *DescribeGatewayBucketCachesResponse, err error) {
	response = CreateDescribeGatewayBucketCachesResponse()
	err = client.DoAction(request, response)
	return
}

// DescribeGatewayBucketCachesWithChan invokes the sgw.DescribeGatewayBucketCaches API asynchronously
func (client *Client) DescribeGatewayBucketCachesWithChan(request *DescribeGatewayBucketCachesRequest) (<-chan *DescribeGatewayBucketCachesResponse, <-chan error) {
	responseChan := make(chan *DescribeGatewayBucketCachesResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.DescribeGatewayBucketCaches(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// DescribeGatewayBucketCachesWithCallback invokes the sgw.DescribeGatewayBucketCaches API asynchronously
func (client *Client) DescribeGatewayBucketCachesWithCallback(request *DescribeGatewayBucketCachesRequest, callback func(response *DescribeGatewayBucketCachesResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *DescribeGatewayBucketCachesResponse
		var err error
		defer close(result)
		response, err = client.DescribeGatewayBucketCaches(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// DescribeGatewayBucketCachesRequest is the request struct for api DescribeGatewayBucketCaches
type DescribeGatewayBucketCachesRequest struct {
	*requests.RpcRequest
	PageNumber    requests.Integer `position:"Query" name:"PageNumber"`
	SecurityToken string           `position:"Query" name:"SecurityToken"`
	BucketName    string           `position:"Query" name:"BucketName"`
	PageSize      requests.Integer `position:"Query" name:"PageSize"`
}

// DescribeGatewayBucketCachesResponse is the response struct for api DescribeGatewayBucketCaches
type DescribeGatewayBucketCachesResponse struct {
	*responses.BaseResponse
	RequestId    string       `json:"RequestId" xml:"RequestId"`
	Success      bool         `json:"Success" xml:"Success"`
	Code         string       `json:"Code" xml:"Code"`
	Message      string       `json:"Message" xml:"Message"`
	TotalCount   int          `json:"TotalCount" xml:"TotalCount"`
	PageNumber   int          `json:"PageNumber" xml:"PageNumber"`
	PageSize     int          `json:"PageSize" xml:"PageSize"`
	BucketCaches BucketCaches `json:"BucketCaches" xml:"BucketCaches"`
}

// CreateDescribeGatewayBucketCachesRequest creates a request to invoke DescribeGatewayBucketCaches API
func CreateDescribeGatewayBucketCachesRequest() (request *DescribeGatewayBucketCachesRequest) {
	request = &DescribeGatewayBucketCachesRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("sgw", "2018-05-11", "DescribeGatewayBucketCaches", "hcs_sgw", "openAPI")
	request.Method = requests.POST
	return
}

// CreateDescribeGatewayBucketCachesResponse creates a response to parse from DescribeGatewayBucketCaches response
func CreateDescribeGatewayBucketCachesResponse() (response *DescribeGatewayBucketCachesResponse) {
	response = &DescribeGatewayBucketCachesResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
