1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/cloudformation/model/StackSetOperationPreferences.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 CloudFormation
19 {
20 namespace Model
21 {
22 
StackSetOperationPreferences()23 StackSetOperationPreferences::StackSetOperationPreferences() :
24     m_regionConcurrencyType(RegionConcurrencyType::NOT_SET),
25     m_regionConcurrencyTypeHasBeenSet(false),
26     m_regionOrderHasBeenSet(false),
27     m_failureToleranceCount(0),
28     m_failureToleranceCountHasBeenSet(false),
29     m_failureTolerancePercentage(0),
30     m_failureTolerancePercentageHasBeenSet(false),
31     m_maxConcurrentCount(0),
32     m_maxConcurrentCountHasBeenSet(false),
33     m_maxConcurrentPercentage(0),
34     m_maxConcurrentPercentageHasBeenSet(false)
35 {
36 }
37 
StackSetOperationPreferences(const XmlNode & xmlNode)38 StackSetOperationPreferences::StackSetOperationPreferences(const XmlNode& xmlNode) :
39     m_regionConcurrencyType(RegionConcurrencyType::NOT_SET),
40     m_regionConcurrencyTypeHasBeenSet(false),
41     m_regionOrderHasBeenSet(false),
42     m_failureToleranceCount(0),
43     m_failureToleranceCountHasBeenSet(false),
44     m_failureTolerancePercentage(0),
45     m_failureTolerancePercentageHasBeenSet(false),
46     m_maxConcurrentCount(0),
47     m_maxConcurrentCountHasBeenSet(false),
48     m_maxConcurrentPercentage(0),
49     m_maxConcurrentPercentageHasBeenSet(false)
50 {
51   *this = xmlNode;
52 }
53 
operator =(const XmlNode & xmlNode)54 StackSetOperationPreferences& StackSetOperationPreferences::operator =(const XmlNode& xmlNode)
55 {
56   XmlNode resultNode = xmlNode;
57 
58   if(!resultNode.IsNull())
59   {
60     XmlNode regionConcurrencyTypeNode = resultNode.FirstChild("RegionConcurrencyType");
61     if(!regionConcurrencyTypeNode.IsNull())
62     {
63       m_regionConcurrencyType = RegionConcurrencyTypeMapper::GetRegionConcurrencyTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(regionConcurrencyTypeNode.GetText()).c_str()).c_str());
64       m_regionConcurrencyTypeHasBeenSet = true;
65     }
66     XmlNode regionOrderNode = resultNode.FirstChild("RegionOrder");
67     if(!regionOrderNode.IsNull())
68     {
69       XmlNode regionOrderMember = regionOrderNode.FirstChild("member");
70       while(!regionOrderMember.IsNull())
71       {
72         m_regionOrder.push_back(regionOrderMember.GetText());
73         regionOrderMember = regionOrderMember.NextNode("member");
74       }
75 
76       m_regionOrderHasBeenSet = true;
77     }
78     XmlNode failureToleranceCountNode = resultNode.FirstChild("FailureToleranceCount");
79     if(!failureToleranceCountNode.IsNull())
80     {
81       m_failureToleranceCount = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(failureToleranceCountNode.GetText()).c_str()).c_str());
82       m_failureToleranceCountHasBeenSet = true;
83     }
84     XmlNode failureTolerancePercentageNode = resultNode.FirstChild("FailureTolerancePercentage");
85     if(!failureTolerancePercentageNode.IsNull())
86     {
87       m_failureTolerancePercentage = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(failureTolerancePercentageNode.GetText()).c_str()).c_str());
88       m_failureTolerancePercentageHasBeenSet = true;
89     }
90     XmlNode maxConcurrentCountNode = resultNode.FirstChild("MaxConcurrentCount");
91     if(!maxConcurrentCountNode.IsNull())
92     {
93       m_maxConcurrentCount = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(maxConcurrentCountNode.GetText()).c_str()).c_str());
94       m_maxConcurrentCountHasBeenSet = true;
95     }
96     XmlNode maxConcurrentPercentageNode = resultNode.FirstChild("MaxConcurrentPercentage");
97     if(!maxConcurrentPercentageNode.IsNull())
98     {
99       m_maxConcurrentPercentage = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(maxConcurrentPercentageNode.GetText()).c_str()).c_str());
100       m_maxConcurrentPercentageHasBeenSet = true;
101     }
102   }
103 
104   return *this;
105 }
106 
OutputToStream(Aws::OStream & oStream,const char * location,unsigned index,const char * locationValue) const107 void StackSetOperationPreferences::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
108 {
109   if(m_regionConcurrencyTypeHasBeenSet)
110   {
111       oStream << location << index << locationValue << ".RegionConcurrencyType=" << RegionConcurrencyTypeMapper::GetNameForRegionConcurrencyType(m_regionConcurrencyType) << "&";
112   }
113 
114   if(m_regionOrderHasBeenSet)
115   {
116       unsigned regionOrderIdx = 1;
117       for(auto& item : m_regionOrder)
118       {
119         oStream << location << index << locationValue << ".RegionOrder.member." << regionOrderIdx++ << "=" << StringUtils::URLEncode(item.c_str()) << "&";
120       }
121   }
122 
123   if(m_failureToleranceCountHasBeenSet)
124   {
125       oStream << location << index << locationValue << ".FailureToleranceCount=" << m_failureToleranceCount << "&";
126   }
127 
128   if(m_failureTolerancePercentageHasBeenSet)
129   {
130       oStream << location << index << locationValue << ".FailureTolerancePercentage=" << m_failureTolerancePercentage << "&";
131   }
132 
133   if(m_maxConcurrentCountHasBeenSet)
134   {
135       oStream << location << index << locationValue << ".MaxConcurrentCount=" << m_maxConcurrentCount << "&";
136   }
137 
138   if(m_maxConcurrentPercentageHasBeenSet)
139   {
140       oStream << location << index << locationValue << ".MaxConcurrentPercentage=" << m_maxConcurrentPercentage << "&";
141   }
142 
143 }
144 
OutputToStream(Aws::OStream & oStream,const char * location) const145 void StackSetOperationPreferences::OutputToStream(Aws::OStream& oStream, const char* location) const
146 {
147   if(m_regionConcurrencyTypeHasBeenSet)
148   {
149       oStream << location << ".RegionConcurrencyType=" << RegionConcurrencyTypeMapper::GetNameForRegionConcurrencyType(m_regionConcurrencyType) << "&";
150   }
151   if(m_regionOrderHasBeenSet)
152   {
153       unsigned regionOrderIdx = 1;
154       for(auto& item : m_regionOrder)
155       {
156         oStream << location << ".RegionOrder.member." << regionOrderIdx++ << "=" << StringUtils::URLEncode(item.c_str()) << "&";
157       }
158   }
159   if(m_failureToleranceCountHasBeenSet)
160   {
161       oStream << location << ".FailureToleranceCount=" << m_failureToleranceCount << "&";
162   }
163   if(m_failureTolerancePercentageHasBeenSet)
164   {
165       oStream << location << ".FailureTolerancePercentage=" << m_failureTolerancePercentage << "&";
166   }
167   if(m_maxConcurrentCountHasBeenSet)
168   {
169       oStream << location << ".MaxConcurrentCount=" << m_maxConcurrentCount << "&";
170   }
171   if(m_maxConcurrentPercentageHasBeenSet)
172   {
173       oStream << location << ".MaxConcurrentPercentage=" << m_maxConcurrentPercentage << "&";
174   }
175 }
176 
177 } // namespace Model
178 } // namespace CloudFormation
179 } // namespace Aws
180