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/RestoreObjectRequest.h>
19 #include <utils/Utils.h>
20 #include <sstream>
21 
22 using namespace AlibabaCloud::OSS;
23 
RestoreObjectRequest(const std::string & bucket,const std::string & key)24 RestoreObjectRequest::RestoreObjectRequest(const std::string &bucket, const std::string &key)
25     :OssObjectRequest(bucket,key),
26     days_(1U),
27     tierTypeIsSet_(false)
28 {
29 }
30 
setDays(uint32_t days)31 void RestoreObjectRequest::setDays(uint32_t days)
32 {
33     days_ = days;
34 }
35 
setTierType(TierType type)36 void RestoreObjectRequest::setTierType(TierType type)
37 {
38     tierType_ = type;
39     tierTypeIsSet_ = true;
40 }
41 
payload() const42 std::string RestoreObjectRequest::payload() const
43 {
44     std::stringstream ss;
45     if (tierTypeIsSet_) {
46         ss << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
47         ss << "<RestoreRequest>" << std::endl;
48         ss << "<Days>" << std::to_string(days_) << "</Days>" << std::endl;
49         ss << "<JobParameters><Tier>" << ToTierTypeName(tierType_) << "</Tier></JobParameters>" << std::endl;
50         ss << "</RestoreRequest>" << std::endl;
51     }
52     return ss.str();
53 }
54 
specialParameters() const55 ParameterCollection RestoreObjectRequest::specialParameters() const
56 {
57     auto parameters = OssObjectRequest::specialParameters();
58     parameters["restore"]="";
59     return parameters;
60 }
61 
62