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/SpotPrice.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
SpotPrice()23 SpotPrice::SpotPrice() :
24 m_availabilityZoneHasBeenSet(false),
25 m_instanceType(InstanceType::NOT_SET),
26 m_instanceTypeHasBeenSet(false),
27 m_productDescription(RIProductDescription::NOT_SET),
28 m_productDescriptionHasBeenSet(false),
29 m_spotPriceHasBeenSet(false),
30 m_timestampHasBeenSet(false)
31 {
32 }
33
SpotPrice(const XmlNode & xmlNode)34 SpotPrice::SpotPrice(const XmlNode& xmlNode) :
35 m_availabilityZoneHasBeenSet(false),
36 m_instanceType(InstanceType::NOT_SET),
37 m_instanceTypeHasBeenSet(false),
38 m_productDescription(RIProductDescription::NOT_SET),
39 m_productDescriptionHasBeenSet(false),
40 m_spotPriceHasBeenSet(false),
41 m_timestampHasBeenSet(false)
42 {
43 *this = xmlNode;
44 }
45
operator =(const XmlNode & xmlNode)46 SpotPrice& SpotPrice::operator =(const XmlNode& xmlNode)
47 {
48 XmlNode resultNode = xmlNode;
49
50 if(!resultNode.IsNull())
51 {
52 XmlNode availabilityZoneNode = resultNode.FirstChild("availabilityZone");
53 if(!availabilityZoneNode.IsNull())
54 {
55 m_availabilityZone = Aws::Utils::Xml::DecodeEscapedXmlText(availabilityZoneNode.GetText());
56 m_availabilityZoneHasBeenSet = true;
57 }
58 XmlNode instanceTypeNode = resultNode.FirstChild("instanceType");
59 if(!instanceTypeNode.IsNull())
60 {
61 m_instanceType = InstanceTypeMapper::GetInstanceTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(instanceTypeNode.GetText()).c_str()).c_str());
62 m_instanceTypeHasBeenSet = true;
63 }
64 XmlNode productDescriptionNode = resultNode.FirstChild("productDescription");
65 if(!productDescriptionNode.IsNull())
66 {
67 m_productDescription = RIProductDescriptionMapper::GetRIProductDescriptionForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(productDescriptionNode.GetText()).c_str()).c_str());
68 m_productDescriptionHasBeenSet = true;
69 }
70 XmlNode spotPriceNode = resultNode.FirstChild("spotPrice");
71 if(!spotPriceNode.IsNull())
72 {
73 m_spotPrice = Aws::Utils::Xml::DecodeEscapedXmlText(spotPriceNode.GetText());
74 m_spotPriceHasBeenSet = true;
75 }
76 XmlNode timestampNode = resultNode.FirstChild("timestamp");
77 if(!timestampNode.IsNull())
78 {
79 m_timestamp = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(timestampNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601);
80 m_timestampHasBeenSet = true;
81 }
82 }
83
84 return *this;
85 }
86
OutputToStream(Aws::OStream & oStream,const char * location,unsigned index,const char * locationValue) const87 void SpotPrice::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
88 {
89 if(m_availabilityZoneHasBeenSet)
90 {
91 oStream << location << index << locationValue << ".AvailabilityZone=" << StringUtils::URLEncode(m_availabilityZone.c_str()) << "&";
92 }
93
94 if(m_instanceTypeHasBeenSet)
95 {
96 oStream << location << index << locationValue << ".InstanceType=" << InstanceTypeMapper::GetNameForInstanceType(m_instanceType) << "&";
97 }
98
99 if(m_productDescriptionHasBeenSet)
100 {
101 oStream << location << index << locationValue << ".ProductDescription=" << RIProductDescriptionMapper::GetNameForRIProductDescription(m_productDescription) << "&";
102 }
103
104 if(m_spotPriceHasBeenSet)
105 {
106 oStream << location << index << locationValue << ".SpotPrice=" << StringUtils::URLEncode(m_spotPrice.c_str()) << "&";
107 }
108
109 if(m_timestampHasBeenSet)
110 {
111 oStream << location << index << locationValue << ".Timestamp=" << StringUtils::URLEncode(m_timestamp.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
112 }
113
114 }
115
OutputToStream(Aws::OStream & oStream,const char * location) const116 void SpotPrice::OutputToStream(Aws::OStream& oStream, const char* location) const
117 {
118 if(m_availabilityZoneHasBeenSet)
119 {
120 oStream << location << ".AvailabilityZone=" << StringUtils::URLEncode(m_availabilityZone.c_str()) << "&";
121 }
122 if(m_instanceTypeHasBeenSet)
123 {
124 oStream << location << ".InstanceType=" << InstanceTypeMapper::GetNameForInstanceType(m_instanceType) << "&";
125 }
126 if(m_productDescriptionHasBeenSet)
127 {
128 oStream << location << ".ProductDescription=" << RIProductDescriptionMapper::GetNameForRIProductDescription(m_productDescription) << "&";
129 }
130 if(m_spotPriceHasBeenSet)
131 {
132 oStream << location << ".SpotPrice=" << StringUtils::URLEncode(m_spotPrice.c_str()) << "&";
133 }
134 if(m_timestampHasBeenSet)
135 {
136 oStream << location << ".Timestamp=" << StringUtils::URLEncode(m_timestamp.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
137 }
138 }
139
140 } // namespace Model
141 } // namespace EC2
142 } // namespace Aws
143