ListTablesResult.cc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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/dms-enterprise/model/ListTablesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Dms_enterprise;
  19. using namespace AlibabaCloud::Dms_enterprise::Model;
  20. ListTablesResult::ListTablesResult() :
  21. ServiceResult()
  22. {}
  23. ListTablesResult::ListTablesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListTablesResult::~ListTablesResult()
  29. {}
  30. void ListTablesResult::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 allTableListNode = value["TableList"]["Table"];
  37. for (auto valueTableListTable : allTableListNode)
  38. {
  39. Table tableListObject;
  40. if(!valueTableListTable["TableId"].isNull())
  41. tableListObject.tableId = valueTableListTable["TableId"].asString();
  42. if(!valueTableListTable["DatabaseId"].isNull())
  43. tableListObject.databaseId = valueTableListTable["DatabaseId"].asString();
  44. if(!valueTableListTable["TableName"].isNull())
  45. tableListObject.tableName = valueTableListTable["TableName"].asString();
  46. if(!valueTableListTable["TableSchemaName"].isNull())
  47. tableListObject.tableSchemaName = valueTableListTable["TableSchemaName"].asString();
  48. if(!valueTableListTable["Engine"].isNull())
  49. tableListObject.engine = valueTableListTable["Engine"].asString();
  50. if(!valueTableListTable["Encoding"].isNull())
  51. tableListObject.encoding = valueTableListTable["Encoding"].asString();
  52. if(!valueTableListTable["TableType"].isNull())
  53. tableListObject.tableType = valueTableListTable["TableType"].asString();
  54. if(!valueTableListTable["NumRows"].isNull())
  55. tableListObject.numRows = std::stol(valueTableListTable["NumRows"].asString());
  56. if(!valueTableListTable["StoreCapacity"].isNull())
  57. tableListObject.storeCapacity = std::stol(valueTableListTable["StoreCapacity"].asString());
  58. if(!valueTableListTable["TableGuid"].isNull())
  59. tableListObject.tableGuid = valueTableListTable["TableGuid"].asString();
  60. if(!valueTableListTable["Description"].isNull())
  61. tableListObject.description = valueTableListTable["Description"].asString();
  62. auto allOwnerIdList = value["OwnerIdList"]["OwnerIds"];
  63. for (auto value : allOwnerIdList)
  64. tableListObject.ownerIdList.push_back(value.asString());
  65. auto allOwnerNameList = value["OwnerNameList"]["OwnerNames"];
  66. for (auto value : allOwnerNameList)
  67. tableListObject.ownerNameList.push_back(value.asString());
  68. tableList_.push_back(tableListObject);
  69. }
  70. if(!value["Success"].isNull())
  71. success_ = value["Success"].asString() == "true";
  72. if(!value["ErrorMessage"].isNull())
  73. errorMessage_ = value["ErrorMessage"].asString();
  74. if(!value["ErrorCode"].isNull())
  75. errorCode_ = value["ErrorCode"].asString();
  76. if(!value["TotalCount"].isNull())
  77. totalCount_ = std::stol(value["TotalCount"].asString());
  78. }
  79. long ListTablesResult::getTotalCount()const
  80. {
  81. return totalCount_;
  82. }
  83. std::vector<ListTablesResult::Table> ListTablesResult::getTableList()const
  84. {
  85. return tableList_;
  86. }
  87. std::string ListTablesResult::getErrorCode()const
  88. {
  89. return errorCode_;
  90. }
  91. std::string ListTablesResult::getErrorMessage()const
  92. {
  93. return errorMessage_;
  94. }
  95. bool ListTablesResult::getSuccess()const
  96. {
  97. return success_;
  98. }