used sdbusplus::unpackPropertiesNoThrow part 7

used sdbusplus::unpackPropertiesNoThrow in cable.hpp,
metric_report_definition.hpp, telemetry_service.hpp and trigger.hpp,
also replaced all usages of "GetAll" with
sdbusplus::asio::getAllProperties

    bmcweb size: 2697624 -> 2693528 (-4096)
compressed size: 1129037 -> 1129322 (+285)

Tested:
  Performed get on one of the:
  - /redfish/v1/Cables
  - /redfish/v1/TelemetryService/MetricReportDefinitions
  - /redfish/v1/TelemetryService/Triggers
    (trigger was added using Dbus API)

  Get result before and after the change was in same format.

Change-Id: I24f001b4f52d8eb5f529b08de278a611f8fa22b2
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/redfish-core/lib/cable.hpp b/redfish-core/lib/cable.hpp
index e553682..0b8cd0f 100644
--- a/redfish-core/lib/cable.hpp
+++ b/redfish-core/lib/cable.hpp
@@ -1,6 +1,9 @@
 #pragma once
 #include <dbus_utility.hpp>
 #include <query.hpp>
+#include <sdbusplus/asio/property.hpp>
+#include <sdbusplus/unpack_properties.hpp>
+#include <utils/dbus_utils.hpp>
 #include <utils/json_utils.hpp>
 
 namespace redfish
@@ -23,40 +26,37 @@
         return;
     }
 
-    for (const auto& [propKey, propVariant] : properties)
+    const std::string* cableTypeDescription = nullptr;
+    const double* length = nullptr;
+
+    const bool success = sdbusplus::unpackPropertiesNoThrow(
+        dbus_utils::UnpackErrorPrinter(), properties, "CableTypeDescription",
+        cableTypeDescription, "Length", length);
+
+    if (!success)
     {
-        if (propKey == "CableTypeDescription")
-        {
-            const std::string* cableTypeDescription =
-                std::get_if<std::string>(&propVariant);
-            if (cableTypeDescription == nullptr)
-            {
-                messages::internalError(resp);
-                return;
-            }
-            resp.jsonValue["CableType"] = *cableTypeDescription;
-        }
-        else if (propKey == "Length")
-        {
-            const double* cableLength = std::get_if<double>(&propVariant);
-            if (cableLength == nullptr)
-            {
-                messages::internalError(resp);
-                return;
-            }
+        messages::internalError(resp);
+        return;
+    }
 
-            if (!std::isfinite(*cableLength))
+    if (cableTypeDescription != nullptr)
+    {
+        resp.jsonValue["CableType"] = *cableTypeDescription;
+    }
+
+    if (length != nullptr)
+    {
+        if (!std::isfinite(*length))
+        {
+            if (std::isnan(*length))
             {
-                if (std::isnan(*cableLength))
-                {
-                    continue;
-                }
-                messages::internalError(resp);
                 return;
             }
-
-            resp.jsonValue["LengthMeters"] = *cableLength;
+            messages::internalError(resp);
+            return;
         }
+
+        resp.jsonValue["LengthMeters"] = *length;
     }
 }
 
@@ -83,14 +83,14 @@
                 continue;
             }
 
-            crow::connections::systemBus->async_method_call(
+            sdbusplus::asio::getAllProperties(
+                *crow::connections::systemBus, service, cableObjectPath,
+                interface,
                 [asyncResp](
                     const boost::system::error_code ec,
                     const dbus::utility::DBusPropertiesMap& properties) {
                 fillCableProperties(asyncResp->res, ec, properties);
-                },
-                service, cableObjectPath, "org.freedesktop.DBus.Properties",
-                "GetAll", interface);
+                });
         }
     }
 }