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/LaunchTemplateSpotMarketOptionsRequest.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
LaunchTemplateSpotMarketOptionsRequest()23 LaunchTemplateSpotMarketOptionsRequest::LaunchTemplateSpotMarketOptionsRequest() :
24 m_maxPriceHasBeenSet(false),
25 m_spotInstanceType(SpotInstanceType::NOT_SET),
26 m_spotInstanceTypeHasBeenSet(false),
27 m_blockDurationMinutes(0),
28 m_blockDurationMinutesHasBeenSet(false),
29 m_validUntilHasBeenSet(false),
30 m_instanceInterruptionBehavior(InstanceInterruptionBehavior::NOT_SET),
31 m_instanceInterruptionBehaviorHasBeenSet(false)
32 {
33 }
34
LaunchTemplateSpotMarketOptionsRequest(const XmlNode & xmlNode)35 LaunchTemplateSpotMarketOptionsRequest::LaunchTemplateSpotMarketOptionsRequest(const XmlNode& xmlNode) :
36 m_maxPriceHasBeenSet(false),
37 m_spotInstanceType(SpotInstanceType::NOT_SET),
38 m_spotInstanceTypeHasBeenSet(false),
39 m_blockDurationMinutes(0),
40 m_blockDurationMinutesHasBeenSet(false),
41 m_validUntilHasBeenSet(false),
42 m_instanceInterruptionBehavior(InstanceInterruptionBehavior::NOT_SET),
43 m_instanceInterruptionBehaviorHasBeenSet(false)
44 {
45 *this = xmlNode;
46 }
47
operator =(const XmlNode & xmlNode)48 LaunchTemplateSpotMarketOptionsRequest& LaunchTemplateSpotMarketOptionsRequest::operator =(const XmlNode& xmlNode)
49 {
50 XmlNode resultNode = xmlNode;
51
52 if(!resultNode.IsNull())
53 {
54 XmlNode maxPriceNode = resultNode.FirstChild("MaxPrice");
55 if(!maxPriceNode.IsNull())
56 {
57 m_maxPrice = Aws::Utils::Xml::DecodeEscapedXmlText(maxPriceNode.GetText());
58 m_maxPriceHasBeenSet = true;
59 }
60 XmlNode spotInstanceTypeNode = resultNode.FirstChild("SpotInstanceType");
61 if(!spotInstanceTypeNode.IsNull())
62 {
63 m_spotInstanceType = SpotInstanceTypeMapper::GetSpotInstanceTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(spotInstanceTypeNode.GetText()).c_str()).c_str());
64 m_spotInstanceTypeHasBeenSet = true;
65 }
66 XmlNode blockDurationMinutesNode = resultNode.FirstChild("BlockDurationMinutes");
67 if(!blockDurationMinutesNode.IsNull())
68 {
69 m_blockDurationMinutes = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(blockDurationMinutesNode.GetText()).c_str()).c_str());
70 m_blockDurationMinutesHasBeenSet = true;
71 }
72 XmlNode validUntilNode = resultNode.FirstChild("ValidUntil");
73 if(!validUntilNode.IsNull())
74 {
75 m_validUntil = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(validUntilNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601);
76 m_validUntilHasBeenSet = true;
77 }
78 XmlNode instanceInterruptionBehaviorNode = resultNode.FirstChild("InstanceInterruptionBehavior");
79 if(!instanceInterruptionBehaviorNode.IsNull())
80 {
81 m_instanceInterruptionBehavior = InstanceInterruptionBehaviorMapper::GetInstanceInterruptionBehaviorForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(instanceInterruptionBehaviorNode.GetText()).c_str()).c_str());
82 m_instanceInterruptionBehaviorHasBeenSet = true;
83 }
84 }
85
86 return *this;
87 }
88
OutputToStream(Aws::OStream & oStream,const char * location,unsigned index,const char * locationValue) const89 void LaunchTemplateSpotMarketOptionsRequest::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
90 {
91 if(m_maxPriceHasBeenSet)
92 {
93 oStream << location << index << locationValue << ".MaxPrice=" << StringUtils::URLEncode(m_maxPrice.c_str()) << "&";
94 }
95
96 if(m_spotInstanceTypeHasBeenSet)
97 {
98 oStream << location << index << locationValue << ".SpotInstanceType=" << SpotInstanceTypeMapper::GetNameForSpotInstanceType(m_spotInstanceType) << "&";
99 }
100
101 if(m_blockDurationMinutesHasBeenSet)
102 {
103 oStream << location << index << locationValue << ".BlockDurationMinutes=" << m_blockDurationMinutes << "&";
104 }
105
106 if(m_validUntilHasBeenSet)
107 {
108 oStream << location << index << locationValue << ".ValidUntil=" << StringUtils::URLEncode(m_validUntil.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
109 }
110
111 if(m_instanceInterruptionBehaviorHasBeenSet)
112 {
113 oStream << location << index << locationValue << ".InstanceInterruptionBehavior=" << InstanceInterruptionBehaviorMapper::GetNameForInstanceInterruptionBehavior(m_instanceInterruptionBehavior) << "&";
114 }
115
116 }
117
OutputToStream(Aws::OStream & oStream,const char * location) const118 void LaunchTemplateSpotMarketOptionsRequest::OutputToStream(Aws::OStream& oStream, const char* location) const
119 {
120 if(m_maxPriceHasBeenSet)
121 {
122 oStream << location << ".MaxPrice=" << StringUtils::URLEncode(m_maxPrice.c_str()) << "&";
123 }
124 if(m_spotInstanceTypeHasBeenSet)
125 {
126 oStream << location << ".SpotInstanceType=" << SpotInstanceTypeMapper::GetNameForSpotInstanceType(m_spotInstanceType) << "&";
127 }
128 if(m_blockDurationMinutesHasBeenSet)
129 {
130 oStream << location << ".BlockDurationMinutes=" << m_blockDurationMinutes << "&";
131 }
132 if(m_validUntilHasBeenSet)
133 {
134 oStream << location << ".ValidUntil=" << StringUtils::URLEncode(m_validUntil.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
135 }
136 if(m_instanceInterruptionBehaviorHasBeenSet)
137 {
138 oStream << location << ".InstanceInterruptionBehavior=" << InstanceInterruptionBehaviorMapper::GetNameForInstanceInterruptionBehavior(m_instanceInterruptionBehavior) << "&";
139 }
140 }
141
142 } // namespace Model
143 } // namespace EC2
144 } // namespace Aws
145