QueryDeviceDistributeJobResult.cc 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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/iot/model/QueryDeviceDistributeJobResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Iot;
  19. using namespace AlibabaCloud::Iot::Model;
  20. QueryDeviceDistributeJobResult::QueryDeviceDistributeJobResult() :
  21. ServiceResult()
  22. {}
  23. QueryDeviceDistributeJobResult::QueryDeviceDistributeJobResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryDeviceDistributeJobResult::~QueryDeviceDistributeJobResult()
  29. {}
  30. void QueryDeviceDistributeJobResult::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["SourceUid"].isNull())
  38. data_.sourceUid = dataNode["SourceUid"].asString();
  39. if(!dataNode["TargetUid"].isNull())
  40. data_.targetUid = dataNode["TargetUid"].asString();
  41. if(!dataNode["SourceInstanceId"].isNull())
  42. data_.sourceInstanceId = dataNode["SourceInstanceId"].asString();
  43. if(!dataNode["JobId"].isNull())
  44. data_.jobId = dataNode["JobId"].asString();
  45. if(!dataNode["ProductKey"].isNull())
  46. data_.productKey = dataNode["ProductKey"].asString();
  47. if(!dataNode["Total"].isNull())
  48. data_.total = std::stoi(dataNode["Total"].asString());
  49. if(!dataNode["Status"].isNull())
  50. data_.status = std::stoi(dataNode["Status"].asString());
  51. if(!dataNode["GmtCreate"].isNull())
  52. data_.gmtCreate = std::stol(dataNode["GmtCreate"].asString());
  53. if(!dataNode["Strategy"].isNull())
  54. data_.strategy = std::stoi(dataNode["Strategy"].asString());
  55. auto allTargetInstanceConfigsNode = dataNode["TargetInstanceConfigs"]["targetInstanceConfigsItem"];
  56. for (auto dataNodeTargetInstanceConfigstargetInstanceConfigsItem : allTargetInstanceConfigsNode)
  57. {
  58. Data::TargetInstanceConfigsItem targetInstanceConfigsItemObject;
  59. if(!dataNodeTargetInstanceConfigstargetInstanceConfigsItem["TargetInstanceId"].isNull())
  60. targetInstanceConfigsItemObject.targetInstanceId = dataNodeTargetInstanceConfigstargetInstanceConfigsItem["TargetInstanceId"].asString();
  61. data_.targetInstanceConfigs.push_back(targetInstanceConfigsItemObject);
  62. }
  63. if(!value["Success"].isNull())
  64. success_ = value["Success"].asString() == "true";
  65. if(!value["Code"].isNull())
  66. code_ = value["Code"].asString();
  67. if(!value["ErrorMessage"].isNull())
  68. errorMessage_ = value["ErrorMessage"].asString();
  69. }
  70. QueryDeviceDistributeJobResult::Data QueryDeviceDistributeJobResult::getData()const
  71. {
  72. return data_;
  73. }
  74. std::string QueryDeviceDistributeJobResult::getErrorMessage()const
  75. {
  76. return errorMessage_;
  77. }
  78. std::string QueryDeviceDistributeJobResult::getCode()const
  79. {
  80. return code_;
  81. }
  82. bool QueryDeviceDistributeJobResult::getSuccess()const
  83. {
  84. return success_;
  85. }