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 230442ef92SNan Zhou #include <boost/beast/http/field.hpp> 249ea15c35SEd Tanous #include <boost/beast/http/status.hpp> 25*4a7fbefdSEd Tanous #include <boost/url/url_view_base.hpp> 26faf100f9SEd Tanous #include <nlohmann/json.hpp> 27f4c4dcf4SKowalski, Kamil 281668ce6dSEd Tanous #include <array> 290442ef92SNan Zhou #include <cstddef> 30f0b59af4SEd Tanous #include <cstdint> 31d85418e3SPatrick Williams #include <source_location> 320442ef92SNan Zhou #include <span> 330442ef92SNan Zhou #include <string> 34f0b59af4SEd Tanous #include <string_view> 350442ef92SNan Zhou #include <utility> 360442ef92SNan Zhou 370442ef92SNan Zhou // IWYU pragma: no_include <stddef.h> 381668ce6dSEd Tanous 391abe55efSEd Tanous namespace redfish 401abe55efSEd Tanous { 411abe55efSEd Tanous 421abe55efSEd Tanous namespace messages 431abe55efSEd Tanous { 44f4c4dcf4SKowalski, Kamil 45f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target, 461abe55efSEd Tanous const nlohmann::json& message) 471abe55efSEd Tanous { 48f4c4dcf4SKowalski, Kamil auto& error = target["error"]; 49f4c4dcf4SKowalski, Kamil 501abe55efSEd Tanous // If this is the first error message, fill in the information from the 511abe55efSEd Tanous // first error message to the top level struct 521abe55efSEd Tanous if (!error.is_object()) 531abe55efSEd Tanous { 54c074230bSJason M. Bills auto messageIdIterator = message.find("MessageId"); 55c074230bSJason M. Bills if (messageIdIterator == message.end()) 561abe55efSEd Tanous { 5762598e31SEd Tanous BMCWEB_LOG_CRITICAL( 5862598e31SEd Tanous "Attempt to add error message without MessageId"); 59f4c4dcf4SKowalski, Kamil return; 60f4c4dcf4SKowalski, Kamil } 61f4c4dcf4SKowalski, Kamil 62c074230bSJason M. Bills auto messageFieldIterator = message.find("Message"); 63c074230bSJason M. Bills if (messageFieldIterator == message.end()) 641abe55efSEd Tanous { 6562598e31SEd Tanous BMCWEB_LOG_CRITICAL("Attempt to add error message without Message"); 66f4c4dcf4SKowalski, Kamil return; 67f4c4dcf4SKowalski, Kamil } 681476687dSEd Tanous error["code"] = *messageIdIterator; 691476687dSEd Tanous error["message"] = *messageFieldIterator; 701abe55efSEd Tanous } 711abe55efSEd Tanous else 721abe55efSEd Tanous { 73f4c4dcf4SKowalski, Kamil // More than 1 error occurred, so the message has to be generic 7455c7b7a2SEd Tanous error["code"] = std::string(messageVersionPrefix) + "GeneralError"; 75cc9139ecSJason M. Bills error["message"] = "A general error has occurred. See Resolution for " 76cc9139ecSJason M. Bills "information on how to resolve the error."; 77f4c4dcf4SKowalski, Kamil } 78f4c4dcf4SKowalski, Kamil 793590bd1dSNan Zhou // This check could technically be done in the default construction 80f4c4dcf4SKowalski, Kamil // branch above, but because we need the pointer to the extended info field 81f4c4dcf4SKowalski, Kamil // anyway, it's more efficient to do it here. 82c074230bSJason M. Bills auto& extendedInfo = error[messages::messageAnnotation]; 83c074230bSJason M. Bills if (!extendedInfo.is_array()) 841abe55efSEd Tanous { 85c074230bSJason M. Bills extendedInfo = nlohmann::json::array(); 86f4c4dcf4SKowalski, Kamil } 87f4c4dcf4SKowalski, Kamil 88c074230bSJason M. Bills extendedInfo.push_back(message); 89f4c4dcf4SKowalski, Kamil } 90f4c4dcf4SKowalski, Kamil 913590bd1dSNan Zhou void moveErrorsToErrorJson(nlohmann::json& target, nlohmann::json& source) 923590bd1dSNan Zhou { 933590bd1dSNan Zhou if (!source.is_object()) 943590bd1dSNan Zhou { 953590bd1dSNan Zhou return; 963590bd1dSNan Zhou } 973590bd1dSNan Zhou auto errorIt = source.find("error"); 983590bd1dSNan Zhou if (errorIt == source.end()) 993590bd1dSNan Zhou { 1003590bd1dSNan Zhou // caller puts error message in root 1013590bd1dSNan Zhou messages::addMessageToErrorJson(target, source); 1023590bd1dSNan Zhou source.clear(); 1033590bd1dSNan Zhou return; 1043590bd1dSNan Zhou } 1053590bd1dSNan Zhou auto extendedInfoIt = errorIt->find(messages::messageAnnotation); 1063590bd1dSNan Zhou if (extendedInfoIt == errorIt->end()) 1073590bd1dSNan Zhou { 1083590bd1dSNan Zhou return; 1093590bd1dSNan Zhou } 1103590bd1dSNan Zhou const nlohmann::json::array_t* extendedInfo = 1113590bd1dSNan Zhou (*extendedInfoIt).get_ptr<const nlohmann::json::array_t*>(); 1123590bd1dSNan Zhou if (extendedInfo == nullptr) 1133590bd1dSNan Zhou { 1143590bd1dSNan Zhou source.erase(errorIt); 1153590bd1dSNan Zhou return; 1163590bd1dSNan Zhou } 1173590bd1dSNan Zhou for (const nlohmann::json& message : *extendedInfo) 1183590bd1dSNan Zhou { 1193590bd1dSNan Zhou addMessageToErrorJson(target, message); 1203590bd1dSNan Zhou } 1213590bd1dSNan Zhou source.erase(errorIt); 1223590bd1dSNan Zhou } 1233590bd1dSNan Zhou 124f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target, 125f12894f8SJason M. Bills const nlohmann::json& message) 1261abe55efSEd Tanous { 1271abe55efSEd Tanous if (!target[messages::messageAnnotation].is_array()) 1281abe55efSEd Tanous { 129f4c4dcf4SKowalski, Kamil // Force object to be an array 13055c7b7a2SEd Tanous target[messages::messageAnnotation] = nlohmann::json::array(); 131f4c4dcf4SKowalski, Kamil } 132f4c4dcf4SKowalski, Kamil 13355c7b7a2SEd Tanous target[messages::messageAnnotation].push_back(message); 134f4c4dcf4SKowalski, Kamil } 135f4c4dcf4SKowalski, Kamil 136f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target, 137f12894f8SJason M. Bills const nlohmann::json& message, 1381668ce6dSEd Tanous std::string_view fieldPath) 1391abe55efSEd Tanous { 1401668ce6dSEd Tanous std::string extendedInfo(fieldPath); 1411668ce6dSEd Tanous extendedInfo += messages::messageAnnotation; 142f4c4dcf4SKowalski, Kamil 1431668ce6dSEd Tanous nlohmann::json& field = target[extendedInfo]; 1441668ce6dSEd Tanous if (!field.is_array()) 1451abe55efSEd Tanous { 146f4c4dcf4SKowalski, Kamil // Force object to be an array 1471668ce6dSEd Tanous field = nlohmann::json::array(); 148f4c4dcf4SKowalski, Kamil } 149f4c4dcf4SKowalski, Kamil 150f4c4dcf4SKowalski, Kamil // Object exists and it is an array so we can just push in the message 1511668ce6dSEd Tanous field.push_back(message); 152f4c4dcf4SKowalski, Kamil } 153f4c4dcf4SKowalski, Kamil 154f7725d79SEd Tanous static nlohmann::json getLog(redfish::registries::base::Index name, 155b6cd31e1SEd Tanous std::span<const std::string_view> args) 156b6cd31e1SEd Tanous { 157b6cd31e1SEd Tanous size_t index = static_cast<size_t>(name); 158fffb8c1fSEd Tanous if (index >= redfish::registries::base::registry.size()) 159b6cd31e1SEd Tanous { 160b6cd31e1SEd Tanous return {}; 161b6cd31e1SEd Tanous } 16265e4f1f7SEd Tanous return getLogFromRegistry(redfish::registries::base::header, 16365e4f1f7SEd Tanous redfish::registries::base::registry, index, args); 164b6cd31e1SEd Tanous } 165b6cd31e1SEd Tanous 166f4c4dcf4SKowalski, Kamil /** 167f4c4dcf4SKowalski, Kamil * @internal 168f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInUse message into JSON 169f4c4dcf4SKowalski, Kamil * 170f4c4dcf4SKowalski, Kamil * See header file for more information 171f4c4dcf4SKowalski, Kamil * @endinternal 172f4c4dcf4SKowalski, Kamil */ 173d9fcfcc1SEd Tanous nlohmann::json resourceInUse() 1741abe55efSEd Tanous { 175fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceInUse, {}); 176b5c07418SJames Feist } 177b5c07418SJames Feist 178b5c07418SJames Feist void resourceInUse(crow::Response& res) 179b5c07418SJames Feist { 180b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 181b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInUse()); 182f4c4dcf4SKowalski, Kamil } 183f4c4dcf4SKowalski, Kamil 184f4c4dcf4SKowalski, Kamil /** 185f4c4dcf4SKowalski, Kamil * @internal 186f4c4dcf4SKowalski, Kamil * @brief Formats MalformedJSON message into JSON 187f4c4dcf4SKowalski, Kamil * 188f4c4dcf4SKowalski, Kamil * See header file for more information 189f4c4dcf4SKowalski, Kamil * @endinternal 190f4c4dcf4SKowalski, Kamil */ 191d9fcfcc1SEd Tanous nlohmann::json malformedJSON() 1921abe55efSEd Tanous { 193fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::malformedJSON, {}); 194b5c07418SJames Feist } 195b5c07418SJames Feist 196b5c07418SJames Feist void malformedJSON(crow::Response& res) 197b5c07418SJames Feist { 198b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 199b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, malformedJSON()); 200f4c4dcf4SKowalski, Kamil } 201f4c4dcf4SKowalski, Kamil 202f4c4dcf4SKowalski, Kamil /** 203f4c4dcf4SKowalski, Kamil * @internal 204f4c4dcf4SKowalski, Kamil * @brief Formats ResourceMissingAtURI message into JSON 205f4c4dcf4SKowalski, Kamil * 206f4c4dcf4SKowalski, Kamil * See header file for more information 207f4c4dcf4SKowalski, Kamil * @endinternal 208f4c4dcf4SKowalski, Kamil */ 209*4a7fbefdSEd Tanous nlohmann::json resourceMissingAtURI(const boost::urls::url_view_base& arg1) 2101abe55efSEd Tanous { 211079360aeSEd Tanous std::array<std::string_view, 1> args{arg1.buffer()}; 212fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceMissingAtURI, args); 213b5c07418SJames Feist } 214b5c07418SJames Feist 215*4a7fbefdSEd Tanous void resourceMissingAtURI(crow::Response& res, 216*4a7fbefdSEd Tanous const boost::urls::url_view_base& arg1) 217b5c07418SJames Feist { 218b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 219b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1)); 220f4c4dcf4SKowalski, Kamil } 221f4c4dcf4SKowalski, Kamil 222f4c4dcf4SKowalski, Kamil /** 223f4c4dcf4SKowalski, Kamil * @internal 224f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueFormatError message into JSON 225f4c4dcf4SKowalski, Kamil * 226f4c4dcf4SKowalski, Kamil * See header file for more information 227f4c4dcf4SKowalski, Kamil * @endinternal 228f4c4dcf4SKowalski, Kamil */ 22995b3ad73SEd Tanous nlohmann::json actionParameterValueFormatError(const nlohmann::json& arg1, 2301668ce6dSEd Tanous std::string_view arg2, 2311668ce6dSEd Tanous std::string_view arg3) 2321abe55efSEd Tanous { 23395b3ad73SEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 23495b3ad73SEd Tanous nlohmann::json::error_handler_t::replace); 235fffb8c1fSEd Tanous return getLog( 236fffb8c1fSEd Tanous redfish::registries::base::Index::actionParameterValueFormatError, 23795b3ad73SEd Tanous std::to_array<std::string_view>({arg1Str, arg2, arg3})); 238b5c07418SJames Feist } 239b5c07418SJames Feist 24095b3ad73SEd Tanous void actionParameterValueFormatError(crow::Response& res, 24195b3ad73SEd Tanous const nlohmann::json& arg1, 2421668ce6dSEd Tanous std::string_view arg2, 2431668ce6dSEd Tanous std::string_view arg3) 244b5c07418SJames Feist { 245b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 246b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 247b5c07418SJames Feist actionParameterValueFormatError(arg1, arg2, arg3)); 248f4c4dcf4SKowalski, Kamil } 249f4c4dcf4SKowalski, Kamil 250f4c4dcf4SKowalski, Kamil /** 251f4c4dcf4SKowalski, Kamil * @internal 2524ef82a15SAlex Schendel * @brief Formats ActionParameterValueNotInList message into JSON 2534ef82a15SAlex Schendel * 2544ef82a15SAlex Schendel * See header file for more information 2554ef82a15SAlex Schendel * @endinternal 2564ef82a15SAlex Schendel */ 2574ef82a15SAlex Schendel nlohmann::json actionParameterValueNotInList(std::string_view arg1, 2584ef82a15SAlex Schendel std::string_view arg2, 2594ef82a15SAlex Schendel std::string_view arg3) 2604ef82a15SAlex Schendel { 2614ef82a15SAlex Schendel return getLog( 2624ef82a15SAlex Schendel redfish::registries::base::Index::actionParameterValueNotInList, 2634ef82a15SAlex Schendel std::to_array({arg1, arg2, arg3})); 2644ef82a15SAlex Schendel } 2654ef82a15SAlex Schendel 2664ef82a15SAlex Schendel void actionParameterValueNotInList(crow::Response& res, std::string_view arg1, 2674ef82a15SAlex Schendel std::string_view arg2, std::string_view arg3) 2684ef82a15SAlex Schendel { 2694ef82a15SAlex Schendel res.result(boost::beast::http::status::bad_request); 2704ef82a15SAlex Schendel addMessageToErrorJson(res.jsonValue, 2714ef82a15SAlex Schendel actionParameterValueNotInList(arg1, arg2, arg3)); 2724ef82a15SAlex Schendel } 2734ef82a15SAlex Schendel 2744ef82a15SAlex Schendel /** 2754ef82a15SAlex Schendel * @internal 276f4c4dcf4SKowalski, Kamil * @brief Formats InternalError message into JSON 277f4c4dcf4SKowalski, Kamil * 278f4c4dcf4SKowalski, Kamil * See header file for more information 279f4c4dcf4SKowalski, Kamil * @endinternal 280f4c4dcf4SKowalski, Kamil */ 281d9fcfcc1SEd Tanous nlohmann::json internalError() 2821abe55efSEd Tanous { 283fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::internalError, {}); 284b5c07418SJames Feist } 285b5c07418SJames Feist 286d85418e3SPatrick Williams void internalError(crow::Response& res, const std::source_location location) 287b5c07418SJames Feist { 28862598e31SEd Tanous BMCWEB_LOG_CRITICAL("Internal Error {}({}:{}) `{}`: ", location.file_name(), 28962598e31SEd Tanous location.line(), location.column(), 29062598e31SEd Tanous location.function_name()); 291b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 292b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, internalError()); 293f12894f8SJason M. Bills } 294f12894f8SJason M. Bills 295f12894f8SJason M. Bills /** 296f12894f8SJason M. Bills * @internal 297f4c4dcf4SKowalski, Kamil * @brief Formats UnrecognizedRequestBody message into JSON 298f4c4dcf4SKowalski, Kamil * 299f4c4dcf4SKowalski, Kamil * See header file for more information 300f4c4dcf4SKowalski, Kamil * @endinternal 301f4c4dcf4SKowalski, Kamil */ 302d9fcfcc1SEd Tanous nlohmann::json unrecognizedRequestBody() 3031abe55efSEd Tanous { 304fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::unrecognizedRequestBody, 305fffb8c1fSEd Tanous {}); 306b5c07418SJames Feist } 307b5c07418SJames Feist 308b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res) 309b5c07418SJames Feist { 310b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 311b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody()); 312f4c4dcf4SKowalski, Kamil } 313f4c4dcf4SKowalski, Kamil 314f4c4dcf4SKowalski, Kamil /** 315f4c4dcf4SKowalski, Kamil * @internal 316f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriUnauthorized message into JSON 317f4c4dcf4SKowalski, Kamil * 318f4c4dcf4SKowalski, Kamil * See header file for more information 319f4c4dcf4SKowalski, Kamil * @endinternal 320f4c4dcf4SKowalski, Kamil */ 321*4a7fbefdSEd Tanous nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view_base& arg1, 3221668ce6dSEd Tanous std::string_view arg2) 3231abe55efSEd Tanous { 324079360aeSEd Tanous return getLog(redfish::registries::base::Index::resourceAtUriUnauthorized, 325079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer(), arg2})); 326b5c07418SJames Feist } 327b5c07418SJames Feist 328*4a7fbefdSEd Tanous void resourceAtUriUnauthorized(crow::Response& res, 329*4a7fbefdSEd Tanous const boost::urls::url_view_base& arg1, 3301668ce6dSEd Tanous std::string_view arg2) 331b5c07418SJames Feist { 332b5c07418SJames Feist res.result(boost::beast::http::status::unauthorized); 333b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2)); 334f4c4dcf4SKowalski, Kamil } 335f4c4dcf4SKowalski, Kamil 336f4c4dcf4SKowalski, Kamil /** 337f4c4dcf4SKowalski, Kamil * @internal 338f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterUnknown message into JSON 339f4c4dcf4SKowalski, Kamil * 340f4c4dcf4SKowalski, Kamil * See header file for more information 341f4c4dcf4SKowalski, Kamil * @endinternal 342f4c4dcf4SKowalski, Kamil */ 3431668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1, 3441668ce6dSEd Tanous std::string_view arg2) 345b5c07418SJames Feist { 346fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterUnknown, 3471668ce6dSEd Tanous std::to_array({arg1, arg2})); 348b5c07418SJames Feist } 349b5c07418SJames Feist 3501668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1, 3511668ce6dSEd Tanous std::string_view arg2) 3521abe55efSEd Tanous { 353f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 354b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2)); 355f4c4dcf4SKowalski, Kamil } 356f4c4dcf4SKowalski, Kamil 357f4c4dcf4SKowalski, Kamil /** 358f4c4dcf4SKowalski, Kamil * @internal 359f4c4dcf4SKowalski, Kamil * @brief Formats ResourceCannotBeDeleted message into JSON 360f4c4dcf4SKowalski, Kamil * 361f4c4dcf4SKowalski, Kamil * See header file for more information 362f4c4dcf4SKowalski, Kamil * @endinternal 363f4c4dcf4SKowalski, Kamil */ 364d9fcfcc1SEd Tanous nlohmann::json resourceCannotBeDeleted() 3651abe55efSEd Tanous { 366fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceCannotBeDeleted, 367fffb8c1fSEd Tanous {}); 368b5c07418SJames Feist } 369b5c07418SJames Feist 370b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res) 371b5c07418SJames Feist { 37244c70412SEd Tanous res.result(boost::beast::http::status::method_not_allowed); 373b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted()); 374f4c4dcf4SKowalski, Kamil } 375f4c4dcf4SKowalski, Kamil 376f4c4dcf4SKowalski, Kamil /** 377f4c4dcf4SKowalski, Kamil * @internal 378f4c4dcf4SKowalski, Kamil * @brief Formats PropertyDuplicate message into JSON 379f4c4dcf4SKowalski, Kamil * 380f4c4dcf4SKowalski, Kamil * See header file for more information 381f4c4dcf4SKowalski, Kamil * @endinternal 382f4c4dcf4SKowalski, Kamil */ 3831668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1) 3841abe55efSEd Tanous { 385fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyDuplicate, 3861668ce6dSEd Tanous std::to_array({arg1})); 387b5c07418SJames Feist } 388b5c07418SJames Feist 3891668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1) 390b5c07418SJames Feist { 391b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 392b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1); 393f4c4dcf4SKowalski, Kamil } 394f4c4dcf4SKowalski, Kamil 395f4c4dcf4SKowalski, Kamil /** 396f4c4dcf4SKowalski, Kamil * @internal 397f4c4dcf4SKowalski, Kamil * @brief Formats ServiceTemporarilyUnavailable message into JSON 398f4c4dcf4SKowalski, Kamil * 399f4c4dcf4SKowalski, Kamil * See header file for more information 400f4c4dcf4SKowalski, Kamil * @endinternal 401f4c4dcf4SKowalski, Kamil */ 4021668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1) 4031abe55efSEd Tanous { 404b6cd31e1SEd Tanous return getLog( 405fffb8c1fSEd Tanous redfish::registries::base::Index::serviceTemporarilyUnavailable, 4061668ce6dSEd Tanous std::to_array({arg1})); 407b5c07418SJames Feist } 408b5c07418SJames Feist 4091668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1) 410b5c07418SJames Feist { 411d9f6c621SEd Tanous res.addHeader(boost::beast::http::field::retry_after, arg1); 412b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 413b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1)); 414f4c4dcf4SKowalski, Kamil } 415f4c4dcf4SKowalski, Kamil 416f4c4dcf4SKowalski, Kamil /** 417f4c4dcf4SKowalski, Kamil * @internal 418f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAlreadyExists message into JSON 419f4c4dcf4SKowalski, Kamil * 420f4c4dcf4SKowalski, Kamil * See header file for more information 421f4c4dcf4SKowalski, Kamil * @endinternal 422f4c4dcf4SKowalski, Kamil */ 4231668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1, 4241668ce6dSEd Tanous std::string_view arg2, 4251668ce6dSEd Tanous std::string_view arg3) 4261abe55efSEd Tanous { 427fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceAlreadyExists, 4281668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 429b5c07418SJames Feist } 430b5c07418SJames Feist 4311668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1, 4321668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 433b5c07418SJames Feist { 434b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 435b5c07418SJames Feist addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3), 436a08b46ccSJason M. Bills arg2); 437f4c4dcf4SKowalski, Kamil } 438f4c4dcf4SKowalski, Kamil 439f4c4dcf4SKowalski, Kamil /** 440f4c4dcf4SKowalski, Kamil * @internal 441f4c4dcf4SKowalski, Kamil * @brief Formats AccountForSessionNoLongerExists message into JSON 442f4c4dcf4SKowalski, Kamil * 443f4c4dcf4SKowalski, Kamil * See header file for more information 444f4c4dcf4SKowalski, Kamil * @endinternal 445f4c4dcf4SKowalski, Kamil */ 446d9fcfcc1SEd Tanous nlohmann::json accountForSessionNoLongerExists() 4471abe55efSEd Tanous { 448fffb8c1fSEd Tanous return getLog( 449fffb8c1fSEd Tanous redfish::registries::base::Index::accountForSessionNoLongerExists, {}); 450b5c07418SJames Feist } 451b5c07418SJames Feist 452b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res) 453b5c07418SJames Feist { 454b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 455b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists()); 456f4c4dcf4SKowalski, Kamil } 457f4c4dcf4SKowalski, Kamil 458f4c4dcf4SKowalski, Kamil /** 459f4c4dcf4SKowalski, Kamil * @internal 460f4c4dcf4SKowalski, Kamil * @brief Formats CreateFailedMissingReqProperties message into JSON 461f4c4dcf4SKowalski, Kamil * 462f4c4dcf4SKowalski, Kamil * See header file for more information 463f4c4dcf4SKowalski, Kamil * @endinternal 464f4c4dcf4SKowalski, Kamil */ 4651668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1) 4661abe55efSEd Tanous { 467fffb8c1fSEd Tanous return getLog( 468fffb8c1fSEd Tanous redfish::registries::base::Index::createFailedMissingReqProperties, 4691668ce6dSEd Tanous std::to_array({arg1})); 470b5c07418SJames Feist } 471b5c07418SJames Feist 472b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res, 4731668ce6dSEd Tanous std::string_view arg1) 474b5c07418SJames Feist { 475b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 476b5c07418SJames Feist addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1), 477a08b46ccSJason M. Bills arg1); 478f12894f8SJason M. Bills } 479f12894f8SJason M. Bills 480f12894f8SJason M. Bills /** 481f12894f8SJason M. Bills * @internal 482f12894f8SJason M. Bills * @brief Formats PropertyValueFormatError message into JSON for the specified 483f12894f8SJason M. Bills * property 484f12894f8SJason M. Bills * 485f12894f8SJason M. Bills * See header file for more information 486f12894f8SJason M. Bills * @endinternal 487f12894f8SJason M. Bills */ 488f818b04dSEd Tanous nlohmann::json propertyValueFormatError(const nlohmann::json& arg1, 4891668ce6dSEd Tanous std::string_view arg2) 490f12894f8SJason M. Bills { 491f818b04dSEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 492f818b04dSEd Tanous nlohmann::json::error_handler_t::replace); 493fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueFormatError, 494f818b04dSEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 495b5c07418SJames Feist } 496b5c07418SJames Feist 497f818b04dSEd Tanous void propertyValueFormatError(crow::Response& res, const nlohmann::json& arg1, 4981668ce6dSEd Tanous std::string_view arg2) 499b5c07418SJames Feist { 500b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 501b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2); 502f12894f8SJason M. Bills } 503f12894f8SJason M. Bills 504f12894f8SJason M. Bills /** 505f12894f8SJason M. Bills * @internal 506f12894f8SJason M. Bills * @brief Formats PropertyValueNotInList message into JSON for the specified 507f12894f8SJason M. Bills * property 508f12894f8SJason M. Bills * 509f12894f8SJason M. Bills * See header file for more information 510f12894f8SJason M. Bills * @endinternal 511f12894f8SJason M. Bills */ 512e2616cc5SEd Tanous 513e2616cc5SEd Tanous nlohmann::json propertyValueNotInList(const nlohmann::json& arg1, 5141668ce6dSEd Tanous std::string_view arg2) 515f12894f8SJason M. Bills { 516e2616cc5SEd Tanous std::string arg1Str = arg1.dump(-1, ' ', true, 517e2616cc5SEd Tanous nlohmann::json::error_handler_t::replace); 518fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueNotInList, 519e2616cc5SEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 520b5c07418SJames Feist } 521b5c07418SJames Feist 522e2616cc5SEd Tanous void propertyValueNotInList(crow::Response& res, const nlohmann::json& arg1, 5231668ce6dSEd Tanous std::string_view arg2) 524b5c07418SJames Feist { 525b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 526b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2); 527f4c4dcf4SKowalski, Kamil } 528f4c4dcf4SKowalski, Kamil 529f4c4dcf4SKowalski, Kamil /** 530f4c4dcf4SKowalski, Kamil * @internal 531227a2b0aSJiaqing Zhao * @brief Formats PropertyValueOutOfRange message into JSON 532227a2b0aSJiaqing Zhao * 533227a2b0aSJiaqing Zhao * See header file for more information 534227a2b0aSJiaqing Zhao * @endinternal 535227a2b0aSJiaqing Zhao */ 53695b3ad73SEd Tanous nlohmann::json propertyValueOutOfRange(const nlohmann::json& arg1, 537227a2b0aSJiaqing Zhao std::string_view arg2) 538227a2b0aSJiaqing Zhao { 53995b3ad73SEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 54095b3ad73SEd Tanous nlohmann::json::error_handler_t::replace); 541227a2b0aSJiaqing Zhao return getLog(redfish::registries::base::Index::propertyValueOutOfRange, 54295b3ad73SEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 543227a2b0aSJiaqing Zhao } 544227a2b0aSJiaqing Zhao 54595b3ad73SEd Tanous void propertyValueOutOfRange(crow::Response& res, const nlohmann::json& arg1, 546227a2b0aSJiaqing Zhao std::string_view arg2) 547227a2b0aSJiaqing Zhao { 548227a2b0aSJiaqing Zhao res.result(boost::beast::http::status::bad_request); 549227a2b0aSJiaqing Zhao addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2)); 550227a2b0aSJiaqing Zhao } 551227a2b0aSJiaqing Zhao 552227a2b0aSJiaqing Zhao /** 553227a2b0aSJiaqing Zhao * @internal 554f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriInUnknownFormat message into JSON 555f4c4dcf4SKowalski, Kamil * 556f4c4dcf4SKowalski, Kamil * See header file for more information 557f4c4dcf4SKowalski, Kamil * @endinternal 558f4c4dcf4SKowalski, Kamil */ 559*4a7fbefdSEd Tanous nlohmann::json 560*4a7fbefdSEd Tanous resourceAtUriInUnknownFormat(const boost::urls::url_view_base& arg1) 5611abe55efSEd Tanous { 562b6cd31e1SEd Tanous return getLog( 563fffb8c1fSEd Tanous redfish::registries::base::Index::resourceAtUriInUnknownFormat, 564079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 565b5c07418SJames Feist } 566b5c07418SJames Feist 567ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res, 568*4a7fbefdSEd Tanous const boost::urls::url_view_base& arg1) 569b5c07418SJames Feist { 570b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 571b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1)); 572f4c4dcf4SKowalski, Kamil } 573f4c4dcf4SKowalski, Kamil 574f4c4dcf4SKowalski, Kamil /** 575f4c4dcf4SKowalski, Kamil * @internal 57681856681SAsmitha Karunanithi * @brief Formats ServiceDisabled message into JSON 57781856681SAsmitha Karunanithi * 57881856681SAsmitha Karunanithi * See header file for more information 57981856681SAsmitha Karunanithi * @endinternal 58081856681SAsmitha Karunanithi */ 5811668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1) 58281856681SAsmitha Karunanithi { 583fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceDisabled, 5841668ce6dSEd Tanous std::to_array({arg1})); 58581856681SAsmitha Karunanithi } 58681856681SAsmitha Karunanithi 5871668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1) 58881856681SAsmitha Karunanithi { 58981856681SAsmitha Karunanithi res.result(boost::beast::http::status::service_unavailable); 59081856681SAsmitha Karunanithi addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1)); 59181856681SAsmitha Karunanithi } 59281856681SAsmitha Karunanithi 59381856681SAsmitha Karunanithi /** 59481856681SAsmitha Karunanithi * @internal 595f4c4dcf4SKowalski, Kamil * @brief Formats ServiceInUnknownState message into JSON 596f4c4dcf4SKowalski, Kamil * 597f4c4dcf4SKowalski, Kamil * See header file for more information 598f4c4dcf4SKowalski, Kamil * @endinternal 599f4c4dcf4SKowalski, Kamil */ 600d9fcfcc1SEd Tanous nlohmann::json serviceInUnknownState() 6011abe55efSEd Tanous { 602fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceInUnknownState, {}); 603b5c07418SJames Feist } 604b5c07418SJames Feist 605b5c07418SJames Feist void serviceInUnknownState(crow::Response& res) 606b5c07418SJames Feist { 607b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 608b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceInUnknownState()); 609f4c4dcf4SKowalski, Kamil } 610f4c4dcf4SKowalski, Kamil 611f4c4dcf4SKowalski, Kamil /** 612f4c4dcf4SKowalski, Kamil * @internal 613f4c4dcf4SKowalski, Kamil * @brief Formats EventSubscriptionLimitExceeded message into JSON 614f4c4dcf4SKowalski, Kamil * 615f4c4dcf4SKowalski, Kamil * See header file for more information 616f4c4dcf4SKowalski, Kamil * @endinternal 617f4c4dcf4SKowalski, Kamil */ 618d9fcfcc1SEd Tanous nlohmann::json eventSubscriptionLimitExceeded() 6191abe55efSEd Tanous { 620fffb8c1fSEd Tanous return getLog( 621fffb8c1fSEd Tanous redfish::registries::base::Index::eventSubscriptionLimitExceeded, {}); 622b5c07418SJames Feist } 623b5c07418SJames Feist 624b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res) 625b5c07418SJames Feist { 626789fdab3SEd Tanous res.result(boost::beast::http::status::service_unavailable); 627b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded()); 628f4c4dcf4SKowalski, Kamil } 629f4c4dcf4SKowalski, Kamil 630f4c4dcf4SKowalski, Kamil /** 631f4c4dcf4SKowalski, Kamil * @internal 632f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterMissing message into JSON 633f4c4dcf4SKowalski, Kamil * 634f4c4dcf4SKowalski, Kamil * See header file for more information 635f4c4dcf4SKowalski, Kamil * @endinternal 636f4c4dcf4SKowalski, Kamil */ 6371668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1, 6381668ce6dSEd Tanous std::string_view arg2) 6391abe55efSEd Tanous { 640fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterMissing, 6411668ce6dSEd Tanous std::to_array({arg1, arg2})); 642b5c07418SJames Feist } 643b5c07418SJames Feist 6441668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1, 6451668ce6dSEd Tanous std::string_view arg2) 646b5c07418SJames Feist { 647b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 648b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2)); 649f4c4dcf4SKowalski, Kamil } 650f4c4dcf4SKowalski, Kamil 651f4c4dcf4SKowalski, Kamil /** 652f4c4dcf4SKowalski, Kamil * @internal 653f4c4dcf4SKowalski, Kamil * @brief Formats StringValueTooLong message into JSON 654f4c4dcf4SKowalski, Kamil * 655f4c4dcf4SKowalski, Kamil * See header file for more information 656f4c4dcf4SKowalski, Kamil * @endinternal 657f4c4dcf4SKowalski, Kamil */ 6581668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2) 6591abe55efSEd Tanous { 660b6cd31e1SEd Tanous std::string arg2String = std::to_string(arg2); 661fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::stringValueTooLong, 6621668ce6dSEd Tanous std::to_array({arg1, std::string_view(arg2String)})); 663b5c07418SJames Feist } 664b5c07418SJames Feist 6651668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2) 666b5c07418SJames Feist { 667b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 668b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2)); 669f4c4dcf4SKowalski, Kamil } 670f4c4dcf4SKowalski, Kamil 671f4c4dcf4SKowalski, Kamil /** 672f4c4dcf4SKowalski, Kamil * @internal 673cc9139ecSJason M. Bills * @brief Formats SessionTerminated message into JSON 674cc9139ecSJason M. Bills * 675cc9139ecSJason M. Bills * See header file for more information 676cc9139ecSJason M. Bills * @endinternal 677cc9139ecSJason M. Bills */ 678d9fcfcc1SEd Tanous nlohmann::json sessionTerminated() 679cc9139ecSJason M. Bills { 680fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::sessionTerminated, {}); 681b5c07418SJames Feist } 682b5c07418SJames Feist 683b5c07418SJames Feist void sessionTerminated(crow::Response& res) 684b5c07418SJames Feist { 685b5c07418SJames Feist res.result(boost::beast::http::status::ok); 686b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, sessionTerminated()); 687cc9139ecSJason M. Bills } 688cc9139ecSJason M. Bills 689cc9139ecSJason M. Bills /** 690cc9139ecSJason M. Bills * @internal 691684bb4b8SJason M. Bills * @brief Formats SubscriptionTerminated message into JSON 692684bb4b8SJason M. Bills * 693684bb4b8SJason M. Bills * See header file for more information 694684bb4b8SJason M. Bills * @endinternal 695684bb4b8SJason M. Bills */ 696d9fcfcc1SEd Tanous nlohmann::json subscriptionTerminated() 697684bb4b8SJason M. Bills { 698fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::subscriptionTerminated, {}); 699684bb4b8SJason M. Bills } 700684bb4b8SJason M. Bills 701684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res) 702684bb4b8SJason M. Bills { 703684bb4b8SJason M. Bills res.result(boost::beast::http::status::ok); 704684bb4b8SJason M. Bills addMessageToJsonRoot(res.jsonValue, subscriptionTerminated()); 705684bb4b8SJason M. Bills } 706684bb4b8SJason M. Bills 707684bb4b8SJason M. Bills /** 708684bb4b8SJason M. Bills * @internal 709cc9139ecSJason M. Bills * @brief Formats ResourceTypeIncompatible message into JSON 710cc9139ecSJason M. Bills * 711cc9139ecSJason M. Bills * See header file for more information 712cc9139ecSJason M. Bills * @endinternal 713cc9139ecSJason M. Bills */ 7141668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1, 7151668ce6dSEd Tanous std::string_view arg2) 716cc9139ecSJason M. Bills { 717fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceTypeIncompatible, 7181668ce6dSEd Tanous std::to_array({arg1, arg2})); 719b5c07418SJames Feist } 720b5c07418SJames Feist 7211668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1, 7221668ce6dSEd Tanous std::string_view arg2) 723b5c07418SJames Feist { 724b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 725b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2)); 726cc9139ecSJason M. Bills } 727cc9139ecSJason M. Bills 728cc9139ecSJason M. Bills /** 729cc9139ecSJason M. Bills * @internal 730684bb4b8SJason M. Bills * @brief Formats ResetRequired message into JSON 731684bb4b8SJason M. Bills * 732684bb4b8SJason M. Bills * See header file for more information 733684bb4b8SJason M. Bills * @endinternal 734684bb4b8SJason M. Bills */ 735*4a7fbefdSEd Tanous nlohmann::json resetRequired(const boost::urls::url_view_base& arg1, 736*4a7fbefdSEd Tanous std::string_view arg2) 737684bb4b8SJason M. Bills { 738fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resetRequired, 739079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer(), arg2})); 740684bb4b8SJason M. Bills } 741684bb4b8SJason M. Bills 742*4a7fbefdSEd Tanous void resetRequired(crow::Response& res, const boost::urls::url_view_base& arg1, 7431668ce6dSEd Tanous std::string_view arg2) 744684bb4b8SJason M. Bills { 745684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 746684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2)); 747684bb4b8SJason M. Bills } 748684bb4b8SJason M. Bills 749684bb4b8SJason M. Bills /** 750684bb4b8SJason M. Bills * @internal 751684bb4b8SJason M. Bills * @brief Formats ChassisPowerStateOnRequired message into JSON 752684bb4b8SJason M. Bills * 753684bb4b8SJason M. Bills * See header file for more information 754684bb4b8SJason M. Bills * @endinternal 755684bb4b8SJason M. Bills */ 7561668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1) 757684bb4b8SJason M. Bills { 758fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resetRequired, 7591668ce6dSEd Tanous std::to_array({arg1})); 760684bb4b8SJason M. Bills } 761684bb4b8SJason M. Bills 7621668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1) 763684bb4b8SJason M. Bills { 764684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 765684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1)); 766684bb4b8SJason M. Bills } 767684bb4b8SJason M. Bills 768684bb4b8SJason M. Bills /** 769684bb4b8SJason M. Bills * @internal 770684bb4b8SJason M. Bills * @brief Formats ChassisPowerStateOffRequired message into JSON 771684bb4b8SJason M. Bills * 772684bb4b8SJason M. Bills * See header file for more information 773684bb4b8SJason M. Bills * @endinternal 774684bb4b8SJason M. Bills */ 7751668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1) 776684bb4b8SJason M. Bills { 777b6cd31e1SEd Tanous return getLog( 778fffb8c1fSEd Tanous redfish::registries::base::Index::chassisPowerStateOffRequired, 7791668ce6dSEd Tanous std::to_array({arg1})); 780684bb4b8SJason M. Bills } 781684bb4b8SJason M. Bills 7821668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1) 783684bb4b8SJason M. Bills { 784684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 785684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1)); 786684bb4b8SJason M. Bills } 787684bb4b8SJason M. Bills 788684bb4b8SJason M. Bills /** 789684bb4b8SJason M. Bills * @internal 790684bb4b8SJason M. Bills * @brief Formats PropertyValueConflict message into JSON 791684bb4b8SJason M. Bills * 792684bb4b8SJason M. Bills * See header file for more information 793684bb4b8SJason M. Bills * @endinternal 794684bb4b8SJason M. Bills */ 7951668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1, 7961668ce6dSEd Tanous std::string_view arg2) 797684bb4b8SJason M. Bills { 798fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueConflict, 7991668ce6dSEd Tanous std::to_array({arg1, arg2})); 800684bb4b8SJason M. Bills } 801684bb4b8SJason M. Bills 8021668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1, 8031668ce6dSEd Tanous std::string_view arg2) 804684bb4b8SJason M. Bills { 805684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 806684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2)); 807684bb4b8SJason M. Bills } 808684bb4b8SJason M. Bills 809684bb4b8SJason M. Bills /** 810684bb4b8SJason M. Bills * @internal 8112a6af81cSRamesh Iyyar * @brief Formats PropertyValueResourceConflict message into JSON 8122a6af81cSRamesh Iyyar * 8132a6af81cSRamesh Iyyar * See header file for more information 8142a6af81cSRamesh Iyyar * @endinternal 8152a6af81cSRamesh Iyyar */ 816*4a7fbefdSEd Tanous nlohmann::json 817*4a7fbefdSEd Tanous propertyValueResourceConflict(std::string_view arg1, 81895b3ad73SEd Tanous const nlohmann::json& arg2, 819*4a7fbefdSEd Tanous const boost::urls::url_view_base& arg3) 8202a6af81cSRamesh Iyyar { 82195b3ad73SEd Tanous std::string arg2Str = arg2.dump(2, ' ', true, 82295b3ad73SEd Tanous nlohmann::json::error_handler_t::replace); 82395b3ad73SEd Tanous 8242a6af81cSRamesh Iyyar return getLog( 8252a6af81cSRamesh Iyyar redfish::registries::base::Index::propertyValueResourceConflict, 82695b3ad73SEd Tanous std::to_array<std::string_view>({arg1, arg2Str, arg3.buffer()})); 8272a6af81cSRamesh Iyyar } 8282a6af81cSRamesh Iyyar 8292a6af81cSRamesh Iyyar void propertyValueResourceConflict(crow::Response& res, std::string_view arg1, 83095b3ad73SEd Tanous const nlohmann::json& arg2, 831*4a7fbefdSEd Tanous const boost::urls::url_view_base& arg3) 8322a6af81cSRamesh Iyyar { 8332a6af81cSRamesh Iyyar res.result(boost::beast::http::status::conflict); 8342a6af81cSRamesh Iyyar addMessageToErrorJson(res.jsonValue, 8352a6af81cSRamesh Iyyar propertyValueResourceConflict(arg1, arg2, arg3)); 8362a6af81cSRamesh Iyyar } 8372a6af81cSRamesh Iyyar 8382a6af81cSRamesh Iyyar /** 8392a6af81cSRamesh Iyyar * @internal 84024861a28SRamesh Iyyar * @brief Formats PropertyValueExternalConflict message into JSON 84124861a28SRamesh Iyyar * 84224861a28SRamesh Iyyar * See header file for more information 84324861a28SRamesh Iyyar * @endinternal 84424861a28SRamesh Iyyar */ 84524861a28SRamesh Iyyar nlohmann::json propertyValueExternalConflict(std::string_view arg1, 84695b3ad73SEd Tanous const nlohmann::json& arg2) 84724861a28SRamesh Iyyar { 84895b3ad73SEd Tanous std::string arg2Str = arg2.dump(2, ' ', true, 84995b3ad73SEd Tanous nlohmann::json::error_handler_t::replace); 85095b3ad73SEd Tanous 85124861a28SRamesh Iyyar return getLog( 85224861a28SRamesh Iyyar redfish::registries::base::Index::propertyValueExternalConflict, 85395b3ad73SEd Tanous std::to_array<std::string_view>({arg1, arg2Str})); 85424861a28SRamesh Iyyar } 85524861a28SRamesh Iyyar 85624861a28SRamesh Iyyar void propertyValueExternalConflict(crow::Response& res, std::string_view arg1, 85795b3ad73SEd Tanous const nlohmann::json& arg2) 85824861a28SRamesh Iyyar { 85924861a28SRamesh Iyyar res.result(boost::beast::http::status::conflict); 86024861a28SRamesh Iyyar addMessageToErrorJson(res.jsonValue, 86124861a28SRamesh Iyyar propertyValueExternalConflict(arg1, arg2)); 86224861a28SRamesh Iyyar } 86324861a28SRamesh Iyyar 86424861a28SRamesh Iyyar /** 86524861a28SRamesh Iyyar * @internal 866684bb4b8SJason M. Bills * @brief Formats PropertyValueIncorrect message into JSON 867684bb4b8SJason M. Bills * 868684bb4b8SJason M. Bills * See header file for more information 869684bb4b8SJason M. Bills * @endinternal 870684bb4b8SJason M. Bills */ 871367b3dceSGinu George nlohmann::json propertyValueIncorrect(std::string_view arg1, 872367b3dceSGinu George const nlohmann::json& arg2) 873684bb4b8SJason M. Bills { 874367b3dceSGinu George std::string arg2Str = arg2.dump(2, ' ', true, 87514fbced6SEd Tanous nlohmann::json::error_handler_t::replace); 876fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueIncorrect, 877367b3dceSGinu George std::to_array<std::string_view>({arg1, arg2Str})); 878684bb4b8SJason M. Bills } 879684bb4b8SJason M. Bills 880367b3dceSGinu George void propertyValueIncorrect(crow::Response& res, std::string_view arg1, 881367b3dceSGinu George const nlohmann::json& arg2) 882684bb4b8SJason M. Bills { 883684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 884684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2)); 885684bb4b8SJason M. Bills } 886684bb4b8SJason M. Bills 887684bb4b8SJason M. Bills /** 888684bb4b8SJason M. Bills * @internal 889684bb4b8SJason M. Bills * @brief Formats ResourceCreationConflict message into JSON 890684bb4b8SJason M. Bills * 891684bb4b8SJason M. Bills * See header file for more information 892684bb4b8SJason M. Bills * @endinternal 893684bb4b8SJason M. Bills */ 894*4a7fbefdSEd Tanous nlohmann::json resourceCreationConflict(const boost::urls::url_view_base& arg1) 895684bb4b8SJason M. Bills { 896fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceCreationConflict, 897079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 898684bb4b8SJason M. Bills } 899684bb4b8SJason M. Bills 900*4a7fbefdSEd Tanous void resourceCreationConflict(crow::Response& res, 901*4a7fbefdSEd Tanous const boost::urls::url_view_base& arg1) 902684bb4b8SJason M. Bills { 903684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 904684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1)); 905684bb4b8SJason M. Bills } 906684bb4b8SJason M. Bills 907684bb4b8SJason M. Bills /** 908684bb4b8SJason M. Bills * @internal 909684bb4b8SJason M. Bills * @brief Formats MaximumErrorsExceeded message into JSON 910684bb4b8SJason M. Bills * 911684bb4b8SJason M. Bills * See header file for more information 912684bb4b8SJason M. Bills * @endinternal 913684bb4b8SJason M. Bills */ 914d9fcfcc1SEd Tanous nlohmann::json maximumErrorsExceeded() 915684bb4b8SJason M. Bills { 916fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {}); 917684bb4b8SJason M. Bills } 918684bb4b8SJason M. Bills 919684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res) 920684bb4b8SJason M. Bills { 921684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 922684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded()); 923684bb4b8SJason M. Bills } 924684bb4b8SJason M. Bills 925684bb4b8SJason M. Bills /** 926684bb4b8SJason M. Bills * @internal 927684bb4b8SJason M. Bills * @brief Formats PreconditionFailed message into JSON 928684bb4b8SJason M. Bills * 929684bb4b8SJason M. Bills * See header file for more information 930684bb4b8SJason M. Bills * @endinternal 931684bb4b8SJason M. Bills */ 932d9fcfcc1SEd Tanous nlohmann::json preconditionFailed() 933684bb4b8SJason M. Bills { 934fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::preconditionFailed, {}); 935684bb4b8SJason M. Bills } 936684bb4b8SJason M. Bills 937684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res) 938684bb4b8SJason M. Bills { 9394df1bee0SEd Tanous res.result(boost::beast::http::status::precondition_failed); 940684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, preconditionFailed()); 941684bb4b8SJason M. Bills } 942684bb4b8SJason M. Bills 943684bb4b8SJason M. Bills /** 944684bb4b8SJason M. Bills * @internal 945684bb4b8SJason M. Bills * @brief Formats PreconditionRequired message into JSON 946684bb4b8SJason M. Bills * 947684bb4b8SJason M. Bills * See header file for more information 948684bb4b8SJason M. Bills * @endinternal 949684bb4b8SJason M. Bills */ 950d9fcfcc1SEd Tanous nlohmann::json preconditionRequired() 951684bb4b8SJason M. Bills { 952fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::preconditionRequired, {}); 953684bb4b8SJason M. Bills } 954684bb4b8SJason M. Bills 955684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res) 956684bb4b8SJason M. Bills { 957684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 958684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, preconditionRequired()); 959684bb4b8SJason M. Bills } 960684bb4b8SJason M. Bills 961684bb4b8SJason M. Bills /** 962684bb4b8SJason M. Bills * @internal 963684bb4b8SJason M. Bills * @brief Formats OperationFailed message into JSON 964684bb4b8SJason M. Bills * 965684bb4b8SJason M. Bills * See header file for more information 966684bb4b8SJason M. Bills * @endinternal 967684bb4b8SJason M. Bills */ 968d9fcfcc1SEd Tanous nlohmann::json operationFailed() 969684bb4b8SJason M. Bills { 970fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::operationFailed, {}); 971684bb4b8SJason M. Bills } 972684bb4b8SJason M. Bills 973684bb4b8SJason M. Bills void operationFailed(crow::Response& res) 974684bb4b8SJason M. Bills { 9758868776eSEd Tanous res.result(boost::beast::http::status::bad_gateway); 976684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, operationFailed()); 977684bb4b8SJason M. Bills } 978684bb4b8SJason M. Bills 979684bb4b8SJason M. Bills /** 980684bb4b8SJason M. Bills * @internal 981684bb4b8SJason M. Bills * @brief Formats OperationTimeout message into JSON 982684bb4b8SJason M. Bills * 983684bb4b8SJason M. Bills * See header file for more information 984684bb4b8SJason M. Bills * @endinternal 985684bb4b8SJason M. Bills */ 986d9fcfcc1SEd Tanous nlohmann::json operationTimeout() 987684bb4b8SJason M. Bills { 988fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::operationTimeout, {}); 989684bb4b8SJason M. Bills } 990684bb4b8SJason M. Bills 991684bb4b8SJason M. Bills void operationTimeout(crow::Response& res) 992684bb4b8SJason M. Bills { 993684bb4b8SJason M. Bills res.result(boost::beast::http::status::internal_server_error); 994684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, operationTimeout()); 995684bb4b8SJason M. Bills } 996684bb4b8SJason M. Bills 997684bb4b8SJason M. Bills /** 998684bb4b8SJason M. Bills * @internal 999f12894f8SJason M. Bills * @brief Formats PropertyValueTypeError message into JSON for the specified 1000f12894f8SJason M. Bills * property 1001f12894f8SJason M. Bills * 1002f12894f8SJason M. Bills * See header file for more information 1003f12894f8SJason M. Bills * @endinternal 1004f12894f8SJason M. Bills */ 10052e8c4bdaSEd Tanous nlohmann::json propertyValueTypeError(const nlohmann::json& arg1, 10061668ce6dSEd Tanous std::string_view arg2) 1007f12894f8SJason M. Bills { 10082e8c4bdaSEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 10092e8c4bdaSEd Tanous nlohmann::json::error_handler_t::replace); 1010fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueTypeError, 10112e8c4bdaSEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 1012b5c07418SJames Feist } 1013b5c07418SJames Feist 10142e8c4bdaSEd Tanous void propertyValueTypeError(crow::Response& res, const nlohmann::json& arg1, 10151668ce6dSEd Tanous std::string_view arg2) 1016b5c07418SJames Feist { 1017b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1018b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2); 1019f4c4dcf4SKowalski, Kamil } 1020f4c4dcf4SKowalski, Kamil 1021f4c4dcf4SKowalski, Kamil /** 1022f4c4dcf4SKowalski, Kamil * @internal 1023b6cd31e1SEd Tanous * @brief Formats ResourceNotFound message into JSONd 1024f4c4dcf4SKowalski, Kamil * 1025f4c4dcf4SKowalski, Kamil * See header file for more information 1026f4c4dcf4SKowalski, Kamil * @endinternal 1027f4c4dcf4SKowalski, Kamil */ 10281668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2) 10291abe55efSEd Tanous { 1030fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceNotFound, 10311668ce6dSEd Tanous std::to_array({arg1, arg2})); 1032b5c07418SJames Feist } 1033b5c07418SJames Feist 10341668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1, 10351668ce6dSEd Tanous std::string_view arg2) 1036b5c07418SJames Feist { 1037b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 1038b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2)); 1039f4c4dcf4SKowalski, Kamil } 1040f4c4dcf4SKowalski, Kamil 1041f4c4dcf4SKowalski, Kamil /** 1042f4c4dcf4SKowalski, Kamil * @internal 1043f4c4dcf4SKowalski, Kamil * @brief Formats CouldNotEstablishConnection message into JSON 1044f4c4dcf4SKowalski, Kamil * 1045f4c4dcf4SKowalski, Kamil * See header file for more information 1046f4c4dcf4SKowalski, Kamil * @endinternal 1047f4c4dcf4SKowalski, Kamil */ 1048*4a7fbefdSEd Tanous nlohmann::json 1049*4a7fbefdSEd Tanous couldNotEstablishConnection(const boost::urls::url_view_base& arg1) 10501abe55efSEd Tanous { 1051fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::couldNotEstablishConnection, 1052079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1053b5c07418SJames Feist } 1054b5c07418SJames Feist 1055ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res, 1056*4a7fbefdSEd Tanous const boost::urls::url_view_base& arg1) 1057b5c07418SJames Feist { 1058b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 1059b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1)); 1060f4c4dcf4SKowalski, Kamil } 1061f4c4dcf4SKowalski, Kamil 1062f4c4dcf4SKowalski, Kamil /** 1063f4c4dcf4SKowalski, Kamil * @internal 1064f12894f8SJason M. Bills * @brief Formats PropertyNotWritable message into JSON for the specified 1065f12894f8SJason M. Bills * property 1066f12894f8SJason M. Bills * 1067f12894f8SJason M. Bills * See header file for more information 1068f12894f8SJason M. Bills * @endinternal 1069f12894f8SJason M. Bills */ 10701668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1) 1071f12894f8SJason M. Bills { 1072fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyNotWritable, 10731668ce6dSEd Tanous std::to_array({arg1})); 1074b5c07418SJames Feist } 1075b5c07418SJames Feist 10761668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1) 1077b5c07418SJames Feist { 1078b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1079b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1); 1080f4c4dcf4SKowalski, Kamil } 1081f4c4dcf4SKowalski, Kamil 1082f4c4dcf4SKowalski, Kamil /** 1083f4c4dcf4SKowalski, Kamil * @internal 1084f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueTypeError message into JSON 1085f4c4dcf4SKowalski, Kamil * 1086f4c4dcf4SKowalski, Kamil * See header file for more information 1087f4c4dcf4SKowalski, Kamil * @endinternal 1088f4c4dcf4SKowalski, Kamil */ 108995b3ad73SEd Tanous nlohmann::json queryParameterValueTypeError(const nlohmann::json& arg1, 10901668ce6dSEd Tanous std::string_view arg2) 10911abe55efSEd Tanous { 109295b3ad73SEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 109395b3ad73SEd Tanous nlohmann::json::error_handler_t::replace); 1094b6cd31e1SEd Tanous return getLog( 1095fffb8c1fSEd Tanous redfish::registries::base::Index::queryParameterValueTypeError, 109695b3ad73SEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 1097b5c07418SJames Feist } 1098b5c07418SJames Feist 109995b3ad73SEd Tanous void queryParameterValueTypeError(crow::Response& res, 110095b3ad73SEd Tanous const nlohmann::json& arg1, 11011668ce6dSEd Tanous std::string_view arg2) 1102b5c07418SJames Feist { 1103b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1104b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1105b5c07418SJames Feist queryParameterValueTypeError(arg1, arg2)); 1106f4c4dcf4SKowalski, Kamil } 1107f4c4dcf4SKowalski, Kamil 1108f4c4dcf4SKowalski, Kamil /** 1109f4c4dcf4SKowalski, Kamil * @internal 1110f4c4dcf4SKowalski, Kamil * @brief Formats ServiceShuttingDown message into JSON 1111f4c4dcf4SKowalski, Kamil * 1112f4c4dcf4SKowalski, Kamil * See header file for more information 1113f4c4dcf4SKowalski, Kamil * @endinternal 1114f4c4dcf4SKowalski, Kamil */ 1115d9fcfcc1SEd Tanous nlohmann::json serviceShuttingDown() 11161abe55efSEd Tanous { 1117fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::serviceShuttingDown, {}); 1118b5c07418SJames Feist } 1119b5c07418SJames Feist 1120b5c07418SJames Feist void serviceShuttingDown(crow::Response& res) 1121b5c07418SJames Feist { 1122b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1123b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceShuttingDown()); 1124f4c4dcf4SKowalski, Kamil } 1125f4c4dcf4SKowalski, Kamil 1126f4c4dcf4SKowalski, Kamil /** 1127f4c4dcf4SKowalski, Kamil * @internal 1128f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterDuplicate message into JSON 1129f4c4dcf4SKowalski, Kamil * 1130f4c4dcf4SKowalski, Kamil * See header file for more information 1131f4c4dcf4SKowalski, Kamil * @endinternal 1132f4c4dcf4SKowalski, Kamil */ 11331668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1, 11341668ce6dSEd Tanous std::string_view arg2) 11351abe55efSEd Tanous { 1136fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterDuplicate, 11371668ce6dSEd Tanous std::to_array({arg1, arg2})); 1138b5c07418SJames Feist } 1139b5c07418SJames Feist 11401668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1, 11411668ce6dSEd Tanous std::string_view arg2) 1142b5c07418SJames Feist { 1143b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1144b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2)); 1145f4c4dcf4SKowalski, Kamil } 1146f4c4dcf4SKowalski, Kamil 1147f4c4dcf4SKowalski, Kamil /** 1148f4c4dcf4SKowalski, Kamil * @internal 1149f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterNotSupported message into JSON 1150f4c4dcf4SKowalski, Kamil * 1151f4c4dcf4SKowalski, Kamil * See header file for more information 1152f4c4dcf4SKowalski, Kamil * @endinternal 1153f4c4dcf4SKowalski, Kamil */ 11541668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1, 11551668ce6dSEd Tanous std::string_view arg2) 11561abe55efSEd Tanous { 1157fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionParameterNotSupported, 11581668ce6dSEd Tanous std::to_array({arg1, arg2})); 1159b5c07418SJames Feist } 1160b5c07418SJames Feist 11611668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1, 11621668ce6dSEd Tanous std::string_view arg2) 1163b5c07418SJames Feist { 1164b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1165b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1166b5c07418SJames Feist actionParameterNotSupported(arg1, arg2)); 1167f4c4dcf4SKowalski, Kamil } 1168f4c4dcf4SKowalski, Kamil 1169f4c4dcf4SKowalski, Kamil /** 1170f4c4dcf4SKowalski, Kamil * @internal 1171f4c4dcf4SKowalski, Kamil * @brief Formats SourceDoesNotSupportProtocol message into JSON 1172f4c4dcf4SKowalski, Kamil * 1173f4c4dcf4SKowalski, Kamil * See header file for more information 1174f4c4dcf4SKowalski, Kamil * @endinternal 1175f4c4dcf4SKowalski, Kamil */ 1176*4a7fbefdSEd Tanous nlohmann::json 1177*4a7fbefdSEd Tanous sourceDoesNotSupportProtocol(const boost::urls::url_view_base& arg1, 11781668ce6dSEd Tanous std::string_view arg2) 11791abe55efSEd Tanous { 1180b6cd31e1SEd Tanous return getLog( 1181fffb8c1fSEd Tanous redfish::registries::base::Index::sourceDoesNotSupportProtocol, 1182079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer(), arg2})); 1183b5c07418SJames Feist } 1184b5c07418SJames Feist 1185ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res, 1186*4a7fbefdSEd Tanous const boost::urls::url_view_base& arg1, 11871668ce6dSEd Tanous std::string_view arg2) 1188b5c07418SJames Feist { 1189b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1190b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1191b5c07418SJames Feist sourceDoesNotSupportProtocol(arg1, arg2)); 1192f4c4dcf4SKowalski, Kamil } 1193f4c4dcf4SKowalski, Kamil 1194f4c4dcf4SKowalski, Kamil /** 1195f4c4dcf4SKowalski, Kamil * @internal 1196b4ad4c05SShantappa Teekappanavar * @brief Formats StrictAccountTypes message into JSON 1197b4ad4c05SShantappa Teekappanavar * 1198b4ad4c05SShantappa Teekappanavar * See header file for more information 1199b4ad4c05SShantappa Teekappanavar * @endinternal 1200b4ad4c05SShantappa Teekappanavar */ 1201b4ad4c05SShantappa Teekappanavar nlohmann::json strictAccountTypes(std::string_view arg1) 1202b4ad4c05SShantappa Teekappanavar { 1203b4ad4c05SShantappa Teekappanavar return getLog(redfish::registries::base::Index::strictAccountTypes, 1204b4ad4c05SShantappa Teekappanavar std::to_array({arg1})); 1205b4ad4c05SShantappa Teekappanavar } 1206b4ad4c05SShantappa Teekappanavar 1207b4ad4c05SShantappa Teekappanavar void strictAccountTypes(crow::Response& res, std::string_view arg1) 1208b4ad4c05SShantappa Teekappanavar { 1209b4ad4c05SShantappa Teekappanavar res.result(boost::beast::http::status::bad_request); 1210b4ad4c05SShantappa Teekappanavar addMessageToErrorJson(res.jsonValue, strictAccountTypes(arg1)); 1211b4ad4c05SShantappa Teekappanavar } 1212b4ad4c05SShantappa Teekappanavar 1213b4ad4c05SShantappa Teekappanavar /** 1214b4ad4c05SShantappa Teekappanavar * @internal 1215f4c4dcf4SKowalski, Kamil * @brief Formats AccountRemoved message into JSON 1216f4c4dcf4SKowalski, Kamil * 1217f4c4dcf4SKowalski, Kamil * See header file for more information 1218f4c4dcf4SKowalski, Kamil * @endinternal 1219f4c4dcf4SKowalski, Kamil */ 1220d9fcfcc1SEd Tanous nlohmann::json accountRemoved() 12211abe55efSEd Tanous { 1222fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountRemoved, {}); 1223b5c07418SJames Feist } 1224b5c07418SJames Feist 1225b5c07418SJames Feist void accountRemoved(crow::Response& res) 1226b5c07418SJames Feist { 1227b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1228b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, accountRemoved()); 1229f4c4dcf4SKowalski, Kamil } 1230f4c4dcf4SKowalski, Kamil 1231f4c4dcf4SKowalski, Kamil /** 1232f4c4dcf4SKowalski, Kamil * @internal 1233f4c4dcf4SKowalski, Kamil * @brief Formats AccessDenied message into JSON 1234f4c4dcf4SKowalski, Kamil * 1235f4c4dcf4SKowalski, Kamil * See header file for more information 1236f4c4dcf4SKowalski, Kamil * @endinternal 1237f4c4dcf4SKowalski, Kamil */ 1238*4a7fbefdSEd Tanous nlohmann::json accessDenied(const boost::urls::url_view_base& arg1) 12391abe55efSEd Tanous { 1240fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accessDenied, 1241079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1242b5c07418SJames Feist } 1243b5c07418SJames Feist 1244*4a7fbefdSEd Tanous void accessDenied(crow::Response& res, const boost::urls::url_view_base& arg1) 1245b5c07418SJames Feist { 1246b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1247b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accessDenied(arg1)); 1248f4c4dcf4SKowalski, Kamil } 1249f4c4dcf4SKowalski, Kamil 1250f4c4dcf4SKowalski, Kamil /** 1251f4c4dcf4SKowalski, Kamil * @internal 1252f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupported message into JSON 1253f4c4dcf4SKowalski, Kamil * 1254f4c4dcf4SKowalski, Kamil * See header file for more information 1255f4c4dcf4SKowalski, Kamil * @endinternal 1256f4c4dcf4SKowalski, Kamil */ 1257d9fcfcc1SEd Tanous nlohmann::json queryNotSupported() 12581abe55efSEd Tanous { 1259fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryNotSupported, {}); 1260b5c07418SJames Feist } 1261b5c07418SJames Feist 1262b5c07418SJames Feist void queryNotSupported(crow::Response& res) 1263b5c07418SJames Feist { 1264b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1265b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupported()); 1266f4c4dcf4SKowalski, Kamil } 1267f4c4dcf4SKowalski, Kamil 1268f4c4dcf4SKowalski, Kamil /** 1269f4c4dcf4SKowalski, Kamil * @internal 1270f4c4dcf4SKowalski, Kamil * @brief Formats CreateLimitReachedForResource message into JSON 1271f4c4dcf4SKowalski, Kamil * 1272f4c4dcf4SKowalski, Kamil * See header file for more information 1273f4c4dcf4SKowalski, Kamil * @endinternal 1274f4c4dcf4SKowalski, Kamil */ 1275d9fcfcc1SEd Tanous nlohmann::json createLimitReachedForResource() 12761abe55efSEd Tanous { 1277b6cd31e1SEd Tanous return getLog( 1278fffb8c1fSEd Tanous redfish::registries::base::Index::createLimitReachedForResource, {}); 1279b5c07418SJames Feist } 1280b5c07418SJames Feist 1281b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res) 1282b5c07418SJames Feist { 1283b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1284b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, createLimitReachedForResource()); 1285f4c4dcf4SKowalski, Kamil } 1286f4c4dcf4SKowalski, Kamil 1287f4c4dcf4SKowalski, Kamil /** 1288f4c4dcf4SKowalski, Kamil * @internal 1289f4c4dcf4SKowalski, Kamil * @brief Formats GeneralError message into JSON 1290f4c4dcf4SKowalski, Kamil * 1291f4c4dcf4SKowalski, Kamil * See header file for more information 1292f4c4dcf4SKowalski, Kamil * @endinternal 1293f4c4dcf4SKowalski, Kamil */ 1294d9fcfcc1SEd Tanous nlohmann::json generalError() 12951abe55efSEd Tanous { 1296fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::generalError, {}); 1297b5c07418SJames Feist } 1298b5c07418SJames Feist 1299b5c07418SJames Feist void generalError(crow::Response& res) 1300b5c07418SJames Feist { 1301b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 1302b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, generalError()); 1303f4c4dcf4SKowalski, Kamil } 1304f4c4dcf4SKowalski, Kamil 1305f4c4dcf4SKowalski, Kamil /** 1306f4c4dcf4SKowalski, Kamil * @internal 1307f4c4dcf4SKowalski, Kamil * @brief Formats Success message into JSON 1308f4c4dcf4SKowalski, Kamil * 1309f4c4dcf4SKowalski, Kamil * See header file for more information 1310f4c4dcf4SKowalski, Kamil * @endinternal 1311f4c4dcf4SKowalski, Kamil */ 1312d9fcfcc1SEd Tanous nlohmann::json success() 13131abe55efSEd Tanous { 1314fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::success, {}); 1315b5c07418SJames Feist } 1316b5c07418SJames Feist 1317b5c07418SJames Feist void success(crow::Response& res) 1318b5c07418SJames Feist { 1319b5c07418SJames Feist // don't set res.result here because success is the default and any 1320b5c07418SJames Feist // error should overwrite the default 1321b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, success()); 1322f12894f8SJason M. Bills } 1323f12894f8SJason M. Bills 1324f12894f8SJason M. Bills /** 1325f12894f8SJason M. Bills * @internal 1326f4c4dcf4SKowalski, Kamil * @brief Formats Created message into JSON 1327f4c4dcf4SKowalski, Kamil * 1328f4c4dcf4SKowalski, Kamil * See header file for more information 1329f4c4dcf4SKowalski, Kamil * @endinternal 1330f4c4dcf4SKowalski, Kamil */ 1331d9fcfcc1SEd Tanous nlohmann::json created() 13321abe55efSEd Tanous { 1333fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::created, {}); 1334b5c07418SJames Feist } 1335b5c07418SJames Feist 1336b5c07418SJames Feist void created(crow::Response& res) 1337b5c07418SJames Feist { 1338b5c07418SJames Feist res.result(boost::beast::http::status::created); 1339b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, created()); 1340f4c4dcf4SKowalski, Kamil } 1341f4c4dcf4SKowalski, Kamil 1342f4c4dcf4SKowalski, Kamil /** 1343f4c4dcf4SKowalski, Kamil * @internal 1344cc9139ecSJason M. Bills * @brief Formats NoOperation message into JSON 1345cc9139ecSJason M. Bills * 1346cc9139ecSJason M. Bills * See header file for more information 1347cc9139ecSJason M. Bills * @endinternal 1348cc9139ecSJason M. Bills */ 1349d9fcfcc1SEd Tanous nlohmann::json noOperation() 1350cc9139ecSJason M. Bills { 1351fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::noOperation, {}); 1352b5c07418SJames Feist } 1353b5c07418SJames Feist 1354b5c07418SJames Feist void noOperation(crow::Response& res) 1355b5c07418SJames Feist { 1356b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1357b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noOperation()); 1358cc9139ecSJason M. Bills } 1359cc9139ecSJason M. Bills 1360cc9139ecSJason M. Bills /** 1361cc9139ecSJason M. Bills * @internal 1362b5c07418SJames Feist * @brief Formats PropertyUnknown message into JSON for the specified 1363b5c07418SJames Feist * property 1364f12894f8SJason M. Bills * 1365f12894f8SJason M. Bills * See header file for more information 1366f12894f8SJason M. Bills * @endinternal 1367f12894f8SJason M. Bills */ 13681668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1) 1369b5c07418SJames Feist { 1370fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyUnknown, 13711668ce6dSEd Tanous std::to_array({arg1})); 1372b5c07418SJames Feist } 1373b5c07418SJames Feist 13741668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1) 1375f12894f8SJason M. Bills { 1376f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 13777b1dd2f9SEd Tanous addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1)); 1378f4c4dcf4SKowalski, Kamil } 1379f4c4dcf4SKowalski, Kamil 1380f4c4dcf4SKowalski, Kamil /** 1381f4c4dcf4SKowalski, Kamil * @internal 1382f4c4dcf4SKowalski, Kamil * @brief Formats NoValidSession message into JSON 1383f4c4dcf4SKowalski, Kamil * 1384f4c4dcf4SKowalski, Kamil * See header file for more information 1385f4c4dcf4SKowalski, Kamil * @endinternal 1386f4c4dcf4SKowalski, Kamil */ 1387d9fcfcc1SEd Tanous nlohmann::json noValidSession() 13881abe55efSEd Tanous { 1389fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::noValidSession, {}); 1390b5c07418SJames Feist } 1391b5c07418SJames Feist 1392b5c07418SJames Feist void noValidSession(crow::Response& res) 1393b5c07418SJames Feist { 1394b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1395b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noValidSession()); 1396f4c4dcf4SKowalski, Kamil } 1397f4c4dcf4SKowalski, Kamil 1398f4c4dcf4SKowalski, Kamil /** 1399f4c4dcf4SKowalski, Kamil * @internal 1400f4c4dcf4SKowalski, Kamil * @brief Formats InvalidObject message into JSON 1401f4c4dcf4SKowalski, Kamil * 1402f4c4dcf4SKowalski, Kamil * See header file for more information 1403f4c4dcf4SKowalski, Kamil * @endinternal 1404f4c4dcf4SKowalski, Kamil */ 1405*4a7fbefdSEd Tanous nlohmann::json invalidObject(const boost::urls::url_view_base& arg1) 14061abe55efSEd Tanous { 1407fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::invalidObject, 1408079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1409b5c07418SJames Feist } 1410b5c07418SJames Feist 1411*4a7fbefdSEd Tanous void invalidObject(crow::Response& res, const boost::urls::url_view_base& arg1) 1412b5c07418SJames Feist { 1413b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1414b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidObject(arg1)); 1415f4c4dcf4SKowalski, Kamil } 1416f4c4dcf4SKowalski, Kamil 1417f4c4dcf4SKowalski, Kamil /** 1418f4c4dcf4SKowalski, Kamil * @internal 1419f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInStandby message into JSON 1420f4c4dcf4SKowalski, Kamil * 1421f4c4dcf4SKowalski, Kamil * See header file for more information 1422f4c4dcf4SKowalski, Kamil * @endinternal 1423f4c4dcf4SKowalski, Kamil */ 1424d9fcfcc1SEd Tanous nlohmann::json resourceInStandby() 14251abe55efSEd Tanous { 1426fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceInStandby, {}); 1427b5c07418SJames Feist } 1428b5c07418SJames Feist 1429b5c07418SJames Feist void resourceInStandby(crow::Response& res) 1430b5c07418SJames Feist { 1431b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1432b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInStandby()); 1433f4c4dcf4SKowalski, Kamil } 1434f4c4dcf4SKowalski, Kamil 1435f4c4dcf4SKowalski, Kamil /** 1436f4c4dcf4SKowalski, Kamil * @internal 1437f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueTypeError message into JSON 1438f4c4dcf4SKowalski, Kamil * 1439f4c4dcf4SKowalski, Kamil * See header file for more information 1440f4c4dcf4SKowalski, Kamil * @endinternal 1441f4c4dcf4SKowalski, Kamil */ 144295b3ad73SEd Tanous nlohmann::json actionParameterValueTypeError(const nlohmann::json& arg1, 14431668ce6dSEd Tanous std::string_view arg2, 14441668ce6dSEd Tanous std::string_view arg3) 14451abe55efSEd Tanous { 144695b3ad73SEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 144795b3ad73SEd Tanous nlohmann::json::error_handler_t::replace); 1448b6cd31e1SEd Tanous return getLog( 1449fffb8c1fSEd Tanous redfish::registries::base::Index::actionParameterValueTypeError, 145095b3ad73SEd Tanous std::to_array<std::string_view>({arg1Str, arg2, arg3})); 1451b5c07418SJames Feist } 1452b5c07418SJames Feist 145395b3ad73SEd Tanous void actionParameterValueTypeError(crow::Response& res, 145495b3ad73SEd Tanous const nlohmann::json& arg1, 14551668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 1456b5c07418SJames Feist { 1457b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1458b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1459b5c07418SJames Feist actionParameterValueTypeError(arg1, arg2, arg3)); 1460f4c4dcf4SKowalski, Kamil } 1461f4c4dcf4SKowalski, Kamil 1462f4c4dcf4SKowalski, Kamil /** 1463f4c4dcf4SKowalski, Kamil * @internal 14641827b4f1SAsmitha Karunanithi * @brief Formats actionParameterValueError message into JSON 14651827b4f1SAsmitha Karunanithi * 14661827b4f1SAsmitha Karunanithi * See header file for more information 14671827b4f1SAsmitha Karunanithi * @endinternal 14681827b4f1SAsmitha Karunanithi */ 14691827b4f1SAsmitha Karunanithi nlohmann::json actionParameterValueError(const nlohmann::json& arg1, 14701827b4f1SAsmitha Karunanithi std::string_view arg2) 14711827b4f1SAsmitha Karunanithi { 14721827b4f1SAsmitha Karunanithi std::string arg1Str = arg1.dump(2, ' ', true, 14731827b4f1SAsmitha Karunanithi nlohmann::json::error_handler_t::replace); 14741827b4f1SAsmitha Karunanithi return getLog(redfish::registries::base::Index::actionParameterValueError, 14751827b4f1SAsmitha Karunanithi std::to_array<std::string_view>({arg1Str, arg2})); 14761827b4f1SAsmitha Karunanithi } 14771827b4f1SAsmitha Karunanithi 14781827b4f1SAsmitha Karunanithi void actionParameterValueError(crow::Response& res, const nlohmann::json& arg1, 14791827b4f1SAsmitha Karunanithi std::string_view arg2) 14801827b4f1SAsmitha Karunanithi { 14811827b4f1SAsmitha Karunanithi res.result(boost::beast::http::status::bad_request); 14821827b4f1SAsmitha Karunanithi addMessageToErrorJson(res.jsonValue, actionParameterValueError(arg1, arg2)); 14831827b4f1SAsmitha Karunanithi } 14841827b4f1SAsmitha Karunanithi 14851827b4f1SAsmitha Karunanithi /** 14861827b4f1SAsmitha Karunanithi * @internal 1487f4c4dcf4SKowalski, Kamil * @brief Formats SessionLimitExceeded message into JSON 1488f4c4dcf4SKowalski, Kamil * 1489f4c4dcf4SKowalski, Kamil * See header file for more information 1490f4c4dcf4SKowalski, Kamil * @endinternal 1491f4c4dcf4SKowalski, Kamil */ 1492d9fcfcc1SEd Tanous nlohmann::json sessionLimitExceeded() 14931abe55efSEd Tanous { 1494fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::sessionLimitExceeded, {}); 1495b5c07418SJames Feist } 1496b5c07418SJames Feist 1497b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res) 1498b5c07418SJames Feist { 1499b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1500b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, sessionLimitExceeded()); 1501f4c4dcf4SKowalski, Kamil } 1502f4c4dcf4SKowalski, Kamil 1503f4c4dcf4SKowalski, Kamil /** 1504f4c4dcf4SKowalski, Kamil * @internal 1505f4c4dcf4SKowalski, Kamil * @brief Formats ActionNotSupported message into JSON 1506f4c4dcf4SKowalski, Kamil * 1507f4c4dcf4SKowalski, Kamil * See header file for more information 1508f4c4dcf4SKowalski, Kamil * @endinternal 1509f4c4dcf4SKowalski, Kamil */ 15101668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1) 15111abe55efSEd Tanous { 1512fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::actionNotSupported, 15131668ce6dSEd Tanous std::to_array({arg1})); 1514b5c07418SJames Feist } 1515b5c07418SJames Feist 15161668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1) 1517b5c07418SJames Feist { 1518b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1519b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1)); 1520f4c4dcf4SKowalski, Kamil } 1521f4c4dcf4SKowalski, Kamil 1522f4c4dcf4SKowalski, Kamil /** 1523f4c4dcf4SKowalski, Kamil * @internal 1524f4c4dcf4SKowalski, Kamil * @brief Formats InvalidIndex message into JSON 1525f4c4dcf4SKowalski, Kamil * 1526f4c4dcf4SKowalski, Kamil * See header file for more information 1527f4c4dcf4SKowalski, Kamil * @endinternal 1528f4c4dcf4SKowalski, Kamil */ 15295187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1) 15301abe55efSEd Tanous { 1531b6cd31e1SEd Tanous std::string arg1Str = std::to_string(arg1); 1532fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::invalidIndex, 15331668ce6dSEd Tanous std::to_array<std::string_view>({arg1Str})); 1534b5c07418SJames Feist } 1535b5c07418SJames Feist 15365187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1) 1537b5c07418SJames Feist { 1538b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1539b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidIndex(arg1)); 1540f4c4dcf4SKowalski, Kamil } 1541f4c4dcf4SKowalski, Kamil 1542f4c4dcf4SKowalski, Kamil /** 1543f4c4dcf4SKowalski, Kamil * @internal 1544f4c4dcf4SKowalski, Kamil * @brief Formats EmptyJSON message into JSON 1545f4c4dcf4SKowalski, Kamil * 1546f4c4dcf4SKowalski, Kamil * See header file for more information 1547f4c4dcf4SKowalski, Kamil * @endinternal 1548f4c4dcf4SKowalski, Kamil */ 1549d9fcfcc1SEd Tanous nlohmann::json emptyJSON() 15501abe55efSEd Tanous { 1551fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::emptyJSON, {}); 1552b5c07418SJames Feist } 1553b5c07418SJames Feist 1554b5c07418SJames Feist void emptyJSON(crow::Response& res) 1555b5c07418SJames Feist { 1556b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1557b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, emptyJSON()); 1558f4c4dcf4SKowalski, Kamil } 1559f4c4dcf4SKowalski, Kamil 1560f4c4dcf4SKowalski, Kamil /** 1561f4c4dcf4SKowalski, Kamil * @internal 1562f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupportedOnResource message into JSON 1563f4c4dcf4SKowalski, Kamil * 1564f4c4dcf4SKowalski, Kamil * See header file for more information 1565f4c4dcf4SKowalski, Kamil * @endinternal 1566f4c4dcf4SKowalski, Kamil */ 1567d9fcfcc1SEd Tanous nlohmann::json queryNotSupportedOnResource() 15681abe55efSEd Tanous { 1569fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryNotSupportedOnResource, 1570b6cd31e1SEd Tanous {}); 1571b5c07418SJames Feist } 1572b5c07418SJames Feist 1573b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res) 1574b5c07418SJames Feist { 15756a409c12SEd Tanous res.result(boost::beast::http::status::bad_request); 1576b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource()); 1577f4c4dcf4SKowalski, Kamil } 1578f4c4dcf4SKowalski, Kamil 1579f4c4dcf4SKowalski, Kamil /** 1580f4c4dcf4SKowalski, Kamil * @internal 1581684bb4b8SJason M. Bills * @brief Formats QueryNotSupportedOnOperation message into JSON 1582684bb4b8SJason M. Bills * 1583684bb4b8SJason M. Bills * See header file for more information 1584684bb4b8SJason M. Bills * @endinternal 1585684bb4b8SJason M. Bills */ 1586d9fcfcc1SEd Tanous nlohmann::json queryNotSupportedOnOperation() 1587684bb4b8SJason M. Bills { 1588b6cd31e1SEd Tanous return getLog( 1589fffb8c1fSEd Tanous redfish::registries::base::Index::queryNotSupportedOnOperation, {}); 1590684bb4b8SJason M. Bills } 1591684bb4b8SJason M. Bills 1592684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res) 1593684bb4b8SJason M. Bills { 15946a409c12SEd Tanous res.result(boost::beast::http::status::bad_request); 1595684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation()); 1596684bb4b8SJason M. Bills } 1597684bb4b8SJason M. Bills 1598684bb4b8SJason M. Bills /** 1599684bb4b8SJason M. Bills * @internal 1600684bb4b8SJason M. Bills * @brief Formats QueryCombinationInvalid message into JSON 1601684bb4b8SJason M. Bills * 1602684bb4b8SJason M. Bills * See header file for more information 1603684bb4b8SJason M. Bills * @endinternal 1604684bb4b8SJason M. Bills */ 1605d9fcfcc1SEd Tanous nlohmann::json queryCombinationInvalid() 1606684bb4b8SJason M. Bills { 1607fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryCombinationInvalid, 1608fffb8c1fSEd Tanous {}); 1609684bb4b8SJason M. Bills } 1610684bb4b8SJason M. Bills 1611684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res) 1612684bb4b8SJason M. Bills { 1613684bb4b8SJason M. Bills res.result(boost::beast::http::status::bad_request); 1614684bb4b8SJason M. Bills addMessageToErrorJson(res.jsonValue, queryCombinationInvalid()); 1615684bb4b8SJason M. Bills } 1616684bb4b8SJason M. Bills 1617684bb4b8SJason M. Bills /** 1618684bb4b8SJason M. Bills * @internal 1619f4c4dcf4SKowalski, Kamil * @brief Formats InsufficientPrivilege message into JSON 1620f4c4dcf4SKowalski, Kamil * 1621f4c4dcf4SKowalski, Kamil * See header file for more information 1622f4c4dcf4SKowalski, Kamil * @endinternal 1623f4c4dcf4SKowalski, Kamil */ 1624d9fcfcc1SEd Tanous nlohmann::json insufficientPrivilege() 16251abe55efSEd Tanous { 1626fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::insufficientPrivilege, {}); 1627b5c07418SJames Feist } 1628b5c07418SJames Feist 1629b5c07418SJames Feist void insufficientPrivilege(crow::Response& res) 1630b5c07418SJames Feist { 1631b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1632b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, insufficientPrivilege()); 1633f4c4dcf4SKowalski, Kamil } 1634f4c4dcf4SKowalski, Kamil 1635f4c4dcf4SKowalski, Kamil /** 1636f4c4dcf4SKowalski, Kamil * @internal 1637f4c4dcf4SKowalski, Kamil * @brief Formats PropertyValueModified message into JSON 1638f4c4dcf4SKowalski, Kamil * 1639f4c4dcf4SKowalski, Kamil * See header file for more information 1640f4c4dcf4SKowalski, Kamil * @endinternal 1641f4c4dcf4SKowalski, Kamil */ 16421668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1, 164395b3ad73SEd Tanous const nlohmann::json& arg2) 1644b5c07418SJames Feist { 164595b3ad73SEd Tanous std::string arg2Str = arg2.dump(2, ' ', true, 164695b3ad73SEd Tanous nlohmann::json::error_handler_t::replace); 1647fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyValueModified, 164895b3ad73SEd Tanous std::to_array<std::string_view>({arg1, arg2Str})); 1649b5c07418SJames Feist } 1650b5c07418SJames Feist 16511668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1, 165295b3ad73SEd Tanous const nlohmann::json& arg2) 16531abe55efSEd Tanous { 1654f12894f8SJason M. Bills res.result(boost::beast::http::status::ok); 1655b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1); 1656f4c4dcf4SKowalski, Kamil } 1657f4c4dcf4SKowalski, Kamil 1658f4c4dcf4SKowalski, Kamil /** 1659f4c4dcf4SKowalski, Kamil * @internal 1660f4c4dcf4SKowalski, Kamil * @brief Formats AccountNotModified message into JSON 1661f4c4dcf4SKowalski, Kamil * 1662f4c4dcf4SKowalski, Kamil * See header file for more information 1663f4c4dcf4SKowalski, Kamil * @endinternal 1664f4c4dcf4SKowalski, Kamil */ 1665d9fcfcc1SEd Tanous nlohmann::json accountNotModified() 16661abe55efSEd Tanous { 1667fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountNotModified, {}); 1668b5c07418SJames Feist } 1669b5c07418SJames Feist 1670b5c07418SJames Feist void accountNotModified(crow::Response& res) 1671b5c07418SJames Feist { 1672b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1673b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountNotModified()); 1674f4c4dcf4SKowalski, Kamil } 1675f4c4dcf4SKowalski, Kamil 1676f4c4dcf4SKowalski, Kamil /** 1677f4c4dcf4SKowalski, Kamil * @internal 1678f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueFormatError message into JSON 1679f4c4dcf4SKowalski, Kamil * 1680f4c4dcf4SKowalski, Kamil * See header file for more information 1681f4c4dcf4SKowalski, Kamil * @endinternal 1682f4c4dcf4SKowalski, Kamil */ 168395b3ad73SEd Tanous nlohmann::json queryParameterValueFormatError(const nlohmann::json& arg1, 16841668ce6dSEd Tanous std::string_view arg2) 16851abe55efSEd Tanous { 168695b3ad73SEd Tanous std::string arg1Str = arg1.dump(2, ' ', true, 168795b3ad73SEd Tanous nlohmann::json::error_handler_t::replace); 1688fffb8c1fSEd Tanous return getLog( 1689fffb8c1fSEd Tanous redfish::registries::base::Index::queryParameterValueFormatError, 169095b3ad73SEd Tanous std::to_array<std::string_view>({arg1Str, arg2})); 1691b5c07418SJames Feist } 1692b5c07418SJames Feist 169395b3ad73SEd Tanous void queryParameterValueFormatError(crow::Response& res, 169495b3ad73SEd Tanous const nlohmann::json& arg1, 16951668ce6dSEd Tanous std::string_view arg2) 1696b5c07418SJames Feist { 1697b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1698b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1699b5c07418SJames Feist queryParameterValueFormatError(arg1, arg2)); 1700f4c4dcf4SKowalski, Kamil } 1701f4c4dcf4SKowalski, Kamil 1702f4c4dcf4SKowalski, Kamil /** 1703f4c4dcf4SKowalski, Kamil * @internal 1704b5c07418SJames Feist * @brief Formats PropertyMissing message into JSON for the specified 1705b5c07418SJames Feist * property 1706f12894f8SJason M. Bills * 1707f12894f8SJason M. Bills * See header file for more information 1708f12894f8SJason M. Bills * @endinternal 1709f12894f8SJason M. Bills */ 17101668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1) 1711f12894f8SJason M. Bills { 1712fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::propertyMissing, 17131668ce6dSEd Tanous std::to_array({arg1})); 1714b5c07418SJames Feist } 1715b5c07418SJames Feist 17161668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1) 1717b5c07418SJames Feist { 1718b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1719b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1); 1720f4c4dcf4SKowalski, Kamil } 1721f4c4dcf4SKowalski, Kamil 1722f4c4dcf4SKowalski, Kamil /** 1723f4c4dcf4SKowalski, Kamil * @internal 1724f4c4dcf4SKowalski, Kamil * @brief Formats ResourceExhaustion message into JSON 1725f4c4dcf4SKowalski, Kamil * 1726f4c4dcf4SKowalski, Kamil * See header file for more information 1727f4c4dcf4SKowalski, Kamil * @endinternal 1728f4c4dcf4SKowalski, Kamil */ 17291668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1) 17301abe55efSEd Tanous { 1731fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::resourceExhaustion, 17321668ce6dSEd Tanous std::to_array({arg1})); 1733b5c07418SJames Feist } 1734b5c07418SJames Feist 17351668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1) 1736b5c07418SJames Feist { 1737b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1738b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1)); 1739f4c4dcf4SKowalski, Kamil } 1740f4c4dcf4SKowalski, Kamil 1741f4c4dcf4SKowalski, Kamil /** 1742f4c4dcf4SKowalski, Kamil * @internal 1743f4c4dcf4SKowalski, Kamil * @brief Formats AccountModified message into JSON 1744f4c4dcf4SKowalski, Kamil * 1745f4c4dcf4SKowalski, Kamil * See header file for more information 1746f4c4dcf4SKowalski, Kamil * @endinternal 1747f4c4dcf4SKowalski, Kamil */ 1748d9fcfcc1SEd Tanous nlohmann::json accountModified() 17491abe55efSEd Tanous { 1750fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::accountModified, {}); 1751b5c07418SJames Feist } 1752b5c07418SJames Feist 1753b5c07418SJames Feist void accountModified(crow::Response& res) 1754b5c07418SJames Feist { 1755b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1756b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountModified()); 1757f4c4dcf4SKowalski, Kamil } 1758f4c4dcf4SKowalski, Kamil 1759f4c4dcf4SKowalski, Kamil /** 1760f4c4dcf4SKowalski, Kamil * @internal 1761f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterOutOfRange message into JSON 1762f4c4dcf4SKowalski, Kamil * 1763f4c4dcf4SKowalski, Kamil * See header file for more information 1764f4c4dcf4SKowalski, Kamil * @endinternal 1765f4c4dcf4SKowalski, Kamil */ 17661668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1, 17671668ce6dSEd Tanous std::string_view arg2, 17681668ce6dSEd Tanous std::string_view arg3) 17691abe55efSEd Tanous { 1770fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::queryParameterOutOfRange, 17711668ce6dSEd Tanous std::to_array({arg1, arg2, arg3})); 1772b5c07418SJames Feist } 1773b5c07418SJames Feist 17741668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1, 17751668ce6dSEd Tanous std::string_view arg2, std::string_view arg3) 1776b5c07418SJames Feist { 1777b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1778b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1779b5c07418SJames Feist queryParameterOutOfRange(arg1, arg2, arg3)); 1780f4c4dcf4SKowalski, Kamil } 1781f4c4dcf4SKowalski, Kamil 1782*4a7fbefdSEd Tanous nlohmann::json passwordChangeRequired(const boost::urls::url_view_base& arg1) 1783b6cd31e1SEd Tanous { 1784fffb8c1fSEd Tanous return getLog(redfish::registries::base::Index::passwordChangeRequired, 1785079360aeSEd Tanous std::to_array<std::string_view>({arg1.buffer()})); 1786b6cd31e1SEd Tanous } 1787b6cd31e1SEd Tanous 17883bf4e632SJoseph Reynolds /** 17893bf4e632SJoseph Reynolds * @internal 17903bf4e632SJoseph Reynolds * @brief Formats PasswordChangeRequired message into JSON 17913bf4e632SJoseph Reynolds * 17923bf4e632SJoseph Reynolds * See header file for more information 17933bf4e632SJoseph Reynolds * @endinternal 17943bf4e632SJoseph Reynolds */ 1795*4a7fbefdSEd Tanous void passwordChangeRequired(crow::Response& res, 1796*4a7fbefdSEd Tanous const boost::urls::url_view_base& arg1) 17973bf4e632SJoseph Reynolds { 1798b6cd31e1SEd Tanous messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1)); 17993bf4e632SJoseph Reynolds } 18003bf4e632SJoseph Reynolds 18014cde5d90SJames Feist /** 18024cde5d90SJames Feist * @internal 1803ae688313SNan Zhou * @brief Formats InsufficientStorage message into JSON 1804ae688313SNan Zhou * 1805ae688313SNan Zhou * See header file for more information 1806ae688313SNan Zhou * @endinternal 1807ae688313SNan Zhou */ 1808ae688313SNan Zhou nlohmann::json insufficientStorage() 1809ae688313SNan Zhou { 1810ae688313SNan Zhou return getLog(redfish::registries::base::Index::insufficientStorage, {}); 1811ae688313SNan Zhou } 1812ae688313SNan Zhou 1813ae688313SNan Zhou void insufficientStorage(crow::Response& res) 1814ae688313SNan Zhou { 1815ae688313SNan Zhou res.result(boost::beast::http::status::insufficient_storage); 1816ae688313SNan Zhou addMessageToErrorJson(res.jsonValue, insufficientStorage()); 1817ae688313SNan Zhou } 1818ae688313SNan Zhou 1819ae688313SNan Zhou /** 1820ae688313SNan Zhou * @internal 182144c70412SEd Tanous * @brief Formats OperationNotAllowed message into JSON 182244c70412SEd Tanous * 182344c70412SEd Tanous * See header file for more information 182444c70412SEd Tanous * @endinternal 182544c70412SEd Tanous */ 182644c70412SEd Tanous nlohmann::json operationNotAllowed() 182744c70412SEd Tanous { 182844c70412SEd Tanous return getLog(redfish::registries::base::Index::operationNotAllowed, {}); 182944c70412SEd Tanous } 183044c70412SEd Tanous 183144c70412SEd Tanous void operationNotAllowed(crow::Response& res) 183244c70412SEd Tanous { 183344c70412SEd Tanous res.result(boost::beast::http::status::method_not_allowed); 183444c70412SEd Tanous addMessageToErrorJson(res.jsonValue, operationNotAllowed()); 183544c70412SEd Tanous } 183644c70412SEd Tanous 1837600af5f1SAppaRao Puli /** 1838600af5f1SAppaRao Puli * @internal 1839600af5f1SAppaRao Puli * @brief Formats ArraySizeTooLong message into JSON 1840600af5f1SAppaRao Puli * 1841600af5f1SAppaRao Puli * See header file for more information 1842600af5f1SAppaRao Puli * @endinternal 1843600af5f1SAppaRao Puli */ 1844600af5f1SAppaRao Puli nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length) 1845600af5f1SAppaRao Puli { 1846600af5f1SAppaRao Puli std::string valStr = std::to_string(length); 1847600af5f1SAppaRao Puli return getLog(redfish::registries::base::Index::arraySizeTooLong, 1848600af5f1SAppaRao Puli std::to_array<std::string_view>({property, valStr})); 1849600af5f1SAppaRao Puli } 1850600af5f1SAppaRao Puli 1851600af5f1SAppaRao Puli void arraySizeTooLong(crow::Response& res, std::string_view property, 1852600af5f1SAppaRao Puli uint64_t length) 1853600af5f1SAppaRao Puli { 185499bf0262SDivya Jyoti res.result(boost::beast::http::status::bad_request); 1855600af5f1SAppaRao Puli addMessageToErrorJson(res.jsonValue, arraySizeTooLong(property, length)); 1856600af5f1SAppaRao Puli } 1857600af5f1SAppaRao Puli 185844c70412SEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1, 185944c70412SEd Tanous std::string_view arg2) 186044c70412SEd Tanous { 186144c70412SEd Tanous res.result(boost::beast::http::status::bad_request); 186244c70412SEd Tanous addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2)); 186344c70412SEd Tanous } 186444c70412SEd Tanous 186544c70412SEd Tanous /** 186644c70412SEd Tanous * @internal 18674cde5d90SJames Feist * @brief Formats Invalid File message into JSON 18684cde5d90SJames Feist * 18694cde5d90SJames Feist * See header file for more information 18704cde5d90SJames Feist * @endinternal 18714cde5d90SJames Feist */ 18721668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2) 18734cde5d90SJames Feist { 18741668ce6dSEd Tanous std::string msg = "Invalid file uploaded to "; 18751668ce6dSEd Tanous msg += arg1; 18761668ce6dSEd Tanous msg += ": "; 18771668ce6dSEd Tanous msg += arg2; 18781668ce6dSEd Tanous msg += "."; 1879613dabeaSEd Tanous 1880613dabeaSEd Tanous nlohmann::json::object_t ret; 1881613dabeaSEd Tanous ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message"; 1882613dabeaSEd Tanous ret["MessageId"] = "OpenBMC.0.2.InvalidUpload"; 1883613dabeaSEd Tanous ret["Message"] = std::move(msg); 1884613dabeaSEd Tanous nlohmann::json::array_t args; 1885ad539545SPatrick Williams args.emplace_back(arg1); 1886ad539545SPatrick Williams args.emplace_back(arg2); 1887613dabeaSEd Tanous ret["MessageArgs"] = std::move(args); 1888613dabeaSEd Tanous ret["MessageSeverity"] = "Warning"; 1889613dabeaSEd Tanous ret["Resolution"] = "None."; 1890613dabeaSEd Tanous return ret; 18914cde5d90SJames Feist } 1892ae688313SNan Zhou 1893f4c4dcf4SKowalski, Kamil } // namespace messages 1894f4c4dcf4SKowalski, Kamil 1895d425c6f6SEd Tanous } // namespace redfish 1896