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