ListJobsResult.cc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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/ehpc/model/ListJobsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::EHPC;
  19. using namespace AlibabaCloud::EHPC::Model;
  20. ListJobsResult::ListJobsResult() :
  21. ServiceResult()
  22. {}
  23. ListJobsResult::ListJobsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListJobsResult::~ListJobsResult()
  29. {}
  30. void ListJobsResult::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 allJobsNode = value["Jobs"]["JobInfo"];
  37. for (auto valueJobsJobInfo : allJobsNode)
  38. {
  39. JobInfo jobsObject;
  40. if(!valueJobsJobInfo["Id"].isNull())
  41. jobsObject.id = valueJobsJobInfo["Id"].asString();
  42. if(!valueJobsJobInfo["Name"].isNull())
  43. jobsObject.name = valueJobsJobInfo["Name"].asString();
  44. if(!valueJobsJobInfo["Owner"].isNull())
  45. jobsObject.owner = valueJobsJobInfo["Owner"].asString();
  46. if(!valueJobsJobInfo["NodeList"].isNull())
  47. jobsObject.nodeList = valueJobsJobInfo["NodeList"].asString();
  48. if(!valueJobsJobInfo["Priority"].isNull())
  49. jobsObject.priority = valueJobsJobInfo["Priority"].asString();
  50. if(!valueJobsJobInfo["State"].isNull())
  51. jobsObject.state = valueJobsJobInfo["State"].asString();
  52. if(!valueJobsJobInfo["SubmitTime"].isNull())
  53. jobsObject.submitTime = valueJobsJobInfo["SubmitTime"].asString();
  54. if(!valueJobsJobInfo["StartTime"].isNull())
  55. jobsObject.startTime = valueJobsJobInfo["StartTime"].asString();
  56. if(!valueJobsJobInfo["LastModifyTime"].isNull())
  57. jobsObject.lastModifyTime = valueJobsJobInfo["LastModifyTime"].asString();
  58. if(!valueJobsJobInfo["Stdout"].isNull())
  59. jobsObject._stdout = valueJobsJobInfo["Stdout"].asString();
  60. if(!valueJobsJobInfo["Stderr"].isNull())
  61. jobsObject._stderr = valueJobsJobInfo["Stderr"].asString();
  62. if(!valueJobsJobInfo["ShellPath"].isNull())
  63. jobsObject.shellPath = valueJobsJobInfo["ShellPath"].asString();
  64. if(!valueJobsJobInfo["Comment"].isNull())
  65. jobsObject.comment = valueJobsJobInfo["Comment"].asString();
  66. if(!valueJobsJobInfo["ArrayRequest"].isNull())
  67. jobsObject.arrayRequest = valueJobsJobInfo["ArrayRequest"].asString();
  68. auto resourcesNode = value["Resources"];
  69. if(!resourcesNode["Nodes"].isNull())
  70. jobsObject.resources.nodes = std::stoi(resourcesNode["Nodes"].asString());
  71. if(!resourcesNode["Cores"].isNull())
  72. jobsObject.resources.cores = std::stoi(resourcesNode["Cores"].asString());
  73. jobs_.push_back(jobsObject);
  74. }
  75. if(!value["TotalCount"].isNull())
  76. totalCount_ = std::stoi(value["TotalCount"].asString());
  77. if(!value["PageNumber"].isNull())
  78. pageNumber_ = std::stoi(value["PageNumber"].asString());
  79. if(!value["PageSize"].isNull())
  80. pageSize_ = std::stoi(value["PageSize"].asString());
  81. }
  82. int ListJobsResult::getTotalCount()const
  83. {
  84. return totalCount_;
  85. }
  86. int ListJobsResult::getPageSize()const
  87. {
  88. return pageSize_;
  89. }
  90. std::vector<ListJobsResult::JobInfo> ListJobsResult::getJobs()const
  91. {
  92. return jobs_;
  93. }
  94. int ListJobsResult::getPageNumber()const
  95. {
  96. return pageNumber_;
  97. }