ListBandwidthPackagesResult.cc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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/ga/model/ListBandwidthPackagesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Ga;
  19. using namespace AlibabaCloud::Ga::Model;
  20. ListBandwidthPackagesResult::ListBandwidthPackagesResult() :
  21. ServiceResult()
  22. {}
  23. ListBandwidthPackagesResult::ListBandwidthPackagesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListBandwidthPackagesResult::~ListBandwidthPackagesResult()
  29. {}
  30. void ListBandwidthPackagesResult::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 allBandwidthPackagesNode = value["BandwidthPackages"]["BandwidthPackage"];
  37. for (auto valueBandwidthPackagesBandwidthPackage : allBandwidthPackagesNode)
  38. {
  39. BandwidthPackage bandwidthPackagesObject;
  40. if(!valueBandwidthPackagesBandwidthPackage["CbnGeographicRegionIdB"].isNull())
  41. bandwidthPackagesObject.cbnGeographicRegionIdB = valueBandwidthPackagesBandwidthPackage["CbnGeographicRegionIdB"].asString();
  42. if(!valueBandwidthPackagesBandwidthPackage["Description"].isNull())
  43. bandwidthPackagesObject.description = valueBandwidthPackagesBandwidthPackage["Description"].asString();
  44. if(!valueBandwidthPackagesBandwidthPackage["CbnGeographicRegionIdA"].isNull())
  45. bandwidthPackagesObject.cbnGeographicRegionIdA = valueBandwidthPackagesBandwidthPackage["CbnGeographicRegionIdA"].asString();
  46. if(!valueBandwidthPackagesBandwidthPackage["CreateTime"].isNull())
  47. bandwidthPackagesObject.createTime = valueBandwidthPackagesBandwidthPackage["CreateTime"].asString();
  48. if(!valueBandwidthPackagesBandwidthPackage["Name"].isNull())
  49. bandwidthPackagesObject.name = valueBandwidthPackagesBandwidthPackage["Name"].asString();
  50. if(!valueBandwidthPackagesBandwidthPackage["BandwidthType"].isNull())
  51. bandwidthPackagesObject.bandwidthType = valueBandwidthPackagesBandwidthPackage["BandwidthType"].asString();
  52. if(!valueBandwidthPackagesBandwidthPackage["Type"].isNull())
  53. bandwidthPackagesObject.type = valueBandwidthPackagesBandwidthPackage["Type"].asString();
  54. if(!valueBandwidthPackagesBandwidthPackage["ChargeType"].isNull())
  55. bandwidthPackagesObject.chargeType = valueBandwidthPackagesBandwidthPackage["ChargeType"].asString();
  56. if(!valueBandwidthPackagesBandwidthPackage["State"].isNull())
  57. bandwidthPackagesObject.state = valueBandwidthPackagesBandwidthPackage["State"].asString();
  58. if(!valueBandwidthPackagesBandwidthPackage["ExpiredTime"].isNull())
  59. bandwidthPackagesObject.expiredTime = valueBandwidthPackagesBandwidthPackage["ExpiredTime"].asString();
  60. if(!valueBandwidthPackagesBandwidthPackage["Bandwidth"].isNull())
  61. bandwidthPackagesObject.bandwidth = std::stoi(valueBandwidthPackagesBandwidthPackage["Bandwidth"].asString());
  62. if(!valueBandwidthPackagesBandwidthPackage["BandwidthPackageId"].isNull())
  63. bandwidthPackagesObject.bandwidthPackageId = valueBandwidthPackagesBandwidthPackage["BandwidthPackageId"].asString();
  64. if(!valueBandwidthPackagesBandwidthPackage["Ratio"].isNull())
  65. bandwidthPackagesObject.ratio = std::stoi(valueBandwidthPackagesBandwidthPackage["Ratio"].asString());
  66. if(!valueBandwidthPackagesBandwidthPackage["RegionId"].isNull())
  67. bandwidthPackagesObject.regionId = valueBandwidthPackagesBandwidthPackage["RegionId"].asString();
  68. if(!valueBandwidthPackagesBandwidthPackage["BillingType"].isNull())
  69. bandwidthPackagesObject.billingType = valueBandwidthPackagesBandwidthPackage["BillingType"].asString();
  70. auto allAccelerators = value["Accelerators"]["Accelerator"];
  71. for (auto value : allAccelerators)
  72. bandwidthPackagesObject.accelerators.push_back(value.asString());
  73. bandwidthPackages_.push_back(bandwidthPackagesObject);
  74. }
  75. if(!value["TotalCount"].isNull())
  76. totalCount_ = std::stoi(value["TotalCount"].asString());
  77. if(!value["PageSize"].isNull())
  78. pageSize_ = std::stoi(value["PageSize"].asString());
  79. if(!value["PageNumber"].isNull())
  80. pageNumber_ = std::stoi(value["PageNumber"].asString());
  81. }
  82. int ListBandwidthPackagesResult::getTotalCount()const
  83. {
  84. return totalCount_;
  85. }
  86. int ListBandwidthPackagesResult::getPageSize()const
  87. {
  88. return pageSize_;
  89. }
  90. int ListBandwidthPackagesResult::getPageNumber()const
  91. {
  92. return pageNumber_;
  93. }
  94. std::vector<ListBandwidthPackagesResult::BandwidthPackage> ListBandwidthPackagesResult::getBandwidthPackages()const
  95. {
  96. return bandwidthPackages_;
  97. }