GetEdgeInstanceDeploymentResult.cc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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/GetEdgeInstanceDeploymentResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Iot;
  19. using namespace AlibabaCloud::Iot::Model;
  20. GetEdgeInstanceDeploymentResult::GetEdgeInstanceDeploymentResult() :
  21. ServiceResult()
  22. {}
  23. GetEdgeInstanceDeploymentResult::GetEdgeInstanceDeploymentResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetEdgeInstanceDeploymentResult::~GetEdgeInstanceDeploymentResult()
  29. {}
  30. void GetEdgeInstanceDeploymentResult::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["GmtCreate"].isNull())
  38. data_.gmtCreate = dataNode["GmtCreate"].asString();
  39. if(!dataNode["GmtModified"].isNull())
  40. data_.gmtModified = dataNode["GmtModified"].asString();
  41. if(!dataNode["GmtCompleted"].isNull())
  42. data_.gmtCompleted = dataNode["GmtCompleted"].asString();
  43. if(!dataNode["DeploymentId"].isNull())
  44. data_.deploymentId = dataNode["DeploymentId"].asString();
  45. if(!dataNode["Description"].isNull())
  46. data_.description = dataNode["Description"].asString();
  47. if(!dataNode["Status"].isNull())
  48. data_.status = std::stoi(dataNode["Status"].asString());
  49. if(!dataNode["Type"].isNull())
  50. data_.type = dataNode["Type"].asString();
  51. auto allTaskListNode = dataNode["TaskList"]["Task"];
  52. for (auto dataNodeTaskListTask : allTaskListNode)
  53. {
  54. Data::Task taskObject;
  55. if(!dataNodeTaskListTask["GmtCreate"].isNull())
  56. taskObject.gmtCreate = dataNodeTaskListTask["GmtCreate"].asString();
  57. if(!dataNodeTaskListTask["GmtModified"].isNull())
  58. taskObject.gmtModified = dataNodeTaskListTask["GmtModified"].asString();
  59. if(!dataNodeTaskListTask["GmtCompleted"].isNull())
  60. taskObject.gmtCompleted = dataNodeTaskListTask["GmtCompleted"].asString();
  61. if(!dataNodeTaskListTask["GatewayId"].isNull())
  62. taskObject.gatewayId = dataNodeTaskListTask["GatewayId"].asString();
  63. if(!dataNodeTaskListTask["TaskId"].isNull())
  64. taskObject.taskId = dataNodeTaskListTask["TaskId"].asString();
  65. if(!dataNodeTaskListTask["Stage"].isNull())
  66. taskObject.stage = std::stoi(dataNodeTaskListTask["Stage"].asString());
  67. if(!dataNodeTaskListTask["Status"].isNull())
  68. taskObject.status = std::stoi(dataNodeTaskListTask["Status"].asString());
  69. auto allResourceSnapshotListNode = allTaskListNode["ResourceSnapshotList"]["ResourceSnapshot"];
  70. for (auto allTaskListNodeResourceSnapshotListResourceSnapshot : allResourceSnapshotListNode)
  71. {
  72. Data::Task::ResourceSnapshot resourceSnapshotListObject;
  73. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["GmtCreate"].isNull())
  74. resourceSnapshotListObject.gmtCreate = allTaskListNodeResourceSnapshotListResourceSnapshot["GmtCreate"].asString();
  75. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["GmtModified"].isNull())
  76. resourceSnapshotListObject.gmtModified = allTaskListNodeResourceSnapshotListResourceSnapshot["GmtModified"].asString();
  77. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["GmtCompleted"].isNull())
  78. resourceSnapshotListObject.gmtCompleted = allTaskListNodeResourceSnapshotListResourceSnapshot["GmtCompleted"].asString();
  79. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["SnapshotId"].isNull())
  80. resourceSnapshotListObject.snapshotId = allTaskListNodeResourceSnapshotListResourceSnapshot["SnapshotId"].asString();
  81. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["ResourceType"].isNull())
  82. resourceSnapshotListObject.resourceType = allTaskListNodeResourceSnapshotListResourceSnapshot["ResourceType"].asString();
  83. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["ResourceId"].isNull())
  84. resourceSnapshotListObject.resourceId = allTaskListNodeResourceSnapshotListResourceSnapshot["ResourceId"].asString();
  85. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["ResourceName"].isNull())
  86. resourceSnapshotListObject.resourceName = allTaskListNodeResourceSnapshotListResourceSnapshot["ResourceName"].asString();
  87. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["OperateType"].isNull())
  88. resourceSnapshotListObject.operateType = std::stoi(allTaskListNodeResourceSnapshotListResourceSnapshot["OperateType"].asString());
  89. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["Stage"].isNull())
  90. resourceSnapshotListObject.stage = std::stoi(allTaskListNodeResourceSnapshotListResourceSnapshot["Stage"].asString());
  91. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["Status"].isNull())
  92. resourceSnapshotListObject.status = std::stoi(allTaskListNodeResourceSnapshotListResourceSnapshot["Status"].asString());
  93. if(!allTaskListNodeResourceSnapshotListResourceSnapshot["Log"].isNull())
  94. resourceSnapshotListObject.log = allTaskListNodeResourceSnapshotListResourceSnapshot["Log"].asString();
  95. taskObject.resourceSnapshotList.push_back(resourceSnapshotListObject);
  96. }
  97. data_.taskList.push_back(taskObject);
  98. }
  99. if(!value["Success"].isNull())
  100. success_ = value["Success"].asString() == "true";
  101. if(!value["Code"].isNull())
  102. code_ = value["Code"].asString();
  103. if(!value["ErrorMessage"].isNull())
  104. errorMessage_ = value["ErrorMessage"].asString();
  105. }
  106. GetEdgeInstanceDeploymentResult::Data GetEdgeInstanceDeploymentResult::getData()const
  107. {
  108. return data_;
  109. }
  110. std::string GetEdgeInstanceDeploymentResult::getErrorMessage()const
  111. {
  112. return errorMessage_;
  113. }
  114. std::string GetEdgeInstanceDeploymentResult::getCode()const
  115. {
  116. return code_;
  117. }
  118. bool GetEdgeInstanceDeploymentResult::getSuccess()const
  119. {
  120. return success_;
  121. }