package retailcloud

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

// ListDeployConfig invokes the retailcloud.ListDeployConfig API synchronously
func (client *Client) ListDeployConfig(request *ListDeployConfigRequest) (response *ListDeployConfigResponse, err error) {
	response = CreateListDeployConfigResponse()
	err = client.DoAction(request, response)
	return
}

// ListDeployConfigWithChan invokes the retailcloud.ListDeployConfig API asynchronously
func (client *Client) ListDeployConfigWithChan(request *ListDeployConfigRequest) (<-chan *ListDeployConfigResponse, <-chan error) {
	responseChan := make(chan *ListDeployConfigResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.ListDeployConfig(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// ListDeployConfigWithCallback invokes the retailcloud.ListDeployConfig API asynchronously
func (client *Client) ListDeployConfigWithCallback(request *ListDeployConfigRequest, callback func(response *ListDeployConfigResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *ListDeployConfigResponse
		var err error
		defer close(result)
		response, err = client.ListDeployConfig(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// ListDeployConfigRequest is the request struct for api ListDeployConfig
type ListDeployConfigRequest struct {
	*requests.RpcRequest
	AppId   requests.Integer `position:"Query" name:"AppId"`
	EnvType string           `position:"Query" name:"EnvType"`
	Name    string           `position:"Query" name:"Name"`
	Id      requests.Integer `position:"Query" name:"Id"`
}

// ListDeployConfigResponse is the response struct for api ListDeployConfig
type ListDeployConfigResponse struct {
	*responses.BaseResponse
	Code       int                    `json:"Code" xml:"Code"`
	ErrorMsg   string                 `json:"ErrorMsg" xml:"ErrorMsg"`
	PageNumber int                    `json:"PageNumber" xml:"PageNumber"`
	PageSize   int                    `json:"PageSize" xml:"PageSize"`
	RequestId  string                 `json:"RequestId" xml:"RequestId"`
	TotalCount int64                  `json:"TotalCount" xml:"TotalCount"`
	Data       []DeployConfigInstance `json:"Data" xml:"Data"`
}

// CreateListDeployConfigRequest creates a request to invoke ListDeployConfig API
func CreateListDeployConfigRequest() (request *ListDeployConfigRequest) {
	request = &ListDeployConfigRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("retailcloud", "2018-03-13", "ListDeployConfig", "", "")
	request.Method = requests.POST
	return
}

// CreateListDeployConfigResponse creates a response to parse from ListDeployConfig response
func CreateListDeployConfigResponse() (response *ListDeployConfigResponse) {
	response = &ListDeployConfigResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
