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/NetworkInterfaceAttachment.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 
NetworkInterfaceAttachment()23 NetworkInterfaceAttachment::NetworkInterfaceAttachment() :
24     m_attachTimeHasBeenSet(false),
25     m_attachmentIdHasBeenSet(false),
26     m_deleteOnTermination(false),
27     m_deleteOnTerminationHasBeenSet(false),
28     m_deviceIndex(0),
29     m_deviceIndexHasBeenSet(false),
30     m_networkCardIndex(0),
31     m_networkCardIndexHasBeenSet(false),
32     m_instanceIdHasBeenSet(false),
33     m_instanceOwnerIdHasBeenSet(false),
34     m_status(AttachmentStatus::NOT_SET),
35     m_statusHasBeenSet(false)
36 {
37 }
38 
NetworkInterfaceAttachment(const XmlNode & xmlNode)39 NetworkInterfaceAttachment::NetworkInterfaceAttachment(const XmlNode& xmlNode) :
40     m_attachTimeHasBeenSet(false),
41     m_attachmentIdHasBeenSet(false),
42     m_deleteOnTermination(false),
43     m_deleteOnTerminationHasBeenSet(false),
44     m_deviceIndex(0),
45     m_deviceIndexHasBeenSet(false),
46     m_networkCardIndex(0),
47     m_networkCardIndexHasBeenSet(false),
48     m_instanceIdHasBeenSet(false),
49     m_instanceOwnerIdHasBeenSet(false),
50     m_status(AttachmentStatus::NOT_SET),
51     m_statusHasBeenSet(false)
52 {
53   *this = xmlNode;
54 }
55 
operator =(const XmlNode & xmlNode)56 NetworkInterfaceAttachment& NetworkInterfaceAttachment::operator =(const XmlNode& xmlNode)
57 {
58   XmlNode resultNode = xmlNode;
59 
60   if(!resultNode.IsNull())
61   {
62     XmlNode attachTimeNode = resultNode.FirstChild("attachTime");
63     if(!attachTimeNode.IsNull())
64     {
65       m_attachTime = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(attachTimeNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601);
66       m_attachTimeHasBeenSet = true;
67     }
68     XmlNode attachmentIdNode = resultNode.FirstChild("attachmentId");
69     if(!attachmentIdNode.IsNull())
70     {
71       m_attachmentId = Aws::Utils::Xml::DecodeEscapedXmlText(attachmentIdNode.GetText());
72       m_attachmentIdHasBeenSet = true;
73     }
74     XmlNode deleteOnTerminationNode = resultNode.FirstChild("deleteOnTermination");
75     if(!deleteOnTerminationNode.IsNull())
76     {
77       m_deleteOnTermination = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(deleteOnTerminationNode.GetText()).c_str()).c_str());
78       m_deleteOnTerminationHasBeenSet = true;
79     }
80     XmlNode deviceIndexNode = resultNode.FirstChild("deviceIndex");
81     if(!deviceIndexNode.IsNull())
82     {
83       m_deviceIndex = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(deviceIndexNode.GetText()).c_str()).c_str());
84       m_deviceIndexHasBeenSet = true;
85     }
86     XmlNode networkCardIndexNode = resultNode.FirstChild("networkCardIndex");
87     if(!networkCardIndexNode.IsNull())
88     {
89       m_networkCardIndex = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(networkCardIndexNode.GetText()).c_str()).c_str());
90       m_networkCardIndexHasBeenSet = true;
91     }
92     XmlNode instanceIdNode = resultNode.FirstChild("instanceId");
93     if(!instanceIdNode.IsNull())
94     {
95       m_instanceId = Aws::Utils::Xml::DecodeEscapedXmlText(instanceIdNode.GetText());
96       m_instanceIdHasBeenSet = true;
97     }
98     XmlNode instanceOwnerIdNode = resultNode.FirstChild("instanceOwnerId");
99     if(!instanceOwnerIdNode.IsNull())
100     {
101       m_instanceOwnerId = Aws::Utils::Xml::DecodeEscapedXmlText(instanceOwnerIdNode.GetText());
102       m_instanceOwnerIdHasBeenSet = true;
103     }
104     XmlNode statusNode = resultNode.FirstChild("status");
105     if(!statusNode.IsNull())
106     {
107       m_status = AttachmentStatusMapper::GetAttachmentStatusForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(statusNode.GetText()).c_str()).c_str());
108       m_statusHasBeenSet = true;
109     }
110   }
111 
112   return *this;
113 }
114 
OutputToStream(Aws::OStream & oStream,const char * location,unsigned index,const char * locationValue) const115 void NetworkInterfaceAttachment::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
116 {
117   if(m_attachTimeHasBeenSet)
118   {
119       oStream << location << index << locationValue << ".AttachTime=" << StringUtils::URLEncode(m_attachTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
120   }
121 
122   if(m_attachmentIdHasBeenSet)
123   {
124       oStream << location << index << locationValue << ".AttachmentId=" << StringUtils::URLEncode(m_attachmentId.c_str()) << "&";
125   }
126 
127   if(m_deleteOnTerminationHasBeenSet)
128   {
129       oStream << location << index << locationValue << ".DeleteOnTermination=" << std::boolalpha << m_deleteOnTermination << "&";
130   }
131 
132   if(m_deviceIndexHasBeenSet)
133   {
134       oStream << location << index << locationValue << ".DeviceIndex=" << m_deviceIndex << "&";
135   }
136 
137   if(m_networkCardIndexHasBeenSet)
138   {
139       oStream << location << index << locationValue << ".NetworkCardIndex=" << m_networkCardIndex << "&";
140   }
141 
142   if(m_instanceIdHasBeenSet)
143   {
144       oStream << location << index << locationValue << ".InstanceId=" << StringUtils::URLEncode(m_instanceId.c_str()) << "&";
145   }
146 
147   if(m_instanceOwnerIdHasBeenSet)
148   {
149       oStream << location << index << locationValue << ".InstanceOwnerId=" << StringUtils::URLEncode(m_instanceOwnerId.c_str()) << "&";
150   }
151 
152   if(m_statusHasBeenSet)
153   {
154       oStream << location << index << locationValue << ".Status=" << AttachmentStatusMapper::GetNameForAttachmentStatus(m_status) << "&";
155   }
156 
157 }
158 
OutputToStream(Aws::OStream & oStream,const char * location) const159 void NetworkInterfaceAttachment::OutputToStream(Aws::OStream& oStream, const char* location) const
160 {
161   if(m_attachTimeHasBeenSet)
162   {
163       oStream << location << ".AttachTime=" << StringUtils::URLEncode(m_attachTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
164   }
165   if(m_attachmentIdHasBeenSet)
166   {
167       oStream << location << ".AttachmentId=" << StringUtils::URLEncode(m_attachmentId.c_str()) << "&";
168   }
169   if(m_deleteOnTerminationHasBeenSet)
170   {
171       oStream << location << ".DeleteOnTermination=" << std::boolalpha << m_deleteOnTermination << "&";
172   }
173   if(m_deviceIndexHasBeenSet)
174   {
175       oStream << location << ".DeviceIndex=" << m_deviceIndex << "&";
176   }
177   if(m_networkCardIndexHasBeenSet)
178   {
179       oStream << location << ".NetworkCardIndex=" << m_networkCardIndex << "&";
180   }
181   if(m_instanceIdHasBeenSet)
182   {
183       oStream << location << ".InstanceId=" << StringUtils::URLEncode(m_instanceId.c_str()) << "&";
184   }
185   if(m_instanceOwnerIdHasBeenSet)
186   {
187       oStream << location << ".InstanceOwnerId=" << StringUtils::URLEncode(m_instanceOwnerId.c_str()) << "&";
188   }
189   if(m_statusHasBeenSet)
190   {
191       oStream << location << ".Status=" << AttachmentStatusMapper::GetNameForAttachmentStatus(m_status) << "&";
192   }
193 }
194 
195 } // namespace Model
196 } // namespace EC2
197 } // namespace Aws
198