DescribeEmrMainVersionResult.cc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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/DescribeEmrMainVersionResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Emr;
  19. using namespace AlibabaCloud::Emr::Model;
  20. DescribeEmrMainVersionResult::DescribeEmrMainVersionResult() :
  21. ServiceResult()
  22. {}
  23. DescribeEmrMainVersionResult::DescribeEmrMainVersionResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeEmrMainVersionResult::~DescribeEmrMainVersionResult()
  29. {}
  30. void DescribeEmrMainVersionResult::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 emrMainVersionNode = value["EmrMainVersion"];
  37. if(!emrMainVersionNode["RegionId"].isNull())
  38. emrMainVersion_.regionId = emrMainVersionNode["RegionId"].asString();
  39. if(!emrMainVersionNode["EmrVersion"].isNull())
  40. emrMainVersion_.emrVersion = emrMainVersionNode["EmrVersion"].asString();
  41. if(!emrMainVersionNode["EcmVersion"].isNull())
  42. emrMainVersion_.ecmVersion = emrMainVersionNode["EcmVersion"].asString() == "true";
  43. if(!emrMainVersionNode["ImageId"].isNull())
  44. emrMainVersion_.imageId = emrMainVersionNode["ImageId"].asString();
  45. if(!emrMainVersionNode["Display"].isNull())
  46. emrMainVersion_.display = emrMainVersionNode["Display"].asString() == "true";
  47. if(!emrMainVersionNode["StackName"].isNull())
  48. emrMainVersion_.stackName = emrMainVersionNode["StackName"].asString();
  49. if(!emrMainVersionNode["StackVersion"].isNull())
  50. emrMainVersion_.stackVersion = emrMainVersionNode["StackVersion"].asString();
  51. auto allClusterTypeInfoListNode = emrMainVersionNode["ClusterTypeInfoList"]["ClusterTypeInfo"];
  52. for (auto emrMainVersionNodeClusterTypeInfoListClusterTypeInfo : allClusterTypeInfoListNode)
  53. {
  54. EmrMainVersion::ClusterTypeInfo clusterTypeInfoObject;
  55. if(!emrMainVersionNodeClusterTypeInfoListClusterTypeInfo["ClusterType"].isNull())
  56. clusterTypeInfoObject.clusterType = emrMainVersionNodeClusterTypeInfoListClusterTypeInfo["ClusterType"].asString();
  57. auto allServiceInfoListNode = allClusterTypeInfoListNode["ServiceInfoList"]["ServiceInfo"];
  58. for (auto allClusterTypeInfoListNodeServiceInfoListServiceInfo : allServiceInfoListNode)
  59. {
  60. EmrMainVersion::ClusterTypeInfo::ServiceInfo serviceInfoListObject;
  61. if(!allClusterTypeInfoListNodeServiceInfoListServiceInfo["ServiceName"].isNull())
  62. serviceInfoListObject.serviceName = allClusterTypeInfoListNodeServiceInfoListServiceInfo["ServiceName"].asString();
  63. if(!allClusterTypeInfoListNodeServiceInfoListServiceInfo["ServiceDisplayName"].isNull())
  64. serviceInfoListObject.serviceDisplayName = allClusterTypeInfoListNodeServiceInfoListServiceInfo["ServiceDisplayName"].asString();
  65. if(!allClusterTypeInfoListNodeServiceInfoListServiceInfo["ServiceVersion"].isNull())
  66. serviceInfoListObject.serviceVersion = allClusterTypeInfoListNodeServiceInfoListServiceInfo["ServiceVersion"].asString();
  67. if(!allClusterTypeInfoListNodeServiceInfoListServiceInfo["ServiceDisplayVersion"].isNull())
  68. serviceInfoListObject.serviceDisplayVersion = allClusterTypeInfoListNodeServiceInfoListServiceInfo["ServiceDisplayVersion"].asString();
  69. if(!allClusterTypeInfoListNodeServiceInfoListServiceInfo["Mandatory"].isNull())
  70. serviceInfoListObject.mandatory = allClusterTypeInfoListNodeServiceInfoListServiceInfo["Mandatory"].asString() == "true";
  71. if(!allClusterTypeInfoListNodeServiceInfoListServiceInfo["Display"].isNull())
  72. serviceInfoListObject.display = allClusterTypeInfoListNodeServiceInfoListServiceInfo["Display"].asString() == "true";
  73. clusterTypeInfoObject.serviceInfoList.push_back(serviceInfoListObject);
  74. }
  75. emrMainVersion_.clusterTypeInfoList.push_back(clusterTypeInfoObject);
  76. }
  77. auto allWhiteUserList = emrMainVersionNode["WhiteUserList"]["WwhiteUser"];
  78. for (auto value : allWhiteUserList)
  79. emrMainVersion_.whiteUserList.push_back(value.asString());
  80. }
  81. DescribeEmrMainVersionResult::EmrMainVersion DescribeEmrMainVersionResult::getEmrMainVersion()const
  82. {
  83. return emrMainVersion_;
  84. }