1 /* 2 // Copyright (c) 2018 Intel Corporation 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 */ 16 #include "http_response.hpp" 17 #include "registries/base_message_registry.hpp" 18 19 #include <boost/beast/http/status.hpp> 20 #include <boost/url/url.hpp> 21 #include <error_messages.hpp> 22 #include <logging.hpp> 23 #include <nlohmann/json.hpp> 24 25 #include <array> 26 27 namespace redfish 28 { 29 30 namespace messages 31 { 32 33 static void addMessageToErrorJson(nlohmann::json& target, 34 const nlohmann::json& message) 35 { 36 auto& error = target["error"]; 37 38 // If this is the first error message, fill in the information from the 39 // first error message to the top level struct 40 if (!error.is_object()) 41 { 42 auto messageIdIterator = message.find("MessageId"); 43 if (messageIdIterator == message.end()) 44 { 45 BMCWEB_LOG_CRITICAL 46 << "Attempt to add error message without MessageId"; 47 return; 48 } 49 50 auto messageFieldIterator = message.find("Message"); 51 if (messageFieldIterator == message.end()) 52 { 53 BMCWEB_LOG_CRITICAL 54 << "Attempt to add error message without Message"; 55 return; 56 } 57 error = {{"code", *messageIdIterator}, 58 {"message", *messageFieldIterator}}; 59 } 60 else 61 { 62 // More than 1 error occurred, so the message has to be generic 63 error["code"] = std::string(messageVersionPrefix) + "GeneralError"; 64 error["message"] = "A general error has occurred. See Resolution for " 65 "information on how to resolve the error."; 66 } 67 68 // This check could technically be done in in the default construction 69 // branch above, but because we need the pointer to the extended info field 70 // anyway, it's more efficient to do it here. 71 auto& extendedInfo = error[messages::messageAnnotation]; 72 if (!extendedInfo.is_array()) 73 { 74 extendedInfo = nlohmann::json::array(); 75 } 76 77 extendedInfo.push_back(message); 78 } 79 80 static void addMessageToJsonRoot(nlohmann::json& target, 81 const nlohmann::json& message) 82 { 83 if (!target[messages::messageAnnotation].is_array()) 84 { 85 // Force object to be an array 86 target[messages::messageAnnotation] = nlohmann::json::array(); 87 } 88 89 target[messages::messageAnnotation].push_back(message); 90 } 91 92 static void addMessageToJson(nlohmann::json& target, 93 const nlohmann::json& message, 94 std::string_view fieldPath) 95 { 96 std::string extendedInfo(fieldPath); 97 extendedInfo += messages::messageAnnotation; 98 99 nlohmann::json& field = target[extendedInfo]; 100 if (!field.is_array()) 101 { 102 // Force object to be an array 103 field = nlohmann::json::array(); 104 } 105 106 // Object exists and it is an array so we can just push in the message 107 field.push_back(message); 108 } 109 110 nlohmann::json getLog(redfish::message_registries::base::Index name, 111 std::span<const std::string_view> args) 112 { 113 size_t index = static_cast<size_t>(name); 114 if (index >= redfish::message_registries::base::registry.size()) 115 { 116 return {}; 117 } 118 const redfish::message_registries::MessageEntry& entry = 119 redfish::message_registries::base::registry[index]; 120 // Intentionally make a copy of the string, so we can append in the 121 // parameters. 122 std::string msg = entry.second.message; 123 redfish::message_registries::fillMessageArgs(args, msg); 124 nlohmann::json jArgs = nlohmann::json::array(); 125 for (const std::string_view arg : args) 126 { 127 jArgs.push_back(arg); 128 } 129 std::string msgId = redfish::message_registries::base::header.id; 130 msgId += "."; 131 msgId += entry.first; 132 return {{"@odata.type", "#Message.v1_1_1.Message"}, 133 {"MessageId", std::move(msgId)}, 134 {"Message", std::move(msg)}, 135 {"MessageArgs", std::move(jArgs)}, 136 {"MessageSeverity", entry.second.severity}, 137 {"Resolution", entry.second.resolution}}; 138 } 139 140 /** 141 * @internal 142 * @brief Formats ResourceInUse message into JSON 143 * 144 * See header file for more information 145 * @endinternal 146 */ 147 nlohmann::json resourceInUse(void) 148 { 149 return getLog(redfish::message_registries::base::Index::resourceInUse, {}); 150 } 151 152 void resourceInUse(crow::Response& res) 153 { 154 res.result(boost::beast::http::status::service_unavailable); 155 addMessageToErrorJson(res.jsonValue, resourceInUse()); 156 } 157 158 /** 159 * @internal 160 * @brief Formats MalformedJSON message into JSON 161 * 162 * See header file for more information 163 * @endinternal 164 */ 165 nlohmann::json malformedJSON(void) 166 { 167 return getLog(redfish::message_registries::base::Index::malformedJSON, {}); 168 } 169 170 void malformedJSON(crow::Response& res) 171 { 172 res.result(boost::beast::http::status::bad_request); 173 addMessageToErrorJson(res.jsonValue, malformedJSON()); 174 } 175 176 /** 177 * @internal 178 * @brief Formats ResourceMissingAtURI message into JSON 179 * 180 * See header file for more information 181 * @endinternal 182 */ 183 nlohmann::json resourceMissingAtURI(const boost::urls::url_view& arg1) 184 { 185 std::array<std::string_view, 1> args{ 186 std::string_view{arg1.data(), arg1.size()}}; 187 return getLog( 188 redfish::message_registries::base::Index::resourceMissingAtURI, args); 189 } 190 191 void resourceMissingAtURI(crow::Response& res, 192 const boost::urls::url_view& arg1) 193 { 194 res.result(boost::beast::http::status::bad_request); 195 addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1)); 196 } 197 198 /** 199 * @internal 200 * @brief Formats ActionParameterValueFormatError message into JSON 201 * 202 * See header file for more information 203 * @endinternal 204 */ 205 nlohmann::json actionParameterValueFormatError(std::string_view arg1, 206 std::string_view arg2, 207 std::string_view arg3) 208 { 209 return getLog(redfish::message_registries::base::Index:: 210 actionParameterValueFormatError, 211 std::to_array({arg1, arg2, arg3})); 212 } 213 214 void actionParameterValueFormatError(crow::Response& res, std::string_view arg1, 215 std::string_view arg2, 216 std::string_view arg3) 217 { 218 res.result(boost::beast::http::status::bad_request); 219 addMessageToErrorJson(res.jsonValue, 220 actionParameterValueFormatError(arg1, arg2, arg3)); 221 } 222 223 /** 224 * @internal 225 * @brief Formats InternalError message into JSON 226 * 227 * See header file for more information 228 * @endinternal 229 */ 230 nlohmann::json internalError(void) 231 { 232 return getLog(redfish::message_registries::base::Index::internalError, {}); 233 } 234 235 void internalError(crow::Response& res, const bmcweb::source_location location) 236 { 237 BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "(" 238 << location.line() << ":" << location.column() << ") `" 239 << location.function_name() << "`: "; 240 res.result(boost::beast::http::status::internal_server_error); 241 addMessageToErrorJson(res.jsonValue, internalError()); 242 } 243 244 /** 245 * @internal 246 * @brief Formats UnrecognizedRequestBody message into JSON 247 * 248 * See header file for more information 249 * @endinternal 250 */ 251 nlohmann::json unrecognizedRequestBody(void) 252 { 253 return getLog( 254 redfish::message_registries::base::Index::unrecognizedRequestBody, {}); 255 } 256 257 void unrecognizedRequestBody(crow::Response& res) 258 { 259 res.result(boost::beast::http::status::bad_request); 260 addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody()); 261 } 262 263 /** 264 * @internal 265 * @brief Formats ResourceAtUriUnauthorized message into JSON 266 * 267 * See header file for more information 268 * @endinternal 269 */ 270 nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1, 271 std::string_view arg2) 272 { 273 return getLog( 274 redfish::message_registries::base::Index::resourceAtUriUnauthorized, 275 std::to_array({std::string_view{arg1.data(), arg1.size()}, arg2})); 276 } 277 278 void resourceAtUriUnauthorized(crow::Response& res, 279 const boost::urls::url_view& arg1, 280 std::string_view arg2) 281 { 282 res.result(boost::beast::http::status::unauthorized); 283 addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2)); 284 } 285 286 /** 287 * @internal 288 * @brief Formats ActionParameterUnknown message into JSON 289 * 290 * See header file for more information 291 * @endinternal 292 */ 293 nlohmann::json actionParameterUnknown(std::string_view arg1, 294 std::string_view arg2) 295 { 296 return getLog( 297 redfish::message_registries::base::Index::actionParameterUnknown, 298 std::to_array({arg1, arg2})); 299 } 300 301 void actionParameterUnknown(crow::Response& res, std::string_view arg1, 302 std::string_view arg2) 303 { 304 res.result(boost::beast::http::status::bad_request); 305 addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2)); 306 } 307 308 /** 309 * @internal 310 * @brief Formats ResourceCannotBeDeleted message into JSON 311 * 312 * See header file for more information 313 * @endinternal 314 */ 315 nlohmann::json resourceCannotBeDeleted(void) 316 { 317 return getLog( 318 redfish::message_registries::base::Index::resourceCannotBeDeleted, {}); 319 } 320 321 void resourceCannotBeDeleted(crow::Response& res) 322 { 323 res.result(boost::beast::http::status::forbidden); 324 addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted()); 325 } 326 327 /** 328 * @internal 329 * @brief Formats PropertyDuplicate message into JSON 330 * 331 * See header file for more information 332 * @endinternal 333 */ 334 nlohmann::json propertyDuplicate(std::string_view arg1) 335 { 336 return getLog(redfish::message_registries::base::Index::propertyDuplicate, 337 std::to_array({arg1})); 338 } 339 340 void propertyDuplicate(crow::Response& res, std::string_view arg1) 341 { 342 res.result(boost::beast::http::status::bad_request); 343 addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1); 344 } 345 346 /** 347 * @internal 348 * @brief Formats ServiceTemporarilyUnavailable message into JSON 349 * 350 * See header file for more information 351 * @endinternal 352 */ 353 nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1) 354 { 355 return getLog( 356 redfish::message_registries::base::Index::serviceTemporarilyUnavailable, 357 std::to_array({arg1})); 358 } 359 360 void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1) 361 { 362 res.addHeader("Retry-After", arg1); 363 res.result(boost::beast::http::status::service_unavailable); 364 addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1)); 365 } 366 367 /** 368 * @internal 369 * @brief Formats ResourceAlreadyExists message into JSON 370 * 371 * See header file for more information 372 * @endinternal 373 */ 374 nlohmann::json resourceAlreadyExists(std::string_view arg1, 375 std::string_view arg2, 376 std::string_view arg3) 377 { 378 return getLog( 379 redfish::message_registries::base::Index::resourceAlreadyExists, 380 std::to_array({arg1, arg2, arg3})); 381 } 382 383 void resourceAlreadyExists(crow::Response& res, std::string_view arg1, 384 std::string_view arg2, std::string_view arg3) 385 { 386 res.result(boost::beast::http::status::bad_request); 387 addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3), 388 arg2); 389 } 390 391 /** 392 * @internal 393 * @brief Formats AccountForSessionNoLongerExists message into JSON 394 * 395 * See header file for more information 396 * @endinternal 397 */ 398 nlohmann::json accountForSessionNoLongerExists(void) 399 { 400 return getLog(redfish::message_registries::base::Index:: 401 accountForSessionNoLongerExists, 402 {}); 403 } 404 405 void accountForSessionNoLongerExists(crow::Response& res) 406 { 407 res.result(boost::beast::http::status::forbidden); 408 addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists()); 409 } 410 411 /** 412 * @internal 413 * @brief Formats CreateFailedMissingReqProperties message into JSON 414 * 415 * See header file for more information 416 * @endinternal 417 */ 418 nlohmann::json createFailedMissingReqProperties(std::string_view arg1) 419 { 420 return getLog(redfish::message_registries::base::Index:: 421 createFailedMissingReqProperties, 422 std::to_array({arg1})); 423 } 424 425 void createFailedMissingReqProperties(crow::Response& res, 426 std::string_view arg1) 427 { 428 res.result(boost::beast::http::status::bad_request); 429 addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1), 430 arg1); 431 } 432 433 /** 434 * @internal 435 * @brief Formats PropertyValueFormatError message into JSON for the specified 436 * property 437 * 438 * See header file for more information 439 * @endinternal 440 */ 441 nlohmann::json propertyValueFormatError(std::string_view arg1, 442 std::string_view arg2) 443 { 444 return getLog( 445 redfish::message_registries::base::Index::propertyValueFormatError, 446 std::to_array({arg1, arg2})); 447 } 448 449 void propertyValueFormatError(crow::Response& res, std::string_view arg1, 450 std::string_view arg2) 451 { 452 res.result(boost::beast::http::status::bad_request); 453 addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2); 454 } 455 456 /** 457 * @internal 458 * @brief Formats PropertyValueNotInList message into JSON for the specified 459 * property 460 * 461 * See header file for more information 462 * @endinternal 463 */ 464 nlohmann::json propertyValueNotInList(std::string_view arg1, 465 std::string_view arg2) 466 { 467 return getLog( 468 redfish::message_registries::base::Index::propertyValueNotInList, 469 std::to_array({arg1, arg2})); 470 } 471 472 void propertyValueNotInList(crow::Response& res, std::string_view arg1, 473 std::string_view arg2) 474 { 475 res.result(boost::beast::http::status::bad_request); 476 addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2); 477 } 478 479 /** 480 * @internal 481 * @brief Formats ResourceAtUriInUnknownFormat message into JSON 482 * 483 * See header file for more information 484 * @endinternal 485 */ 486 nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1) 487 { 488 std::string_view arg1str{arg1.data(), arg1.size()}; 489 return getLog( 490 redfish::message_registries::base::Index::resourceAtUriInUnknownFormat, 491 std::to_array({arg1str})); 492 } 493 494 void resourceAtUriInUnknownFormat(crow::Response& res, 495 const boost::urls::url_view& arg1) 496 { 497 res.result(boost::beast::http::status::bad_request); 498 addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1)); 499 } 500 501 /** 502 * @internal 503 * @brief Formats ServiceDisabled message into JSON 504 * 505 * See header file for more information 506 * @endinternal 507 */ 508 nlohmann::json serviceDisabled(std::string_view arg1) 509 { 510 return getLog(redfish::message_registries::base::Index::serviceDisabled, 511 std::to_array({arg1})); 512 } 513 514 void serviceDisabled(crow::Response& res, std::string_view arg1) 515 { 516 res.result(boost::beast::http::status::service_unavailable); 517 addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1)); 518 } 519 520 /** 521 * @internal 522 * @brief Formats ServiceInUnknownState message into JSON 523 * 524 * See header file for more information 525 * @endinternal 526 */ 527 nlohmann::json serviceInUnknownState(void) 528 { 529 return getLog( 530 redfish::message_registries::base::Index::serviceInUnknownState, {}); 531 } 532 533 void serviceInUnknownState(crow::Response& res) 534 { 535 res.result(boost::beast::http::status::service_unavailable); 536 addMessageToErrorJson(res.jsonValue, serviceInUnknownState()); 537 } 538 539 /** 540 * @internal 541 * @brief Formats EventSubscriptionLimitExceeded message into JSON 542 * 543 * See header file for more information 544 * @endinternal 545 */ 546 nlohmann::json eventSubscriptionLimitExceeded(void) 547 { 548 return getLog(redfish::message_registries::base::Index:: 549 eventSubscriptionLimitExceeded, 550 {}); 551 } 552 553 void eventSubscriptionLimitExceeded(crow::Response& res) 554 { 555 res.result(boost::beast::http::status::service_unavailable); 556 addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded()); 557 } 558 559 /** 560 * @internal 561 * @brief Formats ActionParameterMissing message into JSON 562 * 563 * See header file for more information 564 * @endinternal 565 */ 566 nlohmann::json actionParameterMissing(std::string_view arg1, 567 std::string_view arg2) 568 { 569 return getLog( 570 redfish::message_registries::base::Index::actionParameterMissing, 571 std::to_array({arg1, arg2})); 572 } 573 574 void actionParameterMissing(crow::Response& res, std::string_view arg1, 575 std::string_view arg2) 576 { 577 res.result(boost::beast::http::status::bad_request); 578 addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2)); 579 } 580 581 /** 582 * @internal 583 * @brief Formats StringValueTooLong message into JSON 584 * 585 * See header file for more information 586 * @endinternal 587 */ 588 nlohmann::json stringValueTooLong(std::string_view arg1, int arg2) 589 { 590 std::string arg2String = std::to_string(arg2); 591 return getLog(redfish::message_registries::base::Index::stringValueTooLong, 592 std::to_array({arg1, std::string_view(arg2String)})); 593 } 594 595 void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2) 596 { 597 res.result(boost::beast::http::status::bad_request); 598 addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2)); 599 } 600 601 /** 602 * @internal 603 * @brief Formats SessionTerminated message into JSON 604 * 605 * See header file for more information 606 * @endinternal 607 */ 608 nlohmann::json sessionTerminated(void) 609 { 610 return getLog(redfish::message_registries::base::Index::sessionTerminated, 611 {}); 612 } 613 614 void sessionTerminated(crow::Response& res) 615 { 616 res.result(boost::beast::http::status::ok); 617 addMessageToJsonRoot(res.jsonValue, sessionTerminated()); 618 } 619 620 /** 621 * @internal 622 * @brief Formats SubscriptionTerminated message into JSON 623 * 624 * See header file for more information 625 * @endinternal 626 */ 627 nlohmann::json subscriptionTerminated(void) 628 { 629 return getLog( 630 redfish::message_registries::base::Index::subscriptionTerminated, {}); 631 } 632 633 void subscriptionTerminated(crow::Response& res) 634 { 635 res.result(boost::beast::http::status::ok); 636 addMessageToJsonRoot(res.jsonValue, subscriptionTerminated()); 637 } 638 639 /** 640 * @internal 641 * @brief Formats ResourceTypeIncompatible message into JSON 642 * 643 * See header file for more information 644 * @endinternal 645 */ 646 nlohmann::json resourceTypeIncompatible(std::string_view arg1, 647 std::string_view arg2) 648 { 649 return getLog( 650 redfish::message_registries::base::Index::resourceTypeIncompatible, 651 std::to_array({arg1, arg2})); 652 } 653 654 void resourceTypeIncompatible(crow::Response& res, std::string_view arg1, 655 std::string_view arg2) 656 { 657 res.result(boost::beast::http::status::bad_request); 658 addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2)); 659 } 660 661 /** 662 * @internal 663 * @brief Formats ResetRequired message into JSON 664 * 665 * See header file for more information 666 * @endinternal 667 */ 668 nlohmann::json resetRequired(const boost::urls::url_view& arg1, 669 std::string_view arg2) 670 { 671 std::string_view arg1str(arg1.data(), arg1.size()); 672 return getLog(redfish::message_registries::base::Index::resetRequired, 673 std::to_array({arg1str, arg2})); 674 } 675 676 void resetRequired(crow::Response& res, const boost::urls::url_view& arg1, 677 std::string_view arg2) 678 { 679 res.result(boost::beast::http::status::bad_request); 680 addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2)); 681 } 682 683 /** 684 * @internal 685 * @brief Formats ChassisPowerStateOnRequired message into JSON 686 * 687 * See header file for more information 688 * @endinternal 689 */ 690 nlohmann::json chassisPowerStateOnRequired(std::string_view arg1) 691 { 692 return getLog(redfish::message_registries::base::Index::resetRequired, 693 std::to_array({arg1})); 694 } 695 696 void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1) 697 { 698 res.result(boost::beast::http::status::bad_request); 699 addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1)); 700 } 701 702 /** 703 * @internal 704 * @brief Formats ChassisPowerStateOffRequired message into JSON 705 * 706 * See header file for more information 707 * @endinternal 708 */ 709 nlohmann::json chassisPowerStateOffRequired(std::string_view arg1) 710 { 711 return getLog( 712 redfish::message_registries::base::Index::chassisPowerStateOffRequired, 713 std::to_array({arg1})); 714 } 715 716 void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1) 717 { 718 res.result(boost::beast::http::status::bad_request); 719 addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1)); 720 } 721 722 /** 723 * @internal 724 * @brief Formats PropertyValueConflict message into JSON 725 * 726 * See header file for more information 727 * @endinternal 728 */ 729 nlohmann::json propertyValueConflict(std::string_view arg1, 730 std::string_view arg2) 731 { 732 return getLog( 733 redfish::message_registries::base::Index::propertyValueConflict, 734 std::to_array({arg1, arg2})); 735 } 736 737 void propertyValueConflict(crow::Response& res, std::string_view arg1, 738 std::string_view arg2) 739 { 740 res.result(boost::beast::http::status::bad_request); 741 addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2)); 742 } 743 744 /** 745 * @internal 746 * @brief Formats PropertyValueIncorrect message into JSON 747 * 748 * See header file for more information 749 * @endinternal 750 */ 751 nlohmann::json propertyValueIncorrect(std::string_view arg1, 752 std::string_view arg2) 753 { 754 return getLog( 755 redfish::message_registries::base::Index::propertyValueIncorrect, 756 std::to_array({arg1, arg2})); 757 } 758 759 void propertyValueIncorrect(crow::Response& res, std::string_view arg1, 760 std::string_view arg2) 761 { 762 res.result(boost::beast::http::status::bad_request); 763 addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2)); 764 } 765 766 /** 767 * @internal 768 * @brief Formats ResourceCreationConflict message into JSON 769 * 770 * See header file for more information 771 * @endinternal 772 */ 773 nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1) 774 { 775 std::string_view arg1str(arg1.data(), arg1.size()); 776 return getLog( 777 redfish::message_registries::base::Index::resourceCreationConflict, 778 std::to_array({arg1str})); 779 } 780 781 void resourceCreationConflict(crow::Response& res, 782 const boost::urls::url_view& arg1) 783 { 784 res.result(boost::beast::http::status::bad_request); 785 addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1)); 786 } 787 788 /** 789 * @internal 790 * @brief Formats MaximumErrorsExceeded message into JSON 791 * 792 * See header file for more information 793 * @endinternal 794 */ 795 nlohmann::json maximumErrorsExceeded(void) 796 { 797 return getLog( 798 redfish::message_registries::base::Index::maximumErrorsExceeded, {}); 799 } 800 801 void maximumErrorsExceeded(crow::Response& res) 802 { 803 res.result(boost::beast::http::status::internal_server_error); 804 addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded()); 805 } 806 807 /** 808 * @internal 809 * @brief Formats PreconditionFailed message into JSON 810 * 811 * See header file for more information 812 * @endinternal 813 */ 814 nlohmann::json preconditionFailed(void) 815 { 816 return getLog(redfish::message_registries::base::Index::preconditionFailed, 817 {}); 818 } 819 820 void preconditionFailed(crow::Response& res) 821 { 822 res.result(boost::beast::http::status::precondition_failed); 823 addMessageToErrorJson(res.jsonValue, preconditionFailed()); 824 } 825 826 /** 827 * @internal 828 * @brief Formats PreconditionRequired message into JSON 829 * 830 * See header file for more information 831 * @endinternal 832 */ 833 nlohmann::json preconditionRequired(void) 834 { 835 return getLog( 836 redfish::message_registries::base::Index::preconditionRequired, {}); 837 } 838 839 void preconditionRequired(crow::Response& res) 840 { 841 res.result(boost::beast::http::status::bad_request); 842 addMessageToErrorJson(res.jsonValue, preconditionRequired()); 843 } 844 845 /** 846 * @internal 847 * @brief Formats OperationFailed message into JSON 848 * 849 * See header file for more information 850 * @endinternal 851 */ 852 nlohmann::json operationFailed(void) 853 { 854 return getLog(redfish::message_registries::base::Index::operationFailed, 855 {}); 856 } 857 858 void operationFailed(crow::Response& res) 859 { 860 res.result(boost::beast::http::status::internal_server_error); 861 addMessageToErrorJson(res.jsonValue, operationFailed()); 862 } 863 864 /** 865 * @internal 866 * @brief Formats OperationTimeout message into JSON 867 * 868 * See header file for more information 869 * @endinternal 870 */ 871 nlohmann::json operationTimeout(void) 872 { 873 return getLog(redfish::message_registries::base::Index::operationTimeout, 874 {}); 875 } 876 877 void operationTimeout(crow::Response& res) 878 { 879 res.result(boost::beast::http::status::internal_server_error); 880 addMessageToErrorJson(res.jsonValue, operationTimeout()); 881 } 882 883 /** 884 * @internal 885 * @brief Formats PropertyValueTypeError message into JSON for the specified 886 * property 887 * 888 * See header file for more information 889 * @endinternal 890 */ 891 nlohmann::json propertyValueTypeError(std::string_view arg1, 892 std::string_view arg2) 893 { 894 return getLog( 895 redfish::message_registries::base::Index::propertyValueTypeError, 896 std::to_array({arg1, arg2})); 897 } 898 899 void propertyValueTypeError(crow::Response& res, std::string_view arg1, 900 std::string_view arg2) 901 { 902 res.result(boost::beast::http::status::bad_request); 903 addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2); 904 } 905 906 /** 907 * @internal 908 * @brief Formats ResourceNotFound message into JSONd 909 * 910 * See header file for more information 911 * @endinternal 912 */ 913 nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2) 914 { 915 return getLog(redfish::message_registries::base::Index::resourceNotFound, 916 std::to_array({arg1, arg2})); 917 } 918 919 void resourceNotFound(crow::Response& res, std::string_view arg1, 920 std::string_view arg2) 921 { 922 res.result(boost::beast::http::status::not_found); 923 addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2)); 924 } 925 926 /** 927 * @internal 928 * @brief Formats CouldNotEstablishConnection message into JSON 929 * 930 * See header file for more information 931 * @endinternal 932 */ 933 nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1) 934 { 935 std::string_view arg1str(arg1.data(), arg1.size()); 936 return getLog( 937 redfish::message_registries::base::Index::couldNotEstablishConnection, 938 std::to_array({arg1str})); 939 } 940 941 void couldNotEstablishConnection(crow::Response& res, 942 const boost::urls::url_view& arg1) 943 { 944 res.result(boost::beast::http::status::not_found); 945 addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1)); 946 } 947 948 /** 949 * @internal 950 * @brief Formats PropertyNotWritable message into JSON for the specified 951 * property 952 * 953 * See header file for more information 954 * @endinternal 955 */ 956 nlohmann::json propertyNotWritable(std::string_view arg1) 957 { 958 return getLog(redfish::message_registries::base::Index::propertyNotWritable, 959 std::to_array({arg1})); 960 } 961 962 void propertyNotWritable(crow::Response& res, std::string_view arg1) 963 { 964 res.result(boost::beast::http::status::forbidden); 965 addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1); 966 } 967 968 /** 969 * @internal 970 * @brief Formats QueryParameterValueTypeError message into JSON 971 * 972 * See header file for more information 973 * @endinternal 974 */ 975 nlohmann::json queryParameterValueTypeError(std::string_view arg1, 976 std::string_view arg2) 977 { 978 return getLog( 979 redfish::message_registries::base::Index::queryParameterValueTypeError, 980 std::to_array({arg1, arg2})); 981 } 982 983 void queryParameterValueTypeError(crow::Response& res, std::string_view arg1, 984 std::string_view arg2) 985 { 986 res.result(boost::beast::http::status::bad_request); 987 addMessageToErrorJson(res.jsonValue, 988 queryParameterValueTypeError(arg1, arg2)); 989 } 990 991 /** 992 * @internal 993 * @brief Formats ServiceShuttingDown message into JSON 994 * 995 * See header file for more information 996 * @endinternal 997 */ 998 nlohmann::json serviceShuttingDown(void) 999 { 1000 return getLog(redfish::message_registries::base::Index::serviceShuttingDown, 1001 {}); 1002 } 1003 1004 void serviceShuttingDown(crow::Response& res) 1005 { 1006 res.result(boost::beast::http::status::service_unavailable); 1007 addMessageToErrorJson(res.jsonValue, serviceShuttingDown()); 1008 } 1009 1010 /** 1011 * @internal 1012 * @brief Formats ActionParameterDuplicate message into JSON 1013 * 1014 * See header file for more information 1015 * @endinternal 1016 */ 1017 nlohmann::json actionParameterDuplicate(std::string_view arg1, 1018 std::string_view arg2) 1019 { 1020 return getLog( 1021 redfish::message_registries::base::Index::actionParameterDuplicate, 1022 std::to_array({arg1, arg2})); 1023 } 1024 1025 void actionParameterDuplicate(crow::Response& res, std::string_view arg1, 1026 std::string_view arg2) 1027 { 1028 res.result(boost::beast::http::status::bad_request); 1029 addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2)); 1030 } 1031 1032 /** 1033 * @internal 1034 * @brief Formats ActionParameterNotSupported message into JSON 1035 * 1036 * See header file for more information 1037 * @endinternal 1038 */ 1039 nlohmann::json actionParameterNotSupported(std::string_view arg1, 1040 std::string_view arg2) 1041 { 1042 return getLog( 1043 redfish::message_registries::base::Index::actionParameterNotSupported, 1044 std::to_array({arg1, arg2})); 1045 } 1046 1047 void actionParameterNotSupported(crow::Response& res, std::string_view arg1, 1048 std::string_view arg2) 1049 { 1050 res.result(boost::beast::http::status::bad_request); 1051 addMessageToErrorJson(res.jsonValue, 1052 actionParameterNotSupported(arg1, arg2)); 1053 } 1054 1055 /** 1056 * @internal 1057 * @brief Formats SourceDoesNotSupportProtocol message into JSON 1058 * 1059 * See header file for more information 1060 * @endinternal 1061 */ 1062 nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1, 1063 std::string_view arg2) 1064 { 1065 std::string_view arg1str(arg1.data(), arg1.size()); 1066 return getLog( 1067 redfish::message_registries::base::Index::sourceDoesNotSupportProtocol, 1068 std::to_array({arg1str, arg2})); 1069 } 1070 1071 void sourceDoesNotSupportProtocol(crow::Response& res, 1072 const boost::urls::url_view& arg1, 1073 std::string_view arg2) 1074 { 1075 res.result(boost::beast::http::status::bad_request); 1076 addMessageToErrorJson(res.jsonValue, 1077 sourceDoesNotSupportProtocol(arg1, arg2)); 1078 } 1079 1080 /** 1081 * @internal 1082 * @brief Formats AccountRemoved message into JSON 1083 * 1084 * See header file for more information 1085 * @endinternal 1086 */ 1087 nlohmann::json accountRemoved(void) 1088 { 1089 return getLog(redfish::message_registries::base::Index::accountRemoved, {}); 1090 } 1091 1092 void accountRemoved(crow::Response& res) 1093 { 1094 res.result(boost::beast::http::status::ok); 1095 addMessageToJsonRoot(res.jsonValue, accountRemoved()); 1096 } 1097 1098 /** 1099 * @internal 1100 * @brief Formats AccessDenied message into JSON 1101 * 1102 * See header file for more information 1103 * @endinternal 1104 */ 1105 nlohmann::json accessDenied(const boost::urls::url_view& arg1) 1106 { 1107 std::string_view arg1str(arg1.data(), arg1.size()); 1108 return getLog(redfish::message_registries::base::Index::accessDenied, 1109 std::to_array({arg1str})); 1110 } 1111 1112 void accessDenied(crow::Response& res, const boost::urls::url_view& arg1) 1113 { 1114 res.result(boost::beast::http::status::forbidden); 1115 addMessageToErrorJson(res.jsonValue, accessDenied(arg1)); 1116 } 1117 1118 /** 1119 * @internal 1120 * @brief Formats QueryNotSupported message into JSON 1121 * 1122 * See header file for more information 1123 * @endinternal 1124 */ 1125 nlohmann::json queryNotSupported(void) 1126 { 1127 return getLog(redfish::message_registries::base::Index::queryNotSupported, 1128 {}); 1129 } 1130 1131 void queryNotSupported(crow::Response& res) 1132 { 1133 res.result(boost::beast::http::status::bad_request); 1134 addMessageToErrorJson(res.jsonValue, queryNotSupported()); 1135 } 1136 1137 /** 1138 * @internal 1139 * @brief Formats CreateLimitReachedForResource message into JSON 1140 * 1141 * See header file for more information 1142 * @endinternal 1143 */ 1144 nlohmann::json createLimitReachedForResource(void) 1145 { 1146 return getLog( 1147 redfish::message_registries::base::Index::createLimitReachedForResource, 1148 {}); 1149 } 1150 1151 void createLimitReachedForResource(crow::Response& res) 1152 { 1153 res.result(boost::beast::http::status::bad_request); 1154 addMessageToErrorJson(res.jsonValue, createLimitReachedForResource()); 1155 } 1156 1157 /** 1158 * @internal 1159 * @brief Formats GeneralError message into JSON 1160 * 1161 * See header file for more information 1162 * @endinternal 1163 */ 1164 nlohmann::json generalError(void) 1165 { 1166 return getLog(redfish::message_registries::base::Index::generalError, {}); 1167 } 1168 1169 void generalError(crow::Response& res) 1170 { 1171 res.result(boost::beast::http::status::internal_server_error); 1172 addMessageToErrorJson(res.jsonValue, generalError()); 1173 } 1174 1175 /** 1176 * @internal 1177 * @brief Formats Success message into JSON 1178 * 1179 * See header file for more information 1180 * @endinternal 1181 */ 1182 nlohmann::json success(void) 1183 { 1184 return getLog(redfish::message_registries::base::Index::success, {}); 1185 } 1186 1187 void success(crow::Response& res) 1188 { 1189 // don't set res.result here because success is the default and any 1190 // error should overwrite the default 1191 addMessageToJsonRoot(res.jsonValue, success()); 1192 } 1193 1194 /** 1195 * @internal 1196 * @brief Formats Created message into JSON 1197 * 1198 * See header file for more information 1199 * @endinternal 1200 */ 1201 nlohmann::json created(void) 1202 { 1203 return getLog(redfish::message_registries::base::Index::created, {}); 1204 } 1205 1206 void created(crow::Response& res) 1207 { 1208 res.result(boost::beast::http::status::created); 1209 addMessageToJsonRoot(res.jsonValue, created()); 1210 } 1211 1212 /** 1213 * @internal 1214 * @brief Formats NoOperation message into JSON 1215 * 1216 * See header file for more information 1217 * @endinternal 1218 */ 1219 nlohmann::json noOperation(void) 1220 { 1221 return getLog(redfish::message_registries::base::Index::noOperation, {}); 1222 } 1223 1224 void noOperation(crow::Response& res) 1225 { 1226 res.result(boost::beast::http::status::bad_request); 1227 addMessageToErrorJson(res.jsonValue, noOperation()); 1228 } 1229 1230 /** 1231 * @internal 1232 * @brief Formats PropertyUnknown message into JSON for the specified 1233 * property 1234 * 1235 * See header file for more information 1236 * @endinternal 1237 */ 1238 nlohmann::json propertyUnknown(std::string_view arg1) 1239 { 1240 return getLog(redfish::message_registries::base::Index::propertyUnknown, 1241 std::to_array({arg1})); 1242 } 1243 1244 void propertyUnknown(crow::Response& res, std::string_view arg1) 1245 { 1246 res.result(boost::beast::http::status::bad_request); 1247 addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1); 1248 } 1249 1250 /** 1251 * @internal 1252 * @brief Formats NoValidSession message into JSON 1253 * 1254 * See header file for more information 1255 * @endinternal 1256 */ 1257 nlohmann::json noValidSession(void) 1258 { 1259 return getLog(redfish::message_registries::base::Index::noValidSession, {}); 1260 } 1261 1262 void noValidSession(crow::Response& res) 1263 { 1264 res.result(boost::beast::http::status::forbidden); 1265 addMessageToErrorJson(res.jsonValue, noValidSession()); 1266 } 1267 1268 /** 1269 * @internal 1270 * @brief Formats InvalidObject message into JSON 1271 * 1272 * See header file for more information 1273 * @endinternal 1274 */ 1275 nlohmann::json invalidObject(const boost::urls::url_view& arg1) 1276 { 1277 std::string_view arg1str(arg1.data(), arg1.size()); 1278 return getLog(redfish::message_registries::base::Index::invalidObject, 1279 std::to_array({arg1str})); 1280 } 1281 1282 void invalidObject(crow::Response& res, const boost::urls::url_view& arg1) 1283 { 1284 res.result(boost::beast::http::status::bad_request); 1285 addMessageToErrorJson(res.jsonValue, invalidObject(arg1)); 1286 } 1287 1288 /** 1289 * @internal 1290 * @brief Formats ResourceInStandby message into JSON 1291 * 1292 * See header file for more information 1293 * @endinternal 1294 */ 1295 nlohmann::json resourceInStandby(void) 1296 { 1297 return getLog(redfish::message_registries::base::Index::resourceInStandby, 1298 {}); 1299 } 1300 1301 void resourceInStandby(crow::Response& res) 1302 { 1303 res.result(boost::beast::http::status::service_unavailable); 1304 addMessageToErrorJson(res.jsonValue, resourceInStandby()); 1305 } 1306 1307 /** 1308 * @internal 1309 * @brief Formats ActionParameterValueTypeError message into JSON 1310 * 1311 * See header file for more information 1312 * @endinternal 1313 */ 1314 nlohmann::json actionParameterValueTypeError(std::string_view arg1, 1315 std::string_view arg2, 1316 std::string_view arg3) 1317 { 1318 return getLog( 1319 redfish::message_registries::base::Index::actionParameterValueTypeError, 1320 std::to_array({arg1, arg2, arg3})); 1321 } 1322 1323 void actionParameterValueTypeError(crow::Response& res, std::string_view arg1, 1324 std::string_view arg2, std::string_view arg3) 1325 { 1326 res.result(boost::beast::http::status::bad_request); 1327 addMessageToErrorJson(res.jsonValue, 1328 actionParameterValueTypeError(arg1, arg2, arg3)); 1329 } 1330 1331 /** 1332 * @internal 1333 * @brief Formats SessionLimitExceeded message into JSON 1334 * 1335 * See header file for more information 1336 * @endinternal 1337 */ 1338 nlohmann::json sessionLimitExceeded(void) 1339 { 1340 return getLog( 1341 redfish::message_registries::base::Index::sessionLimitExceeded, {}); 1342 } 1343 1344 void sessionLimitExceeded(crow::Response& res) 1345 { 1346 res.result(boost::beast::http::status::service_unavailable); 1347 addMessageToErrorJson(res.jsonValue, sessionLimitExceeded()); 1348 } 1349 1350 /** 1351 * @internal 1352 * @brief Formats ActionNotSupported message into JSON 1353 * 1354 * See header file for more information 1355 * @endinternal 1356 */ 1357 nlohmann::json actionNotSupported(std::string_view arg1) 1358 { 1359 return getLog(redfish::message_registries::base::Index::actionNotSupported, 1360 std::to_array({arg1})); 1361 } 1362 1363 void actionNotSupported(crow::Response& res, std::string_view arg1) 1364 { 1365 res.result(boost::beast::http::status::bad_request); 1366 addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1)); 1367 } 1368 1369 /** 1370 * @internal 1371 * @brief Formats InvalidIndex message into JSON 1372 * 1373 * See header file for more information 1374 * @endinternal 1375 */ 1376 nlohmann::json invalidIndex(int64_t arg1) 1377 { 1378 std::string arg1Str = std::to_string(arg1); 1379 return getLog(redfish::message_registries::base::Index::invalidIndex, 1380 std::to_array<std::string_view>({arg1Str})); 1381 } 1382 1383 void invalidIndex(crow::Response& res, int64_t arg1) 1384 { 1385 res.result(boost::beast::http::status::bad_request); 1386 addMessageToErrorJson(res.jsonValue, invalidIndex(arg1)); 1387 } 1388 1389 /** 1390 * @internal 1391 * @brief Formats EmptyJSON message into JSON 1392 * 1393 * See header file for more information 1394 * @endinternal 1395 */ 1396 nlohmann::json emptyJSON(void) 1397 { 1398 return getLog(redfish::message_registries::base::Index::emptyJSON, {}); 1399 } 1400 1401 void emptyJSON(crow::Response& res) 1402 { 1403 res.result(boost::beast::http::status::bad_request); 1404 addMessageToErrorJson(res.jsonValue, emptyJSON()); 1405 } 1406 1407 /** 1408 * @internal 1409 * @brief Formats QueryNotSupportedOnResource message into JSON 1410 * 1411 * See header file for more information 1412 * @endinternal 1413 */ 1414 nlohmann::json queryNotSupportedOnResource(void) 1415 { 1416 return getLog( 1417 redfish::message_registries::base::Index::queryNotSupportedOnResource, 1418 {}); 1419 } 1420 1421 void queryNotSupportedOnResource(crow::Response& res) 1422 { 1423 res.result(boost::beast::http::status::forbidden); 1424 addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource()); 1425 } 1426 1427 /** 1428 * @internal 1429 * @brief Formats QueryNotSupportedOnOperation message into JSON 1430 * 1431 * See header file for more information 1432 * @endinternal 1433 */ 1434 nlohmann::json queryNotSupportedOnOperation(void) 1435 { 1436 return getLog( 1437 redfish::message_registries::base::Index::queryNotSupportedOnOperation, 1438 {}); 1439 } 1440 1441 void queryNotSupportedOnOperation(crow::Response& res) 1442 { 1443 res.result(boost::beast::http::status::forbidden); 1444 addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation()); 1445 } 1446 1447 /** 1448 * @internal 1449 * @brief Formats QueryCombinationInvalid message into JSON 1450 * 1451 * See header file for more information 1452 * @endinternal 1453 */ 1454 nlohmann::json queryCombinationInvalid(void) 1455 { 1456 return getLog( 1457 redfish::message_registries::base::Index::queryCombinationInvalid, {}); 1458 } 1459 1460 void queryCombinationInvalid(crow::Response& res) 1461 { 1462 res.result(boost::beast::http::status::bad_request); 1463 addMessageToErrorJson(res.jsonValue, queryCombinationInvalid()); 1464 } 1465 1466 /** 1467 * @internal 1468 * @brief Formats InsufficientPrivilege message into JSON 1469 * 1470 * See header file for more information 1471 * @endinternal 1472 */ 1473 nlohmann::json insufficientPrivilege(void) 1474 { 1475 return getLog( 1476 redfish::message_registries::base::Index::insufficientPrivilege, {}); 1477 } 1478 1479 void insufficientPrivilege(crow::Response& res) 1480 { 1481 res.result(boost::beast::http::status::forbidden); 1482 addMessageToErrorJson(res.jsonValue, insufficientPrivilege()); 1483 } 1484 1485 /** 1486 * @internal 1487 * @brief Formats PropertyValueModified message into JSON 1488 * 1489 * See header file for more information 1490 * @endinternal 1491 */ 1492 nlohmann::json propertyValueModified(std::string_view arg1, 1493 std::string_view arg2) 1494 { 1495 return getLog( 1496 redfish::message_registries::base::Index::propertyValueModified, 1497 std::to_array({arg1, arg2})); 1498 } 1499 1500 void propertyValueModified(crow::Response& res, std::string_view arg1, 1501 std::string_view arg2) 1502 { 1503 res.result(boost::beast::http::status::ok); 1504 addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1); 1505 } 1506 1507 /** 1508 * @internal 1509 * @brief Formats AccountNotModified message into JSON 1510 * 1511 * See header file for more information 1512 * @endinternal 1513 */ 1514 nlohmann::json accountNotModified(void) 1515 { 1516 return getLog(redfish::message_registries::base::Index::accountNotModified, 1517 {}); 1518 } 1519 1520 void accountNotModified(crow::Response& res) 1521 { 1522 res.result(boost::beast::http::status::bad_request); 1523 addMessageToErrorJson(res.jsonValue, accountNotModified()); 1524 } 1525 1526 /** 1527 * @internal 1528 * @brief Formats QueryParameterValueFormatError message into JSON 1529 * 1530 * See header file for more information 1531 * @endinternal 1532 */ 1533 nlohmann::json queryParameterValueFormatError(std::string_view arg1, 1534 std::string_view arg2) 1535 { 1536 return getLog(redfish::message_registries::base::Index:: 1537 queryParameterValueFormatError, 1538 std::to_array({arg1, arg2})); 1539 } 1540 1541 void queryParameterValueFormatError(crow::Response& res, std::string_view arg1, 1542 std::string_view arg2) 1543 { 1544 res.result(boost::beast::http::status::bad_request); 1545 addMessageToErrorJson(res.jsonValue, 1546 queryParameterValueFormatError(arg1, arg2)); 1547 } 1548 1549 /** 1550 * @internal 1551 * @brief Formats PropertyMissing message into JSON for the specified 1552 * property 1553 * 1554 * See header file for more information 1555 * @endinternal 1556 */ 1557 nlohmann::json propertyMissing(std::string_view arg1) 1558 { 1559 return getLog(redfish::message_registries::base::Index::propertyMissing, 1560 std::to_array({arg1})); 1561 } 1562 1563 void propertyMissing(crow::Response& res, std::string_view arg1) 1564 { 1565 res.result(boost::beast::http::status::bad_request); 1566 addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1); 1567 } 1568 1569 /** 1570 * @internal 1571 * @brief Formats ResourceExhaustion message into JSON 1572 * 1573 * See header file for more information 1574 * @endinternal 1575 */ 1576 nlohmann::json resourceExhaustion(std::string_view arg1) 1577 { 1578 return getLog(redfish::message_registries::base::Index::resourceExhaustion, 1579 std::to_array({arg1})); 1580 } 1581 1582 void resourceExhaustion(crow::Response& res, std::string_view arg1) 1583 { 1584 res.result(boost::beast::http::status::service_unavailable); 1585 addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1)); 1586 } 1587 1588 /** 1589 * @internal 1590 * @brief Formats AccountModified message into JSON 1591 * 1592 * See header file for more information 1593 * @endinternal 1594 */ 1595 nlohmann::json accountModified(void) 1596 { 1597 return getLog(redfish::message_registries::base::Index::accountModified, 1598 {}); 1599 } 1600 1601 void accountModified(crow::Response& res) 1602 { 1603 res.result(boost::beast::http::status::ok); 1604 addMessageToErrorJson(res.jsonValue, accountModified()); 1605 } 1606 1607 /** 1608 * @internal 1609 * @brief Formats QueryParameterOutOfRange message into JSON 1610 * 1611 * See header file for more information 1612 * @endinternal 1613 */ 1614 nlohmann::json queryParameterOutOfRange(std::string_view arg1, 1615 std::string_view arg2, 1616 std::string_view arg3) 1617 { 1618 return getLog( 1619 redfish::message_registries::base::Index::queryParameterOutOfRange, 1620 std::to_array({arg1, arg2, arg3})); 1621 } 1622 1623 void queryParameterOutOfRange(crow::Response& res, std::string_view arg1, 1624 std::string_view arg2, std::string_view arg3) 1625 { 1626 res.result(boost::beast::http::status::bad_request); 1627 addMessageToErrorJson(res.jsonValue, 1628 queryParameterOutOfRange(arg1, arg2, arg3)); 1629 } 1630 1631 nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1) 1632 { 1633 std::string_view arg1str(arg1.data(), arg1.size()); 1634 return getLog( 1635 redfish::message_registries::base::Index::passwordChangeRequired, 1636 std::to_array({arg1str})); 1637 } 1638 1639 /** 1640 * @internal 1641 * @brief Formats PasswordChangeRequired message into JSON 1642 * 1643 * See header file for more information 1644 * @endinternal 1645 */ 1646 void passwordChangeRequired(crow::Response& res, 1647 const boost::urls::url_view& arg1) 1648 { 1649 messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1)); 1650 } 1651 1652 void invalidUpload(crow::Response& res, std::string_view arg1, 1653 std::string_view arg2) 1654 { 1655 res.result(boost::beast::http::status::bad_request); 1656 addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2)); 1657 } 1658 1659 /** 1660 * @internal 1661 * @brief Formats Invalid File message into JSON 1662 * 1663 * See header file for more information 1664 * @endinternal 1665 */ 1666 nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2) 1667 { 1668 std::string msg = "Invalid file uploaded to "; 1669 msg += arg1; 1670 msg += ": "; 1671 msg += arg2; 1672 msg += "."; 1673 return nlohmann::json{ 1674 {"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"}, 1675 {"MessageId", "OpenBMC.0.2.InvalidUpload"}, 1676 {"Message", std::move(msg)}, 1677 {"MessageArgs", {arg1, arg2}}, 1678 {"MessageSeverity", "Warning"}, 1679 {"Resolution", "None."}}; 1680 } 1681 } // namespace messages 1682 1683 } // namespace redfish 1684