DescribeGroupMonitoringAgentProcessResult.cc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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/DescribeGroupMonitoringAgentProcessResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Cms;
  19. using namespace AlibabaCloud::Cms::Model;
  20. DescribeGroupMonitoringAgentProcessResult::DescribeGroupMonitoringAgentProcessResult() :
  21. ServiceResult()
  22. {}
  23. DescribeGroupMonitoringAgentProcessResult::DescribeGroupMonitoringAgentProcessResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeGroupMonitoringAgentProcessResult::~DescribeGroupMonitoringAgentProcessResult()
  29. {}
  30. void DescribeGroupMonitoringAgentProcessResult::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 allProcessesNode = value["Processes"]["Process"];
  37. for (auto valueProcessesProcess : allProcessesNode)
  38. {
  39. Process processesObject;
  40. if(!valueProcessesProcess["Id"].isNull())
  41. processesObject.id = valueProcessesProcess["Id"].asString();
  42. if(!valueProcessesProcess["GroupId"].isNull())
  43. processesObject.groupId = valueProcessesProcess["GroupId"].asString();
  44. if(!valueProcessesProcess["ProcessName"].isNull())
  45. processesObject.processName = valueProcessesProcess["ProcessName"].asString();
  46. if(!valueProcessesProcess["MatchExpressFilterRelation"].isNull())
  47. processesObject.matchExpressFilterRelation = valueProcessesProcess["MatchExpressFilterRelation"].asString();
  48. auto allMatchExpressNode = allProcessesNode["MatchExpress"]["MatchExpressItem"];
  49. for (auto allProcessesNodeMatchExpressMatchExpressItem : allMatchExpressNode)
  50. {
  51. Process::MatchExpressItem matchExpressObject;
  52. if(!allProcessesNodeMatchExpressMatchExpressItem["Name"].isNull())
  53. matchExpressObject.name = allProcessesNodeMatchExpressMatchExpressItem["Name"].asString();
  54. if(!allProcessesNodeMatchExpressMatchExpressItem["Function"].isNull())
  55. matchExpressObject.function = allProcessesNodeMatchExpressMatchExpressItem["Function"].asString();
  56. if(!allProcessesNodeMatchExpressMatchExpressItem["Value"].isNull())
  57. matchExpressObject.value = allProcessesNodeMatchExpressMatchExpressItem["Value"].asString();
  58. processesObject.matchExpress.push_back(matchExpressObject);
  59. }
  60. auto allAlertConfigNode = allProcessesNode["AlertConfig"]["AlertConfigItem"];
  61. for (auto allProcessesNodeAlertConfigAlertConfigItem : allAlertConfigNode)
  62. {
  63. Process::AlertConfigItem alertConfigObject;
  64. if(!allProcessesNodeAlertConfigAlertConfigItem["EffectiveInterval"].isNull())
  65. alertConfigObject.effectiveInterval = allProcessesNodeAlertConfigAlertConfigItem["EffectiveInterval"].asString();
  66. if(!allProcessesNodeAlertConfigAlertConfigItem["NoEffectiveInterval"].isNull())
  67. alertConfigObject.noEffectiveInterval = allProcessesNodeAlertConfigAlertConfigItem["NoEffectiveInterval"].asString();
  68. if(!allProcessesNodeAlertConfigAlertConfigItem["SilenceTime"].isNull())
  69. alertConfigObject.silenceTime = allProcessesNodeAlertConfigAlertConfigItem["SilenceTime"].asString();
  70. if(!allProcessesNodeAlertConfigAlertConfigItem["Webhook"].isNull())
  71. alertConfigObject.webhook = allProcessesNodeAlertConfigAlertConfigItem["Webhook"].asString();
  72. if(!allProcessesNodeAlertConfigAlertConfigItem["EscalationsLevel"].isNull())
  73. alertConfigObject.escalationsLevel = allProcessesNodeAlertConfigAlertConfigItem["EscalationsLevel"].asString();
  74. if(!allProcessesNodeAlertConfigAlertConfigItem["ComparisonOperator"].isNull())
  75. alertConfigObject.comparisonOperator = allProcessesNodeAlertConfigAlertConfigItem["ComparisonOperator"].asString();
  76. if(!allProcessesNodeAlertConfigAlertConfigItem["Statistics"].isNull())
  77. alertConfigObject.statistics = allProcessesNodeAlertConfigAlertConfigItem["Statistics"].asString();
  78. if(!allProcessesNodeAlertConfigAlertConfigItem["Threshold"].isNull())
  79. alertConfigObject.threshold = allProcessesNodeAlertConfigAlertConfigItem["Threshold"].asString();
  80. if(!allProcessesNodeAlertConfigAlertConfigItem["Times"].isNull())
  81. alertConfigObject.times = allProcessesNodeAlertConfigAlertConfigItem["Times"].asString();
  82. processesObject.alertConfig.push_back(alertConfigObject);
  83. }
  84. processes_.push_back(processesObject);
  85. }
  86. if(!value["Code"].isNull())
  87. code_ = value["Code"].asString();
  88. if(!value["Message"].isNull())
  89. message_ = value["Message"].asString();
  90. if(!value["Success"].isNull())
  91. success_ = value["Success"].asString() == "true";
  92. }
  93. std::string DescribeGroupMonitoringAgentProcessResult::getMessage()const
  94. {
  95. return message_;
  96. }
  97. std::vector<DescribeGroupMonitoringAgentProcessResult::Process> DescribeGroupMonitoringAgentProcessResult::getProcesses()const
  98. {
  99. return processes_;
  100. }
  101. std::string DescribeGroupMonitoringAgentProcessResult::getCode()const
  102. {
  103. return code_;
  104. }
  105. bool DescribeGroupMonitoringAgentProcessResult::getSuccess()const
  106. {
  107. return success_;
  108. }