Make registries return an object_t
All the registry helper functions should return an object_t, given that
they're guaranteed to return an object. nlohmann::json as a type can
technically be string/int/bool/null/object/array, so it causes some
peculiarities in parsing.
Change-Id: If296477cb8d066d7f44ef0d12f17d94a5301e450
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/redfish-core/src/resource_messages.cpp b/redfish-core/src/resource_messages.cpp
index 55fa8ee..17ef0c4 100644
--- a/redfish-core/src/resource_messages.cpp
+++ b/redfish-core/src/resource_messages.cpp
@@ -31,8 +31,9 @@
namespace messages
{
-static nlohmann::json getLog(redfish::registries::ResourceEvent::Index name,
- std::span<const std::string_view> args)
+static nlohmann::json::object_t getLog(
+ redfish::registries::ResourceEvent::Index name,
+ std::span<const std::string_view> args)
{
size_t index = static_cast<size_t>(name);
if (index >= redfish::registries::ResourceEvent::registry.size())
@@ -51,7 +52,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceCreated()
+nlohmann::json::object_t resourceCreated()
{
return getLog(redfish::registries::ResourceEvent::Index::resourceCreated,
{});
@@ -64,7 +65,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceRemoved()
+nlohmann::json::object_t resourceRemoved()
{
return getLog(redfish::registries::ResourceEvent::Index::resourceRemoved,
{});
@@ -77,8 +78,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceErrorsDetected(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t resourceErrorsDetected(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(
redfish::registries::ResourceEvent::Index::resourceErrorsDetected,
@@ -92,8 +93,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceErrorsCorrected(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t resourceErrorsCorrected(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(
redfish::registries::ResourceEvent::Index::resourceErrorsCorrected,
@@ -107,8 +108,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceErrorThresholdExceeded(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t resourceErrorThresholdExceeded(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(redfish::registries::ResourceEvent::Index::
resourceErrorThresholdExceeded,
@@ -122,8 +123,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceErrorThresholdCleared(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t resourceErrorThresholdCleared(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(redfish::registries::ResourceEvent::Index::
resourceErrorThresholdCleared,
@@ -137,8 +138,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceWarningThresholdExceeded(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t resourceWarningThresholdExceeded(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(redfish::registries::ResourceEvent::Index::
resourceWarningThresholdExceeded,
@@ -152,8 +153,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceWarningThresholdCleared(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t resourceWarningThresholdCleared(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(redfish::registries::ResourceEvent::Index::
resourceWarningThresholdCleared,
@@ -167,8 +168,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceStatusChangedOK(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t resourceStatusChangedOK(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(
redfish::registries::ResourceEvent::Index::resourceStatusChangedOK,
@@ -182,8 +183,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceStatusChangedWarning(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t resourceStatusChangedWarning(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(
redfish::registries::ResourceEvent::Index::resourceStatusChangedWarning,
@@ -197,8 +198,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceStatusChangedCritical(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t resourceStatusChangedCritical(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(redfish::registries::ResourceEvent::Index::
resourceStatusChangedCritical,
@@ -212,8 +213,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceStateChanged(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t resourceStateChanged(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(
redfish::registries::ResourceEvent::Index::resourceStateChanged,
@@ -227,7 +228,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourcePoweredOn(std::string_view arg1)
+nlohmann::json::object_t resourcePoweredOn(std::string_view arg1)
{
return getLog(redfish::registries::ResourceEvent::Index::resourcePoweredOn,
std::to_array({arg1}));
@@ -240,7 +241,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourcePoweringOn(std::string_view arg1)
+nlohmann::json::object_t resourcePoweringOn(std::string_view arg1)
{
return getLog(redfish::registries::ResourceEvent::Index::resourcePoweringOn,
std::to_array({arg1}));
@@ -253,7 +254,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourcePoweredOff(std::string_view arg1)
+nlohmann::json::object_t resourcePoweredOff(std::string_view arg1)
{
return getLog(redfish::registries::ResourceEvent::Index::resourcePoweredOff,
std::to_array({arg1}));
@@ -266,7 +267,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourcePoweringOff(std::string_view arg1)
+nlohmann::json::object_t resourcePoweringOff(std::string_view arg1)
{
return getLog(
redfish::registries::ResourceEvent::Index::resourcePoweringOff,
@@ -280,7 +281,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourcePaused(std::string_view arg1)
+nlohmann::json::object_t resourcePaused(std::string_view arg1)
{
return getLog(redfish::registries::ResourceEvent::Index::resourcePaused,
std::to_array({arg1}));
@@ -293,7 +294,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json uRIForResourceChanged()
+nlohmann::json::object_t uRIForResourceChanged()
{
return getLog(
redfish::registries::ResourceEvent::Index::uRIForResourceChanged, {});
@@ -306,7 +307,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceChanged()
+nlohmann::json::object_t resourceChanged()
{
return getLog(redfish::registries::ResourceEvent::Index::resourceChanged,
{});
@@ -319,7 +320,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceVersionIncompatible(std::string_view arg1)
+nlohmann::json::object_t resourceVersionIncompatible(std::string_view arg1)
{
return getLog(
redfish::registries::ResourceEvent::Index::resourceVersionIncompatible,
@@ -333,7 +334,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceSelfTestFailed(std::string_view arg1)
+nlohmann::json::object_t resourceSelfTestFailed(std::string_view arg1)
{
return getLog(
redfish::registries::ResourceEvent::Index::resourceSelfTestFailed,
@@ -347,7 +348,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceSelfTestCompleted()
+nlohmann::json::object_t resourceSelfTestCompleted()
{
return getLog(
redfish::registries::ResourceEvent::Index::resourceSelfTestCompleted,
@@ -361,7 +362,7 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json testMessage()
+nlohmann::json::object_t testMessage()
{
return getLog(redfish::registries::ResourceEvent::Index::testMessage, {});
}
@@ -373,8 +374,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json aggregationSourceDiscovered(std::string_view arg1,
- std::string_view arg2)
+nlohmann::json::object_t aggregationSourceDiscovered(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(
redfish::registries::ResourceEvent::Index::aggregationSourceDiscovered,
@@ -388,7 +389,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json licenseExpired(std::string_view arg1, std::string_view arg2)
+nlohmann::json::object_t licenseExpired(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(redfish::registries::ResourceEvent::Index::licenseExpired,
std::to_array({arg1, arg2}));
@@ -401,7 +403,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json licenseChanged(std::string_view arg1, std::string_view arg2)
+nlohmann::json::object_t licenseChanged(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(redfish::registries::ResourceEvent::Index::licenseChanged,
std::to_array({arg1, arg2}));
@@ -414,7 +417,8 @@
* See header file for more information
* @endinternal
*/
-nlohmann::json licenseAdded(std::string_view arg1, std::string_view arg2)
+nlohmann::json::object_t licenseAdded(std::string_view arg1,
+ std::string_view arg2)
{
return getLog(redfish::registries::ResourceEvent::Index::licenseAdded,
std::to_array({arg1, arg2}));