package cms

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

// DescribeMetricRuleList invokes the cms.DescribeMetricRuleList API synchronously
func (client *Client) DescribeMetricRuleList(request *DescribeMetricRuleListRequest) (response *DescribeMetricRuleListResponse, err error) {
	response = CreateDescribeMetricRuleListResponse()
	err = client.DoAction(request, response)
	return
}

// DescribeMetricRuleListWithChan invokes the cms.DescribeMetricRuleList API asynchronously
func (client *Client) DescribeMetricRuleListWithChan(request *DescribeMetricRuleListRequest) (<-chan *DescribeMetricRuleListResponse, <-chan error) {
	responseChan := make(chan *DescribeMetricRuleListResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.DescribeMetricRuleList(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// DescribeMetricRuleListWithCallback invokes the cms.DescribeMetricRuleList API asynchronously
func (client *Client) DescribeMetricRuleListWithCallback(request *DescribeMetricRuleListRequest, callback func(response *DescribeMetricRuleListResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *DescribeMetricRuleListResponse
		var err error
		defer close(result)
		response, err = client.DescribeMetricRuleList(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// DescribeMetricRuleListRequest is the request struct for api DescribeMetricRuleList
type DescribeMetricRuleListRequest struct {
	*requests.RpcRequest
	EnableState requests.Boolean `position:"Query" name:"EnableState"`
	RuleName    string           `position:"Query" name:"RuleName"`
	PageSize    requests.Integer `position:"Query" name:"PageSize"`
	MetricName  string           `position:"Query" name:"MetricName"`
	GroupId     string           `position:"Query" name:"GroupId"`
	GroupBy     string           `position:"Query" name:"GroupBy"`
	RuleIds     string           `position:"Query" name:"RuleIds"`
	Namespace   string           `position:"Query" name:"Namespace"`
	AlertState  string           `position:"Query" name:"AlertState"`
	Page        requests.Integer `position:"Query" name:"Page"`
	Dimensions  string           `position:"Query" name:"Dimensions"`
}

// DescribeMetricRuleListResponse is the response struct for api DescribeMetricRuleList
type DescribeMetricRuleListResponse struct {
	*responses.BaseResponse
	Code      int    `json:"Code" xml:"Code"`
	Message   string `json:"Message" xml:"Message"`
	RequestId string `json:"RequestId" xml:"RequestId"`
	Total     string `json:"Total" xml:"Total"`
	Success   bool   `json:"Success" xml:"Success"`
	Alarms    Alarms `json:"Alarms" xml:"Alarms"`
}

// CreateDescribeMetricRuleListRequest creates a request to invoke DescribeMetricRuleList API
func CreateDescribeMetricRuleListRequest() (request *DescribeMetricRuleListRequest) {
	request = &DescribeMetricRuleListRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("Cms", "2019-01-01", "DescribeMetricRuleList", "Cms", "openAPI")
	request.Method = requests.POST
	return
}

// CreateDescribeMetricRuleListResponse creates a response to parse from DescribeMetricRuleList response
func CreateDescribeMetricRuleListResponse() (response *DescribeMetricRuleListResponse) {
	response = &DescribeMetricRuleListResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
