BatchJobSubmitResult.cc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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/cloud-siem/model/BatchJobSubmitResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Cloud_siem;
  19. using namespace AlibabaCloud::Cloud_siem::Model;
  20. BatchJobSubmitResult::BatchJobSubmitResult() :
  21. ServiceResult()
  22. {}
  23. BatchJobSubmitResult::BatchJobSubmitResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. BatchJobSubmitResult::~BatchJobSubmitResult()
  29. {}
  30. void BatchJobSubmitResult::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 dataNode = value["Data"];
  37. if(!dataNode["SubmitId"].isNull())
  38. data_.submitId = dataNode["SubmitId"].asString();
  39. if(!dataNode["TaskCount"].isNull())
  40. data_.taskCount = std::stoi(dataNode["TaskCount"].asString());
  41. if(!dataNode["ConfigId"].isNull())
  42. data_.configId = dataNode["ConfigId"].asString();
  43. auto allConfigListNode = dataNode["ConfigList"]["ConfigListItem"];
  44. for (auto dataNodeConfigListConfigListItem : allConfigListNode)
  45. {
  46. Data::ConfigListItem configListItemObject;
  47. if(!dataNodeConfigListConfigListItem["UserId"].isNull())
  48. configListItemObject.userId = std::stol(dataNodeConfigListConfigListItem["UserId"].asString());
  49. auto allProductListNode = dataNodeConfigListConfigListItem["ProductList"]["ProductListItem"];
  50. for (auto dataNodeConfigListConfigListItemProductListProductListItem : allProductListNode)
  51. {
  52. Data::ConfigListItem::ProductListItem productListObject;
  53. if(!dataNodeConfigListConfigListItemProductListProductListItem["ProductCode"].isNull())
  54. productListObject.productCode = dataNodeConfigListConfigListItemProductListProductListItem["ProductCode"].asString();
  55. auto allLogListNode = dataNodeConfigListConfigListItemProductListProductListItem["LogList"]["LogListItem"];
  56. for (auto dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem : allLogListNode)
  57. {
  58. Data::ConfigListItem::ProductListItem::LogListItem logListObject;
  59. if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ProductCode"].isNull())
  60. logListObject.productCode = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ProductCode"].asString();
  61. if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["LogCode"].isNull())
  62. logListObject.logCode = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["LogCode"].asString();
  63. if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["RegionCode"].isNull())
  64. logListObject.regionCode = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["RegionCode"].asString();
  65. if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ProjectNamePattern"].isNull())
  66. logListObject.projectNamePattern = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ProjectNamePattern"].asString();
  67. if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["LogStoreNamePattern"].isNull())
  68. logListObject.logStoreNamePattern = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["LogStoreNamePattern"].asString();
  69. if(!dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ErrorCode"].isNull())
  70. logListObject.errorCode = dataNodeConfigListConfigListItemProductListProductListItemLogListLogListItem["ErrorCode"].asString();
  71. productListObject.logList.push_back(logListObject);
  72. }
  73. configListItemObject.productList.push_back(productListObject);
  74. }
  75. data_.configList.push_back(configListItemObject);
  76. }
  77. if(!value["Success"].isNull())
  78. success_ = value["Success"].asString() == "true";
  79. if(!value["Code"].isNull())
  80. code_ = std::stoi(value["Code"].asString());
  81. if(!value["Message"].isNull())
  82. message_ = value["Message"].asString();
  83. if(!value["ErrCode"].isNull())
  84. errCode_ = value["ErrCode"].asString();
  85. }
  86. std::string BatchJobSubmitResult::getMessage()const
  87. {
  88. return message_;
  89. }
  90. BatchJobSubmitResult::Data BatchJobSubmitResult::getData()const
  91. {
  92. return data_;
  93. }
  94. int BatchJobSubmitResult::getCode()const
  95. {
  96. return code_;
  97. }
  98. bool BatchJobSubmitResult::getSuccess()const
  99. {
  100. return success_;
  101. }
  102. std::string BatchJobSubmitResult::getErrCode()const
  103. {
  104. return errCode_;
  105. }