DescribeJobHistoryResult.cc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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/sae/model/DescribeJobHistoryResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Sae;
  19. using namespace AlibabaCloud::Sae::Model;
  20. DescribeJobHistoryResult::DescribeJobHistoryResult() :
  21. ServiceResult()
  22. {}
  23. DescribeJobHistoryResult::DescribeJobHistoryResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeJobHistoryResult::~DescribeJobHistoryResult()
  29. {}
  30. void DescribeJobHistoryResult::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 dataNode = value["Data"];
  37. if(!dataNode["CurrentPage"].isNull())
  38. data_.currentPage = std::stol(dataNode["CurrentPage"].asString());
  39. if(!dataNode["TotalSize"].isNull())
  40. data_.totalSize = std::stol(dataNode["TotalSize"].asString());
  41. if(!dataNode["PageSize"].isNull())
  42. data_.pageSize = std::stol(dataNode["PageSize"].asString());
  43. auto allJobsNode = dataNode["Jobs"]["job"];
  44. for (auto dataNodeJobsjob : allJobsNode)
  45. {
  46. Data::Job jobObject;
  47. if(!dataNodeJobsjob["JobId"].isNull())
  48. jobObject.jobId = dataNodeJobsjob["JobId"].asString();
  49. if(!dataNodeJobsjob["Active"].isNull())
  50. jobObject.active = std::stol(dataNodeJobsjob["Active"].asString());
  51. if(!dataNodeJobsjob["Succeeded"].isNull())
  52. jobObject.succeeded = std::stol(dataNodeJobsjob["Succeeded"].asString());
  53. if(!dataNodeJobsjob["Failed"].isNull())
  54. jobObject.failed = std::stol(dataNodeJobsjob["Failed"].asString());
  55. if(!dataNodeJobsjob["StartTime"].isNull())
  56. jobObject.startTime = std::stol(dataNodeJobsjob["StartTime"].asString());
  57. if(!dataNodeJobsjob["CompletionTime"].isNull())
  58. jobObject.completionTime = std::stol(dataNodeJobsjob["CompletionTime"].asString());
  59. if(!dataNodeJobsjob["Message"].isNull())
  60. jobObject.message = dataNodeJobsjob["Message"].asString();
  61. if(!dataNodeJobsjob["State"].isNull())
  62. jobObject.state = dataNodeJobsjob["State"].asString();
  63. data_.jobs.push_back(jobObject);
  64. }
  65. if(!value["Message"].isNull())
  66. message_ = value["Message"].asString();
  67. if(!value["TraceId"].isNull())
  68. traceId_ = value["TraceId"].asString();
  69. if(!value["ErrorCode"].isNull())
  70. errorCode_ = value["ErrorCode"].asString();
  71. if(!value["Code"].isNull())
  72. code_ = value["Code"].asString();
  73. if(!value["Success"].isNull())
  74. success_ = value["Success"].asString() == "true";
  75. }
  76. std::string DescribeJobHistoryResult::getMessage()const
  77. {
  78. return message_;
  79. }
  80. std::string DescribeJobHistoryResult::getTraceId()const
  81. {
  82. return traceId_;
  83. }
  84. DescribeJobHistoryResult::Data DescribeJobHistoryResult::getData()const
  85. {
  86. return data_;
  87. }
  88. std::string DescribeJobHistoryResult::getErrorCode()const
  89. {
  90. return errorCode_;
  91. }
  92. std::string DescribeJobHistoryResult::getCode()const
  93. {
  94. return code_;
  95. }
  96. bool DescribeJobHistoryResult::getSuccess()const
  97. {
  98. return success_;
  99. }