DescribeZoneVpcTreeResult.cc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/pvtz/model/DescribeZoneVpcTreeResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Pvtz;
  19. using namespace AlibabaCloud::Pvtz::Model;
  20. DescribeZoneVpcTreeResult::DescribeZoneVpcTreeResult() :
  21. ServiceResult()
  22. {}
  23. DescribeZoneVpcTreeResult::DescribeZoneVpcTreeResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeZoneVpcTreeResult::~DescribeZoneVpcTreeResult()
  29. {}
  30. void DescribeZoneVpcTreeResult::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 allZonesNode = value["Zones"]["Zone"];
  37. for (auto valueZonesZone : allZonesNode)
  38. {
  39. Zone zonesObject;
  40. if(!valueZonesZone["ZoneId"].isNull())
  41. zonesObject.zoneId = valueZonesZone["ZoneId"].asString();
  42. if(!valueZonesZone["ZoneName"].isNull())
  43. zonesObject.zoneName = valueZonesZone["ZoneName"].asString();
  44. if(!valueZonesZone["Remark"].isNull())
  45. zonesObject.remark = valueZonesZone["Remark"].asString();
  46. if(!valueZonesZone["RecordCount"].isNull())
  47. zonesObject.recordCount = std::stoi(valueZonesZone["RecordCount"].asString());
  48. if(!valueZonesZone["CreateTime"].isNull())
  49. zonesObject.createTime = valueZonesZone["CreateTime"].asString();
  50. if(!valueZonesZone["CreateTimestamp"].isNull())
  51. zonesObject.createTimestamp = std::stol(valueZonesZone["CreateTimestamp"].asString());
  52. if(!valueZonesZone["UpdateTime"].isNull())
  53. zonesObject.updateTime = valueZonesZone["UpdateTime"].asString();
  54. if(!valueZonesZone["UpdateTimestamp"].isNull())
  55. zonesObject.updateTimestamp = std::stol(valueZonesZone["UpdateTimestamp"].asString());
  56. if(!valueZonesZone["IsPtr"].isNull())
  57. zonesObject.isPtr = valueZonesZone["IsPtr"].asString() == "true";
  58. auto allVpcsNode = valueZonesZone["Vpcs"]["Vpc"];
  59. for (auto valueZonesZoneVpcsVpc : allVpcsNode)
  60. {
  61. Zone::Vpc vpcsObject;
  62. if(!valueZonesZoneVpcsVpc["RegionId"].isNull())
  63. vpcsObject.regionId = valueZonesZoneVpcsVpc["RegionId"].asString();
  64. if(!valueZonesZoneVpcsVpc["RegionName"].isNull())
  65. vpcsObject.regionName = valueZonesZoneVpcsVpc["RegionName"].asString();
  66. if(!valueZonesZoneVpcsVpc["VpcId"].isNull())
  67. vpcsObject.vpcId = valueZonesZoneVpcsVpc["VpcId"].asString();
  68. if(!valueZonesZoneVpcsVpc["VpcName"].isNull())
  69. vpcsObject.vpcName = valueZonesZoneVpcsVpc["VpcName"].asString();
  70. zonesObject.vpcs.push_back(vpcsObject);
  71. }
  72. zones_.push_back(zonesObject);
  73. }
  74. }
  75. std::vector<DescribeZoneVpcTreeResult::Zone> DescribeZoneVpcTreeResult::getZones()const
  76. {
  77. return zones_;
  78. }