DescribeImageLibResult.cc 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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/green/model/DescribeImageLibResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Green;
  19. using namespace AlibabaCloud::Green::Model;
  20. DescribeImageLibResult::DescribeImageLibResult() :
  21. ServiceResult()
  22. {}
  23. DescribeImageLibResult::DescribeImageLibResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeImageLibResult::~DescribeImageLibResult()
  29. {}
  30. void DescribeImageLibResult::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 allImageLibListNode = value["ImageLibList"]["ImageLib"];
  37. for (auto valueImageLibListImageLib : allImageLibListNode)
  38. {
  39. ImageLib imageLibListObject;
  40. if(!valueImageLibListImageLib["ImageCount"].isNull())
  41. imageLibListObject.imageCount = std::stoi(valueImageLibListImageLib["ImageCount"].asString());
  42. if(!valueImageLibListImageLib["ModifiedTime"].isNull())
  43. imageLibListObject.modifiedTime = valueImageLibListImageLib["ModifiedTime"].asString();
  44. if(!valueImageLibListImageLib["Code"].isNull())
  45. imageLibListObject.code = valueImageLibListImageLib["Code"].asString();
  46. if(!valueImageLibListImageLib["Name"].isNull())
  47. imageLibListObject.name = valueImageLibListImageLib["Name"].asString();
  48. if(!valueImageLibListImageLib["Id"].isNull())
  49. imageLibListObject.id = std::stoi(valueImageLibListImageLib["Id"].asString());
  50. if(!valueImageLibListImageLib["Source"].isNull())
  51. imageLibListObject.source = valueImageLibListImageLib["Source"].asString();
  52. if(!valueImageLibListImageLib["Category"].isNull())
  53. imageLibListObject.category = valueImageLibListImageLib["Category"].asString();
  54. if(!valueImageLibListImageLib["ServiceModule"].isNull())
  55. imageLibListObject.serviceModule = valueImageLibListImageLib["ServiceModule"].asString();
  56. if(!valueImageLibListImageLib["Scene"].isNull())
  57. imageLibListObject.scene = valueImageLibListImageLib["Scene"].asString();
  58. if(!valueImageLibListImageLib["Enable"].isNull())
  59. imageLibListObject.enable = valueImageLibListImageLib["Enable"].asString();
  60. auto allBizTypes = value["BizTypes"]["StringItem"];
  61. for (auto value : allBizTypes)
  62. imageLibListObject.bizTypes.push_back(value.asString());
  63. imageLibList_.push_back(imageLibListObject);
  64. }
  65. if(!value["TotalCount"].isNull())
  66. totalCount_ = std::stoi(value["TotalCount"].asString());
  67. }
  68. int DescribeImageLibResult::getTotalCount()const
  69. {
  70. return totalCount_;
  71. }
  72. std::vector<DescribeImageLibResult::ImageLib> DescribeImageLibResult::getImageLibList()const
  73. {
  74. return imageLibList_;
  75. }