DescribeDeploymentSetsResult.cc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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/ecs/model/DescribeDeploymentSetsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Ecs;
  19. using namespace AlibabaCloud::Ecs::Model;
  20. DescribeDeploymentSetsResult::DescribeDeploymentSetsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeDeploymentSetsResult::DescribeDeploymentSetsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeDeploymentSetsResult::~DescribeDeploymentSetsResult()
  29. {}
  30. void DescribeDeploymentSetsResult::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 allDeploymentSetsNode = value["DeploymentSets"]["DeploymentSet"];
  37. for (auto valueDeploymentSetsDeploymentSet : allDeploymentSetsNode)
  38. {
  39. DeploymentSet deploymentSetsObject;
  40. if(!valueDeploymentSetsDeploymentSet["DeploymentSetId"].isNull())
  41. deploymentSetsObject.deploymentSetId = valueDeploymentSetsDeploymentSet["DeploymentSetId"].asString();
  42. if(!valueDeploymentSetsDeploymentSet["DeploymentSetDescription"].isNull())
  43. deploymentSetsObject.deploymentSetDescription = valueDeploymentSetsDeploymentSet["DeploymentSetDescription"].asString();
  44. if(!valueDeploymentSetsDeploymentSet["DeploymentSetName"].isNull())
  45. deploymentSetsObject.deploymentSetName = valueDeploymentSetsDeploymentSet["DeploymentSetName"].asString();
  46. if(!valueDeploymentSetsDeploymentSet["Strategy"].isNull())
  47. deploymentSetsObject.strategy = valueDeploymentSetsDeploymentSet["Strategy"].asString();
  48. if(!valueDeploymentSetsDeploymentSet["DeploymentStrategy"].isNull())
  49. deploymentSetsObject.deploymentStrategy = valueDeploymentSetsDeploymentSet["DeploymentStrategy"].asString();
  50. if(!valueDeploymentSetsDeploymentSet["Domain"].isNull())
  51. deploymentSetsObject.domain = valueDeploymentSetsDeploymentSet["Domain"].asString();
  52. if(!valueDeploymentSetsDeploymentSet["Granularity"].isNull())
  53. deploymentSetsObject.granularity = valueDeploymentSetsDeploymentSet["Granularity"].asString();
  54. if(!valueDeploymentSetsDeploymentSet["GroupCount"].isNull())
  55. deploymentSetsObject.groupCount = std::stoi(valueDeploymentSetsDeploymentSet["GroupCount"].asString());
  56. if(!valueDeploymentSetsDeploymentSet["InstanceAmount"].isNull())
  57. deploymentSetsObject.instanceAmount = std::stoi(valueDeploymentSetsDeploymentSet["InstanceAmount"].asString());
  58. if(!valueDeploymentSetsDeploymentSet["CreationTime"].isNull())
  59. deploymentSetsObject.creationTime = valueDeploymentSetsDeploymentSet["CreationTime"].asString();
  60. auto allInstanceIds = value["InstanceIds"]["InstanceId"];
  61. for (auto value : allInstanceIds)
  62. deploymentSetsObject.instanceIds.push_back(value.asString());
  63. deploymentSets_.push_back(deploymentSetsObject);
  64. }
  65. if(!value["RegionId"].isNull())
  66. regionId_ = value["RegionId"].asString();
  67. if(!value["TotalCount"].isNull())
  68. totalCount_ = std::stoi(value["TotalCount"].asString());
  69. if(!value["PageNumber"].isNull())
  70. pageNumber_ = std::stoi(value["PageNumber"].asString());
  71. if(!value["PageSize"].isNull())
  72. pageSize_ = std::stoi(value["PageSize"].asString());
  73. }
  74. int DescribeDeploymentSetsResult::getTotalCount()const
  75. {
  76. return totalCount_;
  77. }
  78. int DescribeDeploymentSetsResult::getPageSize()const
  79. {
  80. return pageSize_;
  81. }
  82. std::vector<DescribeDeploymentSetsResult::DeploymentSet> DescribeDeploymentSetsResult::getDeploymentSets()const
  83. {
  84. return deploymentSets_;
  85. }
  86. int DescribeDeploymentSetsResult::getPageNumber()const
  87. {
  88. return pageNumber_;
  89. }
  90. std::string DescribeDeploymentSetsResult::getRegionId()const
  91. {
  92. return regionId_;
  93. }