RollbackInstanceResult.cc 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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/elasticsearch/model/RollbackInstanceResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Elasticsearch;
  19. using namespace AlibabaCloud::Elasticsearch::Model;
  20. RollbackInstanceResult::RollbackInstanceResult() :
  21. ServiceResult()
  22. {}
  23. RollbackInstanceResult::RollbackInstanceResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. RollbackInstanceResult::~RollbackInstanceResult()
  29. {}
  30. void RollbackInstanceResult::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 resultNode = value["Result"];
  37. if(!resultNode["instanceId"].isNull())
  38. result_.instanceId = resultNode["instanceId"].asString();
  39. if(!resultNode["domain"].isNull())
  40. result_.domain = resultNode["domain"].asString();
  41. if(!resultNode["description"].isNull())
  42. result_.description = resultNode["description"].asString();
  43. if(!resultNode["nodeAmount"].isNull())
  44. result_.nodeAmount = std::stoi(resultNode["nodeAmount"].asString());
  45. if(!resultNode["paymentType"].isNull())
  46. result_.paymentType = resultNode["paymentType"].asString();
  47. if(!resultNode["status"].isNull())
  48. result_.status = resultNode["status"].asString();
  49. if(!resultNode["esVersion"].isNull())
  50. result_.esVersion = resultNode["esVersion"].asString();
  51. if(!resultNode["createdAt"].isNull())
  52. result_.createdAt = resultNode["createdAt"].asString();
  53. if(!resultNode["updatedAt"].isNull())
  54. result_.updatedAt = resultNode["updatedAt"].asString();
  55. auto nodeSpecNode = resultNode["nodeSpec"];
  56. if(!nodeSpecNode["spec"].isNull())
  57. result_.nodeSpec.spec = nodeSpecNode["spec"].asString();
  58. if(!nodeSpecNode["disk"].isNull())
  59. result_.nodeSpec.disk = std::stoi(nodeSpecNode["disk"].asString());
  60. auto networkConfigNode = resultNode["networkConfig"];
  61. if(!networkConfigNode["type"].isNull())
  62. result_.networkConfig.type = networkConfigNode["type"].asString();
  63. if(!networkConfigNode["vpcId"].isNull())
  64. result_.networkConfig.vpcId = networkConfigNode["vpcId"].asString();
  65. if(!networkConfigNode["vswitchId"].isNull())
  66. result_.networkConfig.vswitchId = networkConfigNode["vswitchId"].asString();
  67. if(!networkConfigNode["vsArea"].isNull())
  68. result_.networkConfig.vsArea = networkConfigNode["vsArea"].asString();
  69. }
  70. RollbackInstanceResult::Result RollbackInstanceResult::getResult()const
  71. {
  72. return result_;
  73. }