DescribeSnapshotGroupsResult.cc 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/ecs/model/DescribeSnapshotGroupsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Ecs;
  19. using namespace AlibabaCloud::Ecs::Model;
  20. DescribeSnapshotGroupsResult::DescribeSnapshotGroupsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeSnapshotGroupsResult::DescribeSnapshotGroupsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeSnapshotGroupsResult::~DescribeSnapshotGroupsResult()
  29. {}
  30. void DescribeSnapshotGroupsResult::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 allSnapshotGroupsNode = value["SnapshotGroups"]["SnapshotGroup"];
  37. for (auto valueSnapshotGroupsSnapshotGroup : allSnapshotGroupsNode)
  38. {
  39. SnapshotGroup snapshotGroupsObject;
  40. if(!valueSnapshotGroupsSnapshotGroup["InstanceId"].isNull())
  41. snapshotGroupsObject.instanceId = valueSnapshotGroupsSnapshotGroup["InstanceId"].asString();
  42. if(!valueSnapshotGroupsSnapshotGroup["SnapshotGroupId"].isNull())
  43. snapshotGroupsObject.snapshotGroupId = valueSnapshotGroupsSnapshotGroup["SnapshotGroupId"].asString();
  44. if(!valueSnapshotGroupsSnapshotGroup["Status"].isNull())
  45. snapshotGroupsObject.status = valueSnapshotGroupsSnapshotGroup["Status"].asString();
  46. if(!valueSnapshotGroupsSnapshotGroup["Name"].isNull())
  47. snapshotGroupsObject.name = valueSnapshotGroupsSnapshotGroup["Name"].asString();
  48. if(!valueSnapshotGroupsSnapshotGroup["Description"].isNull())
  49. snapshotGroupsObject.description = valueSnapshotGroupsSnapshotGroup["Description"].asString();
  50. if(!valueSnapshotGroupsSnapshotGroup["CreationTime"].isNull())
  51. snapshotGroupsObject.creationTime = valueSnapshotGroupsSnapshotGroup["CreationTime"].asString();
  52. auto allSnapshotsNode = valueSnapshotGroupsSnapshotGroup["Snapshots"]["Snapshot"];
  53. for (auto valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot : allSnapshotsNode)
  54. {
  55. SnapshotGroup::Snapshot snapshotsObject;
  56. if(!valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["SnapshotId"].isNull())
  57. snapshotsObject.snapshotId = valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["SnapshotId"].asString();
  58. if(!valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["Progress"].isNull())
  59. snapshotsObject.progress = valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["Progress"].asString();
  60. if(!valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["SourceDiskId"].isNull())
  61. snapshotsObject.sourceDiskId = valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["SourceDiskId"].asString();
  62. if(!valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["SourceDiskType"].isNull())
  63. snapshotsObject.sourceDiskType = valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["SourceDiskType"].asString();
  64. if(!valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["InstantAccess"].isNull())
  65. snapshotsObject.instantAccess = valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["InstantAccess"].asString() == "true";
  66. if(!valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["InstantAccessRetentionDays"].isNull())
  67. snapshotsObject.instantAccessRetentionDays = std::stoi(valueSnapshotGroupsSnapshotGroupSnapshotsSnapshot["InstantAccessRetentionDays"].asString());
  68. snapshotGroupsObject.snapshots.push_back(snapshotsObject);
  69. }
  70. snapshotGroups_.push_back(snapshotGroupsObject);
  71. }
  72. if(!value["NextToken"].isNull())
  73. nextToken_ = value["NextToken"].asString();
  74. }
  75. std::string DescribeSnapshotGroupsResult::getNextToken()const
  76. {
  77. return nextToken_;
  78. }
  79. std::vector<DescribeSnapshotGroupsResult::SnapshotGroup> DescribeSnapshotGroupsResult::getSnapshotGroups()const
  80. {
  81. return snapshotGroups_;
  82. }