1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/s3-crt/model/UploadPartCopyRequest.h>
7 #include <aws/core/utils/xml/XmlSerializer.h>
8 #include <aws/core/utils/memory/stl/AWSStringStream.h>
9 #include <aws/core/http/URI.h>
10 #include <aws/core/utils/memory/stl/AWSStringStream.h>
11
12 #include <utility>
13
14 using namespace Aws::S3Crt::Model;
15 using namespace Aws::Utils::Xml;
16 using namespace Aws::Utils;
17 using namespace Aws::Http;
18
UploadPartCopyRequest()19 UploadPartCopyRequest::UploadPartCopyRequest() :
20 m_bucketHasBeenSet(false),
21 m_copySourceHasBeenSet(false),
22 m_copySourceIfMatchHasBeenSet(false),
23 m_copySourceIfModifiedSinceHasBeenSet(false),
24 m_copySourceIfNoneMatchHasBeenSet(false),
25 m_copySourceIfUnmodifiedSinceHasBeenSet(false),
26 m_copySourceRangeHasBeenSet(false),
27 m_keyHasBeenSet(false),
28 m_partNumber(0),
29 m_partNumberHasBeenSet(false),
30 m_uploadIdHasBeenSet(false),
31 m_sSECustomerAlgorithmHasBeenSet(false),
32 m_sSECustomerKeyHasBeenSet(false),
33 m_sSECustomerKeyMD5HasBeenSet(false),
34 m_copySourceSSECustomerAlgorithmHasBeenSet(false),
35 m_copySourceSSECustomerKeyHasBeenSet(false),
36 m_copySourceSSECustomerKeyMD5HasBeenSet(false),
37 m_requestPayer(RequestPayer::NOT_SET),
38 m_requestPayerHasBeenSet(false),
39 m_expectedBucketOwnerHasBeenSet(false),
40 m_expectedSourceBucketOwnerHasBeenSet(false),
41 m_customizedAccessLogTagHasBeenSet(false)
42 {
43 }
44
SerializePayload() const45 Aws::String UploadPartCopyRequest::SerializePayload() const
46 {
47 return {};
48 }
49
AddQueryStringParameters(URI & uri) const50 void UploadPartCopyRequest::AddQueryStringParameters(URI& uri) const
51 {
52 Aws::StringStream ss;
53 if(m_partNumberHasBeenSet)
54 {
55 ss << m_partNumber;
56 uri.AddQueryStringParameter("partNumber", ss.str());
57 ss.str("");
58 }
59
60 if(m_uploadIdHasBeenSet)
61 {
62 ss << m_uploadId;
63 uri.AddQueryStringParameter("uploadId", ss.str());
64 ss.str("");
65 }
66
67 if(!m_customizedAccessLogTag.empty())
68 {
69 // only accept customized LogTag which starts with "x-"
70 Aws::Map<Aws::String, Aws::String> collectedLogTags;
71 for(const auto& entry: m_customizedAccessLogTag)
72 {
73 if (!entry.first.empty() && !entry.second.empty() && entry.first.substr(0, 2) == "x-")
74 {
75 collectedLogTags.emplace(entry.first, entry.second);
76 }
77 }
78
79 if (!collectedLogTags.empty())
80 {
81 uri.AddQueryStringParameter(collectedLogTags);
82 }
83 }
84 }
85
GetRequestSpecificHeaders() const86 Aws::Http::HeaderValueCollection UploadPartCopyRequest::GetRequestSpecificHeaders() const
87 {
88 Aws::Http::HeaderValueCollection headers;
89 Aws::StringStream ss;
90 if(m_copySourceHasBeenSet)
91 {
92 ss << m_copySource;
93 headers.emplace("x-amz-copy-source", URI::URLEncodePath(ss.str()));
94 ss.str("");
95 }
96
97 if(m_copySourceIfMatchHasBeenSet)
98 {
99 ss << m_copySourceIfMatch;
100 headers.emplace("x-amz-copy-source-if-match", ss.str());
101 ss.str("");
102 }
103
104 if(m_copySourceIfModifiedSinceHasBeenSet)
105 {
106 headers.emplace("x-amz-copy-source-if-modified-since", m_copySourceIfModifiedSince.ToGmtString(DateFormat::RFC822));
107 }
108
109 if(m_copySourceIfNoneMatchHasBeenSet)
110 {
111 ss << m_copySourceIfNoneMatch;
112 headers.emplace("x-amz-copy-source-if-none-match", ss.str());
113 ss.str("");
114 }
115
116 if(m_copySourceIfUnmodifiedSinceHasBeenSet)
117 {
118 headers.emplace("x-amz-copy-source-if-unmodified-since", m_copySourceIfUnmodifiedSince.ToGmtString(DateFormat::RFC822));
119 }
120
121 if(m_copySourceRangeHasBeenSet)
122 {
123 ss << m_copySourceRange;
124 headers.emplace("x-amz-copy-source-range", ss.str());
125 ss.str("");
126 }
127
128 if(m_sSECustomerAlgorithmHasBeenSet)
129 {
130 ss << m_sSECustomerAlgorithm;
131 headers.emplace("x-amz-server-side-encryption-customer-algorithm", ss.str());
132 ss.str("");
133 }
134
135 if(m_sSECustomerKeyHasBeenSet)
136 {
137 ss << m_sSECustomerKey;
138 headers.emplace("x-amz-server-side-encryption-customer-key", ss.str());
139 ss.str("");
140 }
141
142 if(m_sSECustomerKeyMD5HasBeenSet)
143 {
144 ss << m_sSECustomerKeyMD5;
145 headers.emplace("x-amz-server-side-encryption-customer-key-md5", ss.str());
146 ss.str("");
147 }
148
149 if(m_copySourceSSECustomerAlgorithmHasBeenSet)
150 {
151 ss << m_copySourceSSECustomerAlgorithm;
152 headers.emplace("x-amz-copy-source-server-side-encryption-customer-algorithm", ss.str());
153 ss.str("");
154 }
155
156 if(m_copySourceSSECustomerKeyHasBeenSet)
157 {
158 ss << m_copySourceSSECustomerKey;
159 headers.emplace("x-amz-copy-source-server-side-encryption-customer-key", ss.str());
160 ss.str("");
161 }
162
163 if(m_copySourceSSECustomerKeyMD5HasBeenSet)
164 {
165 ss << m_copySourceSSECustomerKeyMD5;
166 headers.emplace("x-amz-copy-source-server-side-encryption-customer-key-md5", ss.str());
167 ss.str("");
168 }
169
170 if(m_requestPayerHasBeenSet)
171 {
172 headers.emplace("x-amz-request-payer", RequestPayerMapper::GetNameForRequestPayer(m_requestPayer));
173 }
174
175 if(m_expectedBucketOwnerHasBeenSet)
176 {
177 ss << m_expectedBucketOwner;
178 headers.emplace("x-amz-expected-bucket-owner", ss.str());
179 ss.str("");
180 }
181
182 if(m_expectedSourceBucketOwnerHasBeenSet)
183 {
184 ss << m_expectedSourceBucketOwner;
185 headers.emplace("x-amz-source-expected-bucket-owner", ss.str());
186 ss.str("");
187 }
188
189 return headers;
190 }
191