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 */ 160442ef92SNan Zhou #include "error_messages.hpp" 179ea15c35SEd Tanous 180442ef92SNan Zhou #include "http_response.hpp" 190442ef92SNan Zhou #include "logging.hpp" 200442ef92SNan Zhou #include "registries.hpp" 210442ef92SNan Zhou #include "registries/base_message_registry.hpp" 220442ef92SNan Zhou #include "source_location.hpp" 230442ef92SNan Zhou 240442ef92SNan Zhou #include <boost/beast/http/field.hpp> 259ea15c35SEd Tanous #include <boost/beast/http/status.hpp> 26faf100f9SEd Tanous #include <nlohmann/json.hpp> 27f4c4dcf4SKowalski, Kamil 281668ce6dSEd Tanous #include <array> 290442ef92SNan Zhou #include <cstddef> 300442ef92SNan Zhou #include <span> 310442ef92SNan Zhou #include <string> 320442ef92SNan Zhou #include <utility> 330442ef92SNan Zhou 340442ef92SNan Zhou // IWYU pragma: no_include <stddef.h> 351668ce6dSEd Tanous 361abe55efSEd Tanous namespace redfish 371abe55efSEd Tanous { 381abe55efSEd Tanous 391abe55efSEd Tanous namespace messages 401abe55efSEd Tanous { 41f4c4dcf4SKowalski, Kamil 42f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target, 431abe55efSEd Tanous const nlohmann::json& message) 441abe55efSEd Tanous { 45f4c4dcf4SKowalski, Kamil auto& error = target["error"]; 46f4c4dcf4SKowalski, Kamil 471abe55efSEd Tanous // If this is the first error message, fill in the information from the 481abe55efSEd Tanous // first error message to the top level struct 491abe55efSEd Tanous if (!error.is_object()) 501abe55efSEd Tanous { 51c074230bSJason M. Bills auto messageIdIterator = message.find("MessageId"); 52c074230bSJason M. Bills if (messageIdIterator == message.end()) 531abe55efSEd Tanous { 541abe55efSEd Tanous BMCWEB_LOG_CRITICAL 551abe55efSEd Tanous << "Attempt to add error message without MessageId"; 56f4c4dcf4SKowalski, Kamil return; 57f4c4dcf4SKowalski, Kamil } 58f4c4dcf4SKowalski, Kamil 59c074230bSJason M. Bills auto messageFieldIterator = message.find("Message"); 60c074230bSJason M. Bills if (messageFieldIterator == message.end()) 611abe55efSEd Tanous { 621abe55efSEd Tanous BMCWEB_LOG_CRITICAL 631abe55efSEd Tanous << "Attempt to add error message without Message"; 64f4c4dcf4SKowalski, Kamil return; 65f4c4dcf4SKowalski, Kamil } 661476687dSEd Tanous error["code"] = *messageIdIterator; 671476687dSEd Tanous error["message"] = *messageFieldIterator; 681abe55efSEd Tanous } 691abe55efSEd Tanous else 701abe55efSEd Tanous { 71f4c4dcf4SKowalski, Kamil // More than 1 error occurred, so the message has to be generic 7255c7b7a2SEd Tanous error["code"] = std::string(messageVersionPrefix) + "GeneralError"; 73cc9139ecSJason M. Bills error["message"] = "A general error has occurred. See Resolution for " 74cc9139ecSJason M. Bills "information on how to resolve the error."; 75f4c4dcf4SKowalski, Kamil } 76f4c4dcf4SKowalski, Kamil 773590bd1dSNan Zhou // This check could technically be done in the default construction 78f4c4dcf4SKowalski, Kamil // branch above, but because we need the pointer to the extended info field 79f4c4dcf4SKowalski, Kamil // anyway, it's more efficient to do it here. 80c074230bSJason M. Bills auto& extendedInfo = error[messages::messageAnnotation]; 81c074230bSJason M. Bills if (!extendedInfo.is_array()) 821abe55efSEd Tanous { 83c074230bSJason M. Bills extendedInfo = nlohmann::json::array(); 84f4c4dcf4SKowalski, Kamil } 85f4c4dcf4SKowalski, Kamil 86c074230bSJason M. Bills extendedInfo.push_back(message); 87f4c4dcf4SKowalski, Kamil } 88f4c4dcf4SKowalski, Kamil 893590bd1dSNan Zhou void moveErrorsToErrorJson(nlohmann::json& target, nlohmann::json& source) 903590bd1dSNan Zhou { 913590bd1dSNan Zhou if (!source.is_object()) 923590bd1dSNan Zhou { 933590bd1dSNan Zhou return; 943590bd1dSNan Zhou } 953590bd1dSNan Zhou auto errorIt = source.find("error"); 963590bd1dSNan Zhou if (errorIt == source.end()) 973590bd1dSNan Zhou { 983590bd1dSNan Zhou // caller puts error message in root 993590bd1dSNan Zhou messages::addMessageToErrorJson(target, source); 1003590bd1dSNan Zhou source.clear(); 1013590bd1dSNan Zhou return; 1023590bd1dSNan Zhou } 1033590bd1dSNan Zhou auto extendedInfoIt = errorIt->find(messages::messageAnnotation); 1043590bd1dSNan Zhou if (extendedInfoIt == errorIt->end()) 1053590bd1dSNan Zhou { 1063590bd1dSNan Zhou return; 1073590bd1dSNan Zhou } 1083590bd1dSNan Zhou const nlohmann::json::array_t* extendedInfo = 1093590bd1dSNan Zhou (*extendedInfoIt).get_ptr<const nlohmann::json::array_t*>(); 1103590bd1dSNan Zhou if (extendedInfo == nullptr) 1113590bd1dSNan Zhou { 1123590bd1dSNan Zhou source.erase(errorIt); 1133590bd1dSNan Zhou return; 1143590bd1dSNan Zhou } 1153590bd1dSNan Zhou for (const nlohmann::json& message : *extendedInfo) 1163590bd1dSNan Zhou { 1173590bd1dSNan Zhou addMessageToErrorJson(target, message); 1183590bd1dSNan Zhou } 1193590bd1dSNan Zhou source.erase(errorIt); 1203590bd1dSNan Zhou } 1213590bd1dSNan Zhou 122f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target, 123f12894f8SJason M. Bills const nlohmann::json& message) 1241abe55efSEd Tanous { 1251abe55efSEd Tanous if (!target[messages::messageAnnotation].is_array()) 1261abe55efSEd Tanous { 127f4c4dcf4SKowalski, Kamil // Force object to be an array 12855c7b7a2SEd Tanous target[messages::messageAnnotation] = nlohmann::json::array(); 129f4c4dcf4SKowalski, Kamil } 130f4c4dcf4SKowalski, Kamil 13155c7b7a2SEd Tanous target[messages::messageAnnotation].push_back(message); 132f4c4dcf4SKowalski, Kamil } 133f4c4dcf4SKowalski, Kamil 134f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target, 135f12894f8SJason M. Bills const nlohmann::json& message, 1361668ce6dSEd Tanous std::string_view fieldPath) 1371abe55efSEd Tanous { 1381668ce6dSEd Tanous std::string extendedInfo(fieldPath); 1391668ce6dSEd Tanous extendedInfo += messages::messageAnnotation; 140f4c4dcf4SKowalski, Kamil 1411668ce6dSEd Tanous nlohmann::json& field = target[extendedInfo]; 1421668ce6dSEd Tanous if (!field.is_array()) 1431abe55efSEd Tanous { 144f4c4dcf4SKowalski, Kamil // Force object to be an array 1451668ce6dSEd Tanous field = nlohmann::json::array(); 146f4c4dcf4SKowalski, Kamil } 147f4c4dcf4SKowalski, Kamil 148f4c4dcf4SKowalski, Kamil // Object exists and it is an array so we can just push in the message 1491668ce6dSEd Tanous field.push_back(message); 150f4c4dcf4SKowalski, Kamil } 151f4c4dcf4SKowalski, Kamil 152f7725d79SEd Tanous static nlohmann::json getLog(redfish::registries::base::Index name, 153b6cd31e1SEd Tanous std::span<const std::string_view> args) 154b6cd31e1SEd Tanous { 155b6cd31e1SEd Tanous size_t index = static_cast<size_t>(name); 156fffb8c1fSEd Tanous if (index >= redfish::registries::base::registry.size()) 157b6cd31e1SEd Tanous { 158b6cd31e1SEd Tanous return {}; 159b6cd31e1SEd Tanous } 16065e4f1f7SEd Tanous return getLogFromRegistry(redfish::registries::base::header, 16165e4f1f7SEd Tanous redfish::registries::base::registry, index, args); 162b6cd31e1SEd Tanous } 163b6cd31e1SEd Tanous 164f4c4dcf4SKowalski, Kamil /** 165f4c4dcf4SKowalski, Kamil * @internal 166f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInUse message into JSON 167f4c4dcf4SKowalski, Kamil * 168f4c4dcf4SKowalski, Kamil * See header file for more information 169f4c4dcf4SKowalski, Kamil * @endinternal 170f4c4dcf4SKowalski, Kamil */ 171b5c07418SJames Feist nlohmann::json resourceInUse(void) 1721abe55efSEd Tanous { 173fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceInUse, {}); 174b5c07418SJames Feist } 175b5c07418SJames Feist 176b5c07418SJames Feist void resourceInUse(crow::Response& res) 177b5c07418SJames Feist { 178b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 179b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInUse()); 180f4c4dcf4SKowalski, Kamil } 181f4c4dcf4SKowalski, Kamil 182f4c4dcf4SKowalski, Kamil /** 183f4c4dcf4SKowalski, Kamil * @internal 184f4c4dcf4SKowalski, Kamil * @brief Formats MalformedJSON message into JSON 185f4c4dcf4SKowalski, Kamil * 186f4c4dcf4SKowalski, Kamil * See header file for more information 187f4c4dcf4SKowalski, Kamil * @endinternal 188f4c4dcf4SKowalski, Kamil */ 189b5c07418SJames Feist nlohmann::json malformedJSON(void) 1901abe55efSEd Tanous { 191fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::malformedJSON, {}); 192b5c07418SJames Feist } 193b5c07418SJames Feist 194b5c07418SJames Feist void malformedJSON(crow::Response& res) 195b5c07418SJames Feist { 196b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 197b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, malformedJSON()); 198f4c4dcf4SKowalski, Kamil } 199f4c4dcf4SKowalski, Kamil 200f4c4dcf4SKowalski, Kamil /** 201f4c4dcf4SKowalski, Kamil * @internal 202f4c4dcf4SKowalski, Kamil * @brief Formats ResourceMissingAtURI message into JSON 203f4c4dcf4SKowalski, Kamil * 204f4c4dcf4SKowalski, Kamil * See header file for more information 205f4c4dcf4SKowalski, Kamil * @endinternal 206f4c4dcf4SKowalski, Kamil */ 207d9f466b3SEd Tanous nlohmann::json resourceMissingAtURI(boost::urls::url_view arg1) 2081abe55efSEd Tanous { 209079360aeSEd Tanous std::array<std::string_view, 1> args{arg1.buffer()}; 210fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceMissingAtURI, args); 211b5c07418SJames Feist } 212b5c07418SJames Feist 213d9f466b3SEd Tanous void resourceMissingAtURI(crow::Response& res, boost::urls::url_view arg1) 214b5c07418SJames Feist { 215b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 216b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1)); 217f4c4dcf4SKowalski, Kamil } 218f4c4dcf4SKowalski, Kamil 219f4c4dcf4SKowalski, Kamil /** 220f4c4dcf4SKowalski, Kamil * @internal 221f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueFormatError message into JSON 222f4c4dcf4SKowalski, Kamil * 223f4c4dcf4SKowalski, Kamil * See header file for more information 224f4c4dcf4SKowalski, Kamil * @endinternal 225f4c4dcf4SKowalski, Kamil */ 2261668ce6dSEd Tanous nlohmann::json actionParameterValueFormatError(std::string_view arg1, 2271668ce6dSEd Tanous std::string_view arg2, 2281668ce6dSEd Tanous std::string_view arg3) 2291abe55efSEd Tanous { 230fffb8c1fSEd Tanous return getLog( 231fffb8c1fSEd Tanous redfish::registries::base::Index::actionParameterValueFormatError, 2321668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 233b5c07418SJames Feist } 234b5c07418SJames Feist 2351668ce6dSEd Tanous void actionParameterValueFormatError(crow::Response& res, std::string_view arg1, 2361668ce6dSEd Tanous std::string_view arg2, 2371668ce6dSEd Tanous std::string_view arg3) 238b5c07418SJames Feist { 239b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 240b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 241b5c07418SJames Feist actionParameterValueFormatError(arg1, arg2, arg3)); 242f4c4dcf4SKowalski, Kamil } 243f4c4dcf4SKowalski, Kamil 244f4c4dcf4SKowalski, Kamil /** 245f4c4dcf4SKowalski, Kamil * @internal 2464ef82a15SAlex Schendel * @brief Formats ActionParameterValueNotInList message into JSON 2474ef82a15SAlex Schendel * 2484ef82a15SAlex Schendel * See header file for more information 2494ef82a15SAlex Schendel * @endinternal 2504ef82a15SAlex Schendel */ 2514ef82a15SAlex Schendel nlohmann::json actionParameterValueNotInList(std::string_view arg1, 2524ef82a15SAlex Schendel std::string_view arg2, 2534ef82a15SAlex Schendel std::string_view arg3) 2544ef82a15SAlex Schendel { 2554ef82a15SAlex Schendel return getLog( 2564ef82a15SAlex Schendel redfish::registries::base::Index::actionParameterValueNotInList, 2574ef82a15SAlex Schendel std::to_array({arg1, arg2, arg3})); 2584ef82a15SAlex Schendel } 2594ef82a15SAlex Schendel 2604ef82a15SAlex Schendel void actionParameterValueNotInList(crow::Response& res, std::string_view arg1, 2614ef82a15SAlex Schendel std::string_view arg2, std::string_view arg3) 2624ef82a15SAlex Schendel { 2634ef82a15SAlex Schendel res.result(boost::beast::http::status::bad_request); 2644ef82a15SAlex Schendel addMessageToErrorJson(res.jsonValue, 2654ef82a15SAlex Schendel actionParameterValueNotInList(arg1, arg2, arg3)); 2664ef82a15SAlex Schendel } 2674ef82a15SAlex Schendel 2684ef82a15SAlex Schendel /** 2694ef82a15SAlex Schendel * @internal 270f4c4dcf4SKowalski, Kamil * @brief Formats InternalError message into JSON 271f4c4dcf4SKowalski, Kamil * 272f4c4dcf4SKowalski, Kamil * See header file for more information 273f4c4dcf4SKowalski, Kamil * @endinternal 274f4c4dcf4SKowalski, Kamil */ 275b5c07418SJames Feist nlohmann::json internalError(void) 2761abe55efSEd Tanous { 277fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::internalError, {}); 278b5c07418SJames Feist } 279b5c07418SJames Feist 280df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location) 281b5c07418SJames Feist { 282df5415fcSEd Tanous BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "(" 283df5415fcSEd Tanous << location.line() << ":" << location.column() << ") `" 284df5415fcSEd Tanous << location.function_name() << "`: "; 285b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 286b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, internalError()); 287f12894f8SJason M. Bills } 288f12894f8SJason M. Bills 289f12894f8SJason M. Bills /** 290f12894f8SJason M. Bills * @internal 291f4c4dcf4SKowalski, Kamil * @brief Formats UnrecognizedRequestBody message into JSON 292f4c4dcf4SKowalski, Kamil * 293f4c4dcf4SKowalski, Kamil * See header file for more information 294f4c4dcf4SKowalski, Kamil * @endinternal 295f4c4dcf4SKowalski, Kamil */ 296b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void) 2971abe55efSEd Tanous { 298fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::unrecognizedRequestBody, 299fffb8c1fSEd Tanous {}); 300b5c07418SJames Feist } 301b5c07418SJames Feist 302b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res) 303b5c07418SJames Feist { 304b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 305b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody()); 306f4c4dcf4SKowalski, Kamil } 307f4c4dcf4SKowalski, Kamil 308f4c4dcf4SKowalski, Kamil /** 309f4c4dcf4SKowalski, Kamil * @internal 310f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriUnauthorized message into JSON 311f4c4dcf4SKowalski, Kamil * 312f4c4dcf4SKowalski, Kamil * See header file for more information 313f4c4dcf4SKowalski, Kamil * @endinternal 314f4c4dcf4SKowalski, Kamil */ 315d9f466b3SEd Tanous nlohmann::json resourceAtUriUnauthorized(boost::urls::url_view arg1, 3161668ce6dSEd Tanous std::string_view arg2) 3171abe55efSEd Tanous { 318079360aeSEd Tanous return getLog(redfish::registries::base::Index::resourceAtUriUnauthorized, 319079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer(), arg2})); 320b5c07418SJames Feist } 321b5c07418SJames Feist 322d9f466b3SEd Tanous void resourceAtUriUnauthorized(crow::Response& res, boost::urls::url_view arg1, 3231668ce6dSEd Tanous std::string_view arg2) 324b5c07418SJames Feist { 325b5c07418SJames Feist res.result(boost::beast::http::status::unauthorized); 326b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2)); 327f4c4dcf4SKowalski, Kamil } 328f4c4dcf4SKowalski, Kamil 329f4c4dcf4SKowalski, Kamil /** 330f4c4dcf4SKowalski, Kamil * @internal 331f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterUnknown message into JSON 332f4c4dcf4SKowalski, Kamil * 333f4c4dcf4SKowalski, Kamil * See header file for more information 334f4c4dcf4SKowalski, Kamil * @endinternal 335f4c4dcf4SKowalski, Kamil */ 3361668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1, 3371668ce6dSEd Tanous std::string_view arg2) 338b5c07418SJames Feist { 339fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterUnknown, 3401668ce6dSEd Tanous std::to_array({arg1, arg2})); 341b5c07418SJames Feist } 342b5c07418SJames Feist 3431668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1, 3441668ce6dSEd Tanous std::string_view arg2) 3451abe55efSEd Tanous { 346f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 347b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2)); 348f4c4dcf4SKowalski, Kamil } 349f4c4dcf4SKowalski, Kamil 350f4c4dcf4SKowalski, Kamil /** 351f4c4dcf4SKowalski, Kamil * @internal 352f4c4dcf4SKowalski, Kamil * @brief Formats ResourceCannotBeDeleted message into JSON 353f4c4dcf4SKowalski, Kamil * 354f4c4dcf4SKowalski, Kamil * See header file for more information 355f4c4dcf4SKowalski, Kamil * @endinternal 356f4c4dcf4SKowalski, Kamil */ 357b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void) 3581abe55efSEd Tanous { 359fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceCannotBeDeleted, 360fffb8c1fSEd Tanous {}); 361b5c07418SJames Feist } 362b5c07418SJames Feist 363b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res) 364b5c07418SJames Feist { 36544c70412SEd Tanous res.result(boost::beast::http::status::method_not_allowed); 366b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted()); 367f4c4dcf4SKowalski, Kamil } 368f4c4dcf4SKowalski, Kamil 369f4c4dcf4SKowalski, Kamil /** 370f4c4dcf4SKowalski, Kamil * @internal 371f4c4dcf4SKowalski, Kamil * @brief Formats PropertyDuplicate message into JSON 372f4c4dcf4SKowalski, Kamil * 373f4c4dcf4SKowalski, Kamil * See header file for more information 374f4c4dcf4SKowalski, Kamil * @endinternal 375f4c4dcf4SKowalski, Kamil */ 3761668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1) 3771abe55efSEd Tanous { 378fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyDuplicate, 3791668ce6dSEd Tanous std::to_array({arg1})); 380b5c07418SJames Feist } 381b5c07418SJames Feist 3821668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1) 383b5c07418SJames Feist { 384b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 385b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1); 386f4c4dcf4SKowalski, Kamil } 387f4c4dcf4SKowalski, Kamil 388f4c4dcf4SKowalski, Kamil /** 389f4c4dcf4SKowalski, Kamil * @internal 390f4c4dcf4SKowalski, Kamil * @brief Formats ServiceTemporarilyUnavailable message into JSON 391f4c4dcf4SKowalski, Kamil * 392f4c4dcf4SKowalski, Kamil * See header file for more information 393f4c4dcf4SKowalski, Kamil * @endinternal 394f4c4dcf4SKowalski, Kamil */ 3951668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1) 3961abe55efSEd Tanous { 397b6cd31e1SEd Tanous return getLog( 398fffb8c1fSEd Tanous redfish::registries::base::Index::serviceTemporarilyUnavailable, 3991668ce6dSEd Tanous std::to_array({arg1})); 400b5c07418SJames Feist } 401b5c07418SJames Feist 4021668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1) 403b5c07418SJames Feist { 404d9f6c621SEd Tanous res.addHeader(boost::beast::http::field::retry_after, arg1); 405b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 406b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1)); 407f4c4dcf4SKowalski, Kamil } 408f4c4dcf4SKowalski, Kamil 409f4c4dcf4SKowalski, Kamil /** 410f4c4dcf4SKowalski, Kamil * @internal 411f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAlreadyExists message into JSON 412f4c4dcf4SKowalski, Kamil * 413f4c4dcf4SKowalski, Kamil * See header file for more information 414f4c4dcf4SKowalski, Kamil * @endinternal 415f4c4dcf4SKowalski, Kamil */ 4161668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1, 4171668ce6dSEd Tanous std::string_view arg2, 4181668ce6dSEd Tanous std::string_view arg3) 4191abe55efSEd Tanous { 420fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceAlreadyExists, 4211668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 422b5c07418SJames Feist } 423b5c07418SJames Feist 4241668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1, 4251668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 426b5c07418SJames Feist { 427b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 428b5c07418SJames Feist addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3), 429a08b46ccSJason M. Bills arg2); 430f4c4dcf4SKowalski, Kamil } 431f4c4dcf4SKowalski, Kamil 432f4c4dcf4SKowalski, Kamil /** 433f4c4dcf4SKowalski, Kamil * @internal 434f4c4dcf4SKowalski, Kamil * @brief Formats AccountForSessionNoLongerExists message into JSON 435f4c4dcf4SKowalski, Kamil * 436f4c4dcf4SKowalski, Kamil * See header file for more information 437f4c4dcf4SKowalski, Kamil * @endinternal 438f4c4dcf4SKowalski, Kamil */ 439b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void) 4401abe55efSEd Tanous { 441fffb8c1fSEd Tanous return getLog( 442fffb8c1fSEd Tanous redfish::registries::base::Index::accountForSessionNoLongerExists, {}); 443b5c07418SJames Feist } 444b5c07418SJames Feist 445b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res) 446b5c07418SJames Feist { 447b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 448b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists()); 449f4c4dcf4SKowalski, Kamil } 450f4c4dcf4SKowalski, Kamil 451f4c4dcf4SKowalski, Kamil /** 452f4c4dcf4SKowalski, Kamil * @internal 453f4c4dcf4SKowalski, Kamil * @brief Formats CreateFailedMissingReqProperties message into JSON 454f4c4dcf4SKowalski, Kamil * 455f4c4dcf4SKowalski, Kamil * See header file for more information 456f4c4dcf4SKowalski, Kamil * @endinternal 457f4c4dcf4SKowalski, Kamil */ 4581668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1) 4591abe55efSEd Tanous { 460fffb8c1fSEd Tanous return getLog( 461fffb8c1fSEd Tanous redfish::registries::base::Index::createFailedMissingReqProperties, 4621668ce6dSEd Tanous std::to_array({arg1})); 463b5c07418SJames Feist } 464b5c07418SJames Feist 465b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res, 4661668ce6dSEd Tanous std::string_view arg1) 467b5c07418SJames Feist { 468b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 469b5c07418SJames Feist addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1), 470a08b46ccSJason M. Bills arg1); 471f12894f8SJason M. Bills } 472f12894f8SJason M. Bills 473f12894f8SJason M. Bills /** 474f12894f8SJason M. Bills * @internal 475f12894f8SJason M. Bills * @brief Formats PropertyValueFormatError message into JSON for the specified 476f12894f8SJason M. Bills * property 477f12894f8SJason M. Bills * 478f12894f8SJason M. Bills * See header file for more information 479f12894f8SJason M. Bills * @endinternal 480f12894f8SJason M. Bills */ 481f818b04dSEd Tanous nlohmann::json propertyValueFormatError(const nlohmann::json& arg1, 4821668ce6dSEd Tanous std::string_view arg2) 483f12894f8SJason M. Bills { 484f818b04dSEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 485f818b04dSEd Tanous nlohmann::json::error_handler_t::replace); 486fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueFormatError, 487f818b04dSEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 488b5c07418SJames Feist } 489b5c07418SJames Feist 490f818b04dSEd Tanous void propertyValueFormatError(crow::Response& res, const nlohmann::json& arg1, 4911668ce6dSEd Tanous std::string_view arg2) 492b5c07418SJames Feist { 493b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 494b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2); 495f12894f8SJason M. Bills } 496f12894f8SJason M. Bills 497f12894f8SJason M. Bills /** 498f12894f8SJason M. Bills * @internal 499f12894f8SJason M. Bills * @brief Formats PropertyValueNotInList message into JSON for the specified 500f12894f8SJason M. Bills * property 501f12894f8SJason M. Bills * 502f12894f8SJason M. Bills * See header file for more information 503f12894f8SJason M. Bills * @endinternal 504f12894f8SJason M. Bills */ 505e2616cc5SEd Tanous 506e2616cc5SEd Tanous nlohmann::json propertyValueNotInList(const nlohmann::json& arg1, 5071668ce6dSEd Tanous std::string_view arg2) 508f12894f8SJason M. Bills { 509e2616cc5SEd Tanous std::string arg1Str = arg1.dump(-1, ' ', true, 510e2616cc5SEd Tanous nlohmann::json::error_handler_t::replace); 511fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueNotInList, 512e2616cc5SEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 513b5c07418SJames Feist } 514b5c07418SJames Feist 515e2616cc5SEd Tanous void propertyValueNotInList(crow::Response& res, const nlohmann::json& arg1, 5161668ce6dSEd Tanous std::string_view arg2) 517b5c07418SJames Feist { 518b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 519b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2); 520f4c4dcf4SKowalski, Kamil } 521f4c4dcf4SKowalski, Kamil 522f4c4dcf4SKowalski, Kamil /** 523f4c4dcf4SKowalski, Kamil * @internal 524227a2b0aSJiaqing Zhao * @brief Formats PropertyValueOutOfRange message into JSON 525227a2b0aSJiaqing Zhao * 526227a2b0aSJiaqing Zhao * See header file for more information 527227a2b0aSJiaqing Zhao * @endinternal 528227a2b0aSJiaqing Zhao */ 529227a2b0aSJiaqing Zhao nlohmann::json propertyValueOutOfRange(std::string_view arg1, 530227a2b0aSJiaqing Zhao std::string_view arg2) 531227a2b0aSJiaqing Zhao { 532227a2b0aSJiaqing Zhao return getLog(redfish::registries::base::Index::propertyValueOutOfRange, 533227a2b0aSJiaqing Zhao std::to_array({arg1, arg2})); 534227a2b0aSJiaqing Zhao } 535227a2b0aSJiaqing Zhao 536227a2b0aSJiaqing Zhao void propertyValueOutOfRange(crow::Response& res, std::string_view arg1, 537227a2b0aSJiaqing Zhao std::string_view arg2) 538227a2b0aSJiaqing Zhao { 539227a2b0aSJiaqing Zhao res.result(boost::beast::http::status::bad_request); 540227a2b0aSJiaqing Zhao addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2)); 541227a2b0aSJiaqing Zhao } 542227a2b0aSJiaqing Zhao 543227a2b0aSJiaqing Zhao /** 544227a2b0aSJiaqing Zhao * @internal 545f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriInUnknownFormat message into JSON 546f4c4dcf4SKowalski, Kamil * 547f4c4dcf4SKowalski, Kamil * See header file for more information 548f4c4dcf4SKowalski, Kamil * @endinternal 549f4c4dcf4SKowalski, Kamil */ 550d9f466b3SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(boost::urls::url_view arg1) 5511abe55efSEd Tanous { 552b6cd31e1SEd Tanous return getLog( 553fffb8c1fSEd Tanous redfish::registries::base::Index::resourceAtUriInUnknownFormat, 554079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 555b5c07418SJames Feist } 556b5c07418SJames Feist 557ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res, 558d9f466b3SEd Tanous boost::urls::url_view arg1) 559b5c07418SJames Feist { 560b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 561b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1)); 562f4c4dcf4SKowalski, Kamil } 563f4c4dcf4SKowalski, Kamil 564f4c4dcf4SKowalski, Kamil /** 565f4c4dcf4SKowalski, Kamil * @internal 56681856681SAsmitha Karunanithi * @brief Formats ServiceDisabled message into JSON 56781856681SAsmitha Karunanithi * 56881856681SAsmitha Karunanithi * See header file for more information 56981856681SAsmitha Karunanithi * @endinternal 57081856681SAsmitha Karunanithi */ 5711668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1) 57281856681SAsmitha Karunanithi { 573fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceDisabled, 5741668ce6dSEd Tanous std::to_array({arg1})); 57581856681SAsmitha Karunanithi } 57681856681SAsmitha Karunanithi 5771668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1) 57881856681SAsmitha Karunanithi { 57981856681SAsmitha Karunanithi res.result(boost::beast::http::status::service_unavailable); 58081856681SAsmitha Karunanithi addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1)); 58181856681SAsmitha Karunanithi } 58281856681SAsmitha Karunanithi 58381856681SAsmitha Karunanithi /** 58481856681SAsmitha Karunanithi * @internal 585f4c4dcf4SKowalski, Kamil * @brief Formats ServiceInUnknownState message into JSON 586f4c4dcf4SKowalski, Kamil * 587f4c4dcf4SKowalski, Kamil * See header file for more information 588f4c4dcf4SKowalski, Kamil * @endinternal 589f4c4dcf4SKowalski, Kamil */ 590b5c07418SJames Feist nlohmann::json serviceInUnknownState(void) 5911abe55efSEd Tanous { 592fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceInUnknownState, {}); 593b5c07418SJames Feist } 594b5c07418SJames Feist 595b5c07418SJames Feist void serviceInUnknownState(crow::Response& res) 596b5c07418SJames Feist { 597b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 598b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceInUnknownState()); 599f4c4dcf4SKowalski, Kamil } 600f4c4dcf4SKowalski, Kamil 601f4c4dcf4SKowalski, Kamil /** 602f4c4dcf4SKowalski, Kamil * @internal 603f4c4dcf4SKowalski, Kamil * @brief Formats EventSubscriptionLimitExceeded message into JSON 604f4c4dcf4SKowalski, Kamil * 605f4c4dcf4SKowalski, Kamil * See header file for more information 606f4c4dcf4SKowalski, Kamil * @endinternal 607f4c4dcf4SKowalski, Kamil */ 608b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void) 6091abe55efSEd Tanous { 610fffb8c1fSEd Tanous return getLog( 611fffb8c1fSEd Tanous redfish::registries::base::Index::eventSubscriptionLimitExceeded, {}); 612b5c07418SJames Feist } 613b5c07418SJames Feist 614b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res) 615b5c07418SJames Feist { 616789fdab3SEd Tanous res.result(boost::beast::http::status::service_unavailable); 617b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded()); 618f4c4dcf4SKowalski, Kamil } 619f4c4dcf4SKowalski, Kamil 620f4c4dcf4SKowalski, Kamil /** 621f4c4dcf4SKowalski, Kamil * @internal 622f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterMissing message into JSON 623f4c4dcf4SKowalski, Kamil * 624f4c4dcf4SKowalski, Kamil * See header file for more information 625f4c4dcf4SKowalski, Kamil * @endinternal 626f4c4dcf4SKowalski, Kamil */ 6271668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1, 6281668ce6dSEd Tanous std::string_view arg2) 6291abe55efSEd Tanous { 630fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterMissing, 6311668ce6dSEd Tanous std::to_array({arg1, arg2})); 632b5c07418SJames Feist } 633b5c07418SJames Feist 6341668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1, 6351668ce6dSEd Tanous std::string_view arg2) 636b5c07418SJames Feist { 637b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 638b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2)); 639f4c4dcf4SKowalski, Kamil } 640f4c4dcf4SKowalski, Kamil 641f4c4dcf4SKowalski, Kamil /** 642f4c4dcf4SKowalski, Kamil * @internal 643f4c4dcf4SKowalski, Kamil * @brief Formats StringValueTooLong message into JSON 644f4c4dcf4SKowalski, Kamil * 645f4c4dcf4SKowalski, Kamil * See header file for more information 646f4c4dcf4SKowalski, Kamil * @endinternal 647f4c4dcf4SKowalski, Kamil */ 6481668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2) 6491abe55efSEd Tanous { 650b6cd31e1SEd Tanous std::string arg2String = std::to_string(arg2); 651fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::stringValueTooLong, 6521668ce6dSEd Tanous std::to_array({arg1, std::string_view(arg2String)})); 653b5c07418SJames Feist } 654b5c07418SJames Feist 6551668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2) 656b5c07418SJames Feist { 657b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 658b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2)); 659f4c4dcf4SKowalski, Kamil } 660f4c4dcf4SKowalski, Kamil 661f4c4dcf4SKowalski, Kamil /** 662f4c4dcf4SKowalski, Kamil * @internal 663cc9139ecSJason M. Bills * @brief Formats SessionTerminated message into JSON 664cc9139ecSJason M. Bills * 665cc9139ecSJason M. Bills * See header file for more information 666cc9139ecSJason M. Bills * @endinternal 667cc9139ecSJason M. Bills */ 668b5c07418SJames Feist nlohmann::json sessionTerminated(void) 669cc9139ecSJason M. Bills { 670fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::sessionTerminated, {}); 671b5c07418SJames Feist } 672b5c07418SJames Feist 673b5c07418SJames Feist void sessionTerminated(crow::Response& res) 674b5c07418SJames Feist { 675b5c07418SJames Feist res.result(boost::beast::http::status::ok); 676b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, sessionTerminated()); 677cc9139ecSJason M. Bills } 678cc9139ecSJason M. Bills 679cc9139ecSJason M. Bills /** 680cc9139ecSJason M. Bills * @internal 681684bb4b8SJason M. Bills * @brief Formats SubscriptionTerminated message into JSON 682684bb4b8SJason M. Bills * 683684bb4b8SJason M. Bills * See header file for more information 684684bb4b8SJason M. Bills * @endinternal 685684bb4b8SJason M. Bills */ 686684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void) 687684bb4b8SJason M. Bills { 688fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::subscriptionTerminated, {}); 689684bb4b8SJason M. Bills } 690684bb4b8SJason M. Bills 691684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res) 692684bb4b8SJason M. Bills { 693684bb4b8SJason M. Bills res.result(boost::beast::http::status::ok); 694684bb4b8SJason M. Bills addMessageToJsonRoot(res.jsonValue, subscriptionTerminated()); 695684bb4b8SJason M. Bills } 696684bb4b8SJason M. Bills 697684bb4b8SJason M. Bills /** 698684bb4b8SJason M. Bills * @internal 699cc9139ecSJason M. Bills * @brief Formats ResourceTypeIncompatible message into JSON 700cc9139ecSJason M. Bills * 701cc9139ecSJason M. Bills * See header file for more information 702cc9139ecSJason M. Bills * @endinternal 703cc9139ecSJason M. Bills */ 7041668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1, 7051668ce6dSEd Tanous std::string_view arg2) 706cc9139ecSJason M. Bills { 707fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceTypeIncompatible, 7081668ce6dSEd Tanous std::to_array({arg1, arg2})); 709b5c07418SJames Feist } 710b5c07418SJames Feist 7111668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1, 7121668ce6dSEd Tanous std::string_view arg2) 713b5c07418SJames Feist { 714b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 715b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2)); 716cc9139ecSJason M. Bills } 717cc9139ecSJason M. Bills 718cc9139ecSJason M. Bills /** 719cc9139ecSJason M. Bills * @internal 720684bb4b8SJason M. Bills * @brief Formats ResetRequired message into JSON 721684bb4b8SJason M. Bills * 722684bb4b8SJason M. Bills * See header file for more information 723684bb4b8SJason M. Bills * @endinternal 724684bb4b8SJason M. Bills */ 725d9f466b3SEd Tanous nlohmann::json resetRequired(boost::urls::url_view arg1, std::string_view arg2) 726684bb4b8SJason M. Bills { 727fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resetRequired, 728079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer(), arg2})); 729684bb4b8SJason M. Bills } 730684bb4b8SJason M. Bills 731d9f466b3SEd Tanous void resetRequired(crow::Response& res, boost::urls::url_view arg1, 7321668ce6dSEd Tanous std::string_view arg2) 733684bb4b8SJason M. Bills { 734684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 735684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2)); 736684bb4b8SJason M. Bills } 737684bb4b8SJason M. Bills 738684bb4b8SJason M. Bills /** 739684bb4b8SJason M. Bills * @internal 740684bb4b8SJason M. Bills * @brief Formats ChassisPowerStateOnRequired message into JSON 741684bb4b8SJason M. Bills * 742684bb4b8SJason M. Bills * See header file for more information 743684bb4b8SJason M. Bills * @endinternal 744684bb4b8SJason M. Bills */ 7451668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1) 746684bb4b8SJason M. Bills { 747fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resetRequired, 7481668ce6dSEd Tanous std::to_array({arg1})); 749684bb4b8SJason M. Bills } 750684bb4b8SJason M. Bills 7511668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1) 752684bb4b8SJason M. Bills { 753684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 754684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1)); 755684bb4b8SJason M. Bills } 756684bb4b8SJason M. Bills 757684bb4b8SJason M. Bills /** 758684bb4b8SJason M. Bills * @internal 759684bb4b8SJason M. Bills * @brief Formats ChassisPowerStateOffRequired message into JSON 760684bb4b8SJason M. Bills * 761684bb4b8SJason M. Bills * See header file for more information 762684bb4b8SJason M. Bills * @endinternal 763684bb4b8SJason M. Bills */ 7641668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1) 765684bb4b8SJason M. Bills { 766b6cd31e1SEd Tanous return getLog( 767fffb8c1fSEd Tanous redfish::registries::base::Index::chassisPowerStateOffRequired, 7681668ce6dSEd Tanous std::to_array({arg1})); 769684bb4b8SJason M. Bills } 770684bb4b8SJason M. Bills 7711668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1) 772684bb4b8SJason M. Bills { 773684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 774684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1)); 775684bb4b8SJason M. Bills } 776684bb4b8SJason M. Bills 777684bb4b8SJason M. Bills /** 778684bb4b8SJason M. Bills * @internal 779684bb4b8SJason M. Bills * @brief Formats PropertyValueConflict message into JSON 780684bb4b8SJason M. Bills * 781684bb4b8SJason M. Bills * See header file for more information 782684bb4b8SJason M. Bills * @endinternal 783684bb4b8SJason M. Bills */ 7841668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1, 7851668ce6dSEd Tanous std::string_view arg2) 786684bb4b8SJason M. Bills { 787fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueConflict, 7881668ce6dSEd Tanous std::to_array({arg1, arg2})); 789684bb4b8SJason M. Bills } 790684bb4b8SJason M. Bills 7911668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1, 7921668ce6dSEd Tanous std::string_view arg2) 793684bb4b8SJason M. Bills { 794684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 795684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2)); 796684bb4b8SJason M. Bills } 797684bb4b8SJason M. Bills 798684bb4b8SJason M. Bills /** 799684bb4b8SJason M. Bills * @internal 8002a6af81cSRamesh Iyyar * @brief Formats PropertyValueResourceConflict message into JSON 8012a6af81cSRamesh Iyyar * 8022a6af81cSRamesh Iyyar * See header file for more information 8032a6af81cSRamesh Iyyar * @endinternal 8042a6af81cSRamesh Iyyar */ 8052a6af81cSRamesh Iyyar nlohmann::json propertyValueResourceConflict(std::string_view arg1, 8062a6af81cSRamesh Iyyar std::string_view arg2, 807d9f466b3SEd Tanous boost::urls::url_view arg3) 8082a6af81cSRamesh Iyyar { 8092a6af81cSRamesh Iyyar return getLog( 8102a6af81cSRamesh Iyyar redfish::registries::base::Index::propertyValueResourceConflict, 811079360aeSEd Tanous std::to_array<std::string_view>({arg1, arg2, arg3.buffer()})); 8122a6af81cSRamesh Iyyar } 8132a6af81cSRamesh Iyyar 8142a6af81cSRamesh Iyyar void propertyValueResourceConflict(crow::Response& res, std::string_view arg1, 8152a6af81cSRamesh Iyyar std::string_view arg2, 816d9f466b3SEd Tanous boost::urls::url_view arg3) 8172a6af81cSRamesh Iyyar { 8182a6af81cSRamesh Iyyar res.result(boost::beast::http::status::conflict); 8192a6af81cSRamesh Iyyar addMessageToErrorJson(res.jsonValue, 8202a6af81cSRamesh Iyyar propertyValueResourceConflict(arg1, arg2, arg3)); 8212a6af81cSRamesh Iyyar } 8222a6af81cSRamesh Iyyar 8232a6af81cSRamesh Iyyar /** 8242a6af81cSRamesh Iyyar * @internal 82524861a28SRamesh Iyyar * @brief Formats PropertyValueExternalConflict message into JSON 82624861a28SRamesh Iyyar * 82724861a28SRamesh Iyyar * See header file for more information 82824861a28SRamesh Iyyar * @endinternal 82924861a28SRamesh Iyyar */ 83024861a28SRamesh Iyyar nlohmann::json propertyValueExternalConflict(std::string_view arg1, 83124861a28SRamesh Iyyar std::string_view arg2) 83224861a28SRamesh Iyyar { 83324861a28SRamesh Iyyar return getLog( 83424861a28SRamesh Iyyar redfish::registries::base::Index::propertyValueExternalConflict, 83524861a28SRamesh Iyyar std::to_array({arg1, arg2})); 83624861a28SRamesh Iyyar } 83724861a28SRamesh Iyyar 83824861a28SRamesh Iyyar void propertyValueExternalConflict(crow::Response& res, std::string_view arg1, 83924861a28SRamesh Iyyar std::string_view arg2) 84024861a28SRamesh Iyyar { 84124861a28SRamesh Iyyar res.result(boost::beast::http::status::conflict); 84224861a28SRamesh Iyyar addMessageToErrorJson(res.jsonValue, 84324861a28SRamesh Iyyar propertyValueExternalConflict(arg1, arg2)); 84424861a28SRamesh Iyyar } 84524861a28SRamesh Iyyar 84624861a28SRamesh Iyyar /** 84724861a28SRamesh Iyyar * @internal 848684bb4b8SJason M. Bills * @brief Formats PropertyValueIncorrect message into JSON 849684bb4b8SJason M. Bills * 850684bb4b8SJason M. Bills * See header file for more information 851684bb4b8SJason M. Bills * @endinternal 852684bb4b8SJason M. Bills */ 853*14fbced6SEd Tanous nlohmann::json propertyValueIncorrect(const nlohmann::json& arg1, 8541668ce6dSEd Tanous std::string_view arg2) 855684bb4b8SJason M. Bills { 856*14fbced6SEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 857*14fbced6SEd Tanous nlohmann::json::error_handler_t::replace); 858fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueIncorrect, 859*14fbced6SEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 860684bb4b8SJason M. Bills } 861684bb4b8SJason M. Bills 862*14fbced6SEd Tanous void propertyValueIncorrect(crow::Response& res, const nlohmann::json& arg1, 8631668ce6dSEd Tanous std::string_view arg2) 864684bb4b8SJason M. Bills { 865684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 866684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2)); 867684bb4b8SJason M. Bills } 868684bb4b8SJason M. Bills 869684bb4b8SJason M. Bills /** 870684bb4b8SJason M. Bills * @internal 871684bb4b8SJason M. Bills * @brief Formats ResourceCreationConflict message into JSON 872684bb4b8SJason M. Bills * 873684bb4b8SJason M. Bills * See header file for more information 874684bb4b8SJason M. Bills * @endinternal 875684bb4b8SJason M. Bills */ 876d9f466b3SEd Tanous nlohmann::json resourceCreationConflict(boost::urls::url_view arg1) 877684bb4b8SJason M. Bills { 878fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceCreationConflict, 879079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 880684bb4b8SJason M. Bills } 881684bb4b8SJason M. Bills 882d9f466b3SEd Tanous void resourceCreationConflict(crow::Response& res, boost::urls::url_view arg1) 883684bb4b8SJason M. Bills { 884684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 885684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1)); 886684bb4b8SJason M. Bills } 887684bb4b8SJason M. Bills 888684bb4b8SJason M. Bills /** 889684bb4b8SJason M. Bills * @internal 890684bb4b8SJason M. Bills * @brief Formats MaximumErrorsExceeded message into JSON 891684bb4b8SJason M. Bills * 892684bb4b8SJason M. Bills * See header file for more information 893684bb4b8SJason M. Bills * @endinternal 894684bb4b8SJason M. Bills */ 895684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void) 896684bb4b8SJason M. Bills { 897fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {}); 898684bb4b8SJason M. Bills } 899684bb4b8SJason M. Bills 900684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res) 901684bb4b8SJason M. Bills { 902684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 903684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded()); 904684bb4b8SJason M. Bills } 905684bb4b8SJason M. Bills 906684bb4b8SJason M. Bills /** 907684bb4b8SJason M. Bills * @internal 908684bb4b8SJason M. Bills * @brief Formats PreconditionFailed message into JSON 909684bb4b8SJason M. Bills * 910684bb4b8SJason M. Bills * See header file for more information 911684bb4b8SJason M. Bills * @endinternal 912684bb4b8SJason M. Bills */ 913684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void) 914684bb4b8SJason M. Bills { 915fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::preconditionFailed, {}); 916684bb4b8SJason M. Bills } 917684bb4b8SJason M. Bills 918684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res) 919684bb4b8SJason M. Bills { 9204df1bee0SEd Tanous res.result(boost::beast::http::status::precondition_failed); 921684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, preconditionFailed()); 922684bb4b8SJason M. Bills } 923684bb4b8SJason M. Bills 924684bb4b8SJason M. Bills /** 925684bb4b8SJason M. Bills * @internal 926684bb4b8SJason M. Bills * @brief Formats PreconditionRequired message into JSON 927684bb4b8SJason M. Bills * 928684bb4b8SJason M. Bills * See header file for more information 929684bb4b8SJason M. Bills * @endinternal 930684bb4b8SJason M. Bills */ 931684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void) 932684bb4b8SJason M. Bills { 933fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::preconditionRequired, {}); 934684bb4b8SJason M. Bills } 935684bb4b8SJason M. Bills 936684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res) 937684bb4b8SJason M. Bills { 938684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 939684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, preconditionRequired()); 940684bb4b8SJason M. Bills } 941684bb4b8SJason M. Bills 942684bb4b8SJason M. Bills /** 943684bb4b8SJason M. Bills * @internal 944684bb4b8SJason M. Bills * @brief Formats OperationFailed message into JSON 945684bb4b8SJason M. Bills * 946684bb4b8SJason M. Bills * See header file for more information 947684bb4b8SJason M. Bills * @endinternal 948684bb4b8SJason M. Bills */ 949684bb4b8SJason M. Bills nlohmann::json operationFailed(void) 950684bb4b8SJason M. Bills { 951fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::operationFailed, {}); 952684bb4b8SJason M. Bills } 953684bb4b8SJason M. Bills 954684bb4b8SJason M. Bills void operationFailed(crow::Response& res) 955684bb4b8SJason M. Bills { 9568868776eSEd Tanous res.result(boost::beast::http::status::bad_gateway); 957684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, operationFailed()); 958684bb4b8SJason M. Bills } 959684bb4b8SJason M. Bills 960684bb4b8SJason M. Bills /** 961684bb4b8SJason M. Bills * @internal 962684bb4b8SJason M. Bills * @brief Formats OperationTimeout message into JSON 963684bb4b8SJason M. Bills * 964684bb4b8SJason M. Bills * See header file for more information 965684bb4b8SJason M. Bills * @endinternal 966684bb4b8SJason M. Bills */ 967684bb4b8SJason M. Bills nlohmann::json operationTimeout(void) 968684bb4b8SJason M. Bills { 969fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::operationTimeout, {}); 970684bb4b8SJason M. Bills } 971684bb4b8SJason M. Bills 972684bb4b8SJason M. Bills void operationTimeout(crow::Response& res) 973684bb4b8SJason M. Bills { 974684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 975684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, operationTimeout()); 976684bb4b8SJason M. Bills } 977684bb4b8SJason M. Bills 978684bb4b8SJason M. Bills /** 979684bb4b8SJason M. Bills * @internal 980f12894f8SJason M. Bills * @brief Formats PropertyValueTypeError message into JSON for the specified 981f12894f8SJason M. Bills * property 982f12894f8SJason M. Bills * 983f12894f8SJason M. Bills * See header file for more information 984f12894f8SJason M. Bills * @endinternal 985f12894f8SJason M. Bills */ 9862e8c4bdaSEd Tanous nlohmann::json propertyValueTypeError(const nlohmann::json& arg1, 9871668ce6dSEd Tanous std::string_view arg2) 988f12894f8SJason M. Bills { 9892e8c4bdaSEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 9902e8c4bdaSEd Tanous nlohmann::json::error_handler_t::replace); 991fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueTypeError, 9922e8c4bdaSEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 993b5c07418SJames Feist } 994b5c07418SJames Feist 9952e8c4bdaSEd Tanous void propertyValueTypeError(crow::Response& res, const nlohmann::json& arg1, 9961668ce6dSEd Tanous std::string_view arg2) 997b5c07418SJames Feist { 998b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 999b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2); 1000f4c4dcf4SKowalski, Kamil } 1001f4c4dcf4SKowalski, Kamil 1002f4c4dcf4SKowalski, Kamil /** 1003f4c4dcf4SKowalski, Kamil * @internal 1004b6cd31e1SEd Tanous * @brief Formats ResourceNotFound message into JSONd 1005f4c4dcf4SKowalski, Kamil * 1006f4c4dcf4SKowalski, Kamil * See header file for more information 1007f4c4dcf4SKowalski, Kamil * @endinternal 1008f4c4dcf4SKowalski, Kamil */ 10091668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2) 10101abe55efSEd Tanous { 1011fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceNotFound, 10121668ce6dSEd Tanous std::to_array({arg1, arg2})); 1013b5c07418SJames Feist } 1014b5c07418SJames Feist 10151668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1, 10161668ce6dSEd Tanous std::string_view arg2) 1017b5c07418SJames Feist { 1018b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 1019b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2)); 1020f4c4dcf4SKowalski, Kamil } 1021f4c4dcf4SKowalski, Kamil 1022f4c4dcf4SKowalski, Kamil /** 1023f4c4dcf4SKowalski, Kamil * @internal 1024f4c4dcf4SKowalski, Kamil * @brief Formats CouldNotEstablishConnection message into JSON 1025f4c4dcf4SKowalski, Kamil * 1026f4c4dcf4SKowalski, Kamil * See header file for more information 1027f4c4dcf4SKowalski, Kamil * @endinternal 1028f4c4dcf4SKowalski, Kamil */ 1029d9f466b3SEd Tanous nlohmann::json couldNotEstablishConnection(boost::urls::url_view arg1) 10301abe55efSEd Tanous { 1031fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::couldNotEstablishConnection, 1032079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1033b5c07418SJames Feist } 1034b5c07418SJames Feist 1035ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res, 1036d9f466b3SEd Tanous boost::urls::url_view arg1) 1037b5c07418SJames Feist { 1038b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 1039b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1)); 1040f4c4dcf4SKowalski, Kamil } 1041f4c4dcf4SKowalski, Kamil 1042f4c4dcf4SKowalski, Kamil /** 1043f4c4dcf4SKowalski, Kamil * @internal 1044f12894f8SJason M. Bills * @brief Formats PropertyNotWritable message into JSON for the specified 1045f12894f8SJason M. Bills * property 1046f12894f8SJason M. Bills * 1047f12894f8SJason M. Bills * See header file for more information 1048f12894f8SJason M. Bills * @endinternal 1049f12894f8SJason M. Bills */ 10501668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1) 1051f12894f8SJason M. Bills { 1052fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyNotWritable, 10531668ce6dSEd Tanous std::to_array({arg1})); 1054b5c07418SJames Feist } 1055b5c07418SJames Feist 10561668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1) 1057b5c07418SJames Feist { 1058b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1059b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1); 1060f4c4dcf4SKowalski, Kamil } 1061f4c4dcf4SKowalski, Kamil 1062f4c4dcf4SKowalski, Kamil /** 1063f4c4dcf4SKowalski, Kamil * @internal 1064f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueTypeError message into JSON 1065f4c4dcf4SKowalski, Kamil * 1066f4c4dcf4SKowalski, Kamil * See header file for more information 1067f4c4dcf4SKowalski, Kamil * @endinternal 1068f4c4dcf4SKowalski, Kamil */ 10691668ce6dSEd Tanous nlohmann::json queryParameterValueTypeError(std::string_view arg1, 10701668ce6dSEd Tanous std::string_view arg2) 10711abe55efSEd Tanous { 1072b6cd31e1SEd Tanous return getLog( 1073fffb8c1fSEd Tanous redfish::registries::base::Index::queryParameterValueTypeError, 10741668ce6dSEd Tanous std::to_array({arg1, arg2})); 1075b5c07418SJames Feist } 1076b5c07418SJames Feist 10771668ce6dSEd Tanous void queryParameterValueTypeError(crow::Response& res, std::string_view arg1, 10781668ce6dSEd Tanous std::string_view arg2) 1079b5c07418SJames Feist { 1080b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1081b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1082b5c07418SJames Feist queryParameterValueTypeError(arg1, arg2)); 1083f4c4dcf4SKowalski, Kamil } 1084f4c4dcf4SKowalski, Kamil 1085f4c4dcf4SKowalski, Kamil /** 1086f4c4dcf4SKowalski, Kamil * @internal 1087f4c4dcf4SKowalski, Kamil * @brief Formats ServiceShuttingDown message into JSON 1088f4c4dcf4SKowalski, Kamil * 1089f4c4dcf4SKowalski, Kamil * See header file for more information 1090f4c4dcf4SKowalski, Kamil * @endinternal 1091f4c4dcf4SKowalski, Kamil */ 1092b5c07418SJames Feist nlohmann::json serviceShuttingDown(void) 10931abe55efSEd Tanous { 1094fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceShuttingDown, {}); 1095b5c07418SJames Feist } 1096b5c07418SJames Feist 1097b5c07418SJames Feist void serviceShuttingDown(crow::Response& res) 1098b5c07418SJames Feist { 1099b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1100b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceShuttingDown()); 1101f4c4dcf4SKowalski, Kamil } 1102f4c4dcf4SKowalski, Kamil 1103f4c4dcf4SKowalski, Kamil /** 1104f4c4dcf4SKowalski, Kamil * @internal 1105f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterDuplicate message into JSON 1106f4c4dcf4SKowalski, Kamil * 1107f4c4dcf4SKowalski, Kamil * See header file for more information 1108f4c4dcf4SKowalski, Kamil * @endinternal 1109f4c4dcf4SKowalski, Kamil */ 11101668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1, 11111668ce6dSEd Tanous std::string_view arg2) 11121abe55efSEd Tanous { 1113fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterDuplicate, 11141668ce6dSEd Tanous std::to_array({arg1, arg2})); 1115b5c07418SJames Feist } 1116b5c07418SJames Feist 11171668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1, 11181668ce6dSEd Tanous std::string_view arg2) 1119b5c07418SJames Feist { 1120b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1121b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2)); 1122f4c4dcf4SKowalski, Kamil } 1123f4c4dcf4SKowalski, Kamil 1124f4c4dcf4SKowalski, Kamil /** 1125f4c4dcf4SKowalski, Kamil * @internal 1126f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterNotSupported message into JSON 1127f4c4dcf4SKowalski, Kamil * 1128f4c4dcf4SKowalski, Kamil * See header file for more information 1129f4c4dcf4SKowalski, Kamil * @endinternal 1130f4c4dcf4SKowalski, Kamil */ 11311668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1, 11321668ce6dSEd Tanous std::string_view arg2) 11331abe55efSEd Tanous { 1134fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterNotSupported, 11351668ce6dSEd Tanous std::to_array({arg1, arg2})); 1136b5c07418SJames Feist } 1137b5c07418SJames Feist 11381668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1, 11391668ce6dSEd Tanous std::string_view arg2) 1140b5c07418SJames Feist { 1141b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1142b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1143b5c07418SJames Feist actionParameterNotSupported(arg1, arg2)); 1144f4c4dcf4SKowalski, Kamil } 1145f4c4dcf4SKowalski, Kamil 1146f4c4dcf4SKowalski, Kamil /** 1147f4c4dcf4SKowalski, Kamil * @internal 1148f4c4dcf4SKowalski, Kamil * @brief Formats SourceDoesNotSupportProtocol message into JSON 1149f4c4dcf4SKowalski, Kamil * 1150f4c4dcf4SKowalski, Kamil * See header file for more information 1151f4c4dcf4SKowalski, Kamil * @endinternal 1152f4c4dcf4SKowalski, Kamil */ 1153d9f466b3SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1, 11541668ce6dSEd Tanous std::string_view arg2) 11551abe55efSEd Tanous { 1156b6cd31e1SEd Tanous return getLog( 1157fffb8c1fSEd Tanous redfish::registries::base::Index::sourceDoesNotSupportProtocol, 1158079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer(), arg2})); 1159b5c07418SJames Feist } 1160b5c07418SJames Feist 1161ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res, 1162d9f466b3SEd Tanous boost::urls::url_view arg1, 11631668ce6dSEd Tanous std::string_view arg2) 1164b5c07418SJames Feist { 1165b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1166b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1167b5c07418SJames Feist sourceDoesNotSupportProtocol(arg1, arg2)); 1168f4c4dcf4SKowalski, Kamil } 1169f4c4dcf4SKowalski, Kamil 1170f4c4dcf4SKowalski, Kamil /** 1171f4c4dcf4SKowalski, Kamil * @internal 1172b4ad4c05SShantappa Teekappanavar * @brief Formats StrictAccountTypes message into JSON 1173b4ad4c05SShantappa Teekappanavar * 1174b4ad4c05SShantappa Teekappanavar * See header file for more information 1175b4ad4c05SShantappa Teekappanavar * @endinternal 1176b4ad4c05SShantappa Teekappanavar */ 1177b4ad4c05SShantappa Teekappanavar nlohmann::json strictAccountTypes(std::string_view arg1) 1178b4ad4c05SShantappa Teekappanavar { 1179b4ad4c05SShantappa Teekappanavar return getLog(redfish::registries::base::Index::strictAccountTypes, 1180b4ad4c05SShantappa Teekappanavar std::to_array({arg1})); 1181b4ad4c05SShantappa Teekappanavar } 1182b4ad4c05SShantappa Teekappanavar 1183b4ad4c05SShantappa Teekappanavar void strictAccountTypes(crow::Response& res, std::string_view arg1) 1184b4ad4c05SShantappa Teekappanavar { 1185b4ad4c05SShantappa Teekappanavar res.result(boost::beast::http::status::bad_request); 1186b4ad4c05SShantappa Teekappanavar addMessageToErrorJson(res.jsonValue, strictAccountTypes(arg1)); 1187b4ad4c05SShantappa Teekappanavar } 1188b4ad4c05SShantappa Teekappanavar 1189b4ad4c05SShantappa Teekappanavar /** 1190b4ad4c05SShantappa Teekappanavar * @internal 1191f4c4dcf4SKowalski, Kamil * @brief Formats AccountRemoved message into JSON 1192f4c4dcf4SKowalski, Kamil * 1193f4c4dcf4SKowalski, Kamil * See header file for more information 1194f4c4dcf4SKowalski, Kamil * @endinternal 1195f4c4dcf4SKowalski, Kamil */ 1196b5c07418SJames Feist nlohmann::json accountRemoved(void) 11971abe55efSEd Tanous { 1198fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountRemoved, {}); 1199b5c07418SJames Feist } 1200b5c07418SJames Feist 1201b5c07418SJames Feist void accountRemoved(crow::Response& res) 1202b5c07418SJames Feist { 1203b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1204b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, accountRemoved()); 1205f4c4dcf4SKowalski, Kamil } 1206f4c4dcf4SKowalski, Kamil 1207f4c4dcf4SKowalski, Kamil /** 1208f4c4dcf4SKowalski, Kamil * @internal 1209f4c4dcf4SKowalski, Kamil * @brief Formats AccessDenied message into JSON 1210f4c4dcf4SKowalski, Kamil * 1211f4c4dcf4SKowalski, Kamil * See header file for more information 1212f4c4dcf4SKowalski, Kamil * @endinternal 1213f4c4dcf4SKowalski, Kamil */ 1214d9f466b3SEd Tanous nlohmann::json accessDenied(boost::urls::url_view arg1) 12151abe55efSEd Tanous { 1216fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accessDenied, 1217079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1218b5c07418SJames Feist } 1219b5c07418SJames Feist 1220d9f466b3SEd Tanous void accessDenied(crow::Response& res, boost::urls::url_view arg1) 1221b5c07418SJames Feist { 1222b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1223b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accessDenied(arg1)); 1224f4c4dcf4SKowalski, Kamil } 1225f4c4dcf4SKowalski, Kamil 1226f4c4dcf4SKowalski, Kamil /** 1227f4c4dcf4SKowalski, Kamil * @internal 1228f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupported message into JSON 1229f4c4dcf4SKowalski, Kamil * 1230f4c4dcf4SKowalski, Kamil * See header file for more information 1231f4c4dcf4SKowalski, Kamil * @endinternal 1232f4c4dcf4SKowalski, Kamil */ 1233b5c07418SJames Feist nlohmann::json queryNotSupported(void) 12341abe55efSEd Tanous { 1235fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryNotSupported, {}); 1236b5c07418SJames Feist } 1237b5c07418SJames Feist 1238b5c07418SJames Feist void queryNotSupported(crow::Response& res) 1239b5c07418SJames Feist { 1240b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1241b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupported()); 1242f4c4dcf4SKowalski, Kamil } 1243f4c4dcf4SKowalski, Kamil 1244f4c4dcf4SKowalski, Kamil /** 1245f4c4dcf4SKowalski, Kamil * @internal 1246f4c4dcf4SKowalski, Kamil * @brief Formats CreateLimitReachedForResource message into JSON 1247f4c4dcf4SKowalski, Kamil * 1248f4c4dcf4SKowalski, Kamil * See header file for more information 1249f4c4dcf4SKowalski, Kamil * @endinternal 1250f4c4dcf4SKowalski, Kamil */ 1251b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void) 12521abe55efSEd Tanous { 1253b6cd31e1SEd Tanous return getLog( 1254fffb8c1fSEd Tanous redfish::registries::base::Index::createLimitReachedForResource, {}); 1255b5c07418SJames Feist } 1256b5c07418SJames Feist 1257b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res) 1258b5c07418SJames Feist { 1259b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1260b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, createLimitReachedForResource()); 1261f4c4dcf4SKowalski, Kamil } 1262f4c4dcf4SKowalski, Kamil 1263f4c4dcf4SKowalski, Kamil /** 1264f4c4dcf4SKowalski, Kamil * @internal 1265f4c4dcf4SKowalski, Kamil * @brief Formats GeneralError message into JSON 1266f4c4dcf4SKowalski, Kamil * 1267f4c4dcf4SKowalski, Kamil * See header file for more information 1268f4c4dcf4SKowalski, Kamil * @endinternal 1269f4c4dcf4SKowalski, Kamil */ 1270b5c07418SJames Feist nlohmann::json generalError(void) 12711abe55efSEd Tanous { 1272fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::generalError, {}); 1273b5c07418SJames Feist } 1274b5c07418SJames Feist 1275b5c07418SJames Feist void generalError(crow::Response& res) 1276b5c07418SJames Feist { 1277b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 1278b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, generalError()); 1279f4c4dcf4SKowalski, Kamil } 1280f4c4dcf4SKowalski, Kamil 1281f4c4dcf4SKowalski, Kamil /** 1282f4c4dcf4SKowalski, Kamil * @internal 1283f4c4dcf4SKowalski, Kamil * @brief Formats Success message into JSON 1284f4c4dcf4SKowalski, Kamil * 1285f4c4dcf4SKowalski, Kamil * See header file for more information 1286f4c4dcf4SKowalski, Kamil * @endinternal 1287f4c4dcf4SKowalski, Kamil */ 1288b5c07418SJames Feist nlohmann::json success(void) 12891abe55efSEd Tanous { 1290fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::success, {}); 1291b5c07418SJames Feist } 1292b5c07418SJames Feist 1293b5c07418SJames Feist void success(crow::Response& res) 1294b5c07418SJames Feist { 1295b5c07418SJames Feist // don't set res.result here because success is the default and any 1296b5c07418SJames Feist // error should overwrite the default 1297b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, success()); 1298f12894f8SJason M. Bills } 1299f12894f8SJason M. Bills 1300f12894f8SJason M. Bills /** 1301f12894f8SJason M. Bills * @internal 1302f4c4dcf4SKowalski, Kamil * @brief Formats Created message into JSON 1303f4c4dcf4SKowalski, Kamil * 1304f4c4dcf4SKowalski, Kamil * See header file for more information 1305f4c4dcf4SKowalski, Kamil * @endinternal 1306f4c4dcf4SKowalski, Kamil */ 1307b5c07418SJames Feist nlohmann::json created(void) 13081abe55efSEd Tanous { 1309fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::created, {}); 1310b5c07418SJames Feist } 1311b5c07418SJames Feist 1312b5c07418SJames Feist void created(crow::Response& res) 1313b5c07418SJames Feist { 1314b5c07418SJames Feist res.result(boost::beast::http::status::created); 1315b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, created()); 1316f4c4dcf4SKowalski, Kamil } 1317f4c4dcf4SKowalski, Kamil 1318f4c4dcf4SKowalski, Kamil /** 1319f4c4dcf4SKowalski, Kamil * @internal 1320cc9139ecSJason M. Bills * @brief Formats NoOperation message into JSON 1321cc9139ecSJason M. Bills * 1322cc9139ecSJason M. Bills * See header file for more information 1323cc9139ecSJason M. Bills * @endinternal 1324cc9139ecSJason M. Bills */ 1325b5c07418SJames Feist nlohmann::json noOperation(void) 1326cc9139ecSJason M. Bills { 1327fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::noOperation, {}); 1328b5c07418SJames Feist } 1329b5c07418SJames Feist 1330b5c07418SJames Feist void noOperation(crow::Response& res) 1331b5c07418SJames Feist { 1332b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1333b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noOperation()); 1334cc9139ecSJason M. Bills } 1335cc9139ecSJason M. Bills 1336cc9139ecSJason M. Bills /** 1337cc9139ecSJason M. Bills * @internal 1338b5c07418SJames Feist * @brief Formats PropertyUnknown message into JSON for the specified 1339b5c07418SJames Feist * property 1340f12894f8SJason M. Bills * 1341f12894f8SJason M. Bills * See header file for more information 1342f12894f8SJason M. Bills * @endinternal 1343f12894f8SJason M. Bills */ 13441668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1) 1345b5c07418SJames Feist { 1346fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyUnknown, 13471668ce6dSEd Tanous std::to_array({arg1})); 1348b5c07418SJames Feist } 1349b5c07418SJames Feist 13501668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1) 1351f12894f8SJason M. Bills { 1352f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 13537b1dd2f9SEd Tanous addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1)); 1354f4c4dcf4SKowalski, Kamil } 1355f4c4dcf4SKowalski, Kamil 1356f4c4dcf4SKowalski, Kamil /** 1357f4c4dcf4SKowalski, Kamil * @internal 1358f4c4dcf4SKowalski, Kamil * @brief Formats NoValidSession message into JSON 1359f4c4dcf4SKowalski, Kamil * 1360f4c4dcf4SKowalski, Kamil * See header file for more information 1361f4c4dcf4SKowalski, Kamil * @endinternal 1362f4c4dcf4SKowalski, Kamil */ 1363b5c07418SJames Feist nlohmann::json noValidSession(void) 13641abe55efSEd Tanous { 1365fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::noValidSession, {}); 1366b5c07418SJames Feist } 1367b5c07418SJames Feist 1368b5c07418SJames Feist void noValidSession(crow::Response& res) 1369b5c07418SJames Feist { 1370b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1371b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noValidSession()); 1372f4c4dcf4SKowalski, Kamil } 1373f4c4dcf4SKowalski, Kamil 1374f4c4dcf4SKowalski, Kamil /** 1375f4c4dcf4SKowalski, Kamil * @internal 1376f4c4dcf4SKowalski, Kamil * @brief Formats InvalidObject message into JSON 1377f4c4dcf4SKowalski, Kamil * 1378f4c4dcf4SKowalski, Kamil * See header file for more information 1379f4c4dcf4SKowalski, Kamil * @endinternal 1380f4c4dcf4SKowalski, Kamil */ 1381d9f466b3SEd Tanous nlohmann::json invalidObject(boost::urls::url_view arg1) 13821abe55efSEd Tanous { 1383fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::invalidObject, 1384079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1385b5c07418SJames Feist } 1386b5c07418SJames Feist 1387d9f466b3SEd Tanous void invalidObject(crow::Response& res, boost::urls::url_view arg1) 1388b5c07418SJames Feist { 1389b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1390b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidObject(arg1)); 1391f4c4dcf4SKowalski, Kamil } 1392f4c4dcf4SKowalski, Kamil 1393f4c4dcf4SKowalski, Kamil /** 1394f4c4dcf4SKowalski, Kamil * @internal 1395f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInStandby message into JSON 1396f4c4dcf4SKowalski, Kamil * 1397f4c4dcf4SKowalski, Kamil * See header file for more information 1398f4c4dcf4SKowalski, Kamil * @endinternal 1399f4c4dcf4SKowalski, Kamil */ 1400b5c07418SJames Feist nlohmann::json resourceInStandby(void) 14011abe55efSEd Tanous { 1402fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceInStandby, {}); 1403b5c07418SJames Feist } 1404b5c07418SJames Feist 1405b5c07418SJames Feist void resourceInStandby(crow::Response& res) 1406b5c07418SJames Feist { 1407b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1408b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInStandby()); 1409f4c4dcf4SKowalski, Kamil } 1410f4c4dcf4SKowalski, Kamil 1411f4c4dcf4SKowalski, Kamil /** 1412f4c4dcf4SKowalski, Kamil * @internal 1413f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueTypeError message into JSON 1414f4c4dcf4SKowalski, Kamil * 1415f4c4dcf4SKowalski, Kamil * See header file for more information 1416f4c4dcf4SKowalski, Kamil * @endinternal 1417f4c4dcf4SKowalski, Kamil */ 14181668ce6dSEd Tanous nlohmann::json actionParameterValueTypeError(std::string_view arg1, 14191668ce6dSEd Tanous std::string_view arg2, 14201668ce6dSEd Tanous std::string_view arg3) 14211abe55efSEd Tanous { 1422b6cd31e1SEd Tanous return getLog( 1423fffb8c1fSEd Tanous redfish::registries::base::Index::actionParameterValueTypeError, 14241668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 1425b5c07418SJames Feist } 1426b5c07418SJames Feist 14271668ce6dSEd Tanous void actionParameterValueTypeError(crow::Response& res, std::string_view arg1, 14281668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 1429b5c07418SJames Feist { 1430b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1431b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1432b5c07418SJames Feist actionParameterValueTypeError(arg1, arg2, arg3)); 1433f4c4dcf4SKowalski, Kamil } 1434f4c4dcf4SKowalski, Kamil 1435f4c4dcf4SKowalski, Kamil /** 1436f4c4dcf4SKowalski, Kamil * @internal 1437f4c4dcf4SKowalski, Kamil * @brief Formats SessionLimitExceeded message into JSON 1438f4c4dcf4SKowalski, Kamil * 1439f4c4dcf4SKowalski, Kamil * See header file for more information 1440f4c4dcf4SKowalski, Kamil * @endinternal 1441f4c4dcf4SKowalski, Kamil */ 1442b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void) 14431abe55efSEd Tanous { 1444fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::sessionLimitExceeded, {}); 1445b5c07418SJames Feist } 1446b5c07418SJames Feist 1447b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res) 1448b5c07418SJames Feist { 1449b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1450b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, sessionLimitExceeded()); 1451f4c4dcf4SKowalski, Kamil } 1452f4c4dcf4SKowalski, Kamil 1453f4c4dcf4SKowalski, Kamil /** 1454f4c4dcf4SKowalski, Kamil * @internal 1455f4c4dcf4SKowalski, Kamil * @brief Formats ActionNotSupported message into JSON 1456f4c4dcf4SKowalski, Kamil * 1457f4c4dcf4SKowalski, Kamil * See header file for more information 1458f4c4dcf4SKowalski, Kamil * @endinternal 1459f4c4dcf4SKowalski, Kamil */ 14601668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1) 14611abe55efSEd Tanous { 1462fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionNotSupported, 14631668ce6dSEd Tanous std::to_array({arg1})); 1464b5c07418SJames Feist } 1465b5c07418SJames Feist 14661668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1) 1467b5c07418SJames Feist { 1468b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1469b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1)); 1470f4c4dcf4SKowalski, Kamil } 1471f4c4dcf4SKowalski, Kamil 1472f4c4dcf4SKowalski, Kamil /** 1473f4c4dcf4SKowalski, Kamil * @internal 1474f4c4dcf4SKowalski, Kamil * @brief Formats InvalidIndex message into JSON 1475f4c4dcf4SKowalski, Kamil * 1476f4c4dcf4SKowalski, Kamil * See header file for more information 1477f4c4dcf4SKowalski, Kamil * @endinternal 1478f4c4dcf4SKowalski, Kamil */ 14795187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1) 14801abe55efSEd Tanous { 1481b6cd31e1SEd Tanous std::string arg1Str = std::to_string(arg1); 1482fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::invalidIndex, 14831668ce6dSEd Tanous std::to_array<std::string_view>({arg1Str})); 1484b5c07418SJames Feist } 1485b5c07418SJames Feist 14865187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1) 1487b5c07418SJames Feist { 1488b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1489b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidIndex(arg1)); 1490f4c4dcf4SKowalski, Kamil } 1491f4c4dcf4SKowalski, Kamil 1492f4c4dcf4SKowalski, Kamil /** 1493f4c4dcf4SKowalski, Kamil * @internal 1494f4c4dcf4SKowalski, Kamil * @brief Formats EmptyJSON message into JSON 1495f4c4dcf4SKowalski, Kamil * 1496f4c4dcf4SKowalski, Kamil * See header file for more information 1497f4c4dcf4SKowalski, Kamil * @endinternal 1498f4c4dcf4SKowalski, Kamil */ 1499b5c07418SJames Feist nlohmann::json emptyJSON(void) 15001abe55efSEd Tanous { 1501fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::emptyJSON, {}); 1502b5c07418SJames Feist } 1503b5c07418SJames Feist 1504b5c07418SJames Feist void emptyJSON(crow::Response& res) 1505b5c07418SJames Feist { 1506b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1507b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, emptyJSON()); 1508f4c4dcf4SKowalski, Kamil } 1509f4c4dcf4SKowalski, Kamil 1510f4c4dcf4SKowalski, Kamil /** 1511f4c4dcf4SKowalski, Kamil * @internal 1512f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupportedOnResource message into JSON 1513f4c4dcf4SKowalski, Kamil * 1514f4c4dcf4SKowalski, Kamil * See header file for more information 1515f4c4dcf4SKowalski, Kamil * @endinternal 1516f4c4dcf4SKowalski, Kamil */ 1517b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void) 15181abe55efSEd Tanous { 1519fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryNotSupportedOnResource, 1520b6cd31e1SEd Tanous {}); 1521b5c07418SJames Feist } 1522b5c07418SJames Feist 1523b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res) 1524b5c07418SJames Feist { 15256a409c12SEd Tanous res.result(boost::beast::http::status::bad_request); 1526b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource()); 1527f4c4dcf4SKowalski, Kamil } 1528f4c4dcf4SKowalski, Kamil 1529f4c4dcf4SKowalski, Kamil /** 1530f4c4dcf4SKowalski, Kamil * @internal 1531684bb4b8SJason M. Bills * @brief Formats QueryNotSupportedOnOperation message into JSON 1532684bb4b8SJason M. Bills * 1533684bb4b8SJason M. Bills * See header file for more information 1534684bb4b8SJason M. Bills * @endinternal 1535684bb4b8SJason M. Bills */ 1536684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void) 1537684bb4b8SJason M. Bills { 1538b6cd31e1SEd Tanous return getLog( 1539fffb8c1fSEd Tanous redfish::registries::base::Index::queryNotSupportedOnOperation, {}); 1540684bb4b8SJason M. Bills } 1541684bb4b8SJason M. Bills 1542684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res) 1543684bb4b8SJason M. Bills { 15446a409c12SEd Tanous res.result(boost::beast::http::status::bad_request); 1545684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation()); 1546684bb4b8SJason M. Bills } 1547684bb4b8SJason M. Bills 1548684bb4b8SJason M. Bills /** 1549684bb4b8SJason M. Bills * @internal 1550684bb4b8SJason M. Bills * @brief Formats QueryCombinationInvalid message into JSON 1551684bb4b8SJason M. Bills * 1552684bb4b8SJason M. Bills * See header file for more information 1553684bb4b8SJason M. Bills * @endinternal 1554684bb4b8SJason M. Bills */ 1555684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void) 1556684bb4b8SJason M. Bills { 1557fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryCombinationInvalid, 1558fffb8c1fSEd Tanous {}); 1559684bb4b8SJason M. Bills } 1560684bb4b8SJason M. Bills 1561684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res) 1562684bb4b8SJason M. Bills { 1563684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 1564684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, queryCombinationInvalid()); 1565684bb4b8SJason M. Bills } 1566684bb4b8SJason M. Bills 1567684bb4b8SJason M. Bills /** 1568684bb4b8SJason M. Bills * @internal 1569f4c4dcf4SKowalski, Kamil * @brief Formats InsufficientPrivilege message into JSON 1570f4c4dcf4SKowalski, Kamil * 1571f4c4dcf4SKowalski, Kamil * See header file for more information 1572f4c4dcf4SKowalski, Kamil * @endinternal 1573f4c4dcf4SKowalski, Kamil */ 1574b5c07418SJames Feist nlohmann::json insufficientPrivilege(void) 15751abe55efSEd Tanous { 1576fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::insufficientPrivilege, {}); 1577b5c07418SJames Feist } 1578b5c07418SJames Feist 1579b5c07418SJames Feist void insufficientPrivilege(crow::Response& res) 1580b5c07418SJames Feist { 1581b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1582b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, insufficientPrivilege()); 1583f4c4dcf4SKowalski, Kamil } 1584f4c4dcf4SKowalski, Kamil 1585f4c4dcf4SKowalski, Kamil /** 1586f4c4dcf4SKowalski, Kamil * @internal 1587f4c4dcf4SKowalski, Kamil * @brief Formats PropertyValueModified message into JSON 1588f4c4dcf4SKowalski, Kamil * 1589f4c4dcf4SKowalski, Kamil * See header file for more information 1590f4c4dcf4SKowalski, Kamil * @endinternal 1591f4c4dcf4SKowalski, Kamil */ 15921668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1, 15931668ce6dSEd Tanous std::string_view arg2) 1594b5c07418SJames Feist { 1595fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueModified, 15961668ce6dSEd Tanous std::to_array({arg1, arg2})); 1597b5c07418SJames Feist } 1598b5c07418SJames Feist 15991668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1, 16001668ce6dSEd Tanous std::string_view arg2) 16011abe55efSEd Tanous { 1602f12894f8SJason M. Bills res.result(boost::beast::http::status::ok); 1603b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1); 1604f4c4dcf4SKowalski, Kamil } 1605f4c4dcf4SKowalski, Kamil 1606f4c4dcf4SKowalski, Kamil /** 1607f4c4dcf4SKowalski, Kamil * @internal 1608f4c4dcf4SKowalski, Kamil * @brief Formats AccountNotModified message into JSON 1609f4c4dcf4SKowalski, Kamil * 1610f4c4dcf4SKowalski, Kamil * See header file for more information 1611f4c4dcf4SKowalski, Kamil * @endinternal 1612f4c4dcf4SKowalski, Kamil */ 1613b5c07418SJames Feist nlohmann::json accountNotModified(void) 16141abe55efSEd Tanous { 1615fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountNotModified, {}); 1616b5c07418SJames Feist } 1617b5c07418SJames Feist 1618b5c07418SJames Feist void accountNotModified(crow::Response& res) 1619b5c07418SJames Feist { 1620b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1621b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountNotModified()); 1622f4c4dcf4SKowalski, Kamil } 1623f4c4dcf4SKowalski, Kamil 1624f4c4dcf4SKowalski, Kamil /** 1625f4c4dcf4SKowalski, Kamil * @internal 1626f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueFormatError message into JSON 1627f4c4dcf4SKowalski, Kamil * 1628f4c4dcf4SKowalski, Kamil * See header file for more information 1629f4c4dcf4SKowalski, Kamil * @endinternal 1630f4c4dcf4SKowalski, Kamil */ 16311668ce6dSEd Tanous nlohmann::json queryParameterValueFormatError(std::string_view arg1, 16321668ce6dSEd Tanous std::string_view arg2) 16331abe55efSEd Tanous { 1634fffb8c1fSEd Tanous return getLog( 1635fffb8c1fSEd Tanous redfish::registries::base::Index::queryParameterValueFormatError, 16361668ce6dSEd Tanous std::to_array({arg1, arg2})); 1637b5c07418SJames Feist } 1638b5c07418SJames Feist 16391668ce6dSEd Tanous void queryParameterValueFormatError(crow::Response& res, std::string_view arg1, 16401668ce6dSEd Tanous std::string_view arg2) 1641b5c07418SJames Feist { 1642b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1643b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1644b5c07418SJames Feist queryParameterValueFormatError(arg1, arg2)); 1645f4c4dcf4SKowalski, Kamil } 1646f4c4dcf4SKowalski, Kamil 1647f4c4dcf4SKowalski, Kamil /** 1648f4c4dcf4SKowalski, Kamil * @internal 1649b5c07418SJames Feist * @brief Formats PropertyMissing message into JSON for the specified 1650b5c07418SJames Feist * property 1651f12894f8SJason M. Bills * 1652f12894f8SJason M. Bills * See header file for more information 1653f12894f8SJason M. Bills * @endinternal 1654f12894f8SJason M. Bills */ 16551668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1) 1656f12894f8SJason M. Bills { 1657fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyMissing, 16581668ce6dSEd Tanous std::to_array({arg1})); 1659b5c07418SJames Feist } 1660b5c07418SJames Feist 16611668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1) 1662b5c07418SJames Feist { 1663b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1664b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1); 1665f4c4dcf4SKowalski, Kamil } 1666f4c4dcf4SKowalski, Kamil 1667f4c4dcf4SKowalski, Kamil /** 1668f4c4dcf4SKowalski, Kamil * @internal 1669f4c4dcf4SKowalski, Kamil * @brief Formats ResourceExhaustion message into JSON 1670f4c4dcf4SKowalski, Kamil * 1671f4c4dcf4SKowalski, Kamil * See header file for more information 1672f4c4dcf4SKowalski, Kamil * @endinternal 1673f4c4dcf4SKowalski, Kamil */ 16741668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1) 16751abe55efSEd Tanous { 1676fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceExhaustion, 16771668ce6dSEd Tanous std::to_array({arg1})); 1678b5c07418SJames Feist } 1679b5c07418SJames Feist 16801668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1) 1681b5c07418SJames Feist { 1682b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1683b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1)); 1684f4c4dcf4SKowalski, Kamil } 1685f4c4dcf4SKowalski, Kamil 1686f4c4dcf4SKowalski, Kamil /** 1687f4c4dcf4SKowalski, Kamil * @internal 1688f4c4dcf4SKowalski, Kamil * @brief Formats AccountModified message into JSON 1689f4c4dcf4SKowalski, Kamil * 1690f4c4dcf4SKowalski, Kamil * See header file for more information 1691f4c4dcf4SKowalski, Kamil * @endinternal 1692f4c4dcf4SKowalski, Kamil */ 1693b5c07418SJames Feist nlohmann::json accountModified(void) 16941abe55efSEd Tanous { 1695fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountModified, {}); 1696b5c07418SJames Feist } 1697b5c07418SJames Feist 1698b5c07418SJames Feist void accountModified(crow::Response& res) 1699b5c07418SJames Feist { 1700b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1701b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountModified()); 1702f4c4dcf4SKowalski, Kamil } 1703f4c4dcf4SKowalski, Kamil 1704f4c4dcf4SKowalski, Kamil /** 1705f4c4dcf4SKowalski, Kamil * @internal 1706f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterOutOfRange message into JSON 1707f4c4dcf4SKowalski, Kamil * 1708f4c4dcf4SKowalski, Kamil * See header file for more information 1709f4c4dcf4SKowalski, Kamil * @endinternal 1710f4c4dcf4SKowalski, Kamil */ 17111668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1, 17121668ce6dSEd Tanous std::string_view arg2, 17131668ce6dSEd Tanous std::string_view arg3) 17141abe55efSEd Tanous { 1715fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryParameterOutOfRange, 17161668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 1717b5c07418SJames Feist } 1718b5c07418SJames Feist 17191668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1, 17201668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 1721b5c07418SJames Feist { 1722b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1723b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1724b5c07418SJames Feist queryParameterOutOfRange(arg1, arg2, arg3)); 1725f4c4dcf4SKowalski, Kamil } 1726f4c4dcf4SKowalski, Kamil 1727d9f466b3SEd Tanous nlohmann::json passwordChangeRequired(boost::urls::url_view arg1) 1728b6cd31e1SEd Tanous { 1729fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::passwordChangeRequired, 1730079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1731b6cd31e1SEd Tanous } 1732b6cd31e1SEd Tanous 17333bf4e632SJoseph Reynolds /** 17343bf4e632SJoseph Reynolds * @internal 17353bf4e632SJoseph Reynolds * @brief Formats PasswordChangeRequired message into JSON 17363bf4e632SJoseph Reynolds * 17373bf4e632SJoseph Reynolds * See header file for more information 17383bf4e632SJoseph Reynolds * @endinternal 17393bf4e632SJoseph Reynolds */ 1740d9f466b3SEd Tanous void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1) 17413bf4e632SJoseph Reynolds { 1742b6cd31e1SEd Tanous messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1)); 17433bf4e632SJoseph Reynolds } 17443bf4e632SJoseph Reynolds 17454cde5d90SJames Feist /** 17464cde5d90SJames Feist * @internal 1747ae688313SNan Zhou * @brief Formats InsufficientStorage message into JSON 1748ae688313SNan Zhou * 1749ae688313SNan Zhou * See header file for more information 1750ae688313SNan Zhou * @endinternal 1751ae688313SNan Zhou */ 1752ae688313SNan Zhou nlohmann::json insufficientStorage() 1753ae688313SNan Zhou { 1754ae688313SNan Zhou return getLog(redfish::registries::base::Index::insufficientStorage, {}); 1755ae688313SNan Zhou } 1756ae688313SNan Zhou 1757ae688313SNan Zhou void insufficientStorage(crow::Response& res) 1758ae688313SNan Zhou { 1759ae688313SNan Zhou res.result(boost::beast::http::status::insufficient_storage); 1760ae688313SNan Zhou addMessageToErrorJson(res.jsonValue, insufficientStorage()); 1761ae688313SNan Zhou } 1762ae688313SNan Zhou 1763ae688313SNan Zhou /** 1764ae688313SNan Zhou * @internal 176544c70412SEd Tanous * @brief Formats OperationNotAllowed message into JSON 176644c70412SEd Tanous * 176744c70412SEd Tanous * See header file for more information 176844c70412SEd Tanous * @endinternal 176944c70412SEd Tanous */ 177044c70412SEd Tanous nlohmann::json operationNotAllowed() 177144c70412SEd Tanous { 177244c70412SEd Tanous return getLog(redfish::registries::base::Index::operationNotAllowed, {}); 177344c70412SEd Tanous } 177444c70412SEd Tanous 177544c70412SEd Tanous void operationNotAllowed(crow::Response& res) 177644c70412SEd Tanous { 177744c70412SEd Tanous res.result(boost::beast::http::status::method_not_allowed); 177844c70412SEd Tanous addMessageToErrorJson(res.jsonValue, operationNotAllowed()); 177944c70412SEd Tanous } 178044c70412SEd Tanous 1781600af5f1SAppaRao Puli /** 1782600af5f1SAppaRao Puli * @internal 1783600af5f1SAppaRao Puli * @brief Formats ArraySizeTooLong message into JSON 1784600af5f1SAppaRao Puli * 1785600af5f1SAppaRao Puli * See header file for more information 1786600af5f1SAppaRao Puli * @endinternal 1787600af5f1SAppaRao Puli */ 1788600af5f1SAppaRao Puli nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length) 1789600af5f1SAppaRao Puli { 1790600af5f1SAppaRao Puli std::string valStr = std::to_string(length); 1791600af5f1SAppaRao Puli return getLog(redfish::registries::base::Index::arraySizeTooLong, 1792600af5f1SAppaRao Puli std::to_array<std::string_view>({property, valStr})); 1793600af5f1SAppaRao Puli } 1794600af5f1SAppaRao Puli 1795600af5f1SAppaRao Puli void arraySizeTooLong(crow::Response& res, std::string_view property, 1796600af5f1SAppaRao Puli uint64_t length) 1797600af5f1SAppaRao Puli { 1798600af5f1SAppaRao Puli res.result(boost::beast::http::status::method_not_allowed); 1799600af5f1SAppaRao Puli addMessageToErrorJson(res.jsonValue, arraySizeTooLong(property, length)); 1800600af5f1SAppaRao Puli } 1801600af5f1SAppaRao Puli 180244c70412SEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1, 180344c70412SEd Tanous std::string_view arg2) 180444c70412SEd Tanous { 180544c70412SEd Tanous res.result(boost::beast::http::status::bad_request); 180644c70412SEd Tanous addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2)); 180744c70412SEd Tanous } 180844c70412SEd Tanous 180944c70412SEd Tanous /** 181044c70412SEd Tanous * @internal 18114cde5d90SJames Feist * @brief Formats Invalid File message into JSON 18124cde5d90SJames Feist * 18134cde5d90SJames Feist * See header file for more information 18144cde5d90SJames Feist * @endinternal 18154cde5d90SJames Feist */ 18161668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2) 18174cde5d90SJames Feist { 18181668ce6dSEd Tanous std::string msg = "Invalid file uploaded to "; 18191668ce6dSEd Tanous msg += arg1; 18201668ce6dSEd Tanous msg += ": "; 18211668ce6dSEd Tanous msg += arg2; 18221668ce6dSEd Tanous msg += "."; 1823613dabeaSEd Tanous 1824613dabeaSEd Tanous nlohmann::json::object_t ret; 1825613dabeaSEd Tanous ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message"; 1826613dabeaSEd Tanous ret["MessageId"] = "OpenBMC.0.2.InvalidUpload"; 1827613dabeaSEd Tanous ret["Message"] = std::move(msg); 1828613dabeaSEd Tanous nlohmann::json::array_t args; 1829ad539545SPatrick Williams args.emplace_back(arg1); 1830ad539545SPatrick Williams args.emplace_back(arg2); 1831613dabeaSEd Tanous ret["MessageArgs"] = std::move(args); 1832613dabeaSEd Tanous ret["MessageSeverity"] = "Warning"; 1833613dabeaSEd Tanous ret["Resolution"] = "None."; 1834613dabeaSEd Tanous return ret; 18354cde5d90SJames Feist } 1836ae688313SNan Zhou 1837f4c4dcf4SKowalski, Kamil } // namespace messages 1838f4c4dcf4SKowalski, Kamil 1839d425c6f6SEd Tanous } // namespace redfish 1840