DescribeInstanceHistoryEventsResult.cc 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 allInstanceSystemEventSet = value["InstanceSystemEventSet"]["InstanceSystemEventType"];
  37. for (auto value : allInstanceSystemEventSet)
  38. {
  39. InstanceSystemEventType instanceSystemEventSetObject;
  40. if(!value["InstanceId"].isNull())
  41. instanceSystemEventSetObject.instanceId = value["InstanceId"].asString();
  42. if(!value["EventId"].isNull())
  43. instanceSystemEventSetObject.eventId = value["EventId"].asString();
  44. if(!value["EventPublishTime"].isNull())
  45. instanceSystemEventSetObject.eventPublishTime = value["EventPublishTime"].asString();
  46. if(!value["NotBefore"].isNull())
  47. instanceSystemEventSetObject.notBefore = value["NotBefore"].asString();
  48. if(!value["EventFinishTime"].isNull())
  49. instanceSystemEventSetObject.eventFinishTime = value["EventFinishTime"].asString();
  50. auto eventTypeNode = value["EventType"];
  51. if(!eventTypeNode["Code"].isNull())
  52. instanceSystemEventSetObject.eventType.code = std::stoi(eventTypeNode["Code"].asString());
  53. if(!eventTypeNode["Name"].isNull())
  54. instanceSystemEventSetObject.eventType.name = eventTypeNode["Name"].asString();
  55. auto eventCycleStatusNode = value["EventCycleStatus"];
  56. if(!eventCycleStatusNode["Code"].isNull())
  57. instanceSystemEventSetObject.eventCycleStatus.code = std::stoi(eventCycleStatusNode["Code"].asString());
  58. if(!eventCycleStatusNode["Name"].isNull())
  59. instanceSystemEventSetObject.eventCycleStatus.name = eventCycleStatusNode["Name"].asString();
  60. instanceSystemEventSet_.push_back(instanceSystemEventSetObject);
  61. }
  62. if(!value["TotalCount"].isNull())
  63. totalCount_ = std::stoi(value["TotalCount"].asString());
  64. if(!value["PageNumber"].isNull())
  65. pageNumber_ = std::stoi(value["PageNumber"].asString());
  66. if(!value["PageSize"].isNull())
  67. pageSize_ = std::stoi(value["PageSize"].asString());
  68. }
  69. int DescribeInstanceHistoryEventsResult::getTotalCount()const
  70. {
  71. return totalCount_;
  72. }
  73. int DescribeInstanceHistoryEventsResult::getPageSize()const
  74. {
  75. return pageSize_;
  76. }
  77. int DescribeInstanceHistoryEventsResult::getPageNumber()const
  78. {
  79. return pageNumber_;
  80. }
  81. std::vector<DescribeInstanceHistoryEventsResult::InstanceSystemEventType> DescribeInstanceHistoryEventsResult::getInstanceSystemEventSet()const
  82. {
  83. return instanceSystemEventSet_;
  84. }