UpdateCollectorNameResult.cc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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/UpdateCollectorNameResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Elasticsearch;
  19. using namespace AlibabaCloud::Elasticsearch::Model;
  20. UpdateCollectorNameResult::UpdateCollectorNameResult() :
  21. ServiceResult()
  22. {}
  23. UpdateCollectorNameResult::UpdateCollectorNameResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. UpdateCollectorNameResult::~UpdateCollectorNameResult()
  29. {}
  30. void UpdateCollectorNameResult::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 resultNode = value["Result"];
  37. if(!resultNode["gmtCreatedTime"].isNull())
  38. result_.gmtCreatedTime = resultNode["gmtCreatedTime"].asString();
  39. if(!resultNode["gmtUpdateTime"].isNull())
  40. result_.gmtUpdateTime = resultNode["gmtUpdateTime"].asString();
  41. if(!resultNode["name"].isNull())
  42. result_.name = resultNode["name"].asString();
  43. if(!resultNode["resId"].isNull())
  44. result_.resId = resultNode["resId"].asString();
  45. if(!resultNode["resVersion"].isNull())
  46. result_.resVersion = resultNode["resVersion"].asString();
  47. if(!resultNode["vpcId"].isNull())
  48. result_.vpcId = resultNode["vpcId"].asString();
  49. if(!resultNode["resType"].isNull())
  50. result_.resType = resultNode["resType"].asString();
  51. if(!resultNode["ownerId"].isNull())
  52. result_.ownerId = resultNode["ownerId"].asString();
  53. if(!resultNode["status"].isNull())
  54. result_.status = resultNode["status"].asString();
  55. if(!resultNode["dryRun"].isNull())
  56. result_.dryRun = resultNode["dryRun"].asString() == "true";
  57. auto allconfigsNode = resultNode["configs"]["configsItem"];
  58. for (auto resultNodeconfigsconfigsItem : allconfigsNode)
  59. {
  60. Result::ConfigsItem configsItemObject;
  61. if(!resultNodeconfigsconfigsItem["fileName"].isNull())
  62. configsItemObject.fileName = resultNodeconfigsconfigsItem["fileName"].asString();
  63. if(!resultNodeconfigsconfigsItem["content"].isNull())
  64. configsItemObject.content = resultNodeconfigsconfigsItem["content"].asString();
  65. result_.configs.push_back(configsItemObject);
  66. }
  67. auto allextendConfigsNode = resultNode["extendConfigs"]["extendConfigsItem"];
  68. for (auto resultNodeextendConfigsextendConfigsItem : allextendConfigsNode)
  69. {
  70. Result::ExtendConfigsItem extendConfigsItemObject;
  71. if(!resultNodeextendConfigsextendConfigsItem["configType"].isNull())
  72. extendConfigsItemObject.configType = resultNodeextendConfigsextendConfigsItem["configType"].asString();
  73. if(!resultNodeextendConfigsextendConfigsItem["instanceId"].isNull())
  74. extendConfigsItemObject.instanceId = resultNodeextendConfigsextendConfigsItem["instanceId"].asString();
  75. if(!resultNodeextendConfigsextendConfigsItem["instanceType"].isNull())
  76. extendConfigsItemObject.instanceType = resultNodeextendConfigsextendConfigsItem["instanceType"].asString();
  77. if(!resultNodeextendConfigsextendConfigsItem["protocol"].isNull())
  78. extendConfigsItemObject.protocol = resultNodeextendConfigsextendConfigsItem["protocol"].asString();
  79. if(!resultNodeextendConfigsextendConfigsItem["userName"].isNull())
  80. extendConfigsItemObject.userName = resultNodeextendConfigsextendConfigsItem["userName"].asString();
  81. if(!resultNodeextendConfigsextendConfigsItem["enableMonitoring"].isNull())
  82. extendConfigsItemObject.enableMonitoring = resultNodeextendConfigsextendConfigsItem["enableMonitoring"].asString() == "true";
  83. if(!resultNodeextendConfigsextendConfigsItem["type"].isNull())
  84. extendConfigsItemObject.type = resultNodeextendConfigsextendConfigsItem["type"].asString();
  85. if(!resultNodeextendConfigsextendConfigsItem["groupId"].isNull())
  86. extendConfigsItemObject.groupId = resultNodeextendConfigsextendConfigsItem["groupId"].asString();
  87. if(!resultNodeextendConfigsextendConfigsItem["host"].isNull())
  88. extendConfigsItemObject.host = resultNodeextendConfigsextendConfigsItem["host"].asString();
  89. if(!resultNodeextendConfigsextendConfigsItem["kibanaHost"].isNull())
  90. extendConfigsItemObject.kibanaHost = resultNodeextendConfigsextendConfigsItem["kibanaHost"].asString();
  91. auto allmachinesNode = resultNodeextendConfigsextendConfigsItem["machines"]["machinesItem"];
  92. for (auto resultNodeextendConfigsextendConfigsItemmachinesmachinesItem : allmachinesNode)
  93. {
  94. Result::ExtendConfigsItem::MachinesItem machinesObject;
  95. if(!resultNodeextendConfigsextendConfigsItemmachinesmachinesItem["instanceId"].isNull())
  96. machinesObject.instanceId = resultNodeextendConfigsextendConfigsItemmachinesmachinesItem["instanceId"].asString();
  97. if(!resultNodeextendConfigsextendConfigsItemmachinesmachinesItem["agentStatus"].isNull())
  98. machinesObject.agentStatus = resultNodeextendConfigsextendConfigsItemmachinesmachinesItem["agentStatus"].asString();
  99. extendConfigsItemObject.machines.push_back(machinesObject);
  100. }
  101. auto allHosts = value["hosts"]["hosts"];
  102. for (auto value : allHosts)
  103. extendConfigsItemObject.hosts.push_back(value.asString());
  104. result_.extendConfigs.push_back(extendConfigsItemObject);
  105. }
  106. auto allCollectorPaths = resultNode["collectorPaths"]["collectorPaths"];
  107. for (auto value : allCollectorPaths)
  108. result_.collectorPaths.push_back(value.asString());
  109. }
  110. UpdateCollectorNameResult::Result UpdateCollectorNameResult::getResult()const
  111. {
  112. return result_;
  113. }