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/OnDemandOptionsRequest.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
OnDemandOptionsRequest()23 OnDemandOptionsRequest::OnDemandOptionsRequest() :
24 m_allocationStrategy(FleetOnDemandAllocationStrategy::NOT_SET),
25 m_allocationStrategyHasBeenSet(false),
26 m_capacityReservationOptionsHasBeenSet(false),
27 m_singleInstanceType(false),
28 m_singleInstanceTypeHasBeenSet(false),
29 m_singleAvailabilityZone(false),
30 m_singleAvailabilityZoneHasBeenSet(false),
31 m_minTargetCapacity(0),
32 m_minTargetCapacityHasBeenSet(false),
33 m_maxTotalPriceHasBeenSet(false)
34 {
35 }
36
OnDemandOptionsRequest(const XmlNode & xmlNode)37 OnDemandOptionsRequest::OnDemandOptionsRequest(const XmlNode& xmlNode) :
38 m_allocationStrategy(FleetOnDemandAllocationStrategy::NOT_SET),
39 m_allocationStrategyHasBeenSet(false),
40 m_capacityReservationOptionsHasBeenSet(false),
41 m_singleInstanceType(false),
42 m_singleInstanceTypeHasBeenSet(false),
43 m_singleAvailabilityZone(false),
44 m_singleAvailabilityZoneHasBeenSet(false),
45 m_minTargetCapacity(0),
46 m_minTargetCapacityHasBeenSet(false),
47 m_maxTotalPriceHasBeenSet(false)
48 {
49 *this = xmlNode;
50 }
51
operator =(const XmlNode & xmlNode)52 OnDemandOptionsRequest& OnDemandOptionsRequest::operator =(const XmlNode& xmlNode)
53 {
54 XmlNode resultNode = xmlNode;
55
56 if(!resultNode.IsNull())
57 {
58 XmlNode allocationStrategyNode = resultNode.FirstChild("AllocationStrategy");
59 if(!allocationStrategyNode.IsNull())
60 {
61 m_allocationStrategy = FleetOnDemandAllocationStrategyMapper::GetFleetOnDemandAllocationStrategyForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(allocationStrategyNode.GetText()).c_str()).c_str());
62 m_allocationStrategyHasBeenSet = true;
63 }
64 XmlNode capacityReservationOptionsNode = resultNode.FirstChild("CapacityReservationOptions");
65 if(!capacityReservationOptionsNode.IsNull())
66 {
67 m_capacityReservationOptions = capacityReservationOptionsNode;
68 m_capacityReservationOptionsHasBeenSet = true;
69 }
70 XmlNode singleInstanceTypeNode = resultNode.FirstChild("SingleInstanceType");
71 if(!singleInstanceTypeNode.IsNull())
72 {
73 m_singleInstanceType = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(singleInstanceTypeNode.GetText()).c_str()).c_str());
74 m_singleInstanceTypeHasBeenSet = true;
75 }
76 XmlNode singleAvailabilityZoneNode = resultNode.FirstChild("SingleAvailabilityZone");
77 if(!singleAvailabilityZoneNode.IsNull())
78 {
79 m_singleAvailabilityZone = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(singleAvailabilityZoneNode.GetText()).c_str()).c_str());
80 m_singleAvailabilityZoneHasBeenSet = true;
81 }
82 XmlNode minTargetCapacityNode = resultNode.FirstChild("MinTargetCapacity");
83 if(!minTargetCapacityNode.IsNull())
84 {
85 m_minTargetCapacity = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(minTargetCapacityNode.GetText()).c_str()).c_str());
86 m_minTargetCapacityHasBeenSet = true;
87 }
88 XmlNode maxTotalPriceNode = resultNode.FirstChild("MaxTotalPrice");
89 if(!maxTotalPriceNode.IsNull())
90 {
91 m_maxTotalPrice = Aws::Utils::Xml::DecodeEscapedXmlText(maxTotalPriceNode.GetText());
92 m_maxTotalPriceHasBeenSet = true;
93 }
94 }
95
96 return *this;
97 }
98
OutputToStream(Aws::OStream & oStream,const char * location,unsigned index,const char * locationValue) const99 void OnDemandOptionsRequest::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
100 {
101 if(m_allocationStrategyHasBeenSet)
102 {
103 oStream << location << index << locationValue << ".AllocationStrategy=" << FleetOnDemandAllocationStrategyMapper::GetNameForFleetOnDemandAllocationStrategy(m_allocationStrategy) << "&";
104 }
105
106 if(m_capacityReservationOptionsHasBeenSet)
107 {
108 Aws::StringStream capacityReservationOptionsLocationAndMemberSs;
109 capacityReservationOptionsLocationAndMemberSs << location << index << locationValue << ".CapacityReservationOptions";
110 m_capacityReservationOptions.OutputToStream(oStream, capacityReservationOptionsLocationAndMemberSs.str().c_str());
111 }
112
113 if(m_singleInstanceTypeHasBeenSet)
114 {
115 oStream << location << index << locationValue << ".SingleInstanceType=" << std::boolalpha << m_singleInstanceType << "&";
116 }
117
118 if(m_singleAvailabilityZoneHasBeenSet)
119 {
120 oStream << location << index << locationValue << ".SingleAvailabilityZone=" << std::boolalpha << m_singleAvailabilityZone << "&";
121 }
122
123 if(m_minTargetCapacityHasBeenSet)
124 {
125 oStream << location << index << locationValue << ".MinTargetCapacity=" << m_minTargetCapacity << "&";
126 }
127
128 if(m_maxTotalPriceHasBeenSet)
129 {
130 oStream << location << index << locationValue << ".MaxTotalPrice=" << StringUtils::URLEncode(m_maxTotalPrice.c_str()) << "&";
131 }
132
133 }
134
OutputToStream(Aws::OStream & oStream,const char * location) const135 void OnDemandOptionsRequest::OutputToStream(Aws::OStream& oStream, const char* location) const
136 {
137 if(m_allocationStrategyHasBeenSet)
138 {
139 oStream << location << ".AllocationStrategy=" << FleetOnDemandAllocationStrategyMapper::GetNameForFleetOnDemandAllocationStrategy(m_allocationStrategy) << "&";
140 }
141 if(m_capacityReservationOptionsHasBeenSet)
142 {
143 Aws::String capacityReservationOptionsLocationAndMember(location);
144 capacityReservationOptionsLocationAndMember += ".CapacityReservationOptions";
145 m_capacityReservationOptions.OutputToStream(oStream, capacityReservationOptionsLocationAndMember.c_str());
146 }
147 if(m_singleInstanceTypeHasBeenSet)
148 {
149 oStream << location << ".SingleInstanceType=" << std::boolalpha << m_singleInstanceType << "&";
150 }
151 if(m_singleAvailabilityZoneHasBeenSet)
152 {
153 oStream << location << ".SingleAvailabilityZone=" << std::boolalpha << m_singleAvailabilityZone << "&";
154 }
155 if(m_minTargetCapacityHasBeenSet)
156 {
157 oStream << location << ".MinTargetCapacity=" << m_minTargetCapacity << "&";
158 }
159 if(m_maxTotalPriceHasBeenSet)
160 {
161 oStream << location << ".MaxTotalPrice=" << StringUtils::URLEncode(m_maxTotalPrice.c_str()) << "&";
162 }
163 }
164
165 } // namespace Model
166 } // namespace EC2
167 } // namespace Aws
168