CreateTagResult.cc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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/CreateTagResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Codeup;
  19. using namespace AlibabaCloud::Codeup::Model;
  20. CreateTagResult::CreateTagResult() :
  21. ServiceResult()
  22. {}
  23. CreateTagResult::CreateTagResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. CreateTagResult::~CreateTagResult()
  29. {}
  30. void CreateTagResult::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["Name"].isNull())
  38. result_.name = resultNode["Name"].asString();
  39. if(!resultNode["Message"].isNull())
  40. result_.message = resultNode["Message"].asString();
  41. auto commitInfoNode = resultNode["CommitInfo"];
  42. if(!commitInfoNode["Id"].isNull())
  43. result_.commitInfo.id = commitInfoNode["Id"].asString();
  44. if(!commitInfoNode["ShortId"].isNull())
  45. result_.commitInfo.shortId = commitInfoNode["ShortId"].asString();
  46. if(!commitInfoNode["Title"].isNull())
  47. result_.commitInfo.title = commitInfoNode["Title"].asString();
  48. if(!commitInfoNode["AuthorName"].isNull())
  49. result_.commitInfo.authorName = commitInfoNode["AuthorName"].asString();
  50. if(!commitInfoNode["AuthorEmail"].isNull())
  51. result_.commitInfo.authorEmail = commitInfoNode["AuthorEmail"].asString();
  52. if(!commitInfoNode["AuthoredDate"].isNull())
  53. result_.commitInfo.authoredDate = commitInfoNode["AuthoredDate"].asString();
  54. if(!commitInfoNode["CommittedDate"].isNull())
  55. result_.commitInfo.committedDate = commitInfoNode["CommittedDate"].asString();
  56. if(!commitInfoNode["CommitterEmail"].isNull())
  57. result_.commitInfo.committerEmail = commitInfoNode["CommitterEmail"].asString();
  58. if(!commitInfoNode["CommitterName"].isNull())
  59. result_.commitInfo.committerName = commitInfoNode["CommitterName"].asString();
  60. if(!commitInfoNode["CreatedAt"].isNull())
  61. result_.commitInfo.createdAt = commitInfoNode["CreatedAt"].asString();
  62. if(!commitInfoNode["Message"].isNull())
  63. result_.commitInfo.message = commitInfoNode["Message"].asString();
  64. auto allParentIds = commitInfoNode["ParentIds"]["ParentIds"];
  65. for (auto value : allParentIds)
  66. result_.commitInfo.parentIds.push_back(value.asString());
  67. auto releaseNode = resultNode["Release"];
  68. if(!releaseNode["TagName"].isNull())
  69. result_.release.tagName = releaseNode["TagName"].asString();
  70. if(!releaseNode["Description"].isNull())
  71. result_.release.description = releaseNode["Description"].asString();
  72. if(!value["ErrorCode"].isNull())
  73. errorCode_ = value["ErrorCode"].asString();
  74. if(!value["Success"].isNull())
  75. success_ = value["Success"].asString() == "true";
  76. if(!value["ErrorMessage"].isNull())
  77. errorMessage_ = value["ErrorMessage"].asString();
  78. }
  79. std::string CreateTagResult::getErrorCode()const
  80. {
  81. return errorCode_;
  82. }
  83. std::string CreateTagResult::getErrorMessage()const
  84. {
  85. return errorMessage_;
  86. }
  87. bool CreateTagResult::getSuccess()const
  88. {
  89. return success_;
  90. }
  91. CreateTagResult::Result CreateTagResult::getResult()const
  92. {
  93. return result_;
  94. }