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 } 57c21055aaSEd Tanous error = {{"code", *messageIdIterator}, 58c21055aaSEd Tanous {"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; 132b6cd31e1SEd Tanous return {{"@odata.type", "#Message.v1_1_1.Message"}, 133b6cd31e1SEd Tanous {"MessageId", std::move(msgId)}, 134b6cd31e1SEd Tanous {"Message", std::move(msg)}, 135b6cd31e1SEd Tanous {"MessageArgs", std::move(jArgs)}, 1365f2b84eeSEd Tanous {"MessageSeverity", entry.second.messageSeverity}, 137b6cd31e1SEd Tanous {"Resolution", entry.second.resolution}}; 138b6cd31e1SEd Tanous } 139b6cd31e1SEd Tanous 140f4c4dcf4SKowalski, Kamil /** 141f4c4dcf4SKowalski, Kamil * @internal 142f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInUse message into JSON 143f4c4dcf4SKowalski, Kamil * 144f4c4dcf4SKowalski, Kamil * See header file for more information 145f4c4dcf4SKowalski, Kamil * @endinternal 146f4c4dcf4SKowalski, Kamil */ 147b5c07418SJames Feist nlohmann::json resourceInUse(void) 1481abe55efSEd Tanous { 149fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceInUse, {}); 150b5c07418SJames Feist } 151b5c07418SJames Feist 152b5c07418SJames Feist void resourceInUse(crow::Response& res) 153b5c07418SJames Feist { 154b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 155b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInUse()); 156f4c4dcf4SKowalski, Kamil } 157f4c4dcf4SKowalski, Kamil 158f4c4dcf4SKowalski, Kamil /** 159f4c4dcf4SKowalski, Kamil * @internal 160f4c4dcf4SKowalski, Kamil * @brief Formats MalformedJSON message into JSON 161f4c4dcf4SKowalski, Kamil * 162f4c4dcf4SKowalski, Kamil * See header file for more information 163f4c4dcf4SKowalski, Kamil * @endinternal 164f4c4dcf4SKowalski, Kamil */ 165b5c07418SJames Feist nlohmann::json malformedJSON(void) 1661abe55efSEd Tanous { 167fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::malformedJSON, {}); 168b5c07418SJames Feist } 169b5c07418SJames Feist 170b5c07418SJames Feist void malformedJSON(crow::Response& res) 171b5c07418SJames Feist { 172b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 173b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, malformedJSON()); 174f4c4dcf4SKowalski, Kamil } 175f4c4dcf4SKowalski, Kamil 176f4c4dcf4SKowalski, Kamil /** 177f4c4dcf4SKowalski, Kamil * @internal 178f4c4dcf4SKowalski, Kamil * @brief Formats ResourceMissingAtURI message into JSON 179f4c4dcf4SKowalski, Kamil * 180f4c4dcf4SKowalski, Kamil * See header file for more information 181f4c4dcf4SKowalski, Kamil * @endinternal 182f4c4dcf4SKowalski, Kamil */ 183ace85d60SEd Tanous nlohmann::json resourceMissingAtURI(const boost::urls::url_view& arg1) 1841abe55efSEd Tanous { 185b6cd31e1SEd Tanous std::array<std::string_view, 1> args{ 186b6cd31e1SEd Tanous std::string_view{arg1.data(), arg1.size()}}; 187fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceMissingAtURI, args); 188b5c07418SJames Feist } 189b5c07418SJames Feist 190ace85d60SEd Tanous void resourceMissingAtURI(crow::Response& res, 191ace85d60SEd Tanous const boost::urls::url_view& arg1) 192b5c07418SJames Feist { 193b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 194b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1)); 195f4c4dcf4SKowalski, Kamil } 196f4c4dcf4SKowalski, Kamil 197f4c4dcf4SKowalski, Kamil /** 198f4c4dcf4SKowalski, Kamil * @internal 199f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueFormatError message into JSON 200f4c4dcf4SKowalski, Kamil * 201f4c4dcf4SKowalski, Kamil * See header file for more information 202f4c4dcf4SKowalski, Kamil * @endinternal 203f4c4dcf4SKowalski, Kamil */ 2041668ce6dSEd Tanous nlohmann::json actionParameterValueFormatError(std::string_view arg1, 2051668ce6dSEd Tanous std::string_view arg2, 2061668ce6dSEd Tanous std::string_view arg3) 2071abe55efSEd Tanous { 208fffb8c1fSEd Tanous return getLog( 209fffb8c1fSEd Tanous redfish::registries::base::Index::actionParameterValueFormatError, 2101668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 211b5c07418SJames Feist } 212b5c07418SJames Feist 2131668ce6dSEd Tanous void actionParameterValueFormatError(crow::Response& res, std::string_view arg1, 2141668ce6dSEd Tanous std::string_view arg2, 2151668ce6dSEd Tanous std::string_view arg3) 216b5c07418SJames Feist { 217b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 218b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 219b5c07418SJames Feist actionParameterValueFormatError(arg1, arg2, arg3)); 220f4c4dcf4SKowalski, Kamil } 221f4c4dcf4SKowalski, Kamil 222f4c4dcf4SKowalski, Kamil /** 223f4c4dcf4SKowalski, Kamil * @internal 224f4c4dcf4SKowalski, Kamil * @brief Formats InternalError message into JSON 225f4c4dcf4SKowalski, Kamil * 226f4c4dcf4SKowalski, Kamil * See header file for more information 227f4c4dcf4SKowalski, Kamil * @endinternal 228f4c4dcf4SKowalski, Kamil */ 229b5c07418SJames Feist nlohmann::json internalError(void) 2301abe55efSEd Tanous { 231fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::internalError, {}); 232b5c07418SJames Feist } 233b5c07418SJames Feist 234df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location) 235b5c07418SJames Feist { 236df5415fcSEd Tanous BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "(" 237df5415fcSEd Tanous << location.line() << ":" << location.column() << ") `" 238df5415fcSEd Tanous << location.function_name() << "`: "; 239b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 240b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, internalError()); 241f12894f8SJason M. Bills } 242f12894f8SJason M. Bills 243f12894f8SJason M. Bills /** 244f12894f8SJason M. Bills * @internal 245f4c4dcf4SKowalski, Kamil * @brief Formats UnrecognizedRequestBody message into JSON 246f4c4dcf4SKowalski, Kamil * 247f4c4dcf4SKowalski, Kamil * See header file for more information 248f4c4dcf4SKowalski, Kamil * @endinternal 249f4c4dcf4SKowalski, Kamil */ 250b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void) 2511abe55efSEd Tanous { 252fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::unrecognizedRequestBody, 253fffb8c1fSEd Tanous {}); 254b5c07418SJames Feist } 255b5c07418SJames Feist 256b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res) 257b5c07418SJames Feist { 258b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 259b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody()); 260f4c4dcf4SKowalski, Kamil } 261f4c4dcf4SKowalski, Kamil 262f4c4dcf4SKowalski, Kamil /** 263f4c4dcf4SKowalski, Kamil * @internal 264f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriUnauthorized message into JSON 265f4c4dcf4SKowalski, Kamil * 266f4c4dcf4SKowalski, Kamil * See header file for more information 267f4c4dcf4SKowalski, Kamil * @endinternal 268f4c4dcf4SKowalski, Kamil */ 269ace85d60SEd Tanous nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1, 2701668ce6dSEd Tanous std::string_view arg2) 2711abe55efSEd Tanous { 272b6cd31e1SEd Tanous return getLog( 273fffb8c1fSEd Tanous redfish::registries::base::Index::resourceAtUriUnauthorized, 2741668ce6dSEd Tanous std::to_array({std::string_view{arg1.data(), arg1.size()}, arg2})); 275b5c07418SJames Feist } 276b5c07418SJames Feist 277ace85d60SEd Tanous void resourceAtUriUnauthorized(crow::Response& res, 278ace85d60SEd Tanous const boost::urls::url_view& arg1, 2791668ce6dSEd Tanous std::string_view arg2) 280b5c07418SJames Feist { 281b5c07418SJames Feist res.result(boost::beast::http::status::unauthorized); 282b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2)); 283f4c4dcf4SKowalski, Kamil } 284f4c4dcf4SKowalski, Kamil 285f4c4dcf4SKowalski, Kamil /** 286f4c4dcf4SKowalski, Kamil * @internal 287f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterUnknown message into JSON 288f4c4dcf4SKowalski, Kamil * 289f4c4dcf4SKowalski, Kamil * See header file for more information 290f4c4dcf4SKowalski, Kamil * @endinternal 291f4c4dcf4SKowalski, Kamil */ 2921668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1, 2931668ce6dSEd Tanous std::string_view arg2) 294b5c07418SJames Feist { 295fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterUnknown, 2961668ce6dSEd Tanous std::to_array({arg1, arg2})); 297b5c07418SJames Feist } 298b5c07418SJames Feist 2991668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1, 3001668ce6dSEd Tanous std::string_view arg2) 3011abe55efSEd Tanous { 302f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 303b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2)); 304f4c4dcf4SKowalski, Kamil } 305f4c4dcf4SKowalski, Kamil 306f4c4dcf4SKowalski, Kamil /** 307f4c4dcf4SKowalski, Kamil * @internal 308f4c4dcf4SKowalski, Kamil * @brief Formats ResourceCannotBeDeleted message into JSON 309f4c4dcf4SKowalski, Kamil * 310f4c4dcf4SKowalski, Kamil * See header file for more information 311f4c4dcf4SKowalski, Kamil * @endinternal 312f4c4dcf4SKowalski, Kamil */ 313b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void) 3141abe55efSEd Tanous { 315fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceCannotBeDeleted, 316fffb8c1fSEd Tanous {}); 317b5c07418SJames Feist } 318b5c07418SJames Feist 319b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res) 320b5c07418SJames Feist { 321b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 322b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted()); 323f4c4dcf4SKowalski, Kamil } 324f4c4dcf4SKowalski, Kamil 325f4c4dcf4SKowalski, Kamil /** 326f4c4dcf4SKowalski, Kamil * @internal 327f4c4dcf4SKowalski, Kamil * @brief Formats PropertyDuplicate message into JSON 328f4c4dcf4SKowalski, Kamil * 329f4c4dcf4SKowalski, Kamil * See header file for more information 330f4c4dcf4SKowalski, Kamil * @endinternal 331f4c4dcf4SKowalski, Kamil */ 3321668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1) 3331abe55efSEd Tanous { 334fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyDuplicate, 3351668ce6dSEd Tanous std::to_array({arg1})); 336b5c07418SJames Feist } 337b5c07418SJames Feist 3381668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1) 339b5c07418SJames Feist { 340b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 341b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1); 342f4c4dcf4SKowalski, Kamil } 343f4c4dcf4SKowalski, Kamil 344f4c4dcf4SKowalski, Kamil /** 345f4c4dcf4SKowalski, Kamil * @internal 346f4c4dcf4SKowalski, Kamil * @brief Formats ServiceTemporarilyUnavailable message into JSON 347f4c4dcf4SKowalski, Kamil * 348f4c4dcf4SKowalski, Kamil * See header file for more information 349f4c4dcf4SKowalski, Kamil * @endinternal 350f4c4dcf4SKowalski, Kamil */ 3511668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1) 3521abe55efSEd Tanous { 353b6cd31e1SEd Tanous return getLog( 354fffb8c1fSEd Tanous redfish::registries::base::Index::serviceTemporarilyUnavailable, 3551668ce6dSEd Tanous std::to_array({arg1})); 356b5c07418SJames Feist } 357b5c07418SJames Feist 3581668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1) 359b5c07418SJames Feist { 360b5c07418SJames Feist res.addHeader("Retry-After", arg1); 361b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 362b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1)); 363f4c4dcf4SKowalski, Kamil } 364f4c4dcf4SKowalski, Kamil 365f4c4dcf4SKowalski, Kamil /** 366f4c4dcf4SKowalski, Kamil * @internal 367f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAlreadyExists message into JSON 368f4c4dcf4SKowalski, Kamil * 369f4c4dcf4SKowalski, Kamil * See header file for more information 370f4c4dcf4SKowalski, Kamil * @endinternal 371f4c4dcf4SKowalski, Kamil */ 3721668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1, 3731668ce6dSEd Tanous std::string_view arg2, 3741668ce6dSEd Tanous std::string_view arg3) 3751abe55efSEd Tanous { 376fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceAlreadyExists, 3771668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 378b5c07418SJames Feist } 379b5c07418SJames Feist 3801668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1, 3811668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 382b5c07418SJames Feist { 383b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 384b5c07418SJames Feist addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3), 385a08b46ccSJason M. Bills arg2); 386f4c4dcf4SKowalski, Kamil } 387f4c4dcf4SKowalski, Kamil 388f4c4dcf4SKowalski, Kamil /** 389f4c4dcf4SKowalski, Kamil * @internal 390f4c4dcf4SKowalski, Kamil * @brief Formats AccountForSessionNoLongerExists message into JSON 391f4c4dcf4SKowalski, Kamil * 392f4c4dcf4SKowalski, Kamil * See header file for more information 393f4c4dcf4SKowalski, Kamil * @endinternal 394f4c4dcf4SKowalski, Kamil */ 395b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void) 3961abe55efSEd Tanous { 397fffb8c1fSEd Tanous return getLog( 398fffb8c1fSEd Tanous redfish::registries::base::Index::accountForSessionNoLongerExists, {}); 399b5c07418SJames Feist } 400b5c07418SJames Feist 401b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res) 402b5c07418SJames Feist { 403b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 404b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists()); 405f4c4dcf4SKowalski, Kamil } 406f4c4dcf4SKowalski, Kamil 407f4c4dcf4SKowalski, Kamil /** 408f4c4dcf4SKowalski, Kamil * @internal 409f4c4dcf4SKowalski, Kamil * @brief Formats CreateFailedMissingReqProperties message into JSON 410f4c4dcf4SKowalski, Kamil * 411f4c4dcf4SKowalski, Kamil * See header file for more information 412f4c4dcf4SKowalski, Kamil * @endinternal 413f4c4dcf4SKowalski, Kamil */ 4141668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1) 4151abe55efSEd Tanous { 416fffb8c1fSEd Tanous return getLog( 417fffb8c1fSEd Tanous redfish::registries::base::Index::createFailedMissingReqProperties, 4181668ce6dSEd Tanous std::to_array({arg1})); 419b5c07418SJames Feist } 420b5c07418SJames Feist 421b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res, 4221668ce6dSEd Tanous std::string_view arg1) 423b5c07418SJames Feist { 424b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 425b5c07418SJames Feist addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1), 426a08b46ccSJason M. Bills arg1); 427f12894f8SJason M. Bills } 428f12894f8SJason M. Bills 429f12894f8SJason M. Bills /** 430f12894f8SJason M. Bills * @internal 431f12894f8SJason M. Bills * @brief Formats PropertyValueFormatError message into JSON for the specified 432f12894f8SJason M. Bills * property 433f12894f8SJason M. Bills * 434f12894f8SJason M. Bills * See header file for more information 435f12894f8SJason M. Bills * @endinternal 436f12894f8SJason M. Bills */ 4371668ce6dSEd Tanous nlohmann::json propertyValueFormatError(std::string_view arg1, 4381668ce6dSEd Tanous std::string_view arg2) 439f12894f8SJason M. Bills { 440fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueFormatError, 4411668ce6dSEd Tanous std::to_array({arg1, arg2})); 442b5c07418SJames Feist } 443b5c07418SJames Feist 4441668ce6dSEd Tanous void propertyValueFormatError(crow::Response& res, std::string_view arg1, 4451668ce6dSEd Tanous std::string_view arg2) 446b5c07418SJames Feist { 447b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 448b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2); 449f12894f8SJason M. Bills } 450f12894f8SJason M. Bills 451f12894f8SJason M. Bills /** 452f12894f8SJason M. Bills * @internal 453f12894f8SJason M. Bills * @brief Formats PropertyValueNotInList message into JSON for the specified 454f12894f8SJason M. Bills * property 455f12894f8SJason M. Bills * 456f12894f8SJason M. Bills * See header file for more information 457f12894f8SJason M. Bills * @endinternal 458f12894f8SJason M. Bills */ 4591668ce6dSEd Tanous nlohmann::json propertyValueNotInList(std::string_view arg1, 4601668ce6dSEd Tanous std::string_view arg2) 461f12894f8SJason M. Bills { 462fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueNotInList, 4631668ce6dSEd Tanous std::to_array({arg1, arg2})); 464b5c07418SJames Feist } 465b5c07418SJames Feist 4661668ce6dSEd Tanous void propertyValueNotInList(crow::Response& res, std::string_view arg1, 4671668ce6dSEd Tanous std::string_view arg2) 468b5c07418SJames Feist { 469b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 470b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2); 471f4c4dcf4SKowalski, Kamil } 472f4c4dcf4SKowalski, Kamil 473f4c4dcf4SKowalski, Kamil /** 474f4c4dcf4SKowalski, Kamil * @internal 475f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriInUnknownFormat message into JSON 476f4c4dcf4SKowalski, Kamil * 477f4c4dcf4SKowalski, Kamil * See header file for more information 478f4c4dcf4SKowalski, Kamil * @endinternal 479f4c4dcf4SKowalski, Kamil */ 480ace85d60SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1) 4811abe55efSEd Tanous { 4821668ce6dSEd Tanous std::string_view arg1str{arg1.data(), arg1.size()}; 483b6cd31e1SEd Tanous return getLog( 484fffb8c1fSEd Tanous redfish::registries::base::Index::resourceAtUriInUnknownFormat, 4851668ce6dSEd Tanous std::to_array({arg1str})); 486b5c07418SJames Feist } 487b5c07418SJames Feist 488ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res, 489ace85d60SEd Tanous const boost::urls::url_view& arg1) 490b5c07418SJames Feist { 491b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 492b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1)); 493f4c4dcf4SKowalski, Kamil } 494f4c4dcf4SKowalski, Kamil 495f4c4dcf4SKowalski, Kamil /** 496f4c4dcf4SKowalski, Kamil * @internal 49781856681SAsmitha Karunanithi * @brief Formats ServiceDisabled message into JSON 49881856681SAsmitha Karunanithi * 49981856681SAsmitha Karunanithi * See header file for more information 50081856681SAsmitha Karunanithi * @endinternal 50181856681SAsmitha Karunanithi */ 5021668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1) 50381856681SAsmitha Karunanithi { 504fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceDisabled, 5051668ce6dSEd Tanous std::to_array({arg1})); 50681856681SAsmitha Karunanithi } 50781856681SAsmitha Karunanithi 5081668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1) 50981856681SAsmitha Karunanithi { 51081856681SAsmitha Karunanithi res.result(boost::beast::http::status::service_unavailable); 51181856681SAsmitha Karunanithi addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1)); 51281856681SAsmitha Karunanithi } 51381856681SAsmitha Karunanithi 51481856681SAsmitha Karunanithi /** 51581856681SAsmitha Karunanithi * @internal 516f4c4dcf4SKowalski, Kamil * @brief Formats ServiceInUnknownState message into JSON 517f4c4dcf4SKowalski, Kamil * 518f4c4dcf4SKowalski, Kamil * See header file for more information 519f4c4dcf4SKowalski, Kamil * @endinternal 520f4c4dcf4SKowalski, Kamil */ 521b5c07418SJames Feist nlohmann::json serviceInUnknownState(void) 5221abe55efSEd Tanous { 523fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceInUnknownState, {}); 524b5c07418SJames Feist } 525b5c07418SJames Feist 526b5c07418SJames Feist void serviceInUnknownState(crow::Response& res) 527b5c07418SJames Feist { 528b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 529b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceInUnknownState()); 530f4c4dcf4SKowalski, Kamil } 531f4c4dcf4SKowalski, Kamil 532f4c4dcf4SKowalski, Kamil /** 533f4c4dcf4SKowalski, Kamil * @internal 534f4c4dcf4SKowalski, Kamil * @brief Formats EventSubscriptionLimitExceeded message into JSON 535f4c4dcf4SKowalski, Kamil * 536f4c4dcf4SKowalski, Kamil * See header file for more information 537f4c4dcf4SKowalski, Kamil * @endinternal 538f4c4dcf4SKowalski, Kamil */ 539b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void) 5401abe55efSEd Tanous { 541fffb8c1fSEd Tanous return getLog( 542fffb8c1fSEd Tanous redfish::registries::base::Index::eventSubscriptionLimitExceeded, {}); 543b5c07418SJames Feist } 544b5c07418SJames Feist 545b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res) 546b5c07418SJames Feist { 547789fdab3SEd Tanous res.result(boost::beast::http::status::service_unavailable); 548b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded()); 549f4c4dcf4SKowalski, Kamil } 550f4c4dcf4SKowalski, Kamil 551f4c4dcf4SKowalski, Kamil /** 552f4c4dcf4SKowalski, Kamil * @internal 553f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterMissing message into JSON 554f4c4dcf4SKowalski, Kamil * 555f4c4dcf4SKowalski, Kamil * See header file for more information 556f4c4dcf4SKowalski, Kamil * @endinternal 557f4c4dcf4SKowalski, Kamil */ 5581668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1, 5591668ce6dSEd Tanous std::string_view arg2) 5601abe55efSEd Tanous { 561fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterMissing, 5621668ce6dSEd Tanous std::to_array({arg1, arg2})); 563b5c07418SJames Feist } 564b5c07418SJames Feist 5651668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1, 5661668ce6dSEd Tanous std::string_view arg2) 567b5c07418SJames Feist { 568b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 569b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2)); 570f4c4dcf4SKowalski, Kamil } 571f4c4dcf4SKowalski, Kamil 572f4c4dcf4SKowalski, Kamil /** 573f4c4dcf4SKowalski, Kamil * @internal 574f4c4dcf4SKowalski, Kamil * @brief Formats StringValueTooLong message into JSON 575f4c4dcf4SKowalski, Kamil * 576f4c4dcf4SKowalski, Kamil * See header file for more information 577f4c4dcf4SKowalski, Kamil * @endinternal 578f4c4dcf4SKowalski, Kamil */ 5791668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2) 5801abe55efSEd Tanous { 581b6cd31e1SEd Tanous std::string arg2String = std::to_string(arg2); 582fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::stringValueTooLong, 5831668ce6dSEd Tanous std::to_array({arg1, std::string_view(arg2String)})); 584b5c07418SJames Feist } 585b5c07418SJames Feist 5861668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2) 587b5c07418SJames Feist { 588b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 589b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2)); 590f4c4dcf4SKowalski, Kamil } 591f4c4dcf4SKowalski, Kamil 592f4c4dcf4SKowalski, Kamil /** 593f4c4dcf4SKowalski, Kamil * @internal 594cc9139ecSJason M. Bills * @brief Formats SessionTerminated message into JSON 595cc9139ecSJason M. Bills * 596cc9139ecSJason M. Bills * See header file for more information 597cc9139ecSJason M. Bills * @endinternal 598cc9139ecSJason M. Bills */ 599b5c07418SJames Feist nlohmann::json sessionTerminated(void) 600cc9139ecSJason M. Bills { 601fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::sessionTerminated, {}); 602b5c07418SJames Feist } 603b5c07418SJames Feist 604b5c07418SJames Feist void sessionTerminated(crow::Response& res) 605b5c07418SJames Feist { 606b5c07418SJames Feist res.result(boost::beast::http::status::ok); 607b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, sessionTerminated()); 608cc9139ecSJason M. Bills } 609cc9139ecSJason M. Bills 610cc9139ecSJason M. Bills /** 611cc9139ecSJason M. Bills * @internal 612684bb4b8SJason M. Bills * @brief Formats SubscriptionTerminated message into JSON 613684bb4b8SJason M. Bills * 614684bb4b8SJason M. Bills * See header file for more information 615684bb4b8SJason M. Bills * @endinternal 616684bb4b8SJason M. Bills */ 617684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void) 618684bb4b8SJason M. Bills { 619fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::subscriptionTerminated, {}); 620684bb4b8SJason M. Bills } 621684bb4b8SJason M. Bills 622684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res) 623684bb4b8SJason M. Bills { 624684bb4b8SJason M. Bills res.result(boost::beast::http::status::ok); 625684bb4b8SJason M. Bills addMessageToJsonRoot(res.jsonValue, subscriptionTerminated()); 626684bb4b8SJason M. Bills } 627684bb4b8SJason M. Bills 628684bb4b8SJason M. Bills /** 629684bb4b8SJason M. Bills * @internal 630cc9139ecSJason M. Bills * @brief Formats ResourceTypeIncompatible message into JSON 631cc9139ecSJason M. Bills * 632cc9139ecSJason M. Bills * See header file for more information 633cc9139ecSJason M. Bills * @endinternal 634cc9139ecSJason M. Bills */ 6351668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1, 6361668ce6dSEd Tanous std::string_view arg2) 637cc9139ecSJason M. Bills { 638fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceTypeIncompatible, 6391668ce6dSEd Tanous std::to_array({arg1, arg2})); 640b5c07418SJames Feist } 641b5c07418SJames Feist 6421668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1, 6431668ce6dSEd Tanous std::string_view arg2) 644b5c07418SJames Feist { 645b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 646b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2)); 647cc9139ecSJason M. Bills } 648cc9139ecSJason M. Bills 649cc9139ecSJason M. Bills /** 650cc9139ecSJason M. Bills * @internal 651684bb4b8SJason M. Bills * @brief Formats ResetRequired message into JSON 652684bb4b8SJason M. Bills * 653684bb4b8SJason M. Bills * See header file for more information 654684bb4b8SJason M. Bills * @endinternal 655684bb4b8SJason M. Bills */ 656ace85d60SEd Tanous nlohmann::json resetRequired(const boost::urls::url_view& arg1, 6571668ce6dSEd Tanous std::string_view arg2) 658684bb4b8SJason M. Bills { 6591668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 660fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resetRequired, 6611668ce6dSEd Tanous std::to_array({arg1str, arg2})); 662684bb4b8SJason M. Bills } 663684bb4b8SJason M. Bills 664ace85d60SEd Tanous void resetRequired(crow::Response& res, const boost::urls::url_view& arg1, 6651668ce6dSEd Tanous std::string_view arg2) 666684bb4b8SJason M. Bills { 667684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 668684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2)); 669684bb4b8SJason M. Bills } 670684bb4b8SJason M. Bills 671684bb4b8SJason M. Bills /** 672684bb4b8SJason M. Bills * @internal 673684bb4b8SJason M. Bills * @brief Formats ChassisPowerStateOnRequired message into JSON 674684bb4b8SJason M. Bills * 675684bb4b8SJason M. Bills * See header file for more information 676684bb4b8SJason M. Bills * @endinternal 677684bb4b8SJason M. Bills */ 6781668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1) 679684bb4b8SJason M. Bills { 680fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resetRequired, 6811668ce6dSEd Tanous std::to_array({arg1})); 682684bb4b8SJason M. Bills } 683684bb4b8SJason M. Bills 6841668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1) 685684bb4b8SJason M. Bills { 686684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 687684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1)); 688684bb4b8SJason M. Bills } 689684bb4b8SJason M. Bills 690684bb4b8SJason M. Bills /** 691684bb4b8SJason M. Bills * @internal 692684bb4b8SJason M. Bills * @brief Formats ChassisPowerStateOffRequired message into JSON 693684bb4b8SJason M. Bills * 694684bb4b8SJason M. Bills * See header file for more information 695684bb4b8SJason M. Bills * @endinternal 696684bb4b8SJason M. Bills */ 6971668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1) 698684bb4b8SJason M. Bills { 699b6cd31e1SEd Tanous return getLog( 700fffb8c1fSEd Tanous redfish::registries::base::Index::chassisPowerStateOffRequired, 7011668ce6dSEd Tanous std::to_array({arg1})); 702684bb4b8SJason M. Bills } 703684bb4b8SJason M. Bills 7041668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1) 705684bb4b8SJason M. Bills { 706684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 707684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1)); 708684bb4b8SJason M. Bills } 709684bb4b8SJason M. Bills 710684bb4b8SJason M. Bills /** 711684bb4b8SJason M. Bills * @internal 712684bb4b8SJason M. Bills * @brief Formats PropertyValueConflict message into JSON 713684bb4b8SJason M. Bills * 714684bb4b8SJason M. Bills * See header file for more information 715684bb4b8SJason M. Bills * @endinternal 716684bb4b8SJason M. Bills */ 7171668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1, 7181668ce6dSEd Tanous std::string_view arg2) 719684bb4b8SJason M. Bills { 720fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueConflict, 7211668ce6dSEd Tanous std::to_array({arg1, arg2})); 722684bb4b8SJason M. Bills } 723684bb4b8SJason M. Bills 7241668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1, 7251668ce6dSEd Tanous std::string_view arg2) 726684bb4b8SJason M. Bills { 727684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 728684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2)); 729684bb4b8SJason M. Bills } 730684bb4b8SJason M. Bills 731684bb4b8SJason M. Bills /** 732684bb4b8SJason M. Bills * @internal 7332a6af81cSRamesh Iyyar * @brief Formats PropertyValueResourceConflict message into JSON 7342a6af81cSRamesh Iyyar * 7352a6af81cSRamesh Iyyar * See header file for more information 7362a6af81cSRamesh Iyyar * @endinternal 7372a6af81cSRamesh Iyyar */ 7382a6af81cSRamesh Iyyar nlohmann::json propertyValueResourceConflict(std::string_view arg1, 7392a6af81cSRamesh Iyyar std::string_view arg2, 7402a6af81cSRamesh Iyyar const boost::urls::url_view& arg3) 7412a6af81cSRamesh Iyyar { 7422a6af81cSRamesh Iyyar return getLog( 7432a6af81cSRamesh Iyyar redfish::registries::base::Index::propertyValueResourceConflict, 7442a6af81cSRamesh Iyyar std::to_array( 7452a6af81cSRamesh Iyyar {arg1, arg2, std::string_view{arg3.data(), arg3.size()}})); 7462a6af81cSRamesh Iyyar } 7472a6af81cSRamesh Iyyar 7482a6af81cSRamesh Iyyar void propertyValueResourceConflict(crow::Response& res, std::string_view arg1, 7492a6af81cSRamesh Iyyar std::string_view arg2, 7502a6af81cSRamesh Iyyar const boost::urls::url_view& arg3) 7512a6af81cSRamesh Iyyar { 7522a6af81cSRamesh Iyyar res.result(boost::beast::http::status::conflict); 7532a6af81cSRamesh Iyyar addMessageToErrorJson(res.jsonValue, 7542a6af81cSRamesh Iyyar propertyValueResourceConflict(arg1, arg2, arg3)); 7552a6af81cSRamesh Iyyar } 7562a6af81cSRamesh Iyyar 7572a6af81cSRamesh Iyyar /** 7582a6af81cSRamesh Iyyar * @internal 759*24861a28SRamesh Iyyar * @brief Formats PropertyValueExternalConflict message into JSON 760*24861a28SRamesh Iyyar * 761*24861a28SRamesh Iyyar * See header file for more information 762*24861a28SRamesh Iyyar * @endinternal 763*24861a28SRamesh Iyyar */ 764*24861a28SRamesh Iyyar nlohmann::json propertyValueExternalConflict(std::string_view arg1, 765*24861a28SRamesh Iyyar std::string_view arg2) 766*24861a28SRamesh Iyyar { 767*24861a28SRamesh Iyyar return getLog( 768*24861a28SRamesh Iyyar redfish::registries::base::Index::propertyValueExternalConflict, 769*24861a28SRamesh Iyyar std::to_array({arg1, arg2})); 770*24861a28SRamesh Iyyar } 771*24861a28SRamesh Iyyar 772*24861a28SRamesh Iyyar void propertyValueExternalConflict(crow::Response& res, std::string_view arg1, 773*24861a28SRamesh Iyyar std::string_view arg2) 774*24861a28SRamesh Iyyar { 775*24861a28SRamesh Iyyar res.result(boost::beast::http::status::conflict); 776*24861a28SRamesh Iyyar addMessageToErrorJson(res.jsonValue, 777*24861a28SRamesh Iyyar propertyValueExternalConflict(arg1, arg2)); 778*24861a28SRamesh Iyyar } 779*24861a28SRamesh Iyyar 780*24861a28SRamesh Iyyar /** 781*24861a28SRamesh Iyyar * @internal 782684bb4b8SJason M. Bills * @brief Formats PropertyValueIncorrect message into JSON 783684bb4b8SJason M. Bills * 784684bb4b8SJason M. Bills * See header file for more information 785684bb4b8SJason M. Bills * @endinternal 786684bb4b8SJason M. Bills */ 7871668ce6dSEd Tanous nlohmann::json propertyValueIncorrect(std::string_view arg1, 7881668ce6dSEd Tanous std::string_view arg2) 789684bb4b8SJason M. Bills { 790fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueIncorrect, 7911668ce6dSEd Tanous std::to_array({arg1, arg2})); 792684bb4b8SJason M. Bills } 793684bb4b8SJason M. Bills 7941668ce6dSEd Tanous void propertyValueIncorrect(crow::Response& res, std::string_view arg1, 7951668ce6dSEd Tanous std::string_view arg2) 796684bb4b8SJason M. Bills { 797684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 798684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2)); 799684bb4b8SJason M. Bills } 800684bb4b8SJason M. Bills 801684bb4b8SJason M. Bills /** 802684bb4b8SJason M. Bills * @internal 803684bb4b8SJason M. Bills * @brief Formats ResourceCreationConflict message into JSON 804684bb4b8SJason M. Bills * 805684bb4b8SJason M. Bills * See header file for more information 806684bb4b8SJason M. Bills * @endinternal 807684bb4b8SJason M. Bills */ 808ace85d60SEd Tanous nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1) 809684bb4b8SJason M. Bills { 8101668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 811fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceCreationConflict, 8121668ce6dSEd Tanous std::to_array({arg1str})); 813684bb4b8SJason M. Bills } 814684bb4b8SJason M. Bills 815ace85d60SEd Tanous void resourceCreationConflict(crow::Response& res, 816ace85d60SEd Tanous const boost::urls::url_view& arg1) 817684bb4b8SJason M. Bills { 818684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 819684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1)); 820684bb4b8SJason M. Bills } 821684bb4b8SJason M. Bills 822684bb4b8SJason M. Bills /** 823684bb4b8SJason M. Bills * @internal 824684bb4b8SJason M. Bills * @brief Formats MaximumErrorsExceeded message into JSON 825684bb4b8SJason M. Bills * 826684bb4b8SJason M. Bills * See header file for more information 827684bb4b8SJason M. Bills * @endinternal 828684bb4b8SJason M. Bills */ 829684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void) 830684bb4b8SJason M. Bills { 831fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {}); 832684bb4b8SJason M. Bills } 833684bb4b8SJason M. Bills 834684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res) 835684bb4b8SJason M. Bills { 836684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 837684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded()); 838684bb4b8SJason M. Bills } 839684bb4b8SJason M. Bills 840684bb4b8SJason M. Bills /** 841684bb4b8SJason M. Bills * @internal 842684bb4b8SJason M. Bills * @brief Formats PreconditionFailed message into JSON 843684bb4b8SJason M. Bills * 844684bb4b8SJason M. Bills * See header file for more information 845684bb4b8SJason M. Bills * @endinternal 846684bb4b8SJason M. Bills */ 847684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void) 848684bb4b8SJason M. Bills { 849fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::preconditionFailed, {}); 850684bb4b8SJason M. Bills } 851684bb4b8SJason M. Bills 852684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res) 853684bb4b8SJason M. Bills { 8544df1bee0SEd Tanous res.result(boost::beast::http::status::precondition_failed); 855684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, preconditionFailed()); 856684bb4b8SJason M. Bills } 857684bb4b8SJason M. Bills 858684bb4b8SJason M. Bills /** 859684bb4b8SJason M. Bills * @internal 860684bb4b8SJason M. Bills * @brief Formats PreconditionRequired message into JSON 861684bb4b8SJason M. Bills * 862684bb4b8SJason M. Bills * See header file for more information 863684bb4b8SJason M. Bills * @endinternal 864684bb4b8SJason M. Bills */ 865684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void) 866684bb4b8SJason M. Bills { 867fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::preconditionRequired, {}); 868684bb4b8SJason M. Bills } 869684bb4b8SJason M. Bills 870684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res) 871684bb4b8SJason M. Bills { 872684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 873684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, preconditionRequired()); 874684bb4b8SJason M. Bills } 875684bb4b8SJason M. Bills 876684bb4b8SJason M. Bills /** 877684bb4b8SJason M. Bills * @internal 878684bb4b8SJason M. Bills * @brief Formats OperationFailed message into JSON 879684bb4b8SJason M. Bills * 880684bb4b8SJason M. Bills * See header file for more information 881684bb4b8SJason M. Bills * @endinternal 882684bb4b8SJason M. Bills */ 883684bb4b8SJason M. Bills nlohmann::json operationFailed(void) 884684bb4b8SJason M. Bills { 885fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::operationFailed, {}); 886684bb4b8SJason M. Bills } 887684bb4b8SJason M. Bills 888684bb4b8SJason M. Bills void operationFailed(crow::Response& res) 889684bb4b8SJason M. Bills { 890684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 891684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, operationFailed()); 892684bb4b8SJason M. Bills } 893684bb4b8SJason M. Bills 894684bb4b8SJason M. Bills /** 895684bb4b8SJason M. Bills * @internal 896684bb4b8SJason M. Bills * @brief Formats OperationTimeout message into JSON 897684bb4b8SJason M. Bills * 898684bb4b8SJason M. Bills * See header file for more information 899684bb4b8SJason M. Bills * @endinternal 900684bb4b8SJason M. Bills */ 901684bb4b8SJason M. Bills nlohmann::json operationTimeout(void) 902684bb4b8SJason M. Bills { 903fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::operationTimeout, {}); 904684bb4b8SJason M. Bills } 905684bb4b8SJason M. Bills 906684bb4b8SJason M. Bills void operationTimeout(crow::Response& res) 907684bb4b8SJason M. Bills { 908684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 909684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, operationTimeout()); 910684bb4b8SJason M. Bills } 911684bb4b8SJason M. Bills 912684bb4b8SJason M. Bills /** 913684bb4b8SJason M. Bills * @internal 914f12894f8SJason M. Bills * @brief Formats PropertyValueTypeError message into JSON for the specified 915f12894f8SJason M. Bills * property 916f12894f8SJason M. Bills * 917f12894f8SJason M. Bills * See header file for more information 918f12894f8SJason M. Bills * @endinternal 919f12894f8SJason M. Bills */ 9201668ce6dSEd Tanous nlohmann::json propertyValueTypeError(std::string_view arg1, 9211668ce6dSEd Tanous std::string_view arg2) 922f12894f8SJason M. Bills { 923fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueTypeError, 9241668ce6dSEd Tanous std::to_array({arg1, arg2})); 925b5c07418SJames Feist } 926b5c07418SJames Feist 9271668ce6dSEd Tanous void propertyValueTypeError(crow::Response& res, std::string_view arg1, 9281668ce6dSEd Tanous std::string_view arg2) 929b5c07418SJames Feist { 930b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 931b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2); 932f4c4dcf4SKowalski, Kamil } 933f4c4dcf4SKowalski, Kamil 934f4c4dcf4SKowalski, Kamil /** 935f4c4dcf4SKowalski, Kamil * @internal 936b6cd31e1SEd Tanous * @brief Formats ResourceNotFound message into JSONd 937f4c4dcf4SKowalski, Kamil * 938f4c4dcf4SKowalski, Kamil * See header file for more information 939f4c4dcf4SKowalski, Kamil * @endinternal 940f4c4dcf4SKowalski, Kamil */ 9411668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2) 9421abe55efSEd Tanous { 943fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceNotFound, 9441668ce6dSEd Tanous std::to_array({arg1, arg2})); 945b5c07418SJames Feist } 946b5c07418SJames Feist 9471668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1, 9481668ce6dSEd Tanous std::string_view arg2) 949b5c07418SJames Feist { 950b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 951b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2)); 952f4c4dcf4SKowalski, Kamil } 953f4c4dcf4SKowalski, Kamil 954f4c4dcf4SKowalski, Kamil /** 955f4c4dcf4SKowalski, Kamil * @internal 956f4c4dcf4SKowalski, Kamil * @brief Formats CouldNotEstablishConnection message into JSON 957f4c4dcf4SKowalski, Kamil * 958f4c4dcf4SKowalski, Kamil * See header file for more information 959f4c4dcf4SKowalski, Kamil * @endinternal 960f4c4dcf4SKowalski, Kamil */ 961ace85d60SEd Tanous nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1) 9621abe55efSEd Tanous { 9631668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 964fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::couldNotEstablishConnection, 9651668ce6dSEd Tanous std::to_array({arg1str})); 966b5c07418SJames Feist } 967b5c07418SJames Feist 968ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res, 969ace85d60SEd Tanous const boost::urls::url_view& arg1) 970b5c07418SJames Feist { 971b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 972b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1)); 973f4c4dcf4SKowalski, Kamil } 974f4c4dcf4SKowalski, Kamil 975f4c4dcf4SKowalski, Kamil /** 976f4c4dcf4SKowalski, Kamil * @internal 977f12894f8SJason M. Bills * @brief Formats PropertyNotWritable message into JSON for the specified 978f12894f8SJason M. Bills * property 979f12894f8SJason M. Bills * 980f12894f8SJason M. Bills * See header file for more information 981f12894f8SJason M. Bills * @endinternal 982f12894f8SJason M. Bills */ 9831668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1) 984f12894f8SJason M. Bills { 985fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyNotWritable, 9861668ce6dSEd Tanous std::to_array({arg1})); 987b5c07418SJames Feist } 988b5c07418SJames Feist 9891668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1) 990b5c07418SJames Feist { 991b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 992b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1); 993f4c4dcf4SKowalski, Kamil } 994f4c4dcf4SKowalski, Kamil 995f4c4dcf4SKowalski, Kamil /** 996f4c4dcf4SKowalski, Kamil * @internal 997f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueTypeError message into JSON 998f4c4dcf4SKowalski, Kamil * 999f4c4dcf4SKowalski, Kamil * See header file for more information 1000f4c4dcf4SKowalski, Kamil * @endinternal 1001f4c4dcf4SKowalski, Kamil */ 10021668ce6dSEd Tanous nlohmann::json queryParameterValueTypeError(std::string_view arg1, 10031668ce6dSEd Tanous std::string_view arg2) 10041abe55efSEd Tanous { 1005b6cd31e1SEd Tanous return getLog( 1006fffb8c1fSEd Tanous redfish::registries::base::Index::queryParameterValueTypeError, 10071668ce6dSEd Tanous std::to_array({arg1, arg2})); 1008b5c07418SJames Feist } 1009b5c07418SJames Feist 10101668ce6dSEd Tanous void queryParameterValueTypeError(crow::Response& res, std::string_view arg1, 10111668ce6dSEd Tanous std::string_view arg2) 1012b5c07418SJames Feist { 1013b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1014b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1015b5c07418SJames Feist queryParameterValueTypeError(arg1, arg2)); 1016f4c4dcf4SKowalski, Kamil } 1017f4c4dcf4SKowalski, Kamil 1018f4c4dcf4SKowalski, Kamil /** 1019f4c4dcf4SKowalski, Kamil * @internal 1020f4c4dcf4SKowalski, Kamil * @brief Formats ServiceShuttingDown message into JSON 1021f4c4dcf4SKowalski, Kamil * 1022f4c4dcf4SKowalski, Kamil * See header file for more information 1023f4c4dcf4SKowalski, Kamil * @endinternal 1024f4c4dcf4SKowalski, Kamil */ 1025b5c07418SJames Feist nlohmann::json serviceShuttingDown(void) 10261abe55efSEd Tanous { 1027fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceShuttingDown, {}); 1028b5c07418SJames Feist } 1029b5c07418SJames Feist 1030b5c07418SJames Feist void serviceShuttingDown(crow::Response& res) 1031b5c07418SJames Feist { 1032b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1033b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceShuttingDown()); 1034f4c4dcf4SKowalski, Kamil } 1035f4c4dcf4SKowalski, Kamil 1036f4c4dcf4SKowalski, Kamil /** 1037f4c4dcf4SKowalski, Kamil * @internal 1038f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterDuplicate message into JSON 1039f4c4dcf4SKowalski, Kamil * 1040f4c4dcf4SKowalski, Kamil * See header file for more information 1041f4c4dcf4SKowalski, Kamil * @endinternal 1042f4c4dcf4SKowalski, Kamil */ 10431668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1, 10441668ce6dSEd Tanous std::string_view arg2) 10451abe55efSEd Tanous { 1046fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterDuplicate, 10471668ce6dSEd Tanous std::to_array({arg1, arg2})); 1048b5c07418SJames Feist } 1049b5c07418SJames Feist 10501668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1, 10511668ce6dSEd Tanous std::string_view arg2) 1052b5c07418SJames Feist { 1053b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1054b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2)); 1055f4c4dcf4SKowalski, Kamil } 1056f4c4dcf4SKowalski, Kamil 1057f4c4dcf4SKowalski, Kamil /** 1058f4c4dcf4SKowalski, Kamil * @internal 1059f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterNotSupported message into JSON 1060f4c4dcf4SKowalski, Kamil * 1061f4c4dcf4SKowalski, Kamil * See header file for more information 1062f4c4dcf4SKowalski, Kamil * @endinternal 1063f4c4dcf4SKowalski, Kamil */ 10641668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1, 10651668ce6dSEd Tanous std::string_view arg2) 10661abe55efSEd Tanous { 1067fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterNotSupported, 10681668ce6dSEd Tanous std::to_array({arg1, arg2})); 1069b5c07418SJames Feist } 1070b5c07418SJames Feist 10711668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1, 10721668ce6dSEd Tanous std::string_view arg2) 1073b5c07418SJames Feist { 1074b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1075b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1076b5c07418SJames Feist actionParameterNotSupported(arg1, arg2)); 1077f4c4dcf4SKowalski, Kamil } 1078f4c4dcf4SKowalski, Kamil 1079f4c4dcf4SKowalski, Kamil /** 1080f4c4dcf4SKowalski, Kamil * @internal 1081f4c4dcf4SKowalski, Kamil * @brief Formats SourceDoesNotSupportProtocol message into JSON 1082f4c4dcf4SKowalski, Kamil * 1083f4c4dcf4SKowalski, Kamil * See header file for more information 1084f4c4dcf4SKowalski, Kamil * @endinternal 1085f4c4dcf4SKowalski, Kamil */ 1086ace85d60SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1, 10871668ce6dSEd Tanous std::string_view arg2) 10881abe55efSEd Tanous { 10891668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 1090b6cd31e1SEd Tanous return getLog( 1091fffb8c1fSEd Tanous redfish::registries::base::Index::sourceDoesNotSupportProtocol, 10921668ce6dSEd Tanous std::to_array({arg1str, arg2})); 1093b5c07418SJames Feist } 1094b5c07418SJames Feist 1095ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res, 1096ace85d60SEd Tanous const boost::urls::url_view& arg1, 10971668ce6dSEd Tanous std::string_view arg2) 1098b5c07418SJames Feist { 1099b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1100b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1101b5c07418SJames Feist sourceDoesNotSupportProtocol(arg1, arg2)); 1102f4c4dcf4SKowalski, Kamil } 1103f4c4dcf4SKowalski, Kamil 1104f4c4dcf4SKowalski, Kamil /** 1105f4c4dcf4SKowalski, Kamil * @internal 1106f4c4dcf4SKowalski, Kamil * @brief Formats AccountRemoved message into JSON 1107f4c4dcf4SKowalski, Kamil * 1108f4c4dcf4SKowalski, Kamil * See header file for more information 1109f4c4dcf4SKowalski, Kamil * @endinternal 1110f4c4dcf4SKowalski, Kamil */ 1111b5c07418SJames Feist nlohmann::json accountRemoved(void) 11121abe55efSEd Tanous { 1113fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountRemoved, {}); 1114b5c07418SJames Feist } 1115b5c07418SJames Feist 1116b5c07418SJames Feist void accountRemoved(crow::Response& res) 1117b5c07418SJames Feist { 1118b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1119b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, accountRemoved()); 1120f4c4dcf4SKowalski, Kamil } 1121f4c4dcf4SKowalski, Kamil 1122f4c4dcf4SKowalski, Kamil /** 1123f4c4dcf4SKowalski, Kamil * @internal 1124f4c4dcf4SKowalski, Kamil * @brief Formats AccessDenied message into JSON 1125f4c4dcf4SKowalski, Kamil * 1126f4c4dcf4SKowalski, Kamil * See header file for more information 1127f4c4dcf4SKowalski, Kamil * @endinternal 1128f4c4dcf4SKowalski, Kamil */ 1129ace85d60SEd Tanous nlohmann::json accessDenied(const boost::urls::url_view& arg1) 11301abe55efSEd Tanous { 11311668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 1132fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accessDenied, 11331668ce6dSEd Tanous std::to_array({arg1str})); 1134b5c07418SJames Feist } 1135b5c07418SJames Feist 1136ace85d60SEd Tanous void accessDenied(crow::Response& res, const boost::urls::url_view& arg1) 1137b5c07418SJames Feist { 1138b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1139b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accessDenied(arg1)); 1140f4c4dcf4SKowalski, Kamil } 1141f4c4dcf4SKowalski, Kamil 1142f4c4dcf4SKowalski, Kamil /** 1143f4c4dcf4SKowalski, Kamil * @internal 1144f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupported message into JSON 1145f4c4dcf4SKowalski, Kamil * 1146f4c4dcf4SKowalski, Kamil * See header file for more information 1147f4c4dcf4SKowalski, Kamil * @endinternal 1148f4c4dcf4SKowalski, Kamil */ 1149b5c07418SJames Feist nlohmann::json queryNotSupported(void) 11501abe55efSEd Tanous { 1151fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryNotSupported, {}); 1152b5c07418SJames Feist } 1153b5c07418SJames Feist 1154b5c07418SJames Feist void queryNotSupported(crow::Response& res) 1155b5c07418SJames Feist { 1156b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1157b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupported()); 1158f4c4dcf4SKowalski, Kamil } 1159f4c4dcf4SKowalski, Kamil 1160f4c4dcf4SKowalski, Kamil /** 1161f4c4dcf4SKowalski, Kamil * @internal 1162f4c4dcf4SKowalski, Kamil * @brief Formats CreateLimitReachedForResource message into JSON 1163f4c4dcf4SKowalski, Kamil * 1164f4c4dcf4SKowalski, Kamil * See header file for more information 1165f4c4dcf4SKowalski, Kamil * @endinternal 1166f4c4dcf4SKowalski, Kamil */ 1167b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void) 11681abe55efSEd Tanous { 1169b6cd31e1SEd Tanous return getLog( 1170fffb8c1fSEd Tanous redfish::registries::base::Index::createLimitReachedForResource, {}); 1171b5c07418SJames Feist } 1172b5c07418SJames Feist 1173b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res) 1174b5c07418SJames Feist { 1175b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1176b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, createLimitReachedForResource()); 1177f4c4dcf4SKowalski, Kamil } 1178f4c4dcf4SKowalski, Kamil 1179f4c4dcf4SKowalski, Kamil /** 1180f4c4dcf4SKowalski, Kamil * @internal 1181f4c4dcf4SKowalski, Kamil * @brief Formats GeneralError message into JSON 1182f4c4dcf4SKowalski, Kamil * 1183f4c4dcf4SKowalski, Kamil * See header file for more information 1184f4c4dcf4SKowalski, Kamil * @endinternal 1185f4c4dcf4SKowalski, Kamil */ 1186b5c07418SJames Feist nlohmann::json generalError(void) 11871abe55efSEd Tanous { 1188fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::generalError, {}); 1189b5c07418SJames Feist } 1190b5c07418SJames Feist 1191b5c07418SJames Feist void generalError(crow::Response& res) 1192b5c07418SJames Feist { 1193b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 1194b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, generalError()); 1195f4c4dcf4SKowalski, Kamil } 1196f4c4dcf4SKowalski, Kamil 1197f4c4dcf4SKowalski, Kamil /** 1198f4c4dcf4SKowalski, Kamil * @internal 1199f4c4dcf4SKowalski, Kamil * @brief Formats Success message into JSON 1200f4c4dcf4SKowalski, Kamil * 1201f4c4dcf4SKowalski, Kamil * See header file for more information 1202f4c4dcf4SKowalski, Kamil * @endinternal 1203f4c4dcf4SKowalski, Kamil */ 1204b5c07418SJames Feist nlohmann::json success(void) 12051abe55efSEd Tanous { 1206fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::success, {}); 1207b5c07418SJames Feist } 1208b5c07418SJames Feist 1209b5c07418SJames Feist void success(crow::Response& res) 1210b5c07418SJames Feist { 1211b5c07418SJames Feist // don't set res.result here because success is the default and any 1212b5c07418SJames Feist // error should overwrite the default 1213b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, success()); 1214f12894f8SJason M. Bills } 1215f12894f8SJason M. Bills 1216f12894f8SJason M. Bills /** 1217f12894f8SJason M. Bills * @internal 1218f4c4dcf4SKowalski, Kamil * @brief Formats Created message into JSON 1219f4c4dcf4SKowalski, Kamil * 1220f4c4dcf4SKowalski, Kamil * See header file for more information 1221f4c4dcf4SKowalski, Kamil * @endinternal 1222f4c4dcf4SKowalski, Kamil */ 1223b5c07418SJames Feist nlohmann::json created(void) 12241abe55efSEd Tanous { 1225fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::created, {}); 1226b5c07418SJames Feist } 1227b5c07418SJames Feist 1228b5c07418SJames Feist void created(crow::Response& res) 1229b5c07418SJames Feist { 1230b5c07418SJames Feist res.result(boost::beast::http::status::created); 1231b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, created()); 1232f4c4dcf4SKowalski, Kamil } 1233f4c4dcf4SKowalski, Kamil 1234f4c4dcf4SKowalski, Kamil /** 1235f4c4dcf4SKowalski, Kamil * @internal 1236cc9139ecSJason M. Bills * @brief Formats NoOperation message into JSON 1237cc9139ecSJason M. Bills * 1238cc9139ecSJason M. Bills * See header file for more information 1239cc9139ecSJason M. Bills * @endinternal 1240cc9139ecSJason M. Bills */ 1241b5c07418SJames Feist nlohmann::json noOperation(void) 1242cc9139ecSJason M. Bills { 1243fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::noOperation, {}); 1244b5c07418SJames Feist } 1245b5c07418SJames Feist 1246b5c07418SJames Feist void noOperation(crow::Response& res) 1247b5c07418SJames Feist { 1248b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1249b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noOperation()); 1250cc9139ecSJason M. Bills } 1251cc9139ecSJason M. Bills 1252cc9139ecSJason M. Bills /** 1253cc9139ecSJason M. Bills * @internal 1254b5c07418SJames Feist * @brief Formats PropertyUnknown message into JSON for the specified 1255b5c07418SJames Feist * property 1256f12894f8SJason M. Bills * 1257f12894f8SJason M. Bills * See header file for more information 1258f12894f8SJason M. Bills * @endinternal 1259f12894f8SJason M. Bills */ 12601668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1) 1261b5c07418SJames Feist { 1262fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyUnknown, 12631668ce6dSEd Tanous std::to_array({arg1})); 1264b5c07418SJames Feist } 1265b5c07418SJames Feist 12661668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1) 1267f12894f8SJason M. Bills { 1268f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 1269b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1); 1270f4c4dcf4SKowalski, Kamil } 1271f4c4dcf4SKowalski, Kamil 1272f4c4dcf4SKowalski, Kamil /** 1273f4c4dcf4SKowalski, Kamil * @internal 1274f4c4dcf4SKowalski, Kamil * @brief Formats NoValidSession message into JSON 1275f4c4dcf4SKowalski, Kamil * 1276f4c4dcf4SKowalski, Kamil * See header file for more information 1277f4c4dcf4SKowalski, Kamil * @endinternal 1278f4c4dcf4SKowalski, Kamil */ 1279b5c07418SJames Feist nlohmann::json noValidSession(void) 12801abe55efSEd Tanous { 1281fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::noValidSession, {}); 1282b5c07418SJames Feist } 1283b5c07418SJames Feist 1284b5c07418SJames Feist void noValidSession(crow::Response& res) 1285b5c07418SJames Feist { 1286b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1287b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noValidSession()); 1288f4c4dcf4SKowalski, Kamil } 1289f4c4dcf4SKowalski, Kamil 1290f4c4dcf4SKowalski, Kamil /** 1291f4c4dcf4SKowalski, Kamil * @internal 1292f4c4dcf4SKowalski, Kamil * @brief Formats InvalidObject message into JSON 1293f4c4dcf4SKowalski, Kamil * 1294f4c4dcf4SKowalski, Kamil * See header file for more information 1295f4c4dcf4SKowalski, Kamil * @endinternal 1296f4c4dcf4SKowalski, Kamil */ 1297ace85d60SEd Tanous nlohmann::json invalidObject(const boost::urls::url_view& arg1) 12981abe55efSEd Tanous { 12991668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 1300fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::invalidObject, 13011668ce6dSEd Tanous std::to_array({arg1str})); 1302b5c07418SJames Feist } 1303b5c07418SJames Feist 1304ace85d60SEd Tanous void invalidObject(crow::Response& res, const boost::urls::url_view& arg1) 1305b5c07418SJames Feist { 1306b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1307b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidObject(arg1)); 1308f4c4dcf4SKowalski, Kamil } 1309f4c4dcf4SKowalski, Kamil 1310f4c4dcf4SKowalski, Kamil /** 1311f4c4dcf4SKowalski, Kamil * @internal 1312f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInStandby message into JSON 1313f4c4dcf4SKowalski, Kamil * 1314f4c4dcf4SKowalski, Kamil * See header file for more information 1315f4c4dcf4SKowalski, Kamil * @endinternal 1316f4c4dcf4SKowalski, Kamil */ 1317b5c07418SJames Feist nlohmann::json resourceInStandby(void) 13181abe55efSEd Tanous { 1319fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceInStandby, {}); 1320b5c07418SJames Feist } 1321b5c07418SJames Feist 1322b5c07418SJames Feist void resourceInStandby(crow::Response& res) 1323b5c07418SJames Feist { 1324b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1325b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInStandby()); 1326f4c4dcf4SKowalski, Kamil } 1327f4c4dcf4SKowalski, Kamil 1328f4c4dcf4SKowalski, Kamil /** 1329f4c4dcf4SKowalski, Kamil * @internal 1330f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueTypeError message into JSON 1331f4c4dcf4SKowalski, Kamil * 1332f4c4dcf4SKowalski, Kamil * See header file for more information 1333f4c4dcf4SKowalski, Kamil * @endinternal 1334f4c4dcf4SKowalski, Kamil */ 13351668ce6dSEd Tanous nlohmann::json actionParameterValueTypeError(std::string_view arg1, 13361668ce6dSEd Tanous std::string_view arg2, 13371668ce6dSEd Tanous std::string_view arg3) 13381abe55efSEd Tanous { 1339b6cd31e1SEd Tanous return getLog( 1340fffb8c1fSEd Tanous redfish::registries::base::Index::actionParameterValueTypeError, 13411668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 1342b5c07418SJames Feist } 1343b5c07418SJames Feist 13441668ce6dSEd Tanous void actionParameterValueTypeError(crow::Response& res, std::string_view arg1, 13451668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 1346b5c07418SJames Feist { 1347b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1348b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1349b5c07418SJames Feist actionParameterValueTypeError(arg1, arg2, arg3)); 1350f4c4dcf4SKowalski, Kamil } 1351f4c4dcf4SKowalski, Kamil 1352f4c4dcf4SKowalski, Kamil /** 1353f4c4dcf4SKowalski, Kamil * @internal 1354f4c4dcf4SKowalski, Kamil * @brief Formats SessionLimitExceeded message into JSON 1355f4c4dcf4SKowalski, Kamil * 1356f4c4dcf4SKowalski, Kamil * See header file for more information 1357f4c4dcf4SKowalski, Kamil * @endinternal 1358f4c4dcf4SKowalski, Kamil */ 1359b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void) 13601abe55efSEd Tanous { 1361fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::sessionLimitExceeded, {}); 1362b5c07418SJames Feist } 1363b5c07418SJames Feist 1364b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res) 1365b5c07418SJames Feist { 1366b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1367b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, sessionLimitExceeded()); 1368f4c4dcf4SKowalski, Kamil } 1369f4c4dcf4SKowalski, Kamil 1370f4c4dcf4SKowalski, Kamil /** 1371f4c4dcf4SKowalski, Kamil * @internal 1372f4c4dcf4SKowalski, Kamil * @brief Formats ActionNotSupported message into JSON 1373f4c4dcf4SKowalski, Kamil * 1374f4c4dcf4SKowalski, Kamil * See header file for more information 1375f4c4dcf4SKowalski, Kamil * @endinternal 1376f4c4dcf4SKowalski, Kamil */ 13771668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1) 13781abe55efSEd Tanous { 1379fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionNotSupported, 13801668ce6dSEd Tanous std::to_array({arg1})); 1381b5c07418SJames Feist } 1382b5c07418SJames Feist 13831668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1) 1384b5c07418SJames Feist { 1385b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1386b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1)); 1387f4c4dcf4SKowalski, Kamil } 1388f4c4dcf4SKowalski, Kamil 1389f4c4dcf4SKowalski, Kamil /** 1390f4c4dcf4SKowalski, Kamil * @internal 1391f4c4dcf4SKowalski, Kamil * @brief Formats InvalidIndex message into JSON 1392f4c4dcf4SKowalski, Kamil * 1393f4c4dcf4SKowalski, Kamil * See header file for more information 1394f4c4dcf4SKowalski, Kamil * @endinternal 1395f4c4dcf4SKowalski, Kamil */ 13965187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1) 13971abe55efSEd Tanous { 1398b6cd31e1SEd Tanous std::string arg1Str = std::to_string(arg1); 1399fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::invalidIndex, 14001668ce6dSEd Tanous std::to_array<std::string_view>({arg1Str})); 1401b5c07418SJames Feist } 1402b5c07418SJames Feist 14035187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1) 1404b5c07418SJames Feist { 1405b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1406b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidIndex(arg1)); 1407f4c4dcf4SKowalski, Kamil } 1408f4c4dcf4SKowalski, Kamil 1409f4c4dcf4SKowalski, Kamil /** 1410f4c4dcf4SKowalski, Kamil * @internal 1411f4c4dcf4SKowalski, Kamil * @brief Formats EmptyJSON message into JSON 1412f4c4dcf4SKowalski, Kamil * 1413f4c4dcf4SKowalski, Kamil * See header file for more information 1414f4c4dcf4SKowalski, Kamil * @endinternal 1415f4c4dcf4SKowalski, Kamil */ 1416b5c07418SJames Feist nlohmann::json emptyJSON(void) 14171abe55efSEd Tanous { 1418fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::emptyJSON, {}); 1419b5c07418SJames Feist } 1420b5c07418SJames Feist 1421b5c07418SJames Feist void emptyJSON(crow::Response& res) 1422b5c07418SJames Feist { 1423b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1424b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, emptyJSON()); 1425f4c4dcf4SKowalski, Kamil } 1426f4c4dcf4SKowalski, Kamil 1427f4c4dcf4SKowalski, Kamil /** 1428f4c4dcf4SKowalski, Kamil * @internal 1429f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupportedOnResource message into JSON 1430f4c4dcf4SKowalski, Kamil * 1431f4c4dcf4SKowalski, Kamil * See header file for more information 1432f4c4dcf4SKowalski, Kamil * @endinternal 1433f4c4dcf4SKowalski, Kamil */ 1434b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void) 14351abe55efSEd Tanous { 1436fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryNotSupportedOnResource, 1437b6cd31e1SEd Tanous {}); 1438b5c07418SJames Feist } 1439b5c07418SJames Feist 1440b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res) 1441b5c07418SJames Feist { 1442b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1443b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource()); 1444f4c4dcf4SKowalski, Kamil } 1445f4c4dcf4SKowalski, Kamil 1446f4c4dcf4SKowalski, Kamil /** 1447f4c4dcf4SKowalski, Kamil * @internal 1448684bb4b8SJason M. Bills * @brief Formats QueryNotSupportedOnOperation message into JSON 1449684bb4b8SJason M. Bills * 1450684bb4b8SJason M. Bills * See header file for more information 1451684bb4b8SJason M. Bills * @endinternal 1452684bb4b8SJason M. Bills */ 1453684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void) 1454684bb4b8SJason M. Bills { 1455b6cd31e1SEd Tanous return getLog( 1456fffb8c1fSEd Tanous redfish::registries::base::Index::queryNotSupportedOnOperation, {}); 1457684bb4b8SJason M. Bills } 1458684bb4b8SJason M. Bills 1459684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res) 1460684bb4b8SJason M. Bills { 1461684bb4b8SJason M. Bills res.result(boost::beast::http::status::forbidden); 1462684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation()); 1463684bb4b8SJason M. Bills } 1464684bb4b8SJason M. Bills 1465684bb4b8SJason M. Bills /** 1466684bb4b8SJason M. Bills * @internal 1467684bb4b8SJason M. Bills * @brief Formats QueryCombinationInvalid message into JSON 1468684bb4b8SJason M. Bills * 1469684bb4b8SJason M. Bills * See header file for more information 1470684bb4b8SJason M. Bills * @endinternal 1471684bb4b8SJason M. Bills */ 1472684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void) 1473684bb4b8SJason M. Bills { 1474fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryCombinationInvalid, 1475fffb8c1fSEd Tanous {}); 1476684bb4b8SJason M. Bills } 1477684bb4b8SJason M. Bills 1478684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res) 1479684bb4b8SJason M. Bills { 1480684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 1481684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, queryCombinationInvalid()); 1482684bb4b8SJason M. Bills } 1483684bb4b8SJason M. Bills 1484684bb4b8SJason M. Bills /** 1485684bb4b8SJason M. Bills * @internal 1486f4c4dcf4SKowalski, Kamil * @brief Formats InsufficientPrivilege message into JSON 1487f4c4dcf4SKowalski, Kamil * 1488f4c4dcf4SKowalski, Kamil * See header file for more information 1489f4c4dcf4SKowalski, Kamil * @endinternal 1490f4c4dcf4SKowalski, Kamil */ 1491b5c07418SJames Feist nlohmann::json insufficientPrivilege(void) 14921abe55efSEd Tanous { 1493fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::insufficientPrivilege, {}); 1494b5c07418SJames Feist } 1495b5c07418SJames Feist 1496b5c07418SJames Feist void insufficientPrivilege(crow::Response& res) 1497b5c07418SJames Feist { 1498b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1499b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, insufficientPrivilege()); 1500f4c4dcf4SKowalski, Kamil } 1501f4c4dcf4SKowalski, Kamil 1502f4c4dcf4SKowalski, Kamil /** 1503f4c4dcf4SKowalski, Kamil * @internal 1504f4c4dcf4SKowalski, Kamil * @brief Formats PropertyValueModified message into JSON 1505f4c4dcf4SKowalski, Kamil * 1506f4c4dcf4SKowalski, Kamil * See header file for more information 1507f4c4dcf4SKowalski, Kamil * @endinternal 1508f4c4dcf4SKowalski, Kamil */ 15091668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1, 15101668ce6dSEd Tanous std::string_view arg2) 1511b5c07418SJames Feist { 1512fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueModified, 15131668ce6dSEd Tanous std::to_array({arg1, arg2})); 1514b5c07418SJames Feist } 1515b5c07418SJames Feist 15161668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1, 15171668ce6dSEd Tanous std::string_view arg2) 15181abe55efSEd Tanous { 1519f12894f8SJason M. Bills res.result(boost::beast::http::status::ok); 1520b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1); 1521f4c4dcf4SKowalski, Kamil } 1522f4c4dcf4SKowalski, Kamil 1523f4c4dcf4SKowalski, Kamil /** 1524f4c4dcf4SKowalski, Kamil * @internal 1525f4c4dcf4SKowalski, Kamil * @brief Formats AccountNotModified message into JSON 1526f4c4dcf4SKowalski, Kamil * 1527f4c4dcf4SKowalski, Kamil * See header file for more information 1528f4c4dcf4SKowalski, Kamil * @endinternal 1529f4c4dcf4SKowalski, Kamil */ 1530b5c07418SJames Feist nlohmann::json accountNotModified(void) 15311abe55efSEd Tanous { 1532fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountNotModified, {}); 1533b5c07418SJames Feist } 1534b5c07418SJames Feist 1535b5c07418SJames Feist void accountNotModified(crow::Response& res) 1536b5c07418SJames Feist { 1537b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1538b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountNotModified()); 1539f4c4dcf4SKowalski, Kamil } 1540f4c4dcf4SKowalski, Kamil 1541f4c4dcf4SKowalski, Kamil /** 1542f4c4dcf4SKowalski, Kamil * @internal 1543f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueFormatError message into JSON 1544f4c4dcf4SKowalski, Kamil * 1545f4c4dcf4SKowalski, Kamil * See header file for more information 1546f4c4dcf4SKowalski, Kamil * @endinternal 1547f4c4dcf4SKowalski, Kamil */ 15481668ce6dSEd Tanous nlohmann::json queryParameterValueFormatError(std::string_view arg1, 15491668ce6dSEd Tanous std::string_view arg2) 15501abe55efSEd Tanous { 1551fffb8c1fSEd Tanous return getLog( 1552fffb8c1fSEd Tanous redfish::registries::base::Index::queryParameterValueFormatError, 15531668ce6dSEd Tanous std::to_array({arg1, arg2})); 1554b5c07418SJames Feist } 1555b5c07418SJames Feist 15561668ce6dSEd Tanous void queryParameterValueFormatError(crow::Response& res, std::string_view arg1, 15571668ce6dSEd Tanous std::string_view arg2) 1558b5c07418SJames Feist { 1559b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1560b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1561b5c07418SJames Feist queryParameterValueFormatError(arg1, arg2)); 1562f4c4dcf4SKowalski, Kamil } 1563f4c4dcf4SKowalski, Kamil 1564f4c4dcf4SKowalski, Kamil /** 1565f4c4dcf4SKowalski, Kamil * @internal 1566b5c07418SJames Feist * @brief Formats PropertyMissing message into JSON for the specified 1567b5c07418SJames Feist * property 1568f12894f8SJason M. Bills * 1569f12894f8SJason M. Bills * See header file for more information 1570f12894f8SJason M. Bills * @endinternal 1571f12894f8SJason M. Bills */ 15721668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1) 1573f12894f8SJason M. Bills { 1574fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyMissing, 15751668ce6dSEd Tanous std::to_array({arg1})); 1576b5c07418SJames Feist } 1577b5c07418SJames Feist 15781668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1) 1579b5c07418SJames Feist { 1580b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1581b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1); 1582f4c4dcf4SKowalski, Kamil } 1583f4c4dcf4SKowalski, Kamil 1584f4c4dcf4SKowalski, Kamil /** 1585f4c4dcf4SKowalski, Kamil * @internal 1586f4c4dcf4SKowalski, Kamil * @brief Formats ResourceExhaustion message into JSON 1587f4c4dcf4SKowalski, Kamil * 1588f4c4dcf4SKowalski, Kamil * See header file for more information 1589f4c4dcf4SKowalski, Kamil * @endinternal 1590f4c4dcf4SKowalski, Kamil */ 15911668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1) 15921abe55efSEd Tanous { 1593fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceExhaustion, 15941668ce6dSEd Tanous std::to_array({arg1})); 1595b5c07418SJames Feist } 1596b5c07418SJames Feist 15971668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1) 1598b5c07418SJames Feist { 1599b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1600b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1)); 1601f4c4dcf4SKowalski, Kamil } 1602f4c4dcf4SKowalski, Kamil 1603f4c4dcf4SKowalski, Kamil /** 1604f4c4dcf4SKowalski, Kamil * @internal 1605f4c4dcf4SKowalski, Kamil * @brief Formats AccountModified message into JSON 1606f4c4dcf4SKowalski, Kamil * 1607f4c4dcf4SKowalski, Kamil * See header file for more information 1608f4c4dcf4SKowalski, Kamil * @endinternal 1609f4c4dcf4SKowalski, Kamil */ 1610b5c07418SJames Feist nlohmann::json accountModified(void) 16111abe55efSEd Tanous { 1612fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountModified, {}); 1613b5c07418SJames Feist } 1614b5c07418SJames Feist 1615b5c07418SJames Feist void accountModified(crow::Response& res) 1616b5c07418SJames Feist { 1617b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1618b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountModified()); 1619f4c4dcf4SKowalski, Kamil } 1620f4c4dcf4SKowalski, Kamil 1621f4c4dcf4SKowalski, Kamil /** 1622f4c4dcf4SKowalski, Kamil * @internal 1623f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterOutOfRange message into JSON 1624f4c4dcf4SKowalski, Kamil * 1625f4c4dcf4SKowalski, Kamil * See header file for more information 1626f4c4dcf4SKowalski, Kamil * @endinternal 1627f4c4dcf4SKowalski, Kamil */ 16281668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1, 16291668ce6dSEd Tanous std::string_view arg2, 16301668ce6dSEd Tanous std::string_view arg3) 16311abe55efSEd Tanous { 1632fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryParameterOutOfRange, 16331668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 1634b5c07418SJames Feist } 1635b5c07418SJames Feist 16361668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1, 16371668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 1638b5c07418SJames Feist { 1639b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1640b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1641b5c07418SJames Feist queryParameterOutOfRange(arg1, arg2, arg3)); 1642f4c4dcf4SKowalski, Kamil } 1643f4c4dcf4SKowalski, Kamil 1644b6cd31e1SEd Tanous nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1) 1645b6cd31e1SEd Tanous { 16461668ce6dSEd Tanous std::string_view arg1str(arg1.data(), arg1.size()); 1647fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::passwordChangeRequired, 16481668ce6dSEd Tanous std::to_array({arg1str})); 1649b6cd31e1SEd Tanous } 1650b6cd31e1SEd Tanous 16513bf4e632SJoseph Reynolds /** 16523bf4e632SJoseph Reynolds * @internal 16533bf4e632SJoseph Reynolds * @brief Formats PasswordChangeRequired message into JSON 16543bf4e632SJoseph Reynolds * 16553bf4e632SJoseph Reynolds * See header file for more information 16563bf4e632SJoseph Reynolds * @endinternal 16573bf4e632SJoseph Reynolds */ 1658ace85d60SEd Tanous void passwordChangeRequired(crow::Response& res, 1659ace85d60SEd Tanous const boost::urls::url_view& arg1) 16603bf4e632SJoseph Reynolds { 1661b6cd31e1SEd Tanous messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1)); 16623bf4e632SJoseph Reynolds } 16633bf4e632SJoseph Reynolds 16641668ce6dSEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1, 16651668ce6dSEd Tanous std::string_view arg2) 16664cde5d90SJames Feist { 16674cde5d90SJames Feist res.result(boost::beast::http::status::bad_request); 16684cde5d90SJames Feist addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2)); 16694cde5d90SJames Feist } 16704cde5d90SJames Feist 16714cde5d90SJames Feist /** 16724cde5d90SJames Feist * @internal 16734cde5d90SJames Feist * @brief Formats Invalid File message into JSON 16744cde5d90SJames Feist * 16754cde5d90SJames Feist * See header file for more information 16764cde5d90SJames Feist * @endinternal 16774cde5d90SJames Feist */ 16781668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2) 16794cde5d90SJames Feist { 16801668ce6dSEd Tanous std::string msg = "Invalid file uploaded to "; 16811668ce6dSEd Tanous msg += arg1; 16821668ce6dSEd Tanous msg += ": "; 16831668ce6dSEd Tanous msg += arg2; 16841668ce6dSEd Tanous msg += "."; 16854cde5d90SJames Feist return nlohmann::json{ 16863e082749SAsmitha Karunanithi {"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"}, 16874a0bf539SManojkiran Eda {"MessageId", "OpenBMC.0.2.InvalidUpload"}, 16881668ce6dSEd Tanous {"Message", std::move(msg)}, 16894cde5d90SJames Feist {"MessageArgs", {arg1, arg2}}, 1690684bb4b8SJason M. Bills {"MessageSeverity", "Warning"}, 16914cde5d90SJames Feist {"Resolution", "None."}}; 16924cde5d90SJames Feist } 1693f4c4dcf4SKowalski, Kamil } // namespace messages 1694f4c4dcf4SKowalski, Kamil 1695d425c6f6SEd Tanous } // namespace redfish 1696