OnsInstanceInServiceListResult.cc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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/ons/model/OnsInstanceInServiceListResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Ons;
  19. using namespace AlibabaCloud::Ons::Model;
  20. OnsInstanceInServiceListResult::OnsInstanceInServiceListResult() :
  21. ServiceResult()
  22. {}
  23. OnsInstanceInServiceListResult::OnsInstanceInServiceListResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. OnsInstanceInServiceListResult::~OnsInstanceInServiceListResult()
  29. {}
  30. void OnsInstanceInServiceListResult::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 allDataNode = value["Data"]["InstanceVO"];
  37. for (auto valueDataInstanceVO : allDataNode)
  38. {
  39. InstanceVO dataObject;
  40. if(!valueDataInstanceVO["IndependentNaming"].isNull())
  41. dataObject.independentNaming = valueDataInstanceVO["IndependentNaming"].asString() == "true";
  42. if(!valueDataInstanceVO["InstanceName"].isNull())
  43. dataObject.instanceName = valueDataInstanceVO["InstanceName"].asString();
  44. if(!valueDataInstanceVO["ReleaseTime"].isNull())
  45. dataObject.releaseTime = std::stol(valueDataInstanceVO["ReleaseTime"].asString());
  46. if(!valueDataInstanceVO["InstanceStatus"].isNull())
  47. dataObject.instanceStatus = std::stoi(valueDataInstanceVO["InstanceStatus"].asString());
  48. if(!valueDataInstanceVO["InstanceId"].isNull())
  49. dataObject.instanceId = valueDataInstanceVO["InstanceId"].asString();
  50. if(!valueDataInstanceVO["InstanceType"].isNull())
  51. dataObject.instanceType = std::stoi(valueDataInstanceVO["InstanceType"].asString());
  52. auto allTagsNode = valueDataInstanceVO["Tags"]["Tag"];
  53. for (auto valueDataInstanceVOTagsTag : allTagsNode)
  54. {
  55. InstanceVO::Tag tagsObject;
  56. if(!valueDataInstanceVOTagsTag["Key"].isNull())
  57. tagsObject.key = valueDataInstanceVOTagsTag["Key"].asString();
  58. if(!valueDataInstanceVOTagsTag["Value"].isNull())
  59. tagsObject.value = valueDataInstanceVOTagsTag["Value"].asString();
  60. dataObject.tags.push_back(tagsObject);
  61. }
  62. data_.push_back(dataObject);
  63. }
  64. if(!value["HelpUrl"].isNull())
  65. helpUrl_ = value["HelpUrl"].asString();
  66. }
  67. std::vector<OnsInstanceInServiceListResult::InstanceVO> OnsInstanceInServiceListResult::getData()const
  68. {
  69. return data_;
  70. }
  71. std::string OnsInstanceInServiceListResult::getHelpUrl()const
  72. {
  73. return helpUrl_;
  74. }