DescribeVpcsResult.cc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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/DescribeVpcsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Vpc;
  19. using namespace AlibabaCloud::Vpc::Model;
  20. DescribeVpcsResult::DescribeVpcsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeVpcsResult::DescribeVpcsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeVpcsResult::~DescribeVpcsResult()
  29. {}
  30. void DescribeVpcsResult::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 allVpcsNode = value["Vpcs"]["Vpc"];
  37. for (auto valueVpcsVpc : allVpcsNode)
  38. {
  39. Vpc vpcsObject;
  40. if(!valueVpcsVpc["VpcId"].isNull())
  41. vpcsObject.vpcId = valueVpcsVpc["VpcId"].asString();
  42. if(!valueVpcsVpc["RegionId"].isNull())
  43. vpcsObject.regionId = valueVpcsVpc["RegionId"].asString();
  44. if(!valueVpcsVpc["Status"].isNull())
  45. vpcsObject.status = valueVpcsVpc["Status"].asString();
  46. if(!valueVpcsVpc["VpcName"].isNull())
  47. vpcsObject.vpcName = valueVpcsVpc["VpcName"].asString();
  48. if(!valueVpcsVpc["CreationTime"].isNull())
  49. vpcsObject.creationTime = valueVpcsVpc["CreationTime"].asString();
  50. if(!valueVpcsVpc["CidrBlock"].isNull())
  51. vpcsObject.cidrBlock = valueVpcsVpc["CidrBlock"].asString();
  52. if(!valueVpcsVpc["Ipv6CidrBlock"].isNull())
  53. vpcsObject.ipv6CidrBlock = valueVpcsVpc["Ipv6CidrBlock"].asString();
  54. if(!valueVpcsVpc["VRouterId"].isNull())
  55. vpcsObject.vRouterId = valueVpcsVpc["VRouterId"].asString();
  56. if(!valueVpcsVpc["Description"].isNull())
  57. vpcsObject.description = valueVpcsVpc["Description"].asString();
  58. if(!valueVpcsVpc["IsDefault"].isNull())
  59. vpcsObject.isDefault = valueVpcsVpc["IsDefault"].asString() == "true";
  60. if(!valueVpcsVpc["NetworkAclNum"].isNull())
  61. vpcsObject.networkAclNum = valueVpcsVpc["NetworkAclNum"].asString();
  62. if(!valueVpcsVpc["ResourceGroupId"].isNull())
  63. vpcsObject.resourceGroupId = valueVpcsVpc["ResourceGroupId"].asString();
  64. if(!valueVpcsVpc["CenStatus"].isNull())
  65. vpcsObject.cenStatus = valueVpcsVpc["CenStatus"].asString();
  66. auto allTagsNode = allVpcsNode["Tags"]["Tag"];
  67. for (auto allVpcsNodeTagsTag : allTagsNode)
  68. {
  69. Vpc::Tag tagsObject;
  70. if(!allVpcsNodeTagsTag["Key"].isNull())
  71. tagsObject.key = allVpcsNodeTagsTag["Key"].asString();
  72. if(!allVpcsNodeTagsTag["Value"].isNull())
  73. tagsObject.value = allVpcsNodeTagsTag["Value"].asString();
  74. vpcsObject.tags.push_back(tagsObject);
  75. }
  76. auto allVSwitchIds = value["VSwitchIds"]["VSwitchId"];
  77. for (auto value : allVSwitchIds)
  78. vpcsObject.vSwitchIds.push_back(value.asString());
  79. auto allUserCidrs = value["UserCidrs"]["UserCidr"];
  80. for (auto value : allUserCidrs)
  81. vpcsObject.userCidrs.push_back(value.asString());
  82. auto allNatGatewayIds = value["NatGatewayIds"]["NatGatewayIds"];
  83. for (auto value : allNatGatewayIds)
  84. vpcsObject.natGatewayIds.push_back(value.asString());
  85. auto allRouterTableIds = value["RouterTableIds"]["RouterTableIds"];
  86. for (auto value : allRouterTableIds)
  87. vpcsObject.routerTableIds.push_back(value.asString());
  88. vpcs_.push_back(vpcsObject);
  89. }
  90. if(!value["TotalCount"].isNull())
  91. totalCount_ = std::stoi(value["TotalCount"].asString());
  92. if(!value["PageNumber"].isNull())
  93. pageNumber_ = std::stoi(value["PageNumber"].asString());
  94. if(!value["PageSize"].isNull())
  95. pageSize_ = std::stoi(value["PageSize"].asString());
  96. }
  97. std::vector<DescribeVpcsResult::Vpc> DescribeVpcsResult::getVpcs()const
  98. {
  99. return vpcs_;
  100. }
  101. int DescribeVpcsResult::getTotalCount()const
  102. {
  103. return totalCount_;
  104. }
  105. int DescribeVpcsResult::getPageSize()const
  106. {
  107. return pageSize_;
  108. }
  109. int DescribeVpcsResult::getPageNumber()const
  110. {
  111. return pageNumber_;
  112. }