DescribeVSwitchesResult.cc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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/vpc/model/DescribeVSwitchesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Vpc;
  19. using namespace AlibabaCloud::Vpc::Model;
  20. DescribeVSwitchesResult::DescribeVSwitchesResult() :
  21. ServiceResult()
  22. {}
  23. DescribeVSwitchesResult::DescribeVSwitchesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeVSwitchesResult::~DescribeVSwitchesResult()
  29. {}
  30. void DescribeVSwitchesResult::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 allVSwitchesNode = value["VSwitches"]["VSwitch"];
  37. for (auto valueVSwitchesVSwitch : allVSwitchesNode)
  38. {
  39. VSwitch vSwitchesObject;
  40. if(!valueVSwitchesVSwitch["VSwitchId"].isNull())
  41. vSwitchesObject.vSwitchId = valueVSwitchesVSwitch["VSwitchId"].asString();
  42. if(!valueVSwitchesVSwitch["VpcId"].isNull())
  43. vSwitchesObject.vpcId = valueVSwitchesVSwitch["VpcId"].asString();
  44. if(!valueVSwitchesVSwitch["Status"].isNull())
  45. vSwitchesObject.status = valueVSwitchesVSwitch["Status"].asString();
  46. if(!valueVSwitchesVSwitch["CidrBlock"].isNull())
  47. vSwitchesObject.cidrBlock = valueVSwitchesVSwitch["CidrBlock"].asString();
  48. if(!valueVSwitchesVSwitch["Ipv6CidrBlock"].isNull())
  49. vSwitchesObject.ipv6CidrBlock = valueVSwitchesVSwitch["Ipv6CidrBlock"].asString();
  50. if(!valueVSwitchesVSwitch["ZoneId"].isNull())
  51. vSwitchesObject.zoneId = valueVSwitchesVSwitch["ZoneId"].asString();
  52. if(!valueVSwitchesVSwitch["AvailableIpAddressCount"].isNull())
  53. vSwitchesObject.availableIpAddressCount = std::stol(valueVSwitchesVSwitch["AvailableIpAddressCount"].asString());
  54. if(!valueVSwitchesVSwitch["Description"].isNull())
  55. vSwitchesObject.description = valueVSwitchesVSwitch["Description"].asString();
  56. if(!valueVSwitchesVSwitch["VSwitchName"].isNull())
  57. vSwitchesObject.vSwitchName = valueVSwitchesVSwitch["VSwitchName"].asString();
  58. if(!valueVSwitchesVSwitch["CreationTime"].isNull())
  59. vSwitchesObject.creationTime = valueVSwitchesVSwitch["CreationTime"].asString();
  60. if(!valueVSwitchesVSwitch["IsDefault"].isNull())
  61. vSwitchesObject.isDefault = valueVSwitchesVSwitch["IsDefault"].asString() == "true";
  62. if(!valueVSwitchesVSwitch["ResourceGroupId"].isNull())
  63. vSwitchesObject.resourceGroupId = valueVSwitchesVSwitch["ResourceGroupId"].asString();
  64. if(!valueVSwitchesVSwitch["NetworkAclId"].isNull())
  65. vSwitchesObject.networkAclId = valueVSwitchesVSwitch["NetworkAclId"].asString();
  66. auto allTagsNode = allVSwitchesNode["Tags"]["Tag"];
  67. for (auto allVSwitchesNodeTagsTag : allTagsNode)
  68. {
  69. VSwitch::Tag tagsObject;
  70. if(!allVSwitchesNodeTagsTag["Key"].isNull())
  71. tagsObject.key = allVSwitchesNodeTagsTag["Key"].asString();
  72. if(!allVSwitchesNodeTagsTag["Value"].isNull())
  73. tagsObject.value = allVSwitchesNodeTagsTag["Value"].asString();
  74. vSwitchesObject.tags.push_back(tagsObject);
  75. }
  76. auto routeTableNode = value["RouteTable"];
  77. if(!routeTableNode["RouteTableId"].isNull())
  78. vSwitchesObject.routeTable.routeTableId = routeTableNode["RouteTableId"].asString();
  79. if(!routeTableNode["RouteTableType"].isNull())
  80. vSwitchesObject.routeTable.routeTableType = routeTableNode["RouteTableType"].asString();
  81. vSwitches_.push_back(vSwitchesObject);
  82. }
  83. if(!value["TotalCount"].isNull())
  84. totalCount_ = std::stoi(value["TotalCount"].asString());
  85. if(!value["PageNumber"].isNull())
  86. pageNumber_ = std::stoi(value["PageNumber"].asString());
  87. if(!value["PageSize"].isNull())
  88. pageSize_ = std::stoi(value["PageSize"].asString());
  89. }
  90. int DescribeVSwitchesResult::getTotalCount()const
  91. {
  92. return totalCount_;
  93. }
  94. int DescribeVSwitchesResult::getPageSize()const
  95. {
  96. return pageSize_;
  97. }
  98. int DescribeVSwitchesResult::getPageNumber()const
  99. {
  100. return pageNumber_;
  101. }
  102. std::vector<DescribeVSwitchesResult::VSwitch> DescribeVSwitchesResult::getVSwitches()const
  103. {
  104. return vSwitches_;
  105. }