1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/ec2/model/ReservedInstancesOffering.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 EC2
19 {
20 namespace Model
21 {
22
ReservedInstancesOffering()23 ReservedInstancesOffering::ReservedInstancesOffering() :
24 m_availabilityZoneHasBeenSet(false),
25 m_duration(0),
26 m_durationHasBeenSet(false),
27 m_fixedPrice(0.0),
28 m_fixedPriceHasBeenSet(false),
29 m_instanceType(InstanceType::NOT_SET),
30 m_instanceTypeHasBeenSet(false),
31 m_productDescription(RIProductDescription::NOT_SET),
32 m_productDescriptionHasBeenSet(false),
33 m_reservedInstancesOfferingIdHasBeenSet(false),
34 m_usagePrice(0.0),
35 m_usagePriceHasBeenSet(false),
36 m_currencyCode(CurrencyCodeValues::NOT_SET),
37 m_currencyCodeHasBeenSet(false),
38 m_instanceTenancy(Tenancy::NOT_SET),
39 m_instanceTenancyHasBeenSet(false),
40 m_marketplace(false),
41 m_marketplaceHasBeenSet(false),
42 m_offeringClass(OfferingClassType::NOT_SET),
43 m_offeringClassHasBeenSet(false),
44 m_offeringType(OfferingTypeValues::NOT_SET),
45 m_offeringTypeHasBeenSet(false),
46 m_pricingDetailsHasBeenSet(false),
47 m_recurringChargesHasBeenSet(false),
48 m_scope(Scope::NOT_SET),
49 m_scopeHasBeenSet(false)
50 {
51 }
52
ReservedInstancesOffering(const XmlNode & xmlNode)53 ReservedInstancesOffering::ReservedInstancesOffering(const XmlNode& xmlNode) :
54 m_availabilityZoneHasBeenSet(false),
55 m_duration(0),
56 m_durationHasBeenSet(false),
57 m_fixedPrice(0.0),
58 m_fixedPriceHasBeenSet(false),
59 m_instanceType(InstanceType::NOT_SET),
60 m_instanceTypeHasBeenSet(false),
61 m_productDescription(RIProductDescription::NOT_SET),
62 m_productDescriptionHasBeenSet(false),
63 m_reservedInstancesOfferingIdHasBeenSet(false),
64 m_usagePrice(0.0),
65 m_usagePriceHasBeenSet(false),
66 m_currencyCode(CurrencyCodeValues::NOT_SET),
67 m_currencyCodeHasBeenSet(false),
68 m_instanceTenancy(Tenancy::NOT_SET),
69 m_instanceTenancyHasBeenSet(false),
70 m_marketplace(false),
71 m_marketplaceHasBeenSet(false),
72 m_offeringClass(OfferingClassType::NOT_SET),
73 m_offeringClassHasBeenSet(false),
74 m_offeringType(OfferingTypeValues::NOT_SET),
75 m_offeringTypeHasBeenSet(false),
76 m_pricingDetailsHasBeenSet(false),
77 m_recurringChargesHasBeenSet(false),
78 m_scope(Scope::NOT_SET),
79 m_scopeHasBeenSet(false)
80 {
81 *this = xmlNode;
82 }
83
operator =(const XmlNode & xmlNode)84 ReservedInstancesOffering& ReservedInstancesOffering::operator =(const XmlNode& xmlNode)
85 {
86 XmlNode resultNode = xmlNode;
87
88 if(!resultNode.IsNull())
89 {
90 XmlNode availabilityZoneNode = resultNode.FirstChild("availabilityZone");
91 if(!availabilityZoneNode.IsNull())
92 {
93 m_availabilityZone = Aws::Utils::Xml::DecodeEscapedXmlText(availabilityZoneNode.GetText());
94 m_availabilityZoneHasBeenSet = true;
95 }
96 XmlNode durationNode = resultNode.FirstChild("duration");
97 if(!durationNode.IsNull())
98 {
99 m_duration = StringUtils::ConvertToInt64(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(durationNode.GetText()).c_str()).c_str());
100 m_durationHasBeenSet = true;
101 }
102 XmlNode fixedPriceNode = resultNode.FirstChild("fixedPrice");
103 if(!fixedPriceNode.IsNull())
104 {
105 m_fixedPrice = StringUtils::ConvertToDouble(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(fixedPriceNode.GetText()).c_str()).c_str());
106 m_fixedPriceHasBeenSet = true;
107 }
108 XmlNode instanceTypeNode = resultNode.FirstChild("instanceType");
109 if(!instanceTypeNode.IsNull())
110 {
111 m_instanceType = InstanceTypeMapper::GetInstanceTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(instanceTypeNode.GetText()).c_str()).c_str());
112 m_instanceTypeHasBeenSet = true;
113 }
114 XmlNode productDescriptionNode = resultNode.FirstChild("productDescription");
115 if(!productDescriptionNode.IsNull())
116 {
117 m_productDescription = RIProductDescriptionMapper::GetRIProductDescriptionForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(productDescriptionNode.GetText()).c_str()).c_str());
118 m_productDescriptionHasBeenSet = true;
119 }
120 XmlNode reservedInstancesOfferingIdNode = resultNode.FirstChild("reservedInstancesOfferingId");
121 if(!reservedInstancesOfferingIdNode.IsNull())
122 {
123 m_reservedInstancesOfferingId = Aws::Utils::Xml::DecodeEscapedXmlText(reservedInstancesOfferingIdNode.GetText());
124 m_reservedInstancesOfferingIdHasBeenSet = true;
125 }
126 XmlNode usagePriceNode = resultNode.FirstChild("usagePrice");
127 if(!usagePriceNode.IsNull())
128 {
129 m_usagePrice = StringUtils::ConvertToDouble(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(usagePriceNode.GetText()).c_str()).c_str());
130 m_usagePriceHasBeenSet = true;
131 }
132 XmlNode currencyCodeNode = resultNode.FirstChild("currencyCode");
133 if(!currencyCodeNode.IsNull())
134 {
135 m_currencyCode = CurrencyCodeValuesMapper::GetCurrencyCodeValuesForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(currencyCodeNode.GetText()).c_str()).c_str());
136 m_currencyCodeHasBeenSet = true;
137 }
138 XmlNode instanceTenancyNode = resultNode.FirstChild("instanceTenancy");
139 if(!instanceTenancyNode.IsNull())
140 {
141 m_instanceTenancy = TenancyMapper::GetTenancyForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(instanceTenancyNode.GetText()).c_str()).c_str());
142 m_instanceTenancyHasBeenSet = true;
143 }
144 XmlNode marketplaceNode = resultNode.FirstChild("marketplace");
145 if(!marketplaceNode.IsNull())
146 {
147 m_marketplace = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(marketplaceNode.GetText()).c_str()).c_str());
148 m_marketplaceHasBeenSet = true;
149 }
150 XmlNode offeringClassNode = resultNode.FirstChild("offeringClass");
151 if(!offeringClassNode.IsNull())
152 {
153 m_offeringClass = OfferingClassTypeMapper::GetOfferingClassTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(offeringClassNode.GetText()).c_str()).c_str());
154 m_offeringClassHasBeenSet = true;
155 }
156 XmlNode offeringTypeNode = resultNode.FirstChild("offeringType");
157 if(!offeringTypeNode.IsNull())
158 {
159 m_offeringType = OfferingTypeValuesMapper::GetOfferingTypeValuesForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(offeringTypeNode.GetText()).c_str()).c_str());
160 m_offeringTypeHasBeenSet = true;
161 }
162 XmlNode pricingDetailsNode = resultNode.FirstChild("pricingDetailsSet");
163 if(!pricingDetailsNode.IsNull())
164 {
165 XmlNode pricingDetailsMember = pricingDetailsNode.FirstChild("item");
166 while(!pricingDetailsMember.IsNull())
167 {
168 m_pricingDetails.push_back(pricingDetailsMember);
169 pricingDetailsMember = pricingDetailsMember.NextNode("item");
170 }
171
172 m_pricingDetailsHasBeenSet = true;
173 }
174 XmlNode recurringChargesNode = resultNode.FirstChild("recurringCharges");
175 if(!recurringChargesNode.IsNull())
176 {
177 XmlNode recurringChargesMember = recurringChargesNode.FirstChild("item");
178 while(!recurringChargesMember.IsNull())
179 {
180 m_recurringCharges.push_back(recurringChargesMember);
181 recurringChargesMember = recurringChargesMember.NextNode("item");
182 }
183
184 m_recurringChargesHasBeenSet = true;
185 }
186 XmlNode scopeNode = resultNode.FirstChild("scope");
187 if(!scopeNode.IsNull())
188 {
189 m_scope = ScopeMapper::GetScopeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(scopeNode.GetText()).c_str()).c_str());
190 m_scopeHasBeenSet = true;
191 }
192 }
193
194 return *this;
195 }
196
OutputToStream(Aws::OStream & oStream,const char * location,unsigned index,const char * locationValue) const197 void ReservedInstancesOffering::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
198 {
199 if(m_availabilityZoneHasBeenSet)
200 {
201 oStream << location << index << locationValue << ".AvailabilityZone=" << StringUtils::URLEncode(m_availabilityZone.c_str()) << "&";
202 }
203
204 if(m_durationHasBeenSet)
205 {
206 oStream << location << index << locationValue << ".Duration=" << m_duration << "&";
207 }
208
209 if(m_fixedPriceHasBeenSet)
210 {
211 oStream << location << index << locationValue << ".FixedPrice=" << m_fixedPrice << "&";
212 }
213
214 if(m_instanceTypeHasBeenSet)
215 {
216 oStream << location << index << locationValue << ".InstanceType=" << InstanceTypeMapper::GetNameForInstanceType(m_instanceType) << "&";
217 }
218
219 if(m_productDescriptionHasBeenSet)
220 {
221 oStream << location << index << locationValue << ".ProductDescription=" << RIProductDescriptionMapper::GetNameForRIProductDescription(m_productDescription) << "&";
222 }
223
224 if(m_reservedInstancesOfferingIdHasBeenSet)
225 {
226 oStream << location << index << locationValue << ".ReservedInstancesOfferingId=" << StringUtils::URLEncode(m_reservedInstancesOfferingId.c_str()) << "&";
227 }
228
229 if(m_usagePriceHasBeenSet)
230 {
231 oStream << location << index << locationValue << ".UsagePrice=" << m_usagePrice << "&";
232 }
233
234 if(m_currencyCodeHasBeenSet)
235 {
236 oStream << location << index << locationValue << ".CurrencyCode=" << CurrencyCodeValuesMapper::GetNameForCurrencyCodeValues(m_currencyCode) << "&";
237 }
238
239 if(m_instanceTenancyHasBeenSet)
240 {
241 oStream << location << index << locationValue << ".InstanceTenancy=" << TenancyMapper::GetNameForTenancy(m_instanceTenancy) << "&";
242 }
243
244 if(m_marketplaceHasBeenSet)
245 {
246 oStream << location << index << locationValue << ".Marketplace=" << std::boolalpha << m_marketplace << "&";
247 }
248
249 if(m_offeringClassHasBeenSet)
250 {
251 oStream << location << index << locationValue << ".OfferingClass=" << OfferingClassTypeMapper::GetNameForOfferingClassType(m_offeringClass) << "&";
252 }
253
254 if(m_offeringTypeHasBeenSet)
255 {
256 oStream << location << index << locationValue << ".OfferingType=" << OfferingTypeValuesMapper::GetNameForOfferingTypeValues(m_offeringType) << "&";
257 }
258
259 if(m_pricingDetailsHasBeenSet)
260 {
261 unsigned pricingDetailsIdx = 1;
262 for(auto& item : m_pricingDetails)
263 {
264 Aws::StringStream pricingDetailsSs;
265 pricingDetailsSs << location << index << locationValue << ".PricingDetailsSet." << pricingDetailsIdx++;
266 item.OutputToStream(oStream, pricingDetailsSs.str().c_str());
267 }
268 }
269
270 if(m_recurringChargesHasBeenSet)
271 {
272 unsigned recurringChargesIdx = 1;
273 for(auto& item : m_recurringCharges)
274 {
275 Aws::StringStream recurringChargesSs;
276 recurringChargesSs << location << index << locationValue << ".RecurringCharges." << recurringChargesIdx++;
277 item.OutputToStream(oStream, recurringChargesSs.str().c_str());
278 }
279 }
280
281 if(m_scopeHasBeenSet)
282 {
283 oStream << location << index << locationValue << ".Scope=" << ScopeMapper::GetNameForScope(m_scope) << "&";
284 }
285
286 }
287
OutputToStream(Aws::OStream & oStream,const char * location) const288 void ReservedInstancesOffering::OutputToStream(Aws::OStream& oStream, const char* location) const
289 {
290 if(m_availabilityZoneHasBeenSet)
291 {
292 oStream << location << ".AvailabilityZone=" << StringUtils::URLEncode(m_availabilityZone.c_str()) << "&";
293 }
294 if(m_durationHasBeenSet)
295 {
296 oStream << location << ".Duration=" << m_duration << "&";
297 }
298 if(m_fixedPriceHasBeenSet)
299 {
300 oStream << location << ".FixedPrice=" << m_fixedPrice << "&";
301 }
302 if(m_instanceTypeHasBeenSet)
303 {
304 oStream << location << ".InstanceType=" << InstanceTypeMapper::GetNameForInstanceType(m_instanceType) << "&";
305 }
306 if(m_productDescriptionHasBeenSet)
307 {
308 oStream << location << ".ProductDescription=" << RIProductDescriptionMapper::GetNameForRIProductDescription(m_productDescription) << "&";
309 }
310 if(m_reservedInstancesOfferingIdHasBeenSet)
311 {
312 oStream << location << ".ReservedInstancesOfferingId=" << StringUtils::URLEncode(m_reservedInstancesOfferingId.c_str()) << "&";
313 }
314 if(m_usagePriceHasBeenSet)
315 {
316 oStream << location << ".UsagePrice=" << m_usagePrice << "&";
317 }
318 if(m_currencyCodeHasBeenSet)
319 {
320 oStream << location << ".CurrencyCode=" << CurrencyCodeValuesMapper::GetNameForCurrencyCodeValues(m_currencyCode) << "&";
321 }
322 if(m_instanceTenancyHasBeenSet)
323 {
324 oStream << location << ".InstanceTenancy=" << TenancyMapper::GetNameForTenancy(m_instanceTenancy) << "&";
325 }
326 if(m_marketplaceHasBeenSet)
327 {
328 oStream << location << ".Marketplace=" << std::boolalpha << m_marketplace << "&";
329 }
330 if(m_offeringClassHasBeenSet)
331 {
332 oStream << location << ".OfferingClass=" << OfferingClassTypeMapper::GetNameForOfferingClassType(m_offeringClass) << "&";
333 }
334 if(m_offeringTypeHasBeenSet)
335 {
336 oStream << location << ".OfferingType=" << OfferingTypeValuesMapper::GetNameForOfferingTypeValues(m_offeringType) << "&";
337 }
338 if(m_pricingDetailsHasBeenSet)
339 {
340 unsigned pricingDetailsIdx = 1;
341 for(auto& item : m_pricingDetails)
342 {
343 Aws::StringStream pricingDetailsSs;
344 pricingDetailsSs << location << ".PricingDetailsSet." << pricingDetailsIdx++;
345 item.OutputToStream(oStream, pricingDetailsSs.str().c_str());
346 }
347 }
348 if(m_recurringChargesHasBeenSet)
349 {
350 unsigned recurringChargesIdx = 1;
351 for(auto& item : m_recurringCharges)
352 {
353 Aws::StringStream recurringChargesSs;
354 recurringChargesSs << location << ".RecurringCharges." << recurringChargesIdx++;
355 item.OutputToStream(oStream, recurringChargesSs.str().c_str());
356 }
357 }
358 if(m_scopeHasBeenSet)
359 {
360 oStream << location << ".Scope=" << ScopeMapper::GetNameForScope(m_scope) << "&";
361 }
362 }
363
364 } // namespace Model
365 } // namespace EC2
366 } // namespace Aws
367