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/Stack.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 
Stack()23 Stack::Stack() :
24     m_stackIdHasBeenSet(false),
25     m_stackNameHasBeenSet(false),
26     m_changeSetIdHasBeenSet(false),
27     m_descriptionHasBeenSet(false),
28     m_parametersHasBeenSet(false),
29     m_creationTimeHasBeenSet(false),
30     m_deletionTimeHasBeenSet(false),
31     m_lastUpdatedTimeHasBeenSet(false),
32     m_rollbackConfigurationHasBeenSet(false),
33     m_stackStatus(StackStatus::NOT_SET),
34     m_stackStatusHasBeenSet(false),
35     m_stackStatusReasonHasBeenSet(false),
36     m_disableRollback(false),
37     m_disableRollbackHasBeenSet(false),
38     m_notificationARNsHasBeenSet(false),
39     m_timeoutInMinutes(0),
40     m_timeoutInMinutesHasBeenSet(false),
41     m_capabilitiesHasBeenSet(false),
42     m_outputsHasBeenSet(false),
43     m_roleARNHasBeenSet(false),
44     m_tagsHasBeenSet(false),
45     m_enableTerminationProtection(false),
46     m_enableTerminationProtectionHasBeenSet(false),
47     m_parentIdHasBeenSet(false),
48     m_rootIdHasBeenSet(false),
49     m_driftInformationHasBeenSet(false)
50 {
51 }
52 
Stack(const XmlNode & xmlNode)53 Stack::Stack(const XmlNode& xmlNode) :
54     m_stackIdHasBeenSet(false),
55     m_stackNameHasBeenSet(false),
56     m_changeSetIdHasBeenSet(false),
57     m_descriptionHasBeenSet(false),
58     m_parametersHasBeenSet(false),
59     m_creationTimeHasBeenSet(false),
60     m_deletionTimeHasBeenSet(false),
61     m_lastUpdatedTimeHasBeenSet(false),
62     m_rollbackConfigurationHasBeenSet(false),
63     m_stackStatus(StackStatus::NOT_SET),
64     m_stackStatusHasBeenSet(false),
65     m_stackStatusReasonHasBeenSet(false),
66     m_disableRollback(false),
67     m_disableRollbackHasBeenSet(false),
68     m_notificationARNsHasBeenSet(false),
69     m_timeoutInMinutes(0),
70     m_timeoutInMinutesHasBeenSet(false),
71     m_capabilitiesHasBeenSet(false),
72     m_outputsHasBeenSet(false),
73     m_roleARNHasBeenSet(false),
74     m_tagsHasBeenSet(false),
75     m_enableTerminationProtection(false),
76     m_enableTerminationProtectionHasBeenSet(false),
77     m_parentIdHasBeenSet(false),
78     m_rootIdHasBeenSet(false),
79     m_driftInformationHasBeenSet(false)
80 {
81   *this = xmlNode;
82 }
83 
operator =(const XmlNode & xmlNode)84 Stack& Stack::operator =(const XmlNode& xmlNode)
85 {
86   XmlNode resultNode = xmlNode;
87 
88   if(!resultNode.IsNull())
89   {
90     XmlNode stackIdNode = resultNode.FirstChild("StackId");
91     if(!stackIdNode.IsNull())
92     {
93       m_stackId = Aws::Utils::Xml::DecodeEscapedXmlText(stackIdNode.GetText());
94       m_stackIdHasBeenSet = true;
95     }
96     XmlNode stackNameNode = resultNode.FirstChild("StackName");
97     if(!stackNameNode.IsNull())
98     {
99       m_stackName = Aws::Utils::Xml::DecodeEscapedXmlText(stackNameNode.GetText());
100       m_stackNameHasBeenSet = true;
101     }
102     XmlNode changeSetIdNode = resultNode.FirstChild("ChangeSetId");
103     if(!changeSetIdNode.IsNull())
104     {
105       m_changeSetId = Aws::Utils::Xml::DecodeEscapedXmlText(changeSetIdNode.GetText());
106       m_changeSetIdHasBeenSet = true;
107     }
108     XmlNode descriptionNode = resultNode.FirstChild("Description");
109     if(!descriptionNode.IsNull())
110     {
111       m_description = Aws::Utils::Xml::DecodeEscapedXmlText(descriptionNode.GetText());
112       m_descriptionHasBeenSet = true;
113     }
114     XmlNode parametersNode = resultNode.FirstChild("Parameters");
115     if(!parametersNode.IsNull())
116     {
117       XmlNode parametersMember = parametersNode.FirstChild("member");
118       while(!parametersMember.IsNull())
119       {
120         m_parameters.push_back(parametersMember);
121         parametersMember = parametersMember.NextNode("member");
122       }
123 
124       m_parametersHasBeenSet = true;
125     }
126     XmlNode creationTimeNode = resultNode.FirstChild("CreationTime");
127     if(!creationTimeNode.IsNull())
128     {
129       m_creationTime = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(creationTimeNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601);
130       m_creationTimeHasBeenSet = true;
131     }
132     XmlNode deletionTimeNode = resultNode.FirstChild("DeletionTime");
133     if(!deletionTimeNode.IsNull())
134     {
135       m_deletionTime = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(deletionTimeNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601);
136       m_deletionTimeHasBeenSet = true;
137     }
138     XmlNode lastUpdatedTimeNode = resultNode.FirstChild("LastUpdatedTime");
139     if(!lastUpdatedTimeNode.IsNull())
140     {
141       m_lastUpdatedTime = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(lastUpdatedTimeNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601);
142       m_lastUpdatedTimeHasBeenSet = true;
143     }
144     XmlNode rollbackConfigurationNode = resultNode.FirstChild("RollbackConfiguration");
145     if(!rollbackConfigurationNode.IsNull())
146     {
147       m_rollbackConfiguration = rollbackConfigurationNode;
148       m_rollbackConfigurationHasBeenSet = true;
149     }
150     XmlNode stackStatusNode = resultNode.FirstChild("StackStatus");
151     if(!stackStatusNode.IsNull())
152     {
153       m_stackStatus = StackStatusMapper::GetStackStatusForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(stackStatusNode.GetText()).c_str()).c_str());
154       m_stackStatusHasBeenSet = true;
155     }
156     XmlNode stackStatusReasonNode = resultNode.FirstChild("StackStatusReason");
157     if(!stackStatusReasonNode.IsNull())
158     {
159       m_stackStatusReason = Aws::Utils::Xml::DecodeEscapedXmlText(stackStatusReasonNode.GetText());
160       m_stackStatusReasonHasBeenSet = true;
161     }
162     XmlNode disableRollbackNode = resultNode.FirstChild("DisableRollback");
163     if(!disableRollbackNode.IsNull())
164     {
165       m_disableRollback = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(disableRollbackNode.GetText()).c_str()).c_str());
166       m_disableRollbackHasBeenSet = true;
167     }
168     XmlNode notificationARNsNode = resultNode.FirstChild("NotificationARNs");
169     if(!notificationARNsNode.IsNull())
170     {
171       XmlNode notificationARNsMember = notificationARNsNode.FirstChild("member");
172       while(!notificationARNsMember.IsNull())
173       {
174         m_notificationARNs.push_back(notificationARNsMember.GetText());
175         notificationARNsMember = notificationARNsMember.NextNode("member");
176       }
177 
178       m_notificationARNsHasBeenSet = true;
179     }
180     XmlNode timeoutInMinutesNode = resultNode.FirstChild("TimeoutInMinutes");
181     if(!timeoutInMinutesNode.IsNull())
182     {
183       m_timeoutInMinutes = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(timeoutInMinutesNode.GetText()).c_str()).c_str());
184       m_timeoutInMinutesHasBeenSet = true;
185     }
186     XmlNode capabilitiesNode = resultNode.FirstChild("Capabilities");
187     if(!capabilitiesNode.IsNull())
188     {
189       XmlNode capabilitiesMember = capabilitiesNode.FirstChild("member");
190       while(!capabilitiesMember.IsNull())
191       {
192         m_capabilities.push_back(CapabilityMapper::GetCapabilityForName(StringUtils::Trim(capabilitiesMember.GetText().c_str())));
193         capabilitiesMember = capabilitiesMember.NextNode("member");
194       }
195 
196       m_capabilitiesHasBeenSet = true;
197     }
198     XmlNode outputsNode = resultNode.FirstChild("Outputs");
199     if(!outputsNode.IsNull())
200     {
201       XmlNode outputsMember = outputsNode.FirstChild("member");
202       while(!outputsMember.IsNull())
203       {
204         m_outputs.push_back(outputsMember);
205         outputsMember = outputsMember.NextNode("member");
206       }
207 
208       m_outputsHasBeenSet = true;
209     }
210     XmlNode roleARNNode = resultNode.FirstChild("RoleARN");
211     if(!roleARNNode.IsNull())
212     {
213       m_roleARN = Aws::Utils::Xml::DecodeEscapedXmlText(roleARNNode.GetText());
214       m_roleARNHasBeenSet = true;
215     }
216     XmlNode tagsNode = resultNode.FirstChild("Tags");
217     if(!tagsNode.IsNull())
218     {
219       XmlNode tagsMember = tagsNode.FirstChild("member");
220       while(!tagsMember.IsNull())
221       {
222         m_tags.push_back(tagsMember);
223         tagsMember = tagsMember.NextNode("member");
224       }
225 
226       m_tagsHasBeenSet = true;
227     }
228     XmlNode enableTerminationProtectionNode = resultNode.FirstChild("EnableTerminationProtection");
229     if(!enableTerminationProtectionNode.IsNull())
230     {
231       m_enableTerminationProtection = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(enableTerminationProtectionNode.GetText()).c_str()).c_str());
232       m_enableTerminationProtectionHasBeenSet = true;
233     }
234     XmlNode parentIdNode = resultNode.FirstChild("ParentId");
235     if(!parentIdNode.IsNull())
236     {
237       m_parentId = Aws::Utils::Xml::DecodeEscapedXmlText(parentIdNode.GetText());
238       m_parentIdHasBeenSet = true;
239     }
240     XmlNode rootIdNode = resultNode.FirstChild("RootId");
241     if(!rootIdNode.IsNull())
242     {
243       m_rootId = Aws::Utils::Xml::DecodeEscapedXmlText(rootIdNode.GetText());
244       m_rootIdHasBeenSet = true;
245     }
246     XmlNode driftInformationNode = resultNode.FirstChild("DriftInformation");
247     if(!driftInformationNode.IsNull())
248     {
249       m_driftInformation = driftInformationNode;
250       m_driftInformationHasBeenSet = true;
251     }
252   }
253 
254   return *this;
255 }
256 
OutputToStream(Aws::OStream & oStream,const char * location,unsigned index,const char * locationValue) const257 void Stack::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
258 {
259   if(m_stackIdHasBeenSet)
260   {
261       oStream << location << index << locationValue << ".StackId=" << StringUtils::URLEncode(m_stackId.c_str()) << "&";
262   }
263 
264   if(m_stackNameHasBeenSet)
265   {
266       oStream << location << index << locationValue << ".StackName=" << StringUtils::URLEncode(m_stackName.c_str()) << "&";
267   }
268 
269   if(m_changeSetIdHasBeenSet)
270   {
271       oStream << location << index << locationValue << ".ChangeSetId=" << StringUtils::URLEncode(m_changeSetId.c_str()) << "&";
272   }
273 
274   if(m_descriptionHasBeenSet)
275   {
276       oStream << location << index << locationValue << ".Description=" << StringUtils::URLEncode(m_description.c_str()) << "&";
277   }
278 
279   if(m_parametersHasBeenSet)
280   {
281       unsigned parametersIdx = 1;
282       for(auto& item : m_parameters)
283       {
284         Aws::StringStream parametersSs;
285         parametersSs << location << index << locationValue << ".Parameters.member." << parametersIdx++;
286         item.OutputToStream(oStream, parametersSs.str().c_str());
287       }
288   }
289 
290   if(m_creationTimeHasBeenSet)
291   {
292       oStream << location << index << locationValue << ".CreationTime=" << StringUtils::URLEncode(m_creationTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
293   }
294 
295   if(m_deletionTimeHasBeenSet)
296   {
297       oStream << location << index << locationValue << ".DeletionTime=" << StringUtils::URLEncode(m_deletionTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
298   }
299 
300   if(m_lastUpdatedTimeHasBeenSet)
301   {
302       oStream << location << index << locationValue << ".LastUpdatedTime=" << StringUtils::URLEncode(m_lastUpdatedTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
303   }
304 
305   if(m_rollbackConfigurationHasBeenSet)
306   {
307       Aws::StringStream rollbackConfigurationLocationAndMemberSs;
308       rollbackConfigurationLocationAndMemberSs << location << index << locationValue << ".RollbackConfiguration";
309       m_rollbackConfiguration.OutputToStream(oStream, rollbackConfigurationLocationAndMemberSs.str().c_str());
310   }
311 
312   if(m_stackStatusHasBeenSet)
313   {
314       oStream << location << index << locationValue << ".StackStatus=" << StackStatusMapper::GetNameForStackStatus(m_stackStatus) << "&";
315   }
316 
317   if(m_stackStatusReasonHasBeenSet)
318   {
319       oStream << location << index << locationValue << ".StackStatusReason=" << StringUtils::URLEncode(m_stackStatusReason.c_str()) << "&";
320   }
321 
322   if(m_disableRollbackHasBeenSet)
323   {
324       oStream << location << index << locationValue << ".DisableRollback=" << std::boolalpha << m_disableRollback << "&";
325   }
326 
327   if(m_notificationARNsHasBeenSet)
328   {
329       unsigned notificationARNsIdx = 1;
330       for(auto& item : m_notificationARNs)
331       {
332         oStream << location << index << locationValue << ".NotificationARNs.member." << notificationARNsIdx++ << "=" << StringUtils::URLEncode(item.c_str()) << "&";
333       }
334   }
335 
336   if(m_timeoutInMinutesHasBeenSet)
337   {
338       oStream << location << index << locationValue << ".TimeoutInMinutes=" << m_timeoutInMinutes << "&";
339   }
340 
341   if(m_capabilitiesHasBeenSet)
342   {
343       unsigned capabilitiesIdx = 1;
344       for(auto& item : m_capabilities)
345       {
346         oStream << location << index << locationValue << ".Capabilities.member." << capabilitiesIdx++ << "=" << CapabilityMapper::GetNameForCapability(item) << "&";
347       }
348   }
349 
350   if(m_outputsHasBeenSet)
351   {
352       unsigned outputsIdx = 1;
353       for(auto& item : m_outputs)
354       {
355         Aws::StringStream outputsSs;
356         outputsSs << location << index << locationValue << ".Outputs.member." << outputsIdx++;
357         item.OutputToStream(oStream, outputsSs.str().c_str());
358       }
359   }
360 
361   if(m_roleARNHasBeenSet)
362   {
363       oStream << location << index << locationValue << ".RoleARN=" << StringUtils::URLEncode(m_roleARN.c_str()) << "&";
364   }
365 
366   if(m_tagsHasBeenSet)
367   {
368       unsigned tagsIdx = 1;
369       for(auto& item : m_tags)
370       {
371         Aws::StringStream tagsSs;
372         tagsSs << location << index << locationValue << ".Tags.member." << tagsIdx++;
373         item.OutputToStream(oStream, tagsSs.str().c_str());
374       }
375   }
376 
377   if(m_enableTerminationProtectionHasBeenSet)
378   {
379       oStream << location << index << locationValue << ".EnableTerminationProtection=" << std::boolalpha << m_enableTerminationProtection << "&";
380   }
381 
382   if(m_parentIdHasBeenSet)
383   {
384       oStream << location << index << locationValue << ".ParentId=" << StringUtils::URLEncode(m_parentId.c_str()) << "&";
385   }
386 
387   if(m_rootIdHasBeenSet)
388   {
389       oStream << location << index << locationValue << ".RootId=" << StringUtils::URLEncode(m_rootId.c_str()) << "&";
390   }
391 
392   if(m_driftInformationHasBeenSet)
393   {
394       Aws::StringStream driftInformationLocationAndMemberSs;
395       driftInformationLocationAndMemberSs << location << index << locationValue << ".DriftInformation";
396       m_driftInformation.OutputToStream(oStream, driftInformationLocationAndMemberSs.str().c_str());
397   }
398 
399 }
400 
OutputToStream(Aws::OStream & oStream,const char * location) const401 void Stack::OutputToStream(Aws::OStream& oStream, const char* location) const
402 {
403   if(m_stackIdHasBeenSet)
404   {
405       oStream << location << ".StackId=" << StringUtils::URLEncode(m_stackId.c_str()) << "&";
406   }
407   if(m_stackNameHasBeenSet)
408   {
409       oStream << location << ".StackName=" << StringUtils::URLEncode(m_stackName.c_str()) << "&";
410   }
411   if(m_changeSetIdHasBeenSet)
412   {
413       oStream << location << ".ChangeSetId=" << StringUtils::URLEncode(m_changeSetId.c_str()) << "&";
414   }
415   if(m_descriptionHasBeenSet)
416   {
417       oStream << location << ".Description=" << StringUtils::URLEncode(m_description.c_str()) << "&";
418   }
419   if(m_parametersHasBeenSet)
420   {
421       unsigned parametersIdx = 1;
422       for(auto& item : m_parameters)
423       {
424         Aws::StringStream parametersSs;
425         parametersSs << location <<  ".Parameters.member." << parametersIdx++;
426         item.OutputToStream(oStream, parametersSs.str().c_str());
427       }
428   }
429   if(m_creationTimeHasBeenSet)
430   {
431       oStream << location << ".CreationTime=" << StringUtils::URLEncode(m_creationTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
432   }
433   if(m_deletionTimeHasBeenSet)
434   {
435       oStream << location << ".DeletionTime=" << StringUtils::URLEncode(m_deletionTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
436   }
437   if(m_lastUpdatedTimeHasBeenSet)
438   {
439       oStream << location << ".LastUpdatedTime=" << StringUtils::URLEncode(m_lastUpdatedTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
440   }
441   if(m_rollbackConfigurationHasBeenSet)
442   {
443       Aws::String rollbackConfigurationLocationAndMember(location);
444       rollbackConfigurationLocationAndMember += ".RollbackConfiguration";
445       m_rollbackConfiguration.OutputToStream(oStream, rollbackConfigurationLocationAndMember.c_str());
446   }
447   if(m_stackStatusHasBeenSet)
448   {
449       oStream << location << ".StackStatus=" << StackStatusMapper::GetNameForStackStatus(m_stackStatus) << "&";
450   }
451   if(m_stackStatusReasonHasBeenSet)
452   {
453       oStream << location << ".StackStatusReason=" << StringUtils::URLEncode(m_stackStatusReason.c_str()) << "&";
454   }
455   if(m_disableRollbackHasBeenSet)
456   {
457       oStream << location << ".DisableRollback=" << std::boolalpha << m_disableRollback << "&";
458   }
459   if(m_notificationARNsHasBeenSet)
460   {
461       unsigned notificationARNsIdx = 1;
462       for(auto& item : m_notificationARNs)
463       {
464         oStream << location << ".NotificationARNs.member." << notificationARNsIdx++ << "=" << StringUtils::URLEncode(item.c_str()) << "&";
465       }
466   }
467   if(m_timeoutInMinutesHasBeenSet)
468   {
469       oStream << location << ".TimeoutInMinutes=" << m_timeoutInMinutes << "&";
470   }
471   if(m_capabilitiesHasBeenSet)
472   {
473       unsigned capabilitiesIdx = 1;
474       for(auto& item : m_capabilities)
475       {
476         oStream << location << ".Capabilities.member." << capabilitiesIdx++ << "=" << CapabilityMapper::GetNameForCapability(item) << "&";
477       }
478   }
479   if(m_outputsHasBeenSet)
480   {
481       unsigned outputsIdx = 1;
482       for(auto& item : m_outputs)
483       {
484         Aws::StringStream outputsSs;
485         outputsSs << location <<  ".Outputs.member." << outputsIdx++;
486         item.OutputToStream(oStream, outputsSs.str().c_str());
487       }
488   }
489   if(m_roleARNHasBeenSet)
490   {
491       oStream << location << ".RoleARN=" << StringUtils::URLEncode(m_roleARN.c_str()) << "&";
492   }
493   if(m_tagsHasBeenSet)
494   {
495       unsigned tagsIdx = 1;
496       for(auto& item : m_tags)
497       {
498         Aws::StringStream tagsSs;
499         tagsSs << location <<  ".Tags.member." << tagsIdx++;
500         item.OutputToStream(oStream, tagsSs.str().c_str());
501       }
502   }
503   if(m_enableTerminationProtectionHasBeenSet)
504   {
505       oStream << location << ".EnableTerminationProtection=" << std::boolalpha << m_enableTerminationProtection << "&";
506   }
507   if(m_parentIdHasBeenSet)
508   {
509       oStream << location << ".ParentId=" << StringUtils::URLEncode(m_parentId.c_str()) << "&";
510   }
511   if(m_rootIdHasBeenSet)
512   {
513       oStream << location << ".RootId=" << StringUtils::URLEncode(m_rootId.c_str()) << "&";
514   }
515   if(m_driftInformationHasBeenSet)
516   {
517       Aws::String driftInformationLocationAndMember(location);
518       driftInformationLocationAndMember += ".DriftInformation";
519       m_driftInformation.OutputToStream(oStream, driftInformationLocationAndMember.c_str());
520   }
521 }
522 
523 } // namespace Model
524 } // namespace CloudFormation
525 } // namespace Aws
526