1/*
2* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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* A copy of the License is located at
7*
8* http://aws.amazon.com/apache2.0
9*
10* or in the "license" file accompanying this file. This file is distributed
11* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12* express or implied. See the License for the specific language governing
13* permissions and limitations under the License.
14*/
15
16#include <aws/s3/model/SelectObjectContentRequest.h>
17#include <aws/core/utils/xml/XmlSerializer.h>
18#include <aws/core/utils/memory/stl/AWSStringStream.h>
19#include <aws/core/http/URI.h>
20#include <aws/core/utils/memory/stl/AWSStringStream.h>
21
22#include <utility>
23
24using namespace Aws::S3::Model;
25using namespace Aws::Utils::Xml;
26using namespace Aws::Utils;
27using namespace Aws::Http;
28
29SelectObjectContentRequest::SelectObjectContentRequest() :
30 m_bucketHasBeenSet(false),
31 m_keyHasBeenSet(false),
32 m_sSECustomerAlgorithmHasBeenSet(false),
33 m_sSECustomerKeyHasBeenSet(false),
34 m_sSECustomerKeyMD5HasBeenSet(false),
35 m_expressionHasBeenSet(false),
36 m_expressionType(ExpressionType::NOT_SET),
37 m_expressionTypeHasBeenSet(false),
38 m_requestProgressHasBeenSet(false),
39 m_inputSerializationHasBeenSet(false),
40 m_outputSerializationHasBeenSet(false),
41 m_scanRangeHasBeenSet(false),
42 m_customizedAccessLogTagHasBeenSet(false),
43 m_decoder(Aws::Utils::Event::EventStreamDecoder(&m_handler))
44{
45}
46
47Aws::String SelectObjectContentRequest::SerializePayload() const
48{
49 XmlDocument payloadDoc = XmlDocument::CreateWithRootNode("SelectObjectContentRequest");
50
51 XmlNode parentNode = payloadDoc.GetRootElement();
52 parentNode.SetAttributeValue("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
53
54 Aws::StringStream ss;
55 if(m_expressionHasBeenSet)
56 {
57 XmlNode expressionNode = parentNode.CreateChildElement("Expression");
58 expressionNode.SetText(m_expression);
59 }
60
61 if(m_expressionTypeHasBeenSet)
62 {
63 XmlNode expressionTypeNode = parentNode.CreateChildElement("ExpressionType");
64 expressionTypeNode.SetText(ExpressionTypeMapper::GetNameForExpressionType(m_expressionType));
65 }
66
67 if(m_requestProgressHasBeenSet)
68 {
69 XmlNode requestProgressNode = parentNode.CreateChildElement("RequestProgress");
70 m_requestProgress.AddToNode(requestProgressNode);
71 }
72
73 if(m_inputSerializationHasBeenSet)
74 {
75 XmlNode inputSerializationNode = parentNode.CreateChildElement("InputSerialization");
76 m_inputSerialization.AddToNode(inputSerializationNode);
77 }
78
79 if(m_outputSerializationHasBeenSet)
80 {
81 XmlNode outputSerializationNode = parentNode.CreateChildElement("OutputSerialization");
82 m_outputSerialization.AddToNode(outputSerializationNode);
83 }
84
85 if(m_scanRangeHasBeenSet)
86 {
87 XmlNode scanRangeNode = parentNode.CreateChildElement("ScanRange");
88 m_scanRange.AddToNode(scanRangeNode);
89 }
90
91 return payloadDoc.ConvertToString();
92}
93
94void SelectObjectContentRequest::AddQueryStringParameters(URI& uri) const
95{
96 Aws::StringStream ss;
97 if(!m_customizedAccessLogTag.empty())
98 {
99 // only accept customized LogTag which starts with "x-"
100 Aws::Map<Aws::String, Aws::String> collectedLogTags;
101 for(const auto& entry: m_customizedAccessLogTag)
102 {
103 if (!entry.first.empty() && !entry.second.empty() && entry.first.substr(0, 2) == "x-")
104 {
105 collectedLogTags.emplace(entry.first, entry.second);
106 }
107 }
108
109 if (!collectedLogTags.empty())
110 {
111 uri.AddQueryStringParameter(collectedLogTags);
112 }
113 }
114}
115
116Aws::Http::HeaderValueCollection SelectObjectContentRequest::GetRequestSpecificHeaders() const
117{
118 Aws::Http::HeaderValueCollection headers;
119 Aws::StringStream ss;
120 if(m_sSECustomerAlgorithmHasBeenSet)
121 {
122 ss << m_sSECustomerAlgorithm;
123 headers.emplace("x-amz-server-side-encryption-customer-algorithm", ss.str());
124 ss.str("");
125 }
126
127 if(m_sSECustomerKeyHasBeenSet)
128 {
129 ss << m_sSECustomerKey;
130 headers.emplace("x-amz-server-side-encryption-customer-key", ss.str());
131 ss.str("");
132 }
133
134 if(m_sSECustomerKeyMD5HasBeenSet)
135 {
136 ss << m_sSECustomerKeyMD5;
137 headers.emplace("x-amz-server-side-encryption-customer-key-md5", ss.str());
138 ss.str("");
139 }
140
141 return headers;
142}
143