DescribeGWSInstancesResult.cc 4.0 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/ehpc/model/DescribeGWSInstancesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::EHPC;
  19. using namespace AlibabaCloud::EHPC::Model;
  20. DescribeGWSInstancesResult::DescribeGWSInstancesResult() :
  21. ServiceResult()
  22. {}
  23. DescribeGWSInstancesResult::DescribeGWSInstancesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeGWSInstancesResult::~DescribeGWSInstancesResult()
  29. {}
  30. void DescribeGWSInstancesResult::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 allInstancesNode = value["Instances"]["InstanceInfo"];
  37. for (auto valueInstancesInstanceInfo : allInstancesNode)
  38. {
  39. InstanceInfo instancesObject;
  40. if(!valueInstancesInstanceInfo["ClusterId"].isNull())
  41. instancesObject.clusterId = valueInstancesInstanceInfo["ClusterId"].asString();
  42. if(!valueInstancesInstanceInfo["InstanceId"].isNull())
  43. instancesObject.instanceId = valueInstancesInstanceInfo["InstanceId"].asString();
  44. if(!valueInstancesInstanceInfo["InstanceType"].isNull())
  45. instancesObject.instanceType = valueInstancesInstanceInfo["InstanceType"].asString();
  46. if(!valueInstancesInstanceInfo["Status"].isNull())
  47. instancesObject.status = valueInstancesInstanceInfo["Status"].asString();
  48. if(!valueInstancesInstanceInfo["CreateTime"].isNull())
  49. instancesObject.createTime = valueInstancesInstanceInfo["CreateTime"].asString();
  50. if(!valueInstancesInstanceInfo["ExpireTime"].isNull())
  51. instancesObject.expireTime = valueInstancesInstanceInfo["ExpireTime"].asString();
  52. if(!valueInstancesInstanceInfo["WorkMode"].isNull())
  53. instancesObject.workMode = valueInstancesInstanceInfo["WorkMode"].asString();
  54. if(!valueInstancesInstanceInfo["Name"].isNull())
  55. instancesObject.name = valueInstancesInstanceInfo["Name"].asString();
  56. if(!valueInstancesInstanceInfo["UserName"].isNull())
  57. instancesObject.userName = valueInstancesInstanceInfo["UserName"].asString();
  58. auto allAppListNode = valueInstancesInstanceInfo["AppList"]["AppInfo"];
  59. for (auto valueInstancesInstanceInfoAppListAppInfo : allAppListNode)
  60. {
  61. InstanceInfo::AppInfo appListObject;
  62. if(!valueInstancesInstanceInfoAppListAppInfo["AppName"].isNull())
  63. appListObject.appName = valueInstancesInstanceInfoAppListAppInfo["AppName"].asString();
  64. if(!valueInstancesInstanceInfoAppListAppInfo["AppPath"].isNull())
  65. appListObject.appPath = valueInstancesInstanceInfoAppListAppInfo["AppPath"].asString();
  66. if(!valueInstancesInstanceInfoAppListAppInfo["AppArgs"].isNull())
  67. appListObject.appArgs = valueInstancesInstanceInfoAppListAppInfo["AppArgs"].asString();
  68. instancesObject.appList.push_back(appListObject);
  69. }
  70. instances_.push_back(instancesObject);
  71. }
  72. if(!value["TotalCount"].isNull())
  73. totalCount_ = std::stoi(value["TotalCount"].asString());
  74. if(!value["PageNumber"].isNull())
  75. pageNumber_ = std::stoi(value["PageNumber"].asString());
  76. if(!value["PageSize"].isNull())
  77. pageSize_ = std::stoi(value["PageSize"].asString());
  78. }
  79. std::vector<DescribeGWSInstancesResult::InstanceInfo> DescribeGWSInstancesResult::getInstances()const
  80. {
  81. return instances_;
  82. }
  83. int DescribeGWSInstancesResult::getTotalCount()const
  84. {
  85. return totalCount_;
  86. }
  87. int DescribeGWSInstancesResult::getPageSize()const
  88. {
  89. return pageSize_;
  90. }
  91. int DescribeGWSInstancesResult::getPageNumber()const
  92. {
  93. return pageNumber_;
  94. }