| 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/NotificationConfiguration.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 | NotificationConfiguration::NotificationConfiguration() : |
| 34 | m_topicConfigurationsHasBeenSet(false), |
| 35 | m_queueConfigurationsHasBeenSet(false), |
| 36 | m_lambdaFunctionConfigurationsHasBeenSet(false) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | NotificationConfiguration::NotificationConfiguration(const XmlNode& xmlNode) : |
| 41 | m_topicConfigurationsHasBeenSet(false), |
| 42 | m_queueConfigurationsHasBeenSet(false), |
| 43 | m_lambdaFunctionConfigurationsHasBeenSet(false) |
| 44 | { |
| 45 | *this = xmlNode; |
| 46 | } |
| 47 | |
| 48 | NotificationConfiguration& NotificationConfiguration::operator =(const XmlNode& xmlNode) |
| 49 | { |
| 50 | XmlNode resultNode = xmlNode; |
| 51 | |
| 52 | if(!resultNode.IsNull()) |
| 53 | { |
| 54 | XmlNode topicConfigurationsNode = resultNode.FirstChild("TopicConfiguration"); |
| 55 | if(!topicConfigurationsNode.IsNull()) |
| 56 | { |
| 57 | XmlNode topicConfigurationMember = topicConfigurationsNode; |
| 58 | while(!topicConfigurationMember.IsNull()) |
| 59 | { |
| 60 | m_topicConfigurations.push_back(topicConfigurationMember); |
| 61 | topicConfigurationMember = topicConfigurationMember.NextNode("TopicConfiguration"); |
| 62 | } |
| 63 | |
| 64 | m_topicConfigurationsHasBeenSet = true; |
| 65 | } |
| 66 | XmlNode queueConfigurationsNode = resultNode.FirstChild("QueueConfiguration"); |
| 67 | if(!queueConfigurationsNode.IsNull()) |
| 68 | { |
| 69 | XmlNode queueConfigurationMember = queueConfigurationsNode; |
| 70 | while(!queueConfigurationMember.IsNull()) |
| 71 | { |
| 72 | m_queueConfigurations.push_back(queueConfigurationMember); |
| 73 | queueConfigurationMember = queueConfigurationMember.NextNode("QueueConfiguration"); |
| 74 | } |
| 75 | |
| 76 | m_queueConfigurationsHasBeenSet = true; |
| 77 | } |
| 78 | XmlNode lambdaFunctionConfigurationsNode = resultNode.FirstChild("CloudFunctionConfiguration"); |
| 79 | if(!lambdaFunctionConfigurationsNode.IsNull()) |
| 80 | { |
| 81 | XmlNode cloudFunctionConfigurationMember = lambdaFunctionConfigurationsNode; |
| 82 | while(!cloudFunctionConfigurationMember.IsNull()) |
| 83 | { |
| 84 | m_lambdaFunctionConfigurations.push_back(cloudFunctionConfigurationMember); |
| 85 | cloudFunctionConfigurationMember = cloudFunctionConfigurationMember.NextNode("CloudFunctionConfiguration"); |
| 86 | } |
| 87 | |
| 88 | m_lambdaFunctionConfigurationsHasBeenSet = true; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return *this; |
| 93 | } |
| 94 | |
| 95 | void NotificationConfiguration::AddToNode(XmlNode& parentNode) const |
| 96 | { |
| 97 | Aws::StringStream ss; |
| 98 | if(m_topicConfigurationsHasBeenSet) |
| 99 | { |
| 100 | for(const auto& item : m_topicConfigurations) |
| 101 | { |
| 102 | XmlNode topicConfigurationsNode = parentNode.CreateChildElement("TopicConfiguration"); |
| 103 | item.AddToNode(topicConfigurationsNode); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | if(m_queueConfigurationsHasBeenSet) |
| 108 | { |
| 109 | for(const auto& item : m_queueConfigurations) |
| 110 | { |
| 111 | XmlNode queueConfigurationsNode = parentNode.CreateChildElement("QueueConfiguration"); |
| 112 | item.AddToNode(queueConfigurationsNode); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | if(m_lambdaFunctionConfigurationsHasBeenSet) |
| 117 | { |
| 118 | for(const auto& item : m_lambdaFunctionConfigurations) |
| 119 | { |
| 120 | XmlNode lambdaFunctionConfigurationsNode = parentNode.CreateChildElement("CloudFunctionConfiguration"); |
| 121 | item.AddToNode(lambdaFunctionConfigurationsNode); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | } |
| 126 | |
| 127 | } // namespace Model |
| 128 | } // namespace S3 |
| 129 | } // namespace Aws |
| 130 |