ListApmResult.cc 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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/elasticsearch/model/ListApmResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Elasticsearch;
  19. using namespace AlibabaCloud::Elasticsearch::Model;
  20. ListApmResult::ListApmResult() :
  21. ServiceResult()
  22. {}
  23. ListApmResult::ListApmResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListApmResult::~ListApmResult()
  29. {}
  30. void ListApmResult::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"]["返回结果"];
  37. for (auto valueResult返回结果 : allResultNode)
  38. {
  39. 返回结果 resultObject;
  40. if(!valueResult返回结果["createdAt"].isNull())
  41. resultObject.createdAt = valueResult返回结果["createdAt"].asString();
  42. if(!valueResult返回结果["deployedReplica"].isNull())
  43. resultObject.deployedReplica = std::stol(valueResult返回结果["deployedReplica"].asString());
  44. if(!valueResult返回结果["description"].isNull())
  45. resultObject.description = valueResult返回结果["description"].asString();
  46. if(!valueResult返回结果["instanceId"].isNull())
  47. resultObject.instanceId = valueResult返回结果["instanceId"].asString();
  48. if(!valueResult返回结果["nodeAmount"].isNull())
  49. resultObject.nodeAmount = std::stol(valueResult返回结果["nodeAmount"].asString());
  50. if(!valueResult返回结果["outputES"].isNull())
  51. resultObject.outputES = valueResult返回结果["outputES"].asString();
  52. if(!valueResult返回结果["outputESUserName"].isNull())
  53. resultObject.outputESUserName = valueResult返回结果["outputESUserName"].asString();
  54. if(!valueResult返回结果["ownerId"].isNull())
  55. resultObject.ownerId = valueResult返回结果["ownerId"].asString();
  56. if(!valueResult返回结果["paymentType"].isNull())
  57. resultObject.paymentType = valueResult返回结果["paymentType"].asString();
  58. if(!valueResult返回结果["region"].isNull())
  59. resultObject.region = valueResult返回结果["region"].asString();
  60. if(!valueResult返回结果["replica"].isNull())
  61. resultObject.replica = std::stol(valueResult返回结果["replica"].asString());
  62. if(!valueResult返回结果["resourceSpec"].isNull())
  63. resultObject.resourceSpec = valueResult返回结果["resourceSpec"].asString();
  64. if(!valueResult返回结果["status"].isNull())
  65. resultObject.status = valueResult返回结果["status"].asString();
  66. if(!valueResult返回结果["version"].isNull())
  67. resultObject.version = valueResult返回结果["version"].asString();
  68. if(!valueResult返回结果["vpcId"].isNull())
  69. resultObject.vpcId = valueResult返回结果["vpcId"].asString();
  70. if(!valueResult返回结果["vsArea"].isNull())
  71. resultObject.vsArea = valueResult返回结果["vsArea"].asString();
  72. if(!valueResult返回结果["vswitchId"].isNull())
  73. resultObject.vswitchId = valueResult返回结果["vswitchId"].asString();
  74. result_.push_back(resultObject);
  75. }
  76. auto headersNode = value["Headers"];
  77. if(!headersNode["X-Total-Count"].isNull())
  78. headers_.xTotalCount = std::stol(headersNode["X-Total-Count"].asString());
  79. }
  80. ListApmResult::Headers ListApmResult::getHeaders()const
  81. {
  82. return headers_;
  83. }
  84. std::vector<ListApmResult::返回结果> ListApmResult::getResult()const
  85. {
  86. return result_;
  87. }