DescribeInstancesResult.cc 8.8 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/r-kvstore/model/DescribeInstancesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::R_kvstore;
  19. using namespace AlibabaCloud::R_kvstore::Model;
  20. DescribeInstancesResult::DescribeInstancesResult() :
  21. ServiceResult()
  22. {}
  23. DescribeInstancesResult::DescribeInstancesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeInstancesResult::~DescribeInstancesResult()
  29. {}
  30. void DescribeInstancesResult::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 allInstancesNode = value["Instances"]["KVStoreInstance"];
  37. for (auto valueInstancesKVStoreInstance : allInstancesNode)
  38. {
  39. KVStoreInstance instancesObject;
  40. if(!valueInstancesKVStoreInstance["VpcId"].isNull())
  41. instancesObject.vpcId = valueInstancesKVStoreInstance["VpcId"].asString();
  42. if(!valueInstancesKVStoreInstance["PrivateIp"].isNull())
  43. instancesObject.privateIp = valueInstancesKVStoreInstance["PrivateIp"].asString();
  44. if(!valueInstancesKVStoreInstance["Capacity"].isNull())
  45. instancesObject.capacity = std::stol(valueInstancesKVStoreInstance["Capacity"].asString());
  46. if(!valueInstancesKVStoreInstance["ReplacateId"].isNull())
  47. instancesObject.replacateId = valueInstancesKVStoreInstance["ReplacateId"].asString();
  48. if(!valueInstancesKVStoreInstance["CreateTime"].isNull())
  49. instancesObject.createTime = valueInstancesKVStoreInstance["CreateTime"].asString();
  50. if(!valueInstancesKVStoreInstance["ConnectionDomain"].isNull())
  51. instancesObject.connectionDomain = valueInstancesKVStoreInstance["ConnectionDomain"].asString();
  52. if(!valueInstancesKVStoreInstance["IsRds"].isNull())
  53. instancesObject.isRds = valueInstancesKVStoreInstance["IsRds"].asString() == "true";
  54. if(!valueInstancesKVStoreInstance["ChargeType"].isNull())
  55. instancesObject.chargeType = valueInstancesKVStoreInstance["ChargeType"].asString();
  56. if(!valueInstancesKVStoreInstance["ArchitectureType"].isNull())
  57. instancesObject.architectureType = valueInstancesKVStoreInstance["ArchitectureType"].asString();
  58. if(!valueInstancesKVStoreInstance["NetworkType"].isNull())
  59. instancesObject.networkType = valueInstancesKVStoreInstance["NetworkType"].asString();
  60. if(!valueInstancesKVStoreInstance["ConnectionMode"].isNull())
  61. instancesObject.connectionMode = valueInstancesKVStoreInstance["ConnectionMode"].asString();
  62. if(!valueInstancesKVStoreInstance["Port"].isNull())
  63. instancesObject.port = std::stol(valueInstancesKVStoreInstance["Port"].asString());
  64. if(!valueInstancesKVStoreInstance["SecondaryZoneId"].isNull())
  65. instancesObject.secondaryZoneId = valueInstancesKVStoreInstance["SecondaryZoneId"].asString();
  66. if(!valueInstancesKVStoreInstance["EngineVersion"].isNull())
  67. instancesObject.engineVersion = valueInstancesKVStoreInstance["EngineVersion"].asString();
  68. if(!valueInstancesKVStoreInstance["PackageType"].isNull())
  69. instancesObject.packageType = valueInstancesKVStoreInstance["PackageType"].asString();
  70. if(!valueInstancesKVStoreInstance["Config"].isNull())
  71. instancesObject.config = valueInstancesKVStoreInstance["Config"].asString();
  72. if(!valueInstancesKVStoreInstance["VpcCloudInstanceId"].isNull())
  73. instancesObject.vpcCloudInstanceId = valueInstancesKVStoreInstance["VpcCloudInstanceId"].asString();
  74. if(!valueInstancesKVStoreInstance["Bandwidth"].isNull())
  75. instancesObject.bandwidth = std::stol(valueInstancesKVStoreInstance["Bandwidth"].asString());
  76. if(!valueInstancesKVStoreInstance["InstanceName"].isNull())
  77. instancesObject.instanceName = valueInstancesKVStoreInstance["InstanceName"].asString();
  78. if(!valueInstancesKVStoreInstance["ShardCount"].isNull())
  79. instancesObject.shardCount = std::stoi(valueInstancesKVStoreInstance["ShardCount"].asString());
  80. if(!valueInstancesKVStoreInstance["UserName"].isNull())
  81. instancesObject.userName = valueInstancesKVStoreInstance["UserName"].asString();
  82. if(!valueInstancesKVStoreInstance["GlobalInstanceId"].isNull())
  83. instancesObject.globalInstanceId = valueInstancesKVStoreInstance["GlobalInstanceId"].asString();
  84. if(!valueInstancesKVStoreInstance["QPS"].isNull())
  85. instancesObject.qPS = std::stol(valueInstancesKVStoreInstance["QPS"].asString());
  86. if(!valueInstancesKVStoreInstance["InstanceClass"].isNull())
  87. instancesObject.instanceClass = valueInstancesKVStoreInstance["InstanceClass"].asString();
  88. if(!valueInstancesKVStoreInstance["DestroyTime"].isNull())
  89. instancesObject.destroyTime = valueInstancesKVStoreInstance["DestroyTime"].asString();
  90. if(!valueInstancesKVStoreInstance["InstanceId"].isNull())
  91. instancesObject.instanceId = valueInstancesKVStoreInstance["InstanceId"].asString();
  92. if(!valueInstancesKVStoreInstance["InstanceType"].isNull())
  93. instancesObject.instanceType = valueInstancesKVStoreInstance["InstanceType"].asString();
  94. if(!valueInstancesKVStoreInstance["HasRenewChangeOrder"].isNull())
  95. instancesObject.hasRenewChangeOrder = valueInstancesKVStoreInstance["HasRenewChangeOrder"].asString() == "true";
  96. if(!valueInstancesKVStoreInstance["RegionId"].isNull())
  97. instancesObject.regionId = valueInstancesKVStoreInstance["RegionId"].asString();
  98. if(!valueInstancesKVStoreInstance["EndTime"].isNull())
  99. instancesObject.endTime = valueInstancesKVStoreInstance["EndTime"].asString();
  100. if(!valueInstancesKVStoreInstance["VSwitchId"].isNull())
  101. instancesObject.vSwitchId = valueInstancesKVStoreInstance["VSwitchId"].asString();
  102. if(!valueInstancesKVStoreInstance["NodeType"].isNull())
  103. instancesObject.nodeType = valueInstancesKVStoreInstance["NodeType"].asString();
  104. if(!valueInstancesKVStoreInstance["Connections"].isNull())
  105. instancesObject.connections = std::stol(valueInstancesKVStoreInstance["Connections"].asString());
  106. if(!valueInstancesKVStoreInstance["ResourceGroupId"].isNull())
  107. instancesObject.resourceGroupId = valueInstancesKVStoreInstance["ResourceGroupId"].asString();
  108. if(!valueInstancesKVStoreInstance["ZoneId"].isNull())
  109. instancesObject.zoneId = valueInstancesKVStoreInstance["ZoneId"].asString();
  110. if(!valueInstancesKVStoreInstance["InstanceStatus"].isNull())
  111. instancesObject.instanceStatus = valueInstancesKVStoreInstance["InstanceStatus"].asString();
  112. if(!valueInstancesKVStoreInstance["ProxyCount"].isNull())
  113. instancesObject.proxyCount = std::stoi(valueInstancesKVStoreInstance["ProxyCount"].asString());
  114. if(!valueInstancesKVStoreInstance["ComputingType"].isNull())
  115. instancesObject.computingType = valueInstancesKVStoreInstance["ComputingType"].asString();
  116. if(!valueInstancesKVStoreInstance["CloudType"].isNull())
  117. instancesObject.cloudType = valueInstancesKVStoreInstance["CloudType"].asString();
  118. if(!valueInstancesKVStoreInstance["EditionType"].isNull())
  119. instancesObject.editionType = valueInstancesKVStoreInstance["EditionType"].asString();
  120. if(!valueInstancesKVStoreInstance["ReadOnlyCount"].isNull())
  121. instancesObject.readOnlyCount = valueInstancesKVStoreInstance["ReadOnlyCount"].asString();
  122. if(!valueInstancesKVStoreInstance["ShardClass"].isNull())
  123. instancesObject.shardClass = valueInstancesKVStoreInstance["ShardClass"].asString();
  124. auto allTagsNode = valueInstancesKVStoreInstance["Tags"]["Tag"];
  125. for (auto valueInstancesKVStoreInstanceTagsTag : allTagsNode)
  126. {
  127. KVStoreInstance::Tag tagsObject;
  128. if(!valueInstancesKVStoreInstanceTagsTag["Key"].isNull())
  129. tagsObject.key = valueInstancesKVStoreInstanceTagsTag["Key"].asString();
  130. if(!valueInstancesKVStoreInstanceTagsTag["Value"].isNull())
  131. tagsObject.value = valueInstancesKVStoreInstanceTagsTag["Value"].asString();
  132. instancesObject.tags.push_back(tagsObject);
  133. }
  134. instances_.push_back(instancesObject);
  135. }
  136. if(!value["PageNumber"].isNull())
  137. pageNumber_ = std::stoi(value["PageNumber"].asString());
  138. if(!value["PageSize"].isNull())
  139. pageSize_ = std::stoi(value["PageSize"].asString());
  140. if(!value["TotalCount"].isNull())
  141. totalCount_ = std::stoi(value["TotalCount"].asString());
  142. }
  143. std::vector<DescribeInstancesResult::KVStoreInstance> DescribeInstancesResult::getInstances()const
  144. {
  145. return instances_;
  146. }
  147. int DescribeInstancesResult::getTotalCount()const
  148. {
  149. return totalCount_;
  150. }
  151. int DescribeInstancesResult::getPageSize()const
  152. {
  153. return pageSize_;
  154. }
  155. int DescribeInstancesResult::getPageNumber()const
  156. {
  157. return pageNumber_;
  158. }