1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/docdb/model/Event.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 DocDB
19 {
20 namespace Model
21 {
22
Event()23 Event::Event() :
24 m_sourceIdentifierHasBeenSet(false),
25 m_sourceType(SourceType::NOT_SET),
26 m_sourceTypeHasBeenSet(false),
27 m_messageHasBeenSet(false),
28 m_eventCategoriesHasBeenSet(false),
29 m_dateHasBeenSet(false),
30 m_sourceArnHasBeenSet(false)
31 {
32 }
33
Event(const XmlNode & xmlNode)34 Event::Event(const XmlNode& xmlNode) :
35 m_sourceIdentifierHasBeenSet(false),
36 m_sourceType(SourceType::NOT_SET),
37 m_sourceTypeHasBeenSet(false),
38 m_messageHasBeenSet(false),
39 m_eventCategoriesHasBeenSet(false),
40 m_dateHasBeenSet(false),
41 m_sourceArnHasBeenSet(false)
42 {
43 *this = xmlNode;
44 }
45
operator =(const XmlNode & xmlNode)46 Event& Event::operator =(const XmlNode& xmlNode)
47 {
48 XmlNode resultNode = xmlNode;
49
50 if(!resultNode.IsNull())
51 {
52 XmlNode sourceIdentifierNode = resultNode.FirstChild("SourceIdentifier");
53 if(!sourceIdentifierNode.IsNull())
54 {
55 m_sourceIdentifier = Aws::Utils::Xml::DecodeEscapedXmlText(sourceIdentifierNode.GetText());
56 m_sourceIdentifierHasBeenSet = true;
57 }
58 XmlNode sourceTypeNode = resultNode.FirstChild("SourceType");
59 if(!sourceTypeNode.IsNull())
60 {
61 m_sourceType = SourceTypeMapper::GetSourceTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(sourceTypeNode.GetText()).c_str()).c_str());
62 m_sourceTypeHasBeenSet = true;
63 }
64 XmlNode messageNode = resultNode.FirstChild("Message");
65 if(!messageNode.IsNull())
66 {
67 m_message = Aws::Utils::Xml::DecodeEscapedXmlText(messageNode.GetText());
68 m_messageHasBeenSet = true;
69 }
70 XmlNode eventCategoriesNode = resultNode.FirstChild("EventCategories");
71 if(!eventCategoriesNode.IsNull())
72 {
73 XmlNode eventCategoriesMember = eventCategoriesNode.FirstChild("EventCategory");
74 while(!eventCategoriesMember.IsNull())
75 {
76 m_eventCategories.push_back(eventCategoriesMember.GetText());
77 eventCategoriesMember = eventCategoriesMember.NextNode("EventCategory");
78 }
79
80 m_eventCategoriesHasBeenSet = true;
81 }
82 XmlNode dateNode = resultNode.FirstChild("Date");
83 if(!dateNode.IsNull())
84 {
85 m_date = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(dateNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601);
86 m_dateHasBeenSet = true;
87 }
88 XmlNode sourceArnNode = resultNode.FirstChild("SourceArn");
89 if(!sourceArnNode.IsNull())
90 {
91 m_sourceArn = Aws::Utils::Xml::DecodeEscapedXmlText(sourceArnNode.GetText());
92 m_sourceArnHasBeenSet = true;
93 }
94 }
95
96 return *this;
97 }
98
OutputToStream(Aws::OStream & oStream,const char * location,unsigned index,const char * locationValue) const99 void Event::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
100 {
101 if(m_sourceIdentifierHasBeenSet)
102 {
103 oStream << location << index << locationValue << ".SourceIdentifier=" << StringUtils::URLEncode(m_sourceIdentifier.c_str()) << "&";
104 }
105
106 if(m_sourceTypeHasBeenSet)
107 {
108 oStream << location << index << locationValue << ".SourceType=" << SourceTypeMapper::GetNameForSourceType(m_sourceType) << "&";
109 }
110
111 if(m_messageHasBeenSet)
112 {
113 oStream << location << index << locationValue << ".Message=" << StringUtils::URLEncode(m_message.c_str()) << "&";
114 }
115
116 if(m_eventCategoriesHasBeenSet)
117 {
118 unsigned eventCategoriesIdx = 1;
119 for(auto& item : m_eventCategories)
120 {
121 oStream << location << index << locationValue << ".EventCategory." << eventCategoriesIdx++ << "=" << StringUtils::URLEncode(item.c_str()) << "&";
122 }
123 }
124
125 if(m_dateHasBeenSet)
126 {
127 oStream << location << index << locationValue << ".Date=" << StringUtils::URLEncode(m_date.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
128 }
129
130 if(m_sourceArnHasBeenSet)
131 {
132 oStream << location << index << locationValue << ".SourceArn=" << StringUtils::URLEncode(m_sourceArn.c_str()) << "&";
133 }
134
135 }
136
OutputToStream(Aws::OStream & oStream,const char * location) const137 void Event::OutputToStream(Aws::OStream& oStream, const char* location) const
138 {
139 if(m_sourceIdentifierHasBeenSet)
140 {
141 oStream << location << ".SourceIdentifier=" << StringUtils::URLEncode(m_sourceIdentifier.c_str()) << "&";
142 }
143 if(m_sourceTypeHasBeenSet)
144 {
145 oStream << location << ".SourceType=" << SourceTypeMapper::GetNameForSourceType(m_sourceType) << "&";
146 }
147 if(m_messageHasBeenSet)
148 {
149 oStream << location << ".Message=" << StringUtils::URLEncode(m_message.c_str()) << "&";
150 }
151 if(m_eventCategoriesHasBeenSet)
152 {
153 unsigned eventCategoriesIdx = 1;
154 for(auto& item : m_eventCategories)
155 {
156 oStream << location << ".EventCategory." << eventCategoriesIdx++ << "=" << StringUtils::URLEncode(item.c_str()) << "&";
157 }
158 }
159 if(m_dateHasBeenSet)
160 {
161 oStream << location << ".Date=" << StringUtils::URLEncode(m_date.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
162 }
163 if(m_sourceArnHasBeenSet)
164 {
165 oStream << location << ".SourceArn=" << StringUtils::URLEncode(m_sourceArn.c_str()) << "&";
166 }
167 }
168
169 } // namespace Model
170 } // namespace DocDB
171 } // namespace Aws
172