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/PrivateIpAddressSpecification.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 
PrivateIpAddressSpecification()23 PrivateIpAddressSpecification::PrivateIpAddressSpecification() :
24     m_primary(false),
25     m_primaryHasBeenSet(false),
26     m_privateIpAddressHasBeenSet(false)
27 {
28 }
29 
PrivateIpAddressSpecification(const XmlNode & xmlNode)30 PrivateIpAddressSpecification::PrivateIpAddressSpecification(const XmlNode& xmlNode) :
31     m_primary(false),
32     m_primaryHasBeenSet(false),
33     m_privateIpAddressHasBeenSet(false)
34 {
35   *this = xmlNode;
36 }
37 
operator =(const XmlNode & xmlNode)38 PrivateIpAddressSpecification& PrivateIpAddressSpecification::operator =(const XmlNode& xmlNode)
39 {
40   XmlNode resultNode = xmlNode;
41 
42   if(!resultNode.IsNull())
43   {
44     XmlNode primaryNode = resultNode.FirstChild("primary");
45     if(!primaryNode.IsNull())
46     {
47       m_primary = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(primaryNode.GetText()).c_str()).c_str());
48       m_primaryHasBeenSet = true;
49     }
50     XmlNode privateIpAddressNode = resultNode.FirstChild("privateIpAddress");
51     if(!privateIpAddressNode.IsNull())
52     {
53       m_privateIpAddress = Aws::Utils::Xml::DecodeEscapedXmlText(privateIpAddressNode.GetText());
54       m_privateIpAddressHasBeenSet = true;
55     }
56   }
57 
58   return *this;
59 }
60 
OutputToStream(Aws::OStream & oStream,const char * location,unsigned index,const char * locationValue) const61 void PrivateIpAddressSpecification::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
62 {
63   if(m_primaryHasBeenSet)
64   {
65       oStream << location << index << locationValue << ".Primary=" << std::boolalpha << m_primary << "&";
66   }
67 
68   if(m_privateIpAddressHasBeenSet)
69   {
70       oStream << location << index << locationValue << ".PrivateIpAddress=" << StringUtils::URLEncode(m_privateIpAddress.c_str()) << "&";
71   }
72 
73 }
74 
OutputToStream(Aws::OStream & oStream,const char * location) const75 void PrivateIpAddressSpecification::OutputToStream(Aws::OStream& oStream, const char* location) const
76 {
77   if(m_primaryHasBeenSet)
78   {
79       oStream << location << ".Primary=" << std::boolalpha << m_primary << "&";
80   }
81   if(m_privateIpAddressHasBeenSet)
82   {
83       oStream << location << ".PrivateIpAddress=" << StringUtils::URLEncode(m_privateIpAddress.c_str()) << "&";
84   }
85 }
86 
87 } // namespace Model
88 } // namespace EC2
89 } // namespace Aws
90