ListClusterServiceConfigHistoryResult.cc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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/ListClusterServiceConfigHistoryResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Emr;
  19. using namespace AlibabaCloud::Emr::Model;
  20. ListClusterServiceConfigHistoryResult::ListClusterServiceConfigHistoryResult() :
  21. ServiceResult()
  22. {}
  23. ListClusterServiceConfigHistoryResult::ListClusterServiceConfigHistoryResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListClusterServiceConfigHistoryResult::~ListClusterServiceConfigHistoryResult()
  29. {}
  30. void ListClusterServiceConfigHistoryResult::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 allConfigHistoryListNode = value["ConfigHistoryList"]["ConfigHistory"];
  37. for (auto valueConfigHistoryListConfigHistory : allConfigHistoryListNode)
  38. {
  39. ConfigHistory configHistoryListObject;
  40. if(!valueConfigHistoryListConfigHistory["ServiceName"].isNull())
  41. configHistoryListObject.serviceName = valueConfigHistoryListConfigHistory["ServiceName"].asString();
  42. if(!valueConfigHistoryListConfigHistory["ConfigVersion"].isNull())
  43. configHistoryListObject.configVersion = valueConfigHistoryListConfigHistory["ConfigVersion"].asString();
  44. if(!valueConfigHistoryListConfigHistory["ConfigFileName"].isNull())
  45. configHistoryListObject.configFileName = valueConfigHistoryListConfigHistory["ConfigFileName"].asString();
  46. if(!valueConfigHistoryListConfigHistory["ConfigItemName"].isNull())
  47. configHistoryListObject.configItemName = valueConfigHistoryListConfigHistory["ConfigItemName"].asString();
  48. if(!valueConfigHistoryListConfigHistory["NewValue"].isNull())
  49. configHistoryListObject.newValue = valueConfigHistoryListConfigHistory["NewValue"].asString();
  50. if(!valueConfigHistoryListConfigHistory["OldValue"].isNull())
  51. configHistoryListObject.oldValue = valueConfigHistoryListConfigHistory["OldValue"].asString();
  52. if(!valueConfigHistoryListConfigHistory["Applied"].isNull())
  53. configHistoryListObject.applied = valueConfigHistoryListConfigHistory["Applied"].asString() == "true";
  54. if(!valueConfigHistoryListConfigHistory["CreateTime"].isNull())
  55. configHistoryListObject.createTime = std::stol(valueConfigHistoryListConfigHistory["CreateTime"].asString());
  56. if(!valueConfigHistoryListConfigHistory["Author"].isNull())
  57. configHistoryListObject.author = valueConfigHistoryListConfigHistory["Author"].asString();
  58. if(!valueConfigHistoryListConfigHistory["Comment"].isNull())
  59. configHistoryListObject.comment = valueConfigHistoryListConfigHistory["Comment"].asString();
  60. if(!valueConfigHistoryListConfigHistory["HostGroupId"].isNull())
  61. configHistoryListObject.hostGroupId = valueConfigHistoryListConfigHistory["HostGroupId"].asString();
  62. if(!valueConfigHistoryListConfigHistory["HostGroupName"].isNull())
  63. configHistoryListObject.hostGroupName = valueConfigHistoryListConfigHistory["HostGroupName"].asString();
  64. if(!valueConfigHistoryListConfigHistory["HostInstanceId"].isNull())
  65. configHistoryListObject.hostInstanceId = valueConfigHistoryListConfigHistory["HostInstanceId"].asString();
  66. if(!valueConfigHistoryListConfigHistory["HostName"].isNull())
  67. configHistoryListObject.hostName = valueConfigHistoryListConfigHistory["HostName"].asString();
  68. configHistoryList_.push_back(configHistoryListObject);
  69. }
  70. if(!value["TotalCount"].isNull())
  71. totalCount_ = std::stoi(value["TotalCount"].asString());
  72. if(!value["PageNumber"].isNull())
  73. pageNumber_ = std::stoi(value["PageNumber"].asString());
  74. if(!value["PageSize"].isNull())
  75. pageSize_ = std::stoi(value["PageSize"].asString());
  76. }
  77. std::vector<ListClusterServiceConfigHistoryResult::ConfigHistory> ListClusterServiceConfigHistoryResult::getConfigHistoryList()const
  78. {
  79. return configHistoryList_;
  80. }
  81. int ListClusterServiceConfigHistoryResult::getTotalCount()const
  82. {
  83. return totalCount_;
  84. }
  85. int ListClusterServiceConfigHistoryResult::getPageSize()const
  86. {
  87. return pageSize_;
  88. }
  89. int ListClusterServiceConfigHistoryResult::getPageNumber()const
  90. {
  91. return pageNumber_;
  92. }