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/InventoryS3BucketDestination.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
33InventoryS3BucketDestination::InventoryS3BucketDestination() :
34 m_accountIdHasBeenSet(false),
35 m_bucketHasBeenSet(false),
36 m_format(InventoryFormat::NOT_SET),
37 m_formatHasBeenSet(false),
38 m_prefixHasBeenSet(false),
39 m_encryptionHasBeenSet(false)
40{
41}
42
43InventoryS3BucketDestination::InventoryS3BucketDestination(const XmlNode& xmlNode) :
44 m_accountIdHasBeenSet(false),
45 m_bucketHasBeenSet(false),
46 m_format(InventoryFormat::NOT_SET),
47 m_formatHasBeenSet(false),
48 m_prefixHasBeenSet(false),
49 m_encryptionHasBeenSet(false)
50{
51 *this = xmlNode;
52}
53
54InventoryS3BucketDestination& InventoryS3BucketDestination::operator =(const XmlNode& xmlNode)
55{
56 XmlNode resultNode = xmlNode;
57
58 if(!resultNode.IsNull())
59 {
60 XmlNode accountIdNode = resultNode.FirstChild("AccountId");
61 if(!accountIdNode.IsNull())
62 {
63 m_accountId = Aws::Utils::Xml::DecodeEscapedXmlText(accountIdNode.GetText());
64 m_accountIdHasBeenSet = true;
65 }
66 XmlNode bucketNode = resultNode.FirstChild("Bucket");
67 if(!bucketNode.IsNull())
68 {
69 m_bucket = Aws::Utils::Xml::DecodeEscapedXmlText(bucketNode.GetText());
70 m_bucketHasBeenSet = true;
71 }
72 XmlNode formatNode = resultNode.FirstChild("Format");
73 if(!formatNode.IsNull())
74 {
75 m_format = InventoryFormatMapper::GetInventoryFormatForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(formatNode.GetText()).c_str()).c_str());
76 m_formatHasBeenSet = 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 encryptionNode = resultNode.FirstChild("Encryption");
85 if(!encryptionNode.IsNull())
86 {
87 m_encryption = encryptionNode;
88 m_encryptionHasBeenSet = true;
89 }
90 }
91
92 return *this;
93}
94
95void InventoryS3BucketDestination::AddToNode(XmlNode& parentNode) const
96{
97 Aws::StringStream ss;
98 if(m_accountIdHasBeenSet)
99 {
100 XmlNode accountIdNode = parentNode.CreateChildElement("AccountId");
101 accountIdNode.SetText(m_accountId);
102 }
103
104 if(m_bucketHasBeenSet)
105 {
106 XmlNode bucketNode = parentNode.CreateChildElement("Bucket");
107 bucketNode.SetText(m_bucket);
108 }
109
110 if(m_formatHasBeenSet)
111 {
112 XmlNode formatNode = parentNode.CreateChildElement("Format");
113 formatNode.SetText(InventoryFormatMapper::GetNameForInventoryFormat(m_format));
114 }
115
116 if(m_prefixHasBeenSet)
117 {
118 XmlNode prefixNode = parentNode.CreateChildElement("Prefix");
119 prefixNode.SetText(m_prefix);
120 }
121
122 if(m_encryptionHasBeenSet)
123 {
124 XmlNode encryptionNode = parentNode.CreateChildElement("Encryption");
125 m_encryption.AddToNode(encryptionNode);
126 }
127
128}
129
130} // namespace Model
131} // namespace S3
132} // namespace Aws
133