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 */ 169ea15c35SEd Tanous #include "http_response.hpp" 17b6cd31e1SEd Tanous #include "registries/base_message_registry.hpp" 189ea15c35SEd Tanous 199ea15c35SEd Tanous #include <boost/beast/http/status.hpp> 20ace85d60SEd Tanous #include <boost/url/url.hpp> 211abe55efSEd Tanous #include <error_messages.hpp> 2204e438cbSEd Tanous #include <logging.hpp> 239ea15c35SEd Tanous #include <nlohmann/json.hpp> 24f4c4dcf4SKowalski, Kamil 251668ce6dSEd Tanous #include <array> 261668ce6dSEd Tanous 271abe55efSEd Tanous namespace redfish 281abe55efSEd Tanous { 291abe55efSEd Tanous 301abe55efSEd Tanous namespace messages 311abe55efSEd Tanous { 32f4c4dcf4SKowalski, Kamil 33f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target, 341abe55efSEd Tanous const nlohmann::json& message) 351abe55efSEd Tanous { 36f4c4dcf4SKowalski, Kamil auto& error = target["error"]; 37f4c4dcf4SKowalski, Kamil 381abe55efSEd Tanous // If this is the first error message, fill in the information from the 391abe55efSEd Tanous // first error message to the top level struct 401abe55efSEd Tanous if (!error.is_object()) 411abe55efSEd Tanous { 42c074230bSJason M. Bills auto messageIdIterator = message.find("MessageId"); 43c074230bSJason M. Bills if (messageIdIterator == message.end()) 441abe55efSEd Tanous { 451abe55efSEd Tanous BMCWEB_LOG_CRITICAL 461abe55efSEd Tanous << "Attempt to add error message without MessageId"; 47f4c4dcf4SKowalski, Kamil return; 48f4c4dcf4SKowalski, Kamil } 49f4c4dcf4SKowalski, Kamil 50c074230bSJason M. Bills auto messageFieldIterator = message.find("Message"); 51c074230bSJason M. Bills if (messageFieldIterator == message.end()) 521abe55efSEd Tanous { 531abe55efSEd Tanous BMCWEB_LOG_CRITICAL 541abe55efSEd Tanous << "Attempt to add error message without Message"; 55f4c4dcf4SKowalski, Kamil return; 56f4c4dcf4SKowalski, Kamil } 571476687dSEd Tanous error["code"] = *messageIdIterator; 581476687dSEd Tanous error["message"] = *messageFieldIterator; 591abe55efSEd Tanous } 601abe55efSEd Tanous else 611abe55efSEd Tanous { 62f4c4dcf4SKowalski, Kamil // More than 1 error occurred, so the message has to be generic 6355c7b7a2SEd Tanous error["code"] = std::string(messageVersionPrefix) + "GeneralError"; 64cc9139ecSJason M. Bills error["message"] = "A general error has occurred. See Resolution for " 65cc9139ecSJason M. Bills "information on how to resolve the error."; 66f4c4dcf4SKowalski, Kamil } 67f4c4dcf4SKowalski, Kamil 68f4c4dcf4SKowalski, Kamil // This check could technically be done in in the default construction 69f4c4dcf4SKowalski, Kamil // branch above, but because we need the pointer to the extended info field 70f4c4dcf4SKowalski, Kamil // anyway, it's more efficient to do it here. 71c074230bSJason M. Bills auto& extendedInfo = error[messages::messageAnnotation]; 72c074230bSJason M. Bills if (!extendedInfo.is_array()) 731abe55efSEd Tanous { 74c074230bSJason M. Bills extendedInfo = nlohmann::json::array(); 75f4c4dcf4SKowalski, Kamil } 76f4c4dcf4SKowalski, Kamil 77c074230bSJason M. Bills extendedInfo.push_back(message); 78f4c4dcf4SKowalski, Kamil } 79f4c4dcf4SKowalski, Kamil 80f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target, 81f12894f8SJason M. Bills const nlohmann::json& message) 821abe55efSEd Tanous { 831abe55efSEd Tanous if (!target[messages::messageAnnotation].is_array()) 841abe55efSEd Tanous { 85f4c4dcf4SKowalski, Kamil // Force object to be an array 8655c7b7a2SEd Tanous target[messages::messageAnnotation] = nlohmann::json::array(); 87f4c4dcf4SKowalski, Kamil } 88f4c4dcf4SKowalski, Kamil 8955c7b7a2SEd Tanous target[messages::messageAnnotation].push_back(message); 90f4c4dcf4SKowalski, Kamil } 91f4c4dcf4SKowalski, Kamil 92f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target, 93f12894f8SJason M. Bills const nlohmann::json& message, 941668ce6dSEd Tanous std::string_view fieldPath) 951abe55efSEd Tanous { 961668ce6dSEd Tanous std::string extendedInfo(fieldPath); 971668ce6dSEd Tanous extendedInfo += messages::messageAnnotation; 98f4c4dcf4SKowalski, Kamil 991668ce6dSEd Tanous nlohmann::json& field = target[extendedInfo]; 1001668ce6dSEd Tanous if (!field.is_array()) 1011abe55efSEd Tanous { 102f4c4dcf4SKowalski, Kamil // Force object to be an array 1031668ce6dSEd Tanous field = nlohmann::json::array(); 104f4c4dcf4SKowalski, Kamil } 105f4c4dcf4SKowalski, Kamil 106f4c4dcf4SKowalski, Kamil // Object exists and it is an array so we can just push in the message 1071668ce6dSEd Tanous field.push_back(message); 108f4c4dcf4SKowalski, Kamil } 109f4c4dcf4SKowalski, Kamil 110f7725d79SEd Tanous static nlohmann::json getLog(redfish::registries::base::Index name, 111b6cd31e1SEd Tanous std::span<const std::string_view> args) 112b6cd31e1SEd Tanous { 113b6cd31e1SEd Tanous size_t index = static_cast<size_t>(name); 114fffb8c1fSEd Tanous if (index >= redfish::registries::base::registry.size()) 115b6cd31e1SEd Tanous { 116b6cd31e1SEd Tanous return {}; 117b6cd31e1SEd Tanous } 118fffb8c1fSEd Tanous const redfish::registries::MessageEntry& entry = 119fffb8c1fSEd Tanous redfish::registries::base::registry[index]; 120b6cd31e1SEd Tanous // Intentionally make a copy of the string, so we can append in the 121b6cd31e1SEd Tanous // parameters. 122b6cd31e1SEd Tanous std::string msg = entry.second.message; 123fffb8c1fSEd Tanous redfish::registries::fillMessageArgs(args, msg); 124b6cd31e1SEd Tanous nlohmann::json jArgs = nlohmann::json::array(); 125b6cd31e1SEd Tanous for (const std::string_view arg : args) 126b6cd31e1SEd Tanous { 127b6cd31e1SEd Tanous jArgs.push_back(arg); 128b6cd31e1SEd Tanous } 129fffb8c1fSEd Tanous std::string msgId = redfish::registries::base::header.id; 130b6cd31e1SEd Tanous msgId += "."; 131b6cd31e1SEd Tanous msgId += entry.first; 1321476687dSEd Tanous nlohmann::json::object_t response; 1331476687dSEd Tanous response["@odata.type"] = "#Message.v1_1_1.Message"; 1341476687dSEd Tanous response["MessageId"] = std::move(msgId); 1351476687dSEd Tanous response["Message"] = std::move(msg); 1361476687dSEd Tanous response["MessageArgs"] = std::move(jArgs); 1371476687dSEd Tanous response["MessageSeverity"] = entry.second.messageSeverity; 1381476687dSEd Tanous response["Resolution"] = entry.second.resolution; 1391476687dSEd Tanous return response; 140b6cd31e1SEd Tanous } 141b6cd31e1SEd Tanous 142f4c4dcf4SKowalski, Kamil /** 143f4c4dcf4SKowalski, Kamil * @internal 144f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInUse message into JSON 145f4c4dcf4SKowalski, Kamil * 146f4c4dcf4SKowalski, Kamil * See header file for more information 147f4c4dcf4SKowalski, Kamil * @endinternal 148f4c4dcf4SKowalski, Kamil */ 149b5c07418SJames Feist nlohmann::json resourceInUse(void) 1501abe55efSEd Tanous { 151fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceInUse, {}); 152b5c07418SJames Feist } 153b5c07418SJames Feist 154b5c07418SJames Feist void resourceInUse(crow::Response& res) 155b5c07418SJames Feist { 156b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 157b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInUse()); 158f4c4dcf4SKowalski, Kamil } 159f4c4dcf4SKowalski, Kamil 160f4c4dcf4SKowalski, Kamil /** 161f4c4dcf4SKowalski, Kamil * @internal 162f4c4dcf4SKowalski, Kamil * @brief Formats MalformedJSON message into JSON 163f4c4dcf4SKowalski, Kamil * 164f4c4dcf4SKowalski, Kamil * See header file for more information 165f4c4dcf4SKowalski, Kamil * @endinternal 166f4c4dcf4SKowalski, Kamil */ 167b5c07418SJames Feist nlohmann::json malformedJSON(void) 1681abe55efSEd Tanous { 169fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::malformedJSON, {}); 170b5c07418SJames Feist } 171b5c07418SJames Feist 172b5c07418SJames Feist void malformedJSON(crow::Response& res) 173b5c07418SJames Feist { 174b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 175b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, malformedJSON()); 176f4c4dcf4SKowalski, Kamil } 177f4c4dcf4SKowalski, Kamil 178f4c4dcf4SKowalski, Kamil /** 179f4c4dcf4SKowalski, Kamil * @internal 180f4c4dcf4SKowalski, Kamil * @brief Formats ResourceMissingAtURI message into JSON 181f4c4dcf4SKowalski, Kamil * 182f4c4dcf4SKowalski, Kamil * See header file for more information 183f4c4dcf4SKowalski, Kamil * @endinternal 184f4c4dcf4SKowalski, Kamil */ 185ace85d60SEd Tanous nlohmann::json resourceMissingAtURI(const boost::urls::url_view& arg1) 1861abe55efSEd Tanous { 187b6cd31e1SEd Tanous std::array<std::string_view, 1> args{ 188b6cd31e1SEd Tanous std::string_view{arg1.data(), arg1.size()}}; 189fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceMissingAtURI, args); 190b5c07418SJames Feist } 191b5c07418SJames Feist 192ace85d60SEd Tanous void resourceMissingAtURI(crow::Response& res, 193ace85d60SEd Tanous const boost::urls::url_view& arg1) 194b5c07418SJames Feist { 195b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 196b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1)); 197f4c4dcf4SKowalski, Kamil } 198f4c4dcf4SKowalski, Kamil 199f4c4dcf4SKowalski, Kamil /** 200f4c4dcf4SKowalski, Kamil * @internal 201f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueFormatError message into JSON 202f4c4dcf4SKowalski, Kamil * 203f4c4dcf4SKowalski, Kamil * See header file for more information 204f4c4dcf4SKowalski, Kamil * @endinternal 205f4c4dcf4SKowalski, Kamil */ 2061668ce6dSEd Tanous nlohmann::json actionParameterValueFormatError(std::string_view arg1, 2071668ce6dSEd Tanous std::string_view arg2, 2081668ce6dSEd Tanous std::string_view arg3) 2091abe55efSEd Tanous { 210fffb8c1fSEd Tanous return getLog( 211fffb8c1fSEd Tanous redfish::registries::base::Index::actionParameterValueFormatError, 2121668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 213b5c07418SJames Feist } 214b5c07418SJames Feist 2151668ce6dSEd Tanous void actionParameterValueFormatError(crow::Response& res, std::string_view arg1, 2161668ce6dSEd Tanous std::string_view arg2, 2171668ce6dSEd Tanous std::string_view arg3) 218b5c07418SJames Feist { 219b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 220b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 221b5c07418SJames Feist actionParameterValueFormatError(arg1, arg2, arg3)); 222f4c4dcf4SKowalski, Kamil } 223f4c4dcf4SKowalski, Kamil 224f4c4dcf4SKowalski, Kamil /** 225f4c4dcf4SKowalski, Kamil * @internal 226f4c4dcf4SKowalski, Kamil * @brief Formats InternalError message into JSON 227f4c4dcf4SKowalski, Kamil * 228f4c4dcf4SKowalski, Kamil * See header file for more information 229f4c4dcf4SKowalski, Kamil * @endinternal 230f4c4dcf4SKowalski, Kamil */ 231b5c07418SJames Feist nlohmann::json internalError(void) 2321abe55efSEd Tanous { 233fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::internalError, {}); 234b5c07418SJames Feist } 235b5c07418SJames Feist 236df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location) 237b5c07418SJames Feist { 238df5415fcSEd Tanous BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "(" 239df5415fcSEd Tanous << location.line() << ":" << location.column() << ") `" 240df5415fcSEd Tanous << location.function_name() << "`: "; 241b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 242b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, internalError()); 243f12894f8SJason M. Bills } 244f12894f8SJason M. Bills 245f12894f8SJason M. Bills /** 246f12894f8SJason M. Bills * @internal 247f4c4dcf4SKowalski, Kamil * @brief Formats UnrecognizedRequestBody message into JSON 248f4c4dcf4SKowalski, Kamil * 249f4c4dcf4SKowalski, Kamil * See header file for more information 250f4c4dcf4SKowalski, Kamil * @endinternal 251f4c4dcf4SKowalski, Kamil */ 252b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void) 2531abe55efSEd Tanous { 254fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::unrecognizedRequestBody, 255fffb8c1fSEd Tanous {}); 256b5c07418SJames Feist } 257b5c07418SJames Feist 258b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res) 259b5c07418SJames Feist { 260b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 261b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody()); 262f4c4dcf4SKowalski, Kamil } 263f4c4dcf4SKowalski, Kamil 264f4c4dcf4SKowalski, Kamil /** 265f4c4dcf4SKowalski, Kamil * @internal 266f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriUnauthorized message into JSON 267f4c4dcf4SKowalski, Kamil * 268f4c4dcf4SKowalski, Kamil * See header file for more information 269f4c4dcf4SKowalski, Kamil * @endinternal 270f4c4dcf4SKowalski, Kamil */ 271ace85d60SEd Tanous nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1, 2721668ce6dSEd Tanous std::string_view arg2) 2731abe55efSEd Tanous { 274b6cd31e1SEd Tanous return getLog( 275fffb8c1fSEd Tanous redfish::registries::base::Index::resourceAtUriUnauthorized, 2761668ce6dSEd Tanous std::to_array({std::string_view{arg1.data(), arg1.size()}, arg2})); 277b5c07418SJames Feist } 278b5c07418SJames Feist 279ace85d60SEd Tanous void resourceAtUriUnauthorized(crow::Response& res, 280ace85d60SEd Tanous const boost::urls::url_view& arg1, 2811668ce6dSEd Tanous std::string_view arg2) 282b5c07418SJames Feist { 283b5c07418SJames Feist res.result(boost::beast::http::status::unauthorized); 284b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2)); 285f4c4dcf4SKowalski, Kamil } 286f4c4dcf4SKowalski, Kamil 287f4c4dcf4SKowalski, Kamil /** 288f4c4dcf4SKowalski, Kamil * @internal 289f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterUnknown message into JSON 290f4c4dcf4SKowalski, Kamil * 291f4c4dcf4SKowalski, Kamil * See header file for more information 292f4c4dcf4SKowalski, Kamil * @endinternal 293f4c4dcf4SKowalski, Kamil */ 2941668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1, 2951668ce6dSEd Tanous std::string_view arg2) 296b5c07418SJames Feist { 297fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterUnknown, 2981668ce6dSEd Tanous std::to_array({arg1, arg2})); 299b5c07418SJames Feist } 300b5c07418SJames Feist 3011668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1, 3021668ce6dSEd Tanous std::string_view arg2) 3031abe55efSEd Tanous { 304f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 305b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2)); 306f4c4dcf4SKowalski, Kamil } 307f4c4dcf4SKowalski, Kamil 308f4c4dcf4SKowalski, Kamil /** 309f4c4dcf4SKowalski, Kamil * @internal 310f4c4dcf4SKowalski, Kamil * @brief Formats ResourceCannotBeDeleted message into JSON 311f4c4dcf4SKowalski, Kamil * 312f4c4dcf4SKowalski, Kamil * See header file for more information 313f4c4dcf4SKowalski, Kamil * @endinternal 314f4c4dcf4SKowalski, Kamil */ 315b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void) 3161abe55efSEd Tanous { 317fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceCannotBeDeleted, 318fffb8c1fSEd Tanous {}); 319b5c07418SJames Feist } 320b5c07418SJames Feist 321b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res) 322b5c07418SJames Feist { 323b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 324b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted()); 325f4c4dcf4SKowalski, Kamil } 326f4c4dcf4SKowalski, Kamil 327f4c4dcf4SKowalski, Kamil /** 328f4c4dcf4SKowalski, Kamil * @internal 329f4c4dcf4SKowalski, Kamil * @brief Formats PropertyDuplicate message into JSON 330f4c4dcf4SKowalski, Kamil * 331f4c4dcf4SKowalski, Kamil * See header file for more information 332f4c4dcf4SKowalski, Kamil * @endinternal 333f4c4dcf4SKowalski, Kamil */ 3341668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1) 3351abe55efSEd Tanous { 336fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyDuplicate, 3371668ce6dSEd Tanous std::to_array({arg1})); 338b5c07418SJames Feist } 339b5c07418SJames Feist 3401668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1) 341b5c07418SJames Feist { 342b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 343b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1); 344f4c4dcf4SKowalski, Kamil } 345f4c4dcf4SKowalski, Kamil 346f4c4dcf4SKowalski, Kamil /** 347f4c4dcf4SKowalski, Kamil * @internal 348f4c4dcf4SKowalski, Kamil * @brief Formats ServiceTemporarilyUnavailable message into JSON 349f4c4dcf4SKowalski, Kamil * 350f4c4dcf4SKowalski, Kamil * See header file for more information 351f4c4dcf4SKowalski, Kamil * @endinternal 352f4c4dcf4SKowalski, Kamil */ 3531668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1) 3541abe55efSEd Tanous { 355b6cd31e1SEd Tanous return getLog( 356fffb8c1fSEd Tanous redfish::registries::base::Index::serviceTemporarilyUnavailable, 3571668ce6dSEd Tanous std::to_array({arg1})); 358b5c07418SJames Feist } 359b5c07418SJames Feist 3601668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1) 361b5c07418SJames Feist { 362b5c07418SJames Feist res.addHeader("Retry-After", arg1); 363b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 364b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1)); 365f4c4dcf4SKowalski, Kamil } 366f4c4dcf4SKowalski, Kamil 367f4c4dcf4SKowalski, Kamil /** 368f4c4dcf4SKowalski, Kamil * @internal 369f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAlreadyExists message into JSON 370f4c4dcf4SKowalski, Kamil * 371f4c4dcf4SKowalski, Kamil * See header file for more information 372f4c4dcf4SKowalski, Kamil * @endinternal 373f4c4dcf4SKowalski, Kamil */ 3741668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1, 3751668ce6dSEd Tanous std::string_view arg2, 3761668ce6dSEd Tanous std::string_view arg3) 3771abe55efSEd Tanous { 378fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceAlreadyExists, 3791668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 380b5c07418SJames Feist } 381b5c07418SJames Feist 3821668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1, 3831668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 384b5c07418SJames Feist { 385b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 386b5c07418SJames Feist addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3), 387a08b46ccSJason M. Bills arg2); 388f4c4dcf4SKowalski, Kamil } 389f4c4dcf4SKowalski, Kamil 390f4c4dcf4SKowalski, Kamil /** 391f4c4dcf4SKowalski, Kamil * @internal 392f4c4dcf4SKowalski, Kamil * @brief Formats AccountForSessionNoLongerExists message into JSON 393f4c4dcf4SKowalski, Kamil * 394f4c4dcf4SKowalski, Kamil * See header file for more information 395f4c4dcf4SKowalski, Kamil * @endinternal 396f4c4dcf4SKowalski, Kamil */ 397b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void) 3981abe55efSEd Tanous { 399fffb8c1fSEd Tanous return getLog( 400fffb8c1fSEd Tanous redfish::registries::base::Index::accountForSessionNoLongerExists, {}); 401b5c07418SJames Feist } 402b5c07418SJames Feist 403b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res) 404b5c07418SJames Feist { 405b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 406b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists()); 407f4c4dcf4SKowalski, Kamil } 408f4c4dcf4SKowalski, Kamil 409f4c4dcf4SKowalski, Kamil /** 410f4c4dcf4SKowalski, Kamil * @internal 411f4c4dcf4SKowalski, Kamil * @brief Formats CreateFailedMissingReqProperties message into JSON 412f4c4dcf4SKowalski, Kamil * 413f4c4dcf4SKowalski, Kamil * See header file for more information 414f4c4dcf4SKowalski, Kamil * @endinternal 415f4c4dcf4SKowalski, Kamil */ 4161668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1) 4171abe55efSEd Tanous { 418fffb8c1fSEd Tanous return getLog( 419fffb8c1fSEd Tanous redfish::registries::base::Index::createFailedMissingReqProperties, 4201668ce6dSEd Tanous std::to_array({arg1})); 421b5c07418SJames Feist } 422b5c07418SJames Feist 423b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res, 4241668ce6dSEd Tanous std::string_view arg1) 425b5c07418SJames Feist { 426b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 427b5c07418SJames Feist addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1), 428a08b46ccSJason M. Bills arg1); 429f12894f8SJason M. Bills } 430f12894f8SJason M. Bills 431f12894f8SJason M. Bills /** 432f12894f8SJason M. Bills * @internal 433f12894f8SJason M. Bills * @brief Formats PropertyValueFormatError message into JSON for the specified 434f12894f8SJason M. Bills * property 435f12894f8SJason M. Bills * 436f12894f8SJason M. Bills * See header file for more information 437f12894f8SJason M. Bills * @endinternal 438f12894f8SJason M. Bills */ 4391668ce6dSEd Tanous nlohmann::json propertyValueFormatError(std::string_view arg1, 4401668ce6dSEd Tanous std::string_view arg2) 441f12894f8SJason M. Bills { 442fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueFormatError, 4431668ce6dSEd Tanous std::to_array({arg1, arg2})); 444b5c07418SJames Feist } 445b5c07418SJames Feist 4461668ce6dSEd Tanous void propertyValueFormatError(crow::Response& res, std::string_view arg1, 4471668ce6dSEd Tanous std::string_view arg2) 448b5c07418SJames Feist { 449b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 450b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2); 451f12894f8SJason M. Bills } 452f12894f8SJason M. Bills 453f12894f8SJason M. Bills /** 454f12894f8SJason M. Bills * @internal 455f12894f8SJason M. Bills * @brief Formats PropertyValueNotInList message into JSON for the specified 456f12894f8SJason M. Bills * property 457f12894f8SJason M. Bills * 458f12894f8SJason M. Bills * See header file for more information 459f12894f8SJason M. Bills * @endinternal 460f12894f8SJason M. Bills */ 4611668ce6dSEd Tanous nlohmann::json propertyValueNotInList(std::string_view arg1, 4621668ce6dSEd Tanous std::string_view arg2) 463f12894f8SJason M. Bills { 464fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueNotInList, 4651668ce6dSEd Tanous std::to_array({arg1, arg2})); 466b5c07418SJames Feist } 467b5c07418SJames Feist 4681668ce6dSEd Tanous void propertyValueNotInList(crow::Response& res, std::string_view arg1, 4691668ce6dSEd Tanous std::string_view arg2) 470b5c07418SJames Feist { 471b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 472b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2); 473f4c4dcf4SKowalski, Kamil } 474f4c4dcf4SKowalski, Kamil 475f4c4dcf4SKowalski, Kamil /** 476f4c4dcf4SKowalski, Kamil * @internal 477f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriInUnknownFormat message into JSON 478f4c4dcf4SKowalski, Kamil * 479f4c4dcf4SKowalski, Kamil * See header file for more information 480f4c4dcf4SKowalski, Kamil * @endinternal 481f4c4dcf4SKowalski, Kamil */ 482ace85d60SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1) 4831abe55efSEd Tanous { 4841668ce6dSEd Tanous std::string_view arg1str{arg1.data(), arg1.size()}; 485b6cd31e1SEd Tanous return getLog( 486fffb8c1fSEd Tanous redfish::registries::base::Index::resourceAtUriInUnknownFormat, 4871668ce6dSEd Tanous std::to_array({arg1str})); 488b5c07418SJames Feist } 489b5c07418SJames Feist 490ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res, 491ace85d60SEd Tanous const boost::urls::url_view& arg1) 492b5c07418SJames Feist { 493b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 494b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1)); 495f4c4dcf4SKowalski, Kamil } 496f4c4dcf4SKowalski, Kamil 497f4c4dcf4SKowalski, Kamil /** 498f4c4dcf4SKowalski, Kamil * @internal 49981856681SAsmitha Karunanithi * @brief Formats ServiceDisabled message into JSON 50081856681SAsmitha Karunanithi * 50181856681SAsmitha Karunanithi * See header file for more information 50281856681SAsmitha Karunanithi * @endinternal 50381856681SAsmitha Karunanithi */ 5041668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1) 50581856681SAsmitha Karunanithi { 506fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceDisabled, 5071668ce6dSEd Tanous std::to_array({arg1})); 50881856681SAsmitha Karunanithi } 50981856681SAsmitha Karunanithi 5101668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1) 51181856681SAsmitha Karunanithi { 51281856681SAsmitha Karunanithi res.result(boost::beast::http::status::service_unavailable); 51381856681SAsmitha Karunanithi addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1)); 51481856681SAsmitha Karunanithi } 51581856681SAsmitha Karunanithi 51681856681SAsmitha Karunanithi /** 51781856681SAsmitha Karunanithi * @internal 518f4c4dcf4SKowalski, Kamil * @brief Formats ServiceInUnknownState message into JSON 519f4c4dcf4SKowalski, Kamil * 520f4c4dcf4SKowalski, Kamil * See header file for more information 521f4c4dcf4SKowalski, Kamil * @endinternal 522f4c4dcf4SKowalski, Kamil */ 523b5c07418SJames Feist nlohmann::json serviceInUnknownState(void) 5241abe55efSEd Tanous { 525fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceInUnknownState, {}); 526b5c07418SJames Feist } 527b5c07418SJames Feist 528b5c07418SJames Feist void serviceInUnknownState(crow::Response& res) 529b5c07418SJames Feist { 530b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 531b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceInUnknownState()); 532f4c4dcf4SKowalski, Kamil } 533f4c4dcf4SKowalski, Kamil 534f4c4dcf4SKowalski, Kamil /** 535f4c4dcf4SKowalski, Kamil * @internal 536f4c4dcf4SKowalski, Kamil * @brief Formats EventSubscriptionLimitExceeded message into JSON 537f4c4dcf4SKowalski, Kamil * 538f4c4dcf4SKowalski, Kamil * See header file for more information 539f4c4dcf4SKowalski, Kamil * @endinternal 540f4c4dcf4SKowalski, Kamil */ 541b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void) 5421abe55efSEd Tanous { 543fffb8c1fSEd Tanous return getLog( 544fffb8c1fSEd Tanous redfish::registries::base::Index::eventSubscriptionLimitExceeded, {}); 545b5c07418SJames Feist } 546b5c07418SJames Feist 547b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res) 548b5c07418SJames Feist { 549789fdab3SEd Tanous res.result(boost::beast::http::status::service_unavailable); 550b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded()); 551f4c4dcf4SKowalski, Kamil } 552f4c4dcf4SKowalski, Kamil 553f4c4dcf4SKowalski, Kamil /** 554f4c4dcf4SKowalski, Kamil * @internal 555f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterMissing message into JSON 556f4c4dcf4SKowalski, Kamil * 557f4c4dcf4SKowalski, Kamil * See header file for more information 558f4c4dcf4SKowalski, Kamil * @endinternal 559f4c4dcf4SKowalski, Kamil */ 5601668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1, 5611668ce6dSEd Tanous std::string_view arg2) 5621abe55efSEd Tanous { 563fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterMissing, 5641668ce6dSEd Tanous std::to_array({arg1, arg2})); 565b5c07418SJames Feist } 566b5c07418SJames Feist 5671668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1, 5681668ce6dSEd Tanous std::string_view arg2) 569b5c07418SJames Feist { 570b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 571b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2)); 572f4c4dcf4SKowalski, Kamil } 573f4c4dcf4SKowalski, Kamil 574f4c4dcf4SKowalski, Kamil /** 575f4c4dcf4SKowalski, Kamil * @internal 576f4c4dcf4SKowalski, Kamil * @brief Formats StringValueTooLong message into JSON 577f4c4dcf4SKowalski, Kamil * 578f4c4dcf4SKowalski, Kamil * See header file for more information 579f4c4dcf4SKowalski, Kamil * @endinternal 580f4c4dcf4SKowalski, Kamil */ 5811668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2) 5821abe55efSEd Tanous { 583b6cd31e1SEd Tanous std::string arg2String = std::to_string(arg2); 584fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::stringValueTooLong, 5851668ce6dSEd Tanous std::to_array({arg1, std::string_view(arg2String)})); 586b5c07418SJames Feist } 587b5c07418SJames Feist 5881668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2) 589b5c07418SJames Feist { 590b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 591b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2)); 592f4c4dcf4SKowalski, Kamil } 593f4c4dcf4SKowalski, Kamil 594f4c4dcf4SKowalski, Kamil /** 595f4c4dcf4SKowalski, Kamil * @internal 596cc9139ecSJason M. Bills * @brief Formats SessionTerminated message into JSON 597cc9139ecSJason M. Bills * 598cc9139ecSJason M. Bills * See header file for more information 599cc9139ecSJason M. Bills * @endinternal 600cc9139ecSJason M. Bills */ 601b5c07418SJames Feist nlohmann::json sessionTerminated(void) 602cc9139ecSJason M. Bills { 603fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::sessionTerminated, {}); 604b5c07418SJames Feist } 605b5c07418SJames Feist 606b5c07418SJames Feist void sessionTerminated(crow::Response& res) 607b5c07418SJames Feist { 608b5c07418SJames Feist res.result(boost::beast::http::status::ok); 609b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, sessionTerminated()); 610cc9139ecSJason M. Bills } 611cc9139ecSJason M. Bills 612cc9139ecSJason M. Bills /** 613cc9139ecSJason M. Bills * @internal 614684bb4b8SJason M. Bills * @brief Formats SubscriptionTerminated message into JSON 615684bb4b8SJason M. Bills * 616684bb4b8SJason M. Bills * See header file for more information 617684bb4b8SJason M. Bills * @endinternal 618684bb4b8SJason M. Bills */ 619684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void) 620684bb4b8SJason M. Bills { 621fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::subscriptionTerminated, {}); 622684bb4b8SJason M. Bills } 623684bb4b8SJason M. Bills 624684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res) 625684bb4b8SJason M. Bills { 626684bb4b8SJason M. Bills res.result(boost::beast::http::status::ok); 627684bb4b8SJason M. Bills addMessageToJsonRoot(res.jsonValue, subscriptionTerminated()); 628684bb4b8SJason M. Bills } 629684bb4b8SJason M. Bills 630684bb4b8SJason M. Bills /** 631684bb4b8SJason M. Bills * @internal 632cc9139ecSJason M. Bills * @brief Formats ResourceTypeIncompatible message into JSON 633cc9139ecSJason M. Bills * 634cc9139ecSJason M. Bills * See header file for more information 635cc9139ecSJason M. Bills * @endinternal 636cc9139ecSJason M. Bills */ 6371668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1, 6381668ce6dSEd Tanous std::string_view arg2) 639cc9139ecSJason M. Bills { 640fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceTypeIncompatible, 6411668ce6dSEd Tanous std::to_array({arg1, arg2})); 642b5c07418SJames Feist } 643b5c07418SJames Feist 6441668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1, 6451668ce6dSEd Tanous std::string_view arg2) 646b5c07418SJames Feist { 647b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 648b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2)); 649cc9139ecSJason M. Bills } 650cc9139ecSJason M. Bills 651cc9139ecSJason M. Bills /** 652cc9139ecSJason M. Bills * @internal 653684bb4b8SJason M. Bills * @brief Formats ResetRequired message into JSON 654684bb4b8SJason M. Bills * 655684bb4b8SJason M. Bills * See header file for more information 656684bb4b8SJason M. Bills * @endinternal 657684bb4b8SJason M. Bills */ 658ace85d60SEd Tanous nlohmann::json resetRequired(const boost::urls::url_view& arg1, 6591668ce6dSEd Tanous std::string_view arg2) 660684bb4b8SJason M. Bills { 6611668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 662fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resetRequired, 6631668ce6dSEd Tanous std::to_array({arg1str, arg2})); 664684bb4b8SJason M. Bills } 665684bb4b8SJason M. Bills 666ace85d60SEd Tanous void resetRequired(crow::Response& res, const boost::urls::url_view& arg1, 6671668ce6dSEd Tanous std::string_view arg2) 668684bb4b8SJason M. Bills { 669684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 670684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2)); 671684bb4b8SJason M. Bills } 672684bb4b8SJason M. Bills 673684bb4b8SJason M. Bills /** 674684bb4b8SJason M. Bills * @internal 675684bb4b8SJason M. Bills * @brief Formats ChassisPowerStateOnRequired message into JSON 676684bb4b8SJason M. Bills * 677684bb4b8SJason M. Bills * See header file for more information 678684bb4b8SJason M. Bills * @endinternal 679684bb4b8SJason M. Bills */ 6801668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1) 681684bb4b8SJason M. Bills { 682fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resetRequired, 6831668ce6dSEd Tanous std::to_array({arg1})); 684684bb4b8SJason M. Bills } 685684bb4b8SJason M. Bills 6861668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1) 687684bb4b8SJason M. Bills { 688684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 689684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1)); 690684bb4b8SJason M. Bills } 691684bb4b8SJason M. Bills 692684bb4b8SJason M. Bills /** 693684bb4b8SJason M. Bills * @internal 694684bb4b8SJason M. Bills * @brief Formats ChassisPowerStateOffRequired message into JSON 695684bb4b8SJason M. Bills * 696684bb4b8SJason M. Bills * See header file for more information 697684bb4b8SJason M. Bills * @endinternal 698684bb4b8SJason M. Bills */ 6991668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1) 700684bb4b8SJason M. Bills { 701b6cd31e1SEd Tanous return getLog( 702fffb8c1fSEd Tanous redfish::registries::base::Index::chassisPowerStateOffRequired, 7031668ce6dSEd Tanous std::to_array({arg1})); 704684bb4b8SJason M. Bills } 705684bb4b8SJason M. Bills 7061668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1) 707684bb4b8SJason M. Bills { 708684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 709684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1)); 710684bb4b8SJason M. Bills } 711684bb4b8SJason M. Bills 712684bb4b8SJason M. Bills /** 713684bb4b8SJason M. Bills * @internal 714684bb4b8SJason M. Bills * @brief Formats PropertyValueConflict message into JSON 715684bb4b8SJason M. Bills * 716684bb4b8SJason M. Bills * See header file for more information 717684bb4b8SJason M. Bills * @endinternal 718684bb4b8SJason M. Bills */ 7191668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1, 7201668ce6dSEd Tanous std::string_view arg2) 721684bb4b8SJason M. Bills { 722fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueConflict, 7231668ce6dSEd Tanous std::to_array({arg1, arg2})); 724684bb4b8SJason M. Bills } 725684bb4b8SJason M. Bills 7261668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1, 7271668ce6dSEd Tanous std::string_view arg2) 728684bb4b8SJason M. Bills { 729684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 730684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2)); 731684bb4b8SJason M. Bills } 732684bb4b8SJason M. Bills 733684bb4b8SJason M. Bills /** 734684bb4b8SJason M. Bills * @internal 7352a6af81cSRamesh Iyyar * @brief Formats PropertyValueResourceConflict message into JSON 7362a6af81cSRamesh Iyyar * 7372a6af81cSRamesh Iyyar * See header file for more information 7382a6af81cSRamesh Iyyar * @endinternal 7392a6af81cSRamesh Iyyar */ 7402a6af81cSRamesh Iyyar nlohmann::json propertyValueResourceConflict(std::string_view arg1, 7412a6af81cSRamesh Iyyar std::string_view arg2, 7422a6af81cSRamesh Iyyar const boost::urls::url_view& arg3) 7432a6af81cSRamesh Iyyar { 7442a6af81cSRamesh Iyyar return getLog( 7452a6af81cSRamesh Iyyar redfish::registries::base::Index::propertyValueResourceConflict, 7462a6af81cSRamesh Iyyar std::to_array( 7472a6af81cSRamesh Iyyar {arg1, arg2, std::string_view{arg3.data(), arg3.size()}})); 7482a6af81cSRamesh Iyyar } 7492a6af81cSRamesh Iyyar 7502a6af81cSRamesh Iyyar void propertyValueResourceConflict(crow::Response& res, std::string_view arg1, 7512a6af81cSRamesh Iyyar std::string_view arg2, 7522a6af81cSRamesh Iyyar const boost::urls::url_view& arg3) 7532a6af81cSRamesh Iyyar { 7542a6af81cSRamesh Iyyar res.result(boost::beast::http::status::conflict); 7552a6af81cSRamesh Iyyar addMessageToErrorJson(res.jsonValue, 7562a6af81cSRamesh Iyyar propertyValueResourceConflict(arg1, arg2, arg3)); 7572a6af81cSRamesh Iyyar } 7582a6af81cSRamesh Iyyar 7592a6af81cSRamesh Iyyar /** 7602a6af81cSRamesh Iyyar * @internal 76124861a28SRamesh Iyyar * @brief Formats PropertyValueExternalConflict message into JSON 76224861a28SRamesh Iyyar * 76324861a28SRamesh Iyyar * See header file for more information 76424861a28SRamesh Iyyar * @endinternal 76524861a28SRamesh Iyyar */ 76624861a28SRamesh Iyyar nlohmann::json propertyValueExternalConflict(std::string_view arg1, 76724861a28SRamesh Iyyar std::string_view arg2) 76824861a28SRamesh Iyyar { 76924861a28SRamesh Iyyar return getLog( 77024861a28SRamesh Iyyar redfish::registries::base::Index::propertyValueExternalConflict, 77124861a28SRamesh Iyyar std::to_array({arg1, arg2})); 77224861a28SRamesh Iyyar } 77324861a28SRamesh Iyyar 77424861a28SRamesh Iyyar void propertyValueExternalConflict(crow::Response& res, std::string_view arg1, 77524861a28SRamesh Iyyar std::string_view arg2) 77624861a28SRamesh Iyyar { 77724861a28SRamesh Iyyar res.result(boost::beast::http::status::conflict); 77824861a28SRamesh Iyyar addMessageToErrorJson(res.jsonValue, 77924861a28SRamesh Iyyar propertyValueExternalConflict(arg1, arg2)); 78024861a28SRamesh Iyyar } 78124861a28SRamesh Iyyar 78224861a28SRamesh Iyyar /** 78324861a28SRamesh Iyyar * @internal 784684bb4b8SJason M. Bills * @brief Formats PropertyValueIncorrect message into JSON 785684bb4b8SJason M. Bills * 786684bb4b8SJason M. Bills * See header file for more information 787684bb4b8SJason M. Bills * @endinternal 788684bb4b8SJason M. Bills */ 7891668ce6dSEd Tanous nlohmann::json propertyValueIncorrect(std::string_view arg1, 7901668ce6dSEd Tanous std::string_view arg2) 791684bb4b8SJason M. Bills { 792fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueIncorrect, 7931668ce6dSEd Tanous std::to_array({arg1, arg2})); 794684bb4b8SJason M. Bills } 795684bb4b8SJason M. Bills 7961668ce6dSEd Tanous void propertyValueIncorrect(crow::Response& res, std::string_view arg1, 7971668ce6dSEd Tanous std::string_view arg2) 798684bb4b8SJason M. Bills { 799684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 800684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2)); 801684bb4b8SJason M. Bills } 802684bb4b8SJason M. Bills 803684bb4b8SJason M. Bills /** 804684bb4b8SJason M. Bills * @internal 805684bb4b8SJason M. Bills * @brief Formats ResourceCreationConflict message into JSON 806684bb4b8SJason M. Bills * 807684bb4b8SJason M. Bills * See header file for more information 808684bb4b8SJason M. Bills * @endinternal 809684bb4b8SJason M. Bills */ 810ace85d60SEd Tanous nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1) 811684bb4b8SJason M. Bills { 8121668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 813fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceCreationConflict, 8141668ce6dSEd Tanous std::to_array({arg1str})); 815684bb4b8SJason M. Bills } 816684bb4b8SJason M. Bills 817ace85d60SEd Tanous void resourceCreationConflict(crow::Response& res, 818ace85d60SEd Tanous const boost::urls::url_view& arg1) 819684bb4b8SJason M. Bills { 820684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 821684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1)); 822684bb4b8SJason M. Bills } 823684bb4b8SJason M. Bills 824684bb4b8SJason M. Bills /** 825684bb4b8SJason M. Bills * @internal 826684bb4b8SJason M. Bills * @brief Formats MaximumErrorsExceeded message into JSON 827684bb4b8SJason M. Bills * 828684bb4b8SJason M. Bills * See header file for more information 829684bb4b8SJason M. Bills * @endinternal 830684bb4b8SJason M. Bills */ 831684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void) 832684bb4b8SJason M. Bills { 833fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {}); 834684bb4b8SJason M. Bills } 835684bb4b8SJason M. Bills 836684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res) 837684bb4b8SJason M. Bills { 838684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 839684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded()); 840684bb4b8SJason M. Bills } 841684bb4b8SJason M. Bills 842684bb4b8SJason M. Bills /** 843684bb4b8SJason M. Bills * @internal 844684bb4b8SJason M. Bills * @brief Formats PreconditionFailed message into JSON 845684bb4b8SJason M. Bills * 846684bb4b8SJason M. Bills * See header file for more information 847684bb4b8SJason M. Bills * @endinternal 848684bb4b8SJason M. Bills */ 849684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void) 850684bb4b8SJason M. Bills { 851fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::preconditionFailed, {}); 852684bb4b8SJason M. Bills } 853684bb4b8SJason M. Bills 854684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res) 855684bb4b8SJason M. Bills { 8564df1bee0SEd Tanous res.result(boost::beast::http::status::precondition_failed); 857684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, preconditionFailed()); 858684bb4b8SJason M. Bills } 859684bb4b8SJason M. Bills 860684bb4b8SJason M. Bills /** 861684bb4b8SJason M. Bills * @internal 862684bb4b8SJason M. Bills * @brief Formats PreconditionRequired message into JSON 863684bb4b8SJason M. Bills * 864684bb4b8SJason M. Bills * See header file for more information 865684bb4b8SJason M. Bills * @endinternal 866684bb4b8SJason M. Bills */ 867684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void) 868684bb4b8SJason M. Bills { 869fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::preconditionRequired, {}); 870684bb4b8SJason M. Bills } 871684bb4b8SJason M. Bills 872684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res) 873684bb4b8SJason M. Bills { 874684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 875684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, preconditionRequired()); 876684bb4b8SJason M. Bills } 877684bb4b8SJason M. Bills 878684bb4b8SJason M. Bills /** 879684bb4b8SJason M. Bills * @internal 880684bb4b8SJason M. Bills * @brief Formats OperationFailed message into JSON 881684bb4b8SJason M. Bills * 882684bb4b8SJason M. Bills * See header file for more information 883684bb4b8SJason M. Bills * @endinternal 884684bb4b8SJason M. Bills */ 885684bb4b8SJason M. Bills nlohmann::json operationFailed(void) 886684bb4b8SJason M. Bills { 887fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::operationFailed, {}); 888684bb4b8SJason M. Bills } 889684bb4b8SJason M. Bills 890684bb4b8SJason M. Bills void operationFailed(crow::Response& res) 891684bb4b8SJason M. Bills { 892*8868776eSEd Tanous res.result(boost::beast::http::status::bad_gateway); 893684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, operationFailed()); 894684bb4b8SJason M. Bills } 895684bb4b8SJason M. Bills 896684bb4b8SJason M. Bills /** 897684bb4b8SJason M. Bills * @internal 898684bb4b8SJason M. Bills * @brief Formats OperationTimeout message into JSON 899684bb4b8SJason M. Bills * 900684bb4b8SJason M. Bills * See header file for more information 901684bb4b8SJason M. Bills * @endinternal 902684bb4b8SJason M. Bills */ 903684bb4b8SJason M. Bills nlohmann::json operationTimeout(void) 904684bb4b8SJason M. Bills { 905fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::operationTimeout, {}); 906684bb4b8SJason M. Bills } 907684bb4b8SJason M. Bills 908684bb4b8SJason M. Bills void operationTimeout(crow::Response& res) 909684bb4b8SJason M. Bills { 910684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 911684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, operationTimeout()); 912684bb4b8SJason M. Bills } 913684bb4b8SJason M. Bills 914684bb4b8SJason M. Bills /** 915684bb4b8SJason M. Bills * @internal 916f12894f8SJason M. Bills * @brief Formats PropertyValueTypeError message into JSON for the specified 917f12894f8SJason M. Bills * property 918f12894f8SJason M. Bills * 919f12894f8SJason M. Bills * See header file for more information 920f12894f8SJason M. Bills * @endinternal 921f12894f8SJason M. Bills */ 9221668ce6dSEd Tanous nlohmann::json propertyValueTypeError(std::string_view arg1, 9231668ce6dSEd Tanous std::string_view arg2) 924f12894f8SJason M. Bills { 925fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueTypeError, 9261668ce6dSEd Tanous std::to_array({arg1, arg2})); 927b5c07418SJames Feist } 928b5c07418SJames Feist 9291668ce6dSEd Tanous void propertyValueTypeError(crow::Response& res, std::string_view arg1, 9301668ce6dSEd Tanous std::string_view arg2) 931b5c07418SJames Feist { 932b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 933b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2); 934f4c4dcf4SKowalski, Kamil } 935f4c4dcf4SKowalski, Kamil 936f4c4dcf4SKowalski, Kamil /** 937f4c4dcf4SKowalski, Kamil * @internal 938b6cd31e1SEd Tanous * @brief Formats ResourceNotFound message into JSONd 939f4c4dcf4SKowalski, Kamil * 940f4c4dcf4SKowalski, Kamil * See header file for more information 941f4c4dcf4SKowalski, Kamil * @endinternal 942f4c4dcf4SKowalski, Kamil */ 9431668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2) 9441abe55efSEd Tanous { 945fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceNotFound, 9461668ce6dSEd Tanous std::to_array({arg1, arg2})); 947b5c07418SJames Feist } 948b5c07418SJames Feist 9491668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1, 9501668ce6dSEd Tanous std::string_view arg2) 951b5c07418SJames Feist { 952b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 953b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2)); 954f4c4dcf4SKowalski, Kamil } 955f4c4dcf4SKowalski, Kamil 956f4c4dcf4SKowalski, Kamil /** 957f4c4dcf4SKowalski, Kamil * @internal 958f4c4dcf4SKowalski, Kamil * @brief Formats CouldNotEstablishConnection message into JSON 959f4c4dcf4SKowalski, Kamil * 960f4c4dcf4SKowalski, Kamil * See header file for more information 961f4c4dcf4SKowalski, Kamil * @endinternal 962f4c4dcf4SKowalski, Kamil */ 963ace85d60SEd Tanous nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1) 9641abe55efSEd Tanous { 9651668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 966fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::couldNotEstablishConnection, 9671668ce6dSEd Tanous std::to_array({arg1str})); 968b5c07418SJames Feist } 969b5c07418SJames Feist 970ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res, 971ace85d60SEd Tanous const boost::urls::url_view& arg1) 972b5c07418SJames Feist { 973b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 974b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1)); 975f4c4dcf4SKowalski, Kamil } 976f4c4dcf4SKowalski, Kamil 977f4c4dcf4SKowalski, Kamil /** 978f4c4dcf4SKowalski, Kamil * @internal 979f12894f8SJason M. Bills * @brief Formats PropertyNotWritable message into JSON for the specified 980f12894f8SJason M. Bills * property 981f12894f8SJason M. Bills * 982f12894f8SJason M. Bills * See header file for more information 983f12894f8SJason M. Bills * @endinternal 984f12894f8SJason M. Bills */ 9851668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1) 986f12894f8SJason M. Bills { 987fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyNotWritable, 9881668ce6dSEd Tanous std::to_array({arg1})); 989b5c07418SJames Feist } 990b5c07418SJames Feist 9911668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1) 992b5c07418SJames Feist { 993b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 994b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1); 995f4c4dcf4SKowalski, Kamil } 996f4c4dcf4SKowalski, Kamil 997f4c4dcf4SKowalski, Kamil /** 998f4c4dcf4SKowalski, Kamil * @internal 999f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueTypeError message into JSON 1000f4c4dcf4SKowalski, Kamil * 1001f4c4dcf4SKowalski, Kamil * See header file for more information 1002f4c4dcf4SKowalski, Kamil * @endinternal 1003f4c4dcf4SKowalski, Kamil */ 10041668ce6dSEd Tanous nlohmann::json queryParameterValueTypeError(std::string_view arg1, 10051668ce6dSEd Tanous std::string_view arg2) 10061abe55efSEd Tanous { 1007b6cd31e1SEd Tanous return getLog( 1008fffb8c1fSEd Tanous redfish::registries::base::Index::queryParameterValueTypeError, 10091668ce6dSEd Tanous std::to_array({arg1, arg2})); 1010b5c07418SJames Feist } 1011b5c07418SJames Feist 10121668ce6dSEd Tanous void queryParameterValueTypeError(crow::Response& res, std::string_view arg1, 10131668ce6dSEd Tanous std::string_view arg2) 1014b5c07418SJames Feist { 1015b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1016b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1017b5c07418SJames Feist queryParameterValueTypeError(arg1, arg2)); 1018f4c4dcf4SKowalski, Kamil } 1019f4c4dcf4SKowalski, Kamil 1020f4c4dcf4SKowalski, Kamil /** 1021f4c4dcf4SKowalski, Kamil * @internal 1022f4c4dcf4SKowalski, Kamil * @brief Formats ServiceShuttingDown message into JSON 1023f4c4dcf4SKowalski, Kamil * 1024f4c4dcf4SKowalski, Kamil * See header file for more information 1025f4c4dcf4SKowalski, Kamil * @endinternal 1026f4c4dcf4SKowalski, Kamil */ 1027b5c07418SJames Feist nlohmann::json serviceShuttingDown(void) 10281abe55efSEd Tanous { 1029fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceShuttingDown, {}); 1030b5c07418SJames Feist } 1031b5c07418SJames Feist 1032b5c07418SJames Feist void serviceShuttingDown(crow::Response& res) 1033b5c07418SJames Feist { 1034b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1035b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceShuttingDown()); 1036f4c4dcf4SKowalski, Kamil } 1037f4c4dcf4SKowalski, Kamil 1038f4c4dcf4SKowalski, Kamil /** 1039f4c4dcf4SKowalski, Kamil * @internal 1040f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterDuplicate message into JSON 1041f4c4dcf4SKowalski, Kamil * 1042f4c4dcf4SKowalski, Kamil * See header file for more information 1043f4c4dcf4SKowalski, Kamil * @endinternal 1044f4c4dcf4SKowalski, Kamil */ 10451668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1, 10461668ce6dSEd Tanous std::string_view arg2) 10471abe55efSEd Tanous { 1048fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterDuplicate, 10491668ce6dSEd Tanous std::to_array({arg1, arg2})); 1050b5c07418SJames Feist } 1051b5c07418SJames Feist 10521668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1, 10531668ce6dSEd Tanous std::string_view arg2) 1054b5c07418SJames Feist { 1055b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1056b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2)); 1057f4c4dcf4SKowalski, Kamil } 1058f4c4dcf4SKowalski, Kamil 1059f4c4dcf4SKowalski, Kamil /** 1060f4c4dcf4SKowalski, Kamil * @internal 1061f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterNotSupported message into JSON 1062f4c4dcf4SKowalski, Kamil * 1063f4c4dcf4SKowalski, Kamil * See header file for more information 1064f4c4dcf4SKowalski, Kamil * @endinternal 1065f4c4dcf4SKowalski, Kamil */ 10661668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1, 10671668ce6dSEd Tanous std::string_view arg2) 10681abe55efSEd Tanous { 1069fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterNotSupported, 10701668ce6dSEd Tanous std::to_array({arg1, arg2})); 1071b5c07418SJames Feist } 1072b5c07418SJames Feist 10731668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1, 10741668ce6dSEd Tanous std::string_view arg2) 1075b5c07418SJames Feist { 1076b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1077b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1078b5c07418SJames Feist actionParameterNotSupported(arg1, arg2)); 1079f4c4dcf4SKowalski, Kamil } 1080f4c4dcf4SKowalski, Kamil 1081f4c4dcf4SKowalski, Kamil /** 1082f4c4dcf4SKowalski, Kamil * @internal 1083f4c4dcf4SKowalski, Kamil * @brief Formats SourceDoesNotSupportProtocol message into JSON 1084f4c4dcf4SKowalski, Kamil * 1085f4c4dcf4SKowalski, Kamil * See header file for more information 1086f4c4dcf4SKowalski, Kamil * @endinternal 1087f4c4dcf4SKowalski, Kamil */ 1088ace85d60SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1, 10891668ce6dSEd Tanous std::string_view arg2) 10901abe55efSEd Tanous { 10911668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 1092b6cd31e1SEd Tanous return getLog( 1093fffb8c1fSEd Tanous redfish::registries::base::Index::sourceDoesNotSupportProtocol, 10941668ce6dSEd Tanous std::to_array({arg1str, arg2})); 1095b5c07418SJames Feist } 1096b5c07418SJames Feist 1097ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res, 1098ace85d60SEd Tanous const boost::urls::url_view& arg1, 10991668ce6dSEd Tanous std::string_view arg2) 1100b5c07418SJames Feist { 1101b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1102b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1103b5c07418SJames Feist sourceDoesNotSupportProtocol(arg1, arg2)); 1104f4c4dcf4SKowalski, Kamil } 1105f4c4dcf4SKowalski, Kamil 1106f4c4dcf4SKowalski, Kamil /** 1107f4c4dcf4SKowalski, Kamil * @internal 1108f4c4dcf4SKowalski, Kamil * @brief Formats AccountRemoved message into JSON 1109f4c4dcf4SKowalski, Kamil * 1110f4c4dcf4SKowalski, Kamil * See header file for more information 1111f4c4dcf4SKowalski, Kamil * @endinternal 1112f4c4dcf4SKowalski, Kamil */ 1113b5c07418SJames Feist nlohmann::json accountRemoved(void) 11141abe55efSEd Tanous { 1115fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountRemoved, {}); 1116b5c07418SJames Feist } 1117b5c07418SJames Feist 1118b5c07418SJames Feist void accountRemoved(crow::Response& res) 1119b5c07418SJames Feist { 1120b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1121b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, accountRemoved()); 1122f4c4dcf4SKowalski, Kamil } 1123f4c4dcf4SKowalski, Kamil 1124f4c4dcf4SKowalski, Kamil /** 1125f4c4dcf4SKowalski, Kamil * @internal 1126f4c4dcf4SKowalski, Kamil * @brief Formats AccessDenied message into JSON 1127f4c4dcf4SKowalski, Kamil * 1128f4c4dcf4SKowalski, Kamil * See header file for more information 1129f4c4dcf4SKowalski, Kamil * @endinternal 1130f4c4dcf4SKowalski, Kamil */ 1131ace85d60SEd Tanous nlohmann::json accessDenied(const boost::urls::url_view& arg1) 11321abe55efSEd Tanous { 11331668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 1134fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accessDenied, 11351668ce6dSEd Tanous std::to_array({arg1str})); 1136b5c07418SJames Feist } 1137b5c07418SJames Feist 1138ace85d60SEd Tanous void accessDenied(crow::Response& res, const boost::urls::url_view& arg1) 1139b5c07418SJames Feist { 1140b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1141b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accessDenied(arg1)); 1142f4c4dcf4SKowalski, Kamil } 1143f4c4dcf4SKowalski, Kamil 1144f4c4dcf4SKowalski, Kamil /** 1145f4c4dcf4SKowalski, Kamil * @internal 1146f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupported message into JSON 1147f4c4dcf4SKowalski, Kamil * 1148f4c4dcf4SKowalski, Kamil * See header file for more information 1149f4c4dcf4SKowalski, Kamil * @endinternal 1150f4c4dcf4SKowalski, Kamil */ 1151b5c07418SJames Feist nlohmann::json queryNotSupported(void) 11521abe55efSEd Tanous { 1153fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryNotSupported, {}); 1154b5c07418SJames Feist } 1155b5c07418SJames Feist 1156b5c07418SJames Feist void queryNotSupported(crow::Response& res) 1157b5c07418SJames Feist { 1158b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1159b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupported()); 1160f4c4dcf4SKowalski, Kamil } 1161f4c4dcf4SKowalski, Kamil 1162f4c4dcf4SKowalski, Kamil /** 1163f4c4dcf4SKowalski, Kamil * @internal 1164f4c4dcf4SKowalski, Kamil * @brief Formats CreateLimitReachedForResource message into JSON 1165f4c4dcf4SKowalski, Kamil * 1166f4c4dcf4SKowalski, Kamil * See header file for more information 1167f4c4dcf4SKowalski, Kamil * @endinternal 1168f4c4dcf4SKowalski, Kamil */ 1169b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void) 11701abe55efSEd Tanous { 1171b6cd31e1SEd Tanous return getLog( 1172fffb8c1fSEd Tanous redfish::registries::base::Index::createLimitReachedForResource, {}); 1173b5c07418SJames Feist } 1174b5c07418SJames Feist 1175b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res) 1176b5c07418SJames Feist { 1177b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1178b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, createLimitReachedForResource()); 1179f4c4dcf4SKowalski, Kamil } 1180f4c4dcf4SKowalski, Kamil 1181f4c4dcf4SKowalski, Kamil /** 1182f4c4dcf4SKowalski, Kamil * @internal 1183f4c4dcf4SKowalski, Kamil * @brief Formats GeneralError message into JSON 1184f4c4dcf4SKowalski, Kamil * 1185f4c4dcf4SKowalski, Kamil * See header file for more information 1186f4c4dcf4SKowalski, Kamil * @endinternal 1187f4c4dcf4SKowalski, Kamil */ 1188b5c07418SJames Feist nlohmann::json generalError(void) 11891abe55efSEd Tanous { 1190fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::generalError, {}); 1191b5c07418SJames Feist } 1192b5c07418SJames Feist 1193b5c07418SJames Feist void generalError(crow::Response& res) 1194b5c07418SJames Feist { 1195b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 1196b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, generalError()); 1197f4c4dcf4SKowalski, Kamil } 1198f4c4dcf4SKowalski, Kamil 1199f4c4dcf4SKowalski, Kamil /** 1200f4c4dcf4SKowalski, Kamil * @internal 1201f4c4dcf4SKowalski, Kamil * @brief Formats Success message into JSON 1202f4c4dcf4SKowalski, Kamil * 1203f4c4dcf4SKowalski, Kamil * See header file for more information 1204f4c4dcf4SKowalski, Kamil * @endinternal 1205f4c4dcf4SKowalski, Kamil */ 1206b5c07418SJames Feist nlohmann::json success(void) 12071abe55efSEd Tanous { 1208fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::success, {}); 1209b5c07418SJames Feist } 1210b5c07418SJames Feist 1211b5c07418SJames Feist void success(crow::Response& res) 1212b5c07418SJames Feist { 1213b5c07418SJames Feist // don't set res.result here because success is the default and any 1214b5c07418SJames Feist // error should overwrite the default 1215b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, success()); 1216f12894f8SJason M. Bills } 1217f12894f8SJason M. Bills 1218f12894f8SJason M. Bills /** 1219f12894f8SJason M. Bills * @internal 1220f4c4dcf4SKowalski, Kamil * @brief Formats Created message into JSON 1221f4c4dcf4SKowalski, Kamil * 1222f4c4dcf4SKowalski, Kamil * See header file for more information 1223f4c4dcf4SKowalski, Kamil * @endinternal 1224f4c4dcf4SKowalski, Kamil */ 1225b5c07418SJames Feist nlohmann::json created(void) 12261abe55efSEd Tanous { 1227fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::created, {}); 1228b5c07418SJames Feist } 1229b5c07418SJames Feist 1230b5c07418SJames Feist void created(crow::Response& res) 1231b5c07418SJames Feist { 1232b5c07418SJames Feist res.result(boost::beast::http::status::created); 1233b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, created()); 1234f4c4dcf4SKowalski, Kamil } 1235f4c4dcf4SKowalski, Kamil 1236f4c4dcf4SKowalski, Kamil /** 1237f4c4dcf4SKowalski, Kamil * @internal 1238cc9139ecSJason M. Bills * @brief Formats NoOperation message into JSON 1239cc9139ecSJason M. Bills * 1240cc9139ecSJason M. Bills * See header file for more information 1241cc9139ecSJason M. Bills * @endinternal 1242cc9139ecSJason M. Bills */ 1243b5c07418SJames Feist nlohmann::json noOperation(void) 1244cc9139ecSJason M. Bills { 1245fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::noOperation, {}); 1246b5c07418SJames Feist } 1247b5c07418SJames Feist 1248b5c07418SJames Feist void noOperation(crow::Response& res) 1249b5c07418SJames Feist { 1250b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1251b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noOperation()); 1252cc9139ecSJason M. Bills } 1253cc9139ecSJason M. Bills 1254cc9139ecSJason M. Bills /** 1255cc9139ecSJason M. Bills * @internal 1256b5c07418SJames Feist * @brief Formats PropertyUnknown message into JSON for the specified 1257b5c07418SJames Feist * property 1258f12894f8SJason M. Bills * 1259f12894f8SJason M. Bills * See header file for more information 1260f12894f8SJason M. Bills * @endinternal 1261f12894f8SJason M. Bills */ 12621668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1) 1263b5c07418SJames Feist { 1264fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyUnknown, 12651668ce6dSEd Tanous std::to_array({arg1})); 1266b5c07418SJames Feist } 1267b5c07418SJames Feist 12681668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1) 1269f12894f8SJason M. Bills { 1270f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 1271b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1); 1272f4c4dcf4SKowalski, Kamil } 1273f4c4dcf4SKowalski, Kamil 1274f4c4dcf4SKowalski, Kamil /** 1275f4c4dcf4SKowalski, Kamil * @internal 1276f4c4dcf4SKowalski, Kamil * @brief Formats NoValidSession message into JSON 1277f4c4dcf4SKowalski, Kamil * 1278f4c4dcf4SKowalski, Kamil * See header file for more information 1279f4c4dcf4SKowalski, Kamil * @endinternal 1280f4c4dcf4SKowalski, Kamil */ 1281b5c07418SJames Feist nlohmann::json noValidSession(void) 12821abe55efSEd Tanous { 1283fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::noValidSession, {}); 1284b5c07418SJames Feist } 1285b5c07418SJames Feist 1286b5c07418SJames Feist void noValidSession(crow::Response& res) 1287b5c07418SJames Feist { 1288b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1289b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noValidSession()); 1290f4c4dcf4SKowalski, Kamil } 1291f4c4dcf4SKowalski, Kamil 1292f4c4dcf4SKowalski, Kamil /** 1293f4c4dcf4SKowalski, Kamil * @internal 1294f4c4dcf4SKowalski, Kamil * @brief Formats InvalidObject message into JSON 1295f4c4dcf4SKowalski, Kamil * 1296f4c4dcf4SKowalski, Kamil * See header file for more information 1297f4c4dcf4SKowalski, Kamil * @endinternal 1298f4c4dcf4SKowalski, Kamil */ 1299ace85d60SEd Tanous nlohmann::json invalidObject(const boost::urls::url_view& arg1) 13001abe55efSEd Tanous { 13011668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 1302fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::invalidObject, 13031668ce6dSEd Tanous std::to_array({arg1str})); 1304b5c07418SJames Feist } 1305b5c07418SJames Feist 1306ace85d60SEd Tanous void invalidObject(crow::Response& res, const boost::urls::url_view& arg1) 1307b5c07418SJames Feist { 1308b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1309b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidObject(arg1)); 1310f4c4dcf4SKowalski, Kamil } 1311f4c4dcf4SKowalski, Kamil 1312f4c4dcf4SKowalski, Kamil /** 1313f4c4dcf4SKowalski, Kamil * @internal 1314f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInStandby message into JSON 1315f4c4dcf4SKowalski, Kamil * 1316f4c4dcf4SKowalski, Kamil * See header file for more information 1317f4c4dcf4SKowalski, Kamil * @endinternal 1318f4c4dcf4SKowalski, Kamil */ 1319b5c07418SJames Feist nlohmann::json resourceInStandby(void) 13201abe55efSEd Tanous { 1321fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceInStandby, {}); 1322b5c07418SJames Feist } 1323b5c07418SJames Feist 1324b5c07418SJames Feist void resourceInStandby(crow::Response& res) 1325b5c07418SJames Feist { 1326b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1327b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInStandby()); 1328f4c4dcf4SKowalski, Kamil } 1329f4c4dcf4SKowalski, Kamil 1330f4c4dcf4SKowalski, Kamil /** 1331f4c4dcf4SKowalski, Kamil * @internal 1332f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueTypeError message into JSON 1333f4c4dcf4SKowalski, Kamil * 1334f4c4dcf4SKowalski, Kamil * See header file for more information 1335f4c4dcf4SKowalski, Kamil * @endinternal 1336f4c4dcf4SKowalski, Kamil */ 13371668ce6dSEd Tanous nlohmann::json actionParameterValueTypeError(std::string_view arg1, 13381668ce6dSEd Tanous std::string_view arg2, 13391668ce6dSEd Tanous std::string_view arg3) 13401abe55efSEd Tanous { 1341b6cd31e1SEd Tanous return getLog( 1342fffb8c1fSEd Tanous redfish::registries::base::Index::actionParameterValueTypeError, 13431668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 1344b5c07418SJames Feist } 1345b5c07418SJames Feist 13461668ce6dSEd Tanous void actionParameterValueTypeError(crow::Response& res, std::string_view arg1, 13471668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 1348b5c07418SJames Feist { 1349b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1350b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1351b5c07418SJames Feist actionParameterValueTypeError(arg1, arg2, arg3)); 1352f4c4dcf4SKowalski, Kamil } 1353f4c4dcf4SKowalski, Kamil 1354f4c4dcf4SKowalski, Kamil /** 1355f4c4dcf4SKowalski, Kamil * @internal 1356f4c4dcf4SKowalski, Kamil * @brief Formats SessionLimitExceeded message into JSON 1357f4c4dcf4SKowalski, Kamil * 1358f4c4dcf4SKowalski, Kamil * See header file for more information 1359f4c4dcf4SKowalski, Kamil * @endinternal 1360f4c4dcf4SKowalski, Kamil */ 1361b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void) 13621abe55efSEd Tanous { 1363fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::sessionLimitExceeded, {}); 1364b5c07418SJames Feist } 1365b5c07418SJames Feist 1366b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res) 1367b5c07418SJames Feist { 1368b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1369b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, sessionLimitExceeded()); 1370f4c4dcf4SKowalski, Kamil } 1371f4c4dcf4SKowalski, Kamil 1372f4c4dcf4SKowalski, Kamil /** 1373f4c4dcf4SKowalski, Kamil * @internal 1374f4c4dcf4SKowalski, Kamil * @brief Formats ActionNotSupported message into JSON 1375f4c4dcf4SKowalski, Kamil * 1376f4c4dcf4SKowalski, Kamil * See header file for more information 1377f4c4dcf4SKowalski, Kamil * @endinternal 1378f4c4dcf4SKowalski, Kamil */ 13791668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1) 13801abe55efSEd Tanous { 1381fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionNotSupported, 13821668ce6dSEd Tanous std::to_array({arg1})); 1383b5c07418SJames Feist } 1384b5c07418SJames Feist 13851668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1) 1386b5c07418SJames Feist { 1387b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1388b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1)); 1389f4c4dcf4SKowalski, Kamil } 1390f4c4dcf4SKowalski, Kamil 1391f4c4dcf4SKowalski, Kamil /** 1392f4c4dcf4SKowalski, Kamil * @internal 1393f4c4dcf4SKowalski, Kamil * @brief Formats InvalidIndex message into JSON 1394f4c4dcf4SKowalski, Kamil * 1395f4c4dcf4SKowalski, Kamil * See header file for more information 1396f4c4dcf4SKowalski, Kamil * @endinternal 1397f4c4dcf4SKowalski, Kamil */ 13985187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1) 13991abe55efSEd Tanous { 1400b6cd31e1SEd Tanous std::string arg1Str = std::to_string(arg1); 1401fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::invalidIndex, 14021668ce6dSEd Tanous std::to_array<std::string_view>({arg1Str})); 1403b5c07418SJames Feist } 1404b5c07418SJames Feist 14055187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1) 1406b5c07418SJames Feist { 1407b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1408b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidIndex(arg1)); 1409f4c4dcf4SKowalski, Kamil } 1410f4c4dcf4SKowalski, Kamil 1411f4c4dcf4SKowalski, Kamil /** 1412f4c4dcf4SKowalski, Kamil * @internal 1413f4c4dcf4SKowalski, Kamil * @brief Formats EmptyJSON message into JSON 1414f4c4dcf4SKowalski, Kamil * 1415f4c4dcf4SKowalski, Kamil * See header file for more information 1416f4c4dcf4SKowalski, Kamil * @endinternal 1417f4c4dcf4SKowalski, Kamil */ 1418b5c07418SJames Feist nlohmann::json emptyJSON(void) 14191abe55efSEd Tanous { 1420fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::emptyJSON, {}); 1421b5c07418SJames Feist } 1422b5c07418SJames Feist 1423b5c07418SJames Feist void emptyJSON(crow::Response& res) 1424b5c07418SJames Feist { 1425b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1426b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, emptyJSON()); 1427f4c4dcf4SKowalski, Kamil } 1428f4c4dcf4SKowalski, Kamil 1429f4c4dcf4SKowalski, Kamil /** 1430f4c4dcf4SKowalski, Kamil * @internal 1431f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupportedOnResource message into JSON 1432f4c4dcf4SKowalski, Kamil * 1433f4c4dcf4SKowalski, Kamil * See header file for more information 1434f4c4dcf4SKowalski, Kamil * @endinternal 1435f4c4dcf4SKowalski, Kamil */ 1436b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void) 14371abe55efSEd Tanous { 1438fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryNotSupportedOnResource, 1439b6cd31e1SEd Tanous {}); 1440b5c07418SJames Feist } 1441b5c07418SJames Feist 1442b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res) 1443b5c07418SJames Feist { 14446a409c12SEd Tanous res.result(boost::beast::http::status::bad_request); 1445b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource()); 1446f4c4dcf4SKowalski, Kamil } 1447f4c4dcf4SKowalski, Kamil 1448f4c4dcf4SKowalski, Kamil /** 1449f4c4dcf4SKowalski, Kamil * @internal 1450684bb4b8SJason M. Bills * @brief Formats QueryNotSupportedOnOperation message into JSON 1451684bb4b8SJason M. Bills * 1452684bb4b8SJason M. Bills * See header file for more information 1453684bb4b8SJason M. Bills * @endinternal 1454684bb4b8SJason M. Bills */ 1455684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void) 1456684bb4b8SJason M. Bills { 1457b6cd31e1SEd Tanous return getLog( 1458fffb8c1fSEd Tanous redfish::registries::base::Index::queryNotSupportedOnOperation, {}); 1459684bb4b8SJason M. Bills } 1460684bb4b8SJason M. Bills 1461684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res) 1462684bb4b8SJason M. Bills { 14636a409c12SEd Tanous res.result(boost::beast::http::status::bad_request); 1464684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation()); 1465684bb4b8SJason M. Bills } 1466684bb4b8SJason M. Bills 1467684bb4b8SJason M. Bills /** 1468684bb4b8SJason M. Bills * @internal 1469684bb4b8SJason M. Bills * @brief Formats QueryCombinationInvalid message into JSON 1470684bb4b8SJason M. Bills * 1471684bb4b8SJason M. Bills * See header file for more information 1472684bb4b8SJason M. Bills * @endinternal 1473684bb4b8SJason M. Bills */ 1474684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void) 1475684bb4b8SJason M. Bills { 1476fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryCombinationInvalid, 1477fffb8c1fSEd Tanous {}); 1478684bb4b8SJason M. Bills } 1479684bb4b8SJason M. Bills 1480684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res) 1481684bb4b8SJason M. Bills { 1482684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 1483684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, queryCombinationInvalid()); 1484684bb4b8SJason M. Bills } 1485684bb4b8SJason M. Bills 1486684bb4b8SJason M. Bills /** 1487684bb4b8SJason M. Bills * @internal 1488f4c4dcf4SKowalski, Kamil * @brief Formats InsufficientPrivilege message into JSON 1489f4c4dcf4SKowalski, Kamil * 1490f4c4dcf4SKowalski, Kamil * See header file for more information 1491f4c4dcf4SKowalski, Kamil * @endinternal 1492f4c4dcf4SKowalski, Kamil */ 1493b5c07418SJames Feist nlohmann::json insufficientPrivilege(void) 14941abe55efSEd Tanous { 1495fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::insufficientPrivilege, {}); 1496b5c07418SJames Feist } 1497b5c07418SJames Feist 1498b5c07418SJames Feist void insufficientPrivilege(crow::Response& res) 1499b5c07418SJames Feist { 1500b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1501b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, insufficientPrivilege()); 1502f4c4dcf4SKowalski, Kamil } 1503f4c4dcf4SKowalski, Kamil 1504f4c4dcf4SKowalski, Kamil /** 1505f4c4dcf4SKowalski, Kamil * @internal 1506f4c4dcf4SKowalski, Kamil * @brief Formats PropertyValueModified message into JSON 1507f4c4dcf4SKowalski, Kamil * 1508f4c4dcf4SKowalski, Kamil * See header file for more information 1509f4c4dcf4SKowalski, Kamil * @endinternal 1510f4c4dcf4SKowalski, Kamil */ 15111668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1, 15121668ce6dSEd Tanous std::string_view arg2) 1513b5c07418SJames Feist { 1514fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueModified, 15151668ce6dSEd Tanous std::to_array({arg1, arg2})); 1516b5c07418SJames Feist } 1517b5c07418SJames Feist 15181668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1, 15191668ce6dSEd Tanous std::string_view arg2) 15201abe55efSEd Tanous { 1521f12894f8SJason M. Bills res.result(boost::beast::http::status::ok); 1522b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1); 1523f4c4dcf4SKowalski, Kamil } 1524f4c4dcf4SKowalski, Kamil 1525f4c4dcf4SKowalski, Kamil /** 1526f4c4dcf4SKowalski, Kamil * @internal 1527f4c4dcf4SKowalski, Kamil * @brief Formats AccountNotModified message into JSON 1528f4c4dcf4SKowalski, Kamil * 1529f4c4dcf4SKowalski, Kamil * See header file for more information 1530f4c4dcf4SKowalski, Kamil * @endinternal 1531f4c4dcf4SKowalski, Kamil */ 1532b5c07418SJames Feist nlohmann::json accountNotModified(void) 15331abe55efSEd Tanous { 1534fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountNotModified, {}); 1535b5c07418SJames Feist } 1536b5c07418SJames Feist 1537b5c07418SJames Feist void accountNotModified(crow::Response& res) 1538b5c07418SJames Feist { 1539b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1540b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountNotModified()); 1541f4c4dcf4SKowalski, Kamil } 1542f4c4dcf4SKowalski, Kamil 1543f4c4dcf4SKowalski, Kamil /** 1544f4c4dcf4SKowalski, Kamil * @internal 1545f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueFormatError message into JSON 1546f4c4dcf4SKowalski, Kamil * 1547f4c4dcf4SKowalski, Kamil * See header file for more information 1548f4c4dcf4SKowalski, Kamil * @endinternal 1549f4c4dcf4SKowalski, Kamil */ 15501668ce6dSEd Tanous nlohmann::json queryParameterValueFormatError(std::string_view arg1, 15511668ce6dSEd Tanous std::string_view arg2) 15521abe55efSEd Tanous { 1553fffb8c1fSEd Tanous return getLog( 1554fffb8c1fSEd Tanous redfish::registries::base::Index::queryParameterValueFormatError, 15551668ce6dSEd Tanous std::to_array({arg1, arg2})); 1556b5c07418SJames Feist } 1557b5c07418SJames Feist 15581668ce6dSEd Tanous void queryParameterValueFormatError(crow::Response& res, std::string_view arg1, 15591668ce6dSEd Tanous std::string_view arg2) 1560b5c07418SJames Feist { 1561b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1562b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1563b5c07418SJames Feist queryParameterValueFormatError(arg1, arg2)); 1564f4c4dcf4SKowalski, Kamil } 1565f4c4dcf4SKowalski, Kamil 1566f4c4dcf4SKowalski, Kamil /** 1567f4c4dcf4SKowalski, Kamil * @internal 1568b5c07418SJames Feist * @brief Formats PropertyMissing message into JSON for the specified 1569b5c07418SJames Feist * property 1570f12894f8SJason M. Bills * 1571f12894f8SJason M. Bills * See header file for more information 1572f12894f8SJason M. Bills * @endinternal 1573f12894f8SJason M. Bills */ 15741668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1) 1575f12894f8SJason M. Bills { 1576fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyMissing, 15771668ce6dSEd Tanous std::to_array({arg1})); 1578b5c07418SJames Feist } 1579b5c07418SJames Feist 15801668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1) 1581b5c07418SJames Feist { 1582b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1583b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1); 1584f4c4dcf4SKowalski, Kamil } 1585f4c4dcf4SKowalski, Kamil 1586f4c4dcf4SKowalski, Kamil /** 1587f4c4dcf4SKowalski, Kamil * @internal 1588f4c4dcf4SKowalski, Kamil * @brief Formats ResourceExhaustion message into JSON 1589f4c4dcf4SKowalski, Kamil * 1590f4c4dcf4SKowalski, Kamil * See header file for more information 1591f4c4dcf4SKowalski, Kamil * @endinternal 1592f4c4dcf4SKowalski, Kamil */ 15931668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1) 15941abe55efSEd Tanous { 1595fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceExhaustion, 15961668ce6dSEd Tanous std::to_array({arg1})); 1597b5c07418SJames Feist } 1598b5c07418SJames Feist 15991668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1) 1600b5c07418SJames Feist { 1601b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1602b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1)); 1603f4c4dcf4SKowalski, Kamil } 1604f4c4dcf4SKowalski, Kamil 1605f4c4dcf4SKowalski, Kamil /** 1606f4c4dcf4SKowalski, Kamil * @internal 1607f4c4dcf4SKowalski, Kamil * @brief Formats AccountModified message into JSON 1608f4c4dcf4SKowalski, Kamil * 1609f4c4dcf4SKowalski, Kamil * See header file for more information 1610f4c4dcf4SKowalski, Kamil * @endinternal 1611f4c4dcf4SKowalski, Kamil */ 1612b5c07418SJames Feist nlohmann::json accountModified(void) 16131abe55efSEd Tanous { 1614fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountModified, {}); 1615b5c07418SJames Feist } 1616b5c07418SJames Feist 1617b5c07418SJames Feist void accountModified(crow::Response& res) 1618b5c07418SJames Feist { 1619b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1620b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountModified()); 1621f4c4dcf4SKowalski, Kamil } 1622f4c4dcf4SKowalski, Kamil 1623f4c4dcf4SKowalski, Kamil /** 1624f4c4dcf4SKowalski, Kamil * @internal 1625f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterOutOfRange message into JSON 1626f4c4dcf4SKowalski, Kamil * 1627f4c4dcf4SKowalski, Kamil * See header file for more information 1628f4c4dcf4SKowalski, Kamil * @endinternal 1629f4c4dcf4SKowalski, Kamil */ 16301668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1, 16311668ce6dSEd Tanous std::string_view arg2, 16321668ce6dSEd Tanous std::string_view arg3) 16331abe55efSEd Tanous { 1634fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryParameterOutOfRange, 16351668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 1636b5c07418SJames Feist } 1637b5c07418SJames Feist 16381668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1, 16391668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 1640b5c07418SJames Feist { 1641b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1642b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1643b5c07418SJames Feist queryParameterOutOfRange(arg1, arg2, arg3)); 1644f4c4dcf4SKowalski, Kamil } 1645f4c4dcf4SKowalski, Kamil 1646b6cd31e1SEd Tanous nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1) 1647b6cd31e1SEd Tanous { 16481668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 1649fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::passwordChangeRequired, 16501668ce6dSEd Tanous std::to_array({arg1str})); 1651b6cd31e1SEd Tanous } 1652b6cd31e1SEd Tanous 16533bf4e632SJoseph Reynolds /** 16543bf4e632SJoseph Reynolds * @internal 16553bf4e632SJoseph Reynolds * @brief Formats PasswordChangeRequired message into JSON 16563bf4e632SJoseph Reynolds * 16573bf4e632SJoseph Reynolds * See header file for more information 16583bf4e632SJoseph Reynolds * @endinternal 16593bf4e632SJoseph Reynolds */ 1660ace85d60SEd Tanous void passwordChangeRequired(crow::Response& res, 1661ace85d60SEd Tanous const boost::urls::url_view& arg1) 16623bf4e632SJoseph Reynolds { 1663b6cd31e1SEd Tanous messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1)); 16643bf4e632SJoseph Reynolds } 16653bf4e632SJoseph Reynolds 16661668ce6dSEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1, 16671668ce6dSEd Tanous std::string_view arg2) 16684cde5d90SJames Feist { 16694cde5d90SJames Feist res.result(boost::beast::http::status::bad_request); 16704cde5d90SJames Feist addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2)); 16714cde5d90SJames Feist } 16724cde5d90SJames Feist 16734cde5d90SJames Feist /** 16744cde5d90SJames Feist * @internal 16754cde5d90SJames Feist * @brief Formats Invalid File message into JSON 16764cde5d90SJames Feist * 16774cde5d90SJames Feist * See header file for more information 16784cde5d90SJames Feist * @endinternal 16794cde5d90SJames Feist */ 16801668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2) 16814cde5d90SJames Feist { 16821668ce6dSEd Tanous std::string msg = "Invalid file uploaded to "; 16831668ce6dSEd Tanous msg += arg1; 16841668ce6dSEd Tanous msg += ": "; 16851668ce6dSEd Tanous msg += arg2; 16861668ce6dSEd Tanous msg += "."; 16874cde5d90SJames Feist return nlohmann::json{ 16883e082749SAsmitha Karunanithi {"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"}, 16894a0bf539SManojkiran Eda {"MessageId", "OpenBMC.0.2.InvalidUpload"}, 16901668ce6dSEd Tanous {"Message", std::move(msg)}, 16914cde5d90SJames Feist {"MessageArgs", {arg1, arg2}}, 1692684bb4b8SJason M. Bills {"MessageSeverity", "Warning"}, 16934cde5d90SJames Feist {"Resolution", "None."}}; 16944cde5d90SJames Feist } 1695f4c4dcf4SKowalski, Kamil } // namespace messages 1696f4c4dcf4SKowalski, Kamil 1697d425c6f6SEd Tanous } // namespace redfish 1698