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

// RefreshMediaPlayUrls invokes the vod.RefreshMediaPlayUrls API synchronously
func (client *Client) RefreshMediaPlayUrls(request *RefreshMediaPlayUrlsRequest) (response *RefreshMediaPlayUrlsResponse, err error) {
	response = CreateRefreshMediaPlayUrlsResponse()
	err = client.DoAction(request, response)
	return
}

// RefreshMediaPlayUrlsWithChan invokes the vod.RefreshMediaPlayUrls API asynchronously
func (client *Client) RefreshMediaPlayUrlsWithChan(request *RefreshMediaPlayUrlsRequest) (<-chan *RefreshMediaPlayUrlsResponse, <-chan error) {
	responseChan := make(chan *RefreshMediaPlayUrlsResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.RefreshMediaPlayUrls(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// RefreshMediaPlayUrlsWithCallback invokes the vod.RefreshMediaPlayUrls API asynchronously
func (client *Client) RefreshMediaPlayUrlsWithCallback(request *RefreshMediaPlayUrlsRequest, callback func(response *RefreshMediaPlayUrlsResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *RefreshMediaPlayUrlsResponse
		var err error
		defer close(result)
		response, err = client.RefreshMediaPlayUrls(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// RefreshMediaPlayUrlsRequest is the request struct for api RefreshMediaPlayUrls
type RefreshMediaPlayUrlsRequest struct {
	*requests.RpcRequest
	Formats     string           `position:"Query" name:"Formats"`
	UserData    string           `position:"Query" name:"UserData"`
	MediaIds    string           `position:"Query" name:"MediaIds"`
	Definitions string           `position:"Query" name:"Definitions"`
	StreamType  string           `position:"Query" name:"StreamType"`
	TaskType    string           `position:"Query" name:"TaskType"`
	SliceFlag   requests.Boolean `position:"Query" name:"SliceFlag"`
	ResultType  string           `position:"Query" name:"ResultType"`
	SliceCount  requests.Integer `position:"Query" name:"SliceCount"`
}

// RefreshMediaPlayUrlsResponse is the response struct for api RefreshMediaPlayUrls
type RefreshMediaPlayUrlsResponse struct {
	*responses.BaseResponse
	MediaRefreshJobId string `json:"MediaRefreshJobId" xml:"MediaRefreshJobId"`
	NonExistMediaIds  string `json:"NonExistMediaIds" xml:"NonExistMediaIds"`
	ForbiddenMediaIds string `json:"ForbiddenMediaIds" xml:"ForbiddenMediaIds"`
	RequestId         string `json:"RequestId" xml:"RequestId"`
}

// CreateRefreshMediaPlayUrlsRequest creates a request to invoke RefreshMediaPlayUrls API
func CreateRefreshMediaPlayUrlsRequest() (request *RefreshMediaPlayUrlsRequest) {
	request = &RefreshMediaPlayUrlsRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("vod", "2017-03-21", "RefreshMediaPlayUrls", "vod", "openAPI")
	request.Method = requests.POST
	return
}

// CreateRefreshMediaPlayUrlsResponse creates a response to parse from RefreshMediaPlayUrls response
func CreateRefreshMediaPlayUrlsResponse() (response *RefreshMediaPlayUrlsResponse) {
	response = &RefreshMediaPlayUrlsResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}
