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

// DescribeVodDomainCname invokes the vod.DescribeVodDomainCname API synchronously
// api document: https://help.aliyun.com/api/vod/describevoddomaincname.html
func (client *Client) DescribeVodDomainCname(request *DescribeVodDomainCnameRequest) (response *DescribeVodDomainCnameResponse, err error) {
	response = CreateDescribeVodDomainCnameResponse()
	err = client.DoAction(request, response)
	return
}

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

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

// DescribeVodDomainCnameRequest is the request struct for api DescribeVodDomainCname
type DescribeVodDomainCnameRequest struct {
	*requests.RpcRequest
	DomainName string           `position:"Query" name:"DomainName"`
	OwnerId    requests.Integer `position:"Query" name:"OwnerId"`
}

// DescribeVodDomainCnameResponse is the response struct for api DescribeVodDomainCname
type DescribeVodDomainCnameResponse struct {
	*responses.BaseResponse
	RequestId  string     `json:"RequestId" xml:"RequestId"`
	CnameDatas CnameDatas `json:"CnameDatas" xml:"CnameDatas"`
}

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

// CreateDescribeVodDomainCnameResponse creates a response to parse from DescribeVodDomainCname response
func CreateDescribeVodDomainCnameResponse() (response *DescribeVodDomainCnameResponse) {
	response = &DescribeVodDomainCnameResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
