summaryrefslogtreecommitdiff
path: root/redfish-core/lib/event_service.hpp
diff options
context:
space:
mode:
authorAyushi Smriti <smriti.ayushi@linux.intel.com>2020-05-21 13:25:34 +0300
committerAppaRao Puli <apparao.puli@linux.intel.com>2020-07-02 08:21:01 +0300
commit07941a881d1d07fd8cbe2ac0db88b3c96deab4c7 (patch)
tree422cf6b2e3746deca234d569c1510865831dd5f9 /redfish-core/lib/event_service.hpp
parent4bbf237f4217afd1a0fa8c474a921a9175732b13 (diff)
downloadbmcweb-07941a881d1d07fd8cbe2ac0db88b3c96deab4c7.tar.xz
Support the $filter query params for SSE stream
This commit adds the support for $filter query paramater in the URI for SSE stream. Method: GET URI: /redfish/v1/EventService/Subscriptions/SSE? $filter=(MessageIds%20eq%20DCPowerOn) or (MessageIds%20eq%20DCPowerOn) Tested: - From browser sent request using SSE URI along with filter query param - query params were read and parsed successfully. - used SubmitTestEvent and could see test events coming to BMC. - Ran redfish validator successfully. - Performed GET on Subscription collections and Subscription/<id> URI and checked for valid data. Change-Id: Ie18546749495175ede918ab933ff8dd1d65b775f Signed-off-by: Ayushi Smriti <smriti.ayushi@linux.intel.com> Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
Diffstat (limited to 'redfish-core/lib/event_service.hpp')
-rw-r--r--redfish-core/lib/event_service.hpp58
1 files changed, 54 insertions, 4 deletions
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index adb62389cf..da537bfc1e 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -72,6 +72,14 @@ class EventService : public Node
retryTimeoutInterval;
asyncResp->res.jsonValue["EventFormatTypes"] = supportedEvtFormatTypes;
asyncResp->res.jsonValue["RegistryPrefixes"] = supportedRegPrefixes;
+
+ nlohmann::json supportedSSEFilters = {
+ {"EventFormatType", true}, {"MessageId", true},
+ {"MetricReportDefinition", true}, {"RegistryPrefix", true},
+ {"OriginResource", false}, {"ResourceType", false}};
+
+ asyncResp->res.jsonValue["SSEFilterPropertiesSupported"] =
+ supportedSSEFilters;
}
void doPatch(crow::Response& res, const crow::Request& req,
@@ -432,19 +440,61 @@ class EventServiceSSE : public Node
// GET on this URI means, Its SSE subscriptionType.
subValue->subscriptionType = "SSE";
+
+ // Default values
subValue->protocol = "Redfish";
+ subValue->retryPolicy = "TerminateAfterRetries";
char* filters = req.urlParams.get("$filter");
if (filters == nullptr)
{
subValue->eventFormatType = "Event";
- subValue->retryPolicy = "TerminateAfterRetries";
}
else
{
- // TODO: Need to read this from query params.
- subValue->eventFormatType = "Event";
- subValue->retryPolicy = "TerminateAfterRetries";
+ // Reading from query params.
+ bool status = readSSEQueryParams(
+ filters, subValue->eventFormatType, subValue->registryMsgIds,
+ subValue->registryPrefixes, subValue->metricReportDefinitions);
+
+ if (!status)
+ {
+ messages::invalidObject(res, filters);
+ return;
+ }
+
+ if (!subValue->eventFormatType.empty())
+ {
+ if (std::find(supportedEvtFormatTypes.begin(),
+ supportedEvtFormatTypes.end(),
+ subValue->eventFormatType) ==
+ supportedEvtFormatTypes.end())
+ {
+ messages::propertyValueNotInList(
+ res, subValue->eventFormatType, "EventFormatType");
+ return;
+ }
+ }
+ else
+ {
+ // If nothing specified, using default "Event"
+ subValue->eventFormatType.assign({"Event"});
+ }
+
+ if (!subValue->registryPrefixes.empty())
+ {
+ for (const std::string& it : subValue->registryPrefixes)
+ {
+ if (std::find(supportedRegPrefixes.begin(),
+ supportedRegPrefixes.end(),
+ it) == supportedRegPrefixes.end())
+ {
+ messages::propertyValueNotInList(res, it,
+ "RegistryPrefixes");
+ return;
+ }
+ }
+ }
}
std::string id =