package ess

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

// DescribeLifecycleActions invokes the ess.DescribeLifecycleActions API synchronously
func (client *Client) DescribeLifecycleActions(request *DescribeLifecycleActionsRequest) (response *DescribeLifecycleActionsResponse, err error) {
	response = CreateDescribeLifecycleActionsResponse()
	err = client.DoAction(request, response)
	return
}

// DescribeLifecycleActionsWithChan invokes the ess.DescribeLifecycleActions API asynchronously
func (client *Client) DescribeLifecycleActionsWithChan(request *DescribeLifecycleActionsRequest) (<-chan *DescribeLifecycleActionsResponse, <-chan error) {
	responseChan := make(chan *DescribeLifecycleActionsResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.DescribeLifecycleActions(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// DescribeLifecycleActionsWithCallback invokes the ess.DescribeLifecycleActions API asynchronously
func (client *Client) DescribeLifecycleActionsWithCallback(request *DescribeLifecycleActionsRequest, callback func(response *DescribeLifecycleActionsResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *DescribeLifecycleActionsResponse
		var err error
		defer close(result)
		response, err = client.DescribeLifecycleActions(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// DescribeLifecycleActionsRequest is the request struct for api DescribeLifecycleActions
type DescribeLifecycleActionsRequest struct {
	*requests.RpcRequest
	LifecycleActionStatus string           `position:"Query" name:"LifecycleActionStatus"`
	NextToken             string           `position:"Query" name:"NextToken"`
	ResourceOwnerAccount  string           `position:"Query" name:"ResourceOwnerAccount"`
	OwnerId               requests.Integer `position:"Query" name:"OwnerId"`
	ScalingActivityId     string           `position:"Query" name:"ScalingActivityId"`
	MaxResults            requests.Integer `position:"Query" name:"MaxResults"`
}

// DescribeLifecycleActionsResponse is the response struct for api DescribeLifecycleActions
type DescribeLifecycleActionsResponse struct {
	*responses.BaseResponse
	NextToken        string           `json:"NextToken" xml:"NextToken"`
	RequestId        string           `json:"RequestId" xml:"RequestId"`
	TotalCount       int              `json:"TotalCount" xml:"TotalCount"`
	MaxResults       int              `json:"MaxResults" xml:"MaxResults"`
	LifecycleActions LifecycleActions `json:"LifecycleActions" xml:"LifecycleActions"`
}

// CreateDescribeLifecycleActionsRequest creates a request to invoke DescribeLifecycleActions API
func CreateDescribeLifecycleActionsRequest() (request *DescribeLifecycleActionsRequest) {
	request = &DescribeLifecycleActionsRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("Ess", "2014-08-28", "DescribeLifecycleActions", "ess", "openAPI")
	request.Method = requests.POST
	return
}

// CreateDescribeLifecycleActionsResponse creates a response to parse from DescribeLifecycleActions response
func CreateDescribeLifecycleActionsResponse() (response *DescribeLifecycleActionsResponse) {
	response = &DescribeLifecycleActionsResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
