package ddoscoo

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

// DescribeSlaEventList invokes the ddoscoo.DescribeSlaEventList API synchronously
func (client *Client) DescribeSlaEventList(request *DescribeSlaEventListRequest) (response *DescribeSlaEventListResponse, err error) {
	response = CreateDescribeSlaEventListResponse()
	err = client.DoAction(request, response)
	return
}

// DescribeSlaEventListWithChan invokes the ddoscoo.DescribeSlaEventList API asynchronously
func (client *Client) DescribeSlaEventListWithChan(request *DescribeSlaEventListRequest) (<-chan *DescribeSlaEventListResponse, <-chan error) {
	responseChan := make(chan *DescribeSlaEventListResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.DescribeSlaEventList(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// DescribeSlaEventListWithCallback invokes the ddoscoo.DescribeSlaEventList API asynchronously
func (client *Client) DescribeSlaEventListWithCallback(request *DescribeSlaEventListRequest, callback func(response *DescribeSlaEventListResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *DescribeSlaEventListResponse
		var err error
		defer close(result)
		response, err = client.DescribeSlaEventList(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// DescribeSlaEventListRequest is the request struct for api DescribeSlaEventList
type DescribeSlaEventListRequest struct {
	*requests.RpcRequest
	StartTime requests.Integer `position:"Query" name:"StartTime"`
	SourceIp  string           `position:"Query" name:"SourceIp"`
	PageSize  requests.Integer `position:"Query" name:"PageSize"`
	Ip        string           `position:"Query" name:"Ip"`
	EndTime   requests.Integer `position:"Query" name:"EndTime"`
	Page      requests.Integer `position:"Query" name:"Page"`
	Region    string           `position:"Query" name:"Region"`
}

// DescribeSlaEventListResponse is the response struct for api DescribeSlaEventList
type DescribeSlaEventListResponse struct {
	*responses.BaseResponse
	RequestId string         `json:"RequestId" xml:"RequestId"`
	Total     int64          `json:"Total" xml:"Total"`
	SlaEvent  []SlaEventItem `json:"SlaEvent" xml:"SlaEvent"`
}

// CreateDescribeSlaEventListRequest creates a request to invoke DescribeSlaEventList API
func CreateDescribeSlaEventListRequest() (request *DescribeSlaEventListRequest) {
	request = &DescribeSlaEventListRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("ddoscoo", "2020-01-01", "DescribeSlaEventList", "ddoscoo", "openAPI")
	request.Method = requests.POST
	return
}

// CreateDescribeSlaEventListResponse creates a response to parse from DescribeSlaEventList response
func CreateDescribeSlaEventListResponse() (response *DescribeSlaEventListResponse) {
	response = &DescribeSlaEventListResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
