summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-02-08 10:44:31 +0300
committerEd Tanous <ed@tanous.net>2022-02-28 21:48:12 +0300
commit1668ce6d0d427088b7bb8ab7c2927763fb57c8c3 (patch)
tree97bcd7431ab3cb882edfe2378814c84d84d29526
parentb6cd31e162b25779a68344d3c0bde7c6cfb1af7f (diff)
downloadbmcweb-1668ce6d0d427088b7bb8ab7c2927763fb57c8c3.tar.xz
Move error messages to string_view
using std::string_view on these lets us call them in more contexts, and allows us to inline some previously more complex code. In general, for APIs like this, std::string_view should be preferred as it gives more flexibility in calling conventions. Tested: curl --insecure "https://localhost:18080/redfish/v1/AccountService/Roles/foobar" ✔ { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type Role named 'foobar' was not found.", "MessageArgs": [ "Role", "foobar" ], "MessageId": "Base.1.11.0.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.11.0.ResourceNotFound", "message": "The requested resource of type Role named 'foobar' was not found." } } This is the same response as previously. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8ee17120c42d2a13677648c3395aa4f9ec2bd51a
-rw-r--r--redfish-core/include/error_messages.hpp233
-rw-r--r--redfish-core/lib/managers.hpp7
-rw-r--r--redfish-core/lib/metric_report_definition.hpp5
-rw-r--r--redfish-core/src/error_messages.cpp394
4 files changed, 303 insertions, 336 deletions
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index 9658f0bb1a..5e4fb5d3dd 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -75,14 +75,13 @@ void resourceMissingAtURI(crow::Response& res,
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message ActionParameterValueFormatError formatted to JSON */
-nlohmann::json actionParameterValueFormatError(const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3);
+nlohmann::json actionParameterValueFormatError(std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3);
-void actionParameterValueFormatError(crow::Response& res,
- const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3);
+void actionParameterValueFormatError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3);
/**
* @brief Formats InternalError message into JSON
@@ -117,11 +116,11 @@ void unrecognizedRequestBody(crow::Response& res);
*
* @returns Message ResourceAtUriUnauthorized formatted to JSON */
nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1,
- const std::string& arg2);
+ std::string_view arg2);
void resourceAtUriUnauthorized(crow::Response& res,
const boost::urls::url_view& arg1,
- const std::string& arg2);
+ std::string_view arg2);
/**
* @brief Formats ActionParameterUnknown message into JSON
@@ -132,11 +131,11 @@ void resourceAtUriUnauthorized(crow::Response& res,
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message ActionParameterUnknown formatted to JSON */
-nlohmann::json actionParameterUnknown(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json actionParameterUnknown(std::string_view arg1,
+ std::string_view arg2);
-void actionParameterUnknown(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void actionParameterUnknown(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats ResourceCannotBeDeleted message into JSON
@@ -156,9 +155,9 @@ void resourceCannotBeDeleted(crow::Response& res);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message PropertyDuplicate formatted to JSON */
-nlohmann::json propertyDuplicate(const std::string& arg1);
+nlohmann::json propertyDuplicate(std::string_view arg1);
-void propertyDuplicate(crow::Response& res, const std::string& arg1);
+void propertyDuplicate(crow::Response& res, std::string_view arg1);
/**
* @brief Formats ServiceTemporarilyUnavailable message into JSON
@@ -168,10 +167,9 @@ void propertyDuplicate(crow::Response& res, const std::string& arg1);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message ServiceTemporarilyUnavailable formatted to JSON */
-nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1);
+nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1);
-void serviceTemporarilyUnavailable(crow::Response& res,
- const std::string& arg1);
+void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1);
/**
* @brief Formats ResourceAlreadyExists message into JSON
@@ -183,12 +181,12 @@ void serviceTemporarilyUnavailable(crow::Response& res,
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message ResourceAlreadyExists formatted to JSON */
-nlohmann::json resourceAlreadyExists(const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3);
+nlohmann::json resourceAlreadyExists(std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3);
-void resourceAlreadyExists(crow::Response& res, const std::string& arg1,
- const std::string& arg2, const std::string& arg3);
+void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
+ std::string_view arg2, std::string_view arg3);
/**
* @brief Formats AccountForSessionNoLongerExists message into JSON
@@ -209,10 +207,10 @@ void accountForSessionNoLongerExists(crow::Response& res);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message CreateFailedMissingReqProperties formatted to JSON */
-nlohmann::json createFailedMissingReqProperties(const std::string& arg1);
+nlohmann::json createFailedMissingReqProperties(std::string_view arg1);
void createFailedMissingReqProperties(crow::Response& res,
- const std::string& arg1);
+ std::string_view arg1);
/**
* @brief Formats PropertyValueFormatError message into JSON
@@ -223,11 +221,11 @@ void createFailedMissingReqProperties(crow::Response& res,
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message PropertyValueFormatError formatted to JSON */
-nlohmann::json propertyValueFormatError(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json propertyValueFormatError(std::string_view arg1,
+ std::string_view arg2);
-void propertyValueFormatError(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void propertyValueFormatError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats PropertyValueNotInList message into JSON
@@ -238,11 +236,11 @@ void propertyValueFormatError(crow::Response& res, const std::string& arg1,
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message PropertyValueNotInList formatted to JSON */
-nlohmann::json propertyValueNotInList(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json propertyValueNotInList(std::string_view arg1,
+ std::string_view arg2);
-void propertyValueNotInList(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void propertyValueNotInList(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats ResourceAtUriInUnknownFormat message into JSON
@@ -265,9 +263,9 @@ void resourceAtUriInUnknownFormat(crow::Response& res,
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message ServiceDisabled formatted to JSON */
-nlohmann::json serviceDisabled(const std::string& arg1);
+nlohmann::json serviceDisabled(std::string_view arg1);
-void serviceDisabled(crow::Response& res, const std::string& arg1);
+void serviceDisabled(crow::Response& res, std::string_view arg1);
/**
* @brief Formats ServiceInUnknownState message into JSON
@@ -300,11 +298,11 @@ void eventSubscriptionLimitExceeded(crow::Response& res);
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message ActionParameterMissing formatted to JSON */
-nlohmann::json actionParameterMissing(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json actionParameterMissing(std::string_view arg1,
+ std::string_view arg2);
-void actionParameterMissing(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void actionParameterMissing(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats StringValueTooLong message into JSON
@@ -314,9 +312,9 @@ void actionParameterMissing(crow::Response& res, const std::string& arg1,
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message StringValueTooLong formatted to JSON */
-nlohmann::json stringValueTooLong(const std::string& arg1, int arg2);
+nlohmann::json stringValueTooLong(std::string_view arg1, int arg2);
-void stringValueTooLong(crow::Response& res, const std::string& arg1, int arg2);
+void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2);
/**
* @brief Formats SessionTerminated message into JSON
@@ -347,11 +345,11 @@ void subscriptionTerminated(crow::Response& res);
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message ResourceTypeIncompatible formatted to JSON */
-nlohmann::json resourceTypeIncompatible(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json resourceTypeIncompatible(std::string_view arg1,
+ std::string_view arg2);
-void resourceTypeIncompatible(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats ResetRequired message into JSON
@@ -363,10 +361,10 @@ void resourceTypeIncompatible(crow::Response& res, const std::string& arg1,
*
* @returns Message ResetRequired formatted to JSON */
nlohmann::json resetRequired(const boost::urls::url_view& arg1,
- const std::string& arg2);
+ std::string_view arg2);
void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
- const std::string& arg2);
+ std::string_view arg2);
/**
* @brief Formats ChassisPowerStateOnRequired message into JSON
@@ -376,9 +374,9 @@ void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message ChassisPowerStateOnRequired formatted to JSON */
-nlohmann::json chassisPowerStateOnRequired(const std::string& arg1);
+nlohmann::json chassisPowerStateOnRequired(std::string_view arg1);
-void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1);
+void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1);
/**
* @brief Formats ChassisPowerStateOffRequired message into JSON
@@ -388,9 +386,9 @@ void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message ChassisPowerStateOffRequired formatted to JSON */
-nlohmann::json chassisPowerStateOffRequired(const std::string& arg1);
+nlohmann::json chassisPowerStateOffRequired(std::string_view arg1);
-void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1);
+void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1);
/**
* @brief Formats PropertyValueConflict message into JSON
@@ -401,11 +399,11 @@ void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1);
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message PropertyValueConflict formatted to JSON */
-nlohmann::json propertyValueConflict(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json propertyValueConflict(std::string_view arg1,
+ std::string_view arg2);
-void propertyValueConflict(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void propertyValueConflict(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats PropertyValueIncorrect message into JSON
@@ -417,11 +415,11 @@ void propertyValueConflict(crow::Response& res, const std::string& arg1,
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message PropertyValueIncorrect formatted to JSON */
-nlohmann::json propertyValueIncorrect(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json propertyValueIncorrect(std::string_view arg1,
+ std::string_view arg2);
-void propertyValueIncorrect(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats ResourceCreationConflict message into JSON
@@ -431,10 +429,9 @@ void propertyValueIncorrect(crow::Response& res, const std::string& arg1,
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message ResourceCreationConflict formatted to JSON */
-nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1);
+nlohmann::json resourceCreationConflict(std::string_view arg1);
-void resourceCreationConflict(crow::Response& res,
- const boost::urls::url_view& arg1);
+void resourceCreationConflict(crow::Response& res, std::string_view arg1);
/**
* @brief Formats MaximumErrorsExceeded message into JSON
@@ -499,11 +496,11 @@ void operationTimeout(crow::Response& res);
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message PropertyValueTypeError formatted to JSON */
-nlohmann::json propertyValueTypeError(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json propertyValueTypeError(std::string_view arg1,
+ std::string_view arg2);
-void propertyValueTypeError(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void propertyValueTypeError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats ResourceNotFound message into JSON
@@ -514,11 +511,10 @@ void propertyValueTypeError(crow::Response& res, const std::string& arg1,
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message ResourceNotFound formatted to JSON */
-nlohmann::json resourceNotFound(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2);
-void resourceNotFound(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void resourceNotFound(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats CouldNotEstablishConnection message into JSON
@@ -541,9 +537,9 @@ void couldNotEstablishConnection(crow::Response& res,
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message PropertyNotWritable formatted to JSON */
-nlohmann::json propertyNotWritable(const std::string& arg1);
+nlohmann::json propertyNotWritable(std::string_view arg1);
-void propertyNotWritable(crow::Response& res, const std::string& arg1);
+void propertyNotWritable(crow::Response& res, std::string_view arg1);
/**
* @brief Formats QueryParameterValueTypeError message into JSON
@@ -554,11 +550,11 @@ void propertyNotWritable(crow::Response& res, const std::string& arg1);
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message QueryParameterValueTypeError formatted to JSON */
-nlohmann::json queryParameterValueTypeError(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json queryParameterValueTypeError(std::string_view arg1,
+ std::string_view arg2);
-void queryParameterValueTypeError(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats ServiceShuttingDown message into JSON
@@ -580,11 +576,11 @@ void serviceShuttingDown(crow::Response& res);
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message ActionParameterDuplicate formatted to JSON */
-nlohmann::json actionParameterDuplicate(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json actionParameterDuplicate(std::string_view arg1,
+ std::string_view arg2);
-void actionParameterDuplicate(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats ActionParameterNotSupported message into JSON
@@ -595,11 +591,11 @@ void actionParameterDuplicate(crow::Response& res, const std::string& arg1,
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message ActionParameterNotSupported formatted to JSON */
-nlohmann::json actionParameterNotSupported(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json actionParameterNotSupported(std::string_view arg1,
+ std::string_view arg2);
-void actionParameterNotSupported(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats SourceDoesNotSupportProtocol message into JSON
@@ -611,11 +607,11 @@ void actionParameterNotSupported(crow::Response& res, const std::string& arg1,
*
* @returns Message SourceDoesNotSupportProtocol formatted to JSON */
nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1,
- const std::string& arg2);
+ std::string_view arg2);
void sourceDoesNotSupportProtocol(crow::Response& res,
const boost::urls::url_view& arg1,
- const std::string& arg2);
+ std::string_view arg2);
/**
* @brief Formats AccountRemoved message into JSON
@@ -635,9 +631,9 @@ void accountRemoved(crow::Response& res);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message AccessDenied formatted to JSON */
-nlohmann::json accessDenied(const boost::urls::url_view& arg1);
+nlohmann::json accessDenied(std::string_view arg1);
-void accessDenied(crow::Response& res, const boost::urls::url_view& arg1);
+void accessDenied(crow::Response& res, std::string_view arg1);
/**
* @brief Formats QueryNotSupported message into JSON
@@ -710,9 +706,9 @@ void noOperation(crow::Response& res);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message PropertyUnknown formatted to JSON */
-nlohmann::json propertyUnknown(const std::string& arg1);
+nlohmann::json propertyUnknown(std::string_view arg1);
-void propertyUnknown(crow::Response& res, const std::string& arg1);
+void propertyUnknown(crow::Response& res, std::string_view arg1);
/**
* @brief Formats NoValidSession message into JSON
@@ -757,13 +753,13 @@ void resourceInStandby(crow::Response& res);
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message ActionParameterValueTypeError formatted to JSON */
-nlohmann::json actionParameterValueTypeError(const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3);
+nlohmann::json actionParameterValueTypeError(std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3);
-void actionParameterValueTypeError(crow::Response& res, const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3);
+void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3);
/**
* @brief Formats SessionLimitExceeded message into JSON
@@ -783,9 +779,9 @@ void sessionLimitExceeded(crow::Response& res);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message ActionNotSupported formatted to JSON */
-nlohmann::json actionNotSupported(const std::string& arg1);
+nlohmann::json actionNotSupported(std::string_view arg1);
-void actionNotSupported(crow::Response& res, const std::string& arg1);
+void actionNotSupported(crow::Response& res, std::string_view arg1);
/**
* @brief Formats InvalidIndex message into JSON
@@ -861,11 +857,11 @@ void insufficientPrivilege(crow::Response& res);
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message PropertyValueModified formatted to JSON */
-nlohmann::json propertyValueModified(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json propertyValueModified(std::string_view arg1,
+ std::string_view arg2);
-void propertyValueModified(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void propertyValueModified(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats AccountNotModified message into JSON
@@ -887,12 +883,11 @@ void accountNotModified(crow::Response& res);
*
* @returns Message QueryParameterValueFormatError formatted to JSON */
-nlohmann::json queryParameterValueFormatError(const std::string& arg1,
- const std::string& arg2);
+nlohmann::json queryParameterValueFormatError(std::string_view arg1,
+ std::string_view arg2);
-void queryParameterValueFormatError(crow::Response& res,
- const std::string& arg1,
- const std::string& arg2);
+void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
/**
* @brief Formats PropertyMissing message into JSON
@@ -902,9 +897,9 @@ void queryParameterValueFormatError(crow::Response& res,
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message PropertyMissing formatted to JSON */
-nlohmann::json propertyMissing(const std::string& arg1);
+nlohmann::json propertyMissing(std::string_view arg1);
-void propertyMissing(crow::Response& res, const std::string& arg1);
+void propertyMissing(crow::Response& res, std::string_view arg1);
/**
* @brief Formats ResourceExhaustion message into JSON
@@ -914,9 +909,9 @@ void propertyMissing(crow::Response& res, const std::string& arg1);
* @param[in] arg1 Parameter of message that will replace %1 in its body.
*
* @returns Message ResourceExhaustion formatted to JSON */
-nlohmann::json resourceExhaustion(const std::string& arg1);
+nlohmann::json resourceExhaustion(std::string_view arg1);
-void resourceExhaustion(crow::Response& res, const std::string& arg1);
+void resourceExhaustion(crow::Response& res, std::string_view arg1);
/**
* @brief Formats AccountModified message into JSON
@@ -938,12 +933,12 @@ void accountModified(crow::Response& res);
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message QueryParameterOutOfRange formatted to JSON */
-nlohmann::json queryParameterOutOfRange(const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3);
+nlohmann::json queryParameterOutOfRange(std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3);
-void queryParameterOutOfRange(crow::Response& res, const std::string& arg1,
- const std::string& arg2, const std::string& arg3);
+void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
+ std::string_view arg2, std::string_view arg3);
/**
* @brief Formats PasswordChangeRequired message into JSON
@@ -967,10 +962,10 @@ void passwordChangeRequired(crow::Response& res,
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message InvalidUpload formatted to JSON */
-nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2);
+nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2);
-void invalidUpload(crow::Response& res, const std::string& arg1,
- const std::string& arg2);
+void invalidUpload(crow::Response& res, std::string_view arg1,
+ std::string_view arg2);
} // namespace messages
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index a5e8c23456..acaa40ac2c 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -682,8 +682,7 @@ inline bool
if (config.empty())
{
BMCWEB_LOG_ERROR << "Empty Zones";
- messages::propertyValueFormatError(response->res,
- nlohmann::json::array(), "Zones");
+ messages::propertyValueFormatError(response->res, "[]", "Zones");
return false;
}
for (auto& odata : config)
@@ -1601,8 +1600,8 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
if (createNewObject && it.value() == nullptr)
{
// can't delete a non-existent object
- messages::propertyValueNotInList(response->res, it.value(),
- name);
+ messages::propertyValueNotInList(response->res,
+ it.value().dump(), name);
continue;
}
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index 4e9d78a148..ab7c88ba4d 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -316,8 +316,9 @@ class AddReport
{
metricProperties.emplace_back(uri);
}
- messages::propertyValueIncorrect(
- aResp->res, metricProperties, "MetricProperties");
+ messages::propertyValueIncorrect(aResp->res,
+ metricProperties.dump(),
+ "MetricProperties");
return;
}
if (ec)
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index fafbf211d6..1897f2977b 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -22,6 +22,8 @@
#include <logging.hpp>
#include <nlohmann/json.hpp>
+#include <array>
+
namespace redfish
{
@@ -89,18 +91,20 @@ static void addMessageToJsonRoot(nlohmann::json& target,
static void addMessageToJson(nlohmann::json& target,
const nlohmann::json& message,
- const std::string& fieldPath)
+ std::string_view fieldPath)
{
- std::string extendedInfo(fieldPath + messages::messageAnnotation);
+ std::string extendedInfo(fieldPath);
+ extendedInfo += messages::messageAnnotation;
- if (!target[extendedInfo].is_array())
+ nlohmann::json& field = target[extendedInfo];
+ if (!field.is_array())
{
// Force object to be an array
- target[extendedInfo] = nlohmann::json::array();
+ field = nlohmann::json::array();
}
// Object exists and it is an array so we can just push in the message
- target[extendedInfo].push_back(message);
+ field.push_back(message);
}
nlohmann::json getLog(redfish::message_registries::base::Index name,
@@ -198,20 +202,18 @@ void resourceMissingAtURI(crow::Response& res,
* See header file for more information
* @endinternal
*/
-nlohmann::json actionParameterValueFormatError(const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3)
+nlohmann::json actionParameterValueFormatError(std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3)
{
- std::array<std::string_view, 3> args{arg1, arg2, arg3};
return getLog(redfish::message_registries::base::Index::
actionParameterValueFormatError,
- args);
+ std::to_array({arg1, arg2, arg3}));
}
-void actionParameterValueFormatError(crow::Response& res,
- const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3)
+void actionParameterValueFormatError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue,
@@ -266,18 +268,16 @@ void unrecognizedRequestBody(crow::Response& res)
* @endinternal
*/
nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1,
- const std::string& arg2)
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{
- std::string_view{arg1.data(), arg1.size()}, arg2};
return getLog(
redfish::message_registries::base::Index::resourceAtUriUnauthorized,
- args);
+ std::to_array({std::string_view{arg1.data(), arg1.size()}, arg2}));
}
void resourceAtUriUnauthorized(crow::Response& res,
const boost::urls::url_view& arg1,
- const std::string& arg2)
+ std::string_view arg2)
{
res.result(boost::beast::http::status::unauthorized);
addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
@@ -290,16 +290,16 @@ void resourceAtUriUnauthorized(crow::Response& res,
* See header file for more information
* @endinternal
*/
-nlohmann::json actionParameterUnknown(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json actionParameterUnknown(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 3> args{arg1, arg2};
return getLog(
- redfish::message_registries::base::Index::actionParameterUnknown, args);
+ redfish::message_registries::base::Index::actionParameterUnknown,
+ std::to_array({arg1, arg2}));
}
-void actionParameterUnknown(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void actionParameterUnknown(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
@@ -331,14 +331,13 @@ void resourceCannotBeDeleted(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyDuplicate(const std::string& arg1)
+nlohmann::json propertyDuplicate(std::string_view arg1)
{
- std::array<std::string_view, 1> args{arg1};
return getLog(redfish::message_registries::base::Index::propertyDuplicate,
- args);
+ std::to_array({arg1}));
}
-void propertyDuplicate(crow::Response& res, const std::string& arg1)
+void propertyDuplicate(crow::Response& res, std::string_view arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
@@ -351,15 +350,14 @@ void propertyDuplicate(crow::Response& res, const std::string& arg1)
* See header file for more information
* @endinternal
*/
-nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1)
+nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
{
- std::array<std::string_view, 1> args{arg1};
return getLog(
redfish::message_registries::base::Index::serviceTemporarilyUnavailable,
- args);
+ std::to_array({arg1}));
}
-void serviceTemporarilyUnavailable(crow::Response& res, const std::string& arg1)
+void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
{
res.addHeader("Retry-After", arg1);
res.result(boost::beast::http::status::service_unavailable);
@@ -373,17 +371,17 @@ void serviceTemporarilyUnavailable(crow::Response& res, const std::string& arg1)
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceAlreadyExists(const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3)
+nlohmann::json resourceAlreadyExists(std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3)
{
- std::array<std::string_view, 3> args{arg1, arg2, arg3};
return getLog(
- redfish::message_registries::base::Index::resourceAlreadyExists, args);
+ redfish::message_registries::base::Index::resourceAlreadyExists,
+ std::to_array({arg1, arg2, arg3}));
}
-void resourceAlreadyExists(crow::Response& res, const std::string& arg1,
- const std::string& arg2, const std::string& arg3)
+void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
+ std::string_view arg2, std::string_view arg3)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
@@ -417,16 +415,15 @@ void accountForSessionNoLongerExists(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json createFailedMissingReqProperties(const std::string& arg1)
+nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
{
- std::array<std::string_view, 2> args{arg1};
return getLog(redfish::message_registries::base::Index::
createFailedMissingReqProperties,
- args);
+ std::to_array({arg1}));
}
void createFailedMissingReqProperties(crow::Response& res,
- const std::string& arg1)
+ std::string_view arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
@@ -441,17 +438,16 @@ void createFailedMissingReqProperties(crow::Response& res,
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyValueFormatError(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json propertyValueFormatError(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
redfish::message_registries::base::Index::propertyValueFormatError,
- args);
+ std::to_array({arg1, arg2}));
}
-void propertyValueFormatError(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void propertyValueFormatError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
@@ -465,16 +461,16 @@ void propertyValueFormatError(crow::Response& res, const std::string& arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyValueNotInList(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json propertyValueNotInList(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
- redfish::message_registries::base::Index::propertyValueNotInList, args);
+ redfish::message_registries::base::Index::propertyValueNotInList,
+ std::to_array({arg1, arg2}));
}
-void propertyValueNotInList(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void propertyValueNotInList(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
@@ -489,11 +485,10 @@ void propertyValueNotInList(crow::Response& res, const std::string& arg1,
*/
nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1)
{
- std::array<std::string_view, 1> args{
- std::string_view{arg1.data(), arg1.size()}};
+ std::string_view arg1str{arg1.data(), arg1.size()};
return getLog(
redfish::message_registries::base::Index::resourceAtUriInUnknownFormat,
- args);
+ std::to_array({arg1str}));
}
void resourceAtUriInUnknownFormat(crow::Response& res,
@@ -510,14 +505,13 @@ void resourceAtUriInUnknownFormat(crow::Response& res,
* See header file for more information
* @endinternal
*/
-nlohmann::json serviceDisabled(const std::string& arg1)
+nlohmann::json serviceDisabled(std::string_view arg1)
{
- std::array<std::string_view, 1> args{arg1};
return getLog(redfish::message_registries::base::Index::serviceDisabled,
- args);
+ std::to_array({arg1}));
}
-void serviceDisabled(crow::Response& res, const std::string& arg1)
+void serviceDisabled(crow::Response& res, std::string_view arg1)
{
res.result(boost::beast::http::status::service_unavailable);
addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
@@ -569,16 +563,16 @@ void eventSubscriptionLimitExceeded(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json actionParameterMissing(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json actionParameterMissing(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
- redfish::message_registries::base::Index::actionParameterMissing, args);
+ redfish::message_registries::base::Index::actionParameterMissing,
+ std::to_array({arg1, arg2}));
}
-void actionParameterMissing(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void actionParameterMissing(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
@@ -591,15 +585,14 @@ void actionParameterMissing(crow::Response& res, const std::string& arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json stringValueTooLong(const std::string& arg1, int arg2)
+nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
{
std::string arg2String = std::to_string(arg2);
- std::array<std::string_view, 2> args{arg1, arg2String};
return getLog(redfish::message_registries::base::Index::stringValueTooLong,
- args);
+ std::to_array({arg1, std::string_view(arg2String)}));
}
-void stringValueTooLong(crow::Response& res, const std::string& arg1, int arg2)
+void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
@@ -650,17 +643,16 @@ void subscriptionTerminated(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceTypeIncompatible(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json resourceTypeIncompatible(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
redfish::message_registries::base::Index::resourceTypeIncompatible,
- args);
+ std::to_array({arg1, arg2}));
}
-void resourceTypeIncompatible(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
@@ -674,16 +666,15 @@ void resourceTypeIncompatible(crow::Response& res, const std::string& arg1,
* @endinternal
*/
nlohmann::json resetRequired(const boost::urls::url_view& arg1,
- const std::string& arg2)
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{
- std::string_view(arg1.data(), arg1.size()), arg2};
+ std::string_view arg1str(arg1.data(), arg1.size());
return getLog(redfish::message_registries::base::Index::resetRequired,
- args);
+ std::to_array({arg1str, arg2}));
}
void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
- const std::string& arg2)
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
@@ -696,14 +687,13 @@ void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json chassisPowerStateOnRequired(const std::string& arg1)
+nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
{
- std::array<std::string_view, 1> args{arg1};
return getLog(redfish::message_registries::base::Index::resetRequired,
- args);
+ std::to_array({arg1}));
}
-void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1)
+void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
@@ -716,15 +706,14 @@ void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1)
* See header file for more information
* @endinternal
*/
-nlohmann::json chassisPowerStateOffRequired(const std::string& arg1)
+nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
{
- std::array<std::string_view, 1> args{arg1};
return getLog(
redfish::message_registries::base::Index::chassisPowerStateOffRequired,
- args);
+ std::to_array({arg1}));
}
-void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1)
+void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
@@ -737,16 +726,16 @@ void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1)
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyValueConflict(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json propertyValueConflict(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
- redfish::message_registries::base::Index::propertyValueConflict, args);
+ redfish::message_registries::base::Index::propertyValueConflict,
+ std::to_array({arg1, arg2}));
}
-void propertyValueConflict(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void propertyValueConflict(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
@@ -759,16 +748,16 @@ void propertyValueConflict(crow::Response& res, const std::string& arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyValueIncorrect(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json propertyValueIncorrect(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
- redfish::message_registries::base::Index::propertyValueIncorrect, args);
+ redfish::message_registries::base::Index::propertyValueIncorrect,
+ std::to_array({arg1, arg2}));
}
-void propertyValueIncorrect(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
@@ -783,12 +772,10 @@ void propertyValueIncorrect(crow::Response& res, const std::string& arg1,
*/
nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1)
{
-
- std::array<std::string_view, 1> args{
- std::string_view(arg1.data(), arg1.size())};
+ std::string_view arg1str(arg1.data(), arg1.size());
return getLog(
redfish::message_registries::base::Index::resourceCreationConflict,
- args);
+ std::to_array({arg1str}));
}
void resourceCreationConflict(crow::Response& res,
@@ -901,16 +888,16 @@ void operationTimeout(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyValueTypeError(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json propertyValueTypeError(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
- redfish::message_registries::base::Index::propertyValueTypeError, args);
+ redfish::message_registries::base::Index::propertyValueTypeError,
+ std::to_array({arg1, arg2}));
}
-void propertyValueTypeError(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void propertyValueTypeError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
@@ -923,16 +910,14 @@ void propertyValueTypeError(crow::Response& res, const std::string& arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceNotFound(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(redfish::message_registries::base::Index::resourceNotFound,
- args);
+ std::to_array({arg1, arg2}));
}
-void resourceNotFound(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void resourceNotFound(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::not_found);
addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
@@ -947,12 +932,10 @@ void resourceNotFound(crow::Response& res, const std::string& arg1,
*/
nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1)
{
-
- std::array<std::string_view, 1> args{
- std::string_view(arg1.data(), arg1.size())};
+ std::string_view arg1str(arg1.data(), arg1.size());
return getLog(
redfish::message_registries::base::Index::couldNotEstablishConnection,
- args);
+ std::to_array({arg1str}));
}
void couldNotEstablishConnection(crow::Response& res,
@@ -970,14 +953,13 @@ void couldNotEstablishConnection(crow::Response& res,
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyNotWritable(const std::string& arg1)
+nlohmann::json propertyNotWritable(std::string_view arg1)
{
- std::array<std::string_view, 1> args{arg1};
return getLog(redfish::message_registries::base::Index::propertyNotWritable,
- args);
+ std::to_array({arg1}));
}
-void propertyNotWritable(crow::Response& res, const std::string& arg1)
+void propertyNotWritable(crow::Response& res, std::string_view arg1)
{
res.result(boost::beast::http::status::forbidden);
addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
@@ -990,17 +972,16 @@ void propertyNotWritable(crow::Response& res, const std::string& arg1)
* See header file for more information
* @endinternal
*/
-nlohmann::json queryParameterValueTypeError(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json queryParameterValueTypeError(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
redfish::message_registries::base::Index::queryParameterValueTypeError,
- args);
+ std::to_array({arg1, arg2}));
}
-void queryParameterValueTypeError(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue,
@@ -1033,17 +1014,16 @@ void serviceShuttingDown(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json actionParameterDuplicate(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json actionParameterDuplicate(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
redfish::message_registries::base::Index::actionParameterDuplicate,
- args);
+ std::to_array({arg1, arg2}));
}
-void actionParameterDuplicate(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
@@ -1056,17 +1036,16 @@ void actionParameterDuplicate(crow::Response& res, const std::string& arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json actionParameterNotSupported(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json actionParameterNotSupported(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
redfish::message_registries::base::Index::actionParameterNotSupported,
- args);
+ std::to_array({arg1, arg2}));
}
-void actionParameterNotSupported(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue,
@@ -1081,18 +1060,17 @@ void actionParameterNotSupported(crow::Response& res, const std::string& arg1,
* @endinternal
*/
nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1,
- const std::string& arg2)
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{
- std::string_view(arg1.data(), arg1.size()), arg2};
+ std::string_view arg1str(arg1.data(), arg1.size());
return getLog(
redfish::message_registries::base::Index::sourceDoesNotSupportProtocol,
- args);
+ std::to_array({arg1str, arg2}));
}
void sourceDoesNotSupportProtocol(crow::Response& res,
const boost::urls::url_view& arg1,
- const std::string& arg2)
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue,
@@ -1126,9 +1104,9 @@ void accountRemoved(crow::Response& res)
*/
nlohmann::json accessDenied(const boost::urls::url_view& arg1)
{
- std::array<std::string_view, 1> args{
- std::string_view(arg1.data(), arg1.size())};
- return getLog(redfish::message_registries::base::Index::accessDenied, args);
+ std::string_view arg1str(arg1.data(), arg1.size());
+ return getLog(redfish::message_registries::base::Index::accessDenied,
+ std::to_array({arg1str}));
}
void accessDenied(crow::Response& res, const boost::urls::url_view& arg1)
@@ -1257,14 +1235,13 @@ void noOperation(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyUnknown(const std::string& arg1)
+nlohmann::json propertyUnknown(std::string_view arg1)
{
- std::array<std::string_view, 1> args{arg1};
return getLog(redfish::message_registries::base::Index::propertyUnknown,
- args);
+ std::to_array({arg1}));
}
-void propertyUnknown(crow::Response& res, const std::string& arg1)
+void propertyUnknown(crow::Response& res, std::string_view arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1);
@@ -1297,10 +1274,9 @@ void noValidSession(crow::Response& res)
*/
nlohmann::json invalidObject(const boost::urls::url_view& arg1)
{
- std::array<std::string_view, 1> args{
- std::string_view(arg1.data(), arg1.size())};
+ std::string_view arg1str(arg1.data(), arg1.size());
return getLog(redfish::message_registries::base::Index::invalidObject,
- args);
+ std::to_array({arg1str}));
}
void invalidObject(crow::Response& res, const boost::urls::url_view& arg1)
@@ -1335,19 +1311,17 @@ void resourceInStandby(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json actionParameterValueTypeError(const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3)
+nlohmann::json actionParameterValueTypeError(std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3)
{
- std::array<std::string_view, 3> args{arg1, arg2, arg3};
return getLog(
redfish::message_registries::base::Index::actionParameterValueTypeError,
- args);
+ std::to_array({arg1, arg2, arg3}));
}
-void actionParameterValueTypeError(crow::Response& res, const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3)
+void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2, std::string_view arg3)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue,
@@ -1380,14 +1354,13 @@ void sessionLimitExceeded(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json actionNotSupported(const std::string& arg1)
+nlohmann::json actionNotSupported(std::string_view arg1)
{
- std::array<std::string_view, 1> args{arg1};
return getLog(redfish::message_registries::base::Index::actionNotSupported,
- args);
+ std::to_array({arg1}));
}
-void actionNotSupported(crow::Response& res, const std::string& arg1)
+void actionNotSupported(crow::Response& res, std::string_view arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
@@ -1403,8 +1376,8 @@ void actionNotSupported(crow::Response& res, const std::string& arg1)
nlohmann::json invalidIndex(int64_t arg1)
{
std::string arg1Str = std::to_string(arg1);
- std::array<std::string_view, 1> args{arg1Str};
- return getLog(redfish::message_registries::base::Index::invalidIndex, args);
+ return getLog(redfish::message_registries::base::Index::invalidIndex,
+ std::to_array<std::string_view>({arg1Str}));
}
void invalidIndex(crow::Response& res, int64_t arg1)
@@ -1516,16 +1489,16 @@ void insufficientPrivilege(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyValueModified(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json propertyValueModified(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(
- redfish::message_registries::base::Index::propertyValueModified, args);
+ redfish::message_registries::base::Index::propertyValueModified,
+ std::to_array({arg1, arg2}));
}
-void propertyValueModified(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void propertyValueModified(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::ok);
addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
@@ -1557,18 +1530,16 @@ void accountNotModified(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json queryParameterValueFormatError(const std::string& arg1,
- const std::string& arg2)
+nlohmann::json queryParameterValueFormatError(std::string_view arg1,
+ std::string_view arg2)
{
- std::array<std::string_view, 2> args{arg1, arg2};
return getLog(redfish::message_registries::base::Index::
queryParameterValueFormatError,
- args);
+ std::to_array({arg1, arg2}));
}
-void queryParameterValueFormatError(crow::Response& res,
- const std::string& arg1,
- const std::string& arg2)
+void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue,
@@ -1583,14 +1554,13 @@ void queryParameterValueFormatError(crow::Response& res,
* See header file for more information
* @endinternal
*/
-nlohmann::json propertyMissing(const std::string& arg1)
+nlohmann::json propertyMissing(std::string_view arg1)
{
- std::array<std::string_view, 1> args{arg1};
return getLog(redfish::message_registries::base::Index::propertyMissing,
- args);
+ std::to_array({arg1}));
}
-void propertyMissing(crow::Response& res, const std::string& arg1)
+void propertyMissing(crow::Response& res, std::string_view arg1)
{
res.result(boost::beast::http::status::bad_request);
addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
@@ -1603,14 +1573,13 @@ void propertyMissing(crow::Response& res, const std::string& arg1)
* See header file for more information
* @endinternal
*/
-nlohmann::json resourceExhaustion(const std::string& arg1)
+nlohmann::json resourceExhaustion(std::string_view arg1)
{
- std::array<std::string_view, 1> args{arg1};
return getLog(redfish::message_registries::base::Index::resourceExhaustion,
- args);
+ std::to_array({arg1}));
}
-void resourceExhaustion(crow::Response& res, const std::string& arg1)
+void resourceExhaustion(crow::Response& res, std::string_view arg1)
{
res.result(boost::beast::http::status::service_unavailable);
addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
@@ -1642,18 +1611,17 @@ void accountModified(crow::Response& res)
* See header file for more information
* @endinternal
*/
-nlohmann::json queryParameterOutOfRange(const std::string& arg1,
- const std::string& arg2,
- const std::string& arg3)
+nlohmann::json queryParameterOutOfRange(std::string_view arg1,
+ std::string_view arg2,
+ std::string_view arg3)
{
- std::array<std::string_view, 3> args{arg1, arg2, arg3};
return getLog(
redfish::message_registries::base::Index::queryParameterOutOfRange,
- args);
+ std::to_array({arg1, arg2, arg3}));
}
-void queryParameterOutOfRange(crow::Response& res, const std::string& arg1,
- const std::string& arg2, const std::string& arg3)
+void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
+ std::string_view arg2, std::string_view arg3)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue,
@@ -1662,11 +1630,10 @@ void queryParameterOutOfRange(crow::Response& res, const std::string& arg1,
nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1)
{
- std::array<std::string_view, 1> args{
- std::string_view(arg1.data(), arg1.size())};
-
+ std::string_view arg1str(arg1.data(), arg1.size());
return getLog(
- redfish::message_registries::base::Index::passwordChangeRequired, args);
+ redfish::message_registries::base::Index::passwordChangeRequired,
+ std::to_array({arg1str}));
}
/**
@@ -1682,8 +1649,8 @@ void passwordChangeRequired(crow::Response& res,
messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
}
-void invalidUpload(crow::Response& res, const std::string& arg1,
- const std::string& arg2)
+void invalidUpload(crow::Response& res, std::string_view arg1,
+ std::string_view arg2)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
@@ -1696,12 +1663,17 @@ void invalidUpload(crow::Response& res, const std::string& arg1,
* See header file for more information
* @endinternal
*/
-nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2)
+nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
{
+ std::string msg = "Invalid file uploaded to ";
+ msg += arg1;
+ msg += ": ";
+ msg += arg2;
+ msg += ".";
return nlohmann::json{
{"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"},
{"MessageId", "OpenBMC.0.2.InvalidUpload"},
- {"Message", "Invalid file uploaded to " + arg1 + ": " + arg2 + "."},
+ {"Message", std::move(msg)},
{"MessageArgs", {arg1, arg2}},
{"MessageSeverity", "Warning"},
{"Resolution", "None."}};