1 /*
2 * Copyright 2009-2017 Alibaba Cloud All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 #include <alibabacloud/oss/model/PostVodPlaylistRequest.h>
19 #include <sstream>
20 #include "utils/Utils.h"
21 #include "ModelError.h"
22 #include "Const.h"
23
24
25 using namespace AlibabaCloud::OSS;
26
PostVodPlaylistRequest(const std::string & bucket,const std::string & channelName,const std::string & playlist,uint64_t startTime,uint64_t endTime)27 PostVodPlaylistRequest::PostVodPlaylistRequest(const std::string& bucket,
28 const std::string& channelName, const std::string& playlist,
29 uint64_t startTime, uint64_t endTime)
30 :LiveChannelRequest(bucket, channelName),
31 playList_(playlist),
32 startTime_(startTime),
33 endTime_(endTime)
34 {
35 key_.append("/").append(playList_);
36 }
37
validate() const38 int PostVodPlaylistRequest::validate() const
39 {
40 int ret = LiveChannelRequest::validate();
41
42 if(ret)
43 {
44 return ret;
45 }
46
47 if(!IsValidPlayListName(playList_))
48 {
49 return ARG_ERROR_LIVECHANNEL_BAD_PALYLIST_PARAM;
50 }
51 if(endTime_ <= startTime_ || endTime_ > (startTime_ + SecondsOfDay))
52 {
53 return ARG_ERROR_LIVECHANNEL_BAD_TIME_PARAM;
54 }
55 return 0;
56 }
57
specialParameters() const58 ParameterCollection PostVodPlaylistRequest::specialParameters() const
59 {
60 ParameterCollection collection;
61 collection["vod"] = "";
62 collection["endTime"] = std::to_string(endTime_);
63 collection["startTime"] = std::to_string(startTime_);
64 return collection;
65 }
66
setPlayList(const std::string & playList)67 void PostVodPlaylistRequest::setPlayList(const std::string &playList)
68 {
69 playList_ = playList;
70 }
71
setStartTime(uint64_t startTime)72 void PostVodPlaylistRequest::setStartTime(uint64_t startTime)
73 {
74 startTime_ = startTime;
75 }
76
setEndTime(uint64_t endTime)77 void PostVodPlaylistRequest::setEndTime(uint64_t endTime)
78 {
79 endTime_ = endTime;
80 }
81
82