DescribeRulesResult.cc 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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/slb/model/DescribeRulesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Slb;
  19. using namespace AlibabaCloud::Slb::Model;
  20. DescribeRulesResult::DescribeRulesResult() :
  21. ServiceResult()
  22. {}
  23. DescribeRulesResult::DescribeRulesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeRulesResult::~DescribeRulesResult()
  29. {}
  30. void DescribeRulesResult::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 allRulesNode = value["Rules"]["Rule"];
  37. for (auto valueRulesRule : allRulesNode)
  38. {
  39. Rule rulesObject;
  40. if(!valueRulesRule["RuleId"].isNull())
  41. rulesObject.ruleId = valueRulesRule["RuleId"].asString();
  42. if(!valueRulesRule["RuleName"].isNull())
  43. rulesObject.ruleName = valueRulesRule["RuleName"].asString();
  44. if(!valueRulesRule["Domain"].isNull())
  45. rulesObject.domain = valueRulesRule["Domain"].asString();
  46. if(!valueRulesRule["Url"].isNull())
  47. rulesObject.url = valueRulesRule["Url"].asString();
  48. if(!valueRulesRule["VServerGroupId"].isNull())
  49. rulesObject.vServerGroupId = valueRulesRule["VServerGroupId"].asString();
  50. if(!valueRulesRule["ListenerSync"].isNull())
  51. rulesObject.listenerSync = valueRulesRule["ListenerSync"].asString();
  52. if(!valueRulesRule["Scheduler"].isNull())
  53. rulesObject.scheduler = valueRulesRule["Scheduler"].asString();
  54. if(!valueRulesRule["StickySession"].isNull())
  55. rulesObject.stickySession = valueRulesRule["StickySession"].asString();
  56. if(!valueRulesRule["StickySessionType"].isNull())
  57. rulesObject.stickySessionType = valueRulesRule["StickySessionType"].asString();
  58. if(!valueRulesRule["CookieTimeout"].isNull())
  59. rulesObject.cookieTimeout = std::stoi(valueRulesRule["CookieTimeout"].asString());
  60. if(!valueRulesRule["Cookie"].isNull())
  61. rulesObject.cookie = valueRulesRule["Cookie"].asString();
  62. if(!valueRulesRule["HealthCheck"].isNull())
  63. rulesObject.healthCheck = valueRulesRule["HealthCheck"].asString();
  64. if(!valueRulesRule["HealthCheckDomain"].isNull())
  65. rulesObject.healthCheckDomain = valueRulesRule["HealthCheckDomain"].asString();
  66. if(!valueRulesRule["HealthCheckURI"].isNull())
  67. rulesObject.healthCheckURI = valueRulesRule["HealthCheckURI"].asString();
  68. if(!valueRulesRule["HealthyThreshold"].isNull())
  69. rulesObject.healthyThreshold = std::stoi(valueRulesRule["HealthyThreshold"].asString());
  70. if(!valueRulesRule["UnhealthyThreshold"].isNull())
  71. rulesObject.unhealthyThreshold = std::stoi(valueRulesRule["UnhealthyThreshold"].asString());
  72. if(!valueRulesRule["HealthCheckTimeout"].isNull())
  73. rulesObject.healthCheckTimeout = std::stoi(valueRulesRule["HealthCheckTimeout"].asString());
  74. if(!valueRulesRule["HealthCheckInterval"].isNull())
  75. rulesObject.healthCheckInterval = std::stoi(valueRulesRule["HealthCheckInterval"].asString());
  76. if(!valueRulesRule["HealthCheckConnectPort"].isNull())
  77. rulesObject.healthCheckConnectPort = std::stoi(valueRulesRule["HealthCheckConnectPort"].asString());
  78. if(!valueRulesRule["HealthCheckHttpCode"].isNull())
  79. rulesObject.healthCheckHttpCode = valueRulesRule["HealthCheckHttpCode"].asString();
  80. rules_.push_back(rulesObject);
  81. }
  82. }
  83. std::vector<DescribeRulesResult::Rule> DescribeRulesResult::getRules()const
  84. {
  85. return rules_;
  86. }