GetTableResult.cc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud 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. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <alibabacloud/openanalytics-open/model/GetTableResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Openanalytics_open;
  19. using namespace AlibabaCloud::Openanalytics_open::Model;
  20. GetTableResult::GetTableResult() :
  21. ServiceResult()
  22. {}
  23. GetTableResult::GetTableResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetTableResult::~GetTableResult()
  29. {}
  30. void GetTableResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto tableNode = value["Table"];
  37. if(!tableNode["TableName"].isNull())
  38. table_.tableName = tableNode["TableName"].asString();
  39. if(!tableNode["ViewOriginalText"].isNull())
  40. table_.viewOriginalText = tableNode["ViewOriginalText"].asString();
  41. if(!tableNode["Owner"].isNull())
  42. table_.owner = tableNode["Owner"].asString();
  43. if(!tableNode["TableType"].isNull())
  44. table_.tableType = tableNode["TableType"].asString();
  45. if(!tableNode["Parameters"].isNull())
  46. table_.parameters = tableNode["Parameters"].asString();
  47. if(!tableNode["ViewExpandedText"].isNull())
  48. table_.viewExpandedText = tableNode["ViewExpandedText"].asString();
  49. if(!tableNode["CreateTime"].isNull())
  50. table_.createTime = std::stol(tableNode["CreateTime"].asString());
  51. if(!tableNode["DbName"].isNull())
  52. table_.dbName = tableNode["DbName"].asString();
  53. if(!tableNode["LastAccessTime"].isNull())
  54. table_.lastAccessTime = std::stol(tableNode["LastAccessTime"].asString());
  55. auto allPartitionKeysNode = tableNode["PartitionKeys"]["PartitionKeysItem"];
  56. for (auto tableNodePartitionKeysPartitionKeysItem : allPartitionKeysNode)
  57. {
  58. Table::PartitionKeysItem partitionKeysItemObject;
  59. if(!tableNodePartitionKeysPartitionKeysItem["Comment"].isNull())
  60. partitionKeysItemObject.comment = tableNodePartitionKeysPartitionKeysItem["Comment"].asString();
  61. if(!tableNodePartitionKeysPartitionKeysItem["Type"].isNull())
  62. partitionKeysItemObject.type = tableNodePartitionKeysPartitionKeysItem["Type"].asString();
  63. if(!tableNodePartitionKeysPartitionKeysItem["Name"].isNull())
  64. partitionKeysItemObject.name = tableNodePartitionKeysPartitionKeysItem["Name"].asString();
  65. table_.partitionKeys.push_back(partitionKeysItemObject);
  66. }
  67. auto storageDescriptorNode = tableNode["StorageDescriptor"];
  68. if(!storageDescriptorNode["Parameters"].isNull())
  69. table_.storageDescriptor.parameters = storageDescriptorNode["Parameters"].asString();
  70. if(!storageDescriptorNode["InputFormat"].isNull())
  71. table_.storageDescriptor.inputFormat = storageDescriptorNode["InputFormat"].asString();
  72. if(!storageDescriptorNode["OutputFormat"].isNull())
  73. table_.storageDescriptor.outputFormat = storageDescriptorNode["OutputFormat"].asString();
  74. if(!storageDescriptorNode["Location"].isNull())
  75. table_.storageDescriptor.location = storageDescriptorNode["Location"].asString();
  76. auto allColsNode = storageDescriptorNode["Cols"]["ColsItem"];
  77. for (auto storageDescriptorNodeColsColsItem : allColsNode)
  78. {
  79. Table::StorageDescriptor::ColsItem colsItemObject;
  80. if(!storageDescriptorNodeColsColsItem["Comment"].isNull())
  81. colsItemObject.comment = storageDescriptorNodeColsColsItem["Comment"].asString();
  82. if(!storageDescriptorNodeColsColsItem["Type"].isNull())
  83. colsItemObject.type = storageDescriptorNodeColsColsItem["Type"].asString();
  84. if(!storageDescriptorNodeColsColsItem["Name"].isNull())
  85. colsItemObject.name = storageDescriptorNodeColsColsItem["Name"].asString();
  86. table_.storageDescriptor.cols.push_back(colsItemObject);
  87. }
  88. auto serDeInfoNode = storageDescriptorNode["SerDeInfo"];
  89. if(!serDeInfoNode["SerializationLib"].isNull())
  90. table_.storageDescriptor.serDeInfo.serializationLib = serDeInfoNode["SerializationLib"].asString();
  91. if(!serDeInfoNode["Parameters"].isNull())
  92. table_.storageDescriptor.serDeInfo.parameters = serDeInfoNode["Parameters"].asString();
  93. if(!serDeInfoNode["Name"].isNull())
  94. table_.storageDescriptor.serDeInfo.name = serDeInfoNode["Name"].asString();
  95. if(!value["Message"].isNull())
  96. message_ = value["Message"].asString();
  97. if(!value["Code"].isNull())
  98. code_ = value["Code"].asString();
  99. if(!value["Success"].isNull())
  100. success_ = value["Success"].asString() == "true";
  101. }
  102. GetTableResult::Table GetTableResult::getTable()const
  103. {
  104. return table_;
  105. }
  106. std::string GetTableResult::getMessage()const
  107. {
  108. return message_;
  109. }
  110. std::string GetTableResult::getCode()const
  111. {
  112. return code_;
  113. }
  114. bool GetTableResult::getSuccess()const
  115. {
  116. return success_;
  117. }