package vod

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

// GetCDNStatisSum invokes the vod.GetCDNStatisSum API synchronously
// api document: https://help.aliyun.com/api/vod/getcdnstatissum.html
func (client *Client) GetCDNStatisSum(request *GetCDNStatisSumRequest) (response *GetCDNStatisSumResponse, err error) {
	response = CreateGetCDNStatisSumResponse()
	err = client.DoAction(request, response)
	return
}

// GetCDNStatisSumWithChan invokes the vod.GetCDNStatisSum API asynchronously
// api document: https://help.aliyun.com/api/vod/getcdnstatissum.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) GetCDNStatisSumWithChan(request *GetCDNStatisSumRequest) (<-chan *GetCDNStatisSumResponse, <-chan error) {
	responseChan := make(chan *GetCDNStatisSumResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.GetCDNStatisSum(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// GetCDNStatisSumWithCallback invokes the vod.GetCDNStatisSum API asynchronously
// api document: https://help.aliyun.com/api/vod/getcdnstatissum.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) GetCDNStatisSumWithCallback(request *GetCDNStatisSumRequest, callback func(response *GetCDNStatisSumResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *GetCDNStatisSumResponse
		var err error
		defer close(result)
		response, err = client.GetCDNStatisSum(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// GetCDNStatisSumRequest is the request struct for api GetCDNStatisSum
type GetCDNStatisSumRequest struct {
	*requests.RpcRequest
	ResourceOwnerId      string `position:"Query" name:"ResourceOwnerId"`
	StartStatisTime      string `position:"Query" name:"StartStatisTime"`
	ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
	Level                string `position:"Query" name:"Level"`
	OwnerAccount         string `position:"Query" name:"OwnerAccount"`
	OwnerId              string `position:"Query" name:"OwnerId"`
	EndStatisTime        string `position:"Query" name:"EndStatisTime"`
}

// GetCDNStatisSumResponse is the response struct for api GetCDNStatisSum
type GetCDNStatisSumResponse struct {
	*responses.BaseResponse
	RequestId        string        `json:"RequestId" xml:"RequestId"`
	SumFlowDataValue int           `json:"SumFlowDataValue" xml:"SumFlowDataValue"`
	MaxBpsDataValue  int           `json:"MaxBpsDataValue" xml:"MaxBpsDataValue"`
	CDNStatisList    CDNStatisList `json:"CDNStatisList" xml:"CDNStatisList"`
}

// CreateGetCDNStatisSumRequest creates a request to invoke GetCDNStatisSum API
func CreateGetCDNStatisSumRequest() (request *GetCDNStatisSumRequest) {
	request = &GetCDNStatisSumRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("vod", "2017-03-21", "GetCDNStatisSum", "vod", "openAPI")
	return
}

// CreateGetCDNStatisSumResponse creates a response to parse from GetCDNStatisSum response
func CreateGetCDNStatisSumResponse() (response *GetCDNStatisSumResponse) {
	response = &GetCDNStatisSumResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
