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