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/AnalyticsS3BucketDestination.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
33AnalyticsS3BucketDestination::AnalyticsS3BucketDestination() :
34 m_format(AnalyticsS3ExportFileFormat::NOT_SET),
35 m_formatHasBeenSet(false),
36 m_bucketAccountIdHasBeenSet(false),
37 m_bucketHasBeenSet(false),
38 m_prefixHasBeenSet(false)
39{
40}
41
42AnalyticsS3BucketDestination::AnalyticsS3BucketDestination(const XmlNode& xmlNode) :
43 m_format(AnalyticsS3ExportFileFormat::NOT_SET),
44 m_formatHasBeenSet(false),
45 m_bucketAccountIdHasBeenSet(false),
46 m_bucketHasBeenSet(false),
47 m_prefixHasBeenSet(false)
48{
49 *this = xmlNode;
50}
51
52AnalyticsS3BucketDestination& AnalyticsS3BucketDestination::operator =(const XmlNode& xmlNode)
53{
54 XmlNode resultNode = xmlNode;
55
56 if(!resultNode.IsNull())
57 {
58 XmlNode formatNode = resultNode.FirstChild("Format");
59 if(!formatNode.IsNull())
60 {
61 m_format = AnalyticsS3ExportFileFormatMapper::GetAnalyticsS3ExportFileFormatForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(formatNode.GetText()).c_str()).c_str());
62 m_formatHasBeenSet = true;
63 }
64 XmlNode bucketAccountIdNode = resultNode.FirstChild("BucketAccountId");
65 if(!bucketAccountIdNode.IsNull())
66 {
67 m_bucketAccountId = Aws::Utils::Xml::DecodeEscapedXmlText(bucketAccountIdNode.GetText());
68 m_bucketAccountIdHasBeenSet = true;
69 }
70 XmlNode bucketNode = resultNode.FirstChild("Bucket");
71 if(!bucketNode.IsNull())
72 {
73 m_bucket = Aws::Utils::Xml::DecodeEscapedXmlText(bucketNode.GetText());
74 m_bucketHasBeenSet = true;
75 }
76 XmlNode prefixNode = resultNode.FirstChild("Prefix");
77 if(!prefixNode.IsNull())
78 {
79 m_prefix = Aws::Utils::Xml::DecodeEscapedXmlText(prefixNode.GetText());
80 m_prefixHasBeenSet = true;
81 }
82 }
83
84 return *this;
85}
86
87void AnalyticsS3BucketDestination::AddToNode(XmlNode& parentNode) const
88{
89 Aws::StringStream ss;
90 if(m_formatHasBeenSet)
91 {
92 XmlNode formatNode = parentNode.CreateChildElement("Format");
93 formatNode.SetText(AnalyticsS3ExportFileFormatMapper::GetNameForAnalyticsS3ExportFileFormat(m_format));
94 }
95
96 if(m_bucketAccountIdHasBeenSet)
97 {
98 XmlNode bucketAccountIdNode = parentNode.CreateChildElement("BucketAccountId");
99 bucketAccountIdNode.SetText(m_bucketAccountId);
100 }
101
102 if(m_bucketHasBeenSet)
103 {
104 XmlNode bucketNode = parentNode.CreateChildElement("Bucket");
105 bucketNode.SetText(m_bucket);
106 }
107
108 if(m_prefixHasBeenSet)
109 {
110 XmlNode prefixNode = parentNode.CreateChildElement("Prefix");
111 prefixNode.SetText(m_prefix);
112 }
113
114}
115
116} // namespace Model
117} // namespace S3
118} // namespace Aws
119