1f4c4dcf4SKowalski, Kamil /* 2f4c4dcf4SKowalski, Kamil // Copyright (c) 2018 Intel Corporation 3f4c4dcf4SKowalski, Kamil // 4f4c4dcf4SKowalski, Kamil // Licensed under the Apache License, Version 2.0 (the "License"); 5f4c4dcf4SKowalski, Kamil // you may not use this file except in compliance with the License. 6f4c4dcf4SKowalski, Kamil // You may obtain a copy of the License at 7f4c4dcf4SKowalski, Kamil // 8f4c4dcf4SKowalski, Kamil // http://www.apache.org/licenses/LICENSE-2.0 9f4c4dcf4SKowalski, Kamil // 10f4c4dcf4SKowalski, Kamil // Unless required by applicable law or agreed to in writing, software 11f4c4dcf4SKowalski, Kamil // distributed under the License is distributed on an "AS IS" BASIS, 12f4c4dcf4SKowalski, Kamil // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f4c4dcf4SKowalski, Kamil // See the License for the specific language governing permissions and 14f4c4dcf4SKowalski, Kamil // limitations under the License. 15f4c4dcf4SKowalski, Kamil */ 16c94ad49bSEd Tanous #include <logging.h> 17f4c4dcf4SKowalski, Kamil 181abe55efSEd Tanous #include <error_messages.hpp> 19f4c4dcf4SKowalski, Kamil 201abe55efSEd Tanous namespace redfish 211abe55efSEd Tanous { 221abe55efSEd Tanous 231abe55efSEd Tanous namespace messages 241abe55efSEd Tanous { 25f4c4dcf4SKowalski, Kamil 26f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target, 271abe55efSEd Tanous const nlohmann::json& message) 281abe55efSEd Tanous { 29f4c4dcf4SKowalski, Kamil auto& error = target["error"]; 30f4c4dcf4SKowalski, Kamil 311abe55efSEd Tanous // If this is the first error message, fill in the information from the 321abe55efSEd Tanous // first error message to the top level struct 331abe55efSEd Tanous if (!error.is_object()) 341abe55efSEd Tanous { 35c074230bSJason M. Bills auto messageIdIterator = message.find("MessageId"); 36c074230bSJason M. Bills if (messageIdIterator == message.end()) 371abe55efSEd Tanous { 381abe55efSEd Tanous BMCWEB_LOG_CRITICAL 391abe55efSEd Tanous << "Attempt to add error message without MessageId"; 40f4c4dcf4SKowalski, Kamil return; 41f4c4dcf4SKowalski, Kamil } 42f4c4dcf4SKowalski, Kamil 43c074230bSJason M. Bills auto messageFieldIterator = message.find("Message"); 44c074230bSJason M. Bills if (messageFieldIterator == message.end()) 451abe55efSEd Tanous { 461abe55efSEd Tanous BMCWEB_LOG_CRITICAL 471abe55efSEd Tanous << "Attempt to add error message without Message"; 48f4c4dcf4SKowalski, Kamil return; 49f4c4dcf4SKowalski, Kamil } 50c21055aaSEd Tanous error = {{"code", *messageIdIterator}, 51c21055aaSEd Tanous {"message", *messageFieldIterator}}; 521abe55efSEd Tanous } 531abe55efSEd Tanous else 541abe55efSEd Tanous { 55f4c4dcf4SKowalski, Kamil // More than 1 error occurred, so the message has to be generic 5655c7b7a2SEd Tanous error["code"] = std::string(messageVersionPrefix) + "GeneralError"; 57cc9139ecSJason M. Bills error["message"] = "A general error has occurred. See Resolution for " 58cc9139ecSJason M. Bills "information on how to resolve the error."; 59f4c4dcf4SKowalski, Kamil } 60f4c4dcf4SKowalski, Kamil 61f4c4dcf4SKowalski, Kamil // This check could technically be done in in the default construction 62f4c4dcf4SKowalski, Kamil // branch above, but because we need the pointer to the extended info field 63f4c4dcf4SKowalski, Kamil // anyway, it's more efficient to do it here. 64c074230bSJason M. Bills auto& extendedInfo = error[messages::messageAnnotation]; 65c074230bSJason M. Bills if (!extendedInfo.is_array()) 661abe55efSEd Tanous { 67c074230bSJason M. Bills extendedInfo = nlohmann::json::array(); 68f4c4dcf4SKowalski, Kamil } 69f4c4dcf4SKowalski, Kamil 70c074230bSJason M. Bills extendedInfo.push_back(message); 71f4c4dcf4SKowalski, Kamil } 72f4c4dcf4SKowalski, Kamil 73f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target, 74f12894f8SJason M. Bills const nlohmann::json& message) 751abe55efSEd Tanous { 761abe55efSEd Tanous if (!target[messages::messageAnnotation].is_array()) 771abe55efSEd Tanous { 78f4c4dcf4SKowalski, Kamil // Force object to be an array 7955c7b7a2SEd Tanous target[messages::messageAnnotation] = nlohmann::json::array(); 80f4c4dcf4SKowalski, Kamil } 81f4c4dcf4SKowalski, Kamil 8255c7b7a2SEd Tanous target[messages::messageAnnotation].push_back(message); 83f4c4dcf4SKowalski, Kamil } 84f4c4dcf4SKowalski, Kamil 85f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target, 86f12894f8SJason M. Bills const nlohmann::json& message, 871abe55efSEd Tanous const std::string& fieldPath) 881abe55efSEd Tanous { 89a08b46ccSJason M. Bills std::string extendedInfo(fieldPath + messages::messageAnnotation); 90f4c4dcf4SKowalski, Kamil 911abe55efSEd Tanous if (!target[extendedInfo].is_array()) 921abe55efSEd Tanous { 93f4c4dcf4SKowalski, Kamil // Force object to be an array 94f4c4dcf4SKowalski, Kamil target[extendedInfo] = nlohmann::json::array(); 95f4c4dcf4SKowalski, Kamil } 96f4c4dcf4SKowalski, Kamil 97f4c4dcf4SKowalski, Kamil // Object exists and it is an array so we can just push in the message 98f4c4dcf4SKowalski, Kamil target[extendedInfo].push_back(message); 99f4c4dcf4SKowalski, Kamil } 100f4c4dcf4SKowalski, Kamil 101f4c4dcf4SKowalski, Kamil /** 102f4c4dcf4SKowalski, Kamil * @internal 103f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInUse message into JSON 104f4c4dcf4SKowalski, Kamil * 105f4c4dcf4SKowalski, Kamil * See header file for more information 106f4c4dcf4SKowalski, Kamil * @endinternal 107f4c4dcf4SKowalski, Kamil */ 108*b5c07418SJames Feist nlohmann::json resourceInUse(void) 1091abe55efSEd Tanous { 110*b5c07418SJames Feist return nlohmann::json{ 111f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 112cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceInUse"}, 11366ac2b8cSJason M. Bills {"Message", "The change to the requested resource failed because " 11466ac2b8cSJason M. Bills "the resource is in use or in transition."}, 11585659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 116f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 11766ac2b8cSJason M. Bills {"Resolution", "Remove the condition and resubmit the request if " 118*b5c07418SJames Feist "the operation failed."}}; 119*b5c07418SJames Feist } 120*b5c07418SJames Feist 121*b5c07418SJames Feist void resourceInUse(crow::Response& res) 122*b5c07418SJames Feist { 123*b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 124*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInUse()); 125f4c4dcf4SKowalski, Kamil } 126f4c4dcf4SKowalski, Kamil 127f4c4dcf4SKowalski, Kamil /** 128f4c4dcf4SKowalski, Kamil * @internal 129f4c4dcf4SKowalski, Kamil * @brief Formats MalformedJSON message into JSON 130f4c4dcf4SKowalski, Kamil * 131f4c4dcf4SKowalski, Kamil * See header file for more information 132f4c4dcf4SKowalski, Kamil * @endinternal 133f4c4dcf4SKowalski, Kamil */ 134*b5c07418SJames Feist nlohmann::json malformedJSON(void) 1351abe55efSEd Tanous { 136*b5c07418SJames Feist return nlohmann::json{ 137f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 138cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.MalformedJSON"}, 13966ac2b8cSJason M. Bills {"Message", "The request body submitted was malformed JSON and " 14066ac2b8cSJason M. Bills "could not be parsed by the receiving service."}, 14185659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 142f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1431abe55efSEd Tanous {"Resolution", "Ensure that the request body is valid JSON and " 144*b5c07418SJames Feist "resubmit the request."}}; 145*b5c07418SJames Feist } 146*b5c07418SJames Feist 147*b5c07418SJames Feist void malformedJSON(crow::Response& res) 148*b5c07418SJames Feist { 149*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 150*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, malformedJSON()); 151f4c4dcf4SKowalski, Kamil } 152f4c4dcf4SKowalski, Kamil 153f4c4dcf4SKowalski, Kamil /** 154f4c4dcf4SKowalski, Kamil * @internal 155f4c4dcf4SKowalski, Kamil * @brief Formats ResourceMissingAtURI message into JSON 156f4c4dcf4SKowalski, Kamil * 157f4c4dcf4SKowalski, Kamil * See header file for more information 158f4c4dcf4SKowalski, Kamil * @endinternal 159f4c4dcf4SKowalski, Kamil */ 160*b5c07418SJames Feist nlohmann::json resourceMissingAtURI(const std::string& arg1) 1611abe55efSEd Tanous { 162*b5c07418SJames Feist return nlohmann::json{ 163f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 164cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceMissingAtURI"}, 165f4c4dcf4SKowalski, Kamil {"Message", "The resource at the URI " + arg1 + " was not found."}, 16685659adfSJason M. Bills {"MessageArgs", {arg1}}, 167f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 16866ac2b8cSJason M. Bills {"Resolution", "Place a valid resource at the URI or correct the " 169*b5c07418SJames Feist "URI and resubmit the request."}}; 170*b5c07418SJames Feist } 171*b5c07418SJames Feist 172*b5c07418SJames Feist void resourceMissingAtURI(crow::Response& res, const std::string& arg1) 173*b5c07418SJames Feist { 174*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 175*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1)); 176f4c4dcf4SKowalski, Kamil } 177f4c4dcf4SKowalski, Kamil 178f4c4dcf4SKowalski, Kamil /** 179f4c4dcf4SKowalski, Kamil * @internal 180f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueFormatError message into JSON 181f4c4dcf4SKowalski, Kamil * 182f4c4dcf4SKowalski, Kamil * See header file for more information 183f4c4dcf4SKowalski, Kamil * @endinternal 184f4c4dcf4SKowalski, Kamil */ 185*b5c07418SJames Feist nlohmann::json actionParameterValueFormatError(const std::string& arg1, 186f4c4dcf4SKowalski, Kamil const std::string& arg2, 1871abe55efSEd Tanous const std::string& arg3) 1881abe55efSEd Tanous { 189*b5c07418SJames Feist return nlohmann::json{ 190f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 191cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionParameterValueFormatError"}, 192f4c4dcf4SKowalski, Kamil {"Message", 1931abe55efSEd Tanous "The value " + arg1 + " for the parameter " + arg2 + 1941abe55efSEd Tanous " in the action " + arg3 + 1951abe55efSEd Tanous " is of a different format than the parameter can accept."}, 19685659adfSJason M. Bills {"MessageArgs", {arg1, arg2, arg3}}, 197f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 19866ac2b8cSJason M. Bills {"Resolution", 19966ac2b8cSJason M. Bills "Correct the value for the parameter in the request body and " 200*b5c07418SJames Feist "resubmit the request if the operation failed."}}; 201*b5c07418SJames Feist } 202*b5c07418SJames Feist 203*b5c07418SJames Feist void actionParameterValueFormatError(crow::Response& res, 204*b5c07418SJames Feist const std::string& arg1, 205*b5c07418SJames Feist const std::string& arg2, 206*b5c07418SJames Feist const std::string& arg3) 207*b5c07418SJames Feist { 208*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 209*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 210*b5c07418SJames Feist actionParameterValueFormatError(arg1, arg2, arg3)); 211f4c4dcf4SKowalski, Kamil } 212f4c4dcf4SKowalski, Kamil 213f4c4dcf4SKowalski, Kamil /** 214f4c4dcf4SKowalski, Kamil * @internal 215f4c4dcf4SKowalski, Kamil * @brief Formats InternalError message into JSON 216f4c4dcf4SKowalski, Kamil * 217f4c4dcf4SKowalski, Kamil * See header file for more information 218f4c4dcf4SKowalski, Kamil * @endinternal 219f4c4dcf4SKowalski, Kamil */ 220*b5c07418SJames Feist nlohmann::json internalError(void) 2211abe55efSEd Tanous { 222*b5c07418SJames Feist return nlohmann::json{ 223f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 224cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.InternalError"}, 225f12894f8SJason M. Bills {"Message", "The request failed due to an internal service error. " 22666ac2b8cSJason M. Bills "The service is still operational."}, 22785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 228f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 2291abe55efSEd Tanous {"Resolution", "Resubmit the request. If the problem persists, " 230*b5c07418SJames Feist "consider resetting the service."}}; 231*b5c07418SJames Feist } 232*b5c07418SJames Feist 233*b5c07418SJames Feist void internalError(crow::Response& res) 234*b5c07418SJames Feist { 235*b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 236*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, internalError()); 237f12894f8SJason M. Bills } 238f12894f8SJason M. Bills 239f12894f8SJason M. Bills /** 240f12894f8SJason M. Bills * @internal 241f4c4dcf4SKowalski, Kamil * @brief Formats UnrecognizedRequestBody message into JSON 242f4c4dcf4SKowalski, Kamil * 243f4c4dcf4SKowalski, Kamil * See header file for more information 244f4c4dcf4SKowalski, Kamil * @endinternal 245f4c4dcf4SKowalski, Kamil */ 246*b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void) 2471abe55efSEd Tanous { 248*b5c07418SJames Feist return nlohmann::json{ 249f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 250cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.UnrecognizedRequestBody"}, 251f12894f8SJason M. Bills {"Message", "The service detected a malformed request body that it " 25266ac2b8cSJason M. Bills "was unable to interpret."}, 25385659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 254f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 255f12894f8SJason M. Bills {"Resolution", "Correct the request body and resubmit the request " 256*b5c07418SJames Feist "if it failed."}}; 257*b5c07418SJames Feist } 258*b5c07418SJames Feist 259*b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res) 260*b5c07418SJames Feist { 261*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 262*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody()); 263f4c4dcf4SKowalski, Kamil } 264f4c4dcf4SKowalski, Kamil 265f4c4dcf4SKowalski, Kamil /** 266f4c4dcf4SKowalski, Kamil * @internal 267f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriUnauthorized message into JSON 268f4c4dcf4SKowalski, Kamil * 269f4c4dcf4SKowalski, Kamil * See header file for more information 270f4c4dcf4SKowalski, Kamil * @endinternal 271f4c4dcf4SKowalski, Kamil */ 272*b5c07418SJames Feist nlohmann::json resourceAtUriUnauthorized(const std::string& arg1, 2731abe55efSEd Tanous const std::string& arg2) 2741abe55efSEd Tanous { 275*b5c07418SJames Feist return nlohmann::json{ 276f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 277cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceAtUriUnauthorized"}, 278f4c4dcf4SKowalski, Kamil {"Message", "While accessing the resource at " + arg1 + 2791abe55efSEd Tanous ", the service received an authorization error " + 2801abe55efSEd Tanous arg2 + "."}, 28185659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 282f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 283f12894f8SJason M. Bills {"Resolution", "Ensure that the appropriate access is provided for " 284*b5c07418SJames Feist "the service in order for it to access the URI."}}; 285*b5c07418SJames Feist } 286*b5c07418SJames Feist 287*b5c07418SJames Feist void resourceAtUriUnauthorized(crow::Response& res, const std::string& arg1, 288*b5c07418SJames Feist const std::string& arg2) 289*b5c07418SJames Feist { 290*b5c07418SJames Feist res.result(boost::beast::http::status::unauthorized); 291*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2)); 292f4c4dcf4SKowalski, Kamil } 293f4c4dcf4SKowalski, Kamil 294f4c4dcf4SKowalski, Kamil /** 295f4c4dcf4SKowalski, Kamil * @internal 296f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterUnknown message into JSON 297f4c4dcf4SKowalski, Kamil * 298f4c4dcf4SKowalski, Kamil * See header file for more information 299f4c4dcf4SKowalski, Kamil * @endinternal 300f4c4dcf4SKowalski, Kamil */ 301*b5c07418SJames Feist nlohmann::json actionParameterUnknown(const std::string& arg1, 302*b5c07418SJames Feist const std::string& arg2) 303*b5c07418SJames Feist { 304*b5c07418SJames Feist return nlohmann::json{ 305*b5c07418SJames Feist {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 306*b5c07418SJames Feist {"MessageId", "Base.1.4.0.ActionParameterUnknown"}, 307*b5c07418SJames Feist {"Message", "The action " + arg1 + 308*b5c07418SJames Feist " was submitted with the invalid parameter " + arg2 + 309*b5c07418SJames Feist "."}, 310*b5c07418SJames Feist {"MessageArgs", {arg1, arg2}}, 311*b5c07418SJames Feist {"Severity", "Warning"}, 312*b5c07418SJames Feist {"Resolution", "Correct the invalid parameter and resubmit the " 313*b5c07418SJames Feist "request if the operation failed."}}; 314*b5c07418SJames Feist } 315*b5c07418SJames Feist 316f12894f8SJason M. Bills void actionParameterUnknown(crow::Response& res, const std::string& arg1, 3171abe55efSEd Tanous const std::string& arg2) 3181abe55efSEd Tanous { 319f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 320*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2)); 321f4c4dcf4SKowalski, Kamil } 322f4c4dcf4SKowalski, Kamil 323f4c4dcf4SKowalski, Kamil /** 324f4c4dcf4SKowalski, Kamil * @internal 325f4c4dcf4SKowalski, Kamil * @brief Formats ResourceCannotBeDeleted message into JSON 326f4c4dcf4SKowalski, Kamil * 327f4c4dcf4SKowalski, Kamil * See header file for more information 328f4c4dcf4SKowalski, Kamil * @endinternal 329f4c4dcf4SKowalski, Kamil */ 330*b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void) 3311abe55efSEd Tanous { 332*b5c07418SJames Feist return nlohmann::json{ 333f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 334cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceCannotBeDeleted"}, 335f12894f8SJason M. Bills {"Message", "The delete request failed because the resource " 33666ac2b8cSJason M. Bills "requested cannot be deleted."}, 33785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 338f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 339*b5c07418SJames Feist {"Resolution", "Do not attempt to delete a non-deletable resource."}}; 340*b5c07418SJames Feist } 341*b5c07418SJames Feist 342*b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res) 343*b5c07418SJames Feist { 344*b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 345*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted()); 346f4c4dcf4SKowalski, Kamil } 347f4c4dcf4SKowalski, Kamil 348f4c4dcf4SKowalski, Kamil /** 349f4c4dcf4SKowalski, Kamil * @internal 350f4c4dcf4SKowalski, Kamil * @brief Formats PropertyDuplicate message into JSON 351f4c4dcf4SKowalski, Kamil * 352f4c4dcf4SKowalski, Kamil * See header file for more information 353f4c4dcf4SKowalski, Kamil * @endinternal 354f4c4dcf4SKowalski, Kamil */ 355*b5c07418SJames Feist nlohmann::json propertyDuplicate(const std::string& arg1) 3561abe55efSEd Tanous { 357*b5c07418SJames Feist return nlohmann::json{ 358f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 359cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyDuplicate"}, 360*b5c07418SJames Feist {"Message", "The property " + arg1 + " was duplicated in the request."}, 36185659adfSJason M. Bills {"MessageArgs", {arg1}}, 362f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 36366ac2b8cSJason M. Bills {"Resolution", 36466ac2b8cSJason M. Bills "Remove the duplicate property from the request body and resubmit " 365*b5c07418SJames Feist "the request if the operation failed."}}; 366*b5c07418SJames Feist } 367*b5c07418SJames Feist 368*b5c07418SJames Feist void propertyDuplicate(crow::Response& res, const std::string& arg1) 369*b5c07418SJames Feist { 370*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 371*b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1); 372f4c4dcf4SKowalski, Kamil } 373f4c4dcf4SKowalski, Kamil 374f4c4dcf4SKowalski, Kamil /** 375f4c4dcf4SKowalski, Kamil * @internal 376f4c4dcf4SKowalski, Kamil * @brief Formats ServiceTemporarilyUnavailable message into JSON 377f4c4dcf4SKowalski, Kamil * 378f4c4dcf4SKowalski, Kamil * See header file for more information 379f4c4dcf4SKowalski, Kamil * @endinternal 380f4c4dcf4SKowalski, Kamil */ 381*b5c07418SJames Feist nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1) 3821abe55efSEd Tanous { 383*b5c07418SJames Feist return nlohmann::json{ 384f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 385cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ServiceTemporarilyUnavailable"}, 3861abe55efSEd Tanous {"Message", "The service is temporarily unavailable. Retry in " + 3871abe55efSEd Tanous arg1 + " seconds."}, 38885659adfSJason M. Bills {"MessageArgs", {arg1}}, 389f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 390f12894f8SJason M. Bills {"Resolution", "Wait for the indicated retry duration and retry " 391*b5c07418SJames Feist "the operation."}}; 392*b5c07418SJames Feist } 393*b5c07418SJames Feist 394*b5c07418SJames Feist void serviceTemporarilyUnavailable(crow::Response& res, const std::string& arg1) 395*b5c07418SJames Feist { 396*b5c07418SJames Feist res.addHeader("Retry-After", arg1); 397*b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 398*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1)); 399f4c4dcf4SKowalski, Kamil } 400f4c4dcf4SKowalski, Kamil 401f4c4dcf4SKowalski, Kamil /** 402f4c4dcf4SKowalski, Kamil * @internal 403f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAlreadyExists message into JSON 404f4c4dcf4SKowalski, Kamil * 405f4c4dcf4SKowalski, Kamil * See header file for more information 406f4c4dcf4SKowalski, Kamil * @endinternal 407f4c4dcf4SKowalski, Kamil */ 408*b5c07418SJames Feist nlohmann::json resourceAlreadyExists(const std::string& arg1, 409*b5c07418SJames Feist const std::string& arg2, 410*b5c07418SJames Feist const std::string& arg3) 4111abe55efSEd Tanous { 412*b5c07418SJames Feist return nlohmann::json{ 413f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 414cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceAlreadyExists"}, 415f4c4dcf4SKowalski, Kamil {"Message", "The requested resource of type " + arg1 + 4161abe55efSEd Tanous " with the property " + arg2 + " with the value " + 4171abe55efSEd Tanous arg3 + " already exists."}, 41885659adfSJason M. Bills {"MessageArgs", {arg1, arg2, arg3}}, 419f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 420f12894f8SJason M. Bills {"Resolution", "Do not repeat the create operation as the resource " 421*b5c07418SJames Feist "has already been created."}}; 422*b5c07418SJames Feist } 423*b5c07418SJames Feist 424*b5c07418SJames Feist void resourceAlreadyExists(crow::Response& res, const std::string& arg1, 425*b5c07418SJames Feist const std::string& arg2, const std::string& arg3) 426*b5c07418SJames Feist { 427*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 428*b5c07418SJames Feist addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3), 429a08b46ccSJason M. Bills arg2); 430f4c4dcf4SKowalski, Kamil } 431f4c4dcf4SKowalski, Kamil 432f4c4dcf4SKowalski, Kamil /** 433f4c4dcf4SKowalski, Kamil * @internal 434f4c4dcf4SKowalski, Kamil * @brief Formats AccountForSessionNoLongerExists message into JSON 435f4c4dcf4SKowalski, Kamil * 436f4c4dcf4SKowalski, Kamil * See header file for more information 437f4c4dcf4SKowalski, Kamil * @endinternal 438f4c4dcf4SKowalski, Kamil */ 439*b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void) 4401abe55efSEd Tanous { 441*b5c07418SJames Feist return nlohmann::json{ 442f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 443cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.AccountForSessionNoLongerExists"}, 4441abe55efSEd Tanous {"Message", "The account for the current session has been removed, " 44566ac2b8cSJason M. Bills "thus the current session has been removed as well."}, 44685659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 447f4c4dcf4SKowalski, Kamil {"Severity", "OK"}, 448*b5c07418SJames Feist {"Resolution", "Attempt to connect with a valid account."}}; 449*b5c07418SJames Feist } 450*b5c07418SJames Feist 451*b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res) 452*b5c07418SJames Feist { 453*b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 454*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists()); 455f4c4dcf4SKowalski, Kamil } 456f4c4dcf4SKowalski, Kamil 457f4c4dcf4SKowalski, Kamil /** 458f4c4dcf4SKowalski, Kamil * @internal 459f4c4dcf4SKowalski, Kamil * @brief Formats CreateFailedMissingReqProperties message into JSON 460f4c4dcf4SKowalski, Kamil * 461f4c4dcf4SKowalski, Kamil * See header file for more information 462f4c4dcf4SKowalski, Kamil * @endinternal 463f4c4dcf4SKowalski, Kamil */ 464*b5c07418SJames Feist nlohmann::json createFailedMissingReqProperties(const std::string& arg1) 4651abe55efSEd Tanous { 466*b5c07418SJames Feist return nlohmann::json{ 467f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 468cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.CreateFailedMissingReqProperties"}, 4691abe55efSEd Tanous {"Message", 470*b5c07418SJames Feist "The create operation failed because the required property " + arg1 + 471*b5c07418SJames Feist " was missing from the request."}, 47285659adfSJason M. Bills {"MessageArgs", {arg1}}, 473f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 474f4c4dcf4SKowalski, Kamil {"Resolution", 475f12894f8SJason M. Bills "Correct the body to include the required property with a valid " 476*b5c07418SJames Feist "value and resubmit the request if the operation failed."}}; 477*b5c07418SJames Feist } 478*b5c07418SJames Feist 479*b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res, 480*b5c07418SJames Feist const std::string& arg1) 481*b5c07418SJames Feist { 482*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 483*b5c07418SJames Feist addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1), 484a08b46ccSJason M. Bills arg1); 485f12894f8SJason M. Bills } 486f12894f8SJason M. Bills 487f12894f8SJason M. Bills /** 488f12894f8SJason M. Bills * @internal 489f12894f8SJason M. Bills * @brief Formats PropertyValueFormatError message into JSON for the specified 490f12894f8SJason M. Bills * property 491f12894f8SJason M. Bills * 492f12894f8SJason M. Bills * See header file for more information 493f12894f8SJason M. Bills * @endinternal 494f12894f8SJason M. Bills */ 495*b5c07418SJames Feist nlohmann::json propertyValueFormatError(const std::string& arg1, 496a08b46ccSJason M. Bills const std::string& arg2) 497f12894f8SJason M. Bills { 498*b5c07418SJames Feist return nlohmann::json{ 499f12894f8SJason M. Bills {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 500cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyValueFormatError"}, 501f12894f8SJason M. Bills {"Message", 502f12894f8SJason M. Bills "The value " + arg1 + " for the property " + arg2 + 503f12894f8SJason M. Bills " is of a different format than the property can accept."}, 50485659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 505f12894f8SJason M. Bills {"Severity", "Warning"}, 50666ac2b8cSJason M. Bills {"Resolution", 50766ac2b8cSJason M. Bills "Correct the value for the property in the request body and " 508*b5c07418SJames Feist "resubmit the request if the operation failed."}}; 509*b5c07418SJames Feist } 510*b5c07418SJames Feist 511*b5c07418SJames Feist void propertyValueFormatError(crow::Response& res, const std::string& arg1, 512*b5c07418SJames Feist const std::string& arg2) 513*b5c07418SJames Feist { 514*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 515*b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2); 516f12894f8SJason M. Bills } 517f12894f8SJason M. Bills 518f12894f8SJason M. Bills /** 519f12894f8SJason M. Bills * @internal 520f12894f8SJason M. Bills * @brief Formats PropertyValueNotInList message into JSON for the specified 521f12894f8SJason M. Bills * property 522f12894f8SJason M. Bills * 523f12894f8SJason M. Bills * See header file for more information 524f12894f8SJason M. Bills * @endinternal 525f12894f8SJason M. Bills */ 526*b5c07418SJames Feist nlohmann::json propertyValueNotInList(const std::string& arg1, 527a08b46ccSJason M. Bills const std::string& arg2) 528f12894f8SJason M. Bills { 529*b5c07418SJames Feist return nlohmann::json{ 530f12894f8SJason M. Bills {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 531cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyValueNotInList"}, 532f12894f8SJason M. Bills {"Message", "The value " + arg1 + " for the property " + arg2 + 533f12894f8SJason M. Bills " is not in the list of acceptable values."}, 53485659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 535f12894f8SJason M. Bills {"Severity", "Warning"}, 536*b5c07418SJames Feist {"Resolution", "Choose a value from the enumeration list that " 537*b5c07418SJames Feist "the implementation " 538*b5c07418SJames Feist "can support and resubmit the request if the " 539*b5c07418SJames Feist "operation failed."}}; 540*b5c07418SJames Feist } 541*b5c07418SJames Feist 542*b5c07418SJames Feist void propertyValueNotInList(crow::Response& res, const std::string& arg1, 543*b5c07418SJames Feist const std::string& arg2) 544*b5c07418SJames Feist { 545*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 546*b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2); 547f4c4dcf4SKowalski, Kamil } 548f4c4dcf4SKowalski, Kamil 549f4c4dcf4SKowalski, Kamil /** 550f4c4dcf4SKowalski, Kamil * @internal 551f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriInUnknownFormat message into JSON 552f4c4dcf4SKowalski, Kamil * 553f4c4dcf4SKowalski, Kamil * See header file for more information 554f4c4dcf4SKowalski, Kamil * @endinternal 555f4c4dcf4SKowalski, Kamil */ 556*b5c07418SJames Feist nlohmann::json resourceAtUriInUnknownFormat(const std::string& arg1) 5571abe55efSEd Tanous { 558*b5c07418SJames Feist return nlohmann::json{ 559f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 560cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceAtUriInUnknownFormat"}, 561f4c4dcf4SKowalski, Kamil {"Message", "The resource at " + arg1 + 562f4c4dcf4SKowalski, Kamil " is in a format not recognized by the service."}, 56385659adfSJason M. Bills {"MessageArgs", {arg1}}, 564f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 565f12894f8SJason M. Bills {"Resolution", "Place an image or resource or file that is " 566*b5c07418SJames Feist "recognized by the service at the URI."}}; 567*b5c07418SJames Feist } 568*b5c07418SJames Feist 569*b5c07418SJames Feist void resourceAtUriInUnknownFormat(crow::Response& res, const std::string& arg1) 570*b5c07418SJames Feist { 571*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 572*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1)); 573f4c4dcf4SKowalski, Kamil } 574f4c4dcf4SKowalski, Kamil 575f4c4dcf4SKowalski, Kamil /** 576f4c4dcf4SKowalski, Kamil * @internal 577f4c4dcf4SKowalski, Kamil * @brief Formats ServiceInUnknownState message into JSON 578f4c4dcf4SKowalski, Kamil * 579f4c4dcf4SKowalski, Kamil * See header file for more information 580f4c4dcf4SKowalski, Kamil * @endinternal 581f4c4dcf4SKowalski, Kamil */ 582*b5c07418SJames Feist nlohmann::json serviceInUnknownState(void) 5831abe55efSEd Tanous { 584*b5c07418SJames Feist return nlohmann::json{ 585f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 586cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ServiceInUnknownState"}, 58766ac2b8cSJason M. Bills {"Message", 58866ac2b8cSJason M. Bills "The operation failed because the service is in an unknown state " 58966ac2b8cSJason M. Bills "and can no longer take incoming requests."}, 59085659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 591f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 59266ac2b8cSJason M. Bills {"Resolution", "Restart the service and resubmit the request if " 593*b5c07418SJames Feist "the operation failed."}}; 594*b5c07418SJames Feist } 595*b5c07418SJames Feist 596*b5c07418SJames Feist void serviceInUnknownState(crow::Response& res) 597*b5c07418SJames Feist { 598*b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 599*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceInUnknownState()); 600f4c4dcf4SKowalski, Kamil } 601f4c4dcf4SKowalski, Kamil 602f4c4dcf4SKowalski, Kamil /** 603f4c4dcf4SKowalski, Kamil * @internal 604f4c4dcf4SKowalski, Kamil * @brief Formats EventSubscriptionLimitExceeded message into JSON 605f4c4dcf4SKowalski, Kamil * 606f4c4dcf4SKowalski, Kamil * See header file for more information 607f4c4dcf4SKowalski, Kamil * @endinternal 608f4c4dcf4SKowalski, Kamil */ 609*b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void) 6101abe55efSEd Tanous { 611*b5c07418SJames Feist return nlohmann::json{ 612f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 613cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.EventSubscriptionLimitExceeded"}, 614f4c4dcf4SKowalski, Kamil {"Message", 615f4c4dcf4SKowalski, Kamil "The event subscription failed due to the number of simultaneous " 616f4c4dcf4SKowalski, Kamil "subscriptions exceeding the limit of the implementation."}, 61785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 618f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 619f4c4dcf4SKowalski, Kamil {"Resolution", 620f12894f8SJason M. Bills "Reduce the number of other subscriptions before trying to " 62166ac2b8cSJason M. Bills "establish the event subscription or increase the limit of " 622*b5c07418SJames Feist "simultaneous subscriptions (if supported)."}}; 623*b5c07418SJames Feist } 624*b5c07418SJames Feist 625*b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res) 626*b5c07418SJames Feist { 627*b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 628*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded()); 629f4c4dcf4SKowalski, Kamil } 630f4c4dcf4SKowalski, Kamil 631f4c4dcf4SKowalski, Kamil /** 632f4c4dcf4SKowalski, Kamil * @internal 633f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterMissing message into JSON 634f4c4dcf4SKowalski, Kamil * 635f4c4dcf4SKowalski, Kamil * See header file for more information 636f4c4dcf4SKowalski, Kamil * @endinternal 637f4c4dcf4SKowalski, Kamil */ 638*b5c07418SJames Feist nlohmann::json actionParameterMissing(const std::string& arg1, 6391abe55efSEd Tanous const std::string& arg2) 6401abe55efSEd Tanous { 641*b5c07418SJames Feist return nlohmann::json{ 642f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 643cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionParameterMissing"}, 644*b5c07418SJames Feist {"Message", "The action " + arg1 + " requires the parameter " + arg2 + 645*b5c07418SJames Feist " to be present in the request body."}, 64685659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 647f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 648f12894f8SJason M. Bills {"Resolution", 64966ac2b8cSJason M. Bills "Supply the action with the required parameter in the request " 650*b5c07418SJames Feist "body when the request is resubmitted."}}; 651*b5c07418SJames Feist } 652*b5c07418SJames Feist 653*b5c07418SJames Feist void actionParameterMissing(crow::Response& res, const std::string& arg1, 654*b5c07418SJames Feist const std::string& arg2) 655*b5c07418SJames Feist { 656*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 657*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2)); 658f4c4dcf4SKowalski, Kamil } 659f4c4dcf4SKowalski, Kamil 660f4c4dcf4SKowalski, Kamil /** 661f4c4dcf4SKowalski, Kamil * @internal 662f4c4dcf4SKowalski, Kamil * @brief Formats StringValueTooLong message into JSON 663f4c4dcf4SKowalski, Kamil * 664f4c4dcf4SKowalski, Kamil * See header file for more information 665f4c4dcf4SKowalski, Kamil * @endinternal 666f4c4dcf4SKowalski, Kamil */ 667*b5c07418SJames Feist nlohmann::json stringValueTooLong(const std::string& arg1, const int& arg2) 6681abe55efSEd Tanous { 669*b5c07418SJames Feist return nlohmann::json{ 670f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 671cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.StringValueTooLong"}, 672f4c4dcf4SKowalski, Kamil {"Message", "The string " + arg1 + " exceeds the length limit " + 673f4c4dcf4SKowalski, Kamil std::to_string(arg2) + "."}, 67485659adfSJason M. Bills {"MessageArgs", {arg1, std::to_string(arg2)}}, 675f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 676f4c4dcf4SKowalski, Kamil {"Resolution", 677*b5c07418SJames Feist "Resubmit the request with an appropriate string length."}}; 678*b5c07418SJames Feist } 679*b5c07418SJames Feist 680*b5c07418SJames Feist void stringValueTooLong(crow::Response& res, const std::string& arg1, 681*b5c07418SJames Feist const int& arg2) 682*b5c07418SJames Feist { 683*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 684*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2)); 685f4c4dcf4SKowalski, Kamil } 686f4c4dcf4SKowalski, Kamil 687f4c4dcf4SKowalski, Kamil /** 688f4c4dcf4SKowalski, Kamil * @internal 689cc9139ecSJason M. Bills * @brief Formats SessionTerminated message into JSON 690cc9139ecSJason M. Bills * 691cc9139ecSJason M. Bills * See header file for more information 692cc9139ecSJason M. Bills * @endinternal 693cc9139ecSJason M. Bills */ 694*b5c07418SJames Feist nlohmann::json sessionTerminated(void) 695cc9139ecSJason M. Bills { 696*b5c07418SJames Feist return nlohmann::json{ 697cc9139ecSJason M. Bills {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 698cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.SessionTerminated"}, 699cc9139ecSJason M. Bills {"Message", "The session was successfully terminated."}, 70085659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 701cc9139ecSJason M. Bills {"Severity", "OK"}, 702*b5c07418SJames Feist {"Resolution", "No resolution is required."}}; 703*b5c07418SJames Feist } 704*b5c07418SJames Feist 705*b5c07418SJames Feist void sessionTerminated(crow::Response& res) 706*b5c07418SJames Feist { 707*b5c07418SJames Feist res.result(boost::beast::http::status::ok); 708*b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, sessionTerminated()); 709cc9139ecSJason M. Bills } 710cc9139ecSJason M. Bills 711cc9139ecSJason M. Bills /** 712cc9139ecSJason M. Bills * @internal 713cc9139ecSJason M. Bills * @brief Formats ResourceTypeIncompatible message into JSON 714cc9139ecSJason M. Bills * 715cc9139ecSJason M. Bills * See header file for more information 716cc9139ecSJason M. Bills * @endinternal 717cc9139ecSJason M. Bills */ 718*b5c07418SJames Feist nlohmann::json resourceTypeIncompatible(const std::string& arg1, 719cc9139ecSJason M. Bills const std::string& arg2) 720cc9139ecSJason M. Bills { 721*b5c07418SJames Feist return nlohmann::json{ 722cc9139ecSJason M. Bills {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 723cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceTypeIncompatible"}, 724cc9139ecSJason M. Bills {"Message", "The @odata.type of the request body " + arg1 + 725cc9139ecSJason M. Bills " is incompatible with the @odata.type of the " 726cc9139ecSJason M. Bills "resource which is " + 727cc9139ecSJason M. Bills arg2 + "."}, 72885659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 729cc9139ecSJason M. Bills {"Severity", "Critical"}, 730cc9139ecSJason M. Bills {"Resolution", "Resubmit the request with a payload compatible " 731*b5c07418SJames Feist "with the resource's schema."}}; 732*b5c07418SJames Feist } 733*b5c07418SJames Feist 734*b5c07418SJames Feist void resourceTypeIncompatible(crow::Response& res, const std::string& arg1, 735*b5c07418SJames Feist const std::string& arg2) 736*b5c07418SJames Feist { 737*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 738*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2)); 739cc9139ecSJason M. Bills } 740cc9139ecSJason M. Bills 741cc9139ecSJason M. Bills /** 742cc9139ecSJason M. Bills * @internal 743f12894f8SJason M. Bills * @brief Formats PropertyValueTypeError message into JSON for the specified 744f12894f8SJason M. Bills * property 745f12894f8SJason M. Bills * 746f12894f8SJason M. Bills * See header file for more information 747f12894f8SJason M. Bills * @endinternal 748f12894f8SJason M. Bills */ 749*b5c07418SJames Feist nlohmann::json propertyValueTypeError(const std::string& arg1, 750a08b46ccSJason M. Bills const std::string& arg2) 751f12894f8SJason M. Bills { 752*b5c07418SJames Feist return nlohmann::json{ 753f12894f8SJason M. Bills {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 754cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyValueTypeError"}, 755f12894f8SJason M. Bills {"Message", 756f12894f8SJason M. Bills "The value " + arg1 + " for the property " + arg2 + 757f12894f8SJason M. Bills " is of a different type than the property can accept."}, 75885659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 759f12894f8SJason M. Bills {"Severity", "Warning"}, 76066ac2b8cSJason M. Bills {"Resolution", 76166ac2b8cSJason M. Bills "Correct the value for the property in the request body and " 762*b5c07418SJames Feist "resubmit the request if the operation failed."}}; 763*b5c07418SJames Feist } 764*b5c07418SJames Feist 765*b5c07418SJames Feist void propertyValueTypeError(crow::Response& res, const std::string& arg1, 766*b5c07418SJames Feist const std::string& arg2) 767*b5c07418SJames Feist { 768*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 769*b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2); 770f4c4dcf4SKowalski, Kamil } 771f4c4dcf4SKowalski, Kamil 772f4c4dcf4SKowalski, Kamil /** 773f4c4dcf4SKowalski, Kamil * @internal 774f4c4dcf4SKowalski, Kamil * @brief Formats ResourceNotFound message into JSON 775f4c4dcf4SKowalski, Kamil * 776f4c4dcf4SKowalski, Kamil * See header file for more information 777f4c4dcf4SKowalski, Kamil * @endinternal 778f4c4dcf4SKowalski, Kamil */ 779*b5c07418SJames Feist nlohmann::json resourceNotFound(const std::string& arg1, 7801abe55efSEd Tanous const std::string& arg2) 7811abe55efSEd Tanous { 782*b5c07418SJames Feist return nlohmann::json{ 783f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 784cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceNotFound"}, 7851abe55efSEd Tanous {"Message", "The requested resource of type " + arg1 + " named " + 7861abe55efSEd Tanous arg2 + " was not found."}, 78785659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 788f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 789f4c4dcf4SKowalski, Kamil {"Resolution", 790*b5c07418SJames Feist "Provide a valid resource identifier and resubmit the request."}}; 791*b5c07418SJames Feist } 792*b5c07418SJames Feist 793*b5c07418SJames Feist void resourceNotFound(crow::Response& res, const std::string& arg1, 794*b5c07418SJames Feist const std::string& arg2) 795*b5c07418SJames Feist { 796*b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 797*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2)); 798f4c4dcf4SKowalski, Kamil } 799f4c4dcf4SKowalski, Kamil 800f4c4dcf4SKowalski, Kamil /** 801f4c4dcf4SKowalski, Kamil * @internal 802f4c4dcf4SKowalski, Kamil * @brief Formats CouldNotEstablishConnection message into JSON 803f4c4dcf4SKowalski, Kamil * 804f4c4dcf4SKowalski, Kamil * See header file for more information 805f4c4dcf4SKowalski, Kamil * @endinternal 806f4c4dcf4SKowalski, Kamil */ 807*b5c07418SJames Feist nlohmann::json couldNotEstablishConnection(const std::string& arg1) 8081abe55efSEd Tanous { 809*b5c07418SJames Feist return nlohmann::json{ 810f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 811cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.CouldNotEstablishConnection"}, 8121abe55efSEd Tanous {"Message", 813*b5c07418SJames Feist "The service failed to establish a Connection with the URI " + arg1 + 814*b5c07418SJames Feist "."}, 81585659adfSJason M. Bills {"MessageArgs", {arg1}}, 816f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 81766ac2b8cSJason M. Bills {"Resolution", 81866ac2b8cSJason M. Bills "Ensure that the URI contains a valid and reachable node name, " 819*b5c07418SJames Feist "protocol information and other URI components."}}; 820*b5c07418SJames Feist } 821*b5c07418SJames Feist 822*b5c07418SJames Feist void couldNotEstablishConnection(crow::Response& res, const std::string& arg1) 823*b5c07418SJames Feist { 824*b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 825*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1)); 826f4c4dcf4SKowalski, Kamil } 827f4c4dcf4SKowalski, Kamil 828f4c4dcf4SKowalski, Kamil /** 829f4c4dcf4SKowalski, Kamil * @internal 830f12894f8SJason M. Bills * @brief Formats PropertyNotWritable message into JSON for the specified 831f12894f8SJason M. Bills * property 832f12894f8SJason M. Bills * 833f12894f8SJason M. Bills * See header file for more information 834f12894f8SJason M. Bills * @endinternal 835f12894f8SJason M. Bills */ 836*b5c07418SJames Feist nlohmann::json propertyNotWritable(const std::string& arg1) 837f12894f8SJason M. Bills { 838*b5c07418SJames Feist return nlohmann::json{ 839f12894f8SJason M. Bills {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 840cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyNotWritable"}, 841*b5c07418SJames Feist {"Message", "The property " + arg1 + 842*b5c07418SJames Feist " is a read only property and cannot be " 843*b5c07418SJames Feist "assigned a value."}, 84485659adfSJason M. Bills {"MessageArgs", {arg1}}, 845f12894f8SJason M. Bills {"Severity", "Warning"}, 84666ac2b8cSJason M. Bills {"Resolution", "Remove the property from the request body and " 847*b5c07418SJames Feist "resubmit the request if the operation failed."}}; 848*b5c07418SJames Feist } 849*b5c07418SJames Feist 850*b5c07418SJames Feist void propertyNotWritable(crow::Response& res, const std::string& arg1) 851*b5c07418SJames Feist { 852*b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 853*b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1); 854f4c4dcf4SKowalski, Kamil } 855f4c4dcf4SKowalski, Kamil 856f4c4dcf4SKowalski, Kamil /** 857f4c4dcf4SKowalski, Kamil * @internal 858f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueTypeError message into JSON 859f4c4dcf4SKowalski, Kamil * 860f4c4dcf4SKowalski, Kamil * See header file for more information 861f4c4dcf4SKowalski, Kamil * @endinternal 862f4c4dcf4SKowalski, Kamil */ 863*b5c07418SJames Feist nlohmann::json queryParameterValueTypeError(const std::string& arg1, 8641abe55efSEd Tanous const std::string& arg2) 8651abe55efSEd Tanous { 866*b5c07418SJames Feist return nlohmann::json{ 867f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 868cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.QueryParameterValueTypeError"}, 8691abe55efSEd Tanous {"Message", 8701abe55efSEd Tanous "The value " + arg1 + " for the query parameter " + arg2 + 871f4c4dcf4SKowalski, Kamil " is of a different type than the parameter can accept."}, 87285659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 873f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 87466ac2b8cSJason M. Bills {"Resolution", 87566ac2b8cSJason M. Bills "Correct the value for the query parameter in the request and " 876*b5c07418SJames Feist "resubmit the request if the operation failed."}}; 877*b5c07418SJames Feist } 878*b5c07418SJames Feist 879*b5c07418SJames Feist void queryParameterValueTypeError(crow::Response& res, const std::string& arg1, 880*b5c07418SJames Feist const std::string& arg2) 881*b5c07418SJames Feist { 882*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 883*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 884*b5c07418SJames Feist queryParameterValueTypeError(arg1, arg2)); 885f4c4dcf4SKowalski, Kamil } 886f4c4dcf4SKowalski, Kamil 887f4c4dcf4SKowalski, Kamil /** 888f4c4dcf4SKowalski, Kamil * @internal 889f4c4dcf4SKowalski, Kamil * @brief Formats ServiceShuttingDown message into JSON 890f4c4dcf4SKowalski, Kamil * 891f4c4dcf4SKowalski, Kamil * See header file for more information 892f4c4dcf4SKowalski, Kamil * @endinternal 893f4c4dcf4SKowalski, Kamil */ 894*b5c07418SJames Feist nlohmann::json serviceShuttingDown(void) 8951abe55efSEd Tanous { 896*b5c07418SJames Feist return nlohmann::json{ 897f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 898cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ServiceShuttingDown"}, 899f12894f8SJason M. Bills {"Message", "The operation failed because the service is shutting " 90066ac2b8cSJason M. Bills "down and can no longer take incoming requests."}, 90185659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 902f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 90366ac2b8cSJason M. Bills {"Resolution", "When the service becomes available, resubmit the " 904*b5c07418SJames Feist "request if the operation failed."}}; 905*b5c07418SJames Feist } 906*b5c07418SJames Feist 907*b5c07418SJames Feist void serviceShuttingDown(crow::Response& res) 908*b5c07418SJames Feist { 909*b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 910*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceShuttingDown()); 911f4c4dcf4SKowalski, Kamil } 912f4c4dcf4SKowalski, Kamil 913f4c4dcf4SKowalski, Kamil /** 914f4c4dcf4SKowalski, Kamil * @internal 915f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterDuplicate message into JSON 916f4c4dcf4SKowalski, Kamil * 917f4c4dcf4SKowalski, Kamil * See header file for more information 918f4c4dcf4SKowalski, Kamil * @endinternal 919f4c4dcf4SKowalski, Kamil */ 920*b5c07418SJames Feist nlohmann::json actionParameterDuplicate(const std::string& arg1, 9211abe55efSEd Tanous const std::string& arg2) 9221abe55efSEd Tanous { 923*b5c07418SJames Feist return nlohmann::json{ 924f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 925cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionParameterDuplicate"}, 926f4c4dcf4SKowalski, Kamil {"Message", 927f4c4dcf4SKowalski, Kamil "The action " + arg1 + 9281abe55efSEd Tanous " was submitted with more than one value for the parameter " + 9291abe55efSEd Tanous arg2 + "."}, 93085659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 931f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 93266ac2b8cSJason M. Bills {"Resolution", 93366ac2b8cSJason M. Bills "Resubmit the action with only one instance of the parameter in " 934*b5c07418SJames Feist "the request body if the operation failed."}}; 935*b5c07418SJames Feist } 936*b5c07418SJames Feist 937*b5c07418SJames Feist void actionParameterDuplicate(crow::Response& res, const std::string& arg1, 938*b5c07418SJames Feist const std::string& arg2) 939*b5c07418SJames Feist { 940*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 941*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2)); 942f4c4dcf4SKowalski, Kamil } 943f4c4dcf4SKowalski, Kamil 944f4c4dcf4SKowalski, Kamil /** 945f4c4dcf4SKowalski, Kamil * @internal 946f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterNotSupported message into JSON 947f4c4dcf4SKowalski, Kamil * 948f4c4dcf4SKowalski, Kamil * See header file for more information 949f4c4dcf4SKowalski, Kamil * @endinternal 950f4c4dcf4SKowalski, Kamil */ 951*b5c07418SJames Feist nlohmann::json actionParameterNotSupported(const std::string& arg1, 9521abe55efSEd Tanous const std::string& arg2) 9531abe55efSEd Tanous { 954*b5c07418SJames Feist return nlohmann::json{ 955f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 956cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionParameterNotSupported"}, 957f4c4dcf4SKowalski, Kamil {"Message", "The parameter " + arg1 + " for the action " + arg2 + 958f4c4dcf4SKowalski, Kamil " is not supported on the target resource."}, 95985659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 960f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 96166ac2b8cSJason M. Bills {"Resolution", "Remove the parameter supplied and resubmit the " 962*b5c07418SJames Feist "request if the operation failed."}}; 963*b5c07418SJames Feist } 964*b5c07418SJames Feist 965*b5c07418SJames Feist void actionParameterNotSupported(crow::Response& res, const std::string& arg1, 966*b5c07418SJames Feist const std::string& arg2) 967*b5c07418SJames Feist { 968*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 969*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 970*b5c07418SJames Feist actionParameterNotSupported(arg1, arg2)); 971f4c4dcf4SKowalski, Kamil } 972f4c4dcf4SKowalski, Kamil 973f4c4dcf4SKowalski, Kamil /** 974f4c4dcf4SKowalski, Kamil * @internal 975f4c4dcf4SKowalski, Kamil * @brief Formats SourceDoesNotSupportProtocol message into JSON 976f4c4dcf4SKowalski, Kamil * 977f4c4dcf4SKowalski, Kamil * See header file for more information 978f4c4dcf4SKowalski, Kamil * @endinternal 979f4c4dcf4SKowalski, Kamil */ 980*b5c07418SJames Feist nlohmann::json sourceDoesNotSupportProtocol(const std::string& arg1, 9811abe55efSEd Tanous const std::string& arg2) 9821abe55efSEd Tanous { 983*b5c07418SJames Feist return nlohmann::json{ 984f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 985cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.SourceDoesNotSupportProtocol"}, 98655c7b7a2SEd Tanous {"Message", "The other end of the Connection at " + arg1 + 9871abe55efSEd Tanous " does not support the specified protocol " + arg2 + 9881abe55efSEd Tanous "."}, 98985659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 990f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 991*b5c07418SJames Feist {"Resolution", "Change protocols or URIs. "}}; 992*b5c07418SJames Feist } 993*b5c07418SJames Feist 994*b5c07418SJames Feist void sourceDoesNotSupportProtocol(crow::Response& res, const std::string& arg1, 995*b5c07418SJames Feist const std::string& arg2) 996*b5c07418SJames Feist { 997*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 998*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 999*b5c07418SJames Feist sourceDoesNotSupportProtocol(arg1, arg2)); 1000f4c4dcf4SKowalski, Kamil } 1001f4c4dcf4SKowalski, Kamil 1002f4c4dcf4SKowalski, Kamil /** 1003f4c4dcf4SKowalski, Kamil * @internal 1004f4c4dcf4SKowalski, Kamil * @brief Formats AccountRemoved message into JSON 1005f4c4dcf4SKowalski, Kamil * 1006f4c4dcf4SKowalski, Kamil * See header file for more information 1007f4c4dcf4SKowalski, Kamil * @endinternal 1008f4c4dcf4SKowalski, Kamil */ 1009*b5c07418SJames Feist nlohmann::json accountRemoved(void) 10101abe55efSEd Tanous { 1011*b5c07418SJames Feist return nlohmann::json{ 1012f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1013cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.AccountRemoved"}, 1014f4c4dcf4SKowalski, Kamil {"Message", "The account was successfully removed."}, 101585659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1016f4c4dcf4SKowalski, Kamil {"Severity", "OK"}, 1017*b5c07418SJames Feist {"Resolution", "No resolution is required."}}; 1018*b5c07418SJames Feist } 1019*b5c07418SJames Feist 1020*b5c07418SJames Feist void accountRemoved(crow::Response& res) 1021*b5c07418SJames Feist { 1022*b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1023*b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, accountRemoved()); 1024f4c4dcf4SKowalski, Kamil } 1025f4c4dcf4SKowalski, Kamil 1026f4c4dcf4SKowalski, Kamil /** 1027f4c4dcf4SKowalski, Kamil * @internal 1028f4c4dcf4SKowalski, Kamil * @brief Formats AccessDenied message into JSON 1029f4c4dcf4SKowalski, Kamil * 1030f4c4dcf4SKowalski, Kamil * See header file for more information 1031f4c4dcf4SKowalski, Kamil * @endinternal 1032f4c4dcf4SKowalski, Kamil */ 1033*b5c07418SJames Feist nlohmann::json accessDenied(const std::string& arg1) 10341abe55efSEd Tanous { 1035*b5c07418SJames Feist return nlohmann::json{ 1036f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1037cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.AccessDenied"}, 1038*b5c07418SJames Feist {"Message", "While attempting to establish a Connection to " + arg1 + 1039*b5c07418SJames Feist ", the service denied access."}, 104085659adfSJason M. Bills {"MessageArgs", {arg1}}, 1041f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 104266ac2b8cSJason M. Bills {"Resolution", "Attempt to ensure that the URI is correct and that " 1043*b5c07418SJames Feist "the service has the appropriate credentials."}}; 1044*b5c07418SJames Feist } 1045*b5c07418SJames Feist 1046*b5c07418SJames Feist void accessDenied(crow::Response& res, const std::string& arg1) 1047*b5c07418SJames Feist { 1048*b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1049*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accessDenied(arg1)); 1050f4c4dcf4SKowalski, Kamil } 1051f4c4dcf4SKowalski, Kamil 1052f4c4dcf4SKowalski, Kamil /** 1053f4c4dcf4SKowalski, Kamil * @internal 1054f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupported message into JSON 1055f4c4dcf4SKowalski, Kamil * 1056f4c4dcf4SKowalski, Kamil * See header file for more information 1057f4c4dcf4SKowalski, Kamil * @endinternal 1058f4c4dcf4SKowalski, Kamil */ 1059*b5c07418SJames Feist nlohmann::json queryNotSupported(void) 10601abe55efSEd Tanous { 1061*b5c07418SJames Feist return nlohmann::json{ 1062f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1063cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.QueryNotSupported"}, 1064f4c4dcf4SKowalski, Kamil {"Message", "Querying is not supported by the implementation."}, 106585659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1066f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 106766ac2b8cSJason M. Bills {"Resolution", "Remove the query parameters and resubmit the " 1068*b5c07418SJames Feist "request if the operation failed."}}; 1069*b5c07418SJames Feist } 1070*b5c07418SJames Feist 1071*b5c07418SJames Feist void queryNotSupported(crow::Response& res) 1072*b5c07418SJames Feist { 1073*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1074*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupported()); 1075f4c4dcf4SKowalski, Kamil } 1076f4c4dcf4SKowalski, Kamil 1077f4c4dcf4SKowalski, Kamil /** 1078f4c4dcf4SKowalski, Kamil * @internal 1079f4c4dcf4SKowalski, Kamil * @brief Formats CreateLimitReachedForResource message into JSON 1080f4c4dcf4SKowalski, Kamil * 1081f4c4dcf4SKowalski, Kamil * See header file for more information 1082f4c4dcf4SKowalski, Kamil * @endinternal 1083f4c4dcf4SKowalski, Kamil */ 1084*b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void) 10851abe55efSEd Tanous { 1086*b5c07418SJames Feist return nlohmann::json{ 1087f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1088cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.CreateLimitReachedForResource"}, 10891abe55efSEd Tanous {"Message", "The create operation failed because the resource has " 109066ac2b8cSJason M. Bills "reached the limit of possible resources."}, 109185659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1092f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 109366ac2b8cSJason M. Bills {"Resolution", 109466ac2b8cSJason M. Bills "Either delete resources and resubmit the request if the " 1095*b5c07418SJames Feist "operation failed or do not resubmit the request."}}; 1096*b5c07418SJames Feist } 1097*b5c07418SJames Feist 1098*b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res) 1099*b5c07418SJames Feist { 1100*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1101*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, createLimitReachedForResource()); 1102f4c4dcf4SKowalski, Kamil } 1103f4c4dcf4SKowalski, Kamil 1104f4c4dcf4SKowalski, Kamil /** 1105f4c4dcf4SKowalski, Kamil * @internal 1106f4c4dcf4SKowalski, Kamil * @brief Formats GeneralError message into JSON 1107f4c4dcf4SKowalski, Kamil * 1108f4c4dcf4SKowalski, Kamil * See header file for more information 1109f4c4dcf4SKowalski, Kamil * @endinternal 1110f4c4dcf4SKowalski, Kamil */ 1111*b5c07418SJames Feist nlohmann::json generalError(void) 11121abe55efSEd Tanous { 1113*b5c07418SJames Feist return nlohmann::json{ 1114f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1115cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.GeneralError"}, 1116cc9139ecSJason M. Bills {"Message", "A general error has occurred. See Resolution for " 1117cc9139ecSJason M. Bills "information on how to resolve the error."}, 111885659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1119f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1120*b5c07418SJames Feist {"Resolution", "None."}}; 1121*b5c07418SJames Feist } 1122*b5c07418SJames Feist 1123*b5c07418SJames Feist void generalError(crow::Response& res) 1124*b5c07418SJames Feist { 1125*b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 1126*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, generalError()); 1127f4c4dcf4SKowalski, Kamil } 1128f4c4dcf4SKowalski, Kamil 1129f4c4dcf4SKowalski, Kamil /** 1130f4c4dcf4SKowalski, Kamil * @internal 1131f4c4dcf4SKowalski, Kamil * @brief Formats Success message into JSON 1132f4c4dcf4SKowalski, Kamil * 1133f4c4dcf4SKowalski, Kamil * See header file for more information 1134f4c4dcf4SKowalski, Kamil * @endinternal 1135f4c4dcf4SKowalski, Kamil */ 1136*b5c07418SJames Feist nlohmann::json success(void) 11371abe55efSEd Tanous { 1138*b5c07418SJames Feist return nlohmann::json{ 1139f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1140cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.Success"}, 1141f4c4dcf4SKowalski, Kamil {"Message", "Successfully Completed Request"}, 114285659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1143f4c4dcf4SKowalski, Kamil {"Severity", "OK"}, 1144*b5c07418SJames Feist {"Resolution", "None"}}; 1145*b5c07418SJames Feist } 1146*b5c07418SJames Feist 1147*b5c07418SJames Feist void success(crow::Response& res) 1148*b5c07418SJames Feist { 1149*b5c07418SJames Feist // don't set res.result here because success is the default and any 1150*b5c07418SJames Feist // error should overwrite the default 1151*b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, success()); 1152f12894f8SJason M. Bills } 1153f12894f8SJason M. Bills 1154f12894f8SJason M. Bills /** 1155f12894f8SJason M. Bills * @internal 1156f4c4dcf4SKowalski, Kamil * @brief Formats Created message into JSON 1157f4c4dcf4SKowalski, Kamil * 1158f4c4dcf4SKowalski, Kamil * See header file for more information 1159f4c4dcf4SKowalski, Kamil * @endinternal 1160f4c4dcf4SKowalski, Kamil */ 1161*b5c07418SJames Feist nlohmann::json created(void) 11621abe55efSEd Tanous { 1163*b5c07418SJames Feist return nlohmann::json{ 1164f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1165cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.Created"}, 1166f4c4dcf4SKowalski, Kamil {"Message", "The resource has been created successfully"}, 116785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1168f4c4dcf4SKowalski, Kamil {"Severity", "OK"}, 1169*b5c07418SJames Feist {"Resolution", "None"}}; 1170*b5c07418SJames Feist } 1171*b5c07418SJames Feist 1172*b5c07418SJames Feist void created(crow::Response& res) 1173*b5c07418SJames Feist { 1174*b5c07418SJames Feist res.result(boost::beast::http::status::created); 1175*b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, created()); 1176f4c4dcf4SKowalski, Kamil } 1177f4c4dcf4SKowalski, Kamil 1178f4c4dcf4SKowalski, Kamil /** 1179f4c4dcf4SKowalski, Kamil * @internal 1180cc9139ecSJason M. Bills * @brief Formats NoOperation message into JSON 1181cc9139ecSJason M. Bills * 1182cc9139ecSJason M. Bills * See header file for more information 1183cc9139ecSJason M. Bills * @endinternal 1184cc9139ecSJason M. Bills */ 1185*b5c07418SJames Feist nlohmann::json noOperation(void) 1186cc9139ecSJason M. Bills { 1187*b5c07418SJames Feist return nlohmann::json{ 1188cc9139ecSJason M. Bills {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1189cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.NoOperation"}, 1190cc9139ecSJason M. Bills {"Message", "The request body submitted contain no data to act " 1191cc9139ecSJason M. Bills "upon and no changes to the resource took place."}, 119285659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1193cc9139ecSJason M. Bills {"Severity", "Warning"}, 1194cc9139ecSJason M. Bills {"Resolution", 1195*b5c07418SJames Feist "Add properties in the JSON object and resubmit the request."}}; 1196*b5c07418SJames Feist } 1197*b5c07418SJames Feist 1198*b5c07418SJames Feist void noOperation(crow::Response& res) 1199*b5c07418SJames Feist { 1200*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1201*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noOperation()); 1202cc9139ecSJason M. Bills } 1203cc9139ecSJason M. Bills 1204cc9139ecSJason M. Bills /** 1205cc9139ecSJason M. Bills * @internal 1206*b5c07418SJames Feist * @brief Formats PropertyUnknown message into JSON for the specified 1207*b5c07418SJames Feist * property 1208f12894f8SJason M. Bills * 1209f12894f8SJason M. Bills * See header file for more information 1210f12894f8SJason M. Bills * @endinternal 1211f12894f8SJason M. Bills */ 1212*b5c07418SJames Feist nlohmann::json propertyUnknown(const std::string& arg1) 1213*b5c07418SJames Feist { 1214*b5c07418SJames Feist return nlohmann::json{ 1215*b5c07418SJames Feist {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1216*b5c07418SJames Feist {"MessageId", "Base.1.4.0.PropertyUnknown"}, 1217*b5c07418SJames Feist {"Message", "The property " + arg1 + 1218*b5c07418SJames Feist " is not in the list of valid properties for " 1219*b5c07418SJames Feist "the resource."}, 1220*b5c07418SJames Feist {"MessageArgs", {arg1}}, 1221*b5c07418SJames Feist {"Severity", "Warning"}, 1222*b5c07418SJames Feist {"Resolution", "Remove the unknown property from the request " 1223*b5c07418SJames Feist "body and resubmit " 1224*b5c07418SJames Feist "the request if the operation failed."}}; 1225*b5c07418SJames Feist } 1226*b5c07418SJames Feist 1227a08b46ccSJason M. Bills void propertyUnknown(crow::Response& res, const std::string& arg1) 1228f12894f8SJason M. Bills { 1229f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 1230*b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1); 1231f4c4dcf4SKowalski, Kamil } 1232f4c4dcf4SKowalski, Kamil 1233f4c4dcf4SKowalski, Kamil /** 1234f4c4dcf4SKowalski, Kamil * @internal 1235f4c4dcf4SKowalski, Kamil * @brief Formats NoValidSession message into JSON 1236f4c4dcf4SKowalski, Kamil * 1237f4c4dcf4SKowalski, Kamil * See header file for more information 1238f4c4dcf4SKowalski, Kamil * @endinternal 1239f4c4dcf4SKowalski, Kamil */ 1240*b5c07418SJames Feist nlohmann::json noValidSession(void) 12411abe55efSEd Tanous { 1242*b5c07418SJames Feist return nlohmann::json{ 1243f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1244cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.NoValidSession"}, 1245f4c4dcf4SKowalski, Kamil {"Message", 1246f4c4dcf4SKowalski, Kamil "There is no valid session established with the implementation."}, 124785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1248f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 12491abe55efSEd Tanous {"Resolution", 1250*b5c07418SJames Feist "Establish as session before attempting any operations."}}; 1251*b5c07418SJames Feist } 1252*b5c07418SJames Feist 1253*b5c07418SJames Feist void noValidSession(crow::Response& res) 1254*b5c07418SJames Feist { 1255*b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1256*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noValidSession()); 1257f4c4dcf4SKowalski, Kamil } 1258f4c4dcf4SKowalski, Kamil 1259f4c4dcf4SKowalski, Kamil /** 1260f4c4dcf4SKowalski, Kamil * @internal 1261f4c4dcf4SKowalski, Kamil * @brief Formats InvalidObject message into JSON 1262f4c4dcf4SKowalski, Kamil * 1263f4c4dcf4SKowalski, Kamil * See header file for more information 1264f4c4dcf4SKowalski, Kamil * @endinternal 1265f4c4dcf4SKowalski, Kamil */ 1266*b5c07418SJames Feist nlohmann::json invalidObject(const std::string& arg1) 12671abe55efSEd Tanous { 1268*b5c07418SJames Feist return nlohmann::json{ 1269f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1270cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.InvalidObject"}, 1271f4c4dcf4SKowalski, Kamil {"Message", "The object at " + arg1 + " is invalid."}, 127285659adfSJason M. Bills {"MessageArgs", {arg1}}, 1273f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1274f12894f8SJason M. Bills {"Resolution", 127566ac2b8cSJason M. Bills "Either the object is malformed or the URI is not correct. " 1276*b5c07418SJames Feist "Correct the condition and resubmit the request if it failed."}}; 1277*b5c07418SJames Feist } 1278*b5c07418SJames Feist 1279*b5c07418SJames Feist void invalidObject(crow::Response& res, const std::string& arg1) 1280*b5c07418SJames Feist { 1281*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1282*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidObject(arg1)); 1283f4c4dcf4SKowalski, Kamil } 1284f4c4dcf4SKowalski, Kamil 1285f4c4dcf4SKowalski, Kamil /** 1286f4c4dcf4SKowalski, Kamil * @internal 1287f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInStandby message into JSON 1288f4c4dcf4SKowalski, Kamil * 1289f4c4dcf4SKowalski, Kamil * See header file for more information 1290f4c4dcf4SKowalski, Kamil * @endinternal 1291f4c4dcf4SKowalski, Kamil */ 1292*b5c07418SJames Feist nlohmann::json resourceInStandby(void) 12931abe55efSEd Tanous { 1294*b5c07418SJames Feist return nlohmann::json{ 1295f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1296cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceInStandby"}, 129766ac2b8cSJason M. Bills {"Message", "The request could not be performed because the " 129866ac2b8cSJason M. Bills "resource is in standby."}, 129985659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1300f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1301f12894f8SJason M. Bills {"Resolution", "Ensure that the resource is in the correct power " 1302*b5c07418SJames Feist "state and resubmit the request."}}; 1303*b5c07418SJames Feist } 1304*b5c07418SJames Feist 1305*b5c07418SJames Feist void resourceInStandby(crow::Response& res) 1306*b5c07418SJames Feist { 1307*b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1308*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInStandby()); 1309f4c4dcf4SKowalski, Kamil } 1310f4c4dcf4SKowalski, Kamil 1311f4c4dcf4SKowalski, Kamil /** 1312f4c4dcf4SKowalski, Kamil * @internal 1313f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueTypeError message into JSON 1314f4c4dcf4SKowalski, Kamil * 1315f4c4dcf4SKowalski, Kamil * See header file for more information 1316f4c4dcf4SKowalski, Kamil * @endinternal 1317f4c4dcf4SKowalski, Kamil */ 1318*b5c07418SJames Feist nlohmann::json actionParameterValueTypeError(const std::string& arg1, 1319f4c4dcf4SKowalski, Kamil const std::string& arg2, 13201abe55efSEd Tanous const std::string& arg3) 13211abe55efSEd Tanous { 1322*b5c07418SJames Feist return nlohmann::json{ 1323f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1324cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionParameterValueTypeError"}, 13251abe55efSEd Tanous {"Message", 13261abe55efSEd Tanous "The value " + arg1 + " for the parameter " + arg2 + 1327f4c4dcf4SKowalski, Kamil " in the action " + arg3 + 1328f4c4dcf4SKowalski, Kamil " is of a different type than the parameter can accept."}, 132985659adfSJason M. Bills {"MessageArgs", {arg1, arg2, arg3}}, 1330f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 133166ac2b8cSJason M. Bills {"Resolution", 133266ac2b8cSJason M. Bills "Correct the value for the parameter in the request body and " 1333*b5c07418SJames Feist "resubmit the request if the operation failed."}}; 1334*b5c07418SJames Feist } 1335*b5c07418SJames Feist 1336*b5c07418SJames Feist void actionParameterValueTypeError(crow::Response& res, const std::string& arg1, 1337*b5c07418SJames Feist const std::string& arg2, 1338*b5c07418SJames Feist const std::string& arg3) 1339*b5c07418SJames Feist { 1340*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1341*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1342*b5c07418SJames Feist actionParameterValueTypeError(arg1, arg2, arg3)); 1343f4c4dcf4SKowalski, Kamil } 1344f4c4dcf4SKowalski, Kamil 1345f4c4dcf4SKowalski, Kamil /** 1346f4c4dcf4SKowalski, Kamil * @internal 1347f4c4dcf4SKowalski, Kamil * @brief Formats SessionLimitExceeded message into JSON 1348f4c4dcf4SKowalski, Kamil * 1349f4c4dcf4SKowalski, Kamil * See header file for more information 1350f4c4dcf4SKowalski, Kamil * @endinternal 1351f4c4dcf4SKowalski, Kamil */ 1352*b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void) 13531abe55efSEd Tanous { 1354*b5c07418SJames Feist return nlohmann::json{ 1355f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1356cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.SessionLimitExceeded"}, 1357f12894f8SJason M. Bills {"Message", "The session establishment failed due to the number of " 135866ac2b8cSJason M. Bills "simultaneous sessions exceeding the limit of the " 135966ac2b8cSJason M. Bills "implementation."}, 136085659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1361f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 136266ac2b8cSJason M. Bills {"Resolution", "Reduce the number of other sessions before trying " 136366ac2b8cSJason M. Bills "to establish the session or increase the limit of " 1364*b5c07418SJames Feist "simultaneous sessions (if supported)."}}; 1365*b5c07418SJames Feist } 1366*b5c07418SJames Feist 1367*b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res) 1368*b5c07418SJames Feist { 1369*b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1370*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, sessionLimitExceeded()); 1371f4c4dcf4SKowalski, Kamil } 1372f4c4dcf4SKowalski, Kamil 1373f4c4dcf4SKowalski, Kamil /** 1374f4c4dcf4SKowalski, Kamil * @internal 1375f4c4dcf4SKowalski, Kamil * @brief Formats ActionNotSupported message into JSON 1376f4c4dcf4SKowalski, Kamil * 1377f4c4dcf4SKowalski, Kamil * See header file for more information 1378f4c4dcf4SKowalski, Kamil * @endinternal 1379f4c4dcf4SKowalski, Kamil */ 1380*b5c07418SJames Feist nlohmann::json actionNotSupported(const std::string& arg1) 13811abe55efSEd Tanous { 1382*b5c07418SJames Feist return nlohmann::json{ 1383f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1384cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionNotSupported"}, 13851abe55efSEd Tanous {"Message", 13861abe55efSEd Tanous "The action " + arg1 + " is not supported by the resource."}, 138785659adfSJason M. Bills {"MessageArgs", {arg1}}, 1388f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1389f4c4dcf4SKowalski, Kamil {"Resolution", 1390f4c4dcf4SKowalski, Kamil "The action supplied cannot be resubmitted to the implementation. " 1391f12894f8SJason M. Bills " Perhaps the action was invalid, the wrong resource was the " 139266ac2b8cSJason M. Bills "target or the implementation documentation may be of " 1393*b5c07418SJames Feist "assistance."}}; 1394*b5c07418SJames Feist } 1395*b5c07418SJames Feist 1396*b5c07418SJames Feist void actionNotSupported(crow::Response& res, const std::string& arg1) 1397*b5c07418SJames Feist { 1398*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1399*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1)); 1400f4c4dcf4SKowalski, Kamil } 1401f4c4dcf4SKowalski, Kamil 1402f4c4dcf4SKowalski, Kamil /** 1403f4c4dcf4SKowalski, Kamil * @internal 1404f4c4dcf4SKowalski, Kamil * @brief Formats InvalidIndex message into JSON 1405f4c4dcf4SKowalski, Kamil * 1406f4c4dcf4SKowalski, Kamil * See header file for more information 1407f4c4dcf4SKowalski, Kamil * @endinternal 1408f4c4dcf4SKowalski, Kamil */ 1409*b5c07418SJames Feist nlohmann::json invalidIndex(const int& arg1) 14101abe55efSEd Tanous { 1411*b5c07418SJames Feist return nlohmann::json{ 1412f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1413cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.InvalidIndex"}, 141455c7b7a2SEd Tanous {"Message", "The index " + std::to_string(arg1) + 1415f4c4dcf4SKowalski, Kamil " is not a valid offset into the array."}, 141685659adfSJason M. Bills {"MessageArgs", {std::to_string(arg1)}}, 1417f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 1418f12894f8SJason M. Bills {"Resolution", "Verify the index value provided is within the " 1419*b5c07418SJames Feist "bounds of the array."}}; 1420*b5c07418SJames Feist } 1421*b5c07418SJames Feist 1422*b5c07418SJames Feist void invalidIndex(crow::Response& res, const int& arg1) 1423*b5c07418SJames Feist { 1424*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1425*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidIndex(arg1)); 1426f4c4dcf4SKowalski, Kamil } 1427f4c4dcf4SKowalski, Kamil 1428f4c4dcf4SKowalski, Kamil /** 1429f4c4dcf4SKowalski, Kamil * @internal 1430f4c4dcf4SKowalski, Kamil * @brief Formats EmptyJSON message into JSON 1431f4c4dcf4SKowalski, Kamil * 1432f4c4dcf4SKowalski, Kamil * See header file for more information 1433f4c4dcf4SKowalski, Kamil * @endinternal 1434f4c4dcf4SKowalski, Kamil */ 1435*b5c07418SJames Feist nlohmann::json emptyJSON(void) 14361abe55efSEd Tanous { 1437*b5c07418SJames Feist return nlohmann::json{ 1438f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1439cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.EmptyJSON"}, 1440f12894f8SJason M. Bills {"Message", "The request body submitted contained an empty JSON " 144166ac2b8cSJason M. Bills "object and the service is unable to process it."}, 144285659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1443f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 1444f4c4dcf4SKowalski, Kamil {"Resolution", 1445*b5c07418SJames Feist "Add properties in the JSON object and resubmit the request."}}; 1446*b5c07418SJames Feist } 1447*b5c07418SJames Feist 1448*b5c07418SJames Feist void emptyJSON(crow::Response& res) 1449*b5c07418SJames Feist { 1450*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1451*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, emptyJSON()); 1452f4c4dcf4SKowalski, Kamil } 1453f4c4dcf4SKowalski, Kamil 1454f4c4dcf4SKowalski, Kamil /** 1455f4c4dcf4SKowalski, Kamil * @internal 1456f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupportedOnResource message into JSON 1457f4c4dcf4SKowalski, Kamil * 1458f4c4dcf4SKowalski, Kamil * See header file for more information 1459f4c4dcf4SKowalski, Kamil * @endinternal 1460f4c4dcf4SKowalski, Kamil */ 1461*b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void) 14621abe55efSEd Tanous { 1463*b5c07418SJames Feist return nlohmann::json{ 1464f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1465cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.QueryNotSupportedOnResource"}, 1466f4c4dcf4SKowalski, Kamil {"Message", "Querying is not supported on the requested resource."}, 146785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1468f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 146966ac2b8cSJason M. Bills {"Resolution", "Remove the query parameters and resubmit the " 1470*b5c07418SJames Feist "request if the operation failed."}}; 1471*b5c07418SJames Feist } 1472*b5c07418SJames Feist 1473*b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res) 1474*b5c07418SJames Feist { 1475*b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1476*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource()); 1477f4c4dcf4SKowalski, Kamil } 1478f4c4dcf4SKowalski, Kamil 1479f4c4dcf4SKowalski, Kamil /** 1480f4c4dcf4SKowalski, Kamil * @internal 1481f4c4dcf4SKowalski, Kamil * @brief Formats InsufficientPrivilege message into JSON 1482f4c4dcf4SKowalski, Kamil * 1483f4c4dcf4SKowalski, Kamil * See header file for more information 1484f4c4dcf4SKowalski, Kamil * @endinternal 1485f4c4dcf4SKowalski, Kamil */ 1486*b5c07418SJames Feist nlohmann::json insufficientPrivilege(void) 14871abe55efSEd Tanous { 1488*b5c07418SJames Feist return nlohmann::json{ 1489f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1490cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.InsufficientPrivilege"}, 149166ac2b8cSJason M. Bills {"Message", "There are insufficient privileges for the account or " 149266ac2b8cSJason M. Bills "credentials associated with the current session to " 149366ac2b8cSJason M. Bills "perform the requested operation."}, 149485659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1495f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1496f4c4dcf4SKowalski, Kamil {"Resolution", 1497f12894f8SJason M. Bills "Either abandon the operation or change the associated access " 1498*b5c07418SJames Feist "rights and resubmit the request if the operation failed."}}; 1499*b5c07418SJames Feist } 1500*b5c07418SJames Feist 1501*b5c07418SJames Feist void insufficientPrivilege(crow::Response& res) 1502*b5c07418SJames Feist { 1503*b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1504*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, insufficientPrivilege()); 1505f4c4dcf4SKowalski, Kamil } 1506f4c4dcf4SKowalski, Kamil 1507f4c4dcf4SKowalski, Kamil /** 1508f4c4dcf4SKowalski, Kamil * @internal 1509f4c4dcf4SKowalski, Kamil * @brief Formats PropertyValueModified message into JSON 1510f4c4dcf4SKowalski, Kamil * 1511f4c4dcf4SKowalski, Kamil * See header file for more information 1512f4c4dcf4SKowalski, Kamil * @endinternal 1513f4c4dcf4SKowalski, Kamil */ 1514*b5c07418SJames Feist nlohmann::json propertyValueModified(const std::string& arg1, 1515*b5c07418SJames Feist const std::string& arg2) 1516*b5c07418SJames Feist { 1517*b5c07418SJames Feist return nlohmann::json{ 1518*b5c07418SJames Feist {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1519*b5c07418SJames Feist {"MessageId", "Base.1.4.0.PropertyValueModified"}, 1520*b5c07418SJames Feist {"Message", "The property " + arg1 + " was assigned the value " + arg2 + 1521*b5c07418SJames Feist " due to modification by the service."}, 1522*b5c07418SJames Feist {"MessageArgs", {arg1, arg2}}, 1523*b5c07418SJames Feist {"Severity", "Warning"}, 1524*b5c07418SJames Feist {"Resolution", "No resolution is required."}}; 1525*b5c07418SJames Feist } 1526*b5c07418SJames Feist 1527f12894f8SJason M. Bills void propertyValueModified(crow::Response& res, const std::string& arg1, 1528a08b46ccSJason M. Bills const std::string& arg2) 15291abe55efSEd Tanous { 1530f12894f8SJason M. Bills res.result(boost::beast::http::status::ok); 1531*b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1); 1532f4c4dcf4SKowalski, Kamil } 1533f4c4dcf4SKowalski, Kamil 1534f4c4dcf4SKowalski, Kamil /** 1535f4c4dcf4SKowalski, Kamil * @internal 1536f4c4dcf4SKowalski, Kamil * @brief Formats AccountNotModified message into JSON 1537f4c4dcf4SKowalski, Kamil * 1538f4c4dcf4SKowalski, Kamil * See header file for more information 1539f4c4dcf4SKowalski, Kamil * @endinternal 1540f4c4dcf4SKowalski, Kamil */ 1541*b5c07418SJames Feist nlohmann::json accountNotModified(void) 15421abe55efSEd Tanous { 1543*b5c07418SJames Feist return nlohmann::json{ 1544f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1545cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.AccountNotModified"}, 1546f4c4dcf4SKowalski, Kamil {"Message", "The account modification request failed."}, 154785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1548f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 1549f12894f8SJason M. Bills {"Resolution", "The modification may have failed due to permission " 1550*b5c07418SJames Feist "issues or issues with the request body."}}; 1551*b5c07418SJames Feist } 1552*b5c07418SJames Feist 1553*b5c07418SJames Feist void accountNotModified(crow::Response& res) 1554*b5c07418SJames Feist { 1555*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1556*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountNotModified()); 1557f4c4dcf4SKowalski, Kamil } 1558f4c4dcf4SKowalski, Kamil 1559f4c4dcf4SKowalski, Kamil /** 1560f4c4dcf4SKowalski, Kamil * @internal 1561f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueFormatError message into JSON 1562f4c4dcf4SKowalski, Kamil * 1563f4c4dcf4SKowalski, Kamil * See header file for more information 1564f4c4dcf4SKowalski, Kamil * @endinternal 1565f4c4dcf4SKowalski, Kamil */ 1566*b5c07418SJames Feist nlohmann::json queryParameterValueFormatError(const std::string& arg1, 15671abe55efSEd Tanous const std::string& arg2) 15681abe55efSEd Tanous { 1569*b5c07418SJames Feist return nlohmann::json{ 1570f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1571cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.QueryParameterValueFormatError"}, 1572f4c4dcf4SKowalski, Kamil {"Message", 1573f4c4dcf4SKowalski, Kamil "The value " + arg1 + " for the parameter " + arg2 + 1574f4c4dcf4SKowalski, Kamil " is of a different format than the parameter can accept."}, 157585659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 1576f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 157766ac2b8cSJason M. Bills {"Resolution", 157866ac2b8cSJason M. Bills "Correct the value for the query parameter in the request and " 1579*b5c07418SJames Feist "resubmit the request if the operation failed."}}; 1580*b5c07418SJames Feist } 1581*b5c07418SJames Feist 1582*b5c07418SJames Feist void queryParameterValueFormatError(crow::Response& res, 1583*b5c07418SJames Feist const std::string& arg1, 1584*b5c07418SJames Feist const std::string& arg2) 1585*b5c07418SJames Feist { 1586*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1587*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1588*b5c07418SJames Feist queryParameterValueFormatError(arg1, arg2)); 1589f4c4dcf4SKowalski, Kamil } 1590f4c4dcf4SKowalski, Kamil 1591f4c4dcf4SKowalski, Kamil /** 1592f4c4dcf4SKowalski, Kamil * @internal 1593*b5c07418SJames Feist * @brief Formats PropertyMissing message into JSON for the specified 1594*b5c07418SJames Feist * property 1595f12894f8SJason M. Bills * 1596f12894f8SJason M. Bills * See header file for more information 1597f12894f8SJason M. Bills * @endinternal 1598f12894f8SJason M. Bills */ 1599*b5c07418SJames Feist nlohmann::json propertyMissing(const std::string& arg1) 1600f12894f8SJason M. Bills { 1601*b5c07418SJames Feist return nlohmann::json{ 1602f12894f8SJason M. Bills {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1603cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyMissing"}, 1604f12894f8SJason M. Bills {"Message", "The property " + arg1 + 1605f12894f8SJason M. Bills " is a required property and must be included in " 1606f12894f8SJason M. Bills "the request."}, 160785659adfSJason M. Bills {"MessageArgs", {arg1}}, 1608f12894f8SJason M. Bills {"Severity", "Warning"}, 1609f12894f8SJason M. Bills {"Resolution", 1610*b5c07418SJames Feist "Ensure that the property is in the request body and has a " 1611*b5c07418SJames Feist "valid " 1612*b5c07418SJames Feist "value and resubmit the request if the operation failed."}}; 1613*b5c07418SJames Feist } 1614*b5c07418SJames Feist 1615*b5c07418SJames Feist void propertyMissing(crow::Response& res, const std::string& arg1) 1616*b5c07418SJames Feist { 1617*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1618*b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1); 1619f4c4dcf4SKowalski, Kamil } 1620f4c4dcf4SKowalski, Kamil 1621f4c4dcf4SKowalski, Kamil /** 1622f4c4dcf4SKowalski, Kamil * @internal 1623f4c4dcf4SKowalski, Kamil * @brief Formats ResourceExhaustion message into JSON 1624f4c4dcf4SKowalski, Kamil * 1625f4c4dcf4SKowalski, Kamil * See header file for more information 1626f4c4dcf4SKowalski, Kamil * @endinternal 1627f4c4dcf4SKowalski, Kamil */ 1628*b5c07418SJames Feist nlohmann::json resourceExhaustion(const std::string& arg1) 16291abe55efSEd Tanous { 1630*b5c07418SJames Feist return nlohmann::json{ 1631f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1632cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceExhaustion"}, 1633d425c6f6SEd Tanous {"Message", "The resource " + arg1 + 163466ac2b8cSJason M. Bills " was unable to satisfy the request due to " 163566ac2b8cSJason M. Bills "unavailability of resources."}, 163685659adfSJason M. Bills {"MessageArgs", {arg1}}, 1637f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1638f12894f8SJason M. Bills {"Resolution", "Ensure that the resources are available and " 1639*b5c07418SJames Feist "resubmit the request."}}; 1640*b5c07418SJames Feist } 1641*b5c07418SJames Feist 1642*b5c07418SJames Feist void resourceExhaustion(crow::Response& res, const std::string& arg1) 1643*b5c07418SJames Feist { 1644*b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1645*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1)); 1646f4c4dcf4SKowalski, Kamil } 1647f4c4dcf4SKowalski, Kamil 1648f4c4dcf4SKowalski, Kamil /** 1649f4c4dcf4SKowalski, Kamil * @internal 1650f4c4dcf4SKowalski, Kamil * @brief Formats AccountModified message into JSON 1651f4c4dcf4SKowalski, Kamil * 1652f4c4dcf4SKowalski, Kamil * See header file for more information 1653f4c4dcf4SKowalski, Kamil * @endinternal 1654f4c4dcf4SKowalski, Kamil */ 1655*b5c07418SJames Feist nlohmann::json accountModified(void) 16561abe55efSEd Tanous { 1657*b5c07418SJames Feist return nlohmann::json{ 1658f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1659cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.AccountModified"}, 1660f4c4dcf4SKowalski, Kamil {"Message", "The account was successfully modified."}, 166185659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1662f4c4dcf4SKowalski, Kamil {"Severity", "OK"}, 1663*b5c07418SJames Feist {"Resolution", "No resolution is required."}}; 1664*b5c07418SJames Feist } 1665*b5c07418SJames Feist 1666*b5c07418SJames Feist void accountModified(crow::Response& res) 1667*b5c07418SJames Feist { 1668*b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1669*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountModified()); 1670f4c4dcf4SKowalski, Kamil } 1671f4c4dcf4SKowalski, Kamil 1672f4c4dcf4SKowalski, Kamil /** 1673f4c4dcf4SKowalski, Kamil * @internal 1674f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterOutOfRange message into JSON 1675f4c4dcf4SKowalski, Kamil * 1676f4c4dcf4SKowalski, Kamil * See header file for more information 1677f4c4dcf4SKowalski, Kamil * @endinternal 1678f4c4dcf4SKowalski, Kamil */ 1679*b5c07418SJames Feist nlohmann::json queryParameterOutOfRange(const std::string& arg1, 1680*b5c07418SJames Feist const std::string& arg2, 1681*b5c07418SJames Feist const std::string& arg3) 16821abe55efSEd Tanous { 1683*b5c07418SJames Feist return nlohmann::json{ 1684f4c4dcf4SKowalski, Kamil {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1685cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.QueryParameterOutOfRange"}, 1686*b5c07418SJames Feist {"Message", "The value " + arg1 + " for the query parameter " + arg2 + 1687*b5c07418SJames Feist " is out of range " + arg3 + "."}, 168885659adfSJason M. Bills {"MessageArgs", {arg1, arg2, arg3}}, 1689f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 1690f4c4dcf4SKowalski, Kamil {"Resolution", 1691f12894f8SJason M. Bills "Reduce the value for the query parameter to a value that is " 169266ac2b8cSJason M. Bills "within range, such as a start or count value that is within " 169366ac2b8cSJason M. Bills "bounds of the number of resources in a collection or a page that " 1694*b5c07418SJames Feist "is within the range of valid pages."}}; 1695*b5c07418SJames Feist } 1696*b5c07418SJames Feist 1697*b5c07418SJames Feist void queryParameterOutOfRange(crow::Response& res, const std::string& arg1, 1698*b5c07418SJames Feist const std::string& arg2, const std::string& arg3) 1699*b5c07418SJames Feist { 1700*b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1701*b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1702*b5c07418SJames Feist queryParameterOutOfRange(arg1, arg2, arg3)); 1703f4c4dcf4SKowalski, Kamil } 1704f4c4dcf4SKowalski, Kamil 1705f4c4dcf4SKowalski, Kamil } // namespace messages 1706f4c4dcf4SKowalski, Kamil 1707d425c6f6SEd Tanous } // namespace redfish 1708