1e0017ebbSMatt Spinler #pragma once 2e0017ebbSMatt Spinler 3e0017ebbSMatt Spinler #include <sdbusplus/server.hpp> 4*6a2b8956SPatrick Williams 5*6a2b8956SPatrick Williams #include <map> 6e0017ebbSMatt Spinler #include <string> 7e0017ebbSMatt Spinler #include <vector> 8e0017ebbSMatt Spinler 9e0017ebbSMatt Spinler namespace ibm 10e0017ebbSMatt Spinler { 11e0017ebbSMatt Spinler namespace logging 12e0017ebbSMatt Spinler { 13e0017ebbSMatt Spinler 14e0017ebbSMatt Spinler using DbusInterface = std::string; 15e0017ebbSMatt Spinler using DbusProperty = std::string; 16d82a6ddfSMatt Spinler using DbusService = std::string; 17d82a6ddfSMatt Spinler using DbusPath = std::string; 1852ee71bdSMatt Spinler 1952ee71bdSMatt Spinler static constexpr auto forwardPos = 0; 2052ee71bdSMatt Spinler static constexpr auto reversePos = 1; 2152ee71bdSMatt Spinler static constexpr auto endpointPos = 2; 2252ee71bdSMatt Spinler using AssociationsPropertyType = 2352ee71bdSMatt Spinler std::vector<std::tuple<std::string, std::string, std::string>>; 2452ee71bdSMatt Spinler 25b9ba9416SPatrick Williams using Value = std::variant<bool, uint32_t, uint64_t, std::string, 26b9ba9416SPatrick Williams std::vector<std::string>, AssociationsPropertyType>; 27e0017ebbSMatt Spinler 28e0017ebbSMatt Spinler using DbusPropertyMap = std::map<DbusProperty, Value>; 29e0017ebbSMatt Spinler using DbusInterfaceMap = std::map<DbusInterface, DbusPropertyMap>; 30e0017ebbSMatt Spinler using DbusInterfaceList = std::vector<DbusInterface>; 31e0017ebbSMatt Spinler 32bc997490SMatt Spinler using ObjectValueTree = 33bc997490SMatt Spinler std::map<sdbusplus::message::object_path, DbusInterfaceMap>; 34bc997490SMatt Spinler 35d82a6ddfSMatt Spinler using DbusSubtree = 36d82a6ddfSMatt Spinler std::map<DbusPath, std::map<DbusService, DbusInterfaceList>>; 37d82a6ddfSMatt Spinler 3832219bebSMatt Spinler /** 3932219bebSMatt Spinler * Returns the managed objects for an object path and service 4032219bebSMatt Spinler * 4132219bebSMatt Spinler * Returns an empty map if there are any failures. 4232219bebSMatt Spinler * 4332219bebSMatt Spinler * @param[in] bus - the D-Bus object 4432219bebSMatt Spinler * @param[in] service - the D-Bus service name 4532219bebSMatt Spinler * @param[in] objPath - the D-Bus object path 4632219bebSMatt Spinler * 4732219bebSMatt Spinler * @return ObjectValueTree - A map of object paths to their 4832219bebSMatt Spinler * interfaces and properties. 4932219bebSMatt Spinler */ 508123a713SPatrick Williams ObjectValueTree getManagedObjects(sdbusplus::bus_t& bus, 51bc997490SMatt Spinler const std::string& service, 52bc997490SMatt Spinler const std::string& objPath); 53d82a6ddfSMatt Spinler 54d82a6ddfSMatt Spinler /** 55d82a6ddfSMatt Spinler * Returns the subtree for a root, depth, and interface. 56d82a6ddfSMatt Spinler * 57d82a6ddfSMatt Spinler * Returns an empty map if there are any failures. 58d82a6ddfSMatt Spinler * 59d82a6ddfSMatt Spinler * @param[in] bus - the D-Bus object 60d82a6ddfSMatt Spinler * @param[in] root - the point from which to provide results 61d82a6ddfSMatt Spinler * @param[in] depth - the number of path elements to descend 62d82a6ddfSMatt Spinler * 63d82a6ddfSMatt Spinler * @return DbusSubtree - A map of object paths to their 64d82a6ddfSMatt Spinler * services and interfaces. 65d82a6ddfSMatt Spinler */ 668123a713SPatrick Williams DbusSubtree getSubtree(sdbusplus::bus_t& bus, const std::string& root, 677766e25bSMatt Spinler int depth, const std::string& interface); 68d82a6ddfSMatt Spinler 69d82a6ddfSMatt Spinler /** 70d82a6ddfSMatt Spinler * Get the D-Bus service name for the object path and interface from 71d82a6ddfSMatt Spinler * the data returned from a GetSubTree call. 72d82a6ddfSMatt Spinler * 73d82a6ddfSMatt Spinler * Returns an empty string if the service can't be found. 74d82a6ddfSMatt Spinler * 75d82a6ddfSMatt Spinler * @param[in] objPath - the D-Bus object path 76d82a6ddfSMatt Spinler * @param[in] interface - the D-Bus interface name 77d82a6ddfSMatt Spinler * @param[in] tree - the D-Bus GetSubTree response 78d82a6ddfSMatt Spinler * 79d82a6ddfSMatt Spinler * @return string - the service name 80d82a6ddfSMatt Spinler */ 81d82a6ddfSMatt Spinler DbusService getService(const std::string& objPath, const std::string& interface, 82d82a6ddfSMatt Spinler const DbusSubtree& tree); 83d82a6ddfSMatt Spinler 84d82a6ddfSMatt Spinler /** 85d82a6ddfSMatt Spinler * Returns all properties on a particular interface on a 86d82a6ddfSMatt Spinler * particular D-Bus object. 87d82a6ddfSMatt Spinler * 88d82a6ddfSMatt Spinler * Returns an empty map if there are any failures. 89d82a6ddfSMatt Spinler * 90d82a6ddfSMatt Spinler * @param[in] bus - the D-Bus object 91d82a6ddfSMatt Spinler * @param[in] service - the D-Bus service name 92d82a6ddfSMatt Spinler * @param[in] objPath - the D-Bus object path 93d82a6ddfSMatt Spinler * @param[in] interface - the D-Bus interface name 94d82a6ddfSMatt Spinler * 95d82a6ddfSMatt Spinler * @return DbusPropertyMap - The map of property names to values 96d82a6ddfSMatt Spinler */ 978123a713SPatrick Williams DbusPropertyMap getAllProperties(sdbusplus::bus_t& bus, 98d82a6ddfSMatt Spinler const std::string& service, 99d82a6ddfSMatt Spinler const std::string& objPath, 100d82a6ddfSMatt Spinler const std::string& interface); 10166e07073SMatt Spinler } // namespace logging 10266e07073SMatt Spinler } // namespace ibm 103