Remove variant from Thresholds interface

The Thresholds property on the Trigger interface is currently defined as
a relatively complex type:
variant<
   array<discrete struct>
   array<numeric struct>
>

This causes some oddities in unpacking given that Dbus properties are
already a variant, applications consuming this interface have to double
wrap the variant.  This was confusing enough that bmcweb has to keep the
trigger types separate, and cannot use the common typing.

This commit changes by adding two new parameters
NumericThresholds: array<numeric struct>
DiscreteThresholds: array<discrete struct>

Which deduplicates the double wrapped variant.

The intent is that this duplicated interface will exist for a transition
period of a week or two, while bmcweb (the only user of this)
transitions the code to use the new properties, then a followup common
will drop the thresholds properly.

Tested: WIP

Change-Id: I6717d4075de53c91aa179a90c7a844c4a13534cc
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/src/trigger.cpp b/src/trigger.cpp
index ca6804c..0b94711 100644
--- a/src/trigger.cpp
+++ b/src/trigger.cpp
@@ -85,6 +85,61 @@
         });
 
         dbusIface.register_property_rw(
+            "DiscreteThresholds", std::vector<discrete::ThresholdParam>{},
+            sdbusplus::vtable::property_::emits_change,
+            [this, &triggerFactory](
+                const std::vector<discrete::ThresholdParam>& newVal,
+                std::vector<discrete::ThresholdParam>& oldVal) {
+            LabeledTriggerThresholdParams newThresholdParams =
+                utils::ToLabeledThresholdParamConversion()(newVal);
+            TriggerManager::verifyThresholdParams(newThresholdParams);
+            triggerFactory.updateThresholds(thresholds, *id, triggerActions,
+                                            reportIds, sensors,
+                                            newThresholdParams);
+            oldVal = std::move(newVal);
+            return 1;
+        },
+            [this](const auto&) {
+            TriggerThresholdParams unlabeled =
+                fromLabeledThresholdParam(getLabeledThresholds());
+            auto* ptr =
+                std::get_if<std::vector<discrete::ThresholdParam>>(&unlabeled);
+            if (ptr == nullptr)
+            {
+                // If internal type doesn't match, return empty set
+                return std::vector<discrete::ThresholdParam>{};
+            }
+            return *ptr;
+        });
+
+        dbusIface.register_property_rw(
+            "NumericThresholds", std::vector<numeric::ThresholdParam>{},
+            sdbusplus::vtable::property_::emits_change,
+            [this, &triggerFactory](
+                const std::vector<numeric::ThresholdParam>& newVal,
+                std::vector<numeric::ThresholdParam>& oldVal) {
+            LabeledTriggerThresholdParams newThresholdParams =
+                utils::ToLabeledThresholdParamConversion()(newVal);
+            TriggerManager::verifyThresholdParams(newThresholdParams);
+            triggerFactory.updateThresholds(thresholds, *id, triggerActions,
+                                            reportIds, sensors,
+                                            newThresholdParams);
+            oldVal = std::move(newVal);
+            return 1;
+        },
+            [this](const auto&) {
+            TriggerThresholdParams unlabeled =
+                fromLabeledThresholdParam(getLabeledThresholds());
+            auto* ptr =
+                std::get_if<std::vector<numeric::ThresholdParam>>(&unlabeled);
+            if (ptr == nullptr)
+            {
+                // If internal type doesn't match, return empty set
+                return std::vector<numeric::ThresholdParam>{};
+            }
+            return *ptr;
+        });
+        dbusIface.register_property_rw(
             "Sensors", SensorsInfo{},
             sdbusplus::vtable::property_::emits_change,
             [this, &triggerFactory](auto newVal, auto& oldVal) {
diff --git a/src/trigger_manager.cpp b/src/trigger_manager.cpp
index 20dee51..5cc824e 100644
--- a/src/trigger_manager.cpp
+++ b/src/trigger_manager.cpp
@@ -25,16 +25,28 @@
         triggerManagerPath, triggerManagerIfaceName, [this](auto& iface) {
         iface.register_method(
             "AddTrigger",
-            [this](boost::asio::yield_context& yield, const std::string& id,
-                   const std::string& name,
-                   const std::vector<std::string>& triggerActions,
-                   const SensorsInfo& sensors,
-                   const std::vector<sdbusplus::message::object_path>& reports,
-                   const TriggerThresholdParamsExt& thresholds) {
-            LabeledTriggerThresholdParams labeledTriggerThresholdParams =
-                std::visit(utils::ToLabeledThresholdParamConversion(),
-                           thresholds);
-
+            [this](
+                boost::asio::yield_context& yield, const std::string& id,
+                const std::string& name,
+                const std::vector<std::string>& triggerActions,
+                const SensorsInfo& sensors,
+                const std::vector<sdbusplus::message::object_path>& reports,
+                const std::vector<numeric::ThresholdParam>& numericThresholds,
+                const std::vector<discrete::ThresholdParam>&
+                    discreteThresholds) {
+            LabeledTriggerThresholdParams labeledTriggerThresholdParams;
+            if (!numericThresholds.empty())
+            {
+                labeledTriggerThresholdParams =
+                    utils::ToLabeledThresholdParamConversion()(
+                        numericThresholds);
+            }
+            if (!discreteThresholds.empty())
+            {
+                labeledTriggerThresholdParams =
+                    utils::ToLabeledThresholdParamConversion()(
+                        discreteThresholds);
+            }
             std::vector<LabeledSensorInfo> labeledSensorsInfo =
                 triggerFactory->getLabeledSensorsInfo(yield, sensors);
 
diff --git a/src/types/trigger_types.hpp b/src/types/trigger_types.hpp
index 38da4f8..2c53a8b 100644
--- a/src/types/trigger_types.hpp
+++ b/src/types/trigger_types.hpp
@@ -136,12 +136,9 @@
                         utils::tstring::ThresholdValue>;
 } // namespace numeric
 
-using TriggerThresholdParamsExt =
-    std::variant<std::monostate, std::vector<numeric::ThresholdParam>,
-                 std::vector<discrete::ThresholdParam>>;
-
 using TriggerThresholdParams =
-    utils::WithoutMonostate<TriggerThresholdParamsExt>;
+    std::variant<std::vector<numeric::ThresholdParam>,
+                 std::vector<discrete::ThresholdParam>>;
 
 using LabeledTriggerThresholdParams =
     std::variant<std::vector<numeric::LabeledThresholdParam>,