CreateApplicationScalingRuleResult.cc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/sae/model/CreateApplicationScalingRuleResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Sae;
  19. using namespace AlibabaCloud::Sae::Model;
  20. CreateApplicationScalingRuleResult::CreateApplicationScalingRuleResult() :
  21. ServiceResult()
  22. {}
  23. CreateApplicationScalingRuleResult::CreateApplicationScalingRuleResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. CreateApplicationScalingRuleResult::~CreateApplicationScalingRuleResult()
  29. {}
  30. void CreateApplicationScalingRuleResult::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 dataNode = value["Data"];
  37. if(!dataNode["UpdateTime"].isNull())
  38. data_.updateTime = std::stol(dataNode["UpdateTime"].asString());
  39. if(!dataNode["AppId"].isNull())
  40. data_.appId = dataNode["AppId"].asString();
  41. if(!dataNode["CreateTime"].isNull())
  42. data_.createTime = std::stol(dataNode["CreateTime"].asString());
  43. if(!dataNode["LastDisableTime"].isNull())
  44. data_.lastDisableTime = std::stol(dataNode["LastDisableTime"].asString());
  45. if(!dataNode["ScaleRuleEnabled"].isNull())
  46. data_.scaleRuleEnabled = dataNode["ScaleRuleEnabled"].asString() == "true";
  47. if(!dataNode["ScaleRuleType"].isNull())
  48. data_.scaleRuleType = dataNode["ScaleRuleType"].asString();
  49. if(!dataNode["ScaleRuleName"].isNull())
  50. data_.scaleRuleName = dataNode["ScaleRuleName"].asString();
  51. auto timerNode = dataNode["Timer"];
  52. if(!timerNode["EndDate"].isNull())
  53. data_.timer.endDate = timerNode["EndDate"].asString();
  54. if(!timerNode["BeginDate"].isNull())
  55. data_.timer.beginDate = timerNode["BeginDate"].asString();
  56. if(!timerNode["Period"].isNull())
  57. data_.timer.period = timerNode["Period"].asString();
  58. auto allSchedulesNode = timerNode["Schedules"]["Schedule"];
  59. for (auto timerNodeSchedulesSchedule : allSchedulesNode)
  60. {
  61. Data::Timer::Schedule scheduleObject;
  62. if(!timerNodeSchedulesSchedule["AtTime"].isNull())
  63. scheduleObject.atTime = timerNodeSchedulesSchedule["AtTime"].asString();
  64. if(!timerNodeSchedulesSchedule["TargetReplicas"].isNull())
  65. scheduleObject.targetReplicas = std::stoi(timerNodeSchedulesSchedule["TargetReplicas"].asString());
  66. data_.timer.schedules.push_back(scheduleObject);
  67. }
  68. auto metricNode = dataNode["Metric"];
  69. if(!metricNode["MaxReplicas"].isNull())
  70. data_.metric.maxReplicas = std::stoi(metricNode["MaxReplicas"].asString());
  71. if(!metricNode["MinReplicas"].isNull())
  72. data_.metric.minReplicas = std::stoi(metricNode["MinReplicas"].asString());
  73. auto allMetricsNode = metricNode["Metrics"]["Metric"];
  74. for (auto metricNodeMetricsMetric : allMetricsNode)
  75. {
  76. Data::Metric::Metric1 metric1Object;
  77. if(!metricNodeMetricsMetric["MetricTargetAverageUtilization"].isNull())
  78. metric1Object.metricTargetAverageUtilization = std::stoi(metricNodeMetricsMetric["MetricTargetAverageUtilization"].asString());
  79. if(!metricNodeMetricsMetric["MetricType"].isNull())
  80. metric1Object.metricType = metricNodeMetricsMetric["MetricType"].asString();
  81. data_.metric.metrics.push_back(metric1Object);
  82. }
  83. if(!value["TraceId"].isNull())
  84. traceId_ = value["TraceId"].asString();
  85. }
  86. std::string CreateApplicationScalingRuleResult::getTraceId()const
  87. {
  88. return traceId_;
  89. }
  90. CreateApplicationScalingRuleResult::Data CreateApplicationScalingRuleResult::getData()const
  91. {
  92. return data_;
  93. }