1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/s3-crt/model/Redirect.h>
7 #include <aws/core/utils/xml/XmlSerializer.h>
8 #include <aws/core/utils/StringUtils.h>
9 #include <aws/core/utils/memory/stl/AWSStringStream.h>
10
11 #include <utility>
12
13 using namespace Aws::Utils::Xml;
14 using namespace Aws::Utils;
15
16 namespace Aws
17 {
18 namespace S3Crt
19 {
20 namespace Model
21 {
22
Redirect()23 Redirect::Redirect() :
24 m_hostNameHasBeenSet(false),
25 m_httpRedirectCodeHasBeenSet(false),
26 m_protocol(Protocol::NOT_SET),
27 m_protocolHasBeenSet(false),
28 m_replaceKeyPrefixWithHasBeenSet(false),
29 m_replaceKeyWithHasBeenSet(false)
30 {
31 }
32
Redirect(const XmlNode & xmlNode)33 Redirect::Redirect(const XmlNode& xmlNode) :
34 m_hostNameHasBeenSet(false),
35 m_httpRedirectCodeHasBeenSet(false),
36 m_protocol(Protocol::NOT_SET),
37 m_protocolHasBeenSet(false),
38 m_replaceKeyPrefixWithHasBeenSet(false),
39 m_replaceKeyWithHasBeenSet(false)
40 {
41 *this = xmlNode;
42 }
43
operator =(const XmlNode & xmlNode)44 Redirect& Redirect::operator =(const XmlNode& xmlNode)
45 {
46 XmlNode resultNode = xmlNode;
47
48 if(!resultNode.IsNull())
49 {
50 XmlNode hostNameNode = resultNode.FirstChild("HostName");
51 if(!hostNameNode.IsNull())
52 {
53 m_hostName = Aws::Utils::Xml::DecodeEscapedXmlText(hostNameNode.GetText());
54 m_hostNameHasBeenSet = true;
55 }
56 XmlNode httpRedirectCodeNode = resultNode.FirstChild("HttpRedirectCode");
57 if(!httpRedirectCodeNode.IsNull())
58 {
59 m_httpRedirectCode = Aws::Utils::Xml::DecodeEscapedXmlText(httpRedirectCodeNode.GetText());
60 m_httpRedirectCodeHasBeenSet = true;
61 }
62 XmlNode protocolNode = resultNode.FirstChild("Protocol");
63 if(!protocolNode.IsNull())
64 {
65 m_protocol = ProtocolMapper::GetProtocolForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(protocolNode.GetText()).c_str()).c_str());
66 m_protocolHasBeenSet = true;
67 }
68 XmlNode replaceKeyPrefixWithNode = resultNode.FirstChild("ReplaceKeyPrefixWith");
69 if(!replaceKeyPrefixWithNode.IsNull())
70 {
71 m_replaceKeyPrefixWith = Aws::Utils::Xml::DecodeEscapedXmlText(replaceKeyPrefixWithNode.GetText());
72 m_replaceKeyPrefixWithHasBeenSet = true;
73 }
74 XmlNode replaceKeyWithNode = resultNode.FirstChild("ReplaceKeyWith");
75 if(!replaceKeyWithNode.IsNull())
76 {
77 m_replaceKeyWith = Aws::Utils::Xml::DecodeEscapedXmlText(replaceKeyWithNode.GetText());
78 m_replaceKeyWithHasBeenSet = true;
79 }
80 }
81
82 return *this;
83 }
84
AddToNode(XmlNode & parentNode) const85 void Redirect::AddToNode(XmlNode& parentNode) const
86 {
87 Aws::StringStream ss;
88 if(m_hostNameHasBeenSet)
89 {
90 XmlNode hostNameNode = parentNode.CreateChildElement("HostName");
91 hostNameNode.SetText(m_hostName);
92 }
93
94 if(m_httpRedirectCodeHasBeenSet)
95 {
96 XmlNode httpRedirectCodeNode = parentNode.CreateChildElement("HttpRedirectCode");
97 httpRedirectCodeNode.SetText(m_httpRedirectCode);
98 }
99
100 if(m_protocolHasBeenSet)
101 {
102 XmlNode protocolNode = parentNode.CreateChildElement("Protocol");
103 protocolNode.SetText(ProtocolMapper::GetNameForProtocol(m_protocol));
104 }
105
106 if(m_replaceKeyPrefixWithHasBeenSet)
107 {
108 XmlNode replaceKeyPrefixWithNode = parentNode.CreateChildElement("ReplaceKeyPrefixWith");
109 replaceKeyPrefixWithNode.SetText(m_replaceKeyPrefixWith);
110 }
111
112 if(m_replaceKeyWithHasBeenSet)
113 {
114 XmlNode replaceKeyWithNode = parentNode.CreateChildElement("ReplaceKeyWith");
115 replaceKeyWithNode.SetText(m_replaceKeyWith);
116 }
117
118 }
119
120 } // namespace Model
121 } // namespace S3Crt
122 } // namespace Aws
123