| 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/RestoreRequest.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 | RestoreRequest::RestoreRequest() : |
| 34 | m_days(0), |
| 35 | m_daysHasBeenSet(false), |
| 36 | m_glacierJobParametersHasBeenSet(false), |
| 37 | m_type(RestoreRequestType::NOT_SET), |
| 38 | m_typeHasBeenSet(false), |
| 39 | m_tier(Tier::NOT_SET), |
| 40 | m_tierHasBeenSet(false), |
| 41 | m_descriptionHasBeenSet(false), |
| 42 | m_selectParametersHasBeenSet(false), |
| 43 | m_outputLocationHasBeenSet(false) |
| 44 | { |
| 45 | } |
| 46 | |
| 47 | RestoreRequest::RestoreRequest(const XmlNode& xmlNode) : |
| 48 | m_days(0), |
| 49 | m_daysHasBeenSet(false), |
| 50 | m_glacierJobParametersHasBeenSet(false), |
| 51 | m_type(RestoreRequestType::NOT_SET), |
| 52 | m_typeHasBeenSet(false), |
| 53 | m_tier(Tier::NOT_SET), |
| 54 | m_tierHasBeenSet(false), |
| 55 | m_descriptionHasBeenSet(false), |
| 56 | m_selectParametersHasBeenSet(false), |
| 57 | m_outputLocationHasBeenSet(false) |
| 58 | { |
| 59 | *this = xmlNode; |
| 60 | } |
| 61 | |
| 62 | RestoreRequest& RestoreRequest::operator =(const XmlNode& xmlNode) |
| 63 | { |
| 64 | XmlNode resultNode = xmlNode; |
| 65 | |
| 66 | if(!resultNode.IsNull()) |
| 67 | { |
| 68 | XmlNode daysNode = resultNode.FirstChild("Days" ); |
| 69 | if(!daysNode.IsNull()) |
| 70 | { |
| 71 | m_days = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(daysNode.GetText()).c_str()).c_str()); |
| 72 | m_daysHasBeenSet = true; |
| 73 | } |
| 74 | XmlNode glacierJobParametersNode = resultNode.FirstChild("GlacierJobParameters" ); |
| 75 | if(!glacierJobParametersNode.IsNull()) |
| 76 | { |
| 77 | m_glacierJobParameters = glacierJobParametersNode; |
| 78 | m_glacierJobParametersHasBeenSet = true; |
| 79 | } |
| 80 | XmlNode typeNode = resultNode.FirstChild("Type" ); |
| 81 | if(!typeNode.IsNull()) |
| 82 | { |
| 83 | m_type = RestoreRequestTypeMapper::GetRestoreRequestTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(typeNode.GetText()).c_str()).c_str()); |
| 84 | m_typeHasBeenSet = true; |
| 85 | } |
| 86 | XmlNode tierNode = resultNode.FirstChild("Tier" ); |
| 87 | if(!tierNode.IsNull()) |
| 88 | { |
| 89 | m_tier = TierMapper::GetTierForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(tierNode.GetText()).c_str()).c_str()); |
| 90 | m_tierHasBeenSet = true; |
| 91 | } |
| 92 | XmlNode descriptionNode = resultNode.FirstChild("Description" ); |
| 93 | if(!descriptionNode.IsNull()) |
| 94 | { |
| 95 | m_description = Aws::Utils::Xml::DecodeEscapedXmlText(descriptionNode.GetText()); |
| 96 | m_descriptionHasBeenSet = true; |
| 97 | } |
| 98 | XmlNode selectParametersNode = resultNode.FirstChild("SelectParameters" ); |
| 99 | if(!selectParametersNode.IsNull()) |
| 100 | { |
| 101 | m_selectParameters = selectParametersNode; |
| 102 | m_selectParametersHasBeenSet = true; |
| 103 | } |
| 104 | XmlNode outputLocationNode = resultNode.FirstChild("OutputLocation" ); |
| 105 | if(!outputLocationNode.IsNull()) |
| 106 | { |
| 107 | m_outputLocation = outputLocationNode; |
| 108 | m_outputLocationHasBeenSet = true; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | return *this; |
| 113 | } |
| 114 | |
| 115 | void RestoreRequest::AddToNode(XmlNode& parentNode) const |
| 116 | { |
| 117 | Aws::StringStream ss; |
| 118 | if(m_daysHasBeenSet) |
| 119 | { |
| 120 | XmlNode daysNode = parentNode.CreateChildElement("Days" ); |
| 121 | ss << m_days; |
| 122 | daysNode.SetText(ss.str()); |
| 123 | ss.str("" ); |
| 124 | } |
| 125 | |
| 126 | if(m_glacierJobParametersHasBeenSet) |
| 127 | { |
| 128 | XmlNode glacierJobParametersNode = parentNode.CreateChildElement("GlacierJobParameters" ); |
| 129 | m_glacierJobParameters.AddToNode(glacierJobParametersNode); |
| 130 | } |
| 131 | |
| 132 | if(m_typeHasBeenSet) |
| 133 | { |
| 134 | XmlNode typeNode = parentNode.CreateChildElement("Type" ); |
| 135 | typeNode.SetText(RestoreRequestTypeMapper::GetNameForRestoreRequestType(m_type)); |
| 136 | } |
| 137 | |
| 138 | if(m_tierHasBeenSet) |
| 139 | { |
| 140 | XmlNode tierNode = parentNode.CreateChildElement("Tier" ); |
| 141 | tierNode.SetText(TierMapper::GetNameForTier(m_tier)); |
| 142 | } |
| 143 | |
| 144 | if(m_descriptionHasBeenSet) |
| 145 | { |
| 146 | XmlNode descriptionNode = parentNode.CreateChildElement("Description" ); |
| 147 | descriptionNode.SetText(m_description); |
| 148 | } |
| 149 | |
| 150 | if(m_selectParametersHasBeenSet) |
| 151 | { |
| 152 | XmlNode selectParametersNode = parentNode.CreateChildElement("SelectParameters" ); |
| 153 | m_selectParameters.AddToNode(selectParametersNode); |
| 154 | } |
| 155 | |
| 156 | if(m_outputLocationHasBeenSet) |
| 157 | { |
| 158 | XmlNode outputLocationNode = parentNode.CreateChildElement("OutputLocation" ); |
| 159 | m_outputLocation.AddToNode(outputLocationNode); |
| 160 | } |
| 161 | |
| 162 | } |
| 163 | |
| 164 | } // namespace Model |
| 165 | } // namespace S3 |
| 166 | } // namespace Aws |
| 167 | |