GetRepositoryInfoResult.cc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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/codeup/model/GetRepositoryInfoResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Codeup;
  19. using namespace AlibabaCloud::Codeup::Model;
  20. GetRepositoryInfoResult::GetRepositoryInfoResult() :
  21. ServiceResult()
  22. {}
  23. GetRepositoryInfoResult::GetRepositoryInfoResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetRepositoryInfoResult::~GetRepositoryInfoResult()
  29. {}
  30. void GetRepositoryInfoResult::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 resultNode = value["Result"];
  37. if(!resultNode["Id"].isNull())
  38. result_.id = std::stol(resultNode["Id"].asString());
  39. if(!resultNode["SshUrlToRepo"].isNull())
  40. result_.sshUrlToRepo = resultNode["SshUrlToRepo"].asString();
  41. if(!resultNode["Description"].isNull())
  42. result_.description = resultNode["Description"].asString();
  43. if(!resultNode["DefaultBranch"].isNull())
  44. result_.defaultBranch = resultNode["DefaultBranch"].asString();
  45. if(!resultNode["Public"].isNull())
  46. result_._public = resultNode["Public"].asString() == "true";
  47. if(!resultNode["VisibilityLevel"].isNull())
  48. result_.visibilityLevel = resultNode["VisibilityLevel"].asString();
  49. if(!resultNode["HttpUrlToRepo"].isNull())
  50. result_.httpUrlToRepo = resultNode["HttpUrlToRepo"].asString();
  51. if(!resultNode["WebUrl"].isNull())
  52. result_.webUrl = resultNode["WebUrl"].asString();
  53. if(!resultNode["Name"].isNull())
  54. result_.name = resultNode["Name"].asString();
  55. if(!resultNode["NameWithNamespace"].isNull())
  56. result_.nameWithNamespace = resultNode["NameWithNamespace"].asString();
  57. if(!resultNode["Path"].isNull())
  58. result_.path = resultNode["Path"].asString();
  59. if(!resultNode["PathWithNamespace"].isNull())
  60. result_.pathWithNamespace = resultNode["PathWithNamespace"].asString();
  61. if(!resultNode["CreatedAt"].isNull())
  62. result_.createdAt = resultNode["CreatedAt"].asString();
  63. if(!resultNode["LastActivityAt"].isNull())
  64. result_.lastActivityAt = resultNode["LastActivityAt"].asString();
  65. if(!resultNode["CreatorId"].isNull())
  66. result_.creatorId = std::stol(resultNode["CreatorId"].asString());
  67. if(!resultNode["Archive"].isNull())
  68. result_.archive = resultNode["Archive"].asString() == "true";
  69. if(!resultNode["AvatarUrl"].isNull())
  70. result_.avatarUrl = resultNode["AvatarUrl"].asString();
  71. if(!resultNode["DemoProjectStatus"].isNull())
  72. result_.demoProjectStatus = resultNode["DemoProjectStatus"].asString() == "true";
  73. if(!resultNode["AccessLevel"].isNull())
  74. result_.accessLevel = std::stoi(resultNode["AccessLevel"].asString());
  75. if(!resultNode["ImportStatus"].isNull())
  76. result_.importStatus = resultNode["ImportStatus"].asString();
  77. if(!resultNode["ImportUrl"].isNull())
  78. result_.importUrl = resultNode["ImportUrl"].asString();
  79. if(!resultNode["ImportFromSubversion"].isNull())
  80. result_.importFromSubversion = resultNode["ImportFromSubversion"].asString() == "true";
  81. auto _namespaceNode = resultNode["Namespace"];
  82. if(!_namespaceNode["Id"].isNull())
  83. result_._namespace.id = std::stol(_namespaceNode["Id"].asString());
  84. if(!_namespaceNode["Name"].isNull())
  85. result_._namespace.name = _namespaceNode["Name"].asString();
  86. if(!_namespaceNode["Path"].isNull())
  87. result_._namespace.path = _namespaceNode["Path"].asString();
  88. if(!_namespaceNode["OwnerId"].isNull())
  89. result_._namespace.ownerId = std::stol(_namespaceNode["OwnerId"].asString());
  90. if(!_namespaceNode["CreatedAt"].isNull())
  91. result_._namespace.createdAt = _namespaceNode["CreatedAt"].asString();
  92. if(!_namespaceNode["UpdatedAt"].isNull())
  93. result_._namespace.updatedAt = _namespaceNode["UpdatedAt"].asString();
  94. if(!_namespaceNode["Description"].isNull())
  95. result_._namespace.description = _namespaceNode["Description"].asString();
  96. if(!_namespaceNode["State"].isNull())
  97. result_._namespace.state = _namespaceNode["State"].asString();
  98. if(!_namespaceNode["Avatar"].isNull())
  99. result_._namespace.avatar = _namespaceNode["Avatar"].asString();
  100. if(!_namespaceNode["Public"].isNull())
  101. result_._namespace._public = _namespaceNode["Public"].asString() == "true";
  102. if(!_namespaceNode["VisibilityLevel"].isNull())
  103. result_._namespace.visibilityLevel = _namespaceNode["VisibilityLevel"].asString();
  104. auto permissionsNode = resultNode["Permissions"];
  105. auto projectAccessNode = permissionsNode["ProjectAccess"];
  106. if(!projectAccessNode["AccessLevel"].isNull())
  107. result_.permissions.projectAccess.accessLevel = std::stoi(projectAccessNode["AccessLevel"].asString());
  108. auto groupAccessNode = permissionsNode["GroupAccess"];
  109. if(!groupAccessNode["AccessLevel"].isNull())
  110. result_.permissions.groupAccess.accessLevel = std::stoi(groupAccessNode["AccessLevel"].asString());
  111. auto allTagList = resultNode["TagList"]["TagList"];
  112. for (auto value : allTagList)
  113. result_.tagList.push_back(value.asString());
  114. if(!value["ErrorCode"].isNull())
  115. errorCode_ = std::stoi(value["ErrorCode"].asString());
  116. if(!value["ErrorMessage"].isNull())
  117. errorMessage_ = value["ErrorMessage"].asString();
  118. if(!value["Success"].isNull())
  119. success_ = value["Success"].asString() == "true";
  120. }
  121. int GetRepositoryInfoResult::getErrorCode()const
  122. {
  123. return errorCode_;
  124. }
  125. std::string GetRepositoryInfoResult::getErrorMessage()const
  126. {
  127. return errorMessage_;
  128. }
  129. bool GetRepositoryInfoResult::getSuccess()const
  130. {
  131. return success_;
  132. }
  133. GetRepositoryInfoResult::Result GetRepositoryInfoResult::getResult()const
  134. {
  135. return result_;
  136. }