DescribeInstanceHistoryEventsResult.cc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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/DescribeInstanceHistoryEventsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Ecs;
  19. using namespace AlibabaCloud::Ecs::Model;
  20. DescribeInstanceHistoryEventsResult::DescribeInstanceHistoryEventsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeInstanceHistoryEventsResult::DescribeInstanceHistoryEventsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeInstanceHistoryEventsResult::~DescribeInstanceHistoryEventsResult()
  29. {}
  30. void DescribeInstanceHistoryEventsResult::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 allInstanceSystemEventSetNode = value["InstanceSystemEventSet"]["InstanceSystemEventType"];
  37. for (auto valueInstanceSystemEventSetInstanceSystemEventType : allInstanceSystemEventSetNode)
  38. {
  39. InstanceSystemEventType instanceSystemEventSetObject;
  40. if(!valueInstanceSystemEventSetInstanceSystemEventType["InstanceId"].isNull())
  41. instanceSystemEventSetObject.instanceId = valueInstanceSystemEventSetInstanceSystemEventType["InstanceId"].asString();
  42. if(!valueInstanceSystemEventSetInstanceSystemEventType["EventId"].isNull())
  43. instanceSystemEventSetObject.eventId = valueInstanceSystemEventSetInstanceSystemEventType["EventId"].asString();
  44. if(!valueInstanceSystemEventSetInstanceSystemEventType["EventPublishTime"].isNull())
  45. instanceSystemEventSetObject.eventPublishTime = valueInstanceSystemEventSetInstanceSystemEventType["EventPublishTime"].asString();
  46. if(!valueInstanceSystemEventSetInstanceSystemEventType["NotBefore"].isNull())
  47. instanceSystemEventSetObject.notBefore = valueInstanceSystemEventSetInstanceSystemEventType["NotBefore"].asString();
  48. if(!valueInstanceSystemEventSetInstanceSystemEventType["EventFinishTime"].isNull())
  49. instanceSystemEventSetObject.eventFinishTime = valueInstanceSystemEventSetInstanceSystemEventType["EventFinishTime"].asString();
  50. if(!valueInstanceSystemEventSetInstanceSystemEventType["Reason"].isNull())
  51. instanceSystemEventSetObject.reason = valueInstanceSystemEventSetInstanceSystemEventType["Reason"].asString();
  52. if(!valueInstanceSystemEventSetInstanceSystemEventType["ImpactLevel"].isNull())
  53. instanceSystemEventSetObject.impactLevel = valueInstanceSystemEventSetInstanceSystemEventType["ImpactLevel"].asString();
  54. if(!valueInstanceSystemEventSetInstanceSystemEventType["ResourceType"].isNull())
  55. instanceSystemEventSetObject.resourceType = valueInstanceSystemEventSetInstanceSystemEventType["ResourceType"].asString();
  56. auto eventTypeNode = value["EventType"];
  57. if(!eventTypeNode["Code"].isNull())
  58. instanceSystemEventSetObject.eventType.code = std::stoi(eventTypeNode["Code"].asString());
  59. if(!eventTypeNode["Name"].isNull())
  60. instanceSystemEventSetObject.eventType.name = eventTypeNode["Name"].asString();
  61. auto eventCycleStatusNode = value["EventCycleStatus"];
  62. if(!eventCycleStatusNode["Code"].isNull())
  63. instanceSystemEventSetObject.eventCycleStatus.code = std::stoi(eventCycleStatusNode["Code"].asString());
  64. if(!eventCycleStatusNode["Name"].isNull())
  65. instanceSystemEventSetObject.eventCycleStatus.name = eventCycleStatusNode["Name"].asString();
  66. auto extendedAttributeNode = value["ExtendedAttribute"];
  67. if(!extendedAttributeNode["DiskId"].isNull())
  68. instanceSystemEventSetObject.extendedAttribute.diskId = extendedAttributeNode["DiskId"].asString();
  69. if(!extendedAttributeNode["Device"].isNull())
  70. instanceSystemEventSetObject.extendedAttribute.device = extendedAttributeNode["Device"].asString();
  71. auto allInactiveDisksNode = extendedAttributeNode["InactiveDisks"]["InactiveDisk"];
  72. for (auto extendedAttributeNodeInactiveDisksInactiveDisk : allInactiveDisksNode)
  73. {
  74. InstanceSystemEventType::ExtendedAttribute::InactiveDisk inactiveDiskObject;
  75. if(!extendedAttributeNodeInactiveDisksInactiveDisk["CreationTime"].isNull())
  76. inactiveDiskObject.creationTime = extendedAttributeNodeInactiveDisksInactiveDisk["CreationTime"].asString();
  77. if(!extendedAttributeNodeInactiveDisksInactiveDisk["ReleaseTime"].isNull())
  78. inactiveDiskObject.releaseTime = extendedAttributeNodeInactiveDisksInactiveDisk["ReleaseTime"].asString();
  79. if(!extendedAttributeNodeInactiveDisksInactiveDisk["DeviceType"].isNull())
  80. inactiveDiskObject.deviceType = extendedAttributeNodeInactiveDisksInactiveDisk["DeviceType"].asString();
  81. if(!extendedAttributeNodeInactiveDisksInactiveDisk["DeviceCategory"].isNull())
  82. inactiveDiskObject.deviceCategory = extendedAttributeNodeInactiveDisksInactiveDisk["DeviceCategory"].asString();
  83. if(!extendedAttributeNodeInactiveDisksInactiveDisk["DeviceSize"].isNull())
  84. inactiveDiskObject.deviceSize = extendedAttributeNodeInactiveDisksInactiveDisk["DeviceSize"].asString();
  85. instanceSystemEventSetObject.extendedAttribute.inactiveDisks.push_back(inactiveDiskObject);
  86. }
  87. instanceSystemEventSet_.push_back(instanceSystemEventSetObject);
  88. }
  89. if(!value["TotalCount"].isNull())
  90. totalCount_ = std::stoi(value["TotalCount"].asString());
  91. if(!value["PageNumber"].isNull())
  92. pageNumber_ = std::stoi(value["PageNumber"].asString());
  93. if(!value["PageSize"].isNull())
  94. pageSize_ = std::stoi(value["PageSize"].asString());
  95. }
  96. int DescribeInstanceHistoryEventsResult::getTotalCount()const
  97. {
  98. return totalCount_;
  99. }
  100. int DescribeInstanceHistoryEventsResult::getPageSize()const
  101. {
  102. return pageSize_;
  103. }
  104. int DescribeInstanceHistoryEventsResult::getPageNumber()const
  105. {
  106. return pageNumber_;
  107. }
  108. std::vector<DescribeInstanceHistoryEventsResult::InstanceSystemEventType> DescribeInstanceHistoryEventsResult::getInstanceSystemEventSet()const
  109. {
  110. return instanceSystemEventSet_;
  111. }