DescribeNetworkInterfaceAttributeResult.cc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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/ecs/model/DescribeNetworkInterfaceAttributeResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Ecs;
  19. using namespace AlibabaCloud::Ecs::Model;
  20. DescribeNetworkInterfaceAttributeResult::DescribeNetworkInterfaceAttributeResult() :
  21. ServiceResult()
  22. {}
  23. DescribeNetworkInterfaceAttributeResult::DescribeNetworkInterfaceAttributeResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeNetworkInterfaceAttributeResult::~DescribeNetworkInterfaceAttributeResult()
  29. {}
  30. void DescribeNetworkInterfaceAttributeResult::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 allPrivateIpSetsNode = value["PrivateIpSets"]["PrivateIpSet"];
  37. for (auto valuePrivateIpSetsPrivateIpSet : allPrivateIpSetsNode)
  38. {
  39. PrivateIpSet privateIpSetsObject;
  40. if(!valuePrivateIpSetsPrivateIpSet["PrivateIpAddress"].isNull())
  41. privateIpSetsObject.privateIpAddress = valuePrivateIpSetsPrivateIpSet["PrivateIpAddress"].asString();
  42. if(!valuePrivateIpSetsPrivateIpSet["Primary"].isNull())
  43. privateIpSetsObject.primary = valuePrivateIpSetsPrivateIpSet["Primary"].asString() == "true";
  44. auto associatedPublicIp1Node = value["AssociatedPublicIp"];
  45. if(!associatedPublicIp1Node["PublicIpAddress"].isNull())
  46. privateIpSetsObject.associatedPublicIp1.publicIpAddress = associatedPublicIp1Node["PublicIpAddress"].asString();
  47. if(!associatedPublicIp1Node["AllocationId"].isNull())
  48. privateIpSetsObject.associatedPublicIp1.allocationId = associatedPublicIp1Node["AllocationId"].asString();
  49. privateIpSets_.push_back(privateIpSetsObject);
  50. }
  51. auto allIpv6SetsNode = value["Ipv6Sets"]["Ipv6Set"];
  52. for (auto valueIpv6SetsIpv6Set : allIpv6SetsNode)
  53. {
  54. Ipv6Set ipv6SetsObject;
  55. if(!valueIpv6SetsIpv6Set["Ipv6Address"].isNull())
  56. ipv6SetsObject.ipv6Address = valueIpv6SetsIpv6Set["Ipv6Address"].asString();
  57. ipv6Sets_.push_back(ipv6SetsObject);
  58. }
  59. auto allIpv4PrefixSetsNode = value["Ipv4PrefixSets"]["Ipv4PrefixSet"];
  60. for (auto valueIpv4PrefixSetsIpv4PrefixSet : allIpv4PrefixSetsNode)
  61. {
  62. Ipv4PrefixSet ipv4PrefixSetsObject;
  63. if(!valueIpv4PrefixSetsIpv4PrefixSet["Ipv4Prefix"].isNull())
  64. ipv4PrefixSetsObject.ipv4Prefix = valueIpv4PrefixSetsIpv4PrefixSet["Ipv4Prefix"].asString();
  65. ipv4PrefixSets_.push_back(ipv4PrefixSetsObject);
  66. }
  67. auto allIpv6PrefixSetsNode = value["Ipv6PrefixSets"]["Ipv6PrefixSet"];
  68. for (auto valueIpv6PrefixSetsIpv6PrefixSet : allIpv6PrefixSetsNode)
  69. {
  70. Ipv6PrefixSet ipv6PrefixSetsObject;
  71. if(!valueIpv6PrefixSetsIpv6PrefixSet["Ipv6Prefix"].isNull())
  72. ipv6PrefixSetsObject.ipv6Prefix = valueIpv6PrefixSetsIpv6PrefixSet["Ipv6Prefix"].asString();
  73. ipv6PrefixSets_.push_back(ipv6PrefixSetsObject);
  74. }
  75. auto allTagsNode = value["Tags"]["Tag"];
  76. for (auto valueTagsTag : allTagsNode)
  77. {
  78. Tag tagsObject;
  79. if(!valueTagsTag["TagValue"].isNull())
  80. tagsObject.tagValue = valueTagsTag["TagValue"].asString();
  81. if(!valueTagsTag["TagKey"].isNull())
  82. tagsObject.tagKey = valueTagsTag["TagKey"].asString();
  83. tags_.push_back(tagsObject);
  84. }
  85. auto associatedPublicIpNode = value["AssociatedPublicIp"];
  86. if(!associatedPublicIpNode["PublicIpAddress"].isNull())
  87. associatedPublicIp_.publicIpAddress = associatedPublicIpNode["PublicIpAddress"].asString();
  88. if(!associatedPublicIpNode["AllocationId"].isNull())
  89. associatedPublicIp_.allocationId = associatedPublicIpNode["AllocationId"].asString();
  90. auto attachmentNode = value["Attachment"];
  91. if(!attachmentNode["DeviceIndex"].isNull())
  92. attachment_.deviceIndex = std::stoi(attachmentNode["DeviceIndex"].asString());
  93. if(!attachmentNode["InstanceId"].isNull())
  94. attachment_.instanceId = attachmentNode["InstanceId"].asString();
  95. if(!attachmentNode["TrunkNetworkInterfaceId"].isNull())
  96. attachment_.trunkNetworkInterfaceId = attachmentNode["TrunkNetworkInterfaceId"].asString();
  97. if(!attachmentNode["NetworkCardIndex"].isNull())
  98. attachment_.networkCardIndex = std::stoi(attachmentNode["NetworkCardIndex"].asString());
  99. auto allMemberNetworkInterfaceIds = attachmentNode["MemberNetworkInterfaceIds"]["MemberNetworkInterfaceId"];
  100. for (auto value : allMemberNetworkInterfaceIds)
  101. attachment_.memberNetworkInterfaceIds.push_back(value.asString());
  102. auto bondInterfaceSpecificationNode = value["BondInterfaceSpecification"];
  103. if(!bondInterfaceSpecificationNode["BondMode"].isNull())
  104. bondInterfaceSpecification_.bondMode = bondInterfaceSpecificationNode["BondMode"].asString();
  105. auto allSlaveInterfaceSpecification2Node = bondInterfaceSpecificationNode["SlaveInterfaceSpecification"]["SlaveInterfaceSpecificationSet"];
  106. for (auto bondInterfaceSpecificationNodeSlaveInterfaceSpecificationSlaveInterfaceSpecificationSet : allSlaveInterfaceSpecification2Node)
  107. {
  108. BondInterfaceSpecification::SlaveInterfaceSpecificationSet slaveInterfaceSpecificationSetObject;
  109. if(!bondInterfaceSpecificationNodeSlaveInterfaceSpecificationSlaveInterfaceSpecificationSet["SlaveNetworkInterfaceId"].isNull())
  110. slaveInterfaceSpecificationSetObject.slaveNetworkInterfaceId = bondInterfaceSpecificationNodeSlaveInterfaceSpecificationSlaveInterfaceSpecificationSet["SlaveNetworkInterfaceId"].asString();
  111. if(!bondInterfaceSpecificationNodeSlaveInterfaceSpecificationSlaveInterfaceSpecificationSet["WorkState"].isNull())
  112. slaveInterfaceSpecificationSetObject.workState = bondInterfaceSpecificationNodeSlaveInterfaceSpecificationSlaveInterfaceSpecificationSet["WorkState"].asString();
  113. if(!bondInterfaceSpecificationNodeSlaveInterfaceSpecificationSlaveInterfaceSpecificationSet["BondNetworkInterfaceId"].isNull())
  114. slaveInterfaceSpecificationSetObject.bondNetworkInterfaceId = bondInterfaceSpecificationNodeSlaveInterfaceSpecificationSlaveInterfaceSpecificationSet["BondNetworkInterfaceId"].asString();
  115. bondInterfaceSpecification_.slaveInterfaceSpecification2.push_back(slaveInterfaceSpecificationSetObject);
  116. }
  117. auto slaveInterfaceSpecificationNode = value["SlaveInterfaceSpecification"];
  118. if(!slaveInterfaceSpecificationNode["SlaveNetworkInterfaceId"].isNull())
  119. slaveInterfaceSpecification_.slaveNetworkInterfaceId = slaveInterfaceSpecificationNode["SlaveNetworkInterfaceId"].asString();
  120. if(!slaveInterfaceSpecificationNode["WorkState"].isNull())
  121. slaveInterfaceSpecification_.workState = slaveInterfaceSpecificationNode["WorkState"].asString();
  122. if(!slaveInterfaceSpecificationNode["BondNetworkInterfaceId"].isNull())
  123. slaveInterfaceSpecification_.bondNetworkInterfaceId = slaveInterfaceSpecificationNode["BondNetworkInterfaceId"].asString();
  124. auto networkInterfaceTrafficConfigNode = value["NetworkInterfaceTrafficConfig"];
  125. if(!networkInterfaceTrafficConfigNode["NetworkInterfaceTrafficMode"].isNull())
  126. networkInterfaceTrafficConfig_.networkInterfaceTrafficMode = networkInterfaceTrafficConfigNode["NetworkInterfaceTrafficMode"].asString();
  127. if(!networkInterfaceTrafficConfigNode["QueueNumber"].isNull())
  128. networkInterfaceTrafficConfig_.queueNumber = std::stoi(networkInterfaceTrafficConfigNode["QueueNumber"].asString());
  129. if(!networkInterfaceTrafficConfigNode["QueuePairNumber"].isNull())
  130. networkInterfaceTrafficConfig_.queuePairNumber = std::stoi(networkInterfaceTrafficConfigNode["QueuePairNumber"].asString());
  131. auto connectionTrackingConfigurationNode = value["ConnectionTrackingConfiguration"];
  132. if(!connectionTrackingConfigurationNode["TcpEstablishedTimeout"].isNull())
  133. connectionTrackingConfiguration_.tcpEstablishedTimeout = std::stoi(connectionTrackingConfigurationNode["TcpEstablishedTimeout"].asString());
  134. if(!connectionTrackingConfigurationNode["TcpClosedAndTimeWaitTimeout"].isNull())
  135. connectionTrackingConfiguration_.tcpClosedAndTimeWaitTimeout = std::stoi(connectionTrackingConfigurationNode["TcpClosedAndTimeWaitTimeout"].asString());
  136. if(!connectionTrackingConfigurationNode["UdpTimeout"].isNull())
  137. connectionTrackingConfiguration_.udpTimeout = std::stoi(connectionTrackingConfigurationNode["UdpTimeout"].asString());
  138. auto enhancedNetworkNode = value["EnhancedNetwork"];
  139. if(!enhancedNetworkNode["EnableSriov"].isNull())
  140. enhancedNetwork_.enableSriov = enhancedNetworkNode["EnableSriov"].asString() == "true";
  141. auto allSecurityGroupIds = value["SecurityGroupIds"]["SecurityGroupId"];
  142. for (const auto &item : allSecurityGroupIds)
  143. securityGroupIds_.push_back(item.asString());
  144. if(!value["CreationTime"].isNull())
  145. creationTime_ = value["CreationTime"].asString();
  146. if(!value["VpcId"].isNull())
  147. vpcId_ = value["VpcId"].asString();
  148. if(!value["Type"].isNull())
  149. type_ = value["Type"].asString();
  150. if(!value["Status"].isNull())
  151. status_ = value["Status"].asString();
  152. if(!value["NetworkInterfaceTrafficMode"].isNull())
  153. networkInterfaceTrafficMode_ = value["NetworkInterfaceTrafficMode"].asString();
  154. if(!value["NetworkInterfaceName"].isNull())
  155. networkInterfaceName_ = value["NetworkInterfaceName"].asString();
  156. if(!value["MacAddress"].isNull())
  157. macAddress_ = value["MacAddress"].asString();
  158. if(!value["QueuePairNumber"].isNull())
  159. queuePairNumber_ = std::stoi(value["QueuePairNumber"].asString());
  160. if(!value["NetworkInterfaceId"].isNull())
  161. networkInterfaceId_ = value["NetworkInterfaceId"].asString();
  162. if(!value["ServiceID"].isNull())
  163. serviceID_ = std::stol(value["ServiceID"].asString());
  164. if(!value["InstanceId"].isNull())
  165. instanceId_ = value["InstanceId"].asString();
  166. if(!value["OwnerId"].isNull())
  167. ownerId_ = value["OwnerId"].asString();
  168. if(!value["ServiceManaged"].isNull())
  169. serviceManaged_ = value["ServiceManaged"].asString() == "true";
  170. if(!value["VSwitchId"].isNull())
  171. vSwitchId_ = value["VSwitchId"].asString();
  172. if(!value["Description"].isNull())
  173. description_ = value["Description"].asString();
  174. if(!value["ResourceGroupId"].isNull())
  175. resourceGroupId_ = value["ResourceGroupId"].asString();
  176. if(!value["ZoneId"].isNull())
  177. zoneId_ = value["ZoneId"].asString();
  178. if(!value["PrivateIpAddress"].isNull())
  179. privateIpAddress_ = value["PrivateIpAddress"].asString();
  180. if(!value["QueueNumber"].isNull())
  181. queueNumber_ = std::stoi(value["QueueNumber"].asString());
  182. if(!value["DeleteOnRelease"].isNull())
  183. deleteOnRelease_ = value["DeleteOnRelease"].asString() == "true";
  184. if(!value["TcpOptionAddressEnabled"].isNull())
  185. tcpOptionAddressEnabled_ = value["TcpOptionAddressEnabled"].asString();
  186. if(!value["SourceDestCheck"].isNull())
  187. sourceDestCheck_ = value["SourceDestCheck"].asString() == "true";
  188. }
  189. std::string DescribeNetworkInterfaceAttributeResult::getDescription()const
  190. {
  191. return description_;
  192. }
  193. std::string DescribeNetworkInterfaceAttributeResult::getPrivateIpAddress()const
  194. {
  195. return privateIpAddress_;
  196. }
  197. bool DescribeNetworkInterfaceAttributeResult::getServiceManaged()const
  198. {
  199. return serviceManaged_;
  200. }
  201. std::string DescribeNetworkInterfaceAttributeResult::getResourceGroupId()const
  202. {
  203. return resourceGroupId_;
  204. }
  205. bool DescribeNetworkInterfaceAttributeResult::getDeleteOnRelease()const
  206. {
  207. return deleteOnRelease_;
  208. }
  209. DescribeNetworkInterfaceAttributeResult::Attachment DescribeNetworkInterfaceAttributeResult::getAttachment()const
  210. {
  211. return attachment_;
  212. }
  213. std::string DescribeNetworkInterfaceAttributeResult::getNetworkInterfaceId()const
  214. {
  215. return networkInterfaceId_;
  216. }
  217. DescribeNetworkInterfaceAttributeResult::EnhancedNetwork DescribeNetworkInterfaceAttributeResult::getEnhancedNetwork()const
  218. {
  219. return enhancedNetwork_;
  220. }
  221. std::vector<DescribeNetworkInterfaceAttributeResult::Ipv6Set> DescribeNetworkInterfaceAttributeResult::getIpv6Sets()const
  222. {
  223. return ipv6Sets_;
  224. }
  225. std::string DescribeNetworkInterfaceAttributeResult::getOwnerId()const
  226. {
  227. return ownerId_;
  228. }
  229. DescribeNetworkInterfaceAttributeResult::AssociatedPublicIp DescribeNetworkInterfaceAttributeResult::getAssociatedPublicIp()const
  230. {
  231. return associatedPublicIp_;
  232. }
  233. std::vector<DescribeNetworkInterfaceAttributeResult::Tag> DescribeNetworkInterfaceAttributeResult::getTags()const
  234. {
  235. return tags_;
  236. }
  237. std::string DescribeNetworkInterfaceAttributeResult::getStatus()const
  238. {
  239. return status_;
  240. }
  241. std::string DescribeNetworkInterfaceAttributeResult::getNetworkInterfaceTrafficMode()const
  242. {
  243. return networkInterfaceTrafficMode_;
  244. }
  245. DescribeNetworkInterfaceAttributeResult::SlaveInterfaceSpecification DescribeNetworkInterfaceAttributeResult::getSlaveInterfaceSpecification()const
  246. {
  247. return slaveInterfaceSpecification_;
  248. }
  249. std::string DescribeNetworkInterfaceAttributeResult::getZoneId()const
  250. {
  251. return zoneId_;
  252. }
  253. std::string DescribeNetworkInterfaceAttributeResult::getInstanceId()const
  254. {
  255. return instanceId_;
  256. }
  257. std::string DescribeNetworkInterfaceAttributeResult::getVSwitchId()const
  258. {
  259. return vSwitchId_;
  260. }
  261. std::string DescribeNetworkInterfaceAttributeResult::getNetworkInterfaceName()const
  262. {
  263. return networkInterfaceName_;
  264. }
  265. std::string DescribeNetworkInterfaceAttributeResult::getMacAddress()const
  266. {
  267. return macAddress_;
  268. }
  269. std::vector<std::string> DescribeNetworkInterfaceAttributeResult::getSecurityGroupIds()const
  270. {
  271. return securityGroupIds_;
  272. }
  273. long DescribeNetworkInterfaceAttributeResult::getServiceID()const
  274. {
  275. return serviceID_;
  276. }
  277. std::string DescribeNetworkInterfaceAttributeResult::getTcpOptionAddressEnabled()const
  278. {
  279. return tcpOptionAddressEnabled_;
  280. }
  281. bool DescribeNetworkInterfaceAttributeResult::getSourceDestCheck()const
  282. {
  283. return sourceDestCheck_;
  284. }
  285. std::string DescribeNetworkInterfaceAttributeResult::getType()const
  286. {
  287. return type_;
  288. }
  289. int DescribeNetworkInterfaceAttributeResult::getQueuePairNumber()const
  290. {
  291. return queuePairNumber_;
  292. }
  293. int DescribeNetworkInterfaceAttributeResult::getQueueNumber()const
  294. {
  295. return queueNumber_;
  296. }
  297. std::string DescribeNetworkInterfaceAttributeResult::getVpcId()const
  298. {
  299. return vpcId_;
  300. }
  301. std::vector<DescribeNetworkInterfaceAttributeResult::Ipv6PrefixSet> DescribeNetworkInterfaceAttributeResult::getIpv6PrefixSets()const
  302. {
  303. return ipv6PrefixSets_;
  304. }
  305. DescribeNetworkInterfaceAttributeResult::BondInterfaceSpecification DescribeNetworkInterfaceAttributeResult::getBondInterfaceSpecification()const
  306. {
  307. return bondInterfaceSpecification_;
  308. }
  309. std::string DescribeNetworkInterfaceAttributeResult::getCreationTime()const
  310. {
  311. return creationTime_;
  312. }
  313. DescribeNetworkInterfaceAttributeResult::NetworkInterfaceTrafficConfig DescribeNetworkInterfaceAttributeResult::getNetworkInterfaceTrafficConfig()const
  314. {
  315. return networkInterfaceTrafficConfig_;
  316. }
  317. DescribeNetworkInterfaceAttributeResult::ConnectionTrackingConfiguration DescribeNetworkInterfaceAttributeResult::getConnectionTrackingConfiguration()const
  318. {
  319. return connectionTrackingConfiguration_;
  320. }
  321. std::vector<DescribeNetworkInterfaceAttributeResult::Ipv4PrefixSet> DescribeNetworkInterfaceAttributeResult::getIpv4PrefixSets()const
  322. {
  323. return ipv4PrefixSets_;
  324. }
  325. std::vector<DescribeNetworkInterfaceAttributeResult::PrivateIpSet> DescribeNetworkInterfaceAttributeResult::getPrivateIpSets()const
  326. {
  327. return privateIpSets_;
  328. }