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 */ 481*f818b04dSEd Tanous nlohmann::json propertyValueFormatError(const nlohmann::json& arg1, 4821668ce6dSEd Tanous std::string_view arg2) 483f12894f8SJason M. Bills { 484*f818b04dSEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 485*f818b04dSEd Tanous nlohmann::json::error_handler_t::replace); 486fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueFormatError, 487*f818b04dSEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 488b5c07418SJames Feist } 489b5c07418SJames Feist 490*f818b04dSEd 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 */ 8531668ce6dSEd Tanous nlohmann::json propertyValueIncorrect(std::string_view arg1, 8541668ce6dSEd Tanous std::string_view arg2) 855684bb4b8SJason M. Bills { 856fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueIncorrect, 8571668ce6dSEd Tanous std::to_array({arg1, arg2})); 858684bb4b8SJason M. Bills } 859684bb4b8SJason M. Bills 8601668ce6dSEd Tanous void propertyValueIncorrect(crow::Response& res, std::string_view arg1, 8611668ce6dSEd Tanous std::string_view arg2) 862684bb4b8SJason M. Bills { 863684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 864684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2)); 865684bb4b8SJason M. Bills } 866684bb4b8SJason M. Bills 867684bb4b8SJason M. Bills /** 868684bb4b8SJason M. Bills * @internal 869684bb4b8SJason M. Bills * @brief Formats ResourceCreationConflict message into JSON 870684bb4b8SJason M. Bills * 871684bb4b8SJason M. Bills * See header file for more information 872684bb4b8SJason M. Bills * @endinternal 873684bb4b8SJason M. Bills */ 874d9f466b3SEd Tanous nlohmann::json resourceCreationConflict(boost::urls::url_view arg1) 875684bb4b8SJason M. Bills { 876fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceCreationConflict, 877079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 878684bb4b8SJason M. Bills } 879684bb4b8SJason M. Bills 880d9f466b3SEd Tanous void resourceCreationConflict(crow::Response& res, boost::urls::url_view arg1) 881684bb4b8SJason M. Bills { 882684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 883684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1)); 884684bb4b8SJason M. Bills } 885684bb4b8SJason M. Bills 886684bb4b8SJason M. Bills /** 887684bb4b8SJason M. Bills * @internal 888684bb4b8SJason M. Bills * @brief Formats MaximumErrorsExceeded message into JSON 889684bb4b8SJason M. Bills * 890684bb4b8SJason M. Bills * See header file for more information 891684bb4b8SJason M. Bills * @endinternal 892684bb4b8SJason M. Bills */ 893684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void) 894684bb4b8SJason M. Bills { 895fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {}); 896684bb4b8SJason M. Bills } 897684bb4b8SJason M. Bills 898684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res) 899684bb4b8SJason M. Bills { 900684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 901684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded()); 902684bb4b8SJason M. Bills } 903684bb4b8SJason M. Bills 904684bb4b8SJason M. Bills /** 905684bb4b8SJason M. Bills * @internal 906684bb4b8SJason M. Bills * @brief Formats PreconditionFailed message into JSON 907684bb4b8SJason M. Bills * 908684bb4b8SJason M. Bills * See header file for more information 909684bb4b8SJason M. Bills * @endinternal 910684bb4b8SJason M. Bills */ 911684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void) 912684bb4b8SJason M. Bills { 913fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::preconditionFailed, {}); 914684bb4b8SJason M. Bills } 915684bb4b8SJason M. Bills 916684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res) 917684bb4b8SJason M. Bills { 9184df1bee0SEd Tanous res.result(boost::beast::http::status::precondition_failed); 919684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, preconditionFailed()); 920684bb4b8SJason M. Bills } 921684bb4b8SJason M. Bills 922684bb4b8SJason M. Bills /** 923684bb4b8SJason M. Bills * @internal 924684bb4b8SJason M. Bills * @brief Formats PreconditionRequired message into JSON 925684bb4b8SJason M. Bills * 926684bb4b8SJason M. Bills * See header file for more information 927684bb4b8SJason M. Bills * @endinternal 928684bb4b8SJason M. Bills */ 929684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void) 930684bb4b8SJason M. Bills { 931fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::preconditionRequired, {}); 932684bb4b8SJason M. Bills } 933684bb4b8SJason M. Bills 934684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res) 935684bb4b8SJason M. Bills { 936684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 937684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, preconditionRequired()); 938684bb4b8SJason M. Bills } 939684bb4b8SJason M. Bills 940684bb4b8SJason M. Bills /** 941684bb4b8SJason M. Bills * @internal 942684bb4b8SJason M. Bills * @brief Formats OperationFailed message into JSON 943684bb4b8SJason M. Bills * 944684bb4b8SJason M. Bills * See header file for more information 945684bb4b8SJason M. Bills * @endinternal 946684bb4b8SJason M. Bills */ 947684bb4b8SJason M. Bills nlohmann::json operationFailed(void) 948684bb4b8SJason M. Bills { 949fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::operationFailed, {}); 950684bb4b8SJason M. Bills } 951684bb4b8SJason M. Bills 952684bb4b8SJason M. Bills void operationFailed(crow::Response& res) 953684bb4b8SJason M. Bills { 9548868776eSEd Tanous res.result(boost::beast::http::status::bad_gateway); 955684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, operationFailed()); 956684bb4b8SJason M. Bills } 957684bb4b8SJason M. Bills 958684bb4b8SJason M. Bills /** 959684bb4b8SJason M. Bills * @internal 960684bb4b8SJason M. Bills * @brief Formats OperationTimeout message into JSON 961684bb4b8SJason M. Bills * 962684bb4b8SJason M. Bills * See header file for more information 963684bb4b8SJason M. Bills * @endinternal 964684bb4b8SJason M. Bills */ 965684bb4b8SJason M. Bills nlohmann::json operationTimeout(void) 966684bb4b8SJason M. Bills { 967fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::operationTimeout, {}); 968684bb4b8SJason M. Bills } 969684bb4b8SJason M. Bills 970684bb4b8SJason M. Bills void operationTimeout(crow::Response& res) 971684bb4b8SJason M. Bills { 972684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 973684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, operationTimeout()); 974684bb4b8SJason M. Bills } 975684bb4b8SJason M. Bills 976684bb4b8SJason M. Bills /** 977684bb4b8SJason M. Bills * @internal 978f12894f8SJason M. Bills * @brief Formats PropertyValueTypeError message into JSON for the specified 979f12894f8SJason M. Bills * property 980f12894f8SJason M. Bills * 981f12894f8SJason M. Bills * See header file for more information 982f12894f8SJason M. Bills * @endinternal 983f12894f8SJason M. Bills */ 9842e8c4bdaSEd Tanous nlohmann::json propertyValueTypeError(const nlohmann::json& arg1, 9851668ce6dSEd Tanous std::string_view arg2) 986f12894f8SJason M. Bills { 9872e8c4bdaSEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 9882e8c4bdaSEd Tanous nlohmann::json::error_handler_t::replace); 989fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueTypeError, 9902e8c4bdaSEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 991b5c07418SJames Feist } 992b5c07418SJames Feist 9932e8c4bdaSEd Tanous void propertyValueTypeError(crow::Response& res, const nlohmann::json& arg1, 9941668ce6dSEd Tanous std::string_view arg2) 995b5c07418SJames Feist { 996b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 997b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2); 998f4c4dcf4SKowalski, Kamil } 999f4c4dcf4SKowalski, Kamil 1000f4c4dcf4SKowalski, Kamil /** 1001f4c4dcf4SKowalski, Kamil * @internal 1002b6cd31e1SEd Tanous * @brief Formats ResourceNotFound message into JSONd 1003f4c4dcf4SKowalski, Kamil * 1004f4c4dcf4SKowalski, Kamil * See header file for more information 1005f4c4dcf4SKowalski, Kamil * @endinternal 1006f4c4dcf4SKowalski, Kamil */ 10071668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2) 10081abe55efSEd Tanous { 1009fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceNotFound, 10101668ce6dSEd Tanous std::to_array({arg1, arg2})); 1011b5c07418SJames Feist } 1012b5c07418SJames Feist 10131668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1, 10141668ce6dSEd Tanous std::string_view arg2) 1015b5c07418SJames Feist { 1016b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 1017b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2)); 1018f4c4dcf4SKowalski, Kamil } 1019f4c4dcf4SKowalski, Kamil 1020f4c4dcf4SKowalski, Kamil /** 1021f4c4dcf4SKowalski, Kamil * @internal 1022f4c4dcf4SKowalski, Kamil * @brief Formats CouldNotEstablishConnection message into JSON 1023f4c4dcf4SKowalski, Kamil * 1024f4c4dcf4SKowalski, Kamil * See header file for more information 1025f4c4dcf4SKowalski, Kamil * @endinternal 1026f4c4dcf4SKowalski, Kamil */ 1027d9f466b3SEd Tanous nlohmann::json couldNotEstablishConnection(boost::urls::url_view arg1) 10281abe55efSEd Tanous { 1029fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::couldNotEstablishConnection, 1030079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1031b5c07418SJames Feist } 1032b5c07418SJames Feist 1033ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res, 1034d9f466b3SEd Tanous boost::urls::url_view arg1) 1035b5c07418SJames Feist { 1036b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 1037b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1)); 1038f4c4dcf4SKowalski, Kamil } 1039f4c4dcf4SKowalski, Kamil 1040f4c4dcf4SKowalski, Kamil /** 1041f4c4dcf4SKowalski, Kamil * @internal 1042f12894f8SJason M. Bills * @brief Formats PropertyNotWritable message into JSON for the specified 1043f12894f8SJason M. Bills * property 1044f12894f8SJason M. Bills * 1045f12894f8SJason M. Bills * See header file for more information 1046f12894f8SJason M. Bills * @endinternal 1047f12894f8SJason M. Bills */ 10481668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1) 1049f12894f8SJason M. Bills { 1050fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyNotWritable, 10511668ce6dSEd Tanous std::to_array({arg1})); 1052b5c07418SJames Feist } 1053b5c07418SJames Feist 10541668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1) 1055b5c07418SJames Feist { 1056b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1057b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1); 1058f4c4dcf4SKowalski, Kamil } 1059f4c4dcf4SKowalski, Kamil 1060f4c4dcf4SKowalski, Kamil /** 1061f4c4dcf4SKowalski, Kamil * @internal 1062f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueTypeError message into JSON 1063f4c4dcf4SKowalski, Kamil * 1064f4c4dcf4SKowalski, Kamil * See header file for more information 1065f4c4dcf4SKowalski, Kamil * @endinternal 1066f4c4dcf4SKowalski, Kamil */ 10671668ce6dSEd Tanous nlohmann::json queryParameterValueTypeError(std::string_view arg1, 10681668ce6dSEd Tanous std::string_view arg2) 10691abe55efSEd Tanous { 1070b6cd31e1SEd Tanous return getLog( 1071fffb8c1fSEd Tanous redfish::registries::base::Index::queryParameterValueTypeError, 10721668ce6dSEd Tanous std::to_array({arg1, arg2})); 1073b5c07418SJames Feist } 1074b5c07418SJames Feist 10751668ce6dSEd Tanous void queryParameterValueTypeError(crow::Response& res, std::string_view arg1, 10761668ce6dSEd Tanous std::string_view arg2) 1077b5c07418SJames Feist { 1078b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1079b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1080b5c07418SJames Feist queryParameterValueTypeError(arg1, arg2)); 1081f4c4dcf4SKowalski, Kamil } 1082f4c4dcf4SKowalski, Kamil 1083f4c4dcf4SKowalski, Kamil /** 1084f4c4dcf4SKowalski, Kamil * @internal 1085f4c4dcf4SKowalski, Kamil * @brief Formats ServiceShuttingDown message into JSON 1086f4c4dcf4SKowalski, Kamil * 1087f4c4dcf4SKowalski, Kamil * See header file for more information 1088f4c4dcf4SKowalski, Kamil * @endinternal 1089f4c4dcf4SKowalski, Kamil */ 1090b5c07418SJames Feist nlohmann::json serviceShuttingDown(void) 10911abe55efSEd Tanous { 1092fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceShuttingDown, {}); 1093b5c07418SJames Feist } 1094b5c07418SJames Feist 1095b5c07418SJames Feist void serviceShuttingDown(crow::Response& res) 1096b5c07418SJames Feist { 1097b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1098b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceShuttingDown()); 1099f4c4dcf4SKowalski, Kamil } 1100f4c4dcf4SKowalski, Kamil 1101f4c4dcf4SKowalski, Kamil /** 1102f4c4dcf4SKowalski, Kamil * @internal 1103f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterDuplicate message into JSON 1104f4c4dcf4SKowalski, Kamil * 1105f4c4dcf4SKowalski, Kamil * See header file for more information 1106f4c4dcf4SKowalski, Kamil * @endinternal 1107f4c4dcf4SKowalski, Kamil */ 11081668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1, 11091668ce6dSEd Tanous std::string_view arg2) 11101abe55efSEd Tanous { 1111fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterDuplicate, 11121668ce6dSEd Tanous std::to_array({arg1, arg2})); 1113b5c07418SJames Feist } 1114b5c07418SJames Feist 11151668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1, 11161668ce6dSEd Tanous std::string_view arg2) 1117b5c07418SJames Feist { 1118b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1119b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2)); 1120f4c4dcf4SKowalski, Kamil } 1121f4c4dcf4SKowalski, Kamil 1122f4c4dcf4SKowalski, Kamil /** 1123f4c4dcf4SKowalski, Kamil * @internal 1124f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterNotSupported message into JSON 1125f4c4dcf4SKowalski, Kamil * 1126f4c4dcf4SKowalski, Kamil * See header file for more information 1127f4c4dcf4SKowalski, Kamil * @endinternal 1128f4c4dcf4SKowalski, Kamil */ 11291668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1, 11301668ce6dSEd Tanous std::string_view arg2) 11311abe55efSEd Tanous { 1132fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterNotSupported, 11331668ce6dSEd Tanous std::to_array({arg1, arg2})); 1134b5c07418SJames Feist } 1135b5c07418SJames Feist 11361668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1, 11371668ce6dSEd Tanous std::string_view arg2) 1138b5c07418SJames Feist { 1139b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1140b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1141b5c07418SJames Feist actionParameterNotSupported(arg1, arg2)); 1142f4c4dcf4SKowalski, Kamil } 1143f4c4dcf4SKowalski, Kamil 1144f4c4dcf4SKowalski, Kamil /** 1145f4c4dcf4SKowalski, Kamil * @internal 1146f4c4dcf4SKowalski, Kamil * @brief Formats SourceDoesNotSupportProtocol message into JSON 1147f4c4dcf4SKowalski, Kamil * 1148f4c4dcf4SKowalski, Kamil * See header file for more information 1149f4c4dcf4SKowalski, Kamil * @endinternal 1150f4c4dcf4SKowalski, Kamil */ 1151d9f466b3SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1, 11521668ce6dSEd Tanous std::string_view arg2) 11531abe55efSEd Tanous { 1154b6cd31e1SEd Tanous return getLog( 1155fffb8c1fSEd Tanous redfish::registries::base::Index::sourceDoesNotSupportProtocol, 1156079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer(), arg2})); 1157b5c07418SJames Feist } 1158b5c07418SJames Feist 1159ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res, 1160d9f466b3SEd Tanous boost::urls::url_view arg1, 11611668ce6dSEd Tanous std::string_view arg2) 1162b5c07418SJames Feist { 1163b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1164b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1165b5c07418SJames Feist sourceDoesNotSupportProtocol(arg1, arg2)); 1166f4c4dcf4SKowalski, Kamil } 1167f4c4dcf4SKowalski, Kamil 1168f4c4dcf4SKowalski, Kamil /** 1169f4c4dcf4SKowalski, Kamil * @internal 1170b4ad4c05SShantappa Teekappanavar * @brief Formats StrictAccountTypes message into JSON 1171b4ad4c05SShantappa Teekappanavar * 1172b4ad4c05SShantappa Teekappanavar * See header file for more information 1173b4ad4c05SShantappa Teekappanavar * @endinternal 1174b4ad4c05SShantappa Teekappanavar */ 1175b4ad4c05SShantappa Teekappanavar nlohmann::json strictAccountTypes(std::string_view arg1) 1176b4ad4c05SShantappa Teekappanavar { 1177b4ad4c05SShantappa Teekappanavar return getLog(redfish::registries::base::Index::strictAccountTypes, 1178b4ad4c05SShantappa Teekappanavar std::to_array({arg1})); 1179b4ad4c05SShantappa Teekappanavar } 1180b4ad4c05SShantappa Teekappanavar 1181b4ad4c05SShantappa Teekappanavar void strictAccountTypes(crow::Response& res, std::string_view arg1) 1182b4ad4c05SShantappa Teekappanavar { 1183b4ad4c05SShantappa Teekappanavar res.result(boost::beast::http::status::bad_request); 1184b4ad4c05SShantappa Teekappanavar addMessageToErrorJson(res.jsonValue, strictAccountTypes(arg1)); 1185b4ad4c05SShantappa Teekappanavar } 1186b4ad4c05SShantappa Teekappanavar 1187b4ad4c05SShantappa Teekappanavar /** 1188b4ad4c05SShantappa Teekappanavar * @internal 1189f4c4dcf4SKowalski, Kamil * @brief Formats AccountRemoved message into JSON 1190f4c4dcf4SKowalski, Kamil * 1191f4c4dcf4SKowalski, Kamil * See header file for more information 1192f4c4dcf4SKowalski, Kamil * @endinternal 1193f4c4dcf4SKowalski, Kamil */ 1194b5c07418SJames Feist nlohmann::json accountRemoved(void) 11951abe55efSEd Tanous { 1196fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountRemoved, {}); 1197b5c07418SJames Feist } 1198b5c07418SJames Feist 1199b5c07418SJames Feist void accountRemoved(crow::Response& res) 1200b5c07418SJames Feist { 1201b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1202b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, accountRemoved()); 1203f4c4dcf4SKowalski, Kamil } 1204f4c4dcf4SKowalski, Kamil 1205f4c4dcf4SKowalski, Kamil /** 1206f4c4dcf4SKowalski, Kamil * @internal 1207f4c4dcf4SKowalski, Kamil * @brief Formats AccessDenied message into JSON 1208f4c4dcf4SKowalski, Kamil * 1209f4c4dcf4SKowalski, Kamil * See header file for more information 1210f4c4dcf4SKowalski, Kamil * @endinternal 1211f4c4dcf4SKowalski, Kamil */ 1212d9f466b3SEd Tanous nlohmann::json accessDenied(boost::urls::url_view arg1) 12131abe55efSEd Tanous { 1214fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accessDenied, 1215079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1216b5c07418SJames Feist } 1217b5c07418SJames Feist 1218d9f466b3SEd Tanous void accessDenied(crow::Response& res, boost::urls::url_view arg1) 1219b5c07418SJames Feist { 1220b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1221b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accessDenied(arg1)); 1222f4c4dcf4SKowalski, Kamil } 1223f4c4dcf4SKowalski, Kamil 1224f4c4dcf4SKowalski, Kamil /** 1225f4c4dcf4SKowalski, Kamil * @internal 1226f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupported message into JSON 1227f4c4dcf4SKowalski, Kamil * 1228f4c4dcf4SKowalski, Kamil * See header file for more information 1229f4c4dcf4SKowalski, Kamil * @endinternal 1230f4c4dcf4SKowalski, Kamil */ 1231b5c07418SJames Feist nlohmann::json queryNotSupported(void) 12321abe55efSEd Tanous { 1233fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryNotSupported, {}); 1234b5c07418SJames Feist } 1235b5c07418SJames Feist 1236b5c07418SJames Feist void queryNotSupported(crow::Response& res) 1237b5c07418SJames Feist { 1238b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1239b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupported()); 1240f4c4dcf4SKowalski, Kamil } 1241f4c4dcf4SKowalski, Kamil 1242f4c4dcf4SKowalski, Kamil /** 1243f4c4dcf4SKowalski, Kamil * @internal 1244f4c4dcf4SKowalski, Kamil * @brief Formats CreateLimitReachedForResource message into JSON 1245f4c4dcf4SKowalski, Kamil * 1246f4c4dcf4SKowalski, Kamil * See header file for more information 1247f4c4dcf4SKowalski, Kamil * @endinternal 1248f4c4dcf4SKowalski, Kamil */ 1249b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void) 12501abe55efSEd Tanous { 1251b6cd31e1SEd Tanous return getLog( 1252fffb8c1fSEd Tanous redfish::registries::base::Index::createLimitReachedForResource, {}); 1253b5c07418SJames Feist } 1254b5c07418SJames Feist 1255b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res) 1256b5c07418SJames Feist { 1257b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1258b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, createLimitReachedForResource()); 1259f4c4dcf4SKowalski, Kamil } 1260f4c4dcf4SKowalski, Kamil 1261f4c4dcf4SKowalski, Kamil /** 1262f4c4dcf4SKowalski, Kamil * @internal 1263f4c4dcf4SKowalski, Kamil * @brief Formats GeneralError message into JSON 1264f4c4dcf4SKowalski, Kamil * 1265f4c4dcf4SKowalski, Kamil * See header file for more information 1266f4c4dcf4SKowalski, Kamil * @endinternal 1267f4c4dcf4SKowalski, Kamil */ 1268b5c07418SJames Feist nlohmann::json generalError(void) 12691abe55efSEd Tanous { 1270fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::generalError, {}); 1271b5c07418SJames Feist } 1272b5c07418SJames Feist 1273b5c07418SJames Feist void generalError(crow::Response& res) 1274b5c07418SJames Feist { 1275b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 1276b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, generalError()); 1277f4c4dcf4SKowalski, Kamil } 1278f4c4dcf4SKowalski, Kamil 1279f4c4dcf4SKowalski, Kamil /** 1280f4c4dcf4SKowalski, Kamil * @internal 1281f4c4dcf4SKowalski, Kamil * @brief Formats Success message into JSON 1282f4c4dcf4SKowalski, Kamil * 1283f4c4dcf4SKowalski, Kamil * See header file for more information 1284f4c4dcf4SKowalski, Kamil * @endinternal 1285f4c4dcf4SKowalski, Kamil */ 1286b5c07418SJames Feist nlohmann::json success(void) 12871abe55efSEd Tanous { 1288fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::success, {}); 1289b5c07418SJames Feist } 1290b5c07418SJames Feist 1291b5c07418SJames Feist void success(crow::Response& res) 1292b5c07418SJames Feist { 1293b5c07418SJames Feist // don't set res.result here because success is the default and any 1294b5c07418SJames Feist // error should overwrite the default 1295b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, success()); 1296f12894f8SJason M. Bills } 1297f12894f8SJason M. Bills 1298f12894f8SJason M. Bills /** 1299f12894f8SJason M. Bills * @internal 1300f4c4dcf4SKowalski, Kamil * @brief Formats Created message into JSON 1301f4c4dcf4SKowalski, Kamil * 1302f4c4dcf4SKowalski, Kamil * See header file for more information 1303f4c4dcf4SKowalski, Kamil * @endinternal 1304f4c4dcf4SKowalski, Kamil */ 1305b5c07418SJames Feist nlohmann::json created(void) 13061abe55efSEd Tanous { 1307fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::created, {}); 1308b5c07418SJames Feist } 1309b5c07418SJames Feist 1310b5c07418SJames Feist void created(crow::Response& res) 1311b5c07418SJames Feist { 1312b5c07418SJames Feist res.result(boost::beast::http::status::created); 1313b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, created()); 1314f4c4dcf4SKowalski, Kamil } 1315f4c4dcf4SKowalski, Kamil 1316f4c4dcf4SKowalski, Kamil /** 1317f4c4dcf4SKowalski, Kamil * @internal 1318cc9139ecSJason M. Bills * @brief Formats NoOperation message into JSON 1319cc9139ecSJason M. Bills * 1320cc9139ecSJason M. Bills * See header file for more information 1321cc9139ecSJason M. Bills * @endinternal 1322cc9139ecSJason M. Bills */ 1323b5c07418SJames Feist nlohmann::json noOperation(void) 1324cc9139ecSJason M. Bills { 1325fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::noOperation, {}); 1326b5c07418SJames Feist } 1327b5c07418SJames Feist 1328b5c07418SJames Feist void noOperation(crow::Response& res) 1329b5c07418SJames Feist { 1330b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1331b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noOperation()); 1332cc9139ecSJason M. Bills } 1333cc9139ecSJason M. Bills 1334cc9139ecSJason M. Bills /** 1335cc9139ecSJason M. Bills * @internal 1336b5c07418SJames Feist * @brief Formats PropertyUnknown message into JSON for the specified 1337b5c07418SJames Feist * property 1338f12894f8SJason M. Bills * 1339f12894f8SJason M. Bills * See header file for more information 1340f12894f8SJason M. Bills * @endinternal 1341f12894f8SJason M. Bills */ 13421668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1) 1343b5c07418SJames Feist { 1344fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyUnknown, 13451668ce6dSEd Tanous std::to_array({arg1})); 1346b5c07418SJames Feist } 1347b5c07418SJames Feist 13481668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1) 1349f12894f8SJason M. Bills { 1350f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 13517b1dd2f9SEd Tanous addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1)); 1352f4c4dcf4SKowalski, Kamil } 1353f4c4dcf4SKowalski, Kamil 1354f4c4dcf4SKowalski, Kamil /** 1355f4c4dcf4SKowalski, Kamil * @internal 1356f4c4dcf4SKowalski, Kamil * @brief Formats NoValidSession message into JSON 1357f4c4dcf4SKowalski, Kamil * 1358f4c4dcf4SKowalski, Kamil * See header file for more information 1359f4c4dcf4SKowalski, Kamil * @endinternal 1360f4c4dcf4SKowalski, Kamil */ 1361b5c07418SJames Feist nlohmann::json noValidSession(void) 13621abe55efSEd Tanous { 1363fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::noValidSession, {}); 1364b5c07418SJames Feist } 1365b5c07418SJames Feist 1366b5c07418SJames Feist void noValidSession(crow::Response& res) 1367b5c07418SJames Feist { 1368b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1369b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noValidSession()); 1370f4c4dcf4SKowalski, Kamil } 1371f4c4dcf4SKowalski, Kamil 1372f4c4dcf4SKowalski, Kamil /** 1373f4c4dcf4SKowalski, Kamil * @internal 1374f4c4dcf4SKowalski, Kamil * @brief Formats InvalidObject message into JSON 1375f4c4dcf4SKowalski, Kamil * 1376f4c4dcf4SKowalski, Kamil * See header file for more information 1377f4c4dcf4SKowalski, Kamil * @endinternal 1378f4c4dcf4SKowalski, Kamil */ 1379d9f466b3SEd Tanous nlohmann::json invalidObject(boost::urls::url_view arg1) 13801abe55efSEd Tanous { 1381fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::invalidObject, 1382079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1383b5c07418SJames Feist } 1384b5c07418SJames Feist 1385d9f466b3SEd Tanous void invalidObject(crow::Response& res, boost::urls::url_view arg1) 1386b5c07418SJames Feist { 1387b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1388b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidObject(arg1)); 1389f4c4dcf4SKowalski, Kamil } 1390f4c4dcf4SKowalski, Kamil 1391f4c4dcf4SKowalski, Kamil /** 1392f4c4dcf4SKowalski, Kamil * @internal 1393f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInStandby message into JSON 1394f4c4dcf4SKowalski, Kamil * 1395f4c4dcf4SKowalski, Kamil * See header file for more information 1396f4c4dcf4SKowalski, Kamil * @endinternal 1397f4c4dcf4SKowalski, Kamil */ 1398b5c07418SJames Feist nlohmann::json resourceInStandby(void) 13991abe55efSEd Tanous { 1400fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceInStandby, {}); 1401b5c07418SJames Feist } 1402b5c07418SJames Feist 1403b5c07418SJames Feist void resourceInStandby(crow::Response& res) 1404b5c07418SJames Feist { 1405b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1406b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInStandby()); 1407f4c4dcf4SKowalski, Kamil } 1408f4c4dcf4SKowalski, Kamil 1409f4c4dcf4SKowalski, Kamil /** 1410f4c4dcf4SKowalski, Kamil * @internal 1411f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueTypeError message into JSON 1412f4c4dcf4SKowalski, Kamil * 1413f4c4dcf4SKowalski, Kamil * See header file for more information 1414f4c4dcf4SKowalski, Kamil * @endinternal 1415f4c4dcf4SKowalski, Kamil */ 14161668ce6dSEd Tanous nlohmann::json actionParameterValueTypeError(std::string_view arg1, 14171668ce6dSEd Tanous std::string_view arg2, 14181668ce6dSEd Tanous std::string_view arg3) 14191abe55efSEd Tanous { 1420b6cd31e1SEd Tanous return getLog( 1421fffb8c1fSEd Tanous redfish::registries::base::Index::actionParameterValueTypeError, 14221668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 1423b5c07418SJames Feist } 1424b5c07418SJames Feist 14251668ce6dSEd Tanous void actionParameterValueTypeError(crow::Response& res, std::string_view arg1, 14261668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 1427b5c07418SJames Feist { 1428b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1429b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1430b5c07418SJames Feist actionParameterValueTypeError(arg1, arg2, arg3)); 1431f4c4dcf4SKowalski, Kamil } 1432f4c4dcf4SKowalski, Kamil 1433f4c4dcf4SKowalski, Kamil /** 1434f4c4dcf4SKowalski, Kamil * @internal 1435f4c4dcf4SKowalski, Kamil * @brief Formats SessionLimitExceeded message into JSON 1436f4c4dcf4SKowalski, Kamil * 1437f4c4dcf4SKowalski, Kamil * See header file for more information 1438f4c4dcf4SKowalski, Kamil * @endinternal 1439f4c4dcf4SKowalski, Kamil */ 1440b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void) 14411abe55efSEd Tanous { 1442fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::sessionLimitExceeded, {}); 1443b5c07418SJames Feist } 1444b5c07418SJames Feist 1445b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res) 1446b5c07418SJames Feist { 1447b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1448b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, sessionLimitExceeded()); 1449f4c4dcf4SKowalski, Kamil } 1450f4c4dcf4SKowalski, Kamil 1451f4c4dcf4SKowalski, Kamil /** 1452f4c4dcf4SKowalski, Kamil * @internal 1453f4c4dcf4SKowalski, Kamil * @brief Formats ActionNotSupported message into JSON 1454f4c4dcf4SKowalski, Kamil * 1455f4c4dcf4SKowalski, Kamil * See header file for more information 1456f4c4dcf4SKowalski, Kamil * @endinternal 1457f4c4dcf4SKowalski, Kamil */ 14581668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1) 14591abe55efSEd Tanous { 1460fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionNotSupported, 14611668ce6dSEd Tanous std::to_array({arg1})); 1462b5c07418SJames Feist } 1463b5c07418SJames Feist 14641668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1) 1465b5c07418SJames Feist { 1466b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1467b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1)); 1468f4c4dcf4SKowalski, Kamil } 1469f4c4dcf4SKowalski, Kamil 1470f4c4dcf4SKowalski, Kamil /** 1471f4c4dcf4SKowalski, Kamil * @internal 1472f4c4dcf4SKowalski, Kamil * @brief Formats InvalidIndex message into JSON 1473f4c4dcf4SKowalski, Kamil * 1474f4c4dcf4SKowalski, Kamil * See header file for more information 1475f4c4dcf4SKowalski, Kamil * @endinternal 1476f4c4dcf4SKowalski, Kamil */ 14775187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1) 14781abe55efSEd Tanous { 1479b6cd31e1SEd Tanous std::string arg1Str = std::to_string(arg1); 1480fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::invalidIndex, 14811668ce6dSEd Tanous std::to_array<std::string_view>({arg1Str})); 1482b5c07418SJames Feist } 1483b5c07418SJames Feist 14845187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1) 1485b5c07418SJames Feist { 1486b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1487b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidIndex(arg1)); 1488f4c4dcf4SKowalski, Kamil } 1489f4c4dcf4SKowalski, Kamil 1490f4c4dcf4SKowalski, Kamil /** 1491f4c4dcf4SKowalski, Kamil * @internal 1492f4c4dcf4SKowalski, Kamil * @brief Formats EmptyJSON message into JSON 1493f4c4dcf4SKowalski, Kamil * 1494f4c4dcf4SKowalski, Kamil * See header file for more information 1495f4c4dcf4SKowalski, Kamil * @endinternal 1496f4c4dcf4SKowalski, Kamil */ 1497b5c07418SJames Feist nlohmann::json emptyJSON(void) 14981abe55efSEd Tanous { 1499fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::emptyJSON, {}); 1500b5c07418SJames Feist } 1501b5c07418SJames Feist 1502b5c07418SJames Feist void emptyJSON(crow::Response& res) 1503b5c07418SJames Feist { 1504b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1505b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, emptyJSON()); 1506f4c4dcf4SKowalski, Kamil } 1507f4c4dcf4SKowalski, Kamil 1508f4c4dcf4SKowalski, Kamil /** 1509f4c4dcf4SKowalski, Kamil * @internal 1510f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupportedOnResource message into JSON 1511f4c4dcf4SKowalski, Kamil * 1512f4c4dcf4SKowalski, Kamil * See header file for more information 1513f4c4dcf4SKowalski, Kamil * @endinternal 1514f4c4dcf4SKowalski, Kamil */ 1515b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void) 15161abe55efSEd Tanous { 1517fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryNotSupportedOnResource, 1518b6cd31e1SEd Tanous {}); 1519b5c07418SJames Feist } 1520b5c07418SJames Feist 1521b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res) 1522b5c07418SJames Feist { 15236a409c12SEd Tanous res.result(boost::beast::http::status::bad_request); 1524b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource()); 1525f4c4dcf4SKowalski, Kamil } 1526f4c4dcf4SKowalski, Kamil 1527f4c4dcf4SKowalski, Kamil /** 1528f4c4dcf4SKowalski, Kamil * @internal 1529684bb4b8SJason M. Bills * @brief Formats QueryNotSupportedOnOperation message into JSON 1530684bb4b8SJason M. Bills * 1531684bb4b8SJason M. Bills * See header file for more information 1532684bb4b8SJason M. Bills * @endinternal 1533684bb4b8SJason M. Bills */ 1534684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void) 1535684bb4b8SJason M. Bills { 1536b6cd31e1SEd Tanous return getLog( 1537fffb8c1fSEd Tanous redfish::registries::base::Index::queryNotSupportedOnOperation, {}); 1538684bb4b8SJason M. Bills } 1539684bb4b8SJason M. Bills 1540684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res) 1541684bb4b8SJason M. Bills { 15426a409c12SEd Tanous res.result(boost::beast::http::status::bad_request); 1543684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation()); 1544684bb4b8SJason M. Bills } 1545684bb4b8SJason M. Bills 1546684bb4b8SJason M. Bills /** 1547684bb4b8SJason M. Bills * @internal 1548684bb4b8SJason M. Bills * @brief Formats QueryCombinationInvalid message into JSON 1549684bb4b8SJason M. Bills * 1550684bb4b8SJason M. Bills * See header file for more information 1551684bb4b8SJason M. Bills * @endinternal 1552684bb4b8SJason M. Bills */ 1553684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void) 1554684bb4b8SJason M. Bills { 1555fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryCombinationInvalid, 1556fffb8c1fSEd Tanous {}); 1557684bb4b8SJason M. Bills } 1558684bb4b8SJason M. Bills 1559684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res) 1560684bb4b8SJason M. Bills { 1561684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 1562684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, queryCombinationInvalid()); 1563684bb4b8SJason M. Bills } 1564684bb4b8SJason M. Bills 1565684bb4b8SJason M. Bills /** 1566684bb4b8SJason M. Bills * @internal 1567f4c4dcf4SKowalski, Kamil * @brief Formats InsufficientPrivilege message into JSON 1568f4c4dcf4SKowalski, Kamil * 1569f4c4dcf4SKowalski, Kamil * See header file for more information 1570f4c4dcf4SKowalski, Kamil * @endinternal 1571f4c4dcf4SKowalski, Kamil */ 1572b5c07418SJames Feist nlohmann::json insufficientPrivilege(void) 15731abe55efSEd Tanous { 1574fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::insufficientPrivilege, {}); 1575b5c07418SJames Feist } 1576b5c07418SJames Feist 1577b5c07418SJames Feist void insufficientPrivilege(crow::Response& res) 1578b5c07418SJames Feist { 1579b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1580b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, insufficientPrivilege()); 1581f4c4dcf4SKowalski, Kamil } 1582f4c4dcf4SKowalski, Kamil 1583f4c4dcf4SKowalski, Kamil /** 1584f4c4dcf4SKowalski, Kamil * @internal 1585f4c4dcf4SKowalski, Kamil * @brief Formats PropertyValueModified message into JSON 1586f4c4dcf4SKowalski, Kamil * 1587f4c4dcf4SKowalski, Kamil * See header file for more information 1588f4c4dcf4SKowalski, Kamil * @endinternal 1589f4c4dcf4SKowalski, Kamil */ 15901668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1, 15911668ce6dSEd Tanous std::string_view arg2) 1592b5c07418SJames Feist { 1593fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueModified, 15941668ce6dSEd Tanous std::to_array({arg1, arg2})); 1595b5c07418SJames Feist } 1596b5c07418SJames Feist 15971668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1, 15981668ce6dSEd Tanous std::string_view arg2) 15991abe55efSEd Tanous { 1600f12894f8SJason M. Bills res.result(boost::beast::http::status::ok); 1601b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1); 1602f4c4dcf4SKowalski, Kamil } 1603f4c4dcf4SKowalski, Kamil 1604f4c4dcf4SKowalski, Kamil /** 1605f4c4dcf4SKowalski, Kamil * @internal 1606f4c4dcf4SKowalski, Kamil * @brief Formats AccountNotModified message into JSON 1607f4c4dcf4SKowalski, Kamil * 1608f4c4dcf4SKowalski, Kamil * See header file for more information 1609f4c4dcf4SKowalski, Kamil * @endinternal 1610f4c4dcf4SKowalski, Kamil */ 1611b5c07418SJames Feist nlohmann::json accountNotModified(void) 16121abe55efSEd Tanous { 1613fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountNotModified, {}); 1614b5c07418SJames Feist } 1615b5c07418SJames Feist 1616b5c07418SJames Feist void accountNotModified(crow::Response& res) 1617b5c07418SJames Feist { 1618b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1619b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountNotModified()); 1620f4c4dcf4SKowalski, Kamil } 1621f4c4dcf4SKowalski, Kamil 1622f4c4dcf4SKowalski, Kamil /** 1623f4c4dcf4SKowalski, Kamil * @internal 1624f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueFormatError message into JSON 1625f4c4dcf4SKowalski, Kamil * 1626f4c4dcf4SKowalski, Kamil * See header file for more information 1627f4c4dcf4SKowalski, Kamil * @endinternal 1628f4c4dcf4SKowalski, Kamil */ 16291668ce6dSEd Tanous nlohmann::json queryParameterValueFormatError(std::string_view arg1, 16301668ce6dSEd Tanous std::string_view arg2) 16311abe55efSEd Tanous { 1632fffb8c1fSEd Tanous return getLog( 1633fffb8c1fSEd Tanous redfish::registries::base::Index::queryParameterValueFormatError, 16341668ce6dSEd Tanous std::to_array({arg1, arg2})); 1635b5c07418SJames Feist } 1636b5c07418SJames Feist 16371668ce6dSEd Tanous void queryParameterValueFormatError(crow::Response& res, std::string_view arg1, 16381668ce6dSEd Tanous std::string_view arg2) 1639b5c07418SJames Feist { 1640b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1641b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1642b5c07418SJames Feist queryParameterValueFormatError(arg1, arg2)); 1643f4c4dcf4SKowalski, Kamil } 1644f4c4dcf4SKowalski, Kamil 1645f4c4dcf4SKowalski, Kamil /** 1646f4c4dcf4SKowalski, Kamil * @internal 1647b5c07418SJames Feist * @brief Formats PropertyMissing message into JSON for the specified 1648b5c07418SJames Feist * property 1649f12894f8SJason M. Bills * 1650f12894f8SJason M. Bills * See header file for more information 1651f12894f8SJason M. Bills * @endinternal 1652f12894f8SJason M. Bills */ 16531668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1) 1654f12894f8SJason M. Bills { 1655fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyMissing, 16561668ce6dSEd Tanous std::to_array({arg1})); 1657b5c07418SJames Feist } 1658b5c07418SJames Feist 16591668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1) 1660b5c07418SJames Feist { 1661b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1662b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1); 1663f4c4dcf4SKowalski, Kamil } 1664f4c4dcf4SKowalski, Kamil 1665f4c4dcf4SKowalski, Kamil /** 1666f4c4dcf4SKowalski, Kamil * @internal 1667f4c4dcf4SKowalski, Kamil * @brief Formats ResourceExhaustion message into JSON 1668f4c4dcf4SKowalski, Kamil * 1669f4c4dcf4SKowalski, Kamil * See header file for more information 1670f4c4dcf4SKowalski, Kamil * @endinternal 1671f4c4dcf4SKowalski, Kamil */ 16721668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1) 16731abe55efSEd Tanous { 1674fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceExhaustion, 16751668ce6dSEd Tanous std::to_array({arg1})); 1676b5c07418SJames Feist } 1677b5c07418SJames Feist 16781668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1) 1679b5c07418SJames Feist { 1680b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1681b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1)); 1682f4c4dcf4SKowalski, Kamil } 1683f4c4dcf4SKowalski, Kamil 1684f4c4dcf4SKowalski, Kamil /** 1685f4c4dcf4SKowalski, Kamil * @internal 1686f4c4dcf4SKowalski, Kamil * @brief Formats AccountModified message into JSON 1687f4c4dcf4SKowalski, Kamil * 1688f4c4dcf4SKowalski, Kamil * See header file for more information 1689f4c4dcf4SKowalski, Kamil * @endinternal 1690f4c4dcf4SKowalski, Kamil */ 1691b5c07418SJames Feist nlohmann::json accountModified(void) 16921abe55efSEd Tanous { 1693fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountModified, {}); 1694b5c07418SJames Feist } 1695b5c07418SJames Feist 1696b5c07418SJames Feist void accountModified(crow::Response& res) 1697b5c07418SJames Feist { 1698b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1699b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountModified()); 1700f4c4dcf4SKowalski, Kamil } 1701f4c4dcf4SKowalski, Kamil 1702f4c4dcf4SKowalski, Kamil /** 1703f4c4dcf4SKowalski, Kamil * @internal 1704f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterOutOfRange message into JSON 1705f4c4dcf4SKowalski, Kamil * 1706f4c4dcf4SKowalski, Kamil * See header file for more information 1707f4c4dcf4SKowalski, Kamil * @endinternal 1708f4c4dcf4SKowalski, Kamil */ 17091668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1, 17101668ce6dSEd Tanous std::string_view arg2, 17111668ce6dSEd Tanous std::string_view arg3) 17121abe55efSEd Tanous { 1713fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryParameterOutOfRange, 17141668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 1715b5c07418SJames Feist } 1716b5c07418SJames Feist 17171668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1, 17181668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 1719b5c07418SJames Feist { 1720b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1721b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1722b5c07418SJames Feist queryParameterOutOfRange(arg1, arg2, arg3)); 1723f4c4dcf4SKowalski, Kamil } 1724f4c4dcf4SKowalski, Kamil 1725d9f466b3SEd Tanous nlohmann::json passwordChangeRequired(boost::urls::url_view arg1) 1726b6cd31e1SEd Tanous { 1727fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::passwordChangeRequired, 1728079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1729b6cd31e1SEd Tanous } 1730b6cd31e1SEd Tanous 17313bf4e632SJoseph Reynolds /** 17323bf4e632SJoseph Reynolds * @internal 17333bf4e632SJoseph Reynolds * @brief Formats PasswordChangeRequired message into JSON 17343bf4e632SJoseph Reynolds * 17353bf4e632SJoseph Reynolds * See header file for more information 17363bf4e632SJoseph Reynolds * @endinternal 17373bf4e632SJoseph Reynolds */ 1738d9f466b3SEd Tanous void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1) 17393bf4e632SJoseph Reynolds { 1740b6cd31e1SEd Tanous messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1)); 17413bf4e632SJoseph Reynolds } 17423bf4e632SJoseph Reynolds 17434cde5d90SJames Feist /** 17444cde5d90SJames Feist * @internal 1745ae688313SNan Zhou * @brief Formats InsufficientStorage message into JSON 1746ae688313SNan Zhou * 1747ae688313SNan Zhou * See header file for more information 1748ae688313SNan Zhou * @endinternal 1749ae688313SNan Zhou */ 1750ae688313SNan Zhou nlohmann::json insufficientStorage() 1751ae688313SNan Zhou { 1752ae688313SNan Zhou return getLog(redfish::registries::base::Index::insufficientStorage, {}); 1753ae688313SNan Zhou } 1754ae688313SNan Zhou 1755ae688313SNan Zhou void insufficientStorage(crow::Response& res) 1756ae688313SNan Zhou { 1757ae688313SNan Zhou res.result(boost::beast::http::status::insufficient_storage); 1758ae688313SNan Zhou addMessageToErrorJson(res.jsonValue, insufficientStorage()); 1759ae688313SNan Zhou } 1760ae688313SNan Zhou 1761ae688313SNan Zhou /** 1762ae688313SNan Zhou * @internal 176344c70412SEd Tanous * @brief Formats OperationNotAllowed message into JSON 176444c70412SEd Tanous * 176544c70412SEd Tanous * See header file for more information 176644c70412SEd Tanous * @endinternal 176744c70412SEd Tanous */ 176844c70412SEd Tanous nlohmann::json operationNotAllowed() 176944c70412SEd Tanous { 177044c70412SEd Tanous return getLog(redfish::registries::base::Index::operationNotAllowed, {}); 177144c70412SEd Tanous } 177244c70412SEd Tanous 177344c70412SEd Tanous void operationNotAllowed(crow::Response& res) 177444c70412SEd Tanous { 177544c70412SEd Tanous res.result(boost::beast::http::status::method_not_allowed); 177644c70412SEd Tanous addMessageToErrorJson(res.jsonValue, operationNotAllowed()); 177744c70412SEd Tanous } 177844c70412SEd Tanous 1779600af5f1SAppaRao Puli /** 1780600af5f1SAppaRao Puli * @internal 1781600af5f1SAppaRao Puli * @brief Formats ArraySizeTooLong message into JSON 1782600af5f1SAppaRao Puli * 1783600af5f1SAppaRao Puli * See header file for more information 1784600af5f1SAppaRao Puli * @endinternal 1785600af5f1SAppaRao Puli */ 1786600af5f1SAppaRao Puli nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length) 1787600af5f1SAppaRao Puli { 1788600af5f1SAppaRao Puli std::string valStr = std::to_string(length); 1789600af5f1SAppaRao Puli return getLog(redfish::registries::base::Index::arraySizeTooLong, 1790600af5f1SAppaRao Puli std::to_array<std::string_view>({property, valStr})); 1791600af5f1SAppaRao Puli } 1792600af5f1SAppaRao Puli 1793600af5f1SAppaRao Puli void arraySizeTooLong(crow::Response& res, std::string_view property, 1794600af5f1SAppaRao Puli uint64_t length) 1795600af5f1SAppaRao Puli { 1796600af5f1SAppaRao Puli res.result(boost::beast::http::status::method_not_allowed); 1797600af5f1SAppaRao Puli addMessageToErrorJson(res.jsonValue, arraySizeTooLong(property, length)); 1798600af5f1SAppaRao Puli } 1799600af5f1SAppaRao Puli 180044c70412SEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1, 180144c70412SEd Tanous std::string_view arg2) 180244c70412SEd Tanous { 180344c70412SEd Tanous res.result(boost::beast::http::status::bad_request); 180444c70412SEd Tanous addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2)); 180544c70412SEd Tanous } 180644c70412SEd Tanous 180744c70412SEd Tanous /** 180844c70412SEd Tanous * @internal 18094cde5d90SJames Feist * @brief Formats Invalid File message into JSON 18104cde5d90SJames Feist * 18114cde5d90SJames Feist * See header file for more information 18124cde5d90SJames Feist * @endinternal 18134cde5d90SJames Feist */ 18141668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2) 18154cde5d90SJames Feist { 18161668ce6dSEd Tanous std::string msg = "Invalid file uploaded to "; 18171668ce6dSEd Tanous msg += arg1; 18181668ce6dSEd Tanous msg += ": "; 18191668ce6dSEd Tanous msg += arg2; 18201668ce6dSEd Tanous msg += "."; 1821613dabeaSEd Tanous 1822613dabeaSEd Tanous nlohmann::json::object_t ret; 1823613dabeaSEd Tanous ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message"; 1824613dabeaSEd Tanous ret["MessageId"] = "OpenBMC.0.2.InvalidUpload"; 1825613dabeaSEd Tanous ret["Message"] = std::move(msg); 1826613dabeaSEd Tanous nlohmann::json::array_t args; 1827ad539545SPatrick Williams args.emplace_back(arg1); 1828ad539545SPatrick Williams args.emplace_back(arg2); 1829613dabeaSEd Tanous ret["MessageArgs"] = std::move(args); 1830613dabeaSEd Tanous ret["MessageSeverity"] = "Warning"; 1831613dabeaSEd Tanous ret["Resolution"] = "None."; 1832613dabeaSEd Tanous return ret; 18334cde5d90SJames Feist } 1834ae688313SNan Zhou 1835f4c4dcf4SKowalski, Kamil } // namespace messages 1836f4c4dcf4SKowalski, Kamil 1837d425c6f6SEd Tanous } // namespace redfish 1838