FindInstanceListResult.cc 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/csb/model/FindInstanceListResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CSB;
  19. using namespace AlibabaCloud::CSB::Model;
  20. FindInstanceListResult::FindInstanceListResult() :
  21. ServiceResult()
  22. {}
  23. FindInstanceListResult::FindInstanceListResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. FindInstanceListResult::~FindInstanceListResult()
  29. {}
  30. void FindInstanceListResult::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 dataNode = value["Data"];
  37. if(!dataNode["CurrentPage"].isNull())
  38. data_.currentPage = std::stoi(dataNode["CurrentPage"].asString());
  39. if(!dataNode["PageNumber"].isNull())
  40. data_.pageNumber = std::stoi(dataNode["PageNumber"].asString());
  41. auto allItemListNode = dataNode["ItemList"]["Item"];
  42. for (auto dataNodeItemListItem : allItemListNode)
  43. {
  44. Data::Item itemObject;
  45. if(!dataNodeItemListItem["Description"].isNull())
  46. itemObject.description = dataNodeItemListItem["Description"].asString();
  47. if(!dataNodeItemListItem["FrontStatus"].isNull())
  48. itemObject.frontStatus = dataNodeItemListItem["FrontStatus"].asString();
  49. if(!dataNodeItemListItem["GmtCreate"].isNull())
  50. itemObject.gmtCreate = std::stol(dataNodeItemListItem["GmtCreate"].asString());
  51. if(!dataNodeItemListItem["GmtModified"].isNull())
  52. itemObject.gmtModified = std::stol(dataNodeItemListItem["GmtModified"].asString());
  53. if(!dataNodeItemListItem["Id"].isNull())
  54. itemObject.id = std::stol(dataNodeItemListItem["Id"].asString());
  55. if(!dataNodeItemListItem["InstanceCategory"].isNull())
  56. itemObject.instanceCategory = std::stoi(dataNodeItemListItem["InstanceCategory"].asString());
  57. if(!dataNodeItemListItem["Name"].isNull())
  58. itemObject.name = dataNodeItemListItem["Name"].asString();
  59. if(!dataNodeItemListItem["StatusCode"].isNull())
  60. itemObject.statusCode = std::stoi(dataNodeItemListItem["StatusCode"].asString());
  61. if(!dataNodeItemListItem["Visible"].isNull())
  62. itemObject.visible = dataNodeItemListItem["Visible"].asString() == "true";
  63. if(!dataNodeItemListItem["VpcName"].isNull())
  64. itemObject.vpcName = dataNodeItemListItem["VpcName"].asString();
  65. data_.itemList.push_back(itemObject);
  66. }
  67. if(!value["Code"].isNull())
  68. code_ = std::stoi(value["Code"].asString());
  69. if(!value["Message"].isNull())
  70. message_ = value["Message"].asString();
  71. }
  72. std::string FindInstanceListResult::getMessage()const
  73. {
  74. return message_;
  75. }
  76. FindInstanceListResult::Data FindInstanceListResult::getData()const
  77. {
  78. return data_;
  79. }
  80. int FindInstanceListResult::getCode()const
  81. {
  82. return code_;
  83. }