ListApmApplicationResult.cc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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/ListApmApplicationResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Emr;
  19. using namespace AlibabaCloud::Emr::Model;
  20. ListApmApplicationResult::ListApmApplicationResult() :
  21. ServiceResult()
  22. {}
  23. ListApmApplicationResult::ListApmApplicationResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListApmApplicationResult::~ListApmApplicationResult()
  29. {}
  30. void ListApmApplicationResult::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 allApmAppInfoListNode = value["ApmAppInfoList"]["ApmAppInfo"];
  37. for (auto valueApmAppInfoListApmAppInfo : allApmAppInfoListNode)
  38. {
  39. ApmAppInfo apmAppInfoListObject;
  40. if(!valueApmAppInfoListApmAppInfo["ApplicationId"].isNull())
  41. apmAppInfoListObject.applicationId = valueApmAppInfoListApmAppInfo["ApplicationId"].asString();
  42. if(!valueApmAppInfoListApmAppInfo["ClusterBizId"].isNull())
  43. apmAppInfoListObject.clusterBizId = valueApmAppInfoListApmAppInfo["ClusterBizId"].asString();
  44. if(!valueApmAppInfoListApmAppInfo["ApplicationType"].isNull())
  45. apmAppInfoListObject.applicationType = valueApmAppInfoListApmAppInfo["ApplicationType"].asString();
  46. if(!valueApmAppInfoListApmAppInfo["Name"].isNull())
  47. apmAppInfoListObject.name = valueApmAppInfoListApmAppInfo["Name"].asString();
  48. if(!valueApmAppInfoListApmAppInfo["State"].isNull())
  49. apmAppInfoListObject.state = valueApmAppInfoListApmAppInfo["State"].asString();
  50. if(!valueApmAppInfoListApmAppInfo["FinalStatus"].isNull())
  51. apmAppInfoListObject.finalStatus = valueApmAppInfoListApmAppInfo["FinalStatus"].asString();
  52. if(!valueApmAppInfoListApmAppInfo["Queue"].isNull())
  53. apmAppInfoListObject.queue = valueApmAppInfoListApmAppInfo["Queue"].asString();
  54. if(!valueApmAppInfoListApmAppInfo["User"].isNull())
  55. apmAppInfoListObject.user = valueApmAppInfoListApmAppInfo["User"].asString();
  56. if(!valueApmAppInfoListApmAppInfo["AllocatedVcore"].isNull())
  57. apmAppInfoListObject.allocatedVcore = std::stol(valueApmAppInfoListApmAppInfo["AllocatedVcore"].asString());
  58. if(!valueApmAppInfoListApmAppInfo["AllocatedMemory"].isNull())
  59. apmAppInfoListObject.allocatedMemory = std::stol(valueApmAppInfoListApmAppInfo["AllocatedMemory"].asString());
  60. if(!valueApmAppInfoListApmAppInfo["Progress"].isNull())
  61. apmAppInfoListObject.progress = std::stof(valueApmAppInfoListApmAppInfo["Progress"].asString());
  62. if(!valueApmAppInfoListApmAppInfo["VcoreSeconds"].isNull())
  63. apmAppInfoListObject.vcoreSeconds = std::stol(valueApmAppInfoListApmAppInfo["VcoreSeconds"].asString());
  64. if(!valueApmAppInfoListApmAppInfo["MemorySeconds"].isNull())
  65. apmAppInfoListObject.memorySeconds = std::stol(valueApmAppInfoListApmAppInfo["MemorySeconds"].asString());
  66. if(!valueApmAppInfoListApmAppInfo["StartTime"].isNull())
  67. apmAppInfoListObject.startTime = std::stol(valueApmAppInfoListApmAppInfo["StartTime"].asString());
  68. if(!valueApmAppInfoListApmAppInfo["SubmitTime"].isNull())
  69. apmAppInfoListObject.submitTime = std::stol(valueApmAppInfoListApmAppInfo["SubmitTime"].asString());
  70. if(!valueApmAppInfoListApmAppInfo["FinishedTime"].isNull())
  71. apmAppInfoListObject.finishedTime = std::stol(valueApmAppInfoListApmAppInfo["FinishedTime"].asString());
  72. if(!valueApmAppInfoListApmAppInfo["Duration"].isNull())
  73. apmAppInfoListObject.duration = std::stoi(valueApmAppInfoListApmAppInfo["Duration"].asString());
  74. if(!valueApmAppInfoListApmAppInfo["Diagnostics"].isNull())
  75. apmAppInfoListObject.diagnostics = valueApmAppInfoListApmAppInfo["Diagnostics"].asString();
  76. if(!valueApmAppInfoListApmAppInfo["ClusterUsagePercent"].isNull())
  77. apmAppInfoListObject.clusterUsagePercent = std::stof(valueApmAppInfoListApmAppInfo["ClusterUsagePercent"].asString());
  78. if(!valueApmAppInfoListApmAppInfo["QueueUsagePercent"].isNull())
  79. apmAppInfoListObject.queueUsagePercent = std::stof(valueApmAppInfoListApmAppInfo["QueueUsagePercent"].asString());
  80. if(!valueApmAppInfoListApmAppInfo["RunningContainers"].isNull())
  81. apmAppInfoListObject.runningContainers = std::stoi(valueApmAppInfoListApmAppInfo["RunningContainers"].asString());
  82. if(!valueApmAppInfoListApmAppInfo["RunningDuration"].isNull())
  83. apmAppInfoListObject.runningDuration = std::stoi(valueApmAppInfoListApmAppInfo["RunningDuration"].asString());
  84. if(!valueApmAppInfoListApmAppInfo["ResourceRequests"].isNull())
  85. apmAppInfoListObject.resourceRequests = valueApmAppInfoListApmAppInfo["ResourceRequests"].asString();
  86. if(!valueApmAppInfoListApmAppInfo["DiagnoseResult"].isNull())
  87. apmAppInfoListObject.diagnoseResult = valueApmAppInfoListApmAppInfo["DiagnoseResult"].asString();
  88. if(!valueApmAppInfoListApmAppInfo["DiagnoseCode"].isNull())
  89. apmAppInfoListObject.diagnoseCode = valueApmAppInfoListApmAppInfo["DiagnoseCode"].asString();
  90. apmAppInfoList_.push_back(apmAppInfoListObject);
  91. }
  92. if(!value["Total"].isNull())
  93. total_ = std::stoi(value["Total"].asString());
  94. if(!value["PageSize"].isNull())
  95. pageSize_ = std::stoi(value["PageSize"].asString());
  96. if(!value["PageNumber"].isNull())
  97. pageNumber_ = std::stoi(value["PageNumber"].asString());
  98. }
  99. std::vector<ListApmApplicationResult::ApmAppInfo> ListApmApplicationResult::getApmAppInfoList()const
  100. {
  101. return apmAppInfoList_;
  102. }
  103. int ListApmApplicationResult::getPageSize()const
  104. {
  105. return pageSize_;
  106. }
  107. int ListApmApplicationResult::getPageNumber()const
  108. {
  109. return pageNumber_;
  110. }
  111. int ListApmApplicationResult::getTotal()const
  112. {
  113. return total_;
  114. }