DescribeGroupListResult.cc 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/aegis/model/DescribeGroupListResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Aegis;
  19. using namespace AlibabaCloud::Aegis::Model;
  20. DescribeGroupListResult::DescribeGroupListResult() :
  21. ServiceResult()
  22. {}
  23. DescribeGroupListResult::DescribeGroupListResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeGroupListResult::~DescribeGroupListResult()
  29. {}
  30. void DescribeGroupListResult::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 allRuleGroupsNode = value["RuleGroups"]["RuleGroupsItem"];
  37. for (auto valueRuleGroupsRuleGroupsItem : allRuleGroupsNode)
  38. {
  39. RuleGroupsItem ruleGroupsObject;
  40. if(!valueRuleGroupsRuleGroupsItem["GroupName"].isNull())
  41. ruleGroupsObject.groupName = valueRuleGroupsRuleGroupsItem["GroupName"].asString();
  42. if(!valueRuleGroupsRuleGroupsItem["RuleNum"].isNull())
  43. ruleGroupsObject.ruleNum = std::stoi(valueRuleGroupsRuleGroupsItem["RuleNum"].asString());
  44. if(!valueRuleGroupsRuleGroupsItem["Modified"].isNull())
  45. ruleGroupsObject.modified = std::stol(valueRuleGroupsRuleGroupsItem["Modified"].asString());
  46. if(!valueRuleGroupsRuleGroupsItem["Create"].isNull())
  47. ruleGroupsObject.create = std::stol(valueRuleGroupsRuleGroupsItem["Create"].asString());
  48. if(!valueRuleGroupsRuleGroupsItem["Description"].isNull())
  49. ruleGroupsObject.description = valueRuleGroupsRuleGroupsItem["Description"].asString();
  50. if(!valueRuleGroupsRuleGroupsItem["Id"].isNull())
  51. ruleGroupsObject.id = std::stoi(valueRuleGroupsRuleGroupsItem["Id"].asString());
  52. if(!valueRuleGroupsRuleGroupsItem["AliUid"].isNull())
  53. ruleGroupsObject.aliUid = std::stol(valueRuleGroupsRuleGroupsItem["AliUid"].asString());
  54. if(!valueRuleGroupsRuleGroupsItem["Status"].isNull())
  55. ruleGroupsObject.status = std::stoi(valueRuleGroupsRuleGroupsItem["Status"].asString());
  56. if(!valueRuleGroupsRuleGroupsItem["MachineGroupIds"].isNull())
  57. ruleGroupsObject.machineGroupIds = valueRuleGroupsRuleGroupsItem["MachineGroupIds"].asString();
  58. ruleGroups_.push_back(ruleGroupsObject);
  59. }
  60. auto pageInfoNode = value["PageInfo"];
  61. if(!pageInfoNode["Count"].isNull())
  62. pageInfo_.count = std::stoi(pageInfoNode["Count"].asString());
  63. if(!pageInfoNode["PageSize"].isNull())
  64. pageInfo_.pageSize = std::stoi(pageInfoNode["PageSize"].asString());
  65. if(!pageInfoNode["CurrentPage"].isNull())
  66. pageInfo_.currentPage = std::stoi(pageInfoNode["CurrentPage"].asString());
  67. if(!pageInfoNode["TotalCount"].isNull())
  68. pageInfo_.totalCount = std::stoi(pageInfoNode["TotalCount"].asString());
  69. if(!value["Success"].isNull())
  70. success_ = value["Success"].asString() == "true";
  71. }
  72. DescribeGroupListResult::PageInfo DescribeGroupListResult::getPageInfo()const
  73. {
  74. return pageInfo_;
  75. }
  76. std::vector<DescribeGroupListResult::RuleGroupsItem> DescribeGroupListResult::getRuleGroups()const
  77. {
  78. return ruleGroups_;
  79. }
  80. bool DescribeGroupListResult::getSuccess()const
  81. {
  82. return success_;
  83. }