blob: 3091fbfd917b766be8ad5a5c415ed6456fee2c6e [file] [log] [blame]
Matt Spinlere0017eb2018-03-27 11:17:38 -05001#pragma once
2
3#include <map>
4#include <sdbusplus/server.hpp>
5#include <string>
6#include <vector>
7
8namespace ibm
9{
10namespace logging
11{
12
13using DbusInterface = std::string;
14using DbusProperty = std::string;
Matt Spinlerd82a6dd2018-05-23 11:31:22 -050015using DbusService = std::string;
16using DbusPath = std::string;
Matt Spinler52ee71b2018-05-23 13:18:55 -050017
18static constexpr auto forwardPos = 0;
19static constexpr auto reversePos = 1;
20static constexpr auto endpointPos = 2;
21using AssociationsPropertyType =
22 std::vector<std::tuple<std::string, std::string, std::string>>;
23
Patrick Williamsb9ba9412020-05-13 17:43:59 -050024using Value = std::variant<bool, uint32_t, uint64_t, std::string,
25 std::vector<std::string>, AssociationsPropertyType>;
Matt Spinlere0017eb2018-03-27 11:17:38 -050026
27using DbusPropertyMap = std::map<DbusProperty, Value>;
28using DbusInterfaceMap = std::map<DbusInterface, DbusPropertyMap>;
29using DbusInterfaceList = std::vector<DbusInterface>;
30
Matt Spinlerbc997492018-03-27 11:24:45 -050031using ObjectValueTree =
32 std::map<sdbusplus::message::object_path, DbusInterfaceMap>;
33
Matt Spinlerd82a6dd2018-05-23 11:31:22 -050034using DbusSubtree =
35 std::map<DbusPath, std::map<DbusService, DbusInterfaceList>>;
36
Matt Spinler32219be2018-05-23 11:29:41 -050037/**
38 * Returns the managed objects for an object path and service
39 *
40 * Returns an empty map if there are any failures.
41 *
42 * @param[in] bus - the D-Bus object
43 * @param[in] service - the D-Bus service name
44 * @param[in] objPath - the D-Bus object path
45 *
46 * @return ObjectValueTree - A map of object paths to their
47 * interfaces and properties.
48 */
Patrick Williams8123a712022-07-22 19:26:53 -050049ObjectValueTree getManagedObjects(sdbusplus::bus_t& bus,
Matt Spinler259e7272018-03-29 10:57:17 -050050 const std::string& service,
51 const std::string& objPath);
Matt Spinlerd82a6dd2018-05-23 11:31:22 -050052
53/**
54 * Returns the subtree for a root, depth, and interface.
55 *
56 * Returns an empty map if there are any failures.
57 *
58 * @param[in] bus - the D-Bus object
59 * @param[in] root - the point from which to provide results
60 * @param[in] depth - the number of path elements to descend
61 *
62 * @return DbusSubtree - A map of object paths to their
63 * services and interfaces.
64 */
Patrick Williams8123a712022-07-22 19:26:53 -050065DbusSubtree getSubtree(sdbusplus::bus_t& bus, const std::string& root,
Matt Spinler7766e252018-09-12 10:37:56 -050066 int depth, const std::string& interface);
Matt Spinlerd82a6dd2018-05-23 11:31:22 -050067
68/**
69 * Get the D-Bus service name for the object path and interface from
70 * the data returned from a GetSubTree call.
71 *
72 * Returns an empty string if the service can't be found.
73 *
74 * @param[in] objPath - the D-Bus object path
75 * @param[in] interface - the D-Bus interface name
76 * @param[in] tree - the D-Bus GetSubTree response
77 *
78 * @return string - the service name
79 */
80DbusService getService(const std::string& objPath, const std::string& interface,
81 const DbusSubtree& tree);
82
83/**
84 * Returns all properties on a particular interface on a
85 * particular D-Bus object.
86 *
87 * Returns an empty map if there are any failures.
88 *
89 * @param[in] bus - the D-Bus object
90 * @param[in] service - the D-Bus service name
91 * @param[in] objPath - the D-Bus object path
92 * @param[in] interface - the D-Bus interface name
93 *
94 * @return DbusPropertyMap - The map of property names to values
95 */
Patrick Williams8123a712022-07-22 19:26:53 -050096DbusPropertyMap getAllProperties(sdbusplus::bus_t& bus,
Matt Spinlerd82a6dd2018-05-23 11:31:22 -050097 const std::string& service,
98 const std::string& objPath,
99 const std::string& interface);
Matt Spinler66e07072018-09-12 10:36:14 -0500100} // namespace logging
101} // namespace ibm