DescribeGatewaysResult.cc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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/sgw/model/DescribeGatewaysResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Sgw;
  19. using namespace AlibabaCloud::Sgw::Model;
  20. DescribeGatewaysResult::DescribeGatewaysResult() :
  21. ServiceResult()
  22. {}
  23. DescribeGatewaysResult::DescribeGatewaysResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeGatewaysResult::~DescribeGatewaysResult()
  29. {}
  30. void DescribeGatewaysResult::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 allGatewaysNode = value["Gateways"]["Gateway"];
  37. for (auto valueGatewaysGateway : allGatewaysNode)
  38. {
  39. Gateway gatewaysObject;
  40. if(!valueGatewaysGateway["GatewayId"].isNull())
  41. gatewaysObject.gatewayId = valueGatewaysGateway["GatewayId"].asString();
  42. if(!valueGatewaysGateway["StorageBundleId"].isNull())
  43. gatewaysObject.storageBundleId = valueGatewaysGateway["StorageBundleId"].asString();
  44. if(!valueGatewaysGateway["Name"].isNull())
  45. gatewaysObject.name = valueGatewaysGateway["Name"].asString();
  46. if(!valueGatewaysGateway["Description"].isNull())
  47. gatewaysObject.description = valueGatewaysGateway["Description"].asString();
  48. if(!valueGatewaysGateway["Location"].isNull())
  49. gatewaysObject.location = valueGatewaysGateway["Location"].asString();
  50. if(!valueGatewaysGateway["Category"].isNull())
  51. gatewaysObject.category = valueGatewaysGateway["Category"].asString();
  52. if(!valueGatewaysGateway["Type"].isNull())
  53. gatewaysObject.type = valueGatewaysGateway["Type"].asString();
  54. if(!valueGatewaysGateway["GatewayClass"].isNull())
  55. gatewaysObject.gatewayClass = valueGatewaysGateway["GatewayClass"].asString();
  56. if(!valueGatewaysGateway["Model"].isNull())
  57. gatewaysObject.model = valueGatewaysGateway["Model"].asString();
  58. if(!valueGatewaysGateway["SerialNumber"].isNull())
  59. gatewaysObject.serialNumber = valueGatewaysGateway["SerialNumber"].asString();
  60. if(!valueGatewaysGateway["Status"].isNull())
  61. gatewaysObject.status = valueGatewaysGateway["Status"].asString();
  62. if(!valueGatewaysGateway["EcsInstanceId"].isNull())
  63. gatewaysObject.ecsInstanceId = valueGatewaysGateway["EcsInstanceId"].asString();
  64. if(!valueGatewaysGateway["VpcId"].isNull())
  65. gatewaysObject.vpcId = valueGatewaysGateway["VpcId"].asString();
  66. if(!valueGatewaysGateway["VSwitchId"].isNull())
  67. gatewaysObject.vSwitchId = valueGatewaysGateway["VSwitchId"].asString();
  68. if(!valueGatewaysGateway["Ip"].isNull())
  69. gatewaysObject.ip = valueGatewaysGateway["Ip"].asString();
  70. if(!valueGatewaysGateway["InnerIp"].isNull())
  71. gatewaysObject.innerIp = valueGatewaysGateway["InnerIp"].asString();
  72. if(!valueGatewaysGateway["CreatedTime"].isNull())
  73. gatewaysObject.createdTime = std::stol(valueGatewaysGateway["CreatedTime"].asString());
  74. if(!valueGatewaysGateway["ActivatedTime"].isNull())
  75. gatewaysObject.activatedTime = std::stol(valueGatewaysGateway["ActivatedTime"].asString());
  76. if(!valueGatewaysGateway["TaskId"].isNull())
  77. gatewaysObject.taskId = valueGatewaysGateway["TaskId"].asString();
  78. if(!valueGatewaysGateway["GatewayVersion"].isNull())
  79. gatewaysObject.gatewayVersion = valueGatewaysGateway["GatewayVersion"].asString();
  80. if(!valueGatewaysGateway["BuyURL"].isNull())
  81. gatewaysObject.buyURL = valueGatewaysGateway["BuyURL"].asString();
  82. if(!valueGatewaysGateway["RenewURL"].isNull())
  83. gatewaysObject.renewURL = valueGatewaysGateway["RenewURL"].asString();
  84. if(!valueGatewaysGateway["IsPostPaid"].isNull())
  85. gatewaysObject.isPostPaid = valueGatewaysGateway["IsPostPaid"].asString() == "true";
  86. if(!valueGatewaysGateway["IsReleaseAfterExpiration"].isNull())
  87. gatewaysObject.isReleaseAfterExpiration = valueGatewaysGateway["IsReleaseAfterExpiration"].asString() == "true";
  88. if(!valueGatewaysGateway["ExpiredTime"].isNull())
  89. gatewaysObject.expiredTime = std::stol(valueGatewaysGateway["ExpiredTime"].asString());
  90. if(!valueGatewaysGateway["ExpireStatus"].isNull())
  91. gatewaysObject.expireStatus = std::stoi(valueGatewaysGateway["ExpireStatus"].asString());
  92. if(!valueGatewaysGateway["CommonBuyInstanceId"].isNull())
  93. gatewaysObject.commonBuyInstanceId = valueGatewaysGateway["CommonBuyInstanceId"].asString();
  94. if(!valueGatewaysGateway["PublicNetworkBandwidth"].isNull())
  95. gatewaysObject.publicNetworkBandwidth = std::stoi(valueGatewaysGateway["PublicNetworkBandwidth"].asString());
  96. if(!valueGatewaysGateway["GatewayType"].isNull())
  97. gatewaysObject.gatewayType = valueGatewaysGateway["GatewayType"].asString();
  98. if(!valueGatewaysGateway["ElasticGateway"].isNull())
  99. gatewaysObject.elasticGateway = valueGatewaysGateway["ElasticGateway"].asString() == "true";
  100. if(!valueGatewaysGateway["MaxThroughput"].isNull())
  101. gatewaysObject.maxThroughput = std::stoi(valueGatewaysGateway["MaxThroughput"].asString());
  102. if(!valueGatewaysGateway["Capacity"].isNull())
  103. gatewaysObject.capacity = std::stoi(valueGatewaysGateway["Capacity"].asString());
  104. if(!valueGatewaysGateway["DataLoadType"].isNull())
  105. gatewaysObject.dataLoadType = valueGatewaysGateway["DataLoadType"].asString();
  106. if(!valueGatewaysGateway["DataLoadInterval"].isNull())
  107. gatewaysObject.dataLoadInterval = std::stoi(valueGatewaysGateway["DataLoadInterval"].asString());
  108. if(!valueGatewaysGateway["LastErrorKey"].isNull())
  109. gatewaysObject.lastErrorKey = valueGatewaysGateway["LastErrorKey"].asString();
  110. auto allElasticNodes = value["ElasticNodes"]["ElasticNode"];
  111. for (auto value : allElasticNodes)
  112. gatewaysObject.elasticNodes.push_back(value.asString());
  113. gateways_.push_back(gatewaysObject);
  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["TotalCount"].isNull())
  122. totalCount_ = std::stoi(value["TotalCount"].asString());
  123. if(!value["PageNumber"].isNull())
  124. pageNumber_ = std::stoi(value["PageNumber"].asString());
  125. if(!value["PageSize"].isNull())
  126. pageSize_ = std::stoi(value["PageSize"].asString());
  127. }
  128. int DescribeGatewaysResult::getTotalCount()const
  129. {
  130. return totalCount_;
  131. }
  132. std::string DescribeGatewaysResult::getMessage()const
  133. {
  134. return message_;
  135. }
  136. int DescribeGatewaysResult::getPageSize()const
  137. {
  138. return pageSize_;
  139. }
  140. int DescribeGatewaysResult::getPageNumber()const
  141. {
  142. return pageNumber_;
  143. }
  144. std::vector<DescribeGatewaysResult::Gateway> DescribeGatewaysResult::getGateways()const
  145. {
  146. return gateways_;
  147. }
  148. std::string DescribeGatewaysResult::getCode()const
  149. {
  150. return code_;
  151. }
  152. bool DescribeGatewaysResult::getSuccess()const
  153. {
  154. return success_;
  155. }