Report status state field for cable objects

Tested:
Added and removed cables to see state field being reflected
based on the presence.

Change-Id: I0136b1407634ebc9033a7c3ea2da555018fd622b
Signed-off-by: Akshit Shah <shahakshit@google.com>
diff --git a/Redfish.md b/Redfish.md
index 0772b8e..32e266a 100644
--- a/Redfish.md
+++ b/Redfish.md
@@ -33,6 +33,7 @@
 
 - AccountService
 - AggregationService
+- Cables
 - CertificateService
 - Chassis
 - EventService
@@ -162,6 +163,7 @@
 
 - CableType
 - LengthMeters
+- Status
 
 ### /redfish/v1/CertificateService/
 
diff --git a/redfish-core/lib/cable.hpp b/redfish-core/lib/cable.hpp
index 265a1ea..28031e1 100644
--- a/redfish-core/lib/cable.hpp
+++ b/redfish-core/lib/cable.hpp
@@ -89,19 +89,42 @@
     {
         for (const auto& interface : interfaces)
         {
-            if (interface != "xyz.openbmc_project.Inventory.Item.Cable")
+            if (interface == "xyz.openbmc_project.Inventory.Item.Cable")
             {
-                continue;
+                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);
+                    });
             }
+            else if (interface == "xyz.openbmc_project.Inventory.Item")
+            {
+                sdbusplus::asio::getProperty<bool>(
+                    *crow::connections::systemBus, service, cableObjectPath,
+                    interface, "Present",
+                    [asyncResp, cableObjectPath](
+                        const boost::system::error_code& ec, bool present) {
+                    if (ec)
+                    {
+                        BMCWEB_LOG_DEBUG(
+                            "get presence failed for Cable {} with error {}",
+                            cableObjectPath, ec);
+                        if (ec.value() != EBADR)
+                        {
+                            messages::internalError(asyncResp->res);
+                        }
+                        return;
+                    }
 
-            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);
-                });
+                    if (!present)
+                    {
+                        asyncResp->res.jsonValue["Status"]["State"] = "Absent";
+                    }
+                    });
+            }
         }
     }
 }
@@ -155,6 +178,7 @@
                     boost::urls::format("/redfish/v1/Cables/{}", cableId);
                 asyncResp->res.jsonValue["Id"] = cableId;
                 asyncResp->res.jsonValue["Name"] = "Cable";
+                asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
 
                 getCableProperties(asyncResp, objectPath, serviceMap);
                 return;