package wss

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

// DescribePackageDeductions invokes the wss.DescribePackageDeductions API synchronously
func (client *Client) DescribePackageDeductions(request *DescribePackageDeductionsRequest) (response *DescribePackageDeductionsResponse, err error) {
	response = CreateDescribePackageDeductionsResponse()
	err = client.DoAction(request, response)
	return
}

// DescribePackageDeductionsWithChan invokes the wss.DescribePackageDeductions API asynchronously
func (client *Client) DescribePackageDeductionsWithChan(request *DescribePackageDeductionsRequest) (<-chan *DescribePackageDeductionsResponse, <-chan error) {
	responseChan := make(chan *DescribePackageDeductionsResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.DescribePackageDeductions(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// DescribePackageDeductionsWithCallback invokes the wss.DescribePackageDeductions API asynchronously
func (client *Client) DescribePackageDeductionsWithCallback(request *DescribePackageDeductionsRequest, callback func(response *DescribePackageDeductionsResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *DescribePackageDeductionsResponse
		var err error
		defer close(result)
		response, err = client.DescribePackageDeductions(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// DescribePackageDeductionsRequest is the request struct for api DescribePackageDeductions
type DescribePackageDeductionsRequest struct {
	*requests.RpcRequest
	EndTime      requests.Integer `position:"Query" name:"EndTime"`
	StartTime    requests.Integer `position:"Query" name:"StartTime"`
	PageNum      requests.Integer `position:"Query" name:"PageNum"`
	ResourceType string           `position:"Query" name:"ResourceType"`
	PackageIds   *[]string        `position:"Query" name:"PackageIds"  type:"Repeated"`
	InstanceIds  *[]string        `position:"Query" name:"InstanceIds"  type:"Repeated"`
	PageSize     requests.Integer `position:"Query" name:"PageSize"`
}

// DescribePackageDeductionsResponse is the response struct for api DescribePackageDeductions
type DescribePackageDeductionsResponse struct {
	*responses.BaseResponse
	PageNum           int         `json:"PageNum" xml:"PageNum"`
	RequestId         string      `json:"RequestId" xml:"RequestId"`
	PageSize          int         `json:"PageSize" xml:"PageSize"`
	TotalCount        int64       `json:"TotalCount" xml:"TotalCount"`
	TotalUsedTime     int64       `json:"TotalUsedTime" xml:"TotalUsedTime"`
	TotalUsedCoreTime float64     `json:"TotalUsedCoreTime" xml:"TotalUsedCoreTime"`
	Deductions        []Deduction `json:"Deductions" xml:"Deductions"`
}

// CreateDescribePackageDeductionsRequest creates a request to invoke DescribePackageDeductions API
func CreateDescribePackageDeductionsRequest() (request *DescribePackageDeductionsRequest) {
	request = &DescribePackageDeductionsRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("wss", "2021-12-21", "DescribePackageDeductions", "", "")
	request.Method = requests.POST
	return
}

// CreateDescribePackageDeductionsResponse creates a response to parse from DescribePackageDeductions response
func CreateDescribePackageDeductionsResponse() (response *DescribePackageDeductionsResponse) {
	response = &DescribePackageDeductionsResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
