AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2020 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 17 | #include "app.hpp" |
AppaRao Puli | b52664e | 2020-04-09 21:36:51 +0530 | [diff] [blame] | 18 | #include "event_service_manager.hpp" |
Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 19 | #include "http/utility.hpp" |
| 20 | #include "logging.hpp" |
| 21 | #include "query.hpp" |
| 22 | #include "registries/privilege_registry.hpp" |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 23 | |
Ed Tanous | 601c71a | 2021-09-08 16:40:12 -0700 | [diff] [blame] | 24 | #include <boost/beast/http/fields.hpp> |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 25 | |
Patrick Williams | 1e270c5 | 2021-12-04 06:06:56 -0600 | [diff] [blame] | 26 | #include <span> |
| 27 | |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 28 | namespace redfish |
| 29 | { |
| 30 | |
AppaRao Puli | 156d6b0 | 2020-04-25 06:04:05 +0530 | [diff] [blame] | 31 | static constexpr const std::array<const char*, 2> supportedEvtFormatTypes = { |
| 32 | eventFormatType, metricReportFormatType}; |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 33 | static constexpr const std::array<const char*, 3> supportedRegPrefixes = { |
P Dheeraj Srujan Kumar | b304bd7 | 2021-01-29 17:46:35 +0530 | [diff] [blame] | 34 | "Base", "OpenBMC", "TaskEvent"}; |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 35 | static constexpr const std::array<const char*, 3> supportedRetryPolicies = { |
| 36 | "TerminateAfterRetries", "SuspendRetries", "RetryForever"}; |
| 37 | |
Sunitha Harish | e56f254 | 2020-07-22 02:38:59 -0500 | [diff] [blame] | 38 | #ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE |
| 39 | static constexpr const std::array<const char*, 2> supportedResourceTypes = { |
| 40 | "IBMConfigFile", "Task"}; |
| 41 | #else |
| 42 | static constexpr const std::array<const char*, 1> supportedResourceTypes = { |
| 43 | "Task"}; |
| 44 | #endif |
| 45 | |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 46 | static constexpr const uint8_t maxNoOfSubscriptions = 20; |
| 47 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 48 | inline void requestRoutesEventService(App& app) |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 49 | { |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 50 | BMCWEB_ROUTE(app, "/redfish/v1/EventService/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 51 | .privileges(redfish::privileges::getEventService) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 52 | .methods(boost::beast::http::verb::get)( |
| 53 | [&app](const crow::Request& req, |
| 54 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 55 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 56 | { |
| 57 | return; |
| 58 | } |
Ed Tanous | 1476687 | 2022-03-15 10:44:42 -0700 | [diff] [blame] | 59 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 60 | asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/EventService"; |
| 61 | asyncResp->res.jsonValue["@odata.type"] = |
| 62 | "#EventService.v1_5_0.EventService"; |
| 63 | asyncResp->res.jsonValue["Id"] = "EventService"; |
| 64 | asyncResp->res.jsonValue["Name"] = "Event Service"; |
| 65 | asyncResp->res.jsonValue["Subscriptions"]["@odata.id"] = |
| 66 | "/redfish/v1/EventService/Subscriptions"; |
| 67 | asyncResp->res |
| 68 | .jsonValue["Actions"]["#EventService.SubmitTestEvent"]["target"] = |
| 69 | "/redfish/v1/EventService/Actions/EventService.SubmitTestEvent"; |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 70 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 71 | const persistent_data::EventServiceConfig eventServiceConfig = |
| 72 | persistent_data::EventServiceStore::getInstance() |
| 73 | .getEventServiceConfig(); |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 74 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 75 | asyncResp->res.jsonValue["Status"]["State"] = |
| 76 | (eventServiceConfig.enabled ? "Enabled" : "Disabled"); |
| 77 | asyncResp->res.jsonValue["ServiceEnabled"] = eventServiceConfig.enabled; |
| 78 | asyncResp->res.jsonValue["DeliveryRetryAttempts"] = |
| 79 | eventServiceConfig.retryAttempts; |
| 80 | asyncResp->res.jsonValue["DeliveryRetryIntervalSeconds"] = |
| 81 | eventServiceConfig.retryTimeoutInterval; |
| 82 | asyncResp->res.jsonValue["EventFormatTypes"] = supportedEvtFormatTypes; |
| 83 | asyncResp->res.jsonValue["RegistryPrefixes"] = supportedRegPrefixes; |
| 84 | asyncResp->res.jsonValue["ResourceTypes"] = supportedResourceTypes; |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 85 | |
Ed Tanous | 613dabe | 2022-07-09 11:17:36 -0700 | [diff] [blame] | 86 | nlohmann::json::object_t supportedSSEFilters; |
| 87 | supportedSSEFilters["EventFormatType"] = true; |
| 88 | supportedSSEFilters["MessageId"] = true; |
| 89 | supportedSSEFilters["MetricReportDefinition"] = true; |
| 90 | supportedSSEFilters["RegistryPrefix"] = true; |
| 91 | supportedSSEFilters["OriginResource"] = false; |
| 92 | supportedSSEFilters["ResourceType"] = false; |
AppaRao Puli | 7d1cc38 | 2020-05-16 02:42:22 +0530 | [diff] [blame] | 93 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 94 | asyncResp->res.jsonValue["SSEFilterPropertiesSupported"] = |
Ed Tanous | 613dabe | 2022-07-09 11:17:36 -0700 | [diff] [blame] | 95 | std::move(supportedSSEFilters); |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 96 | }); |
Ayushi Smriti | 07941a8 | 2020-05-21 15:55:34 +0530 | [diff] [blame] | 97 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 98 | BMCWEB_ROUTE(app, "/redfish/v1/EventService/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 99 | .privileges(redfish::privileges::patchEventService) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 100 | .methods(boost::beast::http::verb::patch)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 101 | [&app](const crow::Request& req, |
| 102 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 103 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 104 | { |
| 105 | return; |
| 106 | } |
| 107 | std::optional<bool> serviceEnabled; |
| 108 | std::optional<uint32_t> retryAttemps; |
| 109 | std::optional<uint32_t> retryInterval; |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 110 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 111 | if (!json_util::readJsonPatch( |
| 112 | req, asyncResp->res, "ServiceEnabled", serviceEnabled, |
| 113 | "DeliveryRetryAttempts", retryAttemps, |
| 114 | "DeliveryRetryIntervalSeconds", retryInterval)) |
| 115 | { |
| 116 | return; |
| 117 | } |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 118 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 119 | persistent_data::EventServiceConfig eventServiceConfig = |
| 120 | persistent_data::EventServiceStore::getInstance() |
| 121 | .getEventServiceConfig(); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 122 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 123 | if (serviceEnabled) |
| 124 | { |
| 125 | eventServiceConfig.enabled = *serviceEnabled; |
| 126 | } |
Sunitha Harish | e56f254 | 2020-07-22 02:38:59 -0500 | [diff] [blame] | 127 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 128 | if (retryAttemps) |
| 129 | { |
| 130 | // Supported range [1-3] |
| 131 | if ((*retryAttemps < 1) || (*retryAttemps > 3)) |
| 132 | { |
| 133 | messages::queryParameterOutOfRange( |
| 134 | asyncResp->res, std::to_string(*retryAttemps), |
| 135 | "DeliveryRetryAttempts", "[1-3]"); |
| 136 | } |
| 137 | else |
| 138 | { |
| 139 | eventServiceConfig.retryAttempts = *retryAttemps; |
| 140 | } |
| 141 | } |
P Dheeraj Srujan Kumar | b304bd7 | 2021-01-29 17:46:35 +0530 | [diff] [blame] | 142 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 143 | if (retryInterval) |
| 144 | { |
Gunnar Mills | 33a32b3 | 2022-11-17 14:29:07 -0600 | [diff] [blame] | 145 | // Supported range [5 - 180] |
| 146 | if ((*retryInterval < 5) || (*retryInterval > 180)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 147 | { |
| 148 | messages::queryParameterOutOfRange( |
| 149 | asyncResp->res, std::to_string(*retryInterval), |
Gunnar Mills | 33a32b3 | 2022-11-17 14:29:07 -0600 | [diff] [blame] | 150 | "DeliveryRetryIntervalSeconds", "[5-180]"); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 151 | } |
| 152 | else |
| 153 | { |
| 154 | eventServiceConfig.retryTimeoutInterval = *retryInterval; |
| 155 | } |
| 156 | } |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 157 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 158 | EventServiceManager::getInstance().setEventServiceConfig( |
| 159 | eventServiceConfig); |
| 160 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | inline void requestRoutesSubmitTestEvent(App& app) |
| 164 | { |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 165 | BMCWEB_ROUTE( |
| 166 | app, "/redfish/v1/EventService/Actions/EventService.SubmitTestEvent/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 167 | .privileges(redfish::privileges::postEventService) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 168 | .methods(boost::beast::http::verb::post)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 169 | [&app](const crow::Request& req, |
| 170 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 171 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 172 | { |
| 173 | return; |
| 174 | } |
| 175 | if (!EventServiceManager::getInstance().sendTestEventLog()) |
| 176 | { |
| 177 | messages::serviceDisabled(asyncResp->res, |
| 178 | "/redfish/v1/EventService/"); |
| 179 | return; |
| 180 | } |
| 181 | asyncResp->res.result(boost::beast::http::status::no_content); |
| 182 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | inline void requestRoutesEventDestinationCollection(App& app) |
| 186 | { |
Gayathri Leburu | 1ebe3e4 | 2022-02-09 10:45:19 +0000 | [diff] [blame] | 187 | BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 188 | .privileges(redfish::privileges::getEventDestinationCollection) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 189 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 190 | [&app](const crow::Request& req, |
| 191 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 192 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 193 | { |
| 194 | return; |
| 195 | } |
| 196 | asyncResp->res.jsonValue["@odata.type"] = |
| 197 | "#EventDestinationCollection.EventDestinationCollection"; |
| 198 | asyncResp->res.jsonValue["@odata.id"] = |
| 199 | "/redfish/v1/EventService/Subscriptions"; |
| 200 | asyncResp->res.jsonValue["Name"] = "Event Destination Collections"; |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 201 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 202 | nlohmann::json& memberArray = asyncResp->res.jsonValue["Members"]; |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 203 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 204 | std::vector<std::string> subscripIds = |
| 205 | EventServiceManager::getInstance().getAllIDs(); |
| 206 | memberArray = nlohmann::json::array(); |
| 207 | asyncResp->res.jsonValue["Members@odata.count"] = subscripIds.size(); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 208 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 209 | for (const std::string& id : subscripIds) |
| 210 | { |
| 211 | nlohmann::json::object_t member; |
Patrick Williams | 89492a1 | 2023-05-10 07:51:34 -0500 | [diff] [blame] | 212 | member["@odata.id"] = "/redfish/v1/EventService/Subscriptions/" + |
| 213 | id; |
Patrick Williams | b2ba307 | 2023-05-12 10:27:39 -0500 | [diff] [blame] | 214 | memberArray.emplace_back(std::move(member)); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 215 | } |
| 216 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 217 | BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/") |
Abhishek Patel | 7eeafa7 | 2021-07-28 10:59:16 -0500 | [diff] [blame] | 218 | .privileges(redfish::privileges::postEventDestinationCollection) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 219 | .methods(boost::beast::http::verb::post)( |
| 220 | [&app](const crow::Request& req, |
| 221 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 222 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 223 | { |
| 224 | return; |
| 225 | } |
| 226 | if (EventServiceManager::getInstance().getNumberOfSubscriptions() >= |
| 227 | maxNoOfSubscriptions) |
| 228 | { |
| 229 | messages::eventSubscriptionLimitExceeded(asyncResp->res); |
| 230 | return; |
| 231 | } |
| 232 | std::string destUrl; |
| 233 | std::string protocol; |
| 234 | std::optional<std::string> context; |
| 235 | std::optional<std::string> subscriptionType; |
| 236 | std::optional<std::string> eventFormatType2; |
| 237 | std::optional<std::string> retryPolicy; |
| 238 | std::optional<std::vector<std::string>> msgIds; |
| 239 | std::optional<std::vector<std::string>> regPrefixes; |
| 240 | std::optional<std::vector<std::string>> resTypes; |
| 241 | std::optional<std::vector<nlohmann::json>> headers; |
| 242 | std::optional<std::vector<nlohmann::json>> mrdJsonArray; |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 243 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 244 | if (!json_util::readJsonPatch( |
| 245 | req, asyncResp->res, "Destination", destUrl, "Context", context, |
| 246 | "Protocol", protocol, "SubscriptionType", subscriptionType, |
| 247 | "EventFormatType", eventFormatType2, "HttpHeaders", headers, |
| 248 | "RegistryPrefixes", regPrefixes, "MessageIds", msgIds, |
| 249 | "DeliveryRetryPolicy", retryPolicy, "MetricReportDefinitions", |
| 250 | mrdJsonArray, "ResourceTypes", resTypes)) |
| 251 | { |
| 252 | return; |
| 253 | } |
| 254 | |
AppaRao Puli | 600af5f | 2021-10-06 21:51:16 +0000 | [diff] [blame] | 255 | // https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers |
| 256 | static constexpr const uint16_t maxDestinationSize = 2000; |
| 257 | if (destUrl.size() > maxDestinationSize) |
| 258 | { |
| 259 | messages::stringValueTooLong(asyncResp->res, "Destination", |
| 260 | maxDestinationSize); |
| 261 | return; |
| 262 | } |
| 263 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 264 | if (regPrefixes && msgIds) |
| 265 | { |
| 266 | if (!regPrefixes->empty() && !msgIds->empty()) |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 267 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 268 | messages::propertyValueConflict(asyncResp->res, "MessageIds", |
| 269 | "RegistryPrefixes"); |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 270 | return; |
| 271 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 272 | } |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 273 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 274 | std::string host; |
| 275 | std::string urlProto; |
| 276 | uint16_t port = 0; |
| 277 | std::string path; |
| 278 | |
| 279 | if (!crow::utility::validateAndSplitUrl(destUrl, urlProto, host, port, |
| 280 | path)) |
| 281 | { |
| 282 | BMCWEB_LOG_WARNING |
| 283 | << "Failed to validate and split destination url"; |
| 284 | messages::propertyValueFormatError(asyncResp->res, destUrl, |
| 285 | "Destination"); |
| 286 | return; |
| 287 | } |
| 288 | |
| 289 | if (path.empty()) |
| 290 | { |
| 291 | path = "/"; |
| 292 | } |
Ed Tanous | f8ca6d7 | 2022-06-28 12:12:03 -0700 | [diff] [blame] | 293 | std::shared_ptr<Subscription> subValue = std::make_shared<Subscription>( |
| 294 | host, port, path, urlProto, app.ioContext()); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 295 | |
| 296 | subValue->destinationUrl = destUrl; |
| 297 | |
| 298 | if (subscriptionType) |
| 299 | { |
| 300 | if (*subscriptionType != "RedfishEvent") |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 301 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 302 | messages::propertyValueNotInList( |
| 303 | asyncResp->res, *subscriptionType, "SubscriptionType"); |
| 304 | return; |
| 305 | } |
| 306 | subValue->subscriptionType = *subscriptionType; |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | subValue->subscriptionType = "RedfishEvent"; // Default |
| 311 | } |
| 312 | |
| 313 | if (protocol != "Redfish") |
| 314 | { |
| 315 | messages::propertyValueNotInList(asyncResp->res, protocol, |
| 316 | "Protocol"); |
| 317 | return; |
| 318 | } |
| 319 | subValue->protocol = protocol; |
| 320 | |
| 321 | if (eventFormatType2) |
| 322 | { |
| 323 | if (std::find(supportedEvtFormatTypes.begin(), |
| 324 | supportedEvtFormatTypes.end(), |
| 325 | *eventFormatType2) == supportedEvtFormatTypes.end()) |
| 326 | { |
| 327 | messages::propertyValueNotInList( |
| 328 | asyncResp->res, *eventFormatType2, "EventFormatType"); |
| 329 | return; |
| 330 | } |
| 331 | subValue->eventFormatType = *eventFormatType2; |
| 332 | } |
| 333 | else |
| 334 | { |
| 335 | // If not specified, use default "Event" |
| 336 | subValue->eventFormatType = "Event"; |
| 337 | } |
| 338 | |
| 339 | if (context) |
| 340 | { |
AppaRao Puli | 600af5f | 2021-10-06 21:51:16 +0000 | [diff] [blame] | 341 | // This value is selected aribitrarily. |
| 342 | constexpr const size_t maxContextSize = 256; |
| 343 | if (context->size() > maxContextSize) |
| 344 | { |
| 345 | messages::stringValueTooLong(asyncResp->res, "Context", |
| 346 | maxContextSize); |
| 347 | return; |
| 348 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 349 | subValue->customText = *context; |
| 350 | } |
| 351 | |
| 352 | if (headers) |
| 353 | { |
AppaRao Puli | 600af5f | 2021-10-06 21:51:16 +0000 | [diff] [blame] | 354 | size_t cumulativeLen = 0; |
| 355 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 356 | for (const nlohmann::json& headerChunk : *headers) |
| 357 | { |
AppaRao Puli | 600af5f | 2021-10-06 21:51:16 +0000 | [diff] [blame] | 358 | std::string hdr{headerChunk.dump( |
| 359 | -1, ' ', true, nlohmann::json::error_handler_t::replace)}; |
| 360 | cumulativeLen += hdr.length(); |
| 361 | |
| 362 | // This value is selected to mirror http_connection.hpp |
| 363 | constexpr const uint16_t maxHeaderSizeED = 8096; |
| 364 | if (cumulativeLen > maxHeaderSizeED) |
| 365 | { |
| 366 | messages::arraySizeTooLong(asyncResp->res, "HttpHeaders", |
| 367 | maxHeaderSizeED); |
| 368 | return; |
| 369 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 370 | for (const auto& item : headerChunk.items()) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 371 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 372 | const std::string* value = |
| 373 | item.value().get_ptr<const std::string*>(); |
| 374 | if (value == nullptr) |
| 375 | { |
| 376 | messages::propertyValueFormatError( |
| 377 | asyncResp->res, item.value().dump(2, 1), |
| 378 | "HttpHeaders/" + item.key()); |
| 379 | return; |
| 380 | } |
| 381 | subValue->httpHeaders.set(item.key(), *value); |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | if (regPrefixes) |
| 387 | { |
| 388 | for (const std::string& it : *regPrefixes) |
| 389 | { |
| 390 | if (std::find(supportedRegPrefixes.begin(), |
| 391 | supportedRegPrefixes.end(), |
| 392 | it) == supportedRegPrefixes.end()) |
| 393 | { |
| 394 | messages::propertyValueNotInList(asyncResp->res, it, |
| 395 | "RegistryPrefixes"); |
P Dheeraj Srujan Kumar | b304bd7 | 2021-01-29 17:46:35 +0530 | [diff] [blame] | 396 | return; |
| 397 | } |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 398 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 399 | subValue->registryPrefixes = *regPrefixes; |
| 400 | } |
P Dheeraj Srujan Kumar | b304bd7 | 2021-01-29 17:46:35 +0530 | [diff] [blame] | 401 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 402 | if (resTypes) |
| 403 | { |
| 404 | for (const std::string& it : *resTypes) |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 405 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 406 | if (std::find(supportedResourceTypes.begin(), |
| 407 | supportedResourceTypes.end(), |
| 408 | it) == supportedResourceTypes.end()) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 409 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 410 | messages::propertyValueNotInList(asyncResp->res, it, |
| 411 | "ResourceTypes"); |
AppaRao Puli | 144b631 | 2020-08-03 22:23:12 +0530 | [diff] [blame] | 412 | return; |
| 413 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 414 | } |
| 415 | subValue->resourceTypes = *resTypes; |
| 416 | } |
| 417 | |
| 418 | if (msgIds) |
| 419 | { |
| 420 | std::vector<std::string> registryPrefix; |
| 421 | |
| 422 | // If no registry prefixes are mentioned, consider all |
| 423 | // supported prefixes |
| 424 | if (subValue->registryPrefixes.empty()) |
| 425 | { |
| 426 | registryPrefix.assign(supportedRegPrefixes.begin(), |
| 427 | supportedRegPrefixes.end()); |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 428 | } |
| 429 | else |
| 430 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 431 | registryPrefix = subValue->registryPrefixes; |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 432 | } |
AppaRao Puli | 156d6b0 | 2020-04-25 06:04:05 +0530 | [diff] [blame] | 433 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 434 | for (const std::string& id : *msgIds) |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 435 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 436 | bool validId = false; |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 437 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 438 | // Check for Message ID in each of the selected Registry |
| 439 | for (const std::string& it : registryPrefix) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 440 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 441 | const std::span<const redfish::registries::MessageEntry> |
| 442 | registry = |
| 443 | redfish::registries::getRegistryFromPrefix(it); |
| 444 | |
| 445 | if (std::any_of( |
| 446 | registry.begin(), registry.end(), |
| 447 | [&id](const redfish::registries::MessageEntry& |
| 448 | messageEntry) { |
| 449 | return id == messageEntry.first; |
| 450 | })) |
| 451 | { |
| 452 | validId = true; |
| 453 | break; |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | if (!validId) |
| 458 | { |
| 459 | messages::propertyValueNotInList(asyncResp->res, id, |
| 460 | "MessageIds"); |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 461 | return; |
| 462 | } |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 463 | } |
| 464 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 465 | subValue->registryMsgIds = *msgIds; |
| 466 | } |
| 467 | |
| 468 | if (retryPolicy) |
| 469 | { |
| 470 | if (std::find(supportedRetryPolicies.begin(), |
| 471 | supportedRetryPolicies.end(), |
| 472 | *retryPolicy) == supportedRetryPolicies.end()) |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 473 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 474 | messages::propertyValueNotInList(asyncResp->res, *retryPolicy, |
| 475 | "DeliveryRetryPolicy"); |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 476 | return; |
| 477 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 478 | subValue->retryPolicy = *retryPolicy; |
| 479 | } |
| 480 | else |
| 481 | { |
| 482 | // Default "TerminateAfterRetries" |
| 483 | subValue->retryPolicy = "TerminateAfterRetries"; |
| 484 | } |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 485 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 486 | if (mrdJsonArray) |
| 487 | { |
| 488 | for (nlohmann::json& mrdObj : *mrdJsonArray) |
| 489 | { |
| 490 | std::string mrdUri; |
| 491 | |
| 492 | if (!json_util::readJson(mrdObj, asyncResp->res, "@odata.id", |
| 493 | mrdUri)) |
| 494 | |
| 495 | { |
| 496 | return; |
| 497 | } |
| 498 | subValue->metricReportDefinitions.emplace_back(mrdUri); |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | std::string id = |
| 503 | EventServiceManager::getInstance().addSubscription(subValue); |
| 504 | if (id.empty()) |
| 505 | { |
| 506 | messages::internalError(asyncResp->res); |
| 507 | return; |
| 508 | } |
| 509 | |
| 510 | messages::created(asyncResp->res); |
| 511 | asyncResp->res.addHeader( |
| 512 | "Location", "/redfish/v1/EventService/Subscriptions/" + id); |
Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 513 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | inline void requestRoutesEventDestination(App& app) |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 517 | { |
Ravi Teja | 9d41aec | 2021-07-23 01:57:01 -0500 | [diff] [blame] | 518 | BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 519 | .privileges(redfish::privileges::getEventDestination) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 520 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 521 | [&app](const crow::Request& req, |
| 522 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 523 | const std::string& param) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 524 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 525 | { |
| 526 | return; |
| 527 | } |
| 528 | std::shared_ptr<Subscription> subValue = |
| 529 | EventServiceManager::getInstance().getSubscription(param); |
| 530 | if (subValue == nullptr) |
| 531 | { |
| 532 | asyncResp->res.result(boost::beast::http::status::not_found); |
| 533 | return; |
| 534 | } |
| 535 | const std::string& id = param; |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 536 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 537 | asyncResp->res.jsonValue["@odata.type"] = |
| 538 | "#EventDestination.v1_7_0.EventDestination"; |
| 539 | asyncResp->res.jsonValue["Protocol"] = "Redfish"; |
| 540 | asyncResp->res.jsonValue["@odata.id"] = |
| 541 | "/redfish/v1/EventService/Subscriptions/" + id; |
| 542 | asyncResp->res.jsonValue["Id"] = id; |
| 543 | asyncResp->res.jsonValue["Name"] = "Event Destination " + id; |
| 544 | asyncResp->res.jsonValue["Destination"] = subValue->destinationUrl; |
| 545 | asyncResp->res.jsonValue["Context"] = subValue->customText; |
| 546 | asyncResp->res.jsonValue["SubscriptionType"] = |
| 547 | subValue->subscriptionType; |
| 548 | asyncResp->res.jsonValue["HttpHeaders"] = nlohmann::json::array(); |
| 549 | asyncResp->res.jsonValue["EventFormatType"] = subValue->eventFormatType; |
| 550 | asyncResp->res.jsonValue["RegistryPrefixes"] = |
| 551 | subValue->registryPrefixes; |
| 552 | asyncResp->res.jsonValue["ResourceTypes"] = subValue->resourceTypes; |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 553 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 554 | asyncResp->res.jsonValue["MessageIds"] = subValue->registryMsgIds; |
| 555 | asyncResp->res.jsonValue["DeliveryRetryPolicy"] = subValue->retryPolicy; |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 556 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 557 | nlohmann::json::array_t mrdJsonArray; |
| 558 | for (const auto& mdrUri : subValue->metricReportDefinitions) |
| 559 | { |
| 560 | nlohmann::json::object_t mdr; |
| 561 | mdr["@odata.id"] = mdrUri; |
| 562 | mrdJsonArray.emplace_back(std::move(mdr)); |
| 563 | } |
| 564 | asyncResp->res.jsonValue["MetricReportDefinitions"] = mrdJsonArray; |
| 565 | }); |
Ravi Teja | 9d41aec | 2021-07-23 01:57:01 -0500 | [diff] [blame] | 566 | BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 567 | // The below privilege is wrong, it should be ConfigureManager OR |
| 568 | // ConfigureSelf |
Abhishek Patel | 7eeafa7 | 2021-07-28 10:59:16 -0500 | [diff] [blame] | 569 | // https://github.com/openbmc/bmcweb/issues/220 |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 570 | //.privileges(redfish::privileges::patchEventDestination) |
Ed Tanous | 432a890 | 2021-06-14 15:28:56 -0700 | [diff] [blame] | 571 | .privileges({{"ConfigureManager"}}) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 572 | .methods(boost::beast::http::verb::patch)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 573 | [&app](const crow::Request& req, |
| 574 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 575 | const std::string& param) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 576 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 577 | { |
| 578 | return; |
| 579 | } |
| 580 | std::shared_ptr<Subscription> subValue = |
| 581 | EventServiceManager::getInstance().getSubscription(param); |
| 582 | if (subValue == nullptr) |
| 583 | { |
| 584 | asyncResp->res.result(boost::beast::http::status::not_found); |
| 585 | return; |
| 586 | } |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 587 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 588 | std::optional<std::string> context; |
| 589 | std::optional<std::string> retryPolicy; |
| 590 | std::optional<std::vector<nlohmann::json>> headers; |
Sunitha Harish | e56f254 | 2020-07-22 02:38:59 -0500 | [diff] [blame] | 591 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 592 | if (!json_util::readJsonPatch(req, asyncResp->res, "Context", context, |
| 593 | "DeliveryRetryPolicy", retryPolicy, |
| 594 | "HttpHeaders", headers)) |
| 595 | { |
| 596 | return; |
| 597 | } |
AppaRao Puli | 144b631 | 2020-08-03 22:23:12 +0530 | [diff] [blame] | 598 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 599 | if (context) |
| 600 | { |
| 601 | subValue->customText = *context; |
| 602 | } |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 603 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 604 | if (headers) |
| 605 | { |
| 606 | boost::beast::http::fields fields; |
| 607 | for (const nlohmann::json& headerChunk : *headers) |
| 608 | { |
Patrick Williams | 62bafc0 | 2022-09-08 17:35:35 -0500 | [diff] [blame] | 609 | for (const auto& it : headerChunk.items()) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 610 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 611 | const std::string* value = |
| 612 | it.value().get_ptr<const std::string*>(); |
| 613 | if (value == nullptr) |
Ed Tanous | 601c71a | 2021-09-08 16:40:12 -0700 | [diff] [blame] | 614 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 615 | messages::propertyValueFormatError( |
| 616 | asyncResp->res, it.value().dump(2, ' ', true), |
| 617 | "HttpHeaders/" + it.key()); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 618 | return; |
| 619 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 620 | fields.set(it.key(), *value); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 621 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 622 | } |
| 623 | subValue->httpHeaders = fields; |
| 624 | } |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 625 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 626 | if (retryPolicy) |
| 627 | { |
| 628 | if (std::find(supportedRetryPolicies.begin(), |
| 629 | supportedRetryPolicies.end(), |
| 630 | *retryPolicy) == supportedRetryPolicies.end()) |
| 631 | { |
| 632 | messages::propertyValueNotInList(asyncResp->res, *retryPolicy, |
| 633 | "DeliveryRetryPolicy"); |
| 634 | return; |
| 635 | } |
| 636 | subValue->retryPolicy = *retryPolicy; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | EventServiceManager::getInstance().updateSubscriptionData(); |
| 640 | }); |
Ravi Teja | 9d41aec | 2021-07-23 01:57:01 -0500 | [diff] [blame] | 641 | BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 642 | // The below privilege is wrong, it should be ConfigureManager OR |
| 643 | // ConfigureSelf |
Abhishek Patel | 7eeafa7 | 2021-07-28 10:59:16 -0500 | [diff] [blame] | 644 | // https://github.com/openbmc/bmcweb/issues/220 |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 645 | //.privileges(redfish::privileges::deleteEventDestination) |
Ed Tanous | 432a890 | 2021-06-14 15:28:56 -0700 | [diff] [blame] | 646 | .privileges({{"ConfigureManager"}}) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 647 | .methods(boost::beast::http::verb::delete_)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 648 | [&app](const crow::Request& req, |
| 649 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 650 | const std::string& param) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 651 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 652 | { |
| 653 | return; |
| 654 | } |
| 655 | if (!EventServiceManager::getInstance().isSubscriptionExist(param)) |
| 656 | { |
| 657 | asyncResp->res.result(boost::beast::http::status::not_found); |
| 658 | return; |
| 659 | } |
| 660 | EventServiceManager::getInstance().deleteSubscription(param); |
| 661 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 662 | } |
AppaRao Puli | e5aaf04 | 2020-03-20 01:05:52 +0530 | [diff] [blame] | 663 | |
| 664 | } // namespace redfish |