ListPredictiveJobGroupsResult.cc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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/ccc/model/ListPredictiveJobGroupsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CCC;
  19. using namespace AlibabaCloud::CCC::Model;
  20. ListPredictiveJobGroupsResult::ListPredictiveJobGroupsResult() :
  21. ServiceResult()
  22. {}
  23. ListPredictiveJobGroupsResult::ListPredictiveJobGroupsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListPredictiveJobGroupsResult::~ListPredictiveJobGroupsResult()
  29. {}
  30. void ListPredictiveJobGroupsResult::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 jobGroupsNode = value["JobGroups"];
  37. if(!jobGroupsNode["TotalCount"].isNull())
  38. jobGroups_.totalCount = std::stoi(jobGroupsNode["TotalCount"].asString());
  39. if(!jobGroupsNode["PageNumber"].isNull())
  40. jobGroups_.pageNumber = std::stoi(jobGroupsNode["PageNumber"].asString());
  41. if(!jobGroupsNode["PageSize"].isNull())
  42. jobGroups_.pageSize = std::stoi(jobGroupsNode["PageSize"].asString());
  43. auto allListNode = jobGroupsNode["List"]["JobGroup"];
  44. for (auto jobGroupsNodeListJobGroup : allListNode)
  45. {
  46. JobGroups::JobGroup jobGroupObject;
  47. if(!jobGroupsNodeListJobGroup["JobGroupId"].isNull())
  48. jobGroupObject.jobGroupId = jobGroupsNodeListJobGroup["JobGroupId"].asString();
  49. if(!jobGroupsNodeListJobGroup["InstanceId"].isNull())
  50. jobGroupObject.instanceId = jobGroupsNodeListJobGroup["InstanceId"].asString();
  51. if(!jobGroupsNodeListJobGroup["SkillGroupId"].isNull())
  52. jobGroupObject.skillGroupId = jobGroupsNodeListJobGroup["SkillGroupId"].asString();
  53. if(!jobGroupsNodeListJobGroup["SkillGroupName"].isNull())
  54. jobGroupObject.skillGroupName = jobGroupsNodeListJobGroup["SkillGroupName"].asString();
  55. if(!jobGroupsNodeListJobGroup["TaskType"].isNull())
  56. jobGroupObject.taskType = jobGroupsNodeListJobGroup["TaskType"].asString();
  57. if(!jobGroupsNodeListJobGroup["OccupancyRate"].isNull())
  58. jobGroupObject.occupancyRate = jobGroupsNodeListJobGroup["OccupancyRate"].asString();
  59. if(!jobGroupsNodeListJobGroup["StartTime"].isNull())
  60. jobGroupObject.startTime = jobGroupsNodeListJobGroup["StartTime"].asString();
  61. if(!jobGroupsNodeListJobGroup["EndTime"].isNull())
  62. jobGroupObject.endTime = jobGroupsNodeListJobGroup["EndTime"].asString();
  63. if(!jobGroupsNodeListJobGroup["Name"].isNull())
  64. jobGroupObject.name = jobGroupsNodeListJobGroup["Name"].asString();
  65. if(!jobGroupsNodeListJobGroup["Description"].isNull())
  66. jobGroupObject.description = jobGroupsNodeListJobGroup["Description"].asString();
  67. if(!jobGroupsNodeListJobGroup["CreationTime"].isNull())
  68. jobGroupObject.creationTime = std::stol(jobGroupsNodeListJobGroup["CreationTime"].asString());
  69. auto strategyNode = value["Strategy"];
  70. if(!strategyNode["StrategyId"].isNull())
  71. jobGroupObject.strategy.strategyId = strategyNode["StrategyId"].asString();
  72. if(!strategyNode["StartTime"].isNull())
  73. jobGroupObject.strategy.startTime = std::stol(strategyNode["StartTime"].asString());
  74. if(!strategyNode["EndTime"].isNull())
  75. jobGroupObject.strategy.endTime = std::stol(strategyNode["EndTime"].asString());
  76. if(!strategyNode["MaxAttemptsPerDay"].isNull())
  77. jobGroupObject.strategy.maxAttemptsPerDay = std::stoi(strategyNode["MaxAttemptsPerDay"].asString());
  78. if(!strategyNode["MinAttemptInterval"].isNull())
  79. jobGroupObject.strategy.minAttemptInterval = std::stoi(strategyNode["MinAttemptInterval"].asString());
  80. auto allWorkingTimeNode = strategyNode["WorkingTime"]["TimeFrame"];
  81. for (auto strategyNodeWorkingTimeTimeFrame : allWorkingTimeNode)
  82. {
  83. JobGroups::JobGroup::Strategy::TimeFrame timeFrameObject;
  84. if(!strategyNodeWorkingTimeTimeFrame["BeginTime"].isNull())
  85. timeFrameObject.beginTime = strategyNodeWorkingTimeTimeFrame["BeginTime"].asString();
  86. if(!strategyNodeWorkingTimeTimeFrame["EndTime"].isNull())
  87. timeFrameObject.endTime = strategyNodeWorkingTimeTimeFrame["EndTime"].asString();
  88. jobGroupObject.strategy.workingTime.push_back(timeFrameObject);
  89. }
  90. auto progressNode = value["Progress"];
  91. if(!progressNode["TotalJobs"].isNull())
  92. jobGroupObject.progress.totalJobs = std::stoi(progressNode["TotalJobs"].asString());
  93. if(!progressNode["Status"].isNull())
  94. jobGroupObject.progress.status = progressNode["Status"].asString();
  95. if(!progressNode["TotalNotAnswered"].isNull())
  96. jobGroupObject.progress.totalNotAnswered = std::stoi(progressNode["TotalNotAnswered"].asString());
  97. if(!progressNode["TotalCompleted"].isNull())
  98. jobGroupObject.progress.totalCompleted = std::stoi(progressNode["TotalCompleted"].asString());
  99. if(!progressNode["StartTime"].isNull())
  100. jobGroupObject.progress.startTime = std::stol(progressNode["StartTime"].asString());
  101. if(!progressNode["Duration"].isNull())
  102. jobGroupObject.progress.duration = std::stoi(progressNode["Duration"].asString());
  103. auto allCategoriesNode = progressNode["Categories"]["KeyValuePair"];
  104. for (auto progressNodeCategoriesKeyValuePair : allCategoriesNode)
  105. {
  106. JobGroups::JobGroup::Progress::KeyValuePair keyValuePairObject;
  107. if(!progressNodeCategoriesKeyValuePair["Key"].isNull())
  108. keyValuePairObject.key = progressNodeCategoriesKeyValuePair["Key"].asString();
  109. if(!progressNodeCategoriesKeyValuePair["Value"].isNull())
  110. keyValuePairObject.value = progressNodeCategoriesKeyValuePair["Value"].asString();
  111. jobGroupObject.progress.categories.push_back(keyValuePairObject);
  112. }
  113. jobGroups_.list.push_back(jobGroupObject);
  114. }
  115. if(!value["Success"].isNull())
  116. success_ = value["Success"].asString() == "true";
  117. if(!value["Code"].isNull())
  118. code_ = value["Code"].asString();
  119. if(!value["Message"].isNull())
  120. message_ = value["Message"].asString();
  121. if(!value["HttpStatusCode"].isNull())
  122. httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
  123. }
  124. std::string ListPredictiveJobGroupsResult::getMessage()const
  125. {
  126. return message_;
  127. }
  128. int ListPredictiveJobGroupsResult::getHttpStatusCode()const
  129. {
  130. return httpStatusCode_;
  131. }
  132. std::string ListPredictiveJobGroupsResult::getCode()const
  133. {
  134. return code_;
  135. }
  136. ListPredictiveJobGroupsResult::JobGroups ListPredictiveJobGroupsResult::getJobGroups()const
  137. {
  138. return jobGroups_;
  139. }
  140. bool ListPredictiveJobGroupsResult::getSuccess()const
  141. {
  142. return success_;
  143. }