GetPipleineLatestInstanceStatusResult.cc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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/devops-rdc/model/GetPipleineLatestInstanceStatusResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Devops_rdc;
  19. using namespace AlibabaCloud::Devops_rdc::Model;
  20. GetPipleineLatestInstanceStatusResult::GetPipleineLatestInstanceStatusResult() :
  21. ServiceResult()
  22. {}
  23. GetPipleineLatestInstanceStatusResult::GetPipleineLatestInstanceStatusResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetPipleineLatestInstanceStatusResult::~GetPipleineLatestInstanceStatusResult()
  29. {}
  30. void GetPipleineLatestInstanceStatusResult::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 objectNode = value["Object"];
  37. if(!objectNode["Status"].isNull())
  38. object_.status = objectNode["Status"].asString();
  39. auto allGroupsNode = objectNode["Groups"]["group"];
  40. for (auto objectNodeGroupsgroup : allGroupsNode)
  41. {
  42. Object::Group groupObject;
  43. if(!objectNodeGroupsgroup["Name"].isNull())
  44. groupObject.name = objectNodeGroupsgroup["Name"].asString();
  45. if(!objectNodeGroupsgroup["Status"].isNull())
  46. groupObject.status = objectNodeGroupsgroup["Status"].asString();
  47. auto allStagesNode = allGroupsNode["Stages"]["stage"];
  48. for (auto allGroupsNodeStagesstage : allStagesNode)
  49. {
  50. Object::Group::Stage stagesObject;
  51. if(!allGroupsNodeStagesstage["Status"].isNull())
  52. stagesObject.status = allGroupsNodeStagesstage["Status"].asString();
  53. if(!allGroupsNodeStagesstage["Sign"].isNull())
  54. stagesObject.sign = allGroupsNodeStagesstage["Sign"].asString();
  55. auto allComponentsNode = allStagesNode["Components"]["component"];
  56. for (auto allStagesNodeComponentscomponent : allComponentsNode)
  57. {
  58. Object::Group::Stage::Component componentsObject;
  59. if(!allStagesNodeComponentscomponent["Name"].isNull())
  60. componentsObject.name = allStagesNodeComponentscomponent["Name"].asString();
  61. if(!allStagesNodeComponentscomponent["Status"].isNull())
  62. componentsObject.status = allStagesNodeComponentscomponent["Status"].asString();
  63. if(!allStagesNodeComponentscomponent["JobId"].isNull())
  64. componentsObject.jobId = std::stol(allStagesNodeComponentscomponent["JobId"].asString());
  65. stagesObject.components.push_back(componentsObject);
  66. }
  67. groupObject.stages.push_back(stagesObject);
  68. }
  69. object_.groups.push_back(groupObject);
  70. }
  71. if(!value["Success"].isNull())
  72. success_ = value["Success"].asString() == "true";
  73. if(!value["ErrorCode"].isNull())
  74. errorCode_ = value["ErrorCode"].asString();
  75. if(!value["ErrorMessage"].isNull())
  76. errorMessage_ = value["ErrorMessage"].asString();
  77. }
  78. GetPipleineLatestInstanceStatusResult::Object GetPipleineLatestInstanceStatusResult::getObject()const
  79. {
  80. return object_;
  81. }
  82. std::string GetPipleineLatestInstanceStatusResult::getErrorCode()const
  83. {
  84. return errorCode_;
  85. }
  86. std::string GetPipleineLatestInstanceStatusResult::getErrorMessage()const
  87. {
  88. return errorMessage_;
  89. }
  90. bool GetPipleineLatestInstanceStatusResult::getSuccess()const
  91. {
  92. return success_;
  93. }