ListClusterTemplatesResult.cc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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/emr/model/ListClusterTemplatesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Emr;
  19. using namespace AlibabaCloud::Emr::Model;
  20. ListClusterTemplatesResult::ListClusterTemplatesResult() :
  21. ServiceResult()
  22. {}
  23. ListClusterTemplatesResult::ListClusterTemplatesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListClusterTemplatesResult::~ListClusterTemplatesResult()
  29. {}
  30. void ListClusterTemplatesResult::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 allTemplateInfoListNode = value["TemplateInfoList"]["TemplateInfo"];
  37. for (auto valueTemplateInfoListTemplateInfo : allTemplateInfoListNode)
  38. {
  39. TemplateInfo templateInfoListObject;
  40. if(!valueTemplateInfoListTemplateInfo["Id"].isNull())
  41. templateInfoListObject.id = valueTemplateInfoListTemplateInfo["Id"].asString();
  42. if(!valueTemplateInfoListTemplateInfo["TemplateName"].isNull())
  43. templateInfoListObject.templateName = valueTemplateInfoListTemplateInfo["TemplateName"].asString();
  44. if(!valueTemplateInfoListTemplateInfo["LogEnable"].isNull())
  45. templateInfoListObject.logEnable = valueTemplateInfoListTemplateInfo["LogEnable"].asString() == "true";
  46. if(!valueTemplateInfoListTemplateInfo["LogPath"].isNull())
  47. templateInfoListObject.logPath = valueTemplateInfoListTemplateInfo["LogPath"].asString();
  48. if(!valueTemplateInfoListTemplateInfo["UserId"].isNull())
  49. templateInfoListObject.userId = valueTemplateInfoListTemplateInfo["UserId"].asString();
  50. if(!valueTemplateInfoListTemplateInfo["UserDefinedEmrEcsRole"].isNull())
  51. templateInfoListObject.userDefinedEmrEcsRole = valueTemplateInfoListTemplateInfo["UserDefinedEmrEcsRole"].asString();
  52. if(!valueTemplateInfoListTemplateInfo["MasterNodeTotal"].isNull())
  53. templateInfoListObject.masterNodeTotal = std::stoi(valueTemplateInfoListTemplateInfo["MasterNodeTotal"].asString());
  54. if(!valueTemplateInfoListTemplateInfo["VpcId"].isNull())
  55. templateInfoListObject.vpcId = valueTemplateInfoListTemplateInfo["VpcId"].asString();
  56. if(!valueTemplateInfoListTemplateInfo["VSwitchId"].isNull())
  57. templateInfoListObject.vSwitchId = valueTemplateInfoListTemplateInfo["VSwitchId"].asString();
  58. if(!valueTemplateInfoListTemplateInfo["NetType"].isNull())
  59. templateInfoListObject.netType = valueTemplateInfoListTemplateInfo["NetType"].asString();
  60. if(!valueTemplateInfoListTemplateInfo["IoOptimized"].isNull())
  61. templateInfoListObject.ioOptimized = valueTemplateInfoListTemplateInfo["IoOptimized"].asString() == "true";
  62. if(!valueTemplateInfoListTemplateInfo["InstanceGeneration"].isNull())
  63. templateInfoListObject.instanceGeneration = valueTemplateInfoListTemplateInfo["InstanceGeneration"].asString();
  64. if(!valueTemplateInfoListTemplateInfo["HighAvailabilityEnable"].isNull())
  65. templateInfoListObject.highAvailabilityEnable = valueTemplateInfoListTemplateInfo["HighAvailabilityEnable"].asString() == "true";
  66. if(!valueTemplateInfoListTemplateInfo["EasEnable"].isNull())
  67. templateInfoListObject.easEnable = valueTemplateInfoListTemplateInfo["EasEnable"].asString() == "true";
  68. if(!valueTemplateInfoListTemplateInfo["GmtCreate"].isNull())
  69. templateInfoListObject.gmtCreate = std::stol(valueTemplateInfoListTemplateInfo["GmtCreate"].asString());
  70. if(!valueTemplateInfoListTemplateInfo["GmtModified"].isNull())
  71. templateInfoListObject.gmtModified = std::stol(valueTemplateInfoListTemplateInfo["GmtModified"].asString());
  72. if(!valueTemplateInfoListTemplateInfo["ZoneId"].isNull())
  73. templateInfoListObject.zoneId = valueTemplateInfoListTemplateInfo["ZoneId"].asString();
  74. if(!valueTemplateInfoListTemplateInfo["ClusterType"].isNull())
  75. templateInfoListObject.clusterType = valueTemplateInfoListTemplateInfo["ClusterType"].asString();
  76. if(!valueTemplateInfoListTemplateInfo["SecurityGroupId"].isNull())
  77. templateInfoListObject.securityGroupId = valueTemplateInfoListTemplateInfo["SecurityGroupId"].asString();
  78. if(!valueTemplateInfoListTemplateInfo["SecurityGroupName"].isNull())
  79. templateInfoListObject.securityGroupName = valueTemplateInfoListTemplateInfo["SecurityGroupName"].asString();
  80. if(!valueTemplateInfoListTemplateInfo["Configurations"].isNull())
  81. templateInfoListObject.configurations = valueTemplateInfoListTemplateInfo["Configurations"].asString();
  82. if(!valueTemplateInfoListTemplateInfo["AllowNotebook"].isNull())
  83. templateInfoListObject.allowNotebook = valueTemplateInfoListTemplateInfo["AllowNotebook"].asString() == "true";
  84. if(!valueTemplateInfoListTemplateInfo["CreateSource"].isNull())
  85. templateInfoListObject.createSource = valueTemplateInfoListTemplateInfo["CreateSource"].asString();
  86. if(!valueTemplateInfoListTemplateInfo["UseLocalMetaDb"].isNull())
  87. templateInfoListObject.useLocalMetaDb = valueTemplateInfoListTemplateInfo["UseLocalMetaDb"].asString() == "true";
  88. if(!valueTemplateInfoListTemplateInfo["SshEnable"].isNull())
  89. templateInfoListObject.sshEnable = valueTemplateInfoListTemplateInfo["SshEnable"].asString() == "true";
  90. if(!valueTemplateInfoListTemplateInfo["IsOpenPublicIp"].isNull())
  91. templateInfoListObject.isOpenPublicIp = valueTemplateInfoListTemplateInfo["IsOpenPublicIp"].asString() == "true";
  92. if(!valueTemplateInfoListTemplateInfo["DepositType"].isNull())
  93. templateInfoListObject.depositType = valueTemplateInfoListTemplateInfo["DepositType"].asString();
  94. if(!valueTemplateInfoListTemplateInfo["MachineType"].isNull())
  95. templateInfoListObject.machineType = valueTemplateInfoListTemplateInfo["MachineType"].asString();
  96. if(!valueTemplateInfoListTemplateInfo["UseCustomHiveMetaDb"].isNull())
  97. templateInfoListObject.useCustomHiveMetaDb = valueTemplateInfoListTemplateInfo["UseCustomHiveMetaDb"].asString() == "true";
  98. if(!valueTemplateInfoListTemplateInfo["InitCustomHiveMetaDb"].isNull())
  99. templateInfoListObject.initCustomHiveMetaDb = valueTemplateInfoListTemplateInfo["InitCustomHiveMetaDb"].asString() == "true";
  100. if(!valueTemplateInfoListTemplateInfo["KeyPairName"].isNull())
  101. templateInfoListObject.keyPairName = valueTemplateInfoListTemplateInfo["KeyPairName"].asString();
  102. if(!valueTemplateInfoListTemplateInfo["MetaStoreType"].isNull())
  103. templateInfoListObject.metaStoreType = valueTemplateInfoListTemplateInfo["MetaStoreType"].asString();
  104. if(!valueTemplateInfoListTemplateInfo["MetaStoreConf"].isNull())
  105. templateInfoListObject.metaStoreConf = valueTemplateInfoListTemplateInfo["MetaStoreConf"].asString();
  106. auto allBootstrapActionListNode = allTemplateInfoListNode["BootstrapActionList"]["BootstrapAction"];
  107. for (auto allTemplateInfoListNodeBootstrapActionListBootstrapAction : allBootstrapActionListNode)
  108. {
  109. TemplateInfo::BootstrapAction bootstrapActionListObject;
  110. if(!allTemplateInfoListNodeBootstrapActionListBootstrapAction["Name"].isNull())
  111. bootstrapActionListObject.name = allTemplateInfoListNodeBootstrapActionListBootstrapAction["Name"].asString();
  112. if(!allTemplateInfoListNodeBootstrapActionListBootstrapAction["Path"].isNull())
  113. bootstrapActionListObject.path = allTemplateInfoListNodeBootstrapActionListBootstrapAction["Path"].asString();
  114. if(!allTemplateInfoListNodeBootstrapActionListBootstrapAction["Arg"].isNull())
  115. bootstrapActionListObject.arg = allTemplateInfoListNodeBootstrapActionListBootstrapAction["Arg"].asString();
  116. templateInfoListObject.bootstrapActionList.push_back(bootstrapActionListObject);
  117. }
  118. auto allHostGroupListNode = allTemplateInfoListNode["HostGroupList"]["HostGroup"];
  119. for (auto allTemplateInfoListNodeHostGroupListHostGroup : allHostGroupListNode)
  120. {
  121. TemplateInfo::HostGroup hostGroupListObject;
  122. if(!allTemplateInfoListNodeHostGroupListHostGroup["HostGroupId"].isNull())
  123. hostGroupListObject.hostGroupId = allTemplateInfoListNodeHostGroupListHostGroup["HostGroupId"].asString();
  124. if(!allTemplateInfoListNodeHostGroupListHostGroup["HostGroupName"].isNull())
  125. hostGroupListObject.hostGroupName = allTemplateInfoListNodeHostGroupListHostGroup["HostGroupName"].asString();
  126. if(!allTemplateInfoListNodeHostGroupListHostGroup["HostGroupType"].isNull())
  127. hostGroupListObject.hostGroupType = allTemplateInfoListNodeHostGroupListHostGroup["HostGroupType"].asString();
  128. if(!allTemplateInfoListNodeHostGroupListHostGroup["ChargeType"].isNull())
  129. hostGroupListObject.chargeType = allTemplateInfoListNodeHostGroupListHostGroup["ChargeType"].asString();
  130. if(!allTemplateInfoListNodeHostGroupListHostGroup["Period"].isNull())
  131. hostGroupListObject.period = allTemplateInfoListNodeHostGroupListHostGroup["Period"].asString();
  132. if(!allTemplateInfoListNodeHostGroupListHostGroup["NodeCount"].isNull())
  133. hostGroupListObject.nodeCount = std::stoi(allTemplateInfoListNodeHostGroupListHostGroup["NodeCount"].asString());
  134. if(!allTemplateInfoListNodeHostGroupListHostGroup["InstanceType"].isNull())
  135. hostGroupListObject.instanceType = allTemplateInfoListNodeHostGroupListHostGroup["InstanceType"].asString();
  136. if(!allTemplateInfoListNodeHostGroupListHostGroup["DiskType"].isNull())
  137. hostGroupListObject.diskType = allTemplateInfoListNodeHostGroupListHostGroup["DiskType"].asString();
  138. if(!allTemplateInfoListNodeHostGroupListHostGroup["DiskCapacity"].isNull())
  139. hostGroupListObject.diskCapacity = std::stoi(allTemplateInfoListNodeHostGroupListHostGroup["DiskCapacity"].asString());
  140. if(!allTemplateInfoListNodeHostGroupListHostGroup["DiskCount"].isNull())
  141. hostGroupListObject.diskCount = std::stoi(allTemplateInfoListNodeHostGroupListHostGroup["DiskCount"].asString());
  142. if(!allTemplateInfoListNodeHostGroupListHostGroup["SysDiskType"].isNull())
  143. hostGroupListObject.sysDiskType = allTemplateInfoListNodeHostGroupListHostGroup["SysDiskType"].asString();
  144. if(!allTemplateInfoListNodeHostGroupListHostGroup["SysDiskCapacity"].isNull())
  145. hostGroupListObject.sysDiskCapacity = std::stoi(allTemplateInfoListNodeHostGroupListHostGroup["SysDiskCapacity"].asString());
  146. if(!allTemplateInfoListNodeHostGroupListHostGroup["MultiInstanceTypes"].isNull())
  147. hostGroupListObject.multiInstanceTypes = allTemplateInfoListNodeHostGroupListHostGroup["MultiInstanceTypes"].asString();
  148. templateInfoListObject.hostGroupList.push_back(hostGroupListObject);
  149. }
  150. auto allConfigListNode = allTemplateInfoListNode["ConfigList"]["Config"];
  151. for (auto allTemplateInfoListNodeConfigListConfig : allConfigListNode)
  152. {
  153. TemplateInfo::Config configListObject;
  154. if(!allTemplateInfoListNodeConfigListConfig["ServiceName"].isNull())
  155. configListObject.serviceName = allTemplateInfoListNodeConfigListConfig["ServiceName"].asString();
  156. if(!allTemplateInfoListNodeConfigListConfig["FileName"].isNull())
  157. configListObject.fileName = allTemplateInfoListNodeConfigListConfig["FileName"].asString();
  158. if(!allTemplateInfoListNodeConfigListConfig["ConfigKey"].isNull())
  159. configListObject.configKey = allTemplateInfoListNodeConfigListConfig["ConfigKey"].asString();
  160. if(!allTemplateInfoListNodeConfigListConfig["ConfigValue"].isNull())
  161. configListObject.configValue = allTemplateInfoListNodeConfigListConfig["ConfigValue"].asString();
  162. if(!allTemplateInfoListNodeConfigListConfig["Encrypt"].isNull())
  163. configListObject.encrypt = allTemplateInfoListNodeConfigListConfig["Encrypt"].asString();
  164. if(!allTemplateInfoListNodeConfigListConfig["Replace"].isNull())
  165. configListObject.replace = allTemplateInfoListNodeConfigListConfig["Replace"].asString();
  166. templateInfoListObject.configList.push_back(configListObject);
  167. }
  168. auto allSoftwareInfoList = value["SoftwareInfoList"]["SoftwareInfo"];
  169. for (auto value : allSoftwareInfoList)
  170. templateInfoListObject.softwareInfoList.push_back(value.asString());
  171. templateInfoList_.push_back(templateInfoListObject);
  172. }
  173. if(!value["TotalCount"].isNull())
  174. totalCount_ = std::stoi(value["TotalCount"].asString());
  175. if(!value["PageNumber"].isNull())
  176. pageNumber_ = std::stoi(value["PageNumber"].asString());
  177. if(!value["PageSize"].isNull())
  178. pageSize_ = std::stoi(value["PageSize"].asString());
  179. }
  180. int ListClusterTemplatesResult::getTotalCount()const
  181. {
  182. return totalCount_;
  183. }
  184. int ListClusterTemplatesResult::getPageSize()const
  185. {
  186. return pageSize_;
  187. }
  188. int ListClusterTemplatesResult::getPageNumber()const
  189. {
  190. return pageNumber_;
  191. }
  192. std::vector<ListClusterTemplatesResult::TemplateInfo> ListClusterTemplatesResult::getTemplateInfoList()const
  193. {
  194. return templateInfoList_;
  195. }