DescribeAlertHistoryListResult.cc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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/DescribeAlertHistoryListResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Cms;
  19. using namespace AlibabaCloud::Cms::Model;
  20. DescribeAlertHistoryListResult::DescribeAlertHistoryListResult() :
  21. ServiceResult()
  22. {}
  23. DescribeAlertHistoryListResult::DescribeAlertHistoryListResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeAlertHistoryListResult::~DescribeAlertHistoryListResult()
  29. {}
  30. void DescribeAlertHistoryListResult::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 allAlarmHistoryListNode = value["AlarmHistoryList"]["AlarmHistory"];
  37. for (auto valueAlarmHistoryListAlarmHistory : allAlarmHistoryListNode)
  38. {
  39. AlarmHistory alarmHistoryListObject;
  40. if(!valueAlarmHistoryListAlarmHistory["RuleId"].isNull())
  41. alarmHistoryListObject.ruleId = valueAlarmHistoryListAlarmHistory["RuleId"].asString();
  42. if(!valueAlarmHistoryListAlarmHistory["GroupId"].isNull())
  43. alarmHistoryListObject.groupId = valueAlarmHistoryListAlarmHistory["GroupId"].asString();
  44. if(!valueAlarmHistoryListAlarmHistory["Namespace"].isNull())
  45. alarmHistoryListObject._namespace = valueAlarmHistoryListAlarmHistory["Namespace"].asString();
  46. if(!valueAlarmHistoryListAlarmHistory["MetricName"].isNull())
  47. alarmHistoryListObject.metricName = valueAlarmHistoryListAlarmHistory["MetricName"].asString();
  48. if(!valueAlarmHistoryListAlarmHistory["Dimensions"].isNull())
  49. alarmHistoryListObject.dimensions = valueAlarmHistoryListAlarmHistory["Dimensions"].asString();
  50. if(!valueAlarmHistoryListAlarmHistory["Expression"].isNull())
  51. alarmHistoryListObject.expression = valueAlarmHistoryListAlarmHistory["Expression"].asString();
  52. if(!valueAlarmHistoryListAlarmHistory["EvaluationCount"].isNull())
  53. alarmHistoryListObject.evaluationCount = std::stoi(valueAlarmHistoryListAlarmHistory["EvaluationCount"].asString());
  54. if(!valueAlarmHistoryListAlarmHistory["Value"].isNull())
  55. alarmHistoryListObject.value = valueAlarmHistoryListAlarmHistory["Value"].asString();
  56. if(!valueAlarmHistoryListAlarmHistory["AlertTime"].isNull())
  57. alarmHistoryListObject.alertTime = std::stol(valueAlarmHistoryListAlarmHistory["AlertTime"].asString());
  58. if(!valueAlarmHistoryListAlarmHistory["LastTime"].isNull())
  59. alarmHistoryListObject.lastTime = std::stol(valueAlarmHistoryListAlarmHistory["LastTime"].asString());
  60. if(!valueAlarmHistoryListAlarmHistory["Level"].isNull())
  61. alarmHistoryListObject.level = valueAlarmHistoryListAlarmHistory["Level"].asString();
  62. if(!valueAlarmHistoryListAlarmHistory["PreLevel"].isNull())
  63. alarmHistoryListObject.preLevel = valueAlarmHistoryListAlarmHistory["PreLevel"].asString();
  64. if(!valueAlarmHistoryListAlarmHistory["RuleName"].isNull())
  65. alarmHistoryListObject.ruleName = valueAlarmHistoryListAlarmHistory["RuleName"].asString();
  66. if(!valueAlarmHistoryListAlarmHistory["State"].isNull())
  67. alarmHistoryListObject.state = valueAlarmHistoryListAlarmHistory["State"].asString();
  68. if(!valueAlarmHistoryListAlarmHistory["Status"].isNull())
  69. alarmHistoryListObject.status = std::stoi(valueAlarmHistoryListAlarmHistory["Status"].asString());
  70. if(!valueAlarmHistoryListAlarmHistory["Webhooks"].isNull())
  71. alarmHistoryListObject.webhooks = valueAlarmHistoryListAlarmHistory["Webhooks"].asString();
  72. if(!valueAlarmHistoryListAlarmHistory["InstanceName"].isNull())
  73. alarmHistoryListObject.instanceName = valueAlarmHistoryListAlarmHistory["InstanceName"].asString();
  74. auto allContactGroups = value["ContactGroups"]["ContactGroup"];
  75. for (auto value : allContactGroups)
  76. alarmHistoryListObject.contactGroups.push_back(value.asString());
  77. auto allContacts = value["Contacts"]["Contact"];
  78. for (auto value : allContacts)
  79. alarmHistoryListObject.contacts.push_back(value.asString());
  80. auto allContactALIIMs = value["ContactALIIMs"]["ContactALIIM"];
  81. for (auto value : allContactALIIMs)
  82. alarmHistoryListObject.contactALIIMs.push_back(value.asString());
  83. auto allContactSmses = value["ContactSmses"]["ContactSms"];
  84. for (auto value : allContactSmses)
  85. alarmHistoryListObject.contactSmses.push_back(value.asString());
  86. auto allContactMails = value["ContactMails"]["ContactMail"];
  87. for (auto value : allContactMails)
  88. alarmHistoryListObject.contactMails.push_back(value.asString());
  89. alarmHistoryList_.push_back(alarmHistoryListObject);
  90. }
  91. if(!value["Success"].isNull())
  92. success_ = value["Success"].asString() == "true";
  93. if(!value["Code"].isNull())
  94. code_ = value["Code"].asString();
  95. if(!value["Message"].isNull())
  96. message_ = value["Message"].asString();
  97. if(!value["Total"].isNull())
  98. total_ = value["Total"].asString();
  99. }
  100. std::vector<DescribeAlertHistoryListResult::AlarmHistory> DescribeAlertHistoryListResult::getAlarmHistoryList()const
  101. {
  102. return alarmHistoryList_;
  103. }
  104. std::string DescribeAlertHistoryListResult::getMessage()const
  105. {
  106. return message_;
  107. }
  108. std::string DescribeAlertHistoryListResult::getTotal()const
  109. {
  110. return total_;
  111. }
  112. std::string DescribeAlertHistoryListResult::getCode()const
  113. {
  114. return code_;
  115. }
  116. bool DescribeAlertHistoryListResult::getSuccess()const
  117. {
  118. return success_;
  119. }