1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/redshift/model/ReservedNodeOffering.h>
7 #include <aws/core/utils/xml/XmlSerializer.h>
8 #include <aws/core/utils/StringUtils.h>
9 #include <aws/core/utils/memory/stl/AWSStringStream.h>
10
11 #include <utility>
12
13 using namespace Aws::Utils::Xml;
14 using namespace Aws::Utils;
15
16 namespace Aws
17 {
18 namespace Redshift
19 {
20 namespace Model
21 {
22
ReservedNodeOffering()23 ReservedNodeOffering::ReservedNodeOffering() :
24 m_reservedNodeOfferingIdHasBeenSet(false),
25 m_nodeTypeHasBeenSet(false),
26 m_duration(0),
27 m_durationHasBeenSet(false),
28 m_fixedPrice(0.0),
29 m_fixedPriceHasBeenSet(false),
30 m_usagePrice(0.0),
31 m_usagePriceHasBeenSet(false),
32 m_currencyCodeHasBeenSet(false),
33 m_offeringTypeHasBeenSet(false),
34 m_recurringChargesHasBeenSet(false),
35 m_reservedNodeOfferingType(ReservedNodeOfferingType::NOT_SET),
36 m_reservedNodeOfferingTypeHasBeenSet(false)
37 {
38 }
39
ReservedNodeOffering(const XmlNode & xmlNode)40 ReservedNodeOffering::ReservedNodeOffering(const XmlNode& xmlNode) :
41 m_reservedNodeOfferingIdHasBeenSet(false),
42 m_nodeTypeHasBeenSet(false),
43 m_duration(0),
44 m_durationHasBeenSet(false),
45 m_fixedPrice(0.0),
46 m_fixedPriceHasBeenSet(false),
47 m_usagePrice(0.0),
48 m_usagePriceHasBeenSet(false),
49 m_currencyCodeHasBeenSet(false),
50 m_offeringTypeHasBeenSet(false),
51 m_recurringChargesHasBeenSet(false),
52 m_reservedNodeOfferingType(ReservedNodeOfferingType::NOT_SET),
53 m_reservedNodeOfferingTypeHasBeenSet(false)
54 {
55 *this = xmlNode;
56 }
57
operator =(const XmlNode & xmlNode)58 ReservedNodeOffering& ReservedNodeOffering::operator =(const XmlNode& xmlNode)
59 {
60 XmlNode resultNode = xmlNode;
61
62 if(!resultNode.IsNull())
63 {
64 XmlNode reservedNodeOfferingIdNode = resultNode.FirstChild("ReservedNodeOfferingId");
65 if(!reservedNodeOfferingIdNode.IsNull())
66 {
67 m_reservedNodeOfferingId = Aws::Utils::Xml::DecodeEscapedXmlText(reservedNodeOfferingIdNode.GetText());
68 m_reservedNodeOfferingIdHasBeenSet = true;
69 }
70 XmlNode nodeTypeNode = resultNode.FirstChild("NodeType");
71 if(!nodeTypeNode.IsNull())
72 {
73 m_nodeType = Aws::Utils::Xml::DecodeEscapedXmlText(nodeTypeNode.GetText());
74 m_nodeTypeHasBeenSet = true;
75 }
76 XmlNode durationNode = resultNode.FirstChild("Duration");
77 if(!durationNode.IsNull())
78 {
79 m_duration = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(durationNode.GetText()).c_str()).c_str());
80 m_durationHasBeenSet = true;
81 }
82 XmlNode fixedPriceNode = resultNode.FirstChild("FixedPrice");
83 if(!fixedPriceNode.IsNull())
84 {
85 m_fixedPrice = StringUtils::ConvertToDouble(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(fixedPriceNode.GetText()).c_str()).c_str());
86 m_fixedPriceHasBeenSet = true;
87 }
88 XmlNode usagePriceNode = resultNode.FirstChild("UsagePrice");
89 if(!usagePriceNode.IsNull())
90 {
91 m_usagePrice = StringUtils::ConvertToDouble(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(usagePriceNode.GetText()).c_str()).c_str());
92 m_usagePriceHasBeenSet = true;
93 }
94 XmlNode currencyCodeNode = resultNode.FirstChild("CurrencyCode");
95 if(!currencyCodeNode.IsNull())
96 {
97 m_currencyCode = Aws::Utils::Xml::DecodeEscapedXmlText(currencyCodeNode.GetText());
98 m_currencyCodeHasBeenSet = true;
99 }
100 XmlNode offeringTypeNode = resultNode.FirstChild("OfferingType");
101 if(!offeringTypeNode.IsNull())
102 {
103 m_offeringType = Aws::Utils::Xml::DecodeEscapedXmlText(offeringTypeNode.GetText());
104 m_offeringTypeHasBeenSet = true;
105 }
106 XmlNode recurringChargesNode = resultNode.FirstChild("RecurringCharges");
107 if(!recurringChargesNode.IsNull())
108 {
109 XmlNode recurringChargesMember = recurringChargesNode.FirstChild("RecurringCharge");
110 while(!recurringChargesMember.IsNull())
111 {
112 m_recurringCharges.push_back(recurringChargesMember);
113 recurringChargesMember = recurringChargesMember.NextNode("RecurringCharge");
114 }
115
116 m_recurringChargesHasBeenSet = true;
117 }
118 XmlNode reservedNodeOfferingTypeNode = resultNode.FirstChild("ReservedNodeOfferingType");
119 if(!reservedNodeOfferingTypeNode.IsNull())
120 {
121 m_reservedNodeOfferingType = ReservedNodeOfferingTypeMapper::GetReservedNodeOfferingTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(reservedNodeOfferingTypeNode.GetText()).c_str()).c_str());
122 m_reservedNodeOfferingTypeHasBeenSet = true;
123 }
124 }
125
126 return *this;
127 }
128
OutputToStream(Aws::OStream & oStream,const char * location,unsigned index,const char * locationValue) const129 void ReservedNodeOffering::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
130 {
131 if(m_reservedNodeOfferingIdHasBeenSet)
132 {
133 oStream << location << index << locationValue << ".ReservedNodeOfferingId=" << StringUtils::URLEncode(m_reservedNodeOfferingId.c_str()) << "&";
134 }
135
136 if(m_nodeTypeHasBeenSet)
137 {
138 oStream << location << index << locationValue << ".NodeType=" << StringUtils::URLEncode(m_nodeType.c_str()) << "&";
139 }
140
141 if(m_durationHasBeenSet)
142 {
143 oStream << location << index << locationValue << ".Duration=" << m_duration << "&";
144 }
145
146 if(m_fixedPriceHasBeenSet)
147 {
148 oStream << location << index << locationValue << ".FixedPrice=" << StringUtils::URLEncode(m_fixedPrice) << "&";
149 }
150
151 if(m_usagePriceHasBeenSet)
152 {
153 oStream << location << index << locationValue << ".UsagePrice=" << StringUtils::URLEncode(m_usagePrice) << "&";
154 }
155
156 if(m_currencyCodeHasBeenSet)
157 {
158 oStream << location << index << locationValue << ".CurrencyCode=" << StringUtils::URLEncode(m_currencyCode.c_str()) << "&";
159 }
160
161 if(m_offeringTypeHasBeenSet)
162 {
163 oStream << location << index << locationValue << ".OfferingType=" << StringUtils::URLEncode(m_offeringType.c_str()) << "&";
164 }
165
166 if(m_recurringChargesHasBeenSet)
167 {
168 unsigned recurringChargesIdx = 1;
169 for(auto& item : m_recurringCharges)
170 {
171 Aws::StringStream recurringChargesSs;
172 recurringChargesSs << location << index << locationValue << ".RecurringCharge." << recurringChargesIdx++;
173 item.OutputToStream(oStream, recurringChargesSs.str().c_str());
174 }
175 }
176
177 if(m_reservedNodeOfferingTypeHasBeenSet)
178 {
179 oStream << location << index << locationValue << ".ReservedNodeOfferingType=" << ReservedNodeOfferingTypeMapper::GetNameForReservedNodeOfferingType(m_reservedNodeOfferingType) << "&";
180 }
181
182 }
183
OutputToStream(Aws::OStream & oStream,const char * location) const184 void ReservedNodeOffering::OutputToStream(Aws::OStream& oStream, const char* location) const
185 {
186 if(m_reservedNodeOfferingIdHasBeenSet)
187 {
188 oStream << location << ".ReservedNodeOfferingId=" << StringUtils::URLEncode(m_reservedNodeOfferingId.c_str()) << "&";
189 }
190 if(m_nodeTypeHasBeenSet)
191 {
192 oStream << location << ".NodeType=" << StringUtils::URLEncode(m_nodeType.c_str()) << "&";
193 }
194 if(m_durationHasBeenSet)
195 {
196 oStream << location << ".Duration=" << m_duration << "&";
197 }
198 if(m_fixedPriceHasBeenSet)
199 {
200 oStream << location << ".FixedPrice=" << StringUtils::URLEncode(m_fixedPrice) << "&";
201 }
202 if(m_usagePriceHasBeenSet)
203 {
204 oStream << location << ".UsagePrice=" << StringUtils::URLEncode(m_usagePrice) << "&";
205 }
206 if(m_currencyCodeHasBeenSet)
207 {
208 oStream << location << ".CurrencyCode=" << StringUtils::URLEncode(m_currencyCode.c_str()) << "&";
209 }
210 if(m_offeringTypeHasBeenSet)
211 {
212 oStream << location << ".OfferingType=" << StringUtils::URLEncode(m_offeringType.c_str()) << "&";
213 }
214 if(m_recurringChargesHasBeenSet)
215 {
216 unsigned recurringChargesIdx = 1;
217 for(auto& item : m_recurringCharges)
218 {
219 Aws::StringStream recurringChargesSs;
220 recurringChargesSs << location << ".RecurringCharge." << recurringChargesIdx++;
221 item.OutputToStream(oStream, recurringChargesSs.str().c_str());
222 }
223 }
224 if(m_reservedNodeOfferingTypeHasBeenSet)
225 {
226 oStream << location << ".ReservedNodeOfferingType=" << ReservedNodeOfferingTypeMapper::GetNameForReservedNodeOfferingType(m_reservedNodeOfferingType) << "&";
227 }
228 }
229
230 } // namespace Model
231 } // namespace Redshift
232 } // namespace Aws
233