DescribeApiStageResult.cc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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/cloudapi/model/DescribeApiStageResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CloudAPI;
  19. using namespace AlibabaCloud::CloudAPI::Model;
  20. DescribeApiStageResult::DescribeApiStageResult() :
  21. ServiceResult()
  22. {}
  23. DescribeApiStageResult::DescribeApiStageResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeApiStageResult::~DescribeApiStageResult()
  29. {}
  30. void DescribeApiStageResult::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 allVariablesNode = value["Variables"]["VariableItem"];
  37. for (auto valueVariablesVariableItem : allVariablesNode)
  38. {
  39. VariableItem variablesObject;
  40. if(!valueVariablesVariableItem["VariableName"].isNull())
  41. variablesObject.variableName = valueVariablesVariableItem["VariableName"].asString();
  42. if(!valueVariablesVariableItem["VariableValue"].isNull())
  43. variablesObject.variableValue = valueVariablesVariableItem["VariableValue"].asString();
  44. if(!valueVariablesVariableItem["SupportRoute"].isNull())
  45. variablesObject.supportRoute = valueVariablesVariableItem["SupportRoute"].asString() == "true";
  46. auto stageRouteModelNode = value["StageRouteModel"];
  47. if(!stageRouteModelNode["ParameterCatalog"].isNull())
  48. variablesObject.stageRouteModel.parameterCatalog = stageRouteModelNode["ParameterCatalog"].asString();
  49. if(!stageRouteModelNode["ServiceParameterName"].isNull())
  50. variablesObject.stageRouteModel.serviceParameterName = stageRouteModelNode["ServiceParameterName"].asString();
  51. if(!stageRouteModelNode["Location"].isNull())
  52. variablesObject.stageRouteModel.location = stageRouteModelNode["Location"].asString();
  53. if(!stageRouteModelNode["ParameterType"].isNull())
  54. variablesObject.stageRouteModel.parameterType = stageRouteModelNode["ParameterType"].asString();
  55. if(!stageRouteModelNode["RouteMatchSymbol"].isNull())
  56. variablesObject.stageRouteModel.routeMatchSymbol = stageRouteModelNode["RouteMatchSymbol"].asString();
  57. auto allRouteRulesNode = stageRouteModelNode["RouteRules"]["RouteRuleItem"];
  58. for (auto stageRouteModelNodeRouteRulesRouteRuleItem : allRouteRulesNode)
  59. {
  60. VariableItem::StageRouteModel::RouteRuleItem routeRuleItemObject;
  61. if(!stageRouteModelNodeRouteRulesRouteRuleItem["MaxValue"].isNull())
  62. routeRuleItemObject.maxValue = std::stol(stageRouteModelNodeRouteRulesRouteRuleItem["MaxValue"].asString());
  63. if(!stageRouteModelNodeRouteRulesRouteRuleItem["MinValue"].isNull())
  64. routeRuleItemObject.minValue = std::stol(stageRouteModelNodeRouteRulesRouteRuleItem["MinValue"].asString());
  65. if(!stageRouteModelNodeRouteRulesRouteRuleItem["ConditionValue"].isNull())
  66. routeRuleItemObject.conditionValue = stageRouteModelNodeRouteRulesRouteRuleItem["ConditionValue"].asString();
  67. if(!stageRouteModelNodeRouteRulesRouteRuleItem["ResultValue"].isNull())
  68. routeRuleItemObject.resultValue = stageRouteModelNodeRouteRulesRouteRuleItem["ResultValue"].asString();
  69. variablesObject.stageRouteModel.routeRules.push_back(routeRuleItemObject);
  70. }
  71. variables_.push_back(variablesObject);
  72. }
  73. if(!value["GroupId"].isNull())
  74. groupId_ = value["GroupId"].asString();
  75. if(!value["StageId"].isNull())
  76. stageId_ = value["StageId"].asString();
  77. if(!value["StageName"].isNull())
  78. stageName_ = value["StageName"].asString();
  79. if(!value["Description"].isNull())
  80. description_ = value["Description"].asString();
  81. if(!value["CreatedTime"].isNull())
  82. createdTime_ = value["CreatedTime"].asString();
  83. if(!value["ModifiedTime"].isNull())
  84. modifiedTime_ = value["ModifiedTime"].asString();
  85. }
  86. std::vector<DescribeApiStageResult::VariableItem> DescribeApiStageResult::getVariables()const
  87. {
  88. return variables_;
  89. }
  90. std::string DescribeApiStageResult::getDescription()const
  91. {
  92. return description_;
  93. }
  94. std::string DescribeApiStageResult::getCreatedTime()const
  95. {
  96. return createdTime_;
  97. }
  98. std::string DescribeApiStageResult::getModifiedTime()const
  99. {
  100. return modifiedTime_;
  101. }
  102. std::string DescribeApiStageResult::getStageName()const
  103. {
  104. return stageName_;
  105. }
  106. std::string DescribeApiStageResult::getStageId()const
  107. {
  108. return stageId_;
  109. }
  110. std::string DescribeApiStageResult::getGroupId()const
  111. {
  112. return groupId_;
  113. }