DescribeGtmLogsResult.cc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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/DescribeGtmLogsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Alidns;
  19. using namespace AlibabaCloud::Alidns::Model;
  20. DescribeGtmLogsResult::DescribeGtmLogsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeGtmLogsResult::DescribeGtmLogsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeGtmLogsResult::~DescribeGtmLogsResult()
  29. {}
  30. void DescribeGtmLogsResult::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 allLogsNode = value["Logs"]["Log"];
  37. for (auto valueLogsLog : allLogsNode)
  38. {
  39. Log logsObject;
  40. if(!valueLogsLog["OperTime"].isNull())
  41. logsObject.operTime = valueLogsLog["OperTime"].asString();
  42. if(!valueLogsLog["OperAction"].isNull())
  43. logsObject.operAction = valueLogsLog["OperAction"].asString();
  44. if(!valueLogsLog["EntityType"].isNull())
  45. logsObject.entityType = valueLogsLog["EntityType"].asString();
  46. if(!valueLogsLog["EntityId"].isNull())
  47. logsObject.entityId = valueLogsLog["EntityId"].asString();
  48. if(!valueLogsLog["EntityName"].isNull())
  49. logsObject.entityName = valueLogsLog["EntityName"].asString();
  50. if(!valueLogsLog["OperIp"].isNull())
  51. logsObject.operIp = valueLogsLog["OperIp"].asString();
  52. if(!valueLogsLog["OperTimestamp"].isNull())
  53. logsObject.operTimestamp = std::stol(valueLogsLog["OperTimestamp"].asString());
  54. if(!valueLogsLog["Id"].isNull())
  55. logsObject.id = std::stol(valueLogsLog["Id"].asString());
  56. if(!valueLogsLog["Content"].isNull())
  57. logsObject.content = valueLogsLog["Content"].asString();
  58. logs_.push_back(logsObject);
  59. }
  60. if(!value["TotalItems"].isNull())
  61. totalItems_ = std::stoi(value["TotalItems"].asString());
  62. if(!value["TotalPages"].isNull())
  63. totalPages_ = std::stoi(value["TotalPages"].asString());
  64. if(!value["PageSize"].isNull())
  65. pageSize_ = std::stoi(value["PageSize"].asString());
  66. if(!value["PageNumber"].isNull())
  67. pageNumber_ = std::stoi(value["PageNumber"].asString());
  68. }
  69. int DescribeGtmLogsResult::getPageSize()const
  70. {
  71. return pageSize_;
  72. }
  73. int DescribeGtmLogsResult::getPageNumber()const
  74. {
  75. return pageNumber_;
  76. }
  77. int DescribeGtmLogsResult::getTotalPages()const
  78. {
  79. return totalPages_;
  80. }
  81. std::vector<DescribeGtmLogsResult::Log> DescribeGtmLogsResult::getLogs()const
  82. {
  83. return logs_;
  84. }
  85. int DescribeGtmLogsResult::getTotalItems()const
  86. {
  87. return totalItems_;
  88. }