blob: c572d9906143ee7893eb3577dd67a5a9ceae5742 [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
Matt Spinler259e7272018-03-29 10:57:17 -050024using Value = sdbusplus::message::variant<bool, uint32_t, uint64_t, std::string,
Matt Spinler52ee71b2018-05-23 13:18:55 -050025 std::vector<std::string>,
26 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 */
Matt Spinler259e7272018-03-29 10:57:17 -050050ObjectValueTree getManagedObjects(sdbusplus::bus::bus& bus,
51 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 */
66DbusSubtree getSubtree(sdbusplus::bus::bus& bus, const std::string& root,
67 size_t depth, const std::string& interface);
68
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 */
97DbusPropertyMap getAllProperties(sdbusplus::bus::bus& bus,
98 const std::string& service,
99 const std::string& objPath,
100 const std::string& interface);
Matt Spinlere0017eb2018-03-27 11:17:38 -0500101}
102}