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