DescribeCommonBandwidthPackagesResult.cc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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/DescribeCommonBandwidthPackagesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Vpc;
  19. using namespace AlibabaCloud::Vpc::Model;
  20. DescribeCommonBandwidthPackagesResult::DescribeCommonBandwidthPackagesResult() :
  21. ServiceResult()
  22. {}
  23. DescribeCommonBandwidthPackagesResult::DescribeCommonBandwidthPackagesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeCommonBandwidthPackagesResult::~DescribeCommonBandwidthPackagesResult()
  29. {}
  30. void DescribeCommonBandwidthPackagesResult::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 allCommonBandwidthPackages = value["CommonBandwidthPackages"]["CommonBandwidthPackage"];
  37. for (auto value : allCommonBandwidthPackages)
  38. {
  39. CommonBandwidthPackage commonBandwidthPackagesObject;
  40. if(!value["BandwidthPackageId"].isNull())
  41. commonBandwidthPackagesObject.bandwidthPackageId = value["BandwidthPackageId"].asString();
  42. if(!value["RegionId"].isNull())
  43. commonBandwidthPackagesObject.regionId = value["RegionId"].asString();
  44. if(!value["Name"].isNull())
  45. commonBandwidthPackagesObject.name = value["Name"].asString();
  46. if(!value["Description"].isNull())
  47. commonBandwidthPackagesObject.description = value["Description"].asString();
  48. if(!value["Bandwidth"].isNull())
  49. commonBandwidthPackagesObject.bandwidth = value["Bandwidth"].asString();
  50. if(!value["InstanceChargeType"].isNull())
  51. commonBandwidthPackagesObject.instanceChargeType = value["InstanceChargeType"].asString();
  52. if(!value["InternetChargeType"].isNull())
  53. commonBandwidthPackagesObject.internetChargeType = value["InternetChargeType"].asString();
  54. if(!value["BusinessStatus"].isNull())
  55. commonBandwidthPackagesObject.businessStatus = value["BusinessStatus"].asString();
  56. if(!value["CreationTime"].isNull())
  57. commonBandwidthPackagesObject.creationTime = value["CreationTime"].asString();
  58. if(!value["ExpiredTime"].isNull())
  59. commonBandwidthPackagesObject.expiredTime = value["ExpiredTime"].asString();
  60. if(!value["Status"].isNull())
  61. commonBandwidthPackagesObject.status = value["Status"].asString();
  62. if(!value["Ratio"].isNull())
  63. commonBandwidthPackagesObject.ratio = std::stoi(value["Ratio"].asString());
  64. if(!value["ResourceGroupId"].isNull())
  65. commonBandwidthPackagesObject.resourceGroupId = value["ResourceGroupId"].asString();
  66. if(!value["HasReservationData"].isNull())
  67. commonBandwidthPackagesObject.hasReservationData = value["HasReservationData"].asString();
  68. if(!value["ReservationBandwidth"].isNull())
  69. commonBandwidthPackagesObject.reservationBandwidth = value["ReservationBandwidth"].asString();
  70. if(!value["ReservationInternetChargeType"].isNull())
  71. commonBandwidthPackagesObject.reservationInternetChargeType = value["ReservationInternetChargeType"].asString();
  72. if(!value["ReservationActiveTime"].isNull())
  73. commonBandwidthPackagesObject.reservationActiveTime = value["ReservationActiveTime"].asString();
  74. if(!value["ReservationOrderType"].isNull())
  75. commonBandwidthPackagesObject.reservationOrderType = value["ReservationOrderType"].asString();
  76. if(!value["ISP"].isNull())
  77. commonBandwidthPackagesObject.iSP = value["ISP"].asString();
  78. auto allPublicIpAddresses = value["PublicIpAddresses"]["PublicIpAddresse"];
  79. for (auto value : allPublicIpAddresses)
  80. {
  81. CommonBandwidthPackage::PublicIpAddresse publicIpAddressesObject;
  82. if(!value["AllocationId"].isNull())
  83. publicIpAddressesObject.allocationId = value["AllocationId"].asString();
  84. if(!value["IpAddress"].isNull())
  85. publicIpAddressesObject.ipAddress = value["IpAddress"].asString();
  86. commonBandwidthPackagesObject.publicIpAddresses.push_back(publicIpAddressesObject);
  87. }
  88. commonBandwidthPackages_.push_back(commonBandwidthPackagesObject);
  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. int DescribeCommonBandwidthPackagesResult::getTotalCount()const
  98. {
  99. return totalCount_;
  100. }
  101. int DescribeCommonBandwidthPackagesResult::getPageSize()const
  102. {
  103. return pageSize_;
  104. }
  105. int DescribeCommonBandwidthPackagesResult::getPageNumber()const
  106. {
  107. return pageNumber_;
  108. }
  109. std::vector<DescribeCommonBandwidthPackagesResult::CommonBandwidthPackage> DescribeCommonBandwidthPackagesResult::getCommonBandwidthPackages()const
  110. {
  111. return commonBandwidthPackages_;
  112. }