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