DescribeRouteEntryListResult.cc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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/DescribeRouteEntryListResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Vpc;
  19. using namespace AlibabaCloud::Vpc::Model;
  20. DescribeRouteEntryListResult::DescribeRouteEntryListResult() :
  21. ServiceResult()
  22. {}
  23. DescribeRouteEntryListResult::DescribeRouteEntryListResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeRouteEntryListResult::~DescribeRouteEntryListResult()
  29. {}
  30. void DescribeRouteEntryListResult::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 allRouteEntrysNode = value["RouteEntrys"]["RouteEntry"];
  37. for (auto valueRouteEntrysRouteEntry : allRouteEntrysNode)
  38. {
  39. RouteEntry routeEntrysObject;
  40. if(!valueRouteEntrysRouteEntry["RouteTableId"].isNull())
  41. routeEntrysObject.routeTableId = valueRouteEntrysRouteEntry["RouteTableId"].asString();
  42. if(!valueRouteEntrysRouteEntry["DestinationCidrBlock"].isNull())
  43. routeEntrysObject.destinationCidrBlock = valueRouteEntrysRouteEntry["DestinationCidrBlock"].asString();
  44. if(!valueRouteEntrysRouteEntry["Type"].isNull())
  45. routeEntrysObject.type = valueRouteEntrysRouteEntry["Type"].asString();
  46. if(!valueRouteEntrysRouteEntry["RouteEntryId"].isNull())
  47. routeEntrysObject.routeEntryId = valueRouteEntrysRouteEntry["RouteEntryId"].asString();
  48. if(!valueRouteEntrysRouteEntry["RouteEntryName"].isNull())
  49. routeEntrysObject.routeEntryName = valueRouteEntrysRouteEntry["RouteEntryName"].asString();
  50. if(!valueRouteEntrysRouteEntry["Status"].isNull())
  51. routeEntrysObject.status = valueRouteEntrysRouteEntry["Status"].asString();
  52. if(!valueRouteEntrysRouteEntry["IpVersion"].isNull())
  53. routeEntrysObject.ipVersion = valueRouteEntrysRouteEntry["IpVersion"].asString();
  54. auto allNextHopsNode = allRouteEntrysNode["NextHops"]["NextHop"];
  55. for (auto allRouteEntrysNodeNextHopsNextHop : allNextHopsNode)
  56. {
  57. RouteEntry::NextHop nextHopsObject;
  58. if(!allRouteEntrysNodeNextHopsNextHop["NextHopType"].isNull())
  59. nextHopsObject.nextHopType = allRouteEntrysNodeNextHopsNextHop["NextHopType"].asString();
  60. if(!allRouteEntrysNodeNextHopsNextHop["NextHopId"].isNull())
  61. nextHopsObject.nextHopId = allRouteEntrysNodeNextHopsNextHop["NextHopId"].asString();
  62. if(!allRouteEntrysNodeNextHopsNextHop["Enabled"].isNull())
  63. nextHopsObject.enabled = std::stoi(allRouteEntrysNodeNextHopsNextHop["Enabled"].asString());
  64. if(!allRouteEntrysNodeNextHopsNextHop["Weight"].isNull())
  65. nextHopsObject.weight = std::stoi(allRouteEntrysNodeNextHopsNextHop["Weight"].asString());
  66. if(!allRouteEntrysNodeNextHopsNextHop["NextHopRegionId"].isNull())
  67. nextHopsObject.nextHopRegionId = allRouteEntrysNodeNextHopsNextHop["NextHopRegionId"].asString();
  68. auto nextHopRelatedInfoNode = value["NextHopRelatedInfo"];
  69. if(!nextHopRelatedInfoNode["InstanceType"].isNull())
  70. nextHopsObject.nextHopRelatedInfo.instanceType = nextHopRelatedInfoNode["InstanceType"].asString();
  71. if(!nextHopRelatedInfoNode["RegionId"].isNull())
  72. nextHopsObject.nextHopRelatedInfo.regionId = nextHopRelatedInfoNode["RegionId"].asString();
  73. if(!nextHopRelatedInfoNode["InstanceId"].isNull())
  74. nextHopsObject.nextHopRelatedInfo.instanceId = nextHopRelatedInfoNode["InstanceId"].asString();
  75. routeEntrysObject.nextHops.push_back(nextHopsObject);
  76. }
  77. routeEntrys_.push_back(routeEntrysObject);
  78. }
  79. if(!value["NextToken"].isNull())
  80. nextToken_ = value["NextToken"].asString();
  81. }
  82. std::string DescribeRouteEntryListResult::getNextToken()const
  83. {
  84. return nextToken_;
  85. }
  86. std::vector<DescribeRouteEntryListResult::RouteEntry> DescribeRouteEntryListResult::getRouteEntrys()const
  87. {
  88. return routeEntrys_;
  89. }