DescribeCustomLinesResult.cc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/alidns/model/DescribeCustomLinesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Alidns;
  19. using namespace AlibabaCloud::Alidns::Model;
  20. DescribeCustomLinesResult::DescribeCustomLinesResult() :
  21. ServiceResult()
  22. {}
  23. DescribeCustomLinesResult::DescribeCustomLinesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeCustomLinesResult::~DescribeCustomLinesResult()
  29. {}
  30. void DescribeCustomLinesResult::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 allCustomLinesNode = value["CustomLines"]["CustomLine"];
  37. for (auto valueCustomLinesCustomLine : allCustomLinesNode)
  38. {
  39. CustomLine customLinesObject;
  40. if(!valueCustomLinesCustomLine["Id"].isNull())
  41. customLinesObject.id = std::stol(valueCustomLinesCustomLine["Id"].asString());
  42. if(!valueCustomLinesCustomLine["Name"].isNull())
  43. customLinesObject.name = valueCustomLinesCustomLine["Name"].asString();
  44. if(!valueCustomLinesCustomLine["CreateTime"].isNull())
  45. customLinesObject.createTime = valueCustomLinesCustomLine["CreateTime"].asString();
  46. if(!valueCustomLinesCustomLine["CreateTimestamp"].isNull())
  47. customLinesObject.createTimestamp = std::stol(valueCustomLinesCustomLine["CreateTimestamp"].asString());
  48. if(!valueCustomLinesCustomLine["IpSegments"].isNull())
  49. customLinesObject.ipSegments = valueCustomLinesCustomLine["IpSegments"].asString();
  50. if(!valueCustomLinesCustomLine["Code"].isNull())
  51. customLinesObject.code = valueCustomLinesCustomLine["Code"].asString();
  52. auto allIpSegmentListNode = allCustomLinesNode["IpSegmentList"]["IpSegment"];
  53. for (auto allCustomLinesNodeIpSegmentListIpSegment : allIpSegmentListNode)
  54. {
  55. CustomLine::IpSegment ipSegmentListObject;
  56. if(!allCustomLinesNodeIpSegmentListIpSegment["Name"].isNull())
  57. ipSegmentListObject.name = allCustomLinesNodeIpSegmentListIpSegment["Name"].asString();
  58. if(!allCustomLinesNodeIpSegmentListIpSegment["StartIp"].isNull())
  59. ipSegmentListObject.startIp = allCustomLinesNodeIpSegmentListIpSegment["StartIp"].asString();
  60. if(!allCustomLinesNodeIpSegmentListIpSegment["EndIp"].isNull())
  61. ipSegmentListObject.endIp = allCustomLinesNodeIpSegmentListIpSegment["EndIp"].asString();
  62. customLinesObject.ipSegmentList.push_back(ipSegmentListObject);
  63. }
  64. customLines_.push_back(customLinesObject);
  65. }
  66. if(!value["TotalItems"].isNull())
  67. totalItems_ = std::stoi(value["TotalItems"].asString());
  68. if(!value["PageNumber"].isNull())
  69. pageNumber_ = std::stoi(value["PageNumber"].asString());
  70. if(!value["PageSize"].isNull())
  71. pageSize_ = std::stoi(value["PageSize"].asString());
  72. if(!value["TotalPages"].isNull())
  73. totalPages_ = std::stoi(value["TotalPages"].asString());
  74. }
  75. int DescribeCustomLinesResult::getPageSize()const
  76. {
  77. return pageSize_;
  78. }
  79. int DescribeCustomLinesResult::getPageNumber()const
  80. {
  81. return pageNumber_;
  82. }
  83. int DescribeCustomLinesResult::getTotalPages()const
  84. {
  85. return totalPages_;
  86. }
  87. std::vector<DescribeCustomLinesResult::CustomLine> DescribeCustomLinesResult::getCustomLines()const
  88. {
  89. return customLines_;
  90. }
  91. int DescribeCustomLinesResult::getTotalItems()const
  92. {
  93. return totalItems_;
  94. }