summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Add-support-for-DELETE-in-MetricReportDefinitions-st.patch
blob: 4c49b0cd338914d1c931b4cf33cb75f4142ac5d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From 8b2f4a6fe57bf2410cdb22f8c3c695e98d583040 Mon Sep 17 00:00:00 2001
From: "Wludzik, Jozef" <jozef.wludzik@intel.com>
Date: Mon, 18 May 2020 12:40:15 +0200
Subject: [PATCH 3/5] Add support for DELETE in MetricReportDefinitions/<str>

Added support for DELETE action in MetricReportDefinitions/<str>
node. It allows user to remove MetricReportDefinition together
with MetricReport connected to it.

Tested:
 - Succesfully passed RedfishServiceValidator.py
 - Validated DELETE action by removing exisiting
   MetricReportDefinitions from MonitoringService
 - Validated DELETE action with negative cases when
   MetricReportDefinition does not exist

Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
Change-Id: Iffde9f7bbf2955376e9714ac8d833967bd25eaa3
---
 redfish-core/lib/metric_report_definition.hpp | 32 +++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index ecbab0c..8e04ac8 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -533,6 +533,38 @@ class MetricReportDefinition : public Node
             "xyz.openbmc_project.MonitoringService.Report");
     }
 
+    void doDelete(crow::Response& res, const crow::Request& req,
+                  const std::vector<std::string>& params) override
+    {
+        auto asyncResp = std::make_shared<AsyncResp>(res);
+        if (params.size() != 1)
+        {
+            messages::internalError(asyncResp->res);
+            return;
+        }
+
+        const std::string& id = params[0];
+        telemetry::getReport(asyncResp, id, schemaType, deleteReport);
+    }
+
+    static void deleteReport(const std::shared_ptr<AsyncResp>& asyncResp,
+                             const std::string& path, const std::string& id)
+    {
+        crow::connections::systemBus->async_method_call(
+            [asyncResp](const boost::system::error_code ec) {
+                if (ec)
+                {
+                    BMCWEB_LOG_ERROR << "respHandler DBus error " << ec;
+                    messages::internalError(asyncResp->res);
+                    return;
+                }
+
+                asyncResp->res.result(boost::beast::http::status::no_content);
+            },
+            "xyz.openbmc_project.MonitoringService", path,
+            "xyz.openbmc_project.Object.Delete", "Delete");
+    }
+
   public:
     static constexpr const char* schemaType =
         "#MetricReportDefinition.v1_3_0.MetricReportDefinition";
-- 
2.16.6