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/Destination.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 | |
23 | using namespace Aws::Utils::Xml; |
24 | using namespace Aws::Utils; |
25 | |
26 | namespace Aws |
27 | { |
28 | namespace S3 |
29 | { |
30 | namespace Model |
31 | { |
32 | |
33 | Destination::Destination() : |
34 | m_bucketHasBeenSet(false), |
35 | m_accountHasBeenSet(false), |
36 | m_storageClass(StorageClass::NOT_SET), |
37 | m_storageClassHasBeenSet(false), |
38 | m_accessControlTranslationHasBeenSet(false), |
39 | m_encryptionConfigurationHasBeenSet(false), |
40 | m_replicationTimeHasBeenSet(false), |
41 | m_metricsHasBeenSet(false) |
42 | { |
43 | } |
44 | |
45 | Destination::Destination(const XmlNode& xmlNode) : |
46 | m_bucketHasBeenSet(false), |
47 | m_accountHasBeenSet(false), |
48 | m_storageClass(StorageClass::NOT_SET), |
49 | m_storageClassHasBeenSet(false), |
50 | m_accessControlTranslationHasBeenSet(false), |
51 | m_encryptionConfigurationHasBeenSet(false), |
52 | m_replicationTimeHasBeenSet(false), |
53 | m_metricsHasBeenSet(false) |
54 | { |
55 | *this = xmlNode; |
56 | } |
57 | |
58 | Destination& Destination::operator =(const XmlNode& xmlNode) |
59 | { |
60 | XmlNode resultNode = xmlNode; |
61 | |
62 | if(!resultNode.IsNull()) |
63 | { |
64 | XmlNode bucketNode = resultNode.FirstChild("Bucket" ); |
65 | if(!bucketNode.IsNull()) |
66 | { |
67 | m_bucket = Aws::Utils::Xml::DecodeEscapedXmlText(bucketNode.GetText()); |
68 | m_bucketHasBeenSet = true; |
69 | } |
70 | XmlNode accountNode = resultNode.FirstChild("Account" ); |
71 | if(!accountNode.IsNull()) |
72 | { |
73 | m_account = Aws::Utils::Xml::DecodeEscapedXmlText(accountNode.GetText()); |
74 | m_accountHasBeenSet = true; |
75 | } |
76 | XmlNode storageClassNode = resultNode.FirstChild("StorageClass" ); |
77 | if(!storageClassNode.IsNull()) |
78 | { |
79 | m_storageClass = StorageClassMapper::GetStorageClassForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(storageClassNode.GetText()).c_str()).c_str()); |
80 | m_storageClassHasBeenSet = true; |
81 | } |
82 | XmlNode accessControlTranslationNode = resultNode.FirstChild("AccessControlTranslation" ); |
83 | if(!accessControlTranslationNode.IsNull()) |
84 | { |
85 | m_accessControlTranslation = accessControlTranslationNode; |
86 | m_accessControlTranslationHasBeenSet = true; |
87 | } |
88 | XmlNode encryptionConfigurationNode = resultNode.FirstChild("EncryptionConfiguration" ); |
89 | if(!encryptionConfigurationNode.IsNull()) |
90 | { |
91 | m_encryptionConfiguration = encryptionConfigurationNode; |
92 | m_encryptionConfigurationHasBeenSet = true; |
93 | } |
94 | XmlNode replicationTimeNode = resultNode.FirstChild("ReplicationTime" ); |
95 | if(!replicationTimeNode.IsNull()) |
96 | { |
97 | m_replicationTime = replicationTimeNode; |
98 | m_replicationTimeHasBeenSet = true; |
99 | } |
100 | XmlNode metricsNode = resultNode.FirstChild("Metrics" ); |
101 | if(!metricsNode.IsNull()) |
102 | { |
103 | m_metrics = metricsNode; |
104 | m_metricsHasBeenSet = true; |
105 | } |
106 | } |
107 | |
108 | return *this; |
109 | } |
110 | |
111 | void Destination::AddToNode(XmlNode& parentNode) const |
112 | { |
113 | Aws::StringStream ss; |
114 | if(m_bucketHasBeenSet) |
115 | { |
116 | XmlNode bucketNode = parentNode.CreateChildElement("Bucket" ); |
117 | bucketNode.SetText(m_bucket); |
118 | } |
119 | |
120 | if(m_accountHasBeenSet) |
121 | { |
122 | XmlNode accountNode = parentNode.CreateChildElement("Account" ); |
123 | accountNode.SetText(m_account); |
124 | } |
125 | |
126 | if(m_storageClassHasBeenSet) |
127 | { |
128 | XmlNode storageClassNode = parentNode.CreateChildElement("StorageClass" ); |
129 | storageClassNode.SetText(StorageClassMapper::GetNameForStorageClass(m_storageClass)); |
130 | } |
131 | |
132 | if(m_accessControlTranslationHasBeenSet) |
133 | { |
134 | XmlNode accessControlTranslationNode = parentNode.CreateChildElement("AccessControlTranslation" ); |
135 | m_accessControlTranslation.AddToNode(accessControlTranslationNode); |
136 | } |
137 | |
138 | if(m_encryptionConfigurationHasBeenSet) |
139 | { |
140 | XmlNode encryptionConfigurationNode = parentNode.CreateChildElement("EncryptionConfiguration" ); |
141 | m_encryptionConfiguration.AddToNode(encryptionConfigurationNode); |
142 | } |
143 | |
144 | if(m_replicationTimeHasBeenSet) |
145 | { |
146 | XmlNode replicationTimeNode = parentNode.CreateChildElement("ReplicationTime" ); |
147 | m_replicationTime.AddToNode(replicationTimeNode); |
148 | } |
149 | |
150 | if(m_metricsHasBeenSet) |
151 | { |
152 | XmlNode metricsNode = parentNode.CreateChildElement("Metrics" ); |
153 | m_metrics.AddToNode(metricsNode); |
154 | } |
155 | |
156 | } |
157 | |
158 | } // namespace Model |
159 | } // namespace S3 |
160 | } // namespace Aws |
161 | |