| #ifndef THIRD_PARTY_GBMCWEB_DEVPATH_PLUGIN_REDFISH_DEVPATH_INJECTOR_H_ | |
| #define THIRD_PARTY_GBMCWEB_DEVPATH_PLUGIN_REDFISH_DEVPATH_INJECTOR_H_ | |
| #include <memory> | |
| #include <string_view> | |
| #include "absl/status/statusor.h" | |
| #include "redfish_devpath_injector_interface.hpp" | |
| #include "redfish_to_uhm_trie.hpp" | |
| #include "http_request.hpp" | |
| #include "http_response.hpp" | |
| namespace devpath_plugin { | |
| // RedfishDevpathInjector parses a mapping configuration file matching Redfish | |
| // URL patterns to UHM (Unified Hardware Model) monitored component keys and | |
| // their corresponding expose configuration (e.g., whether to expose OEM Google | |
| // Devpaths, placeholder settings, and location contexts). | |
| class RedfishDevpathInjector : public RedfishDevpathInjectorInterface { | |
| public: | |
| // Creates and initializes a `RedfishDevpathInjector` by reading and parsing | |
| // the textproto configuration file at `mapping_config_path`. | |
| // | |
| // Returns: | |
| // - A new `RedfishDevpathInjector` instance (wrapped in `std::unique_ptr`) | |
| // if the configuration is successfully read and parsed. | |
| // - `absl::NotFoundError` if the file cannot be opened. | |
| // - `absl::InvalidArgumentError` if the configuration cannot be parsed. | |
| static absl::StatusOr<std::unique_ptr<RedfishDevpathInjector>> Create( | |
| std::string_view mapping_config_path); | |
| void Inject(const crow::Request& req, crow::Response& res) const override; | |
| private: | |
| RedfishDevpathInjector() = default; | |
| RedfishToUhmTrie trie_; | |
| }; | |
| } // namespace devpath_plugin | |
| #endif // THIRD_PARTY_GBMCWEB_DEVPATH_PLUGIN_REDFISH_DEVPATH_INJECTOR_H_ |