GetStackResult.cc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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/ros/model/GetStackResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::ROS;
  19. using namespace AlibabaCloud::ROS::Model;
  20. GetStackResult::GetStackResult() :
  21. ServiceResult()
  22. {}
  23. GetStackResult::GetStackResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetStackResult::~GetStackResult()
  29. {}
  30. void GetStackResult::parse(const std::string &payload)
  31. {
  32. Json::CharReaderBuilder builder;
  33. Json::CharReader *reader = builder.newCharReader();
  34. Json::Value *val;
  35. Json::Value value;
  36. JSONCPP_STRING *errs;
  37. reader->parse(payload.data(), payload.data() + payload.size(), val, errs);
  38. value = *val;
  39. setRequestId(value["RequestId"].asString());
  40. auto allParameters = value["Parameters"]["Parameter"];
  41. for (auto value : allParameters)
  42. {
  43. Parameter parametersObject;
  44. if(!value["ParameterKey"].isNull())
  45. parametersObject.parameterKey = value["ParameterKey"].asString();
  46. if(!value["ParameterValue"].isNull())
  47. parametersObject.parameterValue = value["ParameterValue"].asString();
  48. parameters_.push_back(parametersObject);
  49. }
  50. auto allOutputs = value["Outputs"]["Output"];
  51. for (const auto &item : allOutputs)
  52. outputs_.push_back(item.asString());
  53. auto allNotificationURLs = value["NotificationURLs"]["NotificationURL"];
  54. for (const auto &item : allNotificationURLs)
  55. notificationURLs_.push_back(item.asString());
  56. if(!value["CreateTime"].isNull())
  57. createTime_ = value["CreateTime"].asString();
  58. if(!value["Description"].isNull())
  59. description_ = value["Description"].asString();
  60. if(!value["DisableRollback"].isNull())
  61. disableRollback_ = value["DisableRollback"].asString() == "true";
  62. if(!value["RegionId"].isNull())
  63. regionId_ = value["RegionId"].asString();
  64. if(!value["StackId"].isNull())
  65. stackId_ = value["StackId"].asString();
  66. if(!value["StackName"].isNull())
  67. stackName_ = value["StackName"].asString();
  68. if(!value["Status"].isNull())
  69. status_ = value["Status"].asString();
  70. if(!value["StatusReason"].isNull())
  71. statusReason_ = value["StatusReason"].asString();
  72. if(!value["TemplateDescription"].isNull())
  73. templateDescription_ = value["TemplateDescription"].asString();
  74. if(!value["TimeoutInMinutes"].isNull())
  75. timeoutInMinutes_ = std::stoi(value["TimeoutInMinutes"].asString());
  76. if(!value["UpdateTime"].isNull())
  77. updateTime_ = value["UpdateTime"].asString();
  78. if(!value["ParentStackId"].isNull())
  79. parentStackId_ = value["ParentStackId"].asString();
  80. }
  81. std::string GetStackResult::getStatus()const
  82. {
  83. return status_;
  84. }
  85. std::vector<GetStackResult::Parameter> GetStackResult::getParameters()const
  86. {
  87. return parameters_;
  88. }
  89. std::string GetStackResult::getDescription()const
  90. {
  91. return description_;
  92. }
  93. std::string GetStackResult::getStatusReason()const
  94. {
  95. return statusReason_;
  96. }
  97. std::string GetStackResult::getParentStackId()const
  98. {
  99. return parentStackId_;
  100. }
  101. std::string GetStackResult::getCreateTime()const
  102. {
  103. return createTime_;
  104. }
  105. std::string GetStackResult::getTemplateDescription()const
  106. {
  107. return templateDescription_;
  108. }
  109. std::vector<std::string> GetStackResult::getOutputs()const
  110. {
  111. return outputs_;
  112. }
  113. std::string GetStackResult::getUpdateTime()const
  114. {
  115. return updateTime_;
  116. }
  117. std::string GetStackResult::getRegionId()const
  118. {
  119. return regionId_;
  120. }
  121. std::vector<std::string> GetStackResult::getNotificationURLs()const
  122. {
  123. return notificationURLs_;
  124. }
  125. bool GetStackResult::getDisableRollback()const
  126. {
  127. return disableRollback_;
  128. }
  129. std::string GetStackResult::getStackName()const
  130. {
  131. return stackName_;
  132. }
  133. std::string GetStackResult::getStackId()const
  134. {
  135. return stackId_;
  136. }
  137. int GetStackResult::getTimeoutInMinutes()const
  138. {
  139. return timeoutInMinutes_;
  140. }