QueryEventTracesResult.cc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/eventbridge/model/QueryEventTracesResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Eventbridge;
  19. using namespace AlibabaCloud::Eventbridge::Model;
  20. QueryEventTracesResult::QueryEventTracesResult() :
  21. ServiceResult()
  22. {}
  23. QueryEventTracesResult::QueryEventTracesResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryEventTracesResult::~QueryEventTracesResult()
  29. {}
  30. void QueryEventTracesResult::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 allDataNode = value["Data"]["DataItem"];
  37. for (auto valueDataDataItem : allDataNode)
  38. {
  39. DataItem dataObject;
  40. if(!valueDataDataItem["Action"].isNull())
  41. dataObject.action = valueDataDataItem["Action"].asString();
  42. if(!valueDataDataItem["ReceivedTime"].isNull())
  43. dataObject.receivedTime = std::stol(valueDataDataItem["ReceivedTime"].asString());
  44. if(!valueDataDataItem["RuleMatchingTime"].isNull())
  45. dataObject.ruleMatchingTime = valueDataDataItem["RuleMatchingTime"].asString();
  46. if(!valueDataDataItem["ActionTime"].isNull())
  47. dataObject.actionTime = std::stol(valueDataDataItem["ActionTime"].asString());
  48. if(!valueDataDataItem["NotifyStatus"].isNull())
  49. dataObject.notifyStatus = valueDataDataItem["NotifyStatus"].asString();
  50. if(!valueDataDataItem["RuleName"].isNull())
  51. dataObject.ruleName = valueDataDataItem["RuleName"].asString();
  52. if(!valueDataDataItem["EventId"].isNull())
  53. dataObject.eventId = valueDataDataItem["EventId"].asString();
  54. if(!valueDataDataItem["EventBusName"].isNull())
  55. dataObject.eventBusName = valueDataDataItem["EventBusName"].asString();
  56. if(!valueDataDataItem["Endpoint"].isNull())
  57. dataObject.endpoint = valueDataDataItem["Endpoint"].asString();
  58. if(!valueDataDataItem["NotifyLatency"].isNull())
  59. dataObject.notifyLatency = valueDataDataItem["NotifyLatency"].asString();
  60. if(!valueDataDataItem["NotifyTime"].isNull())
  61. dataObject.notifyTime = std::stol(valueDataDataItem["NotifyTime"].asString());
  62. if(!valueDataDataItem["EventSource"].isNull())
  63. dataObject.eventSource = valueDataDataItem["EventSource"].asString();
  64. data_.push_back(dataObject);
  65. }
  66. if(!value["Message"].isNull())
  67. message_ = value["Message"].asString();
  68. if(!value["Code"].isNull())
  69. code_ = value["Code"].asString();
  70. if(!value["Success"].isNull())
  71. success_ = value["Success"].asString() == "true";
  72. }
  73. std::string QueryEventTracesResult::getMessage()const
  74. {
  75. return message_;
  76. }
  77. std::vector<QueryEventTracesResult::DataItem> QueryEventTracesResult::getData()const
  78. {
  79. return data_;
  80. }
  81. std::string QueryEventTracesResult::getCode()const
  82. {
  83. return code_;
  84. }
  85. bool QueryEventTracesResult::getSuccess()const
  86. {
  87. return success_;
  88. }