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