ListPromClustersResult.cc 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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/arms/model/ListPromClustersResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::ARMS;
  19. using namespace AlibabaCloud::ARMS::Model;
  20. ListPromClustersResult::ListPromClustersResult() :
  21. ServiceResult()
  22. {}
  23. ListPromClustersResult::ListPromClustersResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListPromClustersResult::~ListPromClustersResult()
  29. {}
  30. void ListPromClustersResult::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 allPromClusterListNode = value["PromClusterList"]["PromCluster"];
  37. for (auto valuePromClusterListPromCluster : allPromClusterListNode)
  38. {
  39. PromCluster promClusterListObject;
  40. if(!valuePromClusterListPromCluster["Id"].isNull())
  41. promClusterListObject.id = std::stol(valuePromClusterListPromCluster["Id"].asString());
  42. if(!valuePromClusterListPromCluster["ClusterId"].isNull())
  43. promClusterListObject.clusterId = valuePromClusterListPromCluster["ClusterId"].asString();
  44. if(!valuePromClusterListPromCluster["ClusterName"].isNull())
  45. promClusterListObject.clusterName = valuePromClusterListPromCluster["ClusterName"].asString();
  46. if(!valuePromClusterListPromCluster["AgentStatus"].isNull())
  47. promClusterListObject.agentStatus = valuePromClusterListPromCluster["AgentStatus"].asString();
  48. if(!valuePromClusterListPromCluster["ClusterType"].isNull())
  49. promClusterListObject.clusterType = valuePromClusterListPromCluster["ClusterType"].asString();
  50. if(!valuePromClusterListPromCluster["ControllerId"].isNull())
  51. promClusterListObject.controllerId = valuePromClusterListPromCluster["ControllerId"].asString();
  52. if(!valuePromClusterListPromCluster["IsControllerInstalled"].isNull())
  53. promClusterListObject.isControllerInstalled = valuePromClusterListPromCluster["IsControllerInstalled"].asString() == "true";
  54. if(!valuePromClusterListPromCluster["UserId"].isNull())
  55. promClusterListObject.userId = valuePromClusterListPromCluster["UserId"].asString();
  56. if(!valuePromClusterListPromCluster["RegionId"].isNull())
  57. promClusterListObject.regionId = valuePromClusterListPromCluster["RegionId"].asString();
  58. if(!valuePromClusterListPromCluster["PluginsJsonArray"].isNull())
  59. promClusterListObject.pluginsJsonArray = valuePromClusterListPromCluster["PluginsJsonArray"].asString();
  60. if(!valuePromClusterListPromCluster["StateJson"].isNull())
  61. promClusterListObject.stateJson = valuePromClusterListPromCluster["StateJson"].asString();
  62. if(!valuePromClusterListPromCluster["NodeNum"].isNull())
  63. promClusterListObject.nodeNum = std::stoi(valuePromClusterListPromCluster["NodeNum"].asString());
  64. if(!valuePromClusterListPromCluster["CreateTime"].isNull())
  65. promClusterListObject.createTime = std::stol(valuePromClusterListPromCluster["CreateTime"].asString());
  66. if(!valuePromClusterListPromCluster["UpdateTime"].isNull())
  67. promClusterListObject.updateTime = std::stol(valuePromClusterListPromCluster["UpdateTime"].asString());
  68. if(!valuePromClusterListPromCluster["LastHeartBeatTime"].isNull())
  69. promClusterListObject.lastHeartBeatTime = std::stol(valuePromClusterListPromCluster["LastHeartBeatTime"].asString());
  70. if(!valuePromClusterListPromCluster["InstallTime"].isNull())
  71. promClusterListObject.installTime = std::stol(valuePromClusterListPromCluster["InstallTime"].asString());
  72. if(!valuePromClusterListPromCluster["Extra"].isNull())
  73. promClusterListObject.extra = valuePromClusterListPromCluster["Extra"].asString();
  74. if(!valuePromClusterListPromCluster["Options"].isNull())
  75. promClusterListObject.options = valuePromClusterListPromCluster["Options"].asString();
  76. promClusterList_.push_back(promClusterListObject);
  77. }
  78. }
  79. std::vector<ListPromClustersResult::PromCluster> ListPromClustersResult::getPromClusterList()const
  80. {
  81. return promClusterList_;
  82. }