DescribeMonitoringAgentHostsResult.cc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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/cms/model/DescribeMonitoringAgentHostsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Cms;
  19. using namespace AlibabaCloud::Cms::Model;
  20. DescribeMonitoringAgentHostsResult::DescribeMonitoringAgentHostsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeMonitoringAgentHostsResult::DescribeMonitoringAgentHostsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeMonitoringAgentHostsResult::~DescribeMonitoringAgentHostsResult()
  29. {}
  30. void DescribeMonitoringAgentHostsResult::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 allHostsNode = value["Hosts"]["Host"];
  37. for (auto valueHostsHost : allHostsNode)
  38. {
  39. Host hostsObject;
  40. if(!valueHostsHost["InstanceId"].isNull())
  41. hostsObject.instanceId = valueHostsHost["InstanceId"].asString();
  42. if(!valueHostsHost["SerialNumber"].isNull())
  43. hostsObject.serialNumber = valueHostsHost["SerialNumber"].asString();
  44. if(!valueHostsHost["HostName"].isNull())
  45. hostsObject.hostName = valueHostsHost["HostName"].asString();
  46. if(!valueHostsHost["AliUid"].isNull())
  47. hostsObject.aliUid = std::stol(valueHostsHost["AliUid"].asString());
  48. if(!valueHostsHost["OperatingSystem"].isNull())
  49. hostsObject.operatingSystem = valueHostsHost["OperatingSystem"].asString();
  50. if(!valueHostsHost["IpGroup"].isNull())
  51. hostsObject.ipGroup = valueHostsHost["IpGroup"].asString();
  52. if(!valueHostsHost["Region"].isNull())
  53. hostsObject.region = valueHostsHost["Region"].asString();
  54. if(!valueHostsHost["AgentVersion"].isNull())
  55. hostsObject.agentVersion = valueHostsHost["AgentVersion"].asString();
  56. if(!valueHostsHost["EipAddress"].isNull())
  57. hostsObject.eipAddress = valueHostsHost["EipAddress"].asString();
  58. if(!valueHostsHost["EipId"].isNull())
  59. hostsObject.eipId = valueHostsHost["EipId"].asString();
  60. if(!valueHostsHost["isAliyunHost"].isNull())
  61. hostsObject.isAliyunHost = valueHostsHost["isAliyunHost"].asString() == "true";
  62. if(!valueHostsHost["NatIp"].isNull())
  63. hostsObject.natIp = valueHostsHost["NatIp"].asString();
  64. if(!valueHostsHost["NetworkType"].isNull())
  65. hostsObject.networkType = valueHostsHost["NetworkType"].asString();
  66. if(!valueHostsHost["InstanceTypeFamily"].isNull())
  67. hostsObject.instanceTypeFamily = valueHostsHost["InstanceTypeFamily"].asString();
  68. hosts_.push_back(hostsObject);
  69. }
  70. if(!value["Code"].isNull())
  71. code_ = value["Code"].asString();
  72. if(!value["Message"].isNull())
  73. message_ = value["Message"].asString();
  74. if(!value["Success"].isNull())
  75. success_ = value["Success"].asString() == "true";
  76. if(!value["PageTotal"].isNull())
  77. pageTotal_ = std::stoi(value["PageTotal"].asString());
  78. if(!value["Total"].isNull())
  79. total_ = std::stoi(value["Total"].asString());
  80. }
  81. std::vector<DescribeMonitoringAgentHostsResult::Host> DescribeMonitoringAgentHostsResult::getHosts()const
  82. {
  83. return hosts_;
  84. }
  85. std::string DescribeMonitoringAgentHostsResult::getMessage()const
  86. {
  87. return message_;
  88. }
  89. int DescribeMonitoringAgentHostsResult::getPageTotal()const
  90. {
  91. return pageTotal_;
  92. }
  93. int DescribeMonitoringAgentHostsResult::getTotal()const
  94. {
  95. return total_;
  96. }
  97. std::string DescribeMonitoringAgentHostsResult::getCode()const
  98. {
  99. return code_;
  100. }
  101. bool DescribeMonitoringAgentHostsResult::getSuccess()const
  102. {
  103. return success_;
  104. }