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/PublicAccessBlockConfiguration.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 | PublicAccessBlockConfiguration::PublicAccessBlockConfiguration() : |
34 | m_blockPublicAcls(false), |
35 | m_blockPublicAclsHasBeenSet(false), |
36 | m_ignorePublicAcls(false), |
37 | m_ignorePublicAclsHasBeenSet(false), |
38 | m_blockPublicPolicy(false), |
39 | m_blockPublicPolicyHasBeenSet(false), |
40 | m_restrictPublicBuckets(false), |
41 | m_restrictPublicBucketsHasBeenSet(false) |
42 | { |
43 | } |
44 | |
45 | PublicAccessBlockConfiguration::PublicAccessBlockConfiguration(const XmlNode& xmlNode) : |
46 | m_blockPublicAcls(false), |
47 | m_blockPublicAclsHasBeenSet(false), |
48 | m_ignorePublicAcls(false), |
49 | m_ignorePublicAclsHasBeenSet(false), |
50 | m_blockPublicPolicy(false), |
51 | m_blockPublicPolicyHasBeenSet(false), |
52 | m_restrictPublicBuckets(false), |
53 | m_restrictPublicBucketsHasBeenSet(false) |
54 | { |
55 | *this = xmlNode; |
56 | } |
57 | |
58 | PublicAccessBlockConfiguration& PublicAccessBlockConfiguration::operator =(const XmlNode& xmlNode) |
59 | { |
60 | XmlNode resultNode = xmlNode; |
61 | |
62 | if(!resultNode.IsNull()) |
63 | { |
64 | XmlNode blockPublicAclsNode = resultNode.FirstChild("BlockPublicAcls" ); |
65 | if(!blockPublicAclsNode.IsNull()) |
66 | { |
67 | m_blockPublicAcls = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(blockPublicAclsNode.GetText()).c_str()).c_str()); |
68 | m_blockPublicAclsHasBeenSet = true; |
69 | } |
70 | XmlNode ignorePublicAclsNode = resultNode.FirstChild("IgnorePublicAcls" ); |
71 | if(!ignorePublicAclsNode.IsNull()) |
72 | { |
73 | m_ignorePublicAcls = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(ignorePublicAclsNode.GetText()).c_str()).c_str()); |
74 | m_ignorePublicAclsHasBeenSet = true; |
75 | } |
76 | XmlNode blockPublicPolicyNode = resultNode.FirstChild("BlockPublicPolicy" ); |
77 | if(!blockPublicPolicyNode.IsNull()) |
78 | { |
79 | m_blockPublicPolicy = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(blockPublicPolicyNode.GetText()).c_str()).c_str()); |
80 | m_blockPublicPolicyHasBeenSet = true; |
81 | } |
82 | XmlNode restrictPublicBucketsNode = resultNode.FirstChild("RestrictPublicBuckets" ); |
83 | if(!restrictPublicBucketsNode.IsNull()) |
84 | { |
85 | m_restrictPublicBuckets = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(restrictPublicBucketsNode.GetText()).c_str()).c_str()); |
86 | m_restrictPublicBucketsHasBeenSet = true; |
87 | } |
88 | } |
89 | |
90 | return *this; |
91 | } |
92 | |
93 | void PublicAccessBlockConfiguration::AddToNode(XmlNode& parentNode) const |
94 | { |
95 | Aws::StringStream ss; |
96 | if(m_blockPublicAclsHasBeenSet) |
97 | { |
98 | XmlNode blockPublicAclsNode = parentNode.CreateChildElement("BlockPublicAcls" ); |
99 | ss << std::boolalpha << m_blockPublicAcls; |
100 | blockPublicAclsNode.SetText(ss.str()); |
101 | ss.str("" ); |
102 | } |
103 | |
104 | if(m_ignorePublicAclsHasBeenSet) |
105 | { |
106 | XmlNode ignorePublicAclsNode = parentNode.CreateChildElement("IgnorePublicAcls" ); |
107 | ss << std::boolalpha << m_ignorePublicAcls; |
108 | ignorePublicAclsNode.SetText(ss.str()); |
109 | ss.str("" ); |
110 | } |
111 | |
112 | if(m_blockPublicPolicyHasBeenSet) |
113 | { |
114 | XmlNode blockPublicPolicyNode = parentNode.CreateChildElement("BlockPublicPolicy" ); |
115 | ss << std::boolalpha << m_blockPublicPolicy; |
116 | blockPublicPolicyNode.SetText(ss.str()); |
117 | ss.str("" ); |
118 | } |
119 | |
120 | if(m_restrictPublicBucketsHasBeenSet) |
121 | { |
122 | XmlNode restrictPublicBucketsNode = parentNode.CreateChildElement("RestrictPublicBuckets" ); |
123 | ss << std::boolalpha << m_restrictPublicBuckets; |
124 | restrictPublicBucketsNode.SetText(ss.str()); |
125 | ss.str("" ); |
126 | } |
127 | |
128 | } |
129 | |
130 | } // namespace Model |
131 | } // namespace S3 |
132 | } // namespace Aws |
133 | |