MetastoreListKafkaTopicResult.cc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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/emr/model/MetastoreListKafkaTopicResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Emr;
  19. using namespace AlibabaCloud::Emr::Model;
  20. MetastoreListKafkaTopicResult::MetastoreListKafkaTopicResult() :
  21. ServiceResult()
  22. {}
  23. MetastoreListKafkaTopicResult::MetastoreListKafkaTopicResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. MetastoreListKafkaTopicResult::~MetastoreListKafkaTopicResult()
  29. {}
  30. void MetastoreListKafkaTopicResult::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 allTopicList = value["TopicList"]["Topic"];
  37. for (auto value : allTopicList)
  38. {
  39. Topic topicListObject;
  40. if(!value["Id"].isNull())
  41. topicListObject.id = value["Id"].asString();
  42. if(!value["DataSourceId"].isNull())
  43. topicListObject.dataSourceId = value["DataSourceId"].asString();
  44. if(!value["TopicName"].isNull())
  45. topicListObject.topicName = value["TopicName"].asString();
  46. if(!value["NumPartitions"].isNull())
  47. topicListObject.numPartitions = std::stoi(value["NumPartitions"].asString());
  48. if(!value["ReplicationFactor"].isNull())
  49. topicListObject.replicationFactor = std::stoi(value["ReplicationFactor"].asString());
  50. if(!value["GmtCreate"].isNull())
  51. topicListObject.gmtCreate = std::stol(value["GmtCreate"].asString());
  52. if(!value["GmtModified"].isNull())
  53. topicListObject.gmtModified = std::stol(value["GmtModified"].asString());
  54. auto allAdvancedConfigList = value["AdvancedConfigList"]["AdvancedConfig"];
  55. for (auto value : allAdvancedConfigList)
  56. {
  57. Topic::AdvancedConfig advancedConfigListObject;
  58. if(!value["Key"].isNull())
  59. advancedConfigListObject.key = value["Key"].asString();
  60. if(!value["Value"].isNull())
  61. advancedConfigListObject.value = value["Value"].asString();
  62. topicListObject.advancedConfigList.push_back(advancedConfigListObject);
  63. }
  64. auto clusterNode = value["Cluster"];
  65. if(!clusterNode["ClusterBizId"].isNull())
  66. topicListObject.cluster.clusterBizId = clusterNode["ClusterBizId"].asString();
  67. if(!clusterNode["ClusterName"].isNull())
  68. topicListObject.cluster.clusterName = clusterNode["ClusterName"].asString();
  69. if(!clusterNode["ClusterStatus"].isNull())
  70. topicListObject.cluster.clusterStatus = clusterNode["ClusterStatus"].asString();
  71. topicList_.push_back(topicListObject);
  72. }
  73. if(!value["TotalCount"].isNull())
  74. totalCount_ = std::stoi(value["TotalCount"].asString());
  75. if(!value["PageNumber"].isNull())
  76. pageNumber_ = std::stoi(value["PageNumber"].asString());
  77. if(!value["PageSize"].isNull())
  78. pageSize_ = std::stoi(value["PageSize"].asString());
  79. }
  80. int MetastoreListKafkaTopicResult::getTotalCount()const
  81. {
  82. return totalCount_;
  83. }
  84. int MetastoreListKafkaTopicResult::getPageSize()const
  85. {
  86. return pageSize_;
  87. }
  88. int MetastoreListKafkaTopicResult::getPageNumber()const
  89. {
  90. return pageNumber_;
  91. }
  92. std::vector<MetastoreListKafkaTopicResult::Topic> MetastoreListKafkaTopicResult::getTopicList()const
  93. {
  94. return topicList_;
  95. }