ListInstanceResult.cc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/foas/model/ListInstanceResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Foas;
  19. using namespace AlibabaCloud::Foas::Model;
  20. ListInstanceResult::ListInstanceResult() :
  21. ServiceResult()
  22. {}
  23. ListInstanceResult::ListInstanceResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListInstanceResult::~ListInstanceResult()
  29. {}
  30. void ListInstanceResult::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 allInstancesNode = value["Instances"]["Instance"];
  37. for (auto valueInstancesInstance : allInstancesNode)
  38. {
  39. Instance instancesObject;
  40. if(!valueInstancesInstance["Id"].isNull())
  41. instancesObject.id = std::stol(valueInstancesInstance["Id"].asString());
  42. if(!valueInstancesInstance["ProjectName"].isNull())
  43. instancesObject.projectName = valueInstancesInstance["ProjectName"].asString();
  44. if(!valueInstancesInstance["JobName"].isNull())
  45. instancesObject.jobName = valueInstancesInstance["JobName"].asString();
  46. if(!valueInstancesInstance["ActualState"].isNull())
  47. instancesObject.actualState = valueInstancesInstance["ActualState"].asString();
  48. if(!valueInstancesInstance["ExpectState"].isNull())
  49. instancesObject.expectState = valueInstancesInstance["ExpectState"].asString();
  50. if(!valueInstancesInstance["JobType"].isNull())
  51. instancesObject.jobType = valueInstancesInstance["JobType"].asString();
  52. if(!valueInstancesInstance["ApiType"].isNull())
  53. instancesObject.apiType = valueInstancesInstance["ApiType"].asString();
  54. if(!valueInstancesInstance["Code"].isNull())
  55. instancesObject.code = valueInstancesInstance["Code"].asString();
  56. if(!valueInstancesInstance["Properties"].isNull())
  57. instancesObject.properties = valueInstancesInstance["Properties"].asString();
  58. if(!valueInstancesInstance["Packages"].isNull())
  59. instancesObject.packages = valueInstancesInstance["Packages"].asString();
  60. if(!valueInstancesInstance["Starter"].isNull())
  61. instancesObject.starter = valueInstancesInstance["Starter"].asString();
  62. if(!valueInstancesInstance["StartTime"].isNull())
  63. instancesObject.startTime = std::stol(valueInstancesInstance["StartTime"].asString());
  64. if(!valueInstancesInstance["LastErrorTime"].isNull())
  65. instancesObject.lastErrorTime = std::stol(valueInstancesInstance["LastErrorTime"].asString());
  66. if(!valueInstancesInstance["LastErrorMessage"].isNull())
  67. instancesObject.lastErrorMessage = valueInstancesInstance["LastErrorMessage"].asString();
  68. if(!valueInstancesInstance["LastOperator"].isNull())
  69. instancesObject.lastOperator = valueInstancesInstance["LastOperator"].asString();
  70. if(!valueInstancesInstance["LastOperateTime"].isNull())
  71. instancesObject.lastOperateTime = std::stol(valueInstancesInstance["LastOperateTime"].asString());
  72. if(!valueInstancesInstance["PlanJson"].isNull())
  73. instancesObject.planJson = valueInstancesInstance["PlanJson"].asString();
  74. if(!valueInstancesInstance["EngineVersion"].isNull())
  75. instancesObject.engineVersion = valueInstancesInstance["EngineVersion"].asString();
  76. if(!valueInstancesInstance["EngineJobHandler"].isNull())
  77. instancesObject.engineJobHandler = valueInstancesInstance["EngineJobHandler"].asString();
  78. if(!valueInstancesInstance["InputDelay"].isNull())
  79. instancesObject.inputDelay = std::stol(valueInstancesInstance["InputDelay"].asString());
  80. if(!valueInstancesInstance["ClusterId"].isNull())
  81. instancesObject.clusterId = valueInstancesInstance["ClusterId"].asString();
  82. if(!valueInstancesInstance["QueueName"].isNull())
  83. instancesObject.queueName = valueInstancesInstance["QueueName"].asString();
  84. if(!valueInstancesInstance["EndTime"].isNull())
  85. instancesObject.endTime = std::stol(valueInstancesInstance["EndTime"].asString());
  86. instances_.push_back(instancesObject);
  87. }
  88. if(!value["PageIndex"].isNull())
  89. pageIndex_ = std::stoi(value["PageIndex"].asString());
  90. if(!value["PageSize"].isNull())
  91. pageSize_ = std::stoi(value["PageSize"].asString());
  92. if(!value["TotalPage"].isNull())
  93. totalPage_ = std::stoi(value["TotalPage"].asString());
  94. if(!value["TotalCount"].isNull())
  95. totalCount_ = std::stol(value["TotalCount"].asString());
  96. }
  97. std::vector<ListInstanceResult::Instance> ListInstanceResult::getInstances()const
  98. {
  99. return instances_;
  100. }
  101. long ListInstanceResult::getTotalCount()const
  102. {
  103. return totalCount_;
  104. }
  105. int ListInstanceResult::getPageSize()const
  106. {
  107. return pageSize_;
  108. }
  109. int ListInstanceResult::getTotalPage()const
  110. {
  111. return totalPage_;
  112. }
  113. int ListInstanceResult::getPageIndex()const
  114. {
  115. return pageIndex_;
  116. }