ListFlowResult.cc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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/emr/model/ListFlowResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Emr;
  19. using namespace AlibabaCloud::Emr::Model;
  20. ListFlowResult::ListFlowResult() :
  21. ServiceResult()
  22. {}
  23. ListFlowResult::ListFlowResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListFlowResult::~ListFlowResult()
  29. {}
  30. void ListFlowResult::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 allFlowNode = value["Flow"]["FlowItem"];
  37. for (auto valueFlowFlowItem : allFlowNode)
  38. {
  39. FlowItem flowObject;
  40. if(!valueFlowFlowItem["Id"].isNull())
  41. flowObject.id = valueFlowFlowItem["Id"].asString();
  42. if(!valueFlowFlowItem["GmtCreate"].isNull())
  43. flowObject.gmtCreate = std::stol(valueFlowFlowItem["GmtCreate"].asString());
  44. if(!valueFlowFlowItem["GmtModified"].isNull())
  45. flowObject.gmtModified = std::stol(valueFlowFlowItem["GmtModified"].asString());
  46. if(!valueFlowFlowItem["Name"].isNull())
  47. flowObject.name = valueFlowFlowItem["Name"].asString();
  48. if(!valueFlowFlowItem["Description"].isNull())
  49. flowObject.description = valueFlowFlowItem["Description"].asString();
  50. if(!valueFlowFlowItem["Type"].isNull())
  51. flowObject.type = valueFlowFlowItem["Type"].asString();
  52. if(!valueFlowFlowItem["Status"].isNull())
  53. flowObject.status = valueFlowFlowItem["Status"].asString();
  54. if(!valueFlowFlowItem["Periodic"].isNull())
  55. flowObject.periodic = valueFlowFlowItem["Periodic"].asString() == "true";
  56. if(!valueFlowFlowItem["StartSchedule"].isNull())
  57. flowObject.startSchedule = std::stol(valueFlowFlowItem["StartSchedule"].asString());
  58. if(!valueFlowFlowItem["EndSchedule"].isNull())
  59. flowObject.endSchedule = std::stol(valueFlowFlowItem["EndSchedule"].asString());
  60. if(!valueFlowFlowItem["CronExpr"].isNull())
  61. flowObject.cronExpr = valueFlowFlowItem["CronExpr"].asString();
  62. if(!valueFlowFlowItem["CreateCluster"].isNull())
  63. flowObject.createCluster = valueFlowFlowItem["CreateCluster"].asString() == "true";
  64. if(!valueFlowFlowItem["ClusterId"].isNull())
  65. flowObject.clusterId = valueFlowFlowItem["ClusterId"].asString();
  66. if(!valueFlowFlowItem["ProjectId"].isNull())
  67. flowObject.projectId = valueFlowFlowItem["ProjectId"].asString();
  68. if(!valueFlowFlowItem["HostName"].isNull())
  69. flowObject.hostName = valueFlowFlowItem["HostName"].asString();
  70. if(!valueFlowFlowItem["Graph"].isNull())
  71. flowObject.graph = valueFlowFlowItem["Graph"].asString();
  72. if(!valueFlowFlowItem["AlertUserGroupBizId"].isNull())
  73. flowObject.alertUserGroupBizId = valueFlowFlowItem["AlertUserGroupBizId"].asString();
  74. if(!valueFlowFlowItem["AlertDingDingGroupBizId"].isNull())
  75. flowObject.alertDingDingGroupBizId = valueFlowFlowItem["AlertDingDingGroupBizId"].asString();
  76. if(!valueFlowFlowItem["AlertConf"].isNull())
  77. flowObject.alertConf = valueFlowFlowItem["AlertConf"].asString();
  78. if(!valueFlowFlowItem["CategoryId"].isNull())
  79. flowObject.categoryId = valueFlowFlowItem["CategoryId"].asString();
  80. flow_.push_back(flowObject);
  81. }
  82. if(!value["PageNumber"].isNull())
  83. pageNumber_ = std::stoi(value["PageNumber"].asString());
  84. if(!value["PageSize"].isNull())
  85. pageSize_ = std::stoi(value["PageSize"].asString());
  86. if(!value["Total"].isNull())
  87. total_ = std::stoi(value["Total"].asString());
  88. }
  89. int ListFlowResult::getPageSize()const
  90. {
  91. return pageSize_;
  92. }
  93. int ListFlowResult::getPageNumber()const
  94. {
  95. return pageNumber_;
  96. }
  97. int ListFlowResult::getTotal()const
  98. {
  99. return total_;
  100. }
  101. std::vector<ListFlowResult::FlowItem> ListFlowResult::getFlow()const
  102. {
  103. return flow_;
  104. }