| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_REDFISH_EXPAND_QUERY_AGGREGATOR_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_REDFISH_EXPAND_QUERY_AGGREGATOR_H_ |
| |
| #include <memory> |
| #include <string> |
| #include <utility> |
| |
| #include "absl/strings/string_view.h" |
| #include "nlohmann/json_fwd.hpp" |
| #include "tlbmc/redfish/query_parameters.h" |
| #include "dbus_utility.hpp" // NOLINT |
| #include "async_resp.hpp" // NOLINT |
| #include "http_request.hpp" // NOLINT |
| #include "router_interface.h" |
| |
| namespace milotic_tlbmc { |
| |
| // This class will be in charge of aggregating the responses from the expand |
| // query. |
| // This class references the implmentation in openbmc gbmcweb. |
| // https://gbmc.googlesource.com/gbmcweb/+/refs/heads/master/redfish-core/include/query.cpp#742 |
| class ExpandQueryAggregator |
| : public std::enable_shared_from_this<ExpandQueryAggregator> { |
| public: |
| ExpandQueryAggregator() = default; |
| |
| ExpandQueryAggregator(std::shared_ptr<bmcweb::AsyncResp> final_async_resp, |
| ::crow::RouterInterface* router, |
| const QueryParameters& query_parameters) |
| : final_async_resp_(std::move(final_async_resp)), |
| smart_router_(router), |
| query_parameters_(query_parameters) {} |
| |
| void StartQuery(); |
| |
| protected: |
| std::string CreateExpandQueryUrl(absl::string_view url, |
| const ExpandNode& expand_node); |
| |
| void AddResponseToFinalResponse(const nlohmann::json::json_pointer& location, |
| ::crow::Response& sub_response); |
| |
| void PropogateErrorCodeIfNeeded(const nlohmann::json::json_pointer& location, |
| ::crow::Response& sub_response); |
| |
| unsigned DetermineFinalErrorCode(unsigned sub_response_code); |
| |
| std::shared_ptr<bmcweb::AsyncResp> final_async_resp_; |
| ::crow::RouterInterface* smart_router_; |
| const QueryParameters query_parameters_; |
| }; |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_REDFISH_EXPAND_QUERY_AGGREGATOR_H_ |