Introduce Redfish Error messages definitions
Added a python script that should be use to generate error_messages.cpp na .hpp
files. These files as are not subject to change in a dynamic manner, should be
regenerated only when MessageRegistry changes.
Tested on x86 Ubuntu VM and Wolfpass platform:
a) No regression in BMCWeb interface
- Went through WebUI observed no changes in functionality
b) No regression in Redfish functionality
- Went through nodes and observed no changes in functionality
- Sessions now return error messages in addition to HTTP codes
Change-Id: I4aba9ee247b6cd2c46a9c158d14bdc7546e9b11b
Signed-off-by: Kowalski, Kamil <kamil.kowalski@intel.com>
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d6037c..02de756 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -141,7 +141,10 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/redfish-core/include)
-set(SRC_FILES ${GENERATED_SRC_FILES})
+set(SRC_FILES
+ redfish-core/src/error_messages.cpp
+ ${GENERATED_SRC_FILES}
+)
file(COPY src/test_resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
new file mode 100644
index 0000000..18ef2af
--- /dev/null
+++ b/redfish-core/include/error_messages.hpp
@@ -0,0 +1,641 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+/****************************************************************
+ * This is an auto-generated header which contains definitions
+ * to use Redfish DMTF defined messages.
+ *
+ * This header contains preprocessor defines which wrap
+ * preparation functions for message with given id. The message
+ * ids can be retrieved from Base.__ver__.json file.
+ ***************************************************************/
+#pragma once
+#include <nlohmann/json.hpp>
+
+namespace redfish {
+
+namespace messages {
+
+constexpr const char* MESSAGE_VERSION_PREFIX = "Base.1.2.0.";
+constexpr const char* MESSAGE_ANNOTATION = "@Message.ExtendedInfo";
+
+/**
+ * @brief Adds Message JSON object to error object
+ *
+ * @param[out] target Target JSON to which message will be added
+ * @param[in] message Message JSON that should be added to target
+ *
+ * @return None
+ */
+void addMessageToErrorJson(nlohmann::json& target,
+ const nlohmann::json& message);
+
+/**
+ * @brief Adds Message JSON object to target JSON
+ *
+ * @internal
+ * This function has similar implementation to addMessageToJson(...), but
+ * does not use nlohmann::json_pointer to avoid costly construction
+ * @endinternal
+ *
+ * @param[out] target Target JSON to which message will be added
+ * @param[in] message Message JSON that should be added to target
+ *
+ * @return None
+ */
+void addMessageToJsonRoot(nlohmann::json& target,
+ const nlohmann::json& message);
+
+/**
+ * @brief Adds Message JSON object connected with specific field to target JSON
+ *
+ * @param[out] target Target JSON to which message will be added
+ * @param[in] message Message JSON that should be added to target
+ * @param[in] fieldPath Path of related field
+ *
+ * @return None
+ */
+void addMessageToJson(nlohmann::json& target, const nlohmann::json& message,
+ const std::string& fieldPath);
+
+/*********************************
+ * AUTOGENERATED FUNCTIONS START *
+ *********************************/
+
+/**
+ * @brief Formats ResourceInUse message into JSON
+ * Message body: "The change to the requested resource failed because the
+ * resource is in use or in transition."
+ *
+ *
+ * @returns Message ResourceInUse formatted to JSON */
+nlohmann::json resourceInUse();
+
+/**
+ * @brief Formats MalformedJSON message into JSON
+ * Message body: "The request body submitted was malformed JSON and could not be
+ * parsed by the receiving service."
+ *
+ *
+ * @returns Message MalformedJSON formatted to JSON */
+nlohmann::json malformedJSON();
+
+/**
+ * @brief Formats ResourceMissingAtURI message into JSON
+ * Message body: "The resource at the URI <arg0> was not found."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ *
+ * @returns Message ResourceMissingAtURI formatted to JSON */
+nlohmann::json resourceMissingAtURI(const std::string& arg1);
+
+/**
+ * @brief Formats ActionParameterValueFormatError message into JSON
+ * Message body: "The value <arg0> for the parameter <arg1> in the action <arg2>
+ * is of a different format than the parameter can accept."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @param[in] arg2 Parameter of message that will replace %2 in its body.
+ * @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);
+
+/**
+ * @brief Formats InternalError message into JSON
+ * Message body: "The request failed due to an internal service error. The
+ * service is still operational."
+ *
+ *
+ * @returns Message InternalError formatted to JSON */
+nlohmann::json internalError();
+
+/**
+ * @brief Formats UnrecognizedRequestBody message into JSON
+ * Message body: "The service detected a malformed request body that it was
+ * unable to interpret."
+ *
+ *
+ * @returns Message UnrecognizedRequestBody formatted to JSON */
+nlohmann::json unrecognizedRequestBody();
+
+/**
+ * @brief Formats ResourceAtUriUnauthorized message into JSON
+ * Message body: "While accessing the resource at <arg0>, the service received
+ * an authorization error <arg1>."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @param[in] arg2 Parameter of message that will replace %2 in its body.
+ *
+ * @returns Message ResourceAtUriUnauthorized formatted to JSON */
+nlohmann::json resourceAtUriUnauthorized(const std::string& arg1,
+ const std::string& arg2);
+
+/**
+ * @brief Formats ActionParameterUnknown message into JSON
+ * Message body: "The action <arg0> was submitted with the invalid parameter
+ * <arg1>."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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);
+
+/**
+ * @brief Formats ResourceCannotBeDeleted message into JSON
+ * Message body: "The delete request failed because the resource requested
+ * cannot be deleted."
+ *
+ *
+ * @returns Message ResourceCannotBeDeleted formatted to JSON */
+nlohmann::json resourceCannotBeDeleted();
+
+/**
+ * @brief Formats PropertyDuplicate message into JSON
+ * Message body: "The property <arg0> was duplicated in the request."
+ *
+ * @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);
+
+/**
+ * @brief Formats ServiceTemporarilyUnavailable message into JSON
+ * Message body: "The service is temporarily unavailable. Retry in <arg0>
+ * seconds."
+ *
+ * @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);
+
+/**
+ * @brief Formats ResourceAlreadyExists message into JSON
+ * Message body: "The requested resource of type <arg0> with the property <arg1>
+ * with the value <arg2> already exists."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @param[in] arg2 Parameter of message that will replace %2 in its body.
+ * @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);
+
+/**
+ * @brief Formats AccountForSessionNoLongerExists message into JSON
+ * Message body: "The account for the current session has been removed, thus the
+ * current session has been removed as well."
+ *
+ *
+ * @returns Message AccountForSessionNoLongerExists formatted to JSON */
+nlohmann::json accountForSessionNoLongerExists();
+
+/**
+ * @brief Formats CreateFailedMissingReqProperties message into JSON
+ * Message body: "The create operation failed because the required property
+ * <arg0> was missing from the request."
+ *
+ * @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);
+
+/**
+ * @brief Formats PropertyValueFormatError message into JSON
+ * Message body: "The value <arg0> for the property <arg1> is of a different
+ * format than the property can accept."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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);
+
+/**
+ * @brief Formats PropertyValueNotInList message into JSON
+ * Message body: "The value <arg0> for the property <arg1> is not in the list of
+ * acceptable values."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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);
+
+/**
+ * @brief Formats ResourceAtUriInUnknownFormat message into JSON
+ * Message body: "The resource at <arg0> is in a format not recognized by the
+ * service."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ *
+ * @returns Message ResourceAtUriInUnknownFormat formatted to JSON */
+nlohmann::json resourceAtUriInUnknownFormat(const std::string& arg1);
+
+/**
+ * @brief Formats ServiceInUnknownState message into JSON
+ * Message body: "The operation failed because the service is in an unknown
+ * state and can no longer take incoming requests."
+ *
+ *
+ * @returns Message ServiceInUnknownState formatted to JSON */
+nlohmann::json serviceInUnknownState();
+
+/**
+ * @brief Formats EventSubscriptionLimitExceeded message into JSON
+ * Message body: "The event subscription failed due to the number of
+ * simultaneous subscriptions exceeding the limit of the implementation."
+ *
+ *
+ * @returns Message EventSubscriptionLimitExceeded formatted to JSON */
+nlohmann::json eventSubscriptionLimitExceeded();
+
+/**
+ * @brief Formats ActionParameterMissing message into JSON
+ * Message body: "The action <arg0> requires the parameter <arg1> to be present
+ * in the request body."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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);
+
+/**
+ * @brief Formats StringValueTooLong message into JSON
+ * Message body: "The string <arg0> exceeds the length limit <arg1>."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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, const int& arg2);
+
+/**
+ * @brief Formats PropertyValueTypeError message into JSON
+ * Message body: "The value <arg0> for the property <arg1> is of a different
+ * type than the property can accept."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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);
+
+/**
+ * @brief Formats ResourceNotFound message into JSON
+ * Message body: "The requested resource of type <arg0> named <arg1> was not
+ * found."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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);
+
+/**
+ * @brief Formats CouldNotEstablishConnection message into JSON
+ * Message body: "The service failed to establish a connection with the URI
+ * <arg0>."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ *
+ * @returns Message CouldNotEstablishConnection formatted to JSON */
+nlohmann::json couldNotEstablishConnection(const std::string& arg1);
+
+/**
+ * @brief Formats PropertyNotWritable message into JSON
+ * Message body: "The property <arg0> is a read only property and cannot be
+ * assigned a value."
+ *
+ * @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);
+
+/**
+ * @brief Formats QueryParameterValueTypeError message into JSON
+ * Message body: "The value <arg0> for the query parameter <arg1> is of a
+ * different type than the parameter can accept."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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);
+
+/**
+ * @brief Formats ServiceShuttingDown message into JSON
+ * Message body: "The operation failed because the service is shutting down and
+ * can no longer take incoming requests."
+ *
+ *
+ * @returns Message ServiceShuttingDown formatted to JSON */
+nlohmann::json serviceShuttingDown();
+
+/**
+ * @brief Formats ActionParameterDuplicate message into JSON
+ * Message body: "The action <arg0> was submitted with more than one value for
+ * the parameter <arg1>."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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);
+
+/**
+ * @brief Formats ActionParameterNotSupported message into JSON
+ * Message body: "The parameter <arg0> for the action <arg1> is not supported on
+ * the target resource."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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);
+
+/**
+ * @brief Formats SourceDoesNotSupportProtocol message into JSON
+ * Message body: "The other end of the connection at <arg0> does not support the
+ * specified protocol <arg1>."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @param[in] arg2 Parameter of message that will replace %2 in its body.
+ *
+ * @returns Message SourceDoesNotSupportProtocol formatted to JSON */
+nlohmann::json sourceDoesNotSupportProtocol(const std::string& arg1,
+ const std::string& arg2);
+
+/**
+ * @brief Formats AccountRemoved message into JSON
+ * Message body: "The account was successfully removed."
+ *
+ *
+ * @returns Message AccountRemoved formatted to JSON */
+nlohmann::json accountRemoved();
+
+/**
+ * @brief Formats AccessDenied message into JSON
+ * Message body: "While attempting to establish a connection to <arg0>, the
+ * service denied access."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ *
+ * @returns Message AccessDenied formatted to JSON */
+nlohmann::json accessDenied(const std::string& arg1);
+
+/**
+ * @brief Formats QueryNotSupported message into JSON
+ * Message body: "Querying is not supported by the implementation."
+ *
+ *
+ * @returns Message QueryNotSupported formatted to JSON */
+nlohmann::json queryNotSupported();
+
+/**
+ * @brief Formats CreateLimitReachedForResource message into JSON
+ * Message body: "The create operation failed because the resource has reached
+ * the limit of possible resources."
+ *
+ *
+ * @returns Message CreateLimitReachedForResource formatted to JSON */
+nlohmann::json createLimitReachedForResource();
+
+/**
+ * @brief Formats GeneralError message into JSON
+ * Message body: "A general error has occurred. See ExtendedInfo for more
+ * information."
+ *
+ *
+ * @returns Message GeneralError formatted to JSON */
+nlohmann::json generalError();
+
+/**
+ * @brief Formats Success message into JSON
+ * Message body: "Successfully Completed Request"
+ *
+ *
+ * @returns Message Success formatted to JSON */
+nlohmann::json success();
+
+/**
+ * @brief Formats Created message into JSON
+ * Message body: "The resource has been created successfully"
+ *
+ *
+ * @returns Message Created formatted to JSON */
+nlohmann::json created();
+
+/**
+ * @brief Formats PropertyUnknown message into JSON
+ * Message body: "The property <arg0> is not in the list of valid properties for
+ * the resource."
+ *
+ * @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);
+
+/**
+ * @brief Formats NoValidSession message into JSON
+ * Message body: "There is no valid session established with the
+ * implementation."
+ *
+ *
+ * @returns Message NoValidSession formatted to JSON */
+nlohmann::json noValidSession();
+
+/**
+ * @brief Formats InvalidObject message into JSON
+ * Message body: "The object at <arg0> is invalid."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ *
+ * @returns Message InvalidObject formatted to JSON */
+nlohmann::json invalidObject(const std::string& arg1);
+
+/**
+ * @brief Formats ResourceInStandby message into JSON
+ * Message body: "The request could not be performed because the resource is in
+ * standby."
+ *
+ *
+ * @returns Message ResourceInStandby formatted to JSON */
+nlohmann::json resourceInStandby();
+
+/**
+ * @brief Formats ActionParameterValueTypeError message into JSON
+ * Message body: "The value <arg0> for the parameter <arg1> in the action <arg2>
+ * is of a different type than the parameter can accept."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @param[in] arg2 Parameter of message that will replace %2 in its body.
+ * @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);
+
+/**
+ * @brief Formats SessionLimitExceeded message into JSON
+ * Message body: "The session establishment failed due to the number of
+ * simultaneous sessions exceeding the limit of the implementation."
+ *
+ *
+ * @returns Message SessionLimitExceeded formatted to JSON */
+nlohmann::json sessionLimitExceeded();
+
+/**
+ * @brief Formats ActionNotSupported message into JSON
+ * Message body: "The action <arg0> is not supported by the resource."
+ *
+ * @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);
+
+/**
+ * @brief Formats InvalidIndex message into JSON
+ * Message body: "The Index <arg0> is not a valid offset into the array."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ *
+ * @returns Message InvalidIndex formatted to JSON */
+nlohmann::json invalidIndex(const int& arg1);
+
+/**
+ * @brief Formats EmptyJSON message into JSON
+ * Message body: "The request body submitted contained an empty JSON object and
+ * the service is unable to process it."
+ *
+ *
+ * @returns Message EmptyJSON formatted to JSON */
+nlohmann::json emptyJSON();
+
+/**
+ * @brief Formats QueryNotSupportedOnResource message into JSON
+ * Message body: "Querying is not supported on the requested resource."
+ *
+ *
+ * @returns Message QueryNotSupportedOnResource formatted to JSON */
+nlohmann::json queryNotSupportedOnResource();
+
+/**
+ * @brief Formats InsufficientPrivilege message into JSON
+ * Message body: "There are insufficient privileges for the account or
+ * credentials associated with the current session to perform the requested
+ * operation."
+ *
+ *
+ * @returns Message InsufficientPrivilege formatted to JSON */
+nlohmann::json insufficientPrivilege();
+
+/**
+ * @brief Formats PropertyValueModified message into JSON
+ * Message body: "The property <arg0> was assigned the value <arg1> due to
+ * modification by the service."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @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);
+
+/**
+ * @brief Formats AccountNotModified message into JSON
+ * Message body: "The account modification request failed."
+ *
+ *
+ * @returns Message AccountNotModified formatted to JSON */
+nlohmann::json accountNotModified();
+
+/**
+ * @brief Formats QueryParameterValueFormatError message into JSON
+ * Message body: "The value <arg0> for the parameter <arg1> is of a different
+ * format than the parameter can accept."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @param[in] arg2 Parameter of message that will replace %2 in its body.
+ *
+ * @returns Message QueryParameterValueFormatError formatted to JSON */
+nlohmann::json queryParameterValueFormatError(const std::string& arg1,
+ const std::string& arg2);
+
+/**
+ * @brief Formats PropertyMissing message into JSON
+ * Message body: "The property <arg0> is a required property and must be
+ * included in the request."
+ *
+ * @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);
+
+/**
+ * @brief Formats ResourceExhaustion message into JSON
+ * Message body: "The resource <arg0> was unable to satisfy the request due to
+ * unavailability of resources."
+ *
+ * @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);
+
+/**
+ * @brief Formats AccountModified message into JSON
+ * Message body: "The account was successfully modified."
+ *
+ *
+ * @returns Message AccountModified formatted to JSON */
+nlohmann::json accountModified();
+
+/**
+ * @brief Formats QueryParameterOutOfRange message into JSON
+ * Message body: "The value <arg0> for the query parameter <arg1> is out of
+ * range <arg2>."
+ *
+ * @param[in] arg1 Parameter of message that will replace %1 in its body.
+ * @param[in] arg2 Parameter of message that will replace %2 in its body.
+ * @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);
+
+/*********************************
+ * AUTOGENERATED FUNCTIONS END *
+ *********************************/
+
+} // namespace messages
+
+} // namespace redfish
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 4e429e8..507116d 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -15,6 +15,7 @@
*/
#pragma once
+#include "error_messages.hpp"
#include "node.hpp"
#include "session_storage_singleton.hpp"
@@ -46,6 +47,9 @@
crow::PersistentData::session_store->get_session_by_uid(params[0]);
if (session == nullptr) {
+ messages::addMessageToErrorJson(
+ res.json_value, messages::resourceNotFound("Session", params[0]));
+
res.code = static_cast<int>(HttpRespCode::NOT_FOUND);
res.end();
return;
@@ -64,7 +68,12 @@
const std::vector<std::string>& params) override {
// Need only 1 param which should be id of session to be deleted
if (params.size() != 1) {
+ // This should be handled by crow and never happen
+ CROW_LOG_ERROR
+ << "Session DELETE has been called with invalid number of params";
+
res.code = static_cast<int>(HttpRespCode::BAD_REQUEST);
+ messages::addMessageToErrorJson(res.json_value, messages::generalError());
res.end();
return;
}
@@ -73,14 +82,18 @@
crow::PersistentData::session_store->get_session_by_uid(params[0]);
if (session == nullptr) {
+ messages::addMessageToErrorJson(
+ res.json_value, messages::resourceNotFound("Session", params[0]));
+
res.code = static_cast<int>(HttpRespCode::NOT_FOUND);
res.end();
return;
}
+ // DELETE should return representation of object that will be removed
+ doGet(res, req, params);
+
crow::PersistentData::session_store->remove_session(session);
- res.code = static_cast<int>(HttpRespCode::OK);
- res.end();
}
/**
@@ -133,7 +146,8 @@
void doPost(crow::response& res, const crow::request& req,
const std::vector<std::string>& params) override {
std::string username;
- bool userAuthSuccessful = authenticateUser(req, &res.code, &username);
+ bool userAuthSuccessful =
+ authenticateUser(req, res.code, username, res.json_value);
if (!userAuthSuccessful) {
res.end();
return;
@@ -156,25 +170,30 @@
* @param[in] req Crow request containing authentication data
* @param[out] httpRespCode HTTP Code that should be returned in response
* @param[out] user Retrieved username - not filled on failure
+ * @param[out] errJson JSON to which error messages will be written
*
* @return true if authentication was successful, false otherwise
*/
- bool authenticateUser(const crow::request& req, int* httpRespCode,
- std::string* user) {
+ bool authenticateUser(const crow::request& req, int& httpRespCode,
+ std::string& user, nlohmann::json& errJson) {
// We need only UserName and Password - nothing more, nothing less
static constexpr const unsigned int numberOfRequiredFieldsInReq = 2;
// call with exceptions disabled
auto login_credentials = nlohmann::json::parse(req.body, nullptr, false);
if (login_credentials.is_discarded()) {
- *httpRespCode = static_cast<int>(HttpRespCode::BAD_REQUEST);
+ httpRespCode = static_cast<int>(HttpRespCode::BAD_REQUEST);
+
+ messages::addMessageToErrorJson(errJson, messages::malformedJSON());
return false;
}
// Check that there are only as many fields as there should be
if (login_credentials.size() != numberOfRequiredFieldsInReq) {
- *httpRespCode = static_cast<int>(HttpRespCode::BAD_REQUEST);
+ httpRespCode = static_cast<int>(HttpRespCode::BAD_REQUEST);
+
+ messages::addMessageToErrorJson(errJson, messages::malformedJSON());
return false;
}
@@ -184,14 +203,36 @@
auto pass_it = login_credentials.find("Password");
if (user_it == login_credentials.end() ||
pass_it == login_credentials.end()) {
- *httpRespCode = static_cast<int>(HttpRespCode::BAD_REQUEST);
+ httpRespCode = static_cast<int>(HttpRespCode::BAD_REQUEST);
+
+ if (user_it == login_credentials.end()) {
+ messages::addMessageToErrorJson(errJson,
+ messages::propertyMissing("UserName"));
+ }
+
+ if (pass_it == login_credentials.end()) {
+ messages::addMessageToErrorJson(errJson,
+ messages::propertyMissing("Password"));
+ }
return false;
}
// Check that given data is of valid type (string)
if (!user_it->is_string() || !pass_it->is_string()) {
- *httpRespCode = static_cast<int>(HttpRespCode::BAD_REQUEST);
+ httpRespCode = static_cast<int>(HttpRespCode::BAD_REQUEST);
+
+ if (!user_it->is_string()) {
+ messages::addMessageToErrorJson(
+ errJson,
+ messages::propertyValueTypeError(user_it->dump(), "UserName"));
+ }
+
+ if (!pass_it->is_string()) {
+ messages::addMessageToErrorJson(
+ errJson,
+ messages::propertyValueTypeError(user_it->dump(), "Password"));
+ }
return false;
}
@@ -202,21 +243,35 @@
// Verify that required fields are not empty
if (username.empty() || password.empty()) {
- *httpRespCode = static_cast<int>(HttpRespCode::BAD_REQUEST);
+ httpRespCode = static_cast<int>(HttpRespCode::BAD_REQUEST);
+
+ if (username.empty()) {
+ messages::addMessageToErrorJson(errJson,
+ messages::propertyMissing("UserName"));
+ }
+
+ if (password.empty()) {
+ messages::addMessageToErrorJson(errJson,
+ messages::propertyMissing("Password"));
+ }
return false;
}
// Finally - try to authenticate user
if (!pam_authenticate_user(username, password)) {
- *httpRespCode = static_cast<int>(HttpRespCode::UNAUTHORIZED);
+ httpRespCode = static_cast<int>(HttpRespCode::UNAUTHORIZED);
+
+ messages::addMessageToErrorJson(
+ errJson, messages::resourceAtUriUnauthorized(
+ req.url, "Invalid username or password"));
return false;
}
// User authenticated successfully
- *httpRespCode = static_cast<int>(HttpRespCode::OK);
- *user = username;
+ httpRespCode = static_cast<int>(HttpRespCode::OK);
+ user = username;
return true;
}
diff --git a/redfish-core/scripts/error_messages/Base.1.2.0.json b/redfish-core/scripts/error_messages/Base.1.2.0.json
new file mode 100644
index 0000000..3c8c1bb
--- /dev/null
+++ b/redfish-core/scripts/error_messages/Base.1.2.0.json
@@ -0,0 +1,516 @@
+{
+ "@Redfish.Copyright": "Copyright 2014-2015, 2017 Distributed Management Task Force, Inc. (DMTF). All rights reserved.",
+ "@odata.type": "#MessageRegistry.v1_0_0.MessageRegistry",
+ "Id": "Base.1.2.0",
+ "Name": "Base Message Registry",
+ "Language": "en",
+ "Description": "This registry defines the base messages for Redfish",
+ "RegistryPrefix": "Base",
+ "RegistryVersion": "1.2.0",
+ "OwningEntity": "DMTF",
+ "Messages": {
+ "Success": {
+ "Description": "Indicates that all conditions of a successful operation have been met.",
+ "Message": "Successfully Completed Request",
+ "Severity": "OK",
+ "NumberOfArgs": 0,
+ "Resolution": "None"
+ },
+ "GeneralError": {
+ "Description": "Indicates that a general error has occurred.",
+ "Message": "A general error has occurred. See ExtendedInfo for more information.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "See ExtendedInfo for more information."
+ },
+ "Created": {
+ "Description": "Indicates that all conditions of a successful creation operation have been met.",
+ "Message": "The resource has been created successfully",
+ "Severity": "OK",
+ "NumberOfArgs": 0,
+ "Resolution": "None"
+ },
+ "PropertyDuplicate": {
+ "Description": "Indicates that a duplicate property was included in the request body.",
+ "Message": "The property %1 was duplicated in the request.",
+ "Severity": "Warning",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Remove the duplicate property from the request body and resubmit the request if the operation failed."
+ },
+ "PropertyUnknown": {
+ "Description": "Indicates that an unknown property was included in the request body.",
+ "Message": "The property %1 is not in the list of valid properties for the resource.",
+ "Severity": "Warning",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Remove the unknown property from the request body and resubmit the request if the operation failed."
+ },
+ "PropertyValueTypeError": {
+ "Description": "Indicates that a property was given the wrong value type, such as when a number is supplied for a property that requires a string.",
+ "Message": "The value %1 for the property %2 is of a different type than the property can accept.",
+ "Severity": "Warning",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed."
+ },
+ "PropertyValueFormatError": {
+ "Description": "Indicates that a property was given the correct value type but the value of that property was not supported.",
+ "Message": "The value %1 for the property %2 is of a different format than the property can accept.",
+ "Severity": "Warning",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed."
+ },
+ "PropertyValueNotInList": {
+ "Description": "Indicates that a property was given the correct value type but the value of that property was not supported. This values not in an enumeration",
+ "Message": "The value %1 for the property %2 is not in the list of acceptable values.",
+ "Severity": "Warning",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Choose a value from the enumeration list that the implementation can support and resubmit the request if the operation failed."
+ },
+ "PropertyNotWritable": {
+ "Description": "Indicates that a property was given a value in the request body, but the property is a readonly property.",
+ "Message": "The property %1 is a read only property and cannot be assigned a value.",
+ "Severity": "Warning",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Remove the property from the request body and resubmit the request if the operation failed."
+ },
+ "PropertyMissing": {
+ "Description": "Indicates that a required property was not supplied as part of the request.",
+ "Message": "The property %1 is a required property and must be included in the request.",
+ "Severity": "Warning",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Ensure that the property is in the request body and has a valid value and resubmit the request if the operation failed."
+ },
+ "MalformedJSON": {
+ "Description": "Indicates that the request body was malformed JSON. Could be duplicate, syntax error,etc.",
+ "Message": "The request body submitted was malformed JSON and could not be parsed by the receiving service.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "Ensure that the request body is valid JSON and resubmit the request."
+ },
+ "EmptyJSON": {
+ "Description": "Indicates that the request body contained an empty JSON object when one or more properties are expected in the body.",
+ "Message": "The request body submitted contained an empty JSON object and the service is unable to process it.",
+ "Severity": "Warning",
+ "NumberOfArgs": 0,
+ "Resolution": "Add properties in the JSON object and resubmit the request."
+ },
+ "ActionNotSupported": {
+ "Description": "Indicates that the action supplied with the POST operation is not supported by the resource.",
+ "Message": "The action %1 is not supported by the resource.",
+ "Severity": "Critical",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "The action supplied cannot be resubmitted to the implementation. Perhaps the action was invalid, the wrong resource was the target or the implementation documentation may be of assistance."
+ },
+ "ActionParameterMissing": {
+ "Description": "Indicates that the action requested was missing a parameter that is required to process the action.",
+ "Message": "The action %1 requires the parameter %2 to be present in the request body.",
+ "Severity": "Critical",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Supply the action with the required parameter in the request body when the request is resubmitted."
+ },
+ "ActionParameterDuplicate": {
+ "Description": "Indicates that the action was supplied with a duplicated parameter in the request body.",
+ "Message": "The action %1 was submitted with more than one value for the parameter %2.",
+ "Severity": "Warning",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Resubmit the action with only one instance of the parameter in the request body if the operation failed."
+ },
+ "ActionParameterUnknown": {
+ "Description": "Indicates that an action was submitted but a parameter supplied did not match any of the known parameters.",
+ "Message": "The action %1 was submitted with the invalid parameter %2.",
+ "Severity": "Warning",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Correct the invalid parameter and resubmit the request if the operation failed."
+ },
+ "ActionParameterValueTypeError": {
+ "Description": "Indicates that a parameter was given the wrong value type, such as when a number is supplied for a parameter that requires a string.",
+ "Message": "The value %1 for the parameter %2 in the action %3 is of a different type than the parameter can accept.",
+ "Severity": "Warning",
+ "NumberOfArgs": 3,
+ "ParamTypes": [
+ "string",
+ "string",
+ "string"
+ ],
+ "Resolution": "Correct the value for the parameter in the request body and resubmit the request if the operation failed."
+ },
+ "ActionParameterValueFormatError": {
+ "Description": "Indicates that a parameter was given the correct value type but the value of that parameter was not supported. This includes value size/length exceeded.",
+ "Message": "The value %1 for the parameter %2 in the action %3 is of a different format than the parameter can accept.",
+ "Severity": "Warning",
+ "NumberOfArgs": 3,
+ "ParamTypes": [
+ "string",
+ "string",
+ "string"
+ ],
+ "Resolution": "Correct the value for the parameter in the request body and resubmit the request if the operation failed."
+ },
+ "ActionParameterNotSupported": {
+ "Description": "Indicates that the parameter supplied for the action is not supported on the resource.",
+ "Message": "The parameter %1 for the action %2 is not supported on the target resource.",
+ "Severity": "Warning",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Remove the parameter supplied and resubmit the request if the operation failed."
+ },
+ "QueryParameterValueTypeError": {
+ "Description": "Indicates that a query parameter was given the wrong value type, such as when a number is supplied for a query parameter that requires a string.",
+ "Message": "The value %1 for the query parameter %2 is of a different type than the parameter can accept.",
+ "Severity": "Warning",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Correct the value for the query parameter in the request and resubmit the request if the operation failed."
+ },
+ "QueryParameterValueFormatError": {
+ "Description": "Indicates that a query parameter was given the correct value type but the value of that parameter was not supported. This includes value size/length exceeded.",
+ "Message": "The value %1 for the parameter %2 is of a different format than the parameter can accept.",
+ "Severity": "Warning",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Correct the value for the query parameter in the request and resubmit the request if the operation failed."
+ },
+ "QueryParameterOutOfRange": {
+ "Description": "Indicates that a query parameter was supplied that is out of range for the given resource. This can happen with values that are too low or beyond that possible for the supplied resource, such as when a page is requested that is beyond the last page.",
+ "Message": "The value %1 for the query parameter %2 is out of range %3.",
+ "Severity": "Warning",
+ "NumberOfArgs": 3,
+ "ParamTypes": [
+ "string",
+ "string",
+ "string"
+ ],
+ "Resolution": "Reduce the value for the query parameter to a value that is within range, such as a start or count value that is within bounds of the number of resources in a collection or a page that is within the range of valid pages."
+ },
+ "QueryNotSupportedOnResource": {
+ "Description": "Indicates that query is not supported on the given resource, such as when a start/count query is attempted on a resource that is not a collection.",
+ "Message": "Querying is not supported on the requested resource.",
+ "Severity": "Warning",
+ "NumberOfArgs": 0,
+ "Resolution": "Remove the query parameters and resubmit the request if the operation failed."
+ },
+ "QueryNotSupported": {
+ "Description": "Indicates that query is not supported on the implementation.",
+ "Message": "Querying is not supported by the implementation.",
+ "Severity": "Warning",
+ "NumberOfArgs": 0,
+ "Resolution": "Remove the query parameters and resubmit the request if the operation failed."
+ },
+ "SessionLimitExceeded": {
+ "Description": "Indicates that a session establishment has been requested but the operation failed due to the number of simultaneous sessions exceeding the limit of the implementation.",
+ "Message": "The session establishment failed due to the number of simultaneous sessions exceeding the limit of the implementation.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "Reduce the number of other sessions before trying to establish the session or increase the limit of simultaneous sessions (if supported)."
+ },
+ "EventSubscriptionLimitExceeded": {
+ "Description": "Indicates that a event subscription establishment has been requested but the operation failed due to the number of simultaneous connection exceeding the limit of the implementation.",
+ "Message": "The event subscription failed due to the number of simultaneous subscriptions exceeding the limit of the implementation.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "Reduce the number of other subscriptions before trying to establish the event subscription or increase the limit of simultaneous subscriptions (if supported)."
+ },
+ "ResourceCannotBeDeleted": {
+ "Description": "Indicates that a delete operation was attempted on a resource that cannot be deleted.",
+ "Message": "The delete request failed because the resource requested cannot be deleted.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "Do not attempt to delete a non-deletable resource."
+ },
+ "ResourceInUse": {
+ "Description": "Indicates that a change was requested to a resource but the change was rejected due to the resource being in use or transition.",
+ "Message": "The change to the requested resource failed because the resource is in use or in transition.",
+ "Severity": "Warning",
+ "NumberOfArgs": 0,
+ "Resolution": "Remove the condition and resubmit the request if the operation failed."
+ },
+ "ResourceAlreadyExists": {
+ "Description": "Indicates that a resource change or creation was attempted but that the operation cannot proceed because the resource already exists.",
+ "Message": "The requested resource of type %1 with the property %2 with the value %3 already exists.",
+ "Severity": "Critical",
+ "NumberOfArgs": 3,
+ "ParamTypes": [
+ "string",
+ "string",
+ "string"
+ ],
+ "Resolution": "Do not repeat the create operation as the resource has already been created."
+ },
+ "ResourceNotFound": {
+ "Description": "Indicates that the operation expected a resource identifier that corresponds to an existing resource but one was not found.",
+ "Message": "The requested resource of type %1 named %2 was not found.",
+ "Severity": "Critical",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Provide a valid resource identifier and resubmit the request."
+ },
+ "CreateFailedMissingReqProperties": {
+ "Description": "Indicates that a create was attempted on a resource but that properties that are required for the create operation were missing from the request.",
+ "Message": "The create operation failed because the required property %1 was missing from the request.",
+ "Severity": "Critical",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Correct the body to include the required property with a valid value and resubmit the request if the operation failed."
+ },
+ "CreateLimitReachedForResource": {
+ "Description": "Indicates that no more resources can be created on the resource as it has reached its create limit.",
+ "Message": "The create operation failed because the resource has reached the limit of possible resources.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "Either delete resources and resubmit the request if the operation failed or do not resubmit the request."
+ },
+ "ServiceShuttingDown": {
+ "Description": "Indicates that the operation failed as the service is shutting down, such as when the service reboots.",
+ "Message": "The operation failed because the service is shutting down and can no longer take incoming requests.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "When the service becomes available, resubmit the request if the operation failed."
+ },
+ "ServiceInUnknownState": {
+ "Description": "Indicates that the operation failed because the service is in an unknown state and cannot accept additional requests.",
+ "Message": "The operation failed because the service is in an unknown state and can no longer take incoming requests.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "Restart the service and resubmit the request if the operation failed."
+ },
+ "NoValidSession": {
+ "Description": "Indicates that the operation failed because a valid session is required in order to access any resources.",
+ "Message": "There is no valid session established with the implementation.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "Establish as session before attempting any operations."
+ },
+ "InsufficientPrivilege": {
+ "Description": "Indicates that the credentials associated with the established session do not have sufficient privileges for the requested operation",
+ "Message": "There are insufficient privileges for the account or credentials associated with the current session to perform the requested operation.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "Either abandon the operation or change the associated access rights and resubmit the request if the operation failed."
+ },
+ "AccountModified": {
+ "Description": "Indicates that the account was successfully modified.",
+ "Message": "The account was successfully modified.",
+ "Severity": "OK",
+ "NumberOfArgs": 0,
+ "Resolution": "No resolution is required."
+ },
+ "AccountNotModified": {
+ "Description": "Indicates that the modification requested for the account was not successful.",
+ "Message": "The account modification request failed.",
+ "Severity": "Warning",
+ "NumberOfArgs": 0,
+ "Resolution": "The modification may have failed due to permission issues or issues with the request body."
+ },
+ "AccountRemoved": {
+ "Description": "Indicates that the account was successfully removed.",
+ "Message": "The account was successfully removed.",
+ "Severity": "OK",
+ "NumberOfArgs": 0,
+ "Resolution": "No resolution is required."
+ },
+ "AccountForSessionNoLongerExists": {
+ "Description": "Indicates that the account for the session has been removed, thus the session has been removed as well.",
+ "Message": "The account for the current session has been removed, thus the current session has been removed as well.",
+ "Severity": "OK",
+ "NumberOfArgs": 0,
+ "Resolution": "Attempt to connect with a valid account."
+ },
+ "InvalidObject": {
+ "Description": "Indicates that the object in question is invalid according to the implementation. Examples include a firmware update malformed URI.",
+ "Message": "The object at %1 is invalid.",
+ "Severity": "Critical",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Either the object is malformed or the URI is not correct. Correct the condition and resubmit the request if it failed."
+ },
+ "InternalError": {
+ "Description": "Indicates that the request failed for an unknown internal error but that the service is still operational.",
+ "Message": "The request failed due to an internal service error. The service is still operational.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "Resubmit the request. If the problem persists, consider resetting the service."
+ },
+ "UnrecognizedRequestBody": {
+ "Description": "Indicates that the service encountered an unrecognizable request body that could not even be interpreted as malformed JSON.",
+ "Message": "The service detected a malformed request body that it was unable to interpret.",
+ "Severity": "Warning",
+ "NumberOfArgs": 0,
+ "Resolution": "Correct the request body and resubmit the request if it failed."
+ },
+ "ResourceMissingAtURI": {
+ "Description": "Indicates that the operation expected an image or other resource at the provided URI but none was found. Examples of this are in requests that require URIs like Firmware Update.",
+ "Message": "The resource at the URI %1 was not found.",
+ "Severity": "Critical",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Place a valid resource at the URI or correct the URI and resubmit the request."
+ },
+ "ResourceAtUriInUnknownFormat": {
+ "Description": "Indicates that the URI was valid but the resource or image at that URI was in a format not supported by the service.",
+ "Message": "The resource at %1 is in a format not recognized by the service.",
+ "Severity": "Critical",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Place an image or resource or file that is recognized by the service at the URI."
+ },
+ "ResourceAtUriUnauthorized": {
+ "Description": "Indicates that the attempt to access the resource/file/image at the URI was unauthorized.",
+ "Message": "While accessing the resource at %1, the service received an authorization error %2.",
+ "Severity": "Critical",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Ensure that the appropriate access is provided for the service in order for it to access the URI."
+ },
+ "CouldNotEstablishConnection": {
+ "Description": "Indicates that the attempt to access the resource/file/image at the URI was unsuccessful because a session could not be established.",
+ "Message": "The service failed to establish a connection with the URI %1.",
+ "Severity": "Critical",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Ensure that the URI contains a valid and reachable node name, protocol information and other URI components."
+ },
+ "SourceDoesNotSupportProtocol": {
+ "Description": "Indicates that while attempting to access, connect to or transfer a resource/file/image from another location that the other end of the connection did not support the protocol",
+ "Message": "The other end of the connection at %1 does not support the specified protocol %2.",
+ "Severity": "Critical",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "Change protocols or URIs. "
+ },
+ "AccessDenied": {
+ "Description": "Indicates that while attempting to access, connect to or transfer to/from another resource, the service denied access.",
+ "Message": "While attempting to establish a connection to %1, the service denied access.",
+ "Severity": "Critical",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Attempt to ensure that the URI is correct and that the service has the appropriate credentials."
+ },
+ "ServiceTemporarilyUnavailable": {
+ "Description": "Indicates the service is temporarily unavailable.",
+ "Message": "The service is temporarily unavailable. Retry in %1 seconds.",
+ "Severity": "Critical",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Wait for the indicated retry duration and retry the operation."
+ },
+ "InvalidIndex": {
+ "Description": "The Index is not valid.",
+ "Message": "The Index %1 is not a valid offset into the array.",
+ "Severity": "Warning",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "number"
+ ],
+ "Resolution": "Verify the index value provided is within the bounds of the array."
+ },
+ "PropertyValueModified": {
+ "Description": "Indicates that a property was given the correct value type but the value of that property was modified. Examples are truncated or rounded values.",
+ "Message": "The property %1 was assigned the value %2 due to modification by the service.",
+ "Severity": "Warning",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "string"
+ ],
+ "Resolution": "No resolution is required."
+ },
+ "ResourceInStandby": {
+ "Description": "Indicates that the request could not be performed because the resource is in standby.",
+ "Message": "The request could not be performed because the resource is in standby.",
+ "Severity": "Critical",
+ "NumberOfArgs": 0,
+ "Resolution": "Ensure that the resource is in the correct power state and resubmit the request."
+ },
+ "ResourceExhaustion": {
+ "Description": "Indicates that a resource could not satisfy the request due to some unavailability of resources. An example is that available capacity has been allocated.",
+ "Message": "The resource %1 was unable to satisfy the request due to unavailability of resources.",
+ "Severity": "Critical",
+ "NumberOfArgs": 1,
+ "ParamTypes": [
+ "string"
+ ],
+ "Resolution": "Ensure that the resources are available and resubmit the request."
+ },
+ "StringValueTooLong": {
+ "Description": "Indicates that a string value passed to the given resource exceeded its length limit. An example is when a shorter limit is imposed by an implementation than that allowed by the specification.",
+ "Message": "The string %1 exceeds the length limit %2.",
+ "Severity": "Warning",
+ "NumberOfArgs": 2,
+ "ParamTypes": [
+ "string",
+ "number"
+ ],
+ "Resolution": "Resubmit the request with an appropriate string length."
+ }
+ }
+}
diff --git a/redfish-core/scripts/error_messages/error_messages.cpp.in b/redfish-core/scripts/error_messages/error_messages.cpp.in
new file mode 100644
index 0000000..a254b08
--- /dev/null
+++ b/redfish-core/scripts/error_messages/error_messages.cpp.in
@@ -0,0 +1,100 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+#include <error_messages.hpp>
+#include <crow/logging.h>
+
+namespace redfish {
+
+namespace messages {
+
+void addMessageToErrorJson(nlohmann::json& target,
+ const nlohmann::json& message) {
+ auto& error = target["error"];
+
+ // If this is the first error message, fill in the information from the first
+ // error message to the top level struct
+ if (!error.is_object()) {
+ auto message_id_iterator = message.find("MessageId");
+ if (message_id_iterator == message.end()) {
+ CROW_LOG_CRITICAL << "Attempt to add error message without MessageId";
+ return;
+ }
+
+ auto message_field_iterator = message.find("Message");
+ if (message_field_iterator == message.end()) {
+ CROW_LOG_CRITICAL << "Attempt to add error message without Message";
+ return;
+ }
+ // clang-format off
+ error = {
+ {"code", *message_id_iterator},
+ {"message", *message_field_iterator}
+ };
+ // clang-format on
+ } else {
+ // More than 1 error occurred, so the message has to be generic
+ error["code"] = std::string(MESSAGE_VERSION_PREFIX) + "GeneralError";
+ error["message"] = "A general error has occurred. See ExtendedInfo for more"
+ "information.";
+ }
+
+ // This check could technically be done in in the default construction
+ // branch above, but because we need the pointer to the extended info field
+ // anyway, it's more efficient to do it here.
+ auto& extended_info = error[messages::MESSAGE_ANNOTATION];
+ if (!extended_info.is_array()) {
+ extended_info = nlohmann::json::array();
+ }
+
+ extended_info.push_back(message);
+}
+
+void addMessageToJsonRoot(nlohmann::json& target,
+ const nlohmann::json& message) {
+ if (!target[messages::MESSAGE_ANNOTATION].is_array()) {
+ // Force object to be an array
+ target[messages::MESSAGE_ANNOTATION] = nlohmann::json::array();
+ }
+
+ target[messages::MESSAGE_ANNOTATION].push_back(message);
+}
+
+void addMessageToJson(nlohmann::json& target, const nlohmann::json& message,
+ const std::string& fieldPath) {
+ nlohmann::json_pointer extendedInfo(fieldPath + messages::MESSAGE_ANNOTATION);
+
+ if (!target[extendedInfo].is_array()) {
+ // Force object to be an array
+ target[extendedInfo] = nlohmann::json::array();
+ }
+
+ // Object exists and it is an array so we can just push in the message
+ target[extendedInfo].push_back(message);
+}
+
+/*********************************
+ * AUTOGENERATED FUNCTIONS START *
+ *********************************/
+
+/*<<<<<<AUTOGENERATED_FUNCTIONS_IMPLEMENTATIONS>>>>>>*/
+
+/*********************************
+ * AUTOGENERATED FUNCTIONS END *
+ *********************************/
+
+} // namespace messages
+
+} // namespace redifsh
diff --git a/redfish-core/scripts/error_messages/error_messages.hpp.in b/redfish-core/scripts/error_messages/error_messages.hpp.in
new file mode 100644
index 0000000..287917d
--- /dev/null
+++ b/redfish-core/scripts/error_messages/error_messages.hpp.in
@@ -0,0 +1,85 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+/****************************************************************
+ * This is an auto-generated header which contains definitions
+ * to use Redfish DMTF defined messages.
+ *
+ * This header contains preprocessor defines which wrap
+ * preparation functions for message with given id. The message
+ * ids can be retrieved from Base.__ver__.json file.
+ ***************************************************************/
+#pragma once
+#include <nlohmann/json.hpp>
+
+namespace redfish {
+
+namespace messages {
+
+constexpr const char* MESSAGE_VERSION_PREFIX = "Base.1.2.0.";
+constexpr const char* MESSAGE_ANNOTATION = "@Message.ExtendedInfo";
+
+/**
+ * @brief Adds Message JSON object to error object
+ *
+ * @param[out] target Target JSON to which message will be added
+ * @param[in] message Message JSON that should be added to target
+ *
+ * @return None
+ */
+void addMessageToErrorJson(nlohmann::json& target,
+ const nlohmann::json& message);
+
+/**
+ * @brief Adds Message JSON object to target JSON
+ *
+ * @internal
+ * This function has similar implementation to addMessageToJson(...), but
+ * does not use nlohmann::json_pointer to avoid costly construction
+ * @endinternal
+ *
+ * @param[out] target Target JSON to which message will be added
+ * @param[in] message Message JSON that should be added to target
+ *
+ * @return None
+ */
+void addMessageToJsonRoot(nlohmann::json& target,
+ const nlohmann::json& message);
+
+/**
+ * @brief Adds Message JSON object connected with specific field to target JSON
+ *
+ * @param[out] target Target JSON to which message will be added
+ * @param[in] message Message JSON that should be added to target
+ * @param[in] fieldPath Path of related field
+ *
+ * @return None
+ */
+void addMessageToJson(nlohmann::json& target, const nlohmann::json& message,
+ const std::string& fieldPath);
+
+/*********************************
+ * AUTOGENERATED FUNCTIONS START *
+ *********************************/
+
+/*<<<<<<AUTOGENERATED_FUNCTIONS_DECLARATIONS>>>>>>*/
+
+/*********************************
+ * AUTOGENERATED FUNCTIONS END *
+ *********************************/
+
+} // namespace messages
+
+} // namespace redfish
diff --git a/redfish-core/scripts/error_messages/error_messages.py b/redfish-core/scripts/error_messages/error_messages.py
new file mode 100644
index 0000000..0ab15fd
--- /dev/null
+++ b/redfish-core/scripts/error_messages/error_messages.py
@@ -0,0 +1,332 @@
+# Copyright (c) 2018 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import json
+import os
+import re
+import sys
+
+# CONSTANTS
+# Containing namespace
+NAMESPACE = "redfish::messages::"
+# Single indentation
+INDENT = " " * 2
+# Include directory where created files will be stored
+AUTOGEN_PATH = ""
+# MessageRegistry JSON Path
+MESSAGE_REGISTRY_JSON_PATH = ""
+# Error messages target filename
+ERROR_MESSAGES_TARGET_FILENAME = "error_messages"
+# Script path
+SCRIPT_PATH = os.path.dirname(sys.argv[0])
+
+FORMATTING_FUNCTIONS_DECLARATIONS = []
+FORMATTING_FUNCTIONS_IMPLEMENTATIONS = []
+
+# Loaded MessageRegistry JSON
+MESSAGE_REGISTRY = {}
+
+# Path to output header file
+OUT_HEADER_PATH = ""
+# Path to output source file
+OUT_SOURCE_PATH = ""
+
+PARAM_TYPE_TO_CPP_TYPE = {
+ "string": "std::string",
+ "number": "int"
+}
+
+PARAM_TYPE_TO_FORMATTING_ARG = {
+ "string": 'arg{}',
+ "number": 'std::to_string(arg{})'
+}
+
+
+def verify_message(message_id):
+ """
+ Verifies message, by checking that all its parameter information is correct
+
+ :param message_id: Id to be verified
+ :return: True if message is OK, False otherwise
+ """
+ try:
+ message_body = MESSAGE_REGISTRY["Messages"][message_id]["Message"]
+ message_num_args = MESSAGE_REGISTRY["Messages"][message_id]["NumberOfArgs"]
+ regex_find_all_args = '(%[0-9]{1})'
+ found_args = re.findall(regex_find_all_args, message_body)
+
+ if message_num_args == 0:
+ # Verify that there are no %<digit> in message body
+ if len(found_args) != 0:
+ return False
+ else:
+ param_types = MESSAGE_REGISTRY["Messages"][message_id]["ParamTypes"]
+
+ if message_num_args != len(param_types):
+ return False
+ else:
+ # Verify that param types are not unknown
+ for param_type in param_types:
+ if not param_type in PARAM_TYPE_TO_CPP_TYPE:
+ print "Unknown param type " + param_type
+
+ return False
+
+ # Verify that there are as many args as there should be
+ if len(found_args) != message_num_args:
+ return False
+
+ # Verify that all required args exist
+ for i in range(1, message_num_args + 1):
+ found_args.remove("%" + str(i))
+
+ if len(found_args) != 0:
+ return False
+ except:
+ return False
+
+ return True
+
+
+def create_function_brief(message_id):
+ """
+ Creates dOxygen brief for formatting function of given message
+
+ :param message_id: Id of message for which brief should be created
+ :return: Created @brief message
+ """
+ return "@brief Formats " + message_id + " message into JSON"
+
+
+def create_message_body_for_doxy(message_id):
+ """
+ Creates formatted message body for dOxygen comment to lookup message without looking into function code
+
+ :param message_id: Id of message for which message body for doxy should be created
+ :return: Created message
+ """
+ body = MESSAGE_REGISTRY["Messages"][message_id]["Message"]
+ num_params = MESSAGE_REGISTRY["Messages"][message_id]["NumberOfArgs"]
+
+ for param_idx in range(0, num_params):
+ formatting_str = '%' + str(param_idx + 1)
+
+ body = body.replace(formatting_str, '<arg' + str(param_idx) + '>');
+
+ return 'Message body: "' + body + '"'
+
+
+def create_full_doxygen_comment(message_id):
+ """
+ Creates full dOxygen comment with given data
+
+ :param message_id: Id of message for which's formatting function comment should be created
+ :return:
+ """
+ num_params = MESSAGE_REGISTRY["Messages"][message_id]["NumberOfArgs"]
+
+ out_comment = "/**\n" + \
+ " * " + create_function_brief(message_id) + "\n" \
+ " * " + create_message_body_for_doxy(message_id) + "\n" \
+ " *\n"
+
+ for param_idx in range(1, num_params + 1):
+ out_comment += " * @param[in] arg" + str(param_idx) + " Parameter of message that will replace %" +\
+ str(param_idx) + " in its body.\n"
+
+ out_comment += " *\n"
+ out_comment += " * @returns Message " + message_id + " formatted to JSON"
+ out_comment += " */\n"
+
+ return out_comment
+
+
+def create_internal_doxygen_comment(message_id):
+ """
+ Creates internal dOxygen comment with given data
+
+ :param message_id: Id of message for which's formatting function comment should be created
+ :return:
+ """
+ out_comment = "/**\n" + \
+ " * @internal\n" + \
+ " * " + create_function_brief(message_id) + "\n" + \
+ " *\n" + \
+ " * See header file for more information\n" + \
+ " * @endinternal\n" + \
+ " */\n"
+
+ return out_comment
+
+
+def create_message_function_head(message_id):
+ """
+ Create header like nlohmann::json <msg_id_with_first_letter_lowercase>(...)
+
+ :param message_id: Id of message for which function header should be created
+ :return: Created function header
+ """
+ function_name = message_id[:1].lower() + message_id[1:]
+ function_arguments = ""
+
+ if MESSAGE_REGISTRY["Messages"][message_id]["NumberOfArgs"] != 0:
+ param_types = MESSAGE_REGISTRY["Messages"][message_id]["ParamTypes"]
+ params = []
+
+ for param_idx in range(0, len(param_types)):
+ params.append("const " + PARAM_TYPE_TO_CPP_TYPE[param_types[param_idx]] + "& arg" + str(param_idx + 1))
+
+ function_arguments = ', '.join(params)
+
+ return "nlohmann::json " + function_name + "(" + function_arguments + ")"
+
+
+def create_message_function_body(message_id, is_complex):
+ """
+ Creates format function body for message without parameters
+
+ :param message_id: Id of message for which format function body should be created
+ :return: Format function body for given message
+ """
+ message_data = MESSAGE_REGISTRY["Messages"][message_id]
+ message_body = message_data["Message"]
+
+ if is_complex:
+ param_types = message_data["ParamTypes"]
+
+ for param_idx in range(0, len(param_types)):
+ formatting_str = '%' + str(param_idx + 1)
+ formatting_arg = PARAM_TYPE_TO_FORMATTING_ARG[param_types[param_idx]].format(str(param_idx + 1))
+
+ message_body = message_body.replace(formatting_str, '" + ' + formatting_arg + ' + "');
+
+ body = ' {\n' + \
+ INDENT + 'return nlohmann::json{' + '\n' + \
+ INDENT + INDENT + '{"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},' + '\n' + \
+ INDENT + INDENT + '{"MessageId", "' + MESSAGE_REGISTRY["Id"] + "." + message_id + '"},' + '\n' + \
+ INDENT + INDENT + '{"Message", "' + message_body + '"},' + '\n' + \
+ INDENT + INDENT + '{"Severity", "' + message_data["Severity"] + '"},' + '\n' + \
+ INDENT + INDENT + '{"Resolution", "' + message_data["Resolution"] + '"}' + '\n' + \
+ INDENT + '};' + '\n' + \
+ '}'
+
+ return body
+
+
+def process_message(message_id):
+ """
+ Processes given message and adds created definitions to appropriate globals
+ - Creates MessageId enumeration value for given message
+ - Creates macro to use given message in format:
+ a) For argument-less messages - FORMAT_REDFISH_MESSAGE_<message_id>
+ b) For parametrized messages - FORMAT_REDFISH_MESSAGE_<message_id>(arg1, arg2, ...)
+ - Creates structure definition for message
+
+ :param message_id: ID of message that should be processed
+
+ :return: None
+ """
+ if verify_message(message_id):
+ foo_head = create_message_function_head(message_id)
+ foo_body = create_message_function_body(message_id,
+ MESSAGE_REGISTRY["Messages"][message_id]["NumberOfArgs"] != 0)
+
+ # For header file
+ full_doxy_comment = create_full_doxygen_comment(message_id)
+
+ FORMATTING_FUNCTIONS_DECLARATIONS.append(full_doxy_comment + foo_head + ';\n')
+
+ # For source file
+ internal_doxy_comment = create_internal_doxygen_comment(message_id)
+
+ format_foo_impl = internal_doxy_comment + foo_head + foo_body
+
+ FORMATTING_FUNCTIONS_IMPLEMENTATIONS.append(format_foo_impl)
+ else:
+ print message_id + " is not correctly defined! It will be omitted"
+
+
+def process_messages():
+ """
+ Iterates through all messages and processes each of them
+
+ :return: None
+ """
+ for message_id in MESSAGE_REGISTRY[u'Messages']:
+ process_message(message_id)
+
+
+def prepare_declarations():
+ return '\n'.join(FORMATTING_FUNCTIONS_DECLARATIONS)
+
+
+def prepare_implementations():
+ return '\n\n'.join(FORMATTING_FUNCTIONS_IMPLEMENTATIONS)
+
+
+def generate_error_messages_cpp():
+ """
+ Replaces placeholders inside source file with generated data
+
+ :return: None
+ """
+ with open(SCRIPT_PATH + "/" + ERROR_MESSAGES_TARGET_FILENAME + ".cpp.in", 'r') as source_file_template:
+ file_contents = source_file_template.read()
+
+ file_contents = file_contents.replace("/*<<<<<<AUTOGENERATED_FUNCTIONS_IMPLEMENTATIONS>>>>>>*/",
+ prepare_implementations())
+
+ with open(OUT_SOURCE_PATH, "w") as source_file_target:
+ source_file_target.write(file_contents)
+
+
+def generate_error_messages_hpp():
+ """
+ Replaces placeholders inside header file with generated data
+
+ :return: None
+ """
+ with open(SCRIPT_PATH + "/" + ERROR_MESSAGES_TARGET_FILENAME + ".hpp.in", 'r') as header_file_template:
+ file_contents = header_file_template.read()
+
+ # Add definitions
+ file_contents = file_contents.replace("/*<<<<<<AUTOGENERATED_FUNCTIONS_DECLARATIONS>>>>>>*/",
+ prepare_declarations())
+
+ with open(OUT_HEADER_PATH, "w") as header_file_target:
+ header_file_target.write(file_contents)
+
+
+if __name__ == "__main__":
+ if len(sys.argv) < 2:
+ sys.exit("Not enough arguments. Required syntax is:\n error_messages.py <autogen_dir> <messages_json>")
+ else:
+ AUTOGEN_PATH = sys.argv[1]
+ MESSAGE_REGISTRY_JSON_PATH = sys.argv[2]
+
+ MESSAGE_REGISTRY = json.load(open(MESSAGE_REGISTRY_JSON_PATH))
+
+ OUT_HEADER_PATH = AUTOGEN_PATH + "/" + ERROR_MESSAGES_TARGET_FILENAME + ".hpp"
+ OUT_SOURCE_PATH = AUTOGEN_PATH + "/" + ERROR_MESSAGES_TARGET_FILENAME + ".cpp"
+
+ # Make sure that files directory exists
+ if not os.path.exists(AUTOGEN_PATH):
+ os.makedirs(AUTOGEN_PATH)
+
+ # Process found messages
+ process_messages()
+
+ # Generate files
+ generate_error_messages_cpp()
+ generate_error_messages_hpp()
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
new file mode 100644
index 0000000..7fd532e
--- /dev/null
+++ b/redfish-core/src/error_messages.cpp
@@ -0,0 +1,1159 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+#include <error_messages.hpp>
+#include <crow/logging.h>
+
+namespace redfish {
+
+namespace messages {
+
+void addMessageToErrorJson(nlohmann::json& target,
+ const nlohmann::json& message) {
+ auto& error = target["error"];
+
+ // If this is the first error message, fill in the information from the first
+ // error message to the top level struct
+ if (!error.is_object()) {
+ auto message_id_iterator = message.find("MessageId");
+ if (message_id_iterator == message.end()) {
+ CROW_LOG_CRITICAL << "Attempt to add error message without MessageId";
+ return;
+ }
+
+ auto message_field_iterator = message.find("Message");
+ if (message_field_iterator == message.end()) {
+ CROW_LOG_CRITICAL << "Attempt to add error message without Message";
+ return;
+ }
+ // clang-format off
+ error = {
+ {"code", *message_id_iterator},
+ {"message", *message_field_iterator}
+ };
+ // clang-format on
+ } else {
+ // More than 1 error occurred, so the message has to be generic
+ error["code"] = std::string(MESSAGE_VERSION_PREFIX) + "GeneralError";
+ error["message"] =
+ "A general error has occurred. See ExtendedInfo for more"
+ "information.";
+ }
+
+ // This check could technically be done in in the default construction
+ // branch above, but because we need the pointer to the extended info field
+ // anyway, it's more efficient to do it here.
+ auto& extended_info = error[messages::MESSAGE_ANNOTATION];
+ if (!extended_info.is_array()) {
+ extended_info = nlohmann::json::array();
+ }
+
+ extended_info.push_back(message);
+}
+
+void addMessageToJsonRoot(nlohmann::json& target,
+ const nlohmann::json& message) {
+ if (!target[messages::MESSAGE_ANNOTATION].is_array()) {
+ // Force object to be an array
+ target[messages::MESSAGE_ANNOTATION] = nlohmann::json::array();
+ }
+
+ target[messages::MESSAGE_ANNOTATION].push_back(message);
+}
+
+void addMessageToJson(nlohmann::json& target, const nlohmann::json& message,
+ const std::string& fieldPath) {
+ nlohmann::json_pointer extendedInfo(fieldPath + messages::MESSAGE_ANNOTATION);
+
+ if (!target[extendedInfo].is_array()) {
+ // Force object to be an array
+ target[extendedInfo] = nlohmann::json::array();
+ }
+
+ // Object exists and it is an array so we can just push in the message
+ target[extendedInfo].push_back(message);
+}
+
+/*********************************
+ * AUTOGENERATED FUNCTIONS START *
+ *********************************/
+
+/**
+ * @internal
+ * @brief Formats ResourceInUse message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json resourceInUse() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ResourceInUse"},
+ {"Message",
+ "The change to the requested resource failed because the resource is in "
+ "use or in transition."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Remove the condition and resubmit the request if the operation "
+ "failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats MalformedJSON message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json malformedJSON() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.MalformedJSON"},
+ {"Message",
+ "The request body submitted was malformed JSON and could not be parsed "
+ "by the receiving service."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Ensure that the request body is valid JSON and resubmit the request."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ResourceMissingAtURI message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json resourceMissingAtURI(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ResourceMissingAtURI"},
+ {"Message", "The resource at the URI " + arg1 + " was not found."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Place a valid resource at the URI or correct the URI and resubmit the "
+ "request."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ActionParameterValueFormatError message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json actionParameterValueFormatError(const std::string& arg1,
+ const std::string& arg2,
+ const std::string& arg3) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ActionParameterValueFormatError"},
+ {"Message",
+ "The value " + arg1 + " for the parameter " + arg2 + " in the action " +
+ arg3 + " is of a different format than the parameter can accept."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Correct the value for the parameter in the request body and resubmit "
+ "the request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats InternalError message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json internalError() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.InternalError"},
+ {"Message",
+ "The request failed due to an internal service error. The service is "
+ "still operational."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Resubmit the request. If the problem persists, consider resetting the "
+ "service."}};
+}
+
+/**
+ * @internal
+ * @brief Formats UnrecognizedRequestBody message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json unrecognizedRequestBody() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.UnrecognizedRequestBody"},
+ {"Message",
+ "The service detected a malformed request body that it was unable to "
+ "interpret."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Correct the request body and resubmit the request if it failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ResourceAtUriUnauthorized message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json resourceAtUriUnauthorized(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ResourceAtUriUnauthorized"},
+ {"Message", "While accessing the resource at " + arg1 +
+ ", the service received an authorization error " + arg2 +
+ "."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Ensure that the appropriate access is provided for the service in "
+ "order for it to access the URI."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ActionParameterUnknown message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json actionParameterUnknown(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ActionParameterUnknown"},
+ {"Message", "The action " + arg1 +
+ " was submitted with the invalid parameter " + arg2 +
+ "."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Correct the invalid parameter and resubmit the request if the "
+ "operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ResourceCannotBeDeleted message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json resourceCannotBeDeleted() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ResourceCannotBeDeleted"},
+ {"Message",
+ "The delete request failed because the resource requested cannot be "
+ "deleted."},
+ {"Severity", "Critical"},
+ {"Resolution", "Do not attempt to delete a non-deletable resource."}};
+}
+
+/**
+ * @internal
+ * @brief Formats PropertyDuplicate message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json propertyDuplicate(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.PropertyDuplicate"},
+ {"Message", "The property " + arg1 + " was duplicated in the request."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Remove the duplicate property from the request body and resubmit the "
+ "request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ServiceTemporarilyUnavailable message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ServiceTemporarilyUnavailable"},
+ {"Message", "The service is temporarily unavailable. Retry in " + arg1 +
+ " seconds."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Wait for the indicated retry duration and retry the operation."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ResourceAlreadyExists message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json resourceAlreadyExists(const std::string& arg1,
+ const std::string& arg2,
+ const std::string& arg3) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ResourceAlreadyExists"},
+ {"Message", "The requested resource of type " + arg1 +
+ " with the property " + arg2 + " with the value " + arg3 +
+ " already exists."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Do not repeat the create operation as the resource has already been "
+ "created."}};
+}
+
+/**
+ * @internal
+ * @brief Formats AccountForSessionNoLongerExists message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json accountForSessionNoLongerExists() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.AccountForSessionNoLongerExists"},
+ {"Message",
+ "The account for the current session has been removed, thus the current "
+ "session has been removed as well."},
+ {"Severity", "OK"},
+ {"Resolution", "Attempt to connect with a valid account."}};
+}
+
+/**
+ * @internal
+ * @brief Formats CreateFailedMissingReqProperties message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json createFailedMissingReqProperties(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.CreateFailedMissingReqProperties"},
+ {"Message", "The create operation failed because the required property " +
+ arg1 + " was missing from the request."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Correct the body to include the required property with a valid value "
+ "and resubmit the request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats PropertyValueFormatError message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json propertyValueFormatError(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.PropertyValueFormatError"},
+ {"Message",
+ "The value " + arg1 + " for the property " + arg2 +
+ " is of a different format than the property can accept."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Correct the value for the property in the request body and resubmit "
+ "the request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats PropertyValueNotInList message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json propertyValueNotInList(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.PropertyValueNotInList"},
+ {"Message", "The value " + arg1 + " for the property " + arg2 +
+ " is not in the list of acceptable values."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Choose a value from the enumeration list that the implementation can "
+ "support and resubmit the request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ResourceAtUriInUnknownFormat message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json resourceAtUriInUnknownFormat(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ResourceAtUriInUnknownFormat"},
+ {"Message", "The resource at " + arg1 +
+ " is in a format not recognized by the service."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Place an image or resource or file that is recognized by the service "
+ "at the URI."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ServiceInUnknownState message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json serviceInUnknownState() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ServiceInUnknownState"},
+ {"Message",
+ "The operation failed because the service is in an unknown state and "
+ "can no longer take incoming requests."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Restart the service and resubmit the request if the operation "
+ "failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats EventSubscriptionLimitExceeded message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json eventSubscriptionLimitExceeded() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.EventSubscriptionLimitExceeded"},
+ {"Message",
+ "The event subscription failed due to the number of simultaneous "
+ "subscriptions exceeding the limit of the implementation."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Reduce the number of other subscriptions before trying to establish "
+ "the event subscription or increase the limit of simultaneous "
+ "subscriptions (if supported)."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ActionParameterMissing message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json actionParameterMissing(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ActionParameterMissing"},
+ {"Message", "The action " + arg1 + " requires the parameter " + arg2 +
+ " to be present in the request body."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Supply the action with the required parameter in the request body when "
+ "the request is resubmitted."}};
+}
+
+/**
+ * @internal
+ * @brief Formats StringValueTooLong message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json stringValueTooLong(const std::string& arg1, const int& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.StringValueTooLong"},
+ {"Message", "The string " + arg1 + " exceeds the length limit " +
+ std::to_string(arg2) + "."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Resubmit the request with an appropriate string length."}};
+}
+
+/**
+ * @internal
+ * @brief Formats PropertyValueTypeError message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json propertyValueTypeError(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.PropertyValueTypeError"},
+ {"Message", "The value " + arg1 + " for the property " + arg2 +
+ " is of a different type than the property can accept."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Correct the value for the property in the request body and resubmit "
+ "the request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ResourceNotFound message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json resourceNotFound(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ResourceNotFound"},
+ {"Message", "The requested resource of type " + arg1 + " named " + arg2 +
+ " was not found."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Provide a valid resource identifier and resubmit the request."}};
+}
+
+/**
+ * @internal
+ * @brief Formats CouldNotEstablishConnection message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json couldNotEstablishConnection(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.CouldNotEstablishConnection"},
+ {"Message", "The service failed to establish a connection with the URI " +
+ arg1 + "."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Ensure that the URI contains a valid and reachable node name, protocol "
+ "information and other URI components."}};
+}
+
+/**
+ * @internal
+ * @brief Formats PropertyNotWritable message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json propertyNotWritable(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.PropertyNotWritable"},
+ {"Message",
+ "The property " + arg1 +
+ " is a read only property and cannot be assigned a value."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Remove the property from the request body and resubmit the request if "
+ "the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats QueryParameterValueTypeError message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json queryParameterValueTypeError(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.QueryParameterValueTypeError"},
+ {"Message", "The value " + arg1 + " for the query parameter " + arg2 +
+ " is of a different type than the parameter can accept."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Correct the value for the query parameter in the request and resubmit "
+ "the request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ServiceShuttingDown message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json serviceShuttingDown() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ServiceShuttingDown"},
+ {"Message",
+ "The operation failed because the service is shutting down and can no "
+ "longer take incoming requests."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "When the service becomes available, resubmit the request if the "
+ "operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ActionParameterDuplicate message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json actionParameterDuplicate(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ActionParameterDuplicate"},
+ {"Message",
+ "The action " + arg1 +
+ " was submitted with more than one value for the parameter " + arg2 +
+ "."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Resubmit the action with only one instance of the parameter in the "
+ "request body if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ActionParameterNotSupported message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json actionParameterNotSupported(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ActionParameterNotSupported"},
+ {"Message", "The parameter " + arg1 + " for the action " + arg2 +
+ " is not supported on the target resource."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Remove the parameter supplied and resubmit the request if the "
+ "operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats SourceDoesNotSupportProtocol message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json sourceDoesNotSupportProtocol(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.SourceDoesNotSupportProtocol"},
+ {"Message", "The other end of the connection at " + arg1 +
+ " does not support the specified protocol " + arg2 + "."},
+ {"Severity", "Critical"},
+ {"Resolution", "Change protocols or URIs. "}};
+}
+
+/**
+ * @internal
+ * @brief Formats AccountRemoved message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json accountRemoved() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.AccountRemoved"},
+ {"Message", "The account was successfully removed."},
+ {"Severity", "OK"},
+ {"Resolution", "No resolution is required."}};
+}
+
+/**
+ * @internal
+ * @brief Formats AccessDenied message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json accessDenied(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.AccessDenied"},
+ {"Message", "While attempting to establish a connection to " + arg1 +
+ ", the service denied access."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Attempt to ensure that the URI is correct and that the service has the "
+ "appropriate credentials."}};
+}
+
+/**
+ * @internal
+ * @brief Formats QueryNotSupported message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json queryNotSupported() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.QueryNotSupported"},
+ {"Message", "Querying is not supported by the implementation."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Remove the query parameters and resubmit the request if the operation "
+ "failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats CreateLimitReachedForResource message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json createLimitReachedForResource() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.CreateLimitReachedForResource"},
+ {"Message",
+ "The create operation failed because the resource has reached the limit "
+ "of possible resources."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Either delete resources and resubmit the request if the operation "
+ "failed or do not resubmit the request."}};
+}
+
+/**
+ * @internal
+ * @brief Formats GeneralError message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json generalError() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.GeneralError"},
+ {"Message",
+ "A general error has occurred. See ExtendedInfo for more information."},
+ {"Severity", "Critical"},
+ {"Resolution", "See ExtendedInfo for more information."}};
+}
+
+/**
+ * @internal
+ * @brief Formats Success message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json success() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.Success"},
+ {"Message", "Successfully Completed Request"},
+ {"Severity", "OK"},
+ {"Resolution", "None"}};
+}
+
+/**
+ * @internal
+ * @brief Formats Created message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json created() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.Created"},
+ {"Message", "The resource has been created successfully"},
+ {"Severity", "OK"},
+ {"Resolution", "None"}};
+}
+
+/**
+ * @internal
+ * @brief Formats PropertyUnknown message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json propertyUnknown(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.PropertyUnknown"},
+ {"Message",
+ "The property " + arg1 +
+ " is not in the list of valid properties for the resource."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Remove the unknown property from the request body and resubmit the "
+ "request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats NoValidSession message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json noValidSession() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.NoValidSession"},
+ {"Message",
+ "There is no valid session established with the implementation."},
+ {"Severity", "Critical"},
+ {"Resolution", "Establish as session before attempting any operations."}};
+}
+
+/**
+ * @internal
+ * @brief Formats InvalidObject message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json invalidObject(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.InvalidObject"},
+ {"Message", "The object at " + arg1 + " is invalid."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Either the object is malformed or the URI is not correct. Correct the "
+ "condition and resubmit the request if it failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ResourceInStandby message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json resourceInStandby() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ResourceInStandby"},
+ {"Message",
+ "The request could not be performed because the resource is in "
+ "standby."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Ensure that the resource is in the correct power state and resubmit "
+ "the request."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ActionParameterValueTypeError message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json actionParameterValueTypeError(const std::string& arg1,
+ const std::string& arg2,
+ const std::string& arg3) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ActionParameterValueTypeError"},
+ {"Message", "The value " + arg1 + " for the parameter " + arg2 +
+ " in the action " + arg3 +
+ " is of a different type than the parameter can accept."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Correct the value for the parameter in the request body and resubmit "
+ "the request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats SessionLimitExceeded message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json sessionLimitExceeded() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.SessionLimitExceeded"},
+ {"Message",
+ "The session establishment failed due to the number of simultaneous "
+ "sessions exceeding the limit of the implementation."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Reduce the number of other sessions before trying to establish the "
+ "session or increase the limit of simultaneous sessions (if "
+ "supported)."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ActionNotSupported message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json actionNotSupported(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ActionNotSupported"},
+ {"Message", "The action " + arg1 + " is not supported by the resource."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "The action supplied cannot be resubmitted to the implementation. "
+ "Perhaps the action was invalid, the wrong resource was the target or "
+ "the implementation documentation may be of assistance."}};
+}
+
+/**
+ * @internal
+ * @brief Formats InvalidIndex message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json invalidIndex(const int& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.InvalidIndex"},
+ {"Message", "The Index " + std::to_string(arg1) +
+ " is not a valid offset into the array."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Verify the index value provided is within the bounds of the array."}};
+}
+
+/**
+ * @internal
+ * @brief Formats EmptyJSON message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json emptyJSON() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.EmptyJSON"},
+ {"Message",
+ "The request body submitted contained an empty JSON object and the "
+ "service is unable to process it."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Add properties in the JSON object and resubmit the request."}};
+}
+
+/**
+ * @internal
+ * @brief Formats QueryNotSupportedOnResource message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json queryNotSupportedOnResource() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.QueryNotSupportedOnResource"},
+ {"Message", "Querying is not supported on the requested resource."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Remove the query parameters and resubmit the request if the operation "
+ "failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats InsufficientPrivilege message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json insufficientPrivilege() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.InsufficientPrivilege"},
+ {"Message",
+ "There are insufficient privileges for the account or credentials "
+ "associated with the current session to perform the requested "
+ "operation."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Either abandon the operation or change the associated access rights "
+ "and resubmit the request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats PropertyValueModified message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json propertyValueModified(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.PropertyValueModified"},
+ {"Message", "The property " + arg1 + " was assigned the value " + arg2 +
+ " due to modification by the service."},
+ {"Severity", "Warning"},
+ {"Resolution", "No resolution is required."}};
+}
+
+/**
+ * @internal
+ * @brief Formats AccountNotModified message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json accountNotModified() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.AccountNotModified"},
+ {"Message", "The account modification request failed."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "The modification may have failed due to permission issues or issues "
+ "with the request body."}};
+}
+
+/**
+ * @internal
+ * @brief Formats QueryParameterValueFormatError message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json queryParameterValueFormatError(const std::string& arg1,
+ const std::string& arg2) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.QueryParameterValueFormatError"},
+ {"Message",
+ "The value " + arg1 + " for the parameter " + arg2 +
+ " is of a different format than the parameter can accept."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Correct the value for the query parameter in the request and resubmit "
+ "the request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats PropertyMissing message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json propertyMissing(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.PropertyMissing"},
+ {"Message",
+ "The property " + arg1 +
+ " is a required property and must be included in the request."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Ensure that the property is in the request body and has a valid value "
+ "and resubmit the request if the operation failed."}};
+}
+
+/**
+ * @internal
+ * @brief Formats ResourceExhaustion message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json resourceExhaustion(const std::string& arg1) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.ResourceExhaustion"},
+ {"Message", "The resource " + arg1 + " was unable to satisfy the request "
+ "due to unavailability of "
+ "resources."},
+ {"Severity", "Critical"},
+ {"Resolution",
+ "Ensure that the resources are available and resubmit the request."}};
+}
+
+/**
+ * @internal
+ * @brief Formats AccountModified message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json accountModified() {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.AccountModified"},
+ {"Message", "The account was successfully modified."},
+ {"Severity", "OK"},
+ {"Resolution", "No resolution is required."}};
+}
+
+/**
+ * @internal
+ * @brief Formats QueryParameterOutOfRange message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json queryParameterOutOfRange(const std::string& arg1,
+ const std::string& arg2,
+ const std::string& arg3) {
+ return nlohmann::json{
+ {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
+ {"MessageId", "Base.1.2.0.QueryParameterOutOfRange"},
+ {"Message", "The value " + arg1 + " for the query parameter " + arg2 +
+ " is out of range " + arg3 + "."},
+ {"Severity", "Warning"},
+ {"Resolution",
+ "Reduce the value for the query parameter to a value that is within "
+ "range, such as a start or count value that is within bounds of the "
+ "number of resources in a collection or a page that is within the range "
+ "of valid pages."}};
+}
+
+/*********************************
+ * AUTOGENERATED FUNCTIONS END *
+ *********************************/
+
+} // namespace messages
+
+} // namespace redifsh