1/*
2* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3*
4* Licensed under the Apache License, Version 2.0 (the "License").
5* You may not use this file except in compliance with the License.
6* A copy of the License is located at
7*
8* http://aws.amazon.com/apache2.0
9*
10* or in the "license" file accompanying this file. This file is distributed
11* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12* express or implied. See the License for the specific language governing
13* permissions and limitations under the License.
14*/
15
16#include <aws/s3/model/Rule.h>
17#include <aws/core/utils/xml/XmlSerializer.h>
18#include <aws/core/utils/StringUtils.h>
19#include <aws/core/utils/memory/stl/AWSStringStream.h>
20
21#include <utility>
22
23using namespace Aws::Utils::Xml;
24using namespace Aws::Utils;
25
26namespace Aws
27{
28namespace S3
29{
30namespace Model
31{
32
33Rule::Rule() :
34 m_expirationHasBeenSet(false),
35 m_iDHasBeenSet(false),
36 m_prefixHasBeenSet(false),
37 m_status(ExpirationStatus::NOT_SET),
38 m_statusHasBeenSet(false),
39 m_transitionHasBeenSet(false),
40 m_noncurrentVersionTransitionHasBeenSet(false),
41 m_noncurrentVersionExpirationHasBeenSet(false),
42 m_abortIncompleteMultipartUploadHasBeenSet(false)
43{
44}
45
46Rule::Rule(const XmlNode& xmlNode) :
47 m_expirationHasBeenSet(false),
48 m_iDHasBeenSet(false),
49 m_prefixHasBeenSet(false),
50 m_status(ExpirationStatus::NOT_SET),
51 m_statusHasBeenSet(false),
52 m_transitionHasBeenSet(false),
53 m_noncurrentVersionTransitionHasBeenSet(false),
54 m_noncurrentVersionExpirationHasBeenSet(false),
55 m_abortIncompleteMultipartUploadHasBeenSet(false)
56{
57 *this = xmlNode;
58}
59
60Rule& Rule::operator =(const XmlNode& xmlNode)
61{
62 XmlNode resultNode = xmlNode;
63
64 if(!resultNode.IsNull())
65 {
66 XmlNode expirationNode = resultNode.FirstChild("Expiration");
67 if(!expirationNode.IsNull())
68 {
69 m_expiration = expirationNode;
70 m_expirationHasBeenSet = true;
71 }
72 XmlNode iDNode = resultNode.FirstChild("ID");
73 if(!iDNode.IsNull())
74 {
75 m_iD = Aws::Utils::Xml::DecodeEscapedXmlText(iDNode.GetText());
76 m_iDHasBeenSet = true;
77 }
78 XmlNode prefixNode = resultNode.FirstChild("Prefix");
79 if(!prefixNode.IsNull())
80 {
81 m_prefix = Aws::Utils::Xml::DecodeEscapedXmlText(prefixNode.GetText());
82 m_prefixHasBeenSet = true;
83 }
84 XmlNode statusNode = resultNode.FirstChild("Status");
85 if(!statusNode.IsNull())
86 {
87 m_status = ExpirationStatusMapper::GetExpirationStatusForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(statusNode.GetText()).c_str()).c_str());
88 m_statusHasBeenSet = true;
89 }
90 XmlNode transitionNode = resultNode.FirstChild("Transition");
91 if(!transitionNode.IsNull())
92 {
93 m_transition = transitionNode;
94 m_transitionHasBeenSet = true;
95 }
96 XmlNode noncurrentVersionTransitionNode = resultNode.FirstChild("NoncurrentVersionTransition");
97 if(!noncurrentVersionTransitionNode.IsNull())
98 {
99 m_noncurrentVersionTransition = noncurrentVersionTransitionNode;
100 m_noncurrentVersionTransitionHasBeenSet = true;
101 }
102 XmlNode noncurrentVersionExpirationNode = resultNode.FirstChild("NoncurrentVersionExpiration");
103 if(!noncurrentVersionExpirationNode.IsNull())
104 {
105 m_noncurrentVersionExpiration = noncurrentVersionExpirationNode;
106 m_noncurrentVersionExpirationHasBeenSet = true;
107 }
108 XmlNode abortIncompleteMultipartUploadNode = resultNode.FirstChild("AbortIncompleteMultipartUpload");
109 if(!abortIncompleteMultipartUploadNode.IsNull())
110 {
111 m_abortIncompleteMultipartUpload = abortIncompleteMultipartUploadNode;
112 m_abortIncompleteMultipartUploadHasBeenSet = true;
113 }
114 }
115
116 return *this;
117}
118
119void Rule::AddToNode(XmlNode& parentNode) const
120{
121 Aws::StringStream ss;
122 if(m_expirationHasBeenSet)
123 {
124 XmlNode expirationNode = parentNode.CreateChildElement("Expiration");
125 m_expiration.AddToNode(expirationNode);
126 }
127
128 if(m_iDHasBeenSet)
129 {
130 XmlNode iDNode = parentNode.CreateChildElement("ID");
131 iDNode.SetText(m_iD);
132 }
133
134 if(m_prefixHasBeenSet)
135 {
136 XmlNode prefixNode = parentNode.CreateChildElement("Prefix");
137 prefixNode.SetText(m_prefix);
138 }
139
140 if(m_statusHasBeenSet)
141 {
142 XmlNode statusNode = parentNode.CreateChildElement("Status");
143 statusNode.SetText(ExpirationStatusMapper::GetNameForExpirationStatus(m_status));
144 }
145
146 if(m_transitionHasBeenSet)
147 {
148 XmlNode transitionNode = parentNode.CreateChildElement("Transition");
149 m_transition.AddToNode(transitionNode);
150 }
151
152 if(m_noncurrentVersionTransitionHasBeenSet)
153 {
154 XmlNode noncurrentVersionTransitionNode = parentNode.CreateChildElement("NoncurrentVersionTransition");
155 m_noncurrentVersionTransition.AddToNode(noncurrentVersionTransitionNode);
156 }
157
158 if(m_noncurrentVersionExpirationHasBeenSet)
159 {
160 XmlNode noncurrentVersionExpirationNode = parentNode.CreateChildElement("NoncurrentVersionExpiration");
161 m_noncurrentVersionExpiration.AddToNode(noncurrentVersionExpirationNode);
162 }
163
164 if(m_abortIncompleteMultipartUploadHasBeenSet)
165 {
166 XmlNode abortIncompleteMultipartUploadNode = parentNode.CreateChildElement("AbortIncompleteMultipartUpload");
167 m_abortIncompleteMultipartUpload.AddToNode(abortIncompleteMultipartUploadNode);
168 }
169
170}
171
172} // namespace Model
173} // namespace S3
174} // namespace Aws
175