GetDbfsResult.cc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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/dbfs/model/GetDbfsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::DBFS;
  19. using namespace AlibabaCloud::DBFS::Model;
  20. GetDbfsResult::GetDbfsResult() :
  21. ServiceResult()
  22. {}
  23. GetDbfsResult::GetDbfsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetDbfsResult::~GetDbfsResult()
  29. {}
  30. void GetDbfsResult::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 dBFSInfoNode = value["DBFSInfo"];
  37. if(!dBFSInfoNode["Status"].isNull())
  38. dBFSInfo_.status = dBFSInfoNode["Status"].asString();
  39. if(!dBFSInfoNode["PayType"].isNull())
  40. dBFSInfo_.payType = dBFSInfoNode["PayType"].asString();
  41. if(!dBFSInfoNode["FsId"].isNull())
  42. dBFSInfo_.fsId = dBFSInfoNode["FsId"].asString();
  43. if(!dBFSInfoNode["SizeG"].isNull())
  44. dBFSInfo_.sizeG = std::stoi(dBFSInfoNode["SizeG"].asString());
  45. if(!dBFSInfoNode["RegionId"].isNull())
  46. dBFSInfo_.regionId = dBFSInfoNode["RegionId"].asString();
  47. if(!dBFSInfoNode["DBFSClusterId"].isNull())
  48. dBFSInfo_.dBFSClusterId = dBFSInfoNode["DBFSClusterId"].asString();
  49. if(!dBFSInfoNode["Description"].isNull())
  50. dBFSInfo_.description = dBFSInfoNode["Description"].asString();
  51. if(!dBFSInfoNode["ZoneId"].isNull())
  52. dBFSInfo_.zoneId = dBFSInfoNode["ZoneId"].asString();
  53. if(!dBFSInfoNode["FsName"].isNull())
  54. dBFSInfo_.fsName = dBFSInfoNode["FsName"].asString();
  55. if(!dBFSInfoNode["Category"].isNull())
  56. dBFSInfo_.category = dBFSInfoNode["Category"].asString();
  57. if(!dBFSInfoNode["CreatedTime"].isNull())
  58. dBFSInfo_.createdTime = dBFSInfoNode["CreatedTime"].asString();
  59. if(!dBFSInfoNode["AttachNodeNumber"].isNull())
  60. dBFSInfo_.attachNodeNumber = std::stoi(dBFSInfoNode["AttachNodeNumber"].asString());
  61. if(!dBFSInfoNode["KMSKeyId"].isNull())
  62. dBFSInfo_.kMSKeyId = dBFSInfoNode["KMSKeyId"].asString();
  63. if(!dBFSInfoNode["Encryption"].isNull())
  64. dBFSInfo_.encryption = dBFSInfoNode["Encryption"].asString() == "true";
  65. if(!dBFSInfoNode["PerformanceLevel"].isNull())
  66. dBFSInfo_.performanceLevel = dBFSInfoNode["PerformanceLevel"].asString();
  67. if(!dBFSInfoNode["UsedScene"].isNull())
  68. dBFSInfo_.usedScene = dBFSInfoNode["UsedScene"].asString();
  69. if(!dBFSInfoNode["LastMountTime"].isNull())
  70. dBFSInfo_.lastMountTime = dBFSInfoNode["LastMountTime"].asString();
  71. if(!dBFSInfoNode["LastUmountTime"].isNull())
  72. dBFSInfo_.lastUmountTime = dBFSInfoNode["LastUmountTime"].asString();
  73. if(!dBFSInfoNode["EnableRaid"].isNull())
  74. dBFSInfo_.enableRaid = dBFSInfoNode["EnableRaid"].asString() == "true";
  75. if(!dBFSInfoNode["RaidStrip"].isNull())
  76. dBFSInfo_.raidStrip = std::stoi(dBFSInfoNode["RaidStrip"].asString());
  77. auto allTagsNode = dBFSInfoNode["Tags"]["TagList"];
  78. for (auto dBFSInfoNodeTagsTagList : allTagsNode)
  79. {
  80. DBFSInfo::TagList tagListObject;
  81. if(!dBFSInfoNodeTagsTagList["TagValue"].isNull())
  82. tagListObject.tagValue = dBFSInfoNodeTagsTagList["TagValue"].asString();
  83. if(!dBFSInfoNodeTagsTagList["Id"].isNull())
  84. tagListObject.id = std::stoi(dBFSInfoNodeTagsTagList["Id"].asString());
  85. if(!dBFSInfoNodeTagsTagList["TagKey"].isNull())
  86. tagListObject.tagKey = dBFSInfoNodeTagsTagList["TagKey"].asString();
  87. dBFSInfo_.tags.push_back(tagListObject);
  88. }
  89. auto allEcsListNode = dBFSInfoNode["EcsList"]["EcsListItem"];
  90. for (auto dBFSInfoNodeEcsListEcsListItem : allEcsListNode)
  91. {
  92. DBFSInfo::EcsListItem ecsListItemObject;
  93. if(!dBFSInfoNodeEcsListEcsListItem["EcsId"].isNull())
  94. ecsListItemObject.ecsId = dBFSInfoNodeEcsListEcsListItem["EcsId"].asString();
  95. dBFSInfo_.ecsList.push_back(ecsListItemObject);
  96. }
  97. auto allEbsListNode = dBFSInfoNode["EbsList"]["EbsListItem"];
  98. for (auto dBFSInfoNodeEbsListEbsListItem : allEbsListNode)
  99. {
  100. DBFSInfo::EbsListItem ebsListItemObject;
  101. if(!dBFSInfoNodeEbsListEbsListItem["EbsId"].isNull())
  102. ebsListItemObject.ebsId = dBFSInfoNodeEbsListEbsListItem["EbsId"].asString();
  103. if(!dBFSInfoNodeEbsListEbsListItem["SizeG"].isNull())
  104. ebsListItemObject.sizeG = std::stoi(dBFSInfoNodeEbsListEbsListItem["SizeG"].asString());
  105. dBFSInfo_.ebsList.push_back(ebsListItemObject);
  106. }
  107. }
  108. GetDbfsResult::DBFSInfo GetDbfsResult::getDBFSInfo()const
  109. {
  110. return dBFSInfo_;
  111. }