DescribeClusterServiceConfigResult.cc 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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/DescribeClusterServiceConfigResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Emr;
  19. using namespace AlibabaCloud::Emr::Model;
  20. DescribeClusterServiceConfigResult::DescribeClusterServiceConfigResult() :
  21. ServiceResult()
  22. {}
  23. DescribeClusterServiceConfigResult::DescribeClusterServiceConfigResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeClusterServiceConfigResult::~DescribeClusterServiceConfigResult()
  29. {}
  30. void DescribeClusterServiceConfigResult::parse(const std::string &payload)
  31. {
  32. Json::CharReaderBuilder builder;
  33. Json::CharReader *reader = builder.newCharReader();
  34. Json::Value *val;
  35. Json::Value value;
  36. JSONCPP_STRING *errs;
  37. reader->parse(payload.data(), payload.data() + payload.size(), val, errs);
  38. value = *val;
  39. setRequestId(value["RequestId"].asString());
  40. auto configNode = value["Config"];
  41. if(!configNode["ServiceName"].isNull())
  42. config_.serviceName = configNode["ServiceName"].asString();
  43. if(!configNode["ConfigVersion"].isNull())
  44. config_.configVersion = configNode["ConfigVersion"].asString();
  45. if(!configNode["Applied"].isNull())
  46. config_.applied = configNode["Applied"].asString();
  47. if(!configNode["CreateTime"].isNull())
  48. config_.createTime = configNode["CreateTime"].asString();
  49. if(!configNode["Author"].isNull())
  50. config_.author = configNode["Author"].asString();
  51. if(!configNode["Comment"].isNull())
  52. config_.comment = configNode["Comment"].asString();
  53. auto allConfigValueList = value["ConfigValueList"]["ConfigValue"];
  54. for (auto value : allConfigValueList)
  55. {
  56. Config::ConfigValue configValueObject;
  57. if(!value["ConfigName"].isNull())
  58. configValueObject.configName = value["ConfigName"].asString();
  59. if(!value["AllowCustom"].isNull())
  60. configValueObject.allowCustom = value["AllowCustom"].asString() == "true";
  61. auto allConfigItemValueList = value["ConfigItemValueList"]["ConfigItemValue"];
  62. for (auto value : allConfigItemValueList)
  63. {
  64. Config::ConfigValue::ConfigItemValue configItemValueListObject;
  65. if(!value["ItemName"].isNull())
  66. configItemValueListObject.itemName = value["ItemName"].asString();
  67. if(!value["Value"].isNull())
  68. configItemValueListObject.value = value["Value"].asString();
  69. if(!value["IsCustom"].isNull())
  70. configItemValueListObject.isCustom = value["IsCustom"].asString() == "true";
  71. if(!value["Description"].isNull())
  72. configItemValueListObject.description = value["Description"].asString();
  73. configValueObject.configItemValueList.push_back(configItemValueListObject);
  74. }
  75. config_.configValueList.push_back(configValueObject);
  76. }
  77. auto allPropertyInfoList = value["PropertyInfoList"]["PropertyInfo"];
  78. for (auto value : allPropertyInfoList)
  79. {
  80. Config::PropertyInfo propertyInfoObject;
  81. if(!value["Name"].isNull())
  82. propertyInfoObject.name = value["Name"].asString();
  83. if(!value["Value"].isNull())
  84. propertyInfoObject.value = value["Value"].asString();
  85. if(!value["Description"].isNull())
  86. propertyInfoObject.description = value["Description"].asString();
  87. if(!value["FileName"].isNull())
  88. propertyInfoObject.fileName = value["FileName"].asString();
  89. if(!value["DisplayName"].isNull())
  90. propertyInfoObject.displayName = value["DisplayName"].asString();
  91. if(!value["ServiceName"].isNull())
  92. propertyInfoObject.serviceName = value["ServiceName"].asString();
  93. if(!value["Component"].isNull())
  94. propertyInfoObject.component = value["Component"].asString();
  95. auto propertyValueAttributesNode = value["PropertyValueAttributes"];
  96. if(!propertyValueAttributesNode["Type"].isNull())
  97. propertyInfoObject.propertyValueAttributes.type = propertyValueAttributesNode["Type"].asString();
  98. if(!propertyValueAttributesNode["Maximum"].isNull())
  99. propertyInfoObject.propertyValueAttributes.maximum = propertyValueAttributesNode["Maximum"].asString();
  100. if(!propertyValueAttributesNode["Mimimum"].isNull())
  101. propertyInfoObject.propertyValueAttributes.mimimum = propertyValueAttributesNode["Mimimum"].asString();
  102. if(!propertyValueAttributesNode["Unit"].isNull())
  103. propertyInfoObject.propertyValueAttributes.unit = propertyValueAttributesNode["Unit"].asString();
  104. if(!propertyValueAttributesNode["ReadOnly"].isNull())
  105. propertyInfoObject.propertyValueAttributes.readOnly = propertyValueAttributesNode["ReadOnly"].asString() == "true";
  106. if(!propertyValueAttributesNode["Hidden"].isNull())
  107. propertyInfoObject.propertyValueAttributes.hidden = propertyValueAttributesNode["Hidden"].asString() == "true";
  108. if(!propertyValueAttributesNode["IncrememtStep"].isNull())
  109. propertyInfoObject.propertyValueAttributes.incrememtStep = propertyValueAttributesNode["IncrememtStep"].asString();
  110. auto allEntries = value["Entries"]["ValueEntryInfo"];
  111. for (auto value : allEntries)
  112. {
  113. Config::PropertyInfo::PropertyValueAttributes::ValueEntryInfo valueEntryInfoObject;
  114. if(!value["Value"].isNull())
  115. valueEntryInfoObject.value = value["Value"].asString();
  116. if(!value["Label"].isNull())
  117. valueEntryInfoObject.label = value["Label"].asString();
  118. if(!value["Description"].isNull())
  119. valueEntryInfoObject.description = value["Description"].asString();
  120. propertyInfoObject.propertyValueAttributes.entries.push_back(valueEntryInfoObject);
  121. }
  122. auto effectWayNode = value["EffectWay"];
  123. if(!effectWayNode["EffectType"].isNull())
  124. propertyInfoObject.effectWay.effectType = effectWayNode["EffectType"].asString();
  125. if(!effectWayNode["InvokeServiceName"].isNull())
  126. propertyInfoObject.effectWay.invokeServiceName = effectWayNode["InvokeServiceName"].asString();
  127. auto allPropertyTypes = value["PropertyTypes"]["propertyType"];
  128. for (auto value : allPropertyTypes)
  129. propertyInfoObject.propertyTypes.push_back(value.asString());
  130. config_.propertyInfoList.push_back(propertyInfoObject);
  131. }
  132. }
  133. DescribeClusterServiceConfigResult::Config DescribeClusterServiceConfigResult::getConfig()const
  134. {
  135. return config_;
  136. }