SearchDatabaseResult.cc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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/SearchDatabaseResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Dms_enterprise;
  19. using namespace AlibabaCloud::Dms_enterprise::Model;
  20. SearchDatabaseResult::SearchDatabaseResult() :
  21. ServiceResult()
  22. {}
  23. SearchDatabaseResult::SearchDatabaseResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. SearchDatabaseResult::~SearchDatabaseResult()
  29. {}
  30. void SearchDatabaseResult::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 allSearchDatabaseListNode = value["SearchDatabaseList"]["SearchDatabase"];
  37. for (auto valueSearchDatabaseListSearchDatabase : allSearchDatabaseListNode)
  38. {
  39. SearchDatabase searchDatabaseListObject;
  40. if(!valueSearchDatabaseListSearchDatabase["DatabaseId"].isNull())
  41. searchDatabaseListObject.databaseId = valueSearchDatabaseListSearchDatabase["DatabaseId"].asString();
  42. if(!valueSearchDatabaseListSearchDatabase["Host"].isNull())
  43. searchDatabaseListObject.host = valueSearchDatabaseListSearchDatabase["Host"].asString();
  44. if(!valueSearchDatabaseListSearchDatabase["DbaId"].isNull())
  45. searchDatabaseListObject.dbaId = valueSearchDatabaseListSearchDatabase["DbaId"].asString();
  46. if(!valueSearchDatabaseListSearchDatabase["SchemaName"].isNull())
  47. searchDatabaseListObject.schemaName = valueSearchDatabaseListSearchDatabase["SchemaName"].asString();
  48. if(!valueSearchDatabaseListSearchDatabase["Logic"].isNull())
  49. searchDatabaseListObject.logic = valueSearchDatabaseListSearchDatabase["Logic"].asString() == "true";
  50. if(!valueSearchDatabaseListSearchDatabase["DatalinkName"].isNull())
  51. searchDatabaseListObject.datalinkName = valueSearchDatabaseListSearchDatabase["DatalinkName"].asString();
  52. if(!valueSearchDatabaseListSearchDatabase["Port"].isNull())
  53. searchDatabaseListObject.port = std::stoi(valueSearchDatabaseListSearchDatabase["Port"].asString());
  54. if(!valueSearchDatabaseListSearchDatabase["EnvType"].isNull())
  55. searchDatabaseListObject.envType = valueSearchDatabaseListSearchDatabase["EnvType"].asString();
  56. if(!valueSearchDatabaseListSearchDatabase["Sid"].isNull())
  57. searchDatabaseListObject.sid = valueSearchDatabaseListSearchDatabase["Sid"].asString();
  58. if(!valueSearchDatabaseListSearchDatabase["Encoding"].isNull())
  59. searchDatabaseListObject.encoding = valueSearchDatabaseListSearchDatabase["Encoding"].asString();
  60. if(!valueSearchDatabaseListSearchDatabase["DbType"].isNull())
  61. searchDatabaseListObject.dbType = valueSearchDatabaseListSearchDatabase["DbType"].asString();
  62. if(!valueSearchDatabaseListSearchDatabase["SearchName"].isNull())
  63. searchDatabaseListObject.searchName = valueSearchDatabaseListSearchDatabase["SearchName"].asString();
  64. if(!valueSearchDatabaseListSearchDatabase["Alias"].isNull())
  65. searchDatabaseListObject.alias = valueSearchDatabaseListSearchDatabase["Alias"].asString();
  66. auto allOwnerIdList = value["OwnerIdList"]["OwnerIds"];
  67. for (auto value : allOwnerIdList)
  68. searchDatabaseListObject.ownerIdList.push_back(value.asString());
  69. auto allOwnerNameList = value["OwnerNameList"]["OwnerNames"];
  70. for (auto value : allOwnerNameList)
  71. searchDatabaseListObject.ownerNameList.push_back(value.asString());
  72. searchDatabaseList_.push_back(searchDatabaseListObject);
  73. }
  74. if(!value["TotalCount"].isNull())
  75. totalCount_ = std::stol(value["TotalCount"].asString());
  76. if(!value["ErrorCode"].isNull())
  77. errorCode_ = value["ErrorCode"].asString();
  78. if(!value["ErrorMessage"].isNull())
  79. errorMessage_ = value["ErrorMessage"].asString();
  80. if(!value["Success"].isNull())
  81. success_ = value["Success"].asString() == "true";
  82. }
  83. long SearchDatabaseResult::getTotalCount()const
  84. {
  85. return totalCount_;
  86. }
  87. std::vector<SearchDatabaseResult::SearchDatabase> SearchDatabaseResult::getSearchDatabaseList()const
  88. {
  89. return searchDatabaseList_;
  90. }
  91. std::string SearchDatabaseResult::getErrorCode()const
  92. {
  93. return errorCode_;
  94. }
  95. std::string SearchDatabaseResult::getErrorMessage()const
  96. {
  97. return errorMessage_;
  98. }
  99. bool SearchDatabaseResult::getSuccess()const
  100. {
  101. return success_;
  102. }