InventoryS3BucketDestination.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /**
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. * SPDX-License-Identifier: Apache-2.0.
  4. */
  5. #include <aws/s3/model/InventoryS3BucketDestination.h>
  6. #include <aws/core/utils/xml/XmlSerializer.h>
  7. #include <aws/core/utils/StringUtils.h>
  8. #include <aws/core/utils/memory/stl/AWSStringStream.h>
  9. #include <utility>
  10. using namespace Aws::Utils::Xml;
  11. using namespace Aws::Utils;
  12. namespace Aws
  13. {
  14. namespace S3
  15. {
  16. namespace Model
  17. {
  18. InventoryS3BucketDestination::InventoryS3BucketDestination() :
  19. m_accountIdHasBeenSet(false),
  20. m_bucketHasBeenSet(false),
  21. m_format(InventoryFormat::NOT_SET),
  22. m_formatHasBeenSet(false),
  23. m_prefixHasBeenSet(false),
  24. m_encryptionHasBeenSet(false)
  25. {
  26. }
  27. InventoryS3BucketDestination::InventoryS3BucketDestination(const XmlNode& xmlNode) :
  28. m_accountIdHasBeenSet(false),
  29. m_bucketHasBeenSet(false),
  30. m_format(InventoryFormat::NOT_SET),
  31. m_formatHasBeenSet(false),
  32. m_prefixHasBeenSet(false),
  33. m_encryptionHasBeenSet(false)
  34. {
  35. *this = xmlNode;
  36. }
  37. InventoryS3BucketDestination& InventoryS3BucketDestination::operator =(const XmlNode& xmlNode)
  38. {
  39. XmlNode resultNode = xmlNode;
  40. if(!resultNode.IsNull())
  41. {
  42. XmlNode accountIdNode = resultNode.FirstChild("AccountId");
  43. if(!accountIdNode.IsNull())
  44. {
  45. m_accountId = Aws::Utils::Xml::DecodeEscapedXmlText(accountIdNode.GetText());
  46. m_accountIdHasBeenSet = true;
  47. }
  48. XmlNode bucketNode = resultNode.FirstChild("Bucket");
  49. if(!bucketNode.IsNull())
  50. {
  51. m_bucket = Aws::Utils::Xml::DecodeEscapedXmlText(bucketNode.GetText());
  52. m_bucketHasBeenSet = true;
  53. }
  54. XmlNode formatNode = resultNode.FirstChild("Format");
  55. if(!formatNode.IsNull())
  56. {
  57. m_format = InventoryFormatMapper::GetInventoryFormatForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(formatNode.GetText()).c_str()).c_str());
  58. m_formatHasBeenSet = true;
  59. }
  60. XmlNode prefixNode = resultNode.FirstChild("Prefix");
  61. if(!prefixNode.IsNull())
  62. {
  63. m_prefix = Aws::Utils::Xml::DecodeEscapedXmlText(prefixNode.GetText());
  64. m_prefixHasBeenSet = true;
  65. }
  66. XmlNode encryptionNode = resultNode.FirstChild("Encryption");
  67. if(!encryptionNode.IsNull())
  68. {
  69. m_encryption = encryptionNode;
  70. m_encryptionHasBeenSet = true;
  71. }
  72. }
  73. return *this;
  74. }
  75. void InventoryS3BucketDestination::AddToNode(XmlNode& parentNode) const
  76. {
  77. Aws::StringStream ss;
  78. if(m_accountIdHasBeenSet)
  79. {
  80. XmlNode accountIdNode = parentNode.CreateChildElement("AccountId");
  81. accountIdNode.SetText(m_accountId);
  82. }
  83. if(m_bucketHasBeenSet)
  84. {
  85. XmlNode bucketNode = parentNode.CreateChildElement("Bucket");
  86. bucketNode.SetText(m_bucket);
  87. }
  88. if(m_formatHasBeenSet)
  89. {
  90. XmlNode formatNode = parentNode.CreateChildElement("Format");
  91. formatNode.SetText(InventoryFormatMapper::GetNameForInventoryFormat(m_format));
  92. }
  93. if(m_prefixHasBeenSet)
  94. {
  95. XmlNode prefixNode = parentNode.CreateChildElement("Prefix");
  96. prefixNode.SetText(m_prefix);
  97. }
  98. if(m_encryptionHasBeenSet)
  99. {
  100. XmlNode encryptionNode = parentNode.CreateChildElement("Encryption");
  101. m_encryption.AddToNode(encryptionNode);
  102. }
  103. }
  104. } // namespace Model
  105. } // namespace S3
  106. } // namespace Aws