| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- /*
- * Copyright 2009-2017 Alibaba Cloud All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #include <alibabacloud/emr/model/ListClusterTemplatesResult.h>
- #include <json/json.h>
- using namespace AlibabaCloud::Emr;
- using namespace AlibabaCloud::Emr::Model;
- ListClusterTemplatesResult::ListClusterTemplatesResult() :
- ServiceResult()
- {}
- ListClusterTemplatesResult::ListClusterTemplatesResult(const std::string &payload) :
- ServiceResult()
- {
- parse(payload);
- }
- ListClusterTemplatesResult::~ListClusterTemplatesResult()
- {}
- void ListClusterTemplatesResult::parse(const std::string &payload)
- {
- Json::Reader reader;
- Json::Value value;
- reader.parse(payload, value);
- setRequestId(value["RequestId"].asString());
- auto allTemplateInfoListNode = value["TemplateInfoList"]["TemplateInfo"];
- for (auto valueTemplateInfoListTemplateInfo : allTemplateInfoListNode)
- {
- TemplateInfo templateInfoListObject;
- if(!valueTemplateInfoListTemplateInfo["Id"].isNull())
- templateInfoListObject.id = valueTemplateInfoListTemplateInfo["Id"].asString();
- if(!valueTemplateInfoListTemplateInfo["TemplateName"].isNull())
- templateInfoListObject.templateName = valueTemplateInfoListTemplateInfo["TemplateName"].asString();
- if(!valueTemplateInfoListTemplateInfo["LogEnable"].isNull())
- templateInfoListObject.logEnable = valueTemplateInfoListTemplateInfo["LogEnable"].asString() == "true";
- if(!valueTemplateInfoListTemplateInfo["LogPath"].isNull())
- templateInfoListObject.logPath = valueTemplateInfoListTemplateInfo["LogPath"].asString();
- if(!valueTemplateInfoListTemplateInfo["UserId"].isNull())
- templateInfoListObject.userId = valueTemplateInfoListTemplateInfo["UserId"].asString();
- if(!valueTemplateInfoListTemplateInfo["UserDefinedEmrEcsRole"].isNull())
- templateInfoListObject.userDefinedEmrEcsRole = valueTemplateInfoListTemplateInfo["UserDefinedEmrEcsRole"].asString();
- if(!valueTemplateInfoListTemplateInfo["MasterNodeTotal"].isNull())
- templateInfoListObject.masterNodeTotal = std::stoi(valueTemplateInfoListTemplateInfo["MasterNodeTotal"].asString());
- if(!valueTemplateInfoListTemplateInfo["VpcId"].isNull())
- templateInfoListObject.vpcId = valueTemplateInfoListTemplateInfo["VpcId"].asString();
- if(!valueTemplateInfoListTemplateInfo["VSwitchId"].isNull())
- templateInfoListObject.vSwitchId = valueTemplateInfoListTemplateInfo["VSwitchId"].asString();
- if(!valueTemplateInfoListTemplateInfo["NetType"].isNull())
- templateInfoListObject.netType = valueTemplateInfoListTemplateInfo["NetType"].asString();
- if(!valueTemplateInfoListTemplateInfo["IoOptimized"].isNull())
- templateInfoListObject.ioOptimized = valueTemplateInfoListTemplateInfo["IoOptimized"].asString() == "true";
- if(!valueTemplateInfoListTemplateInfo["InstanceGeneration"].isNull())
- templateInfoListObject.instanceGeneration = valueTemplateInfoListTemplateInfo["InstanceGeneration"].asString();
- if(!valueTemplateInfoListTemplateInfo["HighAvailabilityEnable"].isNull())
- templateInfoListObject.highAvailabilityEnable = valueTemplateInfoListTemplateInfo["HighAvailabilityEnable"].asString() == "true";
- if(!valueTemplateInfoListTemplateInfo["EasEnable"].isNull())
- templateInfoListObject.easEnable = valueTemplateInfoListTemplateInfo["EasEnable"].asString() == "true";
- if(!valueTemplateInfoListTemplateInfo["GmtCreate"].isNull())
- templateInfoListObject.gmtCreate = std::stol(valueTemplateInfoListTemplateInfo["GmtCreate"].asString());
- if(!valueTemplateInfoListTemplateInfo["GmtModified"].isNull())
- templateInfoListObject.gmtModified = std::stol(valueTemplateInfoListTemplateInfo["GmtModified"].asString());
- if(!valueTemplateInfoListTemplateInfo["ZoneId"].isNull())
- templateInfoListObject.zoneId = valueTemplateInfoListTemplateInfo["ZoneId"].asString();
- if(!valueTemplateInfoListTemplateInfo["ClusterType"].isNull())
- templateInfoListObject.clusterType = valueTemplateInfoListTemplateInfo["ClusterType"].asString();
- if(!valueTemplateInfoListTemplateInfo["SecurityGroupId"].isNull())
- templateInfoListObject.securityGroupId = valueTemplateInfoListTemplateInfo["SecurityGroupId"].asString();
- if(!valueTemplateInfoListTemplateInfo["SecurityGroupName"].isNull())
- templateInfoListObject.securityGroupName = valueTemplateInfoListTemplateInfo["SecurityGroupName"].asString();
- if(!valueTemplateInfoListTemplateInfo["Configurations"].isNull())
- templateInfoListObject.configurations = valueTemplateInfoListTemplateInfo["Configurations"].asString();
- if(!valueTemplateInfoListTemplateInfo["AllowNotebook"].isNull())
- templateInfoListObject.allowNotebook = valueTemplateInfoListTemplateInfo["AllowNotebook"].asString() == "true";
- if(!valueTemplateInfoListTemplateInfo["CreateSource"].isNull())
- templateInfoListObject.createSource = valueTemplateInfoListTemplateInfo["CreateSource"].asString();
- if(!valueTemplateInfoListTemplateInfo["UseLocalMetaDb"].isNull())
- templateInfoListObject.useLocalMetaDb = valueTemplateInfoListTemplateInfo["UseLocalMetaDb"].asString() == "true";
- if(!valueTemplateInfoListTemplateInfo["SshEnable"].isNull())
- templateInfoListObject.sshEnable = valueTemplateInfoListTemplateInfo["SshEnable"].asString() == "true";
- if(!valueTemplateInfoListTemplateInfo["IsOpenPublicIp"].isNull())
- templateInfoListObject.isOpenPublicIp = valueTemplateInfoListTemplateInfo["IsOpenPublicIp"].asString() == "true";
- if(!valueTemplateInfoListTemplateInfo["DepositType"].isNull())
- templateInfoListObject.depositType = valueTemplateInfoListTemplateInfo["DepositType"].asString();
- if(!valueTemplateInfoListTemplateInfo["MachineType"].isNull())
- templateInfoListObject.machineType = valueTemplateInfoListTemplateInfo["MachineType"].asString();
- if(!valueTemplateInfoListTemplateInfo["UseCustomHiveMetaDb"].isNull())
- templateInfoListObject.useCustomHiveMetaDb = valueTemplateInfoListTemplateInfo["UseCustomHiveMetaDb"].asString() == "true";
- if(!valueTemplateInfoListTemplateInfo["InitCustomHiveMetaDb"].isNull())
- templateInfoListObject.initCustomHiveMetaDb = valueTemplateInfoListTemplateInfo["InitCustomHiveMetaDb"].asString() == "true";
- if(!valueTemplateInfoListTemplateInfo["KeyPairName"].isNull())
- templateInfoListObject.keyPairName = valueTemplateInfoListTemplateInfo["KeyPairName"].asString();
- if(!valueTemplateInfoListTemplateInfo["MetaStoreType"].isNull())
- templateInfoListObject.metaStoreType = valueTemplateInfoListTemplateInfo["MetaStoreType"].asString();
- if(!valueTemplateInfoListTemplateInfo["MetaStoreConf"].isNull())
- templateInfoListObject.metaStoreConf = valueTemplateInfoListTemplateInfo["MetaStoreConf"].asString();
- auto allBootstrapActionListNode = allTemplateInfoListNode["BootstrapActionList"]["BootstrapAction"];
- for (auto allTemplateInfoListNodeBootstrapActionListBootstrapAction : allBootstrapActionListNode)
- {
- TemplateInfo::BootstrapAction bootstrapActionListObject;
- if(!allTemplateInfoListNodeBootstrapActionListBootstrapAction["Name"].isNull())
- bootstrapActionListObject.name = allTemplateInfoListNodeBootstrapActionListBootstrapAction["Name"].asString();
- if(!allTemplateInfoListNodeBootstrapActionListBootstrapAction["Path"].isNull())
- bootstrapActionListObject.path = allTemplateInfoListNodeBootstrapActionListBootstrapAction["Path"].asString();
- if(!allTemplateInfoListNodeBootstrapActionListBootstrapAction["Arg"].isNull())
- bootstrapActionListObject.arg = allTemplateInfoListNodeBootstrapActionListBootstrapAction["Arg"].asString();
- templateInfoListObject.bootstrapActionList.push_back(bootstrapActionListObject);
- }
- auto allHostGroupListNode = allTemplateInfoListNode["HostGroupList"]["HostGroup"];
- for (auto allTemplateInfoListNodeHostGroupListHostGroup : allHostGroupListNode)
- {
- TemplateInfo::HostGroup hostGroupListObject;
- if(!allTemplateInfoListNodeHostGroupListHostGroup["HostGroupId"].isNull())
- hostGroupListObject.hostGroupId = allTemplateInfoListNodeHostGroupListHostGroup["HostGroupId"].asString();
- if(!allTemplateInfoListNodeHostGroupListHostGroup["HostGroupName"].isNull())
- hostGroupListObject.hostGroupName = allTemplateInfoListNodeHostGroupListHostGroup["HostGroupName"].asString();
- if(!allTemplateInfoListNodeHostGroupListHostGroup["HostGroupType"].isNull())
- hostGroupListObject.hostGroupType = allTemplateInfoListNodeHostGroupListHostGroup["HostGroupType"].asString();
- if(!allTemplateInfoListNodeHostGroupListHostGroup["ChargeType"].isNull())
- hostGroupListObject.chargeType = allTemplateInfoListNodeHostGroupListHostGroup["ChargeType"].asString();
- if(!allTemplateInfoListNodeHostGroupListHostGroup["Period"].isNull())
- hostGroupListObject.period = allTemplateInfoListNodeHostGroupListHostGroup["Period"].asString();
- if(!allTemplateInfoListNodeHostGroupListHostGroup["NodeCount"].isNull())
- hostGroupListObject.nodeCount = std::stoi(allTemplateInfoListNodeHostGroupListHostGroup["NodeCount"].asString());
- if(!allTemplateInfoListNodeHostGroupListHostGroup["InstanceType"].isNull())
- hostGroupListObject.instanceType = allTemplateInfoListNodeHostGroupListHostGroup["InstanceType"].asString();
- if(!allTemplateInfoListNodeHostGroupListHostGroup["DiskType"].isNull())
- hostGroupListObject.diskType = allTemplateInfoListNodeHostGroupListHostGroup["DiskType"].asString();
- if(!allTemplateInfoListNodeHostGroupListHostGroup["DiskCapacity"].isNull())
- hostGroupListObject.diskCapacity = std::stoi(allTemplateInfoListNodeHostGroupListHostGroup["DiskCapacity"].asString());
- if(!allTemplateInfoListNodeHostGroupListHostGroup["DiskCount"].isNull())
- hostGroupListObject.diskCount = std::stoi(allTemplateInfoListNodeHostGroupListHostGroup["DiskCount"].asString());
- if(!allTemplateInfoListNodeHostGroupListHostGroup["SysDiskType"].isNull())
- hostGroupListObject.sysDiskType = allTemplateInfoListNodeHostGroupListHostGroup["SysDiskType"].asString();
- if(!allTemplateInfoListNodeHostGroupListHostGroup["SysDiskCapacity"].isNull())
- hostGroupListObject.sysDiskCapacity = std::stoi(allTemplateInfoListNodeHostGroupListHostGroup["SysDiskCapacity"].asString());
- if(!allTemplateInfoListNodeHostGroupListHostGroup["MultiInstanceTypes"].isNull())
- hostGroupListObject.multiInstanceTypes = allTemplateInfoListNodeHostGroupListHostGroup["MultiInstanceTypes"].asString();
- templateInfoListObject.hostGroupList.push_back(hostGroupListObject);
- }
- auto allConfigListNode = allTemplateInfoListNode["ConfigList"]["Config"];
- for (auto allTemplateInfoListNodeConfigListConfig : allConfigListNode)
- {
- TemplateInfo::Config configListObject;
- if(!allTemplateInfoListNodeConfigListConfig["ServiceName"].isNull())
- configListObject.serviceName = allTemplateInfoListNodeConfigListConfig["ServiceName"].asString();
- if(!allTemplateInfoListNodeConfigListConfig["FileName"].isNull())
- configListObject.fileName = allTemplateInfoListNodeConfigListConfig["FileName"].asString();
- if(!allTemplateInfoListNodeConfigListConfig["ConfigKey"].isNull())
- configListObject.configKey = allTemplateInfoListNodeConfigListConfig["ConfigKey"].asString();
- if(!allTemplateInfoListNodeConfigListConfig["ConfigValue"].isNull())
- configListObject.configValue = allTemplateInfoListNodeConfigListConfig["ConfigValue"].asString();
- if(!allTemplateInfoListNodeConfigListConfig["Encrypt"].isNull())
- configListObject.encrypt = allTemplateInfoListNodeConfigListConfig["Encrypt"].asString();
- if(!allTemplateInfoListNodeConfigListConfig["Replace"].isNull())
- configListObject.replace = allTemplateInfoListNodeConfigListConfig["Replace"].asString();
- templateInfoListObject.configList.push_back(configListObject);
- }
- auto allSoftwareInfoList = value["SoftwareInfoList"]["SoftwareInfo"];
- for (auto value : allSoftwareInfoList)
- templateInfoListObject.softwareInfoList.push_back(value.asString());
- templateInfoList_.push_back(templateInfoListObject);
- }
- if(!value["TotalCount"].isNull())
- totalCount_ = std::stoi(value["TotalCount"].asString());
- if(!value["PageNumber"].isNull())
- pageNumber_ = std::stoi(value["PageNumber"].asString());
- if(!value["PageSize"].isNull())
- pageSize_ = std::stoi(value["PageSize"].asString());
- }
- int ListClusterTemplatesResult::getTotalCount()const
- {
- return totalCount_;
- }
- int ListClusterTemplatesResult::getPageSize()const
- {
- return pageSize_;
- }
- int ListClusterTemplatesResult::getPageNumber()const
- {
- return pageNumber_;
- }
- std::vector<ListClusterTemplatesResult::TemplateInfo> ListClusterTemplatesResult::getTemplateInfoList()const
- {
- return templateInfoList_;
- }
|