ListFlowClusterAllResult.cc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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/ListFlowClusterAllResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Emr;
  19. using namespace AlibabaCloud::Emr::Model;
  20. ListFlowClusterAllResult::ListFlowClusterAllResult() :
  21. ServiceResult()
  22. {}
  23. ListFlowClusterAllResult::ListFlowClusterAllResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListFlowClusterAllResult::~ListFlowClusterAllResult()
  29. {}
  30. void ListFlowClusterAllResult::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 allClusters = value["Clusters"]["ClusterInfo"];
  41. for (auto value : allClusters)
  42. {
  43. ClusterInfo clustersObject;
  44. if(!value["Id"].isNull())
  45. clustersObject.id = value["Id"].asString();
  46. if(!value["Name"].isNull())
  47. clustersObject.name = value["Name"].asString();
  48. if(!value["Type"].isNull())
  49. clustersObject.type = value["Type"].asString();
  50. if(!value["CreateTime"].isNull())
  51. clustersObject.createTime = std::stol(value["CreateTime"].asString());
  52. if(!value["RunningTime"].isNull())
  53. clustersObject.runningTime = std::stoi(value["RunningTime"].asString());
  54. if(!value["Status"].isNull())
  55. clustersObject.status = value["Status"].asString();
  56. if(!value["ChargeType"].isNull())
  57. clustersObject.chargeType = value["ChargeType"].asString();
  58. if(!value["ExpiredTime"].isNull())
  59. clustersObject.expiredTime = std::stol(value["ExpiredTime"].asString());
  60. if(!value["Period"].isNull())
  61. clustersObject.period = std::stoi(value["Period"].asString());
  62. if(!value["HasUncompletedOrder"].isNull())
  63. clustersObject.hasUncompletedOrder = value["HasUncompletedOrder"].asString() == "true";
  64. if(!value["OrderList"].isNull())
  65. clustersObject.orderList = value["OrderList"].asString();
  66. if(!value["CreateResource"].isNull())
  67. clustersObject.createResource = value["CreateResource"].asString();
  68. auto orderTaskInfoNode = value["OrderTaskInfo"];
  69. if(!orderTaskInfoNode["TargetCount"].isNull())
  70. clustersObject.orderTaskInfo.targetCount = std::stoi(orderTaskInfoNode["TargetCount"].asString());
  71. if(!orderTaskInfoNode["CurrentCount"].isNull())
  72. clustersObject.orderTaskInfo.currentCount = std::stoi(orderTaskInfoNode["CurrentCount"].asString());
  73. if(!orderTaskInfoNode["OrderIdList"].isNull())
  74. clustersObject.orderTaskInfo.orderIdList = orderTaskInfoNode["OrderIdList"].asString();
  75. auto failReasonNode = value["FailReason"];
  76. if(!failReasonNode["ErrorCode"].isNull())
  77. clustersObject.failReason.errorCode = failReasonNode["ErrorCode"].asString();
  78. if(!failReasonNode["ErrorMsg"].isNull())
  79. clustersObject.failReason.errorMsg = failReasonNode["ErrorMsg"].asString();
  80. if(!failReasonNode["RequestId"].isNull())
  81. clustersObject.failReason.requestId = failReasonNode["RequestId"].asString();
  82. clusters_.push_back(clustersObject);
  83. }
  84. if(!value["TotalCount"].isNull())
  85. totalCount_ = std::stoi(value["TotalCount"].asString());
  86. if(!value["PageNumber"].isNull())
  87. pageNumber_ = std::stoi(value["PageNumber"].asString());
  88. if(!value["PageSize"].isNull())
  89. pageSize_ = std::stoi(value["PageSize"].asString());
  90. }
  91. int ListFlowClusterAllResult::getTotalCount()const
  92. {
  93. return totalCount_;
  94. }
  95. int ListFlowClusterAllResult::getPageSize()const
  96. {
  97. return pageSize_;
  98. }
  99. int ListFlowClusterAllResult::getPageNumber()const
  100. {
  101. return pageNumber_;
  102. }
  103. std::vector<ListFlowClusterAllResult::ClusterInfo> ListFlowClusterAllResult::getClusters()const
  104. {
  105. return clusters_;
  106. }