DescribeEventRuleListResult.cc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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/DescribeEventRuleListResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Cms;
  19. using namespace AlibabaCloud::Cms::Model;
  20. DescribeEventRuleListResult::DescribeEventRuleListResult() :
  21. ServiceResult()
  22. {}
  23. DescribeEventRuleListResult::DescribeEventRuleListResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeEventRuleListResult::~DescribeEventRuleListResult()
  29. {}
  30. void DescribeEventRuleListResult::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 allEventRulesNode = value["EventRules"]["EventRule"];
  37. for (auto valueEventRulesEventRule : allEventRulesNode)
  38. {
  39. EventRule eventRulesObject;
  40. if(!valueEventRulesEventRule["Name"].isNull())
  41. eventRulesObject.name = valueEventRulesEventRule["Name"].asString();
  42. if(!valueEventRulesEventRule["GroupId"].isNull())
  43. eventRulesObject.groupId = valueEventRulesEventRule["GroupId"].asString();
  44. if(!valueEventRulesEventRule["EventType"].isNull())
  45. eventRulesObject.eventType = valueEventRulesEventRule["EventType"].asString();
  46. if(!valueEventRulesEventRule["State"].isNull())
  47. eventRulesObject.state = valueEventRulesEventRule["State"].asString();
  48. if(!valueEventRulesEventRule["Description"].isNull())
  49. eventRulesObject.description = valueEventRulesEventRule["Description"].asString();
  50. auto allEventPatternNode = allEventRulesNode["EventPattern"]["EventPatternItem"];
  51. for (auto allEventRulesNodeEventPatternEventPatternItem : allEventPatternNode)
  52. {
  53. EventRule::EventPatternItem eventPatternObject;
  54. if(!allEventRulesNodeEventPatternEventPatternItem["Product"].isNull())
  55. eventPatternObject.product = allEventRulesNodeEventPatternEventPatternItem["Product"].asString();
  56. auto allNameList = value["NameList"]["NameList"];
  57. for (auto value : allNameList)
  58. eventPatternObject.nameList.push_back(value.asString());
  59. auto allLevelList = value["LevelList"]["LevelList"];
  60. for (auto value : allLevelList)
  61. eventPatternObject.levelList.push_back(value.asString());
  62. auto allEventTypeList = value["EventTypeList"]["EventTypeList"];
  63. for (auto value : allEventTypeList)
  64. eventPatternObject.eventTypeList.push_back(value.asString());
  65. eventRulesObject.eventPattern.push_back(eventPatternObject);
  66. }
  67. eventRules_.push_back(eventRulesObject);
  68. }
  69. if(!value["Success"].isNull())
  70. success_ = value["Success"].asString() == "true";
  71. if(!value["Code"].isNull())
  72. code_ = value["Code"].asString();
  73. if(!value["Message"].isNull())
  74. message_ = value["Message"].asString();
  75. if(!value["Total"].isNull())
  76. total_ = std::stoi(value["Total"].asString());
  77. }
  78. std::string DescribeEventRuleListResult::getMessage()const
  79. {
  80. return message_;
  81. }
  82. int DescribeEventRuleListResult::getTotal()const
  83. {
  84. return total_;
  85. }
  86. std::vector<DescribeEventRuleListResult::EventRule> DescribeEventRuleListResult::getEventRules()const
  87. {
  88. return eventRules_;
  89. }
  90. std::string DescribeEventRuleListResult::getCode()const
  91. {
  92. return code_;
  93. }
  94. bool DescribeEventRuleListResult::getSuccess()const
  95. {
  96. return success_;
  97. }