monitor:JSON: Parse fan monitoring conditions
Optional conditions can be used to include monitoring a fan or not based
on the results of the condition function configured. These condition
functions have their own required set of parameters, so parsing the JSON
for these conditions are done per supported condition function. This
adds the JSON parsing support for the current condition functions.
Tested:
`propertiesMatch` JSON parameters parsed into condition function
Any required parameters missing throws an exception
The `propertiesMatch` condition functions the same using JSON
Change-Id: I0f843951f4e83f2a5d44068820694010538788c1
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/monitor/conditions.hpp b/monitor/conditions.hpp
index 76aa0de..687dfee 100644
--- a/monitor/conditions.hpp
+++ b/monitor/conditions.hpp
@@ -2,6 +2,8 @@
#include "types.hpp"
+#include <nlohmann/json.hpp>
+
namespace phosphor
{
namespace fan
@@ -9,6 +11,8 @@
namespace monitor
{
+using json = nlohmann::json;
+
/**
* @brief Create a condition function object
*
@@ -37,6 +41,21 @@
*/
Condition propertiesMatch(std::vector<PropertyState>&& propStates);
+/**
+ * @brief Parse the propertiesMatch condition's parameters from the given JSON
+ * configuration
+ * @details Parses and verifies all the required parameters are given in the
+ * JSON configuration to construct and return a function pointer to the
+ * propertiesMatch condition function.
+ *
+ * @param[in] condParams - JSON object containing all the propertiesMatch
+ * condition parameters
+ *
+ * @return Condition lambda function
+ * The propertiesMatch condition function that checks all properties match
+ */
+Condition getPropertiesMatch(const json& condParams);
+
} // namespace condition
} // namespace monitor
} // namespace fan