GetAutoScaleConfigResult.cc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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/ehpc/model/GetAutoScaleConfigResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::EHPC;
  19. using namespace AlibabaCloud::EHPC::Model;
  20. GetAutoScaleConfigResult::GetAutoScaleConfigResult() :
  21. ServiceResult()
  22. {}
  23. GetAutoScaleConfigResult::GetAutoScaleConfigResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetAutoScaleConfigResult::~GetAutoScaleConfigResult()
  29. {}
  30. void GetAutoScaleConfigResult::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 allQueuesNode = value["Queues"]["QueueInfo"];
  37. for (auto valueQueuesQueueInfo : allQueuesNode)
  38. {
  39. QueueInfo queuesObject;
  40. if(!valueQueuesQueueInfo["QueueName"].isNull())
  41. queuesObject.queueName = valueQueuesQueueInfo["QueueName"].asString();
  42. if(!valueQueuesQueueInfo["ResourceGroupId"].isNull())
  43. queuesObject.resourceGroupId = valueQueuesQueueInfo["ResourceGroupId"].asString();
  44. if(!valueQueuesQueueInfo["InstanceType"].isNull())
  45. queuesObject.instanceType = valueQueuesQueueInfo["InstanceType"].asString();
  46. if(!valueQueuesQueueInfo["SpotStrategy"].isNull())
  47. queuesObject.spotStrategy = valueQueuesQueueInfo["SpotStrategy"].asString();
  48. if(!valueQueuesQueueInfo["SpotPriceLimit"].isNull())
  49. queuesObject.spotPriceLimit = std::stof(valueQueuesQueueInfo["SpotPriceLimit"].asString());
  50. if(!valueQueuesQueueInfo["EnableAutoGrow"].isNull())
  51. queuesObject.enableAutoGrow = valueQueuesQueueInfo["EnableAutoGrow"].asString() == "true";
  52. if(!valueQueuesQueueInfo["EnableAutoShrink"].isNull())
  53. queuesObject.enableAutoShrink = valueQueuesQueueInfo["EnableAutoShrink"].asString() == "true";
  54. if(!valueQueuesQueueInfo["MaxNodesInQueue"].isNull())
  55. queuesObject.maxNodesInQueue = std::stoi(valueQueuesQueueInfo["MaxNodesInQueue"].asString());
  56. if(!valueQueuesQueueInfo["MinNodesInQueue"].isNull())
  57. queuesObject.minNodesInQueue = std::stoi(valueQueuesQueueInfo["MinNodesInQueue"].asString());
  58. auto allInstanceTypesNode = allQueuesNode["InstanceTypes"]["InstanceTypeInfo"];
  59. for (auto allQueuesNodeInstanceTypesInstanceTypeInfo : allInstanceTypesNode)
  60. {
  61. QueueInfo::InstanceTypeInfo instanceTypesObject;
  62. if(!allQueuesNodeInstanceTypesInstanceTypeInfo["InstanceType"].isNull())
  63. instanceTypesObject.instanceType = allQueuesNodeInstanceTypesInstanceTypeInfo["InstanceType"].asString();
  64. if(!allQueuesNodeInstanceTypesInstanceTypeInfo["SpotStrategy"].isNull())
  65. instanceTypesObject.spotStrategy = allQueuesNodeInstanceTypesInstanceTypeInfo["SpotStrategy"].asString();
  66. if(!allQueuesNodeInstanceTypesInstanceTypeInfo["SpotPriceLimit"].isNull())
  67. instanceTypesObject.spotPriceLimit = std::stof(allQueuesNodeInstanceTypesInstanceTypeInfo["SpotPriceLimit"].asString());
  68. if(!allQueuesNodeInstanceTypesInstanceTypeInfo["ZoneId"].isNull())
  69. instanceTypesObject.zoneId = allQueuesNodeInstanceTypesInstanceTypeInfo["ZoneId"].asString();
  70. if(!allQueuesNodeInstanceTypesInstanceTypeInfo["VSwitchId"].isNull())
  71. instanceTypesObject.vSwitchId = allQueuesNodeInstanceTypesInstanceTypeInfo["VSwitchId"].asString();
  72. if(!allQueuesNodeInstanceTypesInstanceTypeInfo["HostNamePrefix"].isNull())
  73. instanceTypesObject.hostNamePrefix = allQueuesNodeInstanceTypesInstanceTypeInfo["HostNamePrefix"].asString();
  74. queuesObject.instanceTypes.push_back(instanceTypesObject);
  75. }
  76. queues_.push_back(queuesObject);
  77. }
  78. if(!value["Uid"].isNull())
  79. uid_ = value["Uid"].asString();
  80. if(!value["ClusterId"].isNull())
  81. clusterId_ = value["ClusterId"].asString();
  82. if(!value["ClusterType"].isNull())
  83. clusterType_ = value["ClusterType"].asString();
  84. if(!value["EnableAutoGrow"].isNull())
  85. enableAutoGrow_ = value["EnableAutoGrow"].asString() == "true";
  86. if(!value["EnableAutoShrink"].isNull())
  87. enableAutoShrink_ = value["EnableAutoShrink"].asString() == "true";
  88. if(!value["GrowIntervalInMinutes"].isNull())
  89. growIntervalInMinutes_ = std::stoi(value["GrowIntervalInMinutes"].asString());
  90. if(!value["ShrinkIntervalInMinutes"].isNull())
  91. shrinkIntervalInMinutes_ = std::stoi(value["ShrinkIntervalInMinutes"].asString());
  92. if(!value["ShrinkIdleTimes"].isNull())
  93. shrinkIdleTimes_ = std::stoi(value["ShrinkIdleTimes"].asString());
  94. if(!value["GrowTimeoutInMinutes"].isNull())
  95. growTimeoutInMinutes_ = std::stoi(value["GrowTimeoutInMinutes"].asString());
  96. if(!value["ExtraNodesGrowRatio"].isNull())
  97. extraNodesGrowRatio_ = std::stoi(value["ExtraNodesGrowRatio"].asString());
  98. if(!value["GrowRatio"].isNull())
  99. growRatio_ = std::stoi(value["GrowRatio"].asString());
  100. if(!value["MaxNodesInCluster"].isNull())
  101. maxNodesInCluster_ = std::stoi(value["MaxNodesInCluster"].asString());
  102. if(!value["ExcludeNodes"].isNull())
  103. excludeNodes_ = value["ExcludeNodes"].asString();
  104. if(!value["SpotStrategy"].isNull())
  105. spotStrategy_ = value["SpotStrategy"].asString();
  106. if(!value["SpotPriceLimit"].isNull())
  107. spotPriceLimit_ = std::stof(value["SpotPriceLimit"].asString());
  108. if(!value["ImageId"].isNull())
  109. imageId_ = value["ImageId"].asString();
  110. }
  111. int GetAutoScaleConfigResult::getExtraNodesGrowRatio()const
  112. {
  113. return extraNodesGrowRatio_;
  114. }
  115. bool GetAutoScaleConfigResult::getEnableAutoGrow()const
  116. {
  117. return enableAutoGrow_;
  118. }
  119. std::string GetAutoScaleConfigResult::getClusterId()const
  120. {
  121. return clusterId_;
  122. }
  123. int GetAutoScaleConfigResult::getShrinkIdleTimes()const
  124. {
  125. return shrinkIdleTimes_;
  126. }
  127. int GetAutoScaleConfigResult::getMaxNodesInCluster()const
  128. {
  129. return maxNodesInCluster_;
  130. }
  131. std::string GetAutoScaleConfigResult::getClusterType()const
  132. {
  133. return clusterType_;
  134. }
  135. bool GetAutoScaleConfigResult::getEnableAutoShrink()const
  136. {
  137. return enableAutoShrink_;
  138. }
  139. int GetAutoScaleConfigResult::getGrowRatio()const
  140. {
  141. return growRatio_;
  142. }
  143. int GetAutoScaleConfigResult::getGrowIntervalInMinutes()const
  144. {
  145. return growIntervalInMinutes_;
  146. }
  147. std::string GetAutoScaleConfigResult::getUid()const
  148. {
  149. return uid_;
  150. }
  151. int GetAutoScaleConfigResult::getGrowTimeoutInMinutes()const
  152. {
  153. return growTimeoutInMinutes_;
  154. }
  155. std::string GetAutoScaleConfigResult::getImageId()const
  156. {
  157. return imageId_;
  158. }
  159. int GetAutoScaleConfigResult::getShrinkIntervalInMinutes()const
  160. {
  161. return shrinkIntervalInMinutes_;
  162. }
  163. float GetAutoScaleConfigResult::getSpotPriceLimit()const
  164. {
  165. return spotPriceLimit_;
  166. }
  167. std::vector<GetAutoScaleConfigResult::QueueInfo> GetAutoScaleConfigResult::getQueues()const
  168. {
  169. return queues_;
  170. }
  171. std::string GetAutoScaleConfigResult::getExcludeNodes()const
  172. {
  173. return excludeNodes_;
  174. }
  175. std::string GetAutoScaleConfigResult::getSpotStrategy()const
  176. {
  177. return spotStrategy_;
  178. }