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 <set>
19  #include <sstream>
20  #include <alibabacloud/oss/model/ListPartsRequest.h>
21  #include <alibabacloud/oss/http/HttpType.h>
22  #include "utils/Utils.h"
23  #include "ModelError.h"
24  #include <alibabacloud/oss/Const.h>
25  
26  
27  using namespace AlibabaCloud::OSS;
28  using std::stringstream;
29  
ListPartsRequest(const std::string & bucket,const std::string & key)30  ListPartsRequest::ListPartsRequest(const std::string &bucket,
31       const std::string &key) :
32      ListPartsRequest(bucket, key, std::string())
33  {
34  }
35  
ListPartsRequest(const std::string & bucket,const std::string & key,const std::string & uploadId)36  ListPartsRequest::ListPartsRequest(const std::string &bucket,
37      const std::string &key, const std::string &uploadId) :
38      OssObjectRequest(bucket, key),
39      uploadId_(uploadId),
40      maxPartsIsSet_(false),
41      partNumberMarkerIsSet_(false),
42      encodingTypeIsSet_(false)
43  {
44  }
45  
setUploadId(const std::string & uploadId)46  void ListPartsRequest::setUploadId(const std::string &uploadId)
47  {
48      uploadId_ = uploadId;
49  }
50  
setEncodingType(const std::string & str)51  void ListPartsRequest::setEncodingType(const std::string &str)
52  {
53      encodingType_ = str;
54      encodingTypeIsSet_ = true;
55  }
56  
setMaxParts(uint32_t maxParts)57  void ListPartsRequest::setMaxParts(uint32_t maxParts)
58  {
59      maxParts_ = maxParts > MaxReturnedKeys ? MaxReturnedKeys: maxParts;
60      maxPartsIsSet_ = true;
61  }
62  
setPartNumberMarker(uint32_t partNumberMarker)63  void ListPartsRequest::setPartNumberMarker(uint32_t partNumberMarker)
64  {
65      partNumberMarker_ = partNumberMarker;
66      partNumberMarkerIsSet_ = true;
67  }
68  
specialParameters() const69  ParameterCollection ListPartsRequest::specialParameters() const
70  {
71      ParameterCollection parameters;
72      parameters["uploadId"] = uploadId_;
73  
74      if (maxPartsIsSet_) {
75          parameters["max-parts"] = std::to_string(maxParts_);
76      }
77  
78      if (partNumberMarkerIsSet_) {
79          parameters["part-number-marker"] = std::to_string(partNumberMarker_);
80      }
81  
82      if (encodingTypeIsSet_) {
83          parameters["encoding-type"] = encodingType_;
84      }
85  
86      return parameters;
87  }
88