GetDatabaseResult.cc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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/datalake/model/GetDatabaseResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::DataLake;
  19. using namespace AlibabaCloud::DataLake::Model;
  20. GetDatabaseResult::GetDatabaseResult() :
  21. ServiceResult()
  22. {}
  23. GetDatabaseResult::GetDatabaseResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetDatabaseResult::~GetDatabaseResult()
  29. {}
  30. void GetDatabaseResult::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 databaseNode = value["Database"];
  37. if(!databaseNode["CreateTime"].isNull())
  38. database_.createTime = std::stoi(databaseNode["CreateTime"].asString());
  39. if(!databaseNode["Description"].isNull())
  40. database_.description = databaseNode["Description"].asString();
  41. if(!databaseNode["LocationUri"].isNull())
  42. database_.locationUri = databaseNode["LocationUri"].asString();
  43. if(!databaseNode["Name"].isNull())
  44. database_.name = databaseNode["Name"].asString();
  45. if(!databaseNode["OwnerName"].isNull())
  46. database_.ownerName = databaseNode["OwnerName"].asString();
  47. if(!databaseNode["OwnerType"].isNull())
  48. database_.ownerType = databaseNode["OwnerType"].asString();
  49. if(!databaseNode["Parameters"].isNull())
  50. database_.parameters = databaseNode["Parameters"].asString();
  51. if(!databaseNode["UpdateTime"].isNull())
  52. database_.updateTime = std::stoi(databaseNode["UpdateTime"].asString());
  53. if(!databaseNode["CreatedBy"].isNull())
  54. database_.createdBy = databaseNode["CreatedBy"].asString();
  55. auto privilegesNode = databaseNode["Privileges"];
  56. if(!privilegesNode["GroupPrivileges"].isNull())
  57. database_.privileges.groupPrivileges = privilegesNode["GroupPrivileges"].asString();
  58. if(!privilegesNode["RolePrivileges"].isNull())
  59. database_.privileges.rolePrivileges = privilegesNode["RolePrivileges"].asString();
  60. if(!privilegesNode["UserPrivileges"].isNull())
  61. database_.privileges.userPrivileges = privilegesNode["UserPrivileges"].asString();
  62. if(!value["Code"].isNull())
  63. code_ = value["Code"].asString();
  64. if(!value["Message"].isNull())
  65. message_ = value["Message"].asString();
  66. if(!value["Success"].isNull())
  67. success_ = value["Success"].asString() == "true";
  68. }
  69. std::string GetDatabaseResult::getMessage()const
  70. {
  71. return message_;
  72. }
  73. GetDatabaseResult::Database GetDatabaseResult::getDatabase()const
  74. {
  75. return database_;
  76. }
  77. std::string GetDatabaseResult::getCode()const
  78. {
  79. return code_;
  80. }
  81. bool GetDatabaseResult::getSuccess()const
  82. {
  83. return success_;
  84. }