error message: add insufficientStorage
In the spec, when a response is too large, we need a error messsage to
represent such error. The corresponding error is 507 Insufficient
Storage, which is already in the base registry.
This commit adds that utility to error messages library.
Reference: redfish spec Section 7.3.2
```
If a service cannot return the payload due to its size, it shall return
the HTTP 507 Insufficient Storage status code.
```
Tested: code compies.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I1fe840f015b3d67fa2092d1d3a1f8c3fcbc2c438
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index d9f571c..1a5b941 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -1018,6 +1018,15 @@
void invalidUpload(crow::Response& res, std::string_view arg1,
std::string_view arg2);
+/**
+ * @brief Formats InsufficientStorage message into JSON
+ * Message body: "Insufficent storage or memory available to complete the
+ * request."
+ * @returns Message InsufficientStorage formatted to JSON */
+nlohmann::json insufficientStorage();
+
+void insufficientStorage(crow::Response& res);
+
} // namespace messages
} // namespace redfish
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index cdaced6..654353d 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -1673,6 +1673,24 @@
/**
* @internal
+ * @brief Formats InsufficientStorage message into JSON
+ *
+ * See header file for more information
+ * @endinternal
+ */
+nlohmann::json insufficientStorage()
+{
+ return getLog(redfish::registries::base::Index::insufficientStorage, {});
+}
+
+void insufficientStorage(crow::Response& res)
+{
+ res.result(boost::beast::http::status::insufficient_storage);
+ addMessageToErrorJson(res.jsonValue, insufficientStorage());
+}
+
+/**
+ * @internal
* @brief Formats Invalid File message into JSON
*
* See header file for more information
@@ -1693,6 +1711,7 @@
{"MessageSeverity", "Warning"},
{"Resolution", "None."}};
}
+
} // namespace messages
} // namespace redfish