MetastoreDescribeDatabaseResult.cc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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/emr/model/MetastoreDescribeDatabaseResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Emr;
  19. using namespace AlibabaCloud::Emr::Model;
  20. MetastoreDescribeDatabaseResult::MetastoreDescribeDatabaseResult() :
  21. ServiceResult()
  22. {}
  23. MetastoreDescribeDatabaseResult::MetastoreDescribeDatabaseResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. MetastoreDescribeDatabaseResult::~MetastoreDescribeDatabaseResult()
  29. {}
  30. void MetastoreDescribeDatabaseResult::parse(const std::string &payload)
  31. {
  32. Json::CharReaderBuilder builder;
  33. Json::CharReader *reader = builder.newCharReader();
  34. Json::Value *val;
  35. Json::Value value;
  36. JSONCPP_STRING *errs;
  37. reader->parse(payload.data(), payload.data() + payload.size(), val, errs);
  38. value = *val;
  39. setRequestId(value["RequestId"].asString());
  40. auto allParameters = value["Parameters"]["Parameter"];
  41. for (auto value : allParameters)
  42. {
  43. Parameter parametersObject;
  44. if(!value["Key"].isNull())
  45. parametersObject.key = value["Key"].asString();
  46. if(!value["Value"].isNull())
  47. parametersObject.value = value["Value"].asString();
  48. parameters_.push_back(parametersObject);
  49. }
  50. auto databaseNode = value["Database"];
  51. if(!databaseNode["Id"].isNull())
  52. database_.id = databaseNode["Id"].asString();
  53. if(!databaseNode["ClusterBizId"].isNull())
  54. database_.clusterBizId = databaseNode["ClusterBizId"].asString();
  55. if(!databaseNode["ClusterName"].isNull())
  56. database_.clusterName = databaseNode["ClusterName"].asString();
  57. if(!databaseNode["DatabaseName"].isNull())
  58. database_.databaseName = databaseNode["DatabaseName"].asString();
  59. if(!databaseNode["DatabaseType"].isNull())
  60. database_.databaseType = databaseNode["DatabaseType"].asString();
  61. if(!databaseNode["Owner"].isNull())
  62. database_.owner = databaseNode["Owner"].asString();
  63. if(!databaseNode["OwnerType"].isNull())
  64. database_.ownerType = databaseNode["OwnerType"].asString();
  65. if(!databaseNode["Location"].isNull())
  66. database_.location = databaseNode["Location"].asString();
  67. if(!databaseNode["Status"].isNull())
  68. database_.status = databaseNode["Status"].asString();
  69. if(!databaseNode["DatabaseParameters"].isNull())
  70. database_.databaseParameters = databaseNode["DatabaseParameters"].asString();
  71. if(!databaseNode["GmtCreate"].isNull())
  72. database_.gmtCreate = std::stol(databaseNode["GmtCreate"].asString());
  73. if(!databaseNode["GmtModified"].isNull())
  74. database_.gmtModified = std::stol(databaseNode["GmtModified"].asString());
  75. if(!databaseNode["DataSourceId"].isNull())
  76. database_.dataSourceId = databaseNode["DataSourceId"].asString();
  77. if(!databaseNode["DataSourceType"].isNull())
  78. database_.dataSourceType = databaseNode["DataSourceType"].asString();
  79. if(!databaseNode["LocationType"].isNull())
  80. database_.locationType = databaseNode["LocationType"].asString();
  81. if(!databaseNode["DatabaseComment"].isNull())
  82. database_.databaseComment = databaseNode["DatabaseComment"].asString();
  83. if(!databaseNode["ProjectId"].isNull())
  84. database_.projectId = databaseNode["ProjectId"].asString();
  85. if(!databaseNode["ProjectName"].isNull())
  86. database_.projectName = databaseNode["ProjectName"].asString();
  87. if(!value["DbName"].isNull())
  88. dbName_ = value["DbName"].asString();
  89. if(!value["Description"].isNull())
  90. description_ = value["Description"].asString();
  91. if(!value["LocationUri"].isNull())
  92. locationUri_ = value["LocationUri"].asString();
  93. }
  94. std::string MetastoreDescribeDatabaseResult::getLocationUri()const
  95. {
  96. return locationUri_;
  97. }
  98. std::vector<MetastoreDescribeDatabaseResult::Parameter> MetastoreDescribeDatabaseResult::getParameters()const
  99. {
  100. return parameters_;
  101. }
  102. std::string MetastoreDescribeDatabaseResult::getDescription()const
  103. {
  104. return description_;
  105. }
  106. MetastoreDescribeDatabaseResult::Database MetastoreDescribeDatabaseResult::getDatabase()const
  107. {
  108. return database_;
  109. }
  110. std::string MetastoreDescribeDatabaseResult::getDbName()const
  111. {
  112. return dbName_;
  113. }