ListDataStreamsResult.cc 4.2 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/es-serverless/model/ListDataStreamsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Es_serverless;
  19. using namespace AlibabaCloud::Es_serverless::Model;
  20. ListDataStreamsResult::ListDataStreamsResult() :
  21. ServiceResult()
  22. {}
  23. ListDataStreamsResult::ListDataStreamsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListDataStreamsResult::~ListDataStreamsResult()
  29. {}
  30. void ListDataStreamsResult::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 allresultNode = value["result"]["dataStream"];
  37. for (auto valueresultdataStream : allresultNode)
  38. {
  39. DataStream resultObject;
  40. if(!valueresultdataStream["appName"].isNull())
  41. resultObject.appName = valueresultdataStream["appName"].asString();
  42. if(!valueresultdataStream["regionId"].isNull())
  43. resultObject.regionId = valueresultdataStream["regionId"].asString();
  44. if(!valueresultdataStream["deletePhase"].isNull())
  45. resultObject.deletePhase = valueresultdataStream["deletePhase"].asString();
  46. if(!valueresultdataStream["dataStreamName"].isNull())
  47. resultObject.dataStreamName = valueresultdataStream["dataStreamName"].asString();
  48. if(!valueresultdataStream["dataStreamId"].isNull())
  49. resultObject.dataStreamId = valueresultdataStream["dataStreamId"].asString();
  50. if(!valueresultdataStream["type"].isNull())
  51. resultObject.type = valueresultdataStream["type"].asString();
  52. if(!valueresultdataStream["createTime"].isNull())
  53. resultObject.createTime = valueresultdataStream["createTime"].asString();
  54. if(!valueresultdataStream["timeStampKey"].isNull())
  55. resultObject.timeStampKey = valueresultdataStream["timeStampKey"].asString();
  56. auto _templateNode = value["template"];
  57. auto allmappingsNode = _templateNode["mappings"]["mappingsItem"];
  58. for (auto _templateNodemappingsmappingsItem : allmappingsNode)
  59. {
  60. DataStream::_Template::MappingsItem mappingsItemObject;
  61. if(!_templateNodemappingsmappingsItem["type"].isNull())
  62. mappingsItemObject.type = _templateNodemappingsmappingsItem["type"].asString();
  63. if(!_templateNodemappingsmappingsItem["caseSensitive"].isNull())
  64. mappingsItemObject.caseSensitive = _templateNodemappingsmappingsItem["caseSensitive"].asString() == "true";
  65. if(!_templateNodemappingsmappingsItem["docValues"].isNull())
  66. mappingsItemObject.docValues = _templateNodemappingsmappingsItem["docValues"].asString() == "true";
  67. if(!_templateNodemappingsmappingsItem["index"].isNull())
  68. mappingsItemObject.index = _templateNodemappingsmappingsItem["index"].asString() == "true";
  69. if(!_templateNodemappingsmappingsItem["key"].isNull())
  70. mappingsItemObject.key = _templateNodemappingsmappingsItem["key"].asString();
  71. auto allTokenizeOnChars = value["tokenizeOnChars"]["null"];
  72. for (auto value : allTokenizeOnChars)
  73. mappingsItemObject.tokenizeOnChars.push_back(value.asString());
  74. auto allProperties = value["properties"]["null"];
  75. for (auto value : allProperties)
  76. mappingsItemObject.properties.push_back(value.asString());
  77. resultObject._template.mappings.push_back(mappingsItemObject);
  78. }
  79. result_.push_back(resultObject);
  80. }
  81. if(!value["requestId"].isNull())
  82. requestId_ = value["requestId"].asString();
  83. if(!value["totalCount"].isNull())
  84. totalCount_ = std::stoi(value["totalCount"].asString());
  85. }
  86. std::vector<ListDataStreamsResult::DataStream> ListDataStreamsResult::getresult()const
  87. {
  88. return result_;
  89. }
  90. int ListDataStreamsResult::getTotalCount()const
  91. {
  92. return totalCount_;
  93. }
  94. std::string ListDataStreamsResult::getRequestId()const
  95. {
  96. return requestId_;
  97. }