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 <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 messageIdIterator = message.find("MessageId"); 36 if (messageIdIterator == message.end()) 37 { 38 BMCWEB_LOG_CRITICAL 39 << "Attempt to add error message without MessageId"; 40 return; 41 } 42 43 auto messageFieldIterator = message.find("Message"); 44 if (messageFieldIterator == message.end()) 45 { 46 BMCWEB_LOG_CRITICAL 47 << "Attempt to add error message without Message"; 48 return; 49 } 50 error = {{"code", *messageIdIterator}, 51 {"message", *messageFieldIterator}}; 52 } 53 else 54 { 55 // More than 1 error occurred, so the message has to be generic 56 error["code"] = std::string(messageVersionPrefix) + "GeneralError"; 57 error["message"] = "A general error has occurred. See Resolution for " 58 "information on how to resolve the error."; 59 } 60 61 // This check could technically be done in in the default construction 62 // branch above, but because we need the pointer to the extended info field 63 // anyway, it's more efficient to do it here. 64 auto& extendedInfo = error[messages::messageAnnotation]; 65 if (!extendedInfo.is_array()) 66 { 67 extendedInfo = nlohmann::json::array(); 68 } 69 70 extendedInfo.push_back(message); 71 } 72 73 static void addMessageToJsonRoot(nlohmann::json& target, 74 const nlohmann::json& message) 75 { 76 if (!target[messages::messageAnnotation].is_array()) 77 { 78 // Force object to be an array 79 target[messages::messageAnnotation] = nlohmann::json::array(); 80 } 81 82 target[messages::messageAnnotation].push_back(message); 83 } 84 85 static void addMessageToJson(nlohmann::json& target, 86 const nlohmann::json& message, 87 const std::string& fieldPath) 88 { 89 std::string extendedInfo(fieldPath + messages::messageAnnotation); 90 91 if (!target[extendedInfo].is_array()) 92 { 93 // Force object to be an array 94 target[extendedInfo] = nlohmann::json::array(); 95 } 96 97 // Object exists and it is an array so we can just push in the message 98 target[extendedInfo].push_back(message); 99 } 100 101 /** 102 * @internal 103 * @brief Formats ResourceInUse message into JSON 104 * 105 * See header file for more information 106 * @endinternal 107 */ 108 nlohmann::json resourceInUse(void) 109 { 110 return nlohmann::json{ 111 {"@odata.type", "#Message.v1_0_0.Message"}, 112 {"MessageId", "Base.1.8.1.ResourceInUse"}, 113 {"Message", "The change to the requested resource failed because " 114 "the resource is in use or in transition."}, 115 {"MessageArgs", nlohmann::json::array()}, 116 {"MessageSeverity", "Warning"}, 117 {"Resolution", "Remove the condition and resubmit the request if " 118 "the operation failed."}}; 119 } 120 121 void resourceInUse(crow::Response& res) 122 { 123 res.result(boost::beast::http::status::service_unavailable); 124 addMessageToErrorJson(res.jsonValue, resourceInUse()); 125 } 126 127 /** 128 * @internal 129 * @brief Formats MalformedJSON message into JSON 130 * 131 * See header file for more information 132 * @endinternal 133 */ 134 nlohmann::json malformedJSON(void) 135 { 136 return nlohmann::json{ 137 {"@odata.type", "#Message.v1_0_0.Message"}, 138 {"MessageId", "Base.1.8.1.MalformedJSON"}, 139 {"Message", "The request body submitted was malformed JSON and " 140 "could not be parsed by the receiving service."}, 141 {"MessageArgs", nlohmann::json::array()}, 142 {"MessageSeverity", "Critical"}, 143 {"Resolution", "Ensure that the request body is valid JSON and " 144 "resubmit the request."}}; 145 } 146 147 void malformedJSON(crow::Response& res) 148 { 149 res.result(boost::beast::http::status::bad_request); 150 addMessageToErrorJson(res.jsonValue, malformedJSON()); 151 } 152 153 /** 154 * @internal 155 * @brief Formats ResourceMissingAtURI message into JSON 156 * 157 * See header file for more information 158 * @endinternal 159 */ 160 nlohmann::json resourceMissingAtURI(const std::string& arg1) 161 { 162 return nlohmann::json{ 163 {"@odata.type", "#Message.v1_0_0.Message"}, 164 {"MessageId", "Base.1.8.1.ResourceMissingAtURI"}, 165 {"Message", "The resource at the URI " + arg1 + " was not found."}, 166 {"MessageArgs", {arg1}}, 167 {"MessageSeverity", "Critical"}, 168 {"Resolution", "Place a valid resource at the URI or correct the " 169 "URI and resubmit the request."}}; 170 } 171 172 void resourceMissingAtURI(crow::Response& res, const std::string& arg1) 173 { 174 res.result(boost::beast::http::status::bad_request); 175 addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1)); 176 } 177 178 /** 179 * @internal 180 * @brief Formats ActionParameterValueFormatError message into JSON 181 * 182 * See header file for more information 183 * @endinternal 184 */ 185 nlohmann::json actionParameterValueFormatError(const std::string& arg1, 186 const std::string& arg2, 187 const std::string& arg3) 188 { 189 return nlohmann::json{ 190 {"@odata.type", "#Message.v1_0_0.Message"}, 191 {"MessageId", "Base.1.8.1.ActionParameterValueFormatError"}, 192 {"Message", 193 "The value " + arg1 + " for the parameter " + arg2 + 194 " in the action " + arg3 + 195 " is of a different format than the parameter can accept."}, 196 {"MessageArgs", {arg1, arg2, arg3}}, 197 {"MessageSeverity", "Warning"}, 198 {"Resolution", 199 "Correct the value for the parameter in the request body and " 200 "resubmit the request if the operation failed."}}; 201 } 202 203 void actionParameterValueFormatError(crow::Response& res, 204 const std::string& arg1, 205 const std::string& arg2, 206 const std::string& arg3) 207 { 208 res.result(boost::beast::http::status::bad_request); 209 addMessageToErrorJson(res.jsonValue, 210 actionParameterValueFormatError(arg1, arg2, arg3)); 211 } 212 213 /** 214 * @internal 215 * @brief Formats InternalError message into JSON 216 * 217 * See header file for more information 218 * @endinternal 219 */ 220 nlohmann::json internalError(void) 221 { 222 return nlohmann::json{ 223 {"@odata.type", "#Message.v1_0_0.Message"}, 224 {"MessageId", "Base.1.8.1.InternalError"}, 225 {"Message", "The request failed due to an internal service error. " 226 "The service is still operational."}, 227 {"MessageArgs", nlohmann::json::array()}, 228 {"MessageSeverity", "Critical"}, 229 {"Resolution", "Resubmit the request. If the problem persists, " 230 "consider resetting the service."}}; 231 } 232 233 void internalError(crow::Response& res) 234 { 235 res.result(boost::beast::http::status::internal_server_error); 236 addMessageToErrorJson(res.jsonValue, internalError()); 237 } 238 239 /** 240 * @internal 241 * @brief Formats UnrecognizedRequestBody message into JSON 242 * 243 * See header file for more information 244 * @endinternal 245 */ 246 nlohmann::json unrecognizedRequestBody(void) 247 { 248 return nlohmann::json{ 249 {"@odata.type", "#Message.v1_0_0.Message"}, 250 {"MessageId", "Base.1.8.1.UnrecognizedRequestBody"}, 251 {"Message", "The service detected a malformed request body that it " 252 "was unable to interpret."}, 253 {"MessageArgs", nlohmann::json::array()}, 254 {"MessageSeverity", "Warning"}, 255 {"Resolution", "Correct the request body and resubmit the request " 256 "if it failed."}}; 257 } 258 259 void unrecognizedRequestBody(crow::Response& res) 260 { 261 res.result(boost::beast::http::status::bad_request); 262 addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody()); 263 } 264 265 /** 266 * @internal 267 * @brief Formats ResourceAtUriUnauthorized message into JSON 268 * 269 * See header file for more information 270 * @endinternal 271 */ 272 nlohmann::json resourceAtUriUnauthorized(const std::string& arg1, 273 const std::string& arg2) 274 { 275 return nlohmann::json{ 276 {"@odata.type", "#Message.v1_0_0.Message"}, 277 {"MessageId", "Base.1.8.1.ResourceAtUriUnauthorized"}, 278 {"Message", "While accessing the resource at " + arg1 + 279 ", the service received an authorization error " + 280 arg2 + "."}, 281 {"MessageArgs", {arg1, arg2}}, 282 {"MessageSeverity", "Critical"}, 283 {"Resolution", "Ensure that the appropriate access is provided for " 284 "the service in order for it to access the URI."}}; 285 } 286 287 void resourceAtUriUnauthorized(crow::Response& res, const std::string& arg1, 288 const std::string& arg2) 289 { 290 res.result(boost::beast::http::status::unauthorized); 291 addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2)); 292 } 293 294 /** 295 * @internal 296 * @brief Formats ActionParameterUnknown message into JSON 297 * 298 * See header file for more information 299 * @endinternal 300 */ 301 nlohmann::json actionParameterUnknown(const std::string& arg1, 302 const std::string& arg2) 303 { 304 return nlohmann::json{ 305 {"@odata.type", "#Message.v1_0_0.Message"}, 306 {"MessageId", "Base.1.8.1.ActionParameterUnknown"}, 307 {"Message", "The action " + arg1 + 308 " was submitted with the invalid parameter " + arg2 + 309 "."}, 310 {"MessageArgs", {arg1, arg2}}, 311 {"MessageSeverity", "Warning"}, 312 {"Resolution", "Correct the invalid parameter and resubmit the " 313 "request if the operation failed."}}; 314 } 315 316 void actionParameterUnknown(crow::Response& res, const std::string& arg1, 317 const std::string& arg2) 318 { 319 res.result(boost::beast::http::status::bad_request); 320 addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2)); 321 } 322 323 /** 324 * @internal 325 * @brief Formats ResourceCannotBeDeleted message into JSON 326 * 327 * See header file for more information 328 * @endinternal 329 */ 330 nlohmann::json resourceCannotBeDeleted(void) 331 { 332 return nlohmann::json{ 333 {"@odata.type", "#Message.v1_0_0.Message"}, 334 {"MessageId", "Base.1.8.1.ResourceCannotBeDeleted"}, 335 {"Message", "The delete request failed because the resource " 336 "requested cannot be deleted."}, 337 {"MessageArgs", nlohmann::json::array()}, 338 {"MessageSeverity", "Critical"}, 339 {"Resolution", "Do not attempt to delete a non-deletable resource."}}; 340 } 341 342 void resourceCannotBeDeleted(crow::Response& res) 343 { 344 res.result(boost::beast::http::status::forbidden); 345 addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted()); 346 } 347 348 /** 349 * @internal 350 * @brief Formats PropertyDuplicate message into JSON 351 * 352 * See header file for more information 353 * @endinternal 354 */ 355 nlohmann::json propertyDuplicate(const std::string& arg1) 356 { 357 return nlohmann::json{ 358 {"@odata.type", "#Message.v1_0_0.Message"}, 359 {"MessageId", "Base.1.8.1.PropertyDuplicate"}, 360 {"Message", "The property " + arg1 + " was duplicated in the request."}, 361 {"MessageArgs", {arg1}}, 362 {"MessageSeverity", "Warning"}, 363 {"Resolution", 364 "Remove the duplicate property from the request body and resubmit " 365 "the request if the operation failed."}}; 366 } 367 368 void propertyDuplicate(crow::Response& res, const std::string& arg1) 369 { 370 res.result(boost::beast::http::status::bad_request); 371 addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1); 372 } 373 374 /** 375 * @internal 376 * @brief Formats ServiceTemporarilyUnavailable message into JSON 377 * 378 * See header file for more information 379 * @endinternal 380 */ 381 nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1) 382 { 383 return nlohmann::json{ 384 {"@odata.type", "#Message.v1_0_0.Message"}, 385 {"MessageId", "Base.1.8.1.ServiceTemporarilyUnavailable"}, 386 {"Message", "The service is temporarily unavailable. Retry in " + 387 arg1 + " seconds."}, 388 {"MessageArgs", {arg1}}, 389 {"MessageSeverity", "Critical"}, 390 {"Resolution", "Wait for the indicated retry duration and retry " 391 "the operation."}}; 392 } 393 394 void serviceTemporarilyUnavailable(crow::Response& res, const std::string& arg1) 395 { 396 res.addHeader("Retry-After", arg1); 397 res.result(boost::beast::http::status::service_unavailable); 398 addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1)); 399 } 400 401 /** 402 * @internal 403 * @brief Formats ResourceAlreadyExists message into JSON 404 * 405 * See header file for more information 406 * @endinternal 407 */ 408 nlohmann::json resourceAlreadyExists(const std::string& arg1, 409 const std::string& arg2, 410 const std::string& arg3) 411 { 412 return nlohmann::json{ 413 {"@odata.type", "#Message.v1_0_0.Message"}, 414 {"MessageId", "Base.1.8.1.ResourceAlreadyExists"}, 415 {"Message", "The requested resource of type " + arg1 + 416 " with the property " + arg2 + " with the value " + 417 arg3 + " already exists."}, 418 {"MessageArgs", {arg1, arg2, arg3}}, 419 {"MessageSeverity", "Critical"}, 420 {"Resolution", "Do not repeat the create operation as the resource " 421 "has already been created."}}; 422 } 423 424 void resourceAlreadyExists(crow::Response& res, const std::string& arg1, 425 const std::string& arg2, const std::string& arg3) 426 { 427 res.result(boost::beast::http::status::bad_request); 428 addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3), 429 arg2); 430 } 431 432 /** 433 * @internal 434 * @brief Formats AccountForSessionNoLongerExists message into JSON 435 * 436 * See header file for more information 437 * @endinternal 438 */ 439 nlohmann::json accountForSessionNoLongerExists(void) 440 { 441 return nlohmann::json{ 442 {"@odata.type", "#Message.v1_0_0.Message"}, 443 {"MessageId", "Base.1.8.1.AccountForSessionNoLongerExists"}, 444 {"Message", "The account for the current session has been removed, " 445 "thus the current session has been removed as well."}, 446 {"MessageArgs", nlohmann::json::array()}, 447 {"MessageSeverity", "OK"}, 448 {"Resolution", "Attempt to connect with a valid account."}}; 449 } 450 451 void accountForSessionNoLongerExists(crow::Response& res) 452 { 453 res.result(boost::beast::http::status::forbidden); 454 addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists()); 455 } 456 457 /** 458 * @internal 459 * @brief Formats CreateFailedMissingReqProperties message into JSON 460 * 461 * See header file for more information 462 * @endinternal 463 */ 464 nlohmann::json createFailedMissingReqProperties(const std::string& arg1) 465 { 466 return nlohmann::json{ 467 {"@odata.type", "#Message.v1_0_0.Message"}, 468 {"MessageId", "Base.1.8.1.CreateFailedMissingReqProperties"}, 469 {"Message", 470 "The create operation failed because the required property " + arg1 + 471 " was missing from the request."}, 472 {"MessageArgs", {arg1}}, 473 {"MessageSeverity", "Critical"}, 474 {"Resolution", 475 "Correct the body to include the required property with a valid " 476 "value and resubmit the request if the operation failed."}}; 477 } 478 479 void createFailedMissingReqProperties(crow::Response& res, 480 const std::string& arg1) 481 { 482 res.result(boost::beast::http::status::bad_request); 483 addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1), 484 arg1); 485 } 486 487 /** 488 * @internal 489 * @brief Formats PropertyValueFormatError message into JSON for the specified 490 * property 491 * 492 * See header file for more information 493 * @endinternal 494 */ 495 nlohmann::json propertyValueFormatError(const std::string& arg1, 496 const std::string& arg2) 497 { 498 return nlohmann::json{ 499 {"@odata.type", "#Message.v1_0_0.Message"}, 500 {"MessageId", "Base.1.8.1.PropertyValueFormatError"}, 501 {"Message", 502 "The value " + arg1 + " for the property " + arg2 + 503 " is of a different format than the property can accept."}, 504 {"MessageArgs", {arg1, arg2}}, 505 {"MessageSeverity", "Warning"}, 506 {"Resolution", 507 "Correct the value for the property in the request body and " 508 "resubmit the request if the operation failed."}}; 509 } 510 511 void propertyValueFormatError(crow::Response& res, const std::string& arg1, 512 const std::string& arg2) 513 { 514 res.result(boost::beast::http::status::bad_request); 515 addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2); 516 } 517 518 /** 519 * @internal 520 * @brief Formats PropertyValueNotInList message into JSON for the specified 521 * property 522 * 523 * See header file for more information 524 * @endinternal 525 */ 526 nlohmann::json propertyValueNotInList(const std::string& arg1, 527 const std::string& arg2) 528 { 529 return nlohmann::json{ 530 {"@odata.type", "#Message.v1_0_0.Message"}, 531 {"MessageId", "Base.1.8.1.PropertyValueNotInList"}, 532 {"Message", "The value " + arg1 + " for the property " + arg2 + 533 " is not in the list of acceptable values."}, 534 {"MessageArgs", {arg1, arg2}}, 535 {"MessageSeverity", "Warning"}, 536 {"Resolution", "Choose a value from the enumeration list that " 537 "the implementation " 538 "can support and resubmit the request if the " 539 "operation failed."}}; 540 } 541 542 void propertyValueNotInList(crow::Response& res, const std::string& arg1, 543 const std::string& arg2) 544 { 545 res.result(boost::beast::http::status::bad_request); 546 addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2); 547 } 548 549 /** 550 * @internal 551 * @brief Formats ResourceAtUriInUnknownFormat message into JSON 552 * 553 * See header file for more information 554 * @endinternal 555 */ 556 nlohmann::json resourceAtUriInUnknownFormat(const std::string& arg1) 557 { 558 return nlohmann::json{ 559 {"@odata.type", "#Message.v1_0_0.Message"}, 560 {"MessageId", "Base.1.8.1.ResourceAtUriInUnknownFormat"}, 561 {"Message", "The resource at " + arg1 + 562 " is in a format not recognized by the service."}, 563 {"MessageArgs", {arg1}}, 564 {"MessageSeverity", "Critical"}, 565 {"Resolution", "Place an image or resource or file that is " 566 "recognized by the service at the URI."}}; 567 } 568 569 void resourceAtUriInUnknownFormat(crow::Response& res, const std::string& arg1) 570 { 571 res.result(boost::beast::http::status::bad_request); 572 addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1)); 573 } 574 575 /** 576 * @internal 577 * @brief Formats ServiceInUnknownState message into JSON 578 * 579 * See header file for more information 580 * @endinternal 581 */ 582 nlohmann::json serviceInUnknownState(void) 583 { 584 return nlohmann::json{ 585 {"@odata.type", "#Message.v1_0_0.Message"}, 586 {"MessageId", "Base.1.8.1.ServiceInUnknownState"}, 587 {"Message", 588 "The operation failed because the service is in an unknown state " 589 "and can no longer take incoming requests."}, 590 {"MessageArgs", nlohmann::json::array()}, 591 {"MessageSeverity", "Critical"}, 592 {"Resolution", "Restart the service and resubmit the request if " 593 "the operation failed."}}; 594 } 595 596 void serviceInUnknownState(crow::Response& res) 597 { 598 res.result(boost::beast::http::status::service_unavailable); 599 addMessageToErrorJson(res.jsonValue, serviceInUnknownState()); 600 } 601 602 /** 603 * @internal 604 * @brief Formats EventSubscriptionLimitExceeded message into JSON 605 * 606 * See header file for more information 607 * @endinternal 608 */ 609 nlohmann::json eventSubscriptionLimitExceeded(void) 610 { 611 return nlohmann::json{ 612 {"@odata.type", "#Message.v1_0_0.Message"}, 613 {"MessageId", "Base.1.8.1.EventSubscriptionLimitExceeded"}, 614 {"Message", 615 "The event subscription failed due to the number of simultaneous " 616 "subscriptions exceeding the limit of the implementation."}, 617 {"MessageArgs", nlohmann::json::array()}, 618 {"MessageSeverity", "Critical"}, 619 {"Resolution", 620 "Reduce the number of other subscriptions before trying to " 621 "establish the event subscription or increase the limit of " 622 "simultaneous subscriptions (if supported)."}}; 623 } 624 625 void eventSubscriptionLimitExceeded(crow::Response& res) 626 { 627 res.result(boost::beast::http::status::service_unavailable); 628 addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded()); 629 } 630 631 /** 632 * @internal 633 * @brief Formats ActionParameterMissing message into JSON 634 * 635 * See header file for more information 636 * @endinternal 637 */ 638 nlohmann::json actionParameterMissing(const std::string& arg1, 639 const std::string& arg2) 640 { 641 return nlohmann::json{ 642 {"@odata.type", "#Message.v1_0_0.Message"}, 643 {"MessageId", "Base.1.8.1.ActionParameterMissing"}, 644 {"Message", "The action " + arg1 + " requires the parameter " + arg2 + 645 " to be present in the request body."}, 646 {"MessageArgs", {arg1, arg2}}, 647 {"MessageSeverity", "Critical"}, 648 {"Resolution", 649 "Supply the action with the required parameter in the request " 650 "body when the request is resubmitted."}}; 651 } 652 653 void actionParameterMissing(crow::Response& res, const std::string& arg1, 654 const std::string& arg2) 655 { 656 res.result(boost::beast::http::status::bad_request); 657 addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2)); 658 } 659 660 /** 661 * @internal 662 * @brief Formats StringValueTooLong message into JSON 663 * 664 * See header file for more information 665 * @endinternal 666 */ 667 nlohmann::json stringValueTooLong(const std::string& arg1, const int& arg2) 668 { 669 return nlohmann::json{ 670 {"@odata.type", "#Message.v1_0_0.Message"}, 671 {"MessageId", "Base.1.8.1.StringValueTooLong"}, 672 {"Message", "The string " + arg1 + " exceeds the length limit " + 673 std::to_string(arg2) + "."}, 674 {"MessageArgs", {arg1, std::to_string(arg2)}}, 675 {"MessageSeverity", "Warning"}, 676 {"Resolution", 677 "Resubmit the request with an appropriate string length."}}; 678 } 679 680 void stringValueTooLong(crow::Response& res, const std::string& arg1, 681 const int& arg2) 682 { 683 res.result(boost::beast::http::status::bad_request); 684 addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2)); 685 } 686 687 /** 688 * @internal 689 * @brief Formats SessionTerminated message into JSON 690 * 691 * See header file for more information 692 * @endinternal 693 */ 694 nlohmann::json sessionTerminated(void) 695 { 696 return nlohmann::json{ 697 {"@odata.type", "#Message.v1_0_0.Message"}, 698 {"MessageId", "Base.1.8.1.SessionTerminated"}, 699 {"Message", "The session was successfully terminated."}, 700 {"MessageArgs", nlohmann::json::array()}, 701 {"MessageSeverity", "OK"}, 702 {"Resolution", "No resolution is required."}}; 703 } 704 705 void sessionTerminated(crow::Response& res) 706 { 707 res.result(boost::beast::http::status::ok); 708 addMessageToJsonRoot(res.jsonValue, sessionTerminated()); 709 } 710 711 /** 712 * @internal 713 * @brief Formats SubscriptionTerminated message into JSON 714 * 715 * See header file for more information 716 * @endinternal 717 */ 718 nlohmann::json subscriptionTerminated(void) 719 { 720 return nlohmann::json{ 721 {"@odata.type", "#Message.v1_0_0.Message"}, 722 {"MessageId", "Base.1.8.1.SubscriptionTerminated"}, 723 {"Message", "The event subscription has been terminated."}, 724 {"MessageArgs", nlohmann::json::array()}, 725 {"MessageSeverity", "OK"}, 726 {"Resolution", "No resolution is required."}}; 727 } 728 729 void subscriptionTerminated(crow::Response& res) 730 { 731 res.result(boost::beast::http::status::ok); 732 addMessageToJsonRoot(res.jsonValue, subscriptionTerminated()); 733 } 734 735 /** 736 * @internal 737 * @brief Formats ResourceTypeIncompatible message into JSON 738 * 739 * See header file for more information 740 * @endinternal 741 */ 742 nlohmann::json resourceTypeIncompatible(const std::string& arg1, 743 const std::string& arg2) 744 { 745 return nlohmann::json{ 746 {"@odata.type", "#Message.v1_0_0.Message"}, 747 {"MessageId", "Base.1.8.1.ResourceTypeIncompatible"}, 748 {"Message", "The @odata.type of the request body " + arg1 + 749 " is incompatible with the @odata.type of the " 750 "resource which is " + 751 arg2 + "."}, 752 {"MessageArgs", {arg1, arg2}}, 753 {"MessageSeverity", "Critical"}, 754 {"Resolution", "Resubmit the request with a payload compatible " 755 "with the resource's schema."}}; 756 } 757 758 void resourceTypeIncompatible(crow::Response& res, const std::string& arg1, 759 const std::string& arg2) 760 { 761 res.result(boost::beast::http::status::bad_request); 762 addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2)); 763 } 764 765 /** 766 * @internal 767 * @brief Formats ResetRequired message into JSON 768 * 769 * See header file for more information 770 * @endinternal 771 */ 772 nlohmann::json resetRequired(const std::string& arg1, const std::string& arg2) 773 { 774 return nlohmann::json{ 775 {"@odata.type", "#Message.v1_0_0.Message"}, 776 {"MessageId", "Base.1.8.1.ResetRequired"}, 777 {"Message", "In order to complete the operation, a component reset is " 778 "required with the Reset action URI '" + 779 arg1 + "' and ResetType '" + arg2 + "'."}, 780 {"MessageArgs", {arg1, arg2}}, 781 {"MessageSeverity", "Warning"}, 782 {"Resolution", 783 "Perform the required Reset action on the specified component."}}; 784 } 785 786 void resetRequired(crow::Response& res, const std::string& arg1, 787 const std::string& arg2) 788 { 789 res.result(boost::beast::http::status::bad_request); 790 addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2)); 791 } 792 793 /** 794 * @internal 795 * @brief Formats ChassisPowerStateOnRequired message into JSON 796 * 797 * See header file for more information 798 * @endinternal 799 */ 800 nlohmann::json chassisPowerStateOnRequired(const std::string& arg1) 801 { 802 return nlohmann::json{ 803 {"@odata.type", "#Message.v1_0_0.Message"}, 804 {"MessageId", "Base.1.8.1.ChassisPowerStateOnRequired"}, 805 {"Message", "The Chassis with Id '" + arg1 + 806 "' requires to be powered on to perform this request."}, 807 {"MessageArgs", {arg1}}, 808 {"MessageSeverity", "Warning"}, 809 {"Resolution", 810 "Power on the specified Chassis and resubmit the request."}}; 811 } 812 813 void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1) 814 { 815 res.result(boost::beast::http::status::bad_request); 816 addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1)); 817 } 818 819 /** 820 * @internal 821 * @brief Formats ChassisPowerStateOffRequired message into JSON 822 * 823 * See header file for more information 824 * @endinternal 825 */ 826 nlohmann::json chassisPowerStateOffRequired(const std::string& arg1) 827 { 828 return nlohmann::json{ 829 {"@odata.type", "#Message.v1_0_0.Message"}, 830 {"MessageId", "Base.1.8.1.ChassisPowerStateOffRequired"}, 831 {"Message", 832 "The Chassis with Id '" + arg1 + 833 "' requires to be powered off to perform this request."}, 834 {"MessageArgs", {arg1}}, 835 {"MessageSeverity", "Warning"}, 836 {"Resolution", 837 "Power off the specified Chassis and resubmit the request."}}; 838 } 839 840 void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1) 841 { 842 res.result(boost::beast::http::status::bad_request); 843 addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1)); 844 } 845 846 /** 847 * @internal 848 * @brief Formats PropertyValueConflict message into JSON 849 * 850 * See header file for more information 851 * @endinternal 852 */ 853 nlohmann::json propertyValueConflict(const std::string& arg1, 854 const std::string& arg2) 855 { 856 return nlohmann::json{ 857 {"@odata.type", "#Message.v1_0_0.Message"}, 858 {"MessageId", "Base.1.8.1.PropertyValueConflict"}, 859 {"Message", "The property '" + arg1 + 860 "' could not be written because its value would " 861 "conflict with the value of the '" + 862 arg2 + "' property."}, 863 {"MessageArgs", {arg1, arg2}}, 864 {"MessageSeverity", "Warning"}, 865 {"Resolution", "No resolution is required."}}; 866 } 867 868 void propertyValueConflict(crow::Response& res, const std::string& arg1, 869 const std::string& arg2) 870 { 871 res.result(boost::beast::http::status::bad_request); 872 addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2)); 873 } 874 875 /** 876 * @internal 877 * @brief Formats PropertyValueIncorrect message into JSON 878 * 879 * See header file for more information 880 * @endinternal 881 */ 882 nlohmann::json propertyValueIncorrect(const std::string& arg1, 883 const std::string& arg2) 884 { 885 return nlohmann::json{ 886 {"@odata.type", "#Message.v1_0_0.Message"}, 887 {"MessageId", "Base.1.8.1.PropertyValueIncorrect"}, 888 {"Message", "The property '" + arg1 + 889 "' with the requested value of '" + arg2 + 890 "' could not be written because the value does not " 891 "meet the constraints of the implementation."}, 892 {"MessageArgs", {arg1, arg2}}, 893 {"MessageSeverity", "Warning"}, 894 {"Resolution", "No resolution is required."}}; 895 } 896 897 void propertyValueIncorrect(crow::Response& res, const std::string& arg1, 898 const std::string& arg2) 899 { 900 res.result(boost::beast::http::status::bad_request); 901 addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2)); 902 } 903 904 /** 905 * @internal 906 * @brief Formats ResourceCreationConflict message into JSON 907 * 908 * See header file for more information 909 * @endinternal 910 */ 911 nlohmann::json resourceCreationConflict(const std::string& arg1) 912 { 913 return nlohmann::json{ 914 {"@odata.type", "#Message.v1_0_0.Message"}, 915 {"MessageId", "Base.1.8.1.ResourceCreationConflict"}, 916 {"Message", "The resource could not be created. The service has a " 917 "resource at URI '" + 918 arg1 + "' that conflicts with the creation request."}, 919 {"MessageArgs", {arg1}}, 920 {"MessageSeverity", "Warning"}, 921 {"Resolution", "No resolution is required."}}; 922 } 923 924 void resourceCreationConflict(crow::Response& res, const std::string& arg1) 925 { 926 res.result(boost::beast::http::status::bad_request); 927 addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1)); 928 } 929 930 /** 931 * @internal 932 * @brief Formats MaximumErrorsExceeded message into JSON 933 * 934 * See header file for more information 935 * @endinternal 936 */ 937 nlohmann::json maximumErrorsExceeded(void) 938 { 939 return nlohmann::json{ 940 {"@odata.type", "#Message.v1_0_0.Message"}, 941 {"MessageId", "Base.1.8.1.MaximumErrorsExceeded"}, 942 {"Message", "Too many errors have occurred to report them all."}, 943 {"MessageArgs", nlohmann::json::array()}, 944 {"MessageSeverity", "Critical"}, 945 {"Resolution", 946 "Resolve other reported errors and retry the current operation."}}; 947 } 948 949 void maximumErrorsExceeded(crow::Response& res) 950 { 951 res.result(boost::beast::http::status::internal_server_error); 952 addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded()); 953 } 954 955 /** 956 * @internal 957 * @brief Formats PreconditionFailed message into JSON 958 * 959 * See header file for more information 960 * @endinternal 961 */ 962 nlohmann::json preconditionFailed(void) 963 { 964 return nlohmann::json{ 965 {"@odata.type", "#Message.v1_0_0.Message"}, 966 {"MessageId", "Base.1.8.1.PreconditionFailed"}, 967 {"Message", "The ETag supplied did not match the ETag required to " 968 "change this resource."}, 969 {"MessageArgs", nlohmann::json::array()}, 970 {"MessageSeverity", "Critical"}, 971 {"Resolution", "Try the operation again using the appropriate ETag."}}; 972 } 973 974 void preconditionFailed(crow::Response& res) 975 { 976 res.result(boost::beast::http::status::bad_request); 977 addMessageToErrorJson(res.jsonValue, preconditionFailed()); 978 } 979 980 /** 981 * @internal 982 * @brief Formats PreconditionRequired message into JSON 983 * 984 * See header file for more information 985 * @endinternal 986 */ 987 nlohmann::json preconditionRequired(void) 988 { 989 return nlohmann::json{ 990 {"@odata.type", "#Message.v1_0_0.Message"}, 991 {"MessageId", "Base.1.8.1.PreconditionRequired"}, 992 {"Message", "A precondition header or annotation is required to change " 993 "this resource."}, 994 {"MessageArgs", nlohmann::json::array()}, 995 {"MessageSeverity", "Critical"}, 996 {"Resolution", "Try the operation again using an If-Match or " 997 "If-None-Match header and appropriate ETag."}}; 998 } 999 1000 void preconditionRequired(crow::Response& res) 1001 { 1002 res.result(boost::beast::http::status::bad_request); 1003 addMessageToErrorJson(res.jsonValue, preconditionRequired()); 1004 } 1005 1006 /** 1007 * @internal 1008 * @brief Formats OperationFailed message into JSON 1009 * 1010 * See header file for more information 1011 * @endinternal 1012 */ 1013 nlohmann::json operationFailed(void) 1014 { 1015 return nlohmann::json{ 1016 {"@odata.type", "#Message.v1_0_0.Message"}, 1017 {"MessageId", "Base.1.8.1.OperationFailed"}, 1018 {"Message", 1019 "An error occurred internal to the service as part of the overall " 1020 "request. Partial results may have been returned."}, 1021 {"MessageArgs", nlohmann::json::array()}, 1022 {"MessageSeverity", "Warning"}, 1023 {"Resolution", "Resubmit the request. If the problem persists, " 1024 "consider resetting the service or provider."}}; 1025 } 1026 1027 void operationFailed(crow::Response& res) 1028 { 1029 res.result(boost::beast::http::status::internal_server_error); 1030 addMessageToErrorJson(res.jsonValue, operationFailed()); 1031 } 1032 1033 /** 1034 * @internal 1035 * @brief Formats OperationTimeout message into JSON 1036 * 1037 * See header file for more information 1038 * @endinternal 1039 */ 1040 nlohmann::json operationTimeout(void) 1041 { 1042 return nlohmann::json{ 1043 {"@odata.type", "#Message.v1_0_0.Message"}, 1044 {"MessageId", "Base.1.8.1.OperationTimeout"}, 1045 {"Message", "A timeout internal to the service occured as part of the " 1046 "request. Partial results may have been returned."}, 1047 {"MessageArgs", nlohmann::json::array()}, 1048 {"MessageSeverity", "Warning"}, 1049 {"Resolution", "Resubmit the request. If the problem persists, " 1050 "consider resetting the service or provider."}}; 1051 } 1052 1053 void operationTimeout(crow::Response& res) 1054 { 1055 res.result(boost::beast::http::status::internal_server_error); 1056 addMessageToErrorJson(res.jsonValue, operationTimeout()); 1057 } 1058 1059 /** 1060 * @internal 1061 * @brief Formats PropertyValueTypeError message into JSON for the specified 1062 * property 1063 * 1064 * See header file for more information 1065 * @endinternal 1066 */ 1067 nlohmann::json propertyValueTypeError(const std::string& arg1, 1068 const std::string& arg2) 1069 { 1070 return nlohmann::json{ 1071 {"@odata.type", "#Message.v1_0_0.Message"}, 1072 {"MessageId", "Base.1.8.1.PropertyValueTypeError"}, 1073 {"Message", 1074 "The value " + arg1 + " for the property " + arg2 + 1075 " is of a different type than the property can accept."}, 1076 {"MessageArgs", {arg1, arg2}}, 1077 {"MessageSeverity", "Warning"}, 1078 {"Resolution", 1079 "Correct the value for the property in the request body and " 1080 "resubmit the request if the operation failed."}}; 1081 } 1082 1083 void propertyValueTypeError(crow::Response& res, const std::string& arg1, 1084 const std::string& arg2) 1085 { 1086 res.result(boost::beast::http::status::bad_request); 1087 addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2); 1088 } 1089 1090 /** 1091 * @internal 1092 * @brief Formats ResourceNotFound message into JSON 1093 * 1094 * See header file for more information 1095 * @endinternal 1096 */ 1097 nlohmann::json resourceNotFound(const std::string& arg1, 1098 const std::string& arg2) 1099 { 1100 return nlohmann::json{ 1101 {"@odata.type", "#Message.v1_0_0.Message"}, 1102 {"MessageId", "Base.1.8.1.ResourceNotFound"}, 1103 {"Message", "The requested resource of type " + arg1 + " named " + 1104 arg2 + " was not found."}, 1105 {"MessageArgs", {arg1, arg2}}, 1106 {"MessageSeverity", "Critical"}, 1107 {"Resolution", 1108 "Provide a valid resource identifier and resubmit the request."}}; 1109 } 1110 1111 void resourceNotFound(crow::Response& res, const std::string& arg1, 1112 const std::string& arg2) 1113 { 1114 res.result(boost::beast::http::status::not_found); 1115 addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2)); 1116 } 1117 1118 /** 1119 * @internal 1120 * @brief Formats CouldNotEstablishConnection message into JSON 1121 * 1122 * See header file for more information 1123 * @endinternal 1124 */ 1125 nlohmann::json couldNotEstablishConnection(const std::string& arg1) 1126 { 1127 return nlohmann::json{ 1128 {"@odata.type", "#Message.v1_0_0.Message"}, 1129 {"MessageId", "Base.1.8.1.CouldNotEstablishConnection"}, 1130 {"Message", 1131 "The service failed to establish a connection with the URI " + arg1 + 1132 "."}, 1133 {"MessageArgs", {arg1}}, 1134 {"MessageSeverity", "Critical"}, 1135 {"Resolution", 1136 "Ensure that the URI contains a valid and reachable node name, " 1137 "protocol information and other URI components."}}; 1138 } 1139 1140 void couldNotEstablishConnection(crow::Response& res, const std::string& arg1) 1141 { 1142 res.result(boost::beast::http::status::not_found); 1143 addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1)); 1144 } 1145 1146 /** 1147 * @internal 1148 * @brief Formats PropertyNotWritable message into JSON for the specified 1149 * property 1150 * 1151 * See header file for more information 1152 * @endinternal 1153 */ 1154 nlohmann::json propertyNotWritable(const std::string& arg1) 1155 { 1156 return nlohmann::json{ 1157 {"@odata.type", "#Message.v1_0_0.Message"}, 1158 {"MessageId", "Base.1.8.1.PropertyNotWritable"}, 1159 {"Message", "The property " + arg1 + 1160 " is a read only property and cannot be " 1161 "assigned a value."}, 1162 {"MessageArgs", {arg1}}, 1163 {"MessageSeverity", "Warning"}, 1164 {"Resolution", "Remove the property from the request body and " 1165 "resubmit the request if the operation failed."}}; 1166 } 1167 1168 void propertyNotWritable(crow::Response& res, const std::string& arg1) 1169 { 1170 res.result(boost::beast::http::status::forbidden); 1171 addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1); 1172 } 1173 1174 /** 1175 * @internal 1176 * @brief Formats QueryParameterValueTypeError message into JSON 1177 * 1178 * See header file for more information 1179 * @endinternal 1180 */ 1181 nlohmann::json queryParameterValueTypeError(const std::string& arg1, 1182 const std::string& arg2) 1183 { 1184 return nlohmann::json{ 1185 {"@odata.type", "#Message.v1_0_0.Message"}, 1186 {"MessageId", "Base.1.8.1.QueryParameterValueTypeError"}, 1187 {"Message", 1188 "The value " + arg1 + " for the query parameter " + arg2 + 1189 " is of a different type than the parameter can accept."}, 1190 {"MessageArgs", {arg1, arg2}}, 1191 {"MessageSeverity", "Warning"}, 1192 {"Resolution", 1193 "Correct the value for the query parameter in the request and " 1194 "resubmit the request if the operation failed."}}; 1195 } 1196 1197 void queryParameterValueTypeError(crow::Response& res, const std::string& arg1, 1198 const std::string& arg2) 1199 { 1200 res.result(boost::beast::http::status::bad_request); 1201 addMessageToErrorJson(res.jsonValue, 1202 queryParameterValueTypeError(arg1, arg2)); 1203 } 1204 1205 /** 1206 * @internal 1207 * @brief Formats ServiceShuttingDown message into JSON 1208 * 1209 * See header file for more information 1210 * @endinternal 1211 */ 1212 nlohmann::json serviceShuttingDown(void) 1213 { 1214 return nlohmann::json{ 1215 {"@odata.type", "#Message.v1_0_0.Message"}, 1216 {"MessageId", "Base.1.8.1.ServiceShuttingDown"}, 1217 {"Message", "The operation failed because the service is shutting " 1218 "down and can no longer take incoming requests."}, 1219 {"MessageArgs", nlohmann::json::array()}, 1220 {"MessageSeverity", "Critical"}, 1221 {"Resolution", "When the service becomes available, resubmit the " 1222 "request if the operation failed."}}; 1223 } 1224 1225 void serviceShuttingDown(crow::Response& res) 1226 { 1227 res.result(boost::beast::http::status::service_unavailable); 1228 addMessageToErrorJson(res.jsonValue, serviceShuttingDown()); 1229 } 1230 1231 /** 1232 * @internal 1233 * @brief Formats ActionParameterDuplicate message into JSON 1234 * 1235 * See header file for more information 1236 * @endinternal 1237 */ 1238 nlohmann::json actionParameterDuplicate(const std::string& arg1, 1239 const std::string& arg2) 1240 { 1241 return nlohmann::json{ 1242 {"@odata.type", "#Message.v1_0_0.Message"}, 1243 {"MessageId", "Base.1.8.1.ActionParameterDuplicate"}, 1244 {"Message", 1245 "The action " + arg1 + 1246 " was submitted with more than one value for the parameter " + 1247 arg2 + "."}, 1248 {"MessageArgs", {arg1, arg2}}, 1249 {"MessageSeverity", "Warning"}, 1250 {"Resolution", 1251 "Resubmit the action with only one instance of the parameter in " 1252 "the request body if the operation failed."}}; 1253 } 1254 1255 void actionParameterDuplicate(crow::Response& res, const std::string& arg1, 1256 const std::string& arg2) 1257 { 1258 res.result(boost::beast::http::status::bad_request); 1259 addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2)); 1260 } 1261 1262 /** 1263 * @internal 1264 * @brief Formats ActionParameterNotSupported message into JSON 1265 * 1266 * See header file for more information 1267 * @endinternal 1268 */ 1269 nlohmann::json actionParameterNotSupported(const std::string& arg1, 1270 const std::string& arg2) 1271 { 1272 return nlohmann::json{ 1273 {"@odata.type", "#Message.v1_0_0.Message"}, 1274 {"MessageId", "Base.1.8.1.ActionParameterNotSupported"}, 1275 {"Message", "The parameter " + arg1 + " for the action " + arg2 + 1276 " is not supported on the target resource."}, 1277 {"MessageArgs", {arg1, arg2}}, 1278 {"MessageSeverity", "Warning"}, 1279 {"Resolution", "Remove the parameter supplied and resubmit the " 1280 "request if the operation failed."}}; 1281 } 1282 1283 void actionParameterNotSupported(crow::Response& res, const std::string& arg1, 1284 const std::string& arg2) 1285 { 1286 res.result(boost::beast::http::status::bad_request); 1287 addMessageToErrorJson(res.jsonValue, 1288 actionParameterNotSupported(arg1, arg2)); 1289 } 1290 1291 /** 1292 * @internal 1293 * @brief Formats SourceDoesNotSupportProtocol message into JSON 1294 * 1295 * See header file for more information 1296 * @endinternal 1297 */ 1298 nlohmann::json sourceDoesNotSupportProtocol(const std::string& arg1, 1299 const std::string& arg2) 1300 { 1301 return nlohmann::json{ 1302 {"@odata.type", "#Message.v1_0_0.Message"}, 1303 {"MessageId", "Base.1.8.1.SourceDoesNotSupportProtocol"}, 1304 {"Message", "The other end of the connection at " + arg1 + 1305 " does not support the specified protocol " + arg2 + 1306 "."}, 1307 {"MessageArgs", {arg1, arg2}}, 1308 {"MessageSeverity", "Critical"}, 1309 {"Resolution", "Change protocols or URIs. "}}; 1310 } 1311 1312 void sourceDoesNotSupportProtocol(crow::Response& res, const std::string& arg1, 1313 const std::string& arg2) 1314 { 1315 res.result(boost::beast::http::status::bad_request); 1316 addMessageToErrorJson(res.jsonValue, 1317 sourceDoesNotSupportProtocol(arg1, arg2)); 1318 } 1319 1320 /** 1321 * @internal 1322 * @brief Formats AccountRemoved message into JSON 1323 * 1324 * See header file for more information 1325 * @endinternal 1326 */ 1327 nlohmann::json accountRemoved(void) 1328 { 1329 return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, 1330 {"MessageId", "Base.1.8.1.AccountRemoved"}, 1331 {"Message", "The account was successfully removed."}, 1332 {"MessageArgs", nlohmann::json::array()}, 1333 {"MessageSeverity", "OK"}, 1334 {"Resolution", "No resolution is required."}}; 1335 } 1336 1337 void accountRemoved(crow::Response& res) 1338 { 1339 res.result(boost::beast::http::status::ok); 1340 addMessageToJsonRoot(res.jsonValue, accountRemoved()); 1341 } 1342 1343 /** 1344 * @internal 1345 * @brief Formats AccessDenied message into JSON 1346 * 1347 * See header file for more information 1348 * @endinternal 1349 */ 1350 nlohmann::json accessDenied(const std::string& arg1) 1351 { 1352 return nlohmann::json{ 1353 {"@odata.type", "#Message.v1_0_0.Message"}, 1354 {"MessageId", "Base.1.8.1.AccessDenied"}, 1355 {"Message", "While attempting to establish a connection to " + arg1 + 1356 ", the service denied access."}, 1357 {"MessageArgs", {arg1}}, 1358 {"MessageSeverity", "Critical"}, 1359 {"Resolution", "Attempt to ensure that the URI is correct and that " 1360 "the service has the appropriate credentials."}}; 1361 } 1362 1363 void accessDenied(crow::Response& res, const std::string& arg1) 1364 { 1365 res.result(boost::beast::http::status::forbidden); 1366 addMessageToErrorJson(res.jsonValue, accessDenied(arg1)); 1367 } 1368 1369 /** 1370 * @internal 1371 * @brief Formats QueryNotSupported message into JSON 1372 * 1373 * See header file for more information 1374 * @endinternal 1375 */ 1376 nlohmann::json queryNotSupported(void) 1377 { 1378 return nlohmann::json{ 1379 {"@odata.type", "#Message.v1_0_0.Message"}, 1380 {"MessageId", "Base.1.8.1.QueryNotSupported"}, 1381 {"Message", "Querying is not supported by the implementation."}, 1382 {"MessageArgs", nlohmann::json::array()}, 1383 {"MessageSeverity", "Warning"}, 1384 {"Resolution", "Remove the query parameters and resubmit the " 1385 "request if the operation failed."}}; 1386 } 1387 1388 void queryNotSupported(crow::Response& res) 1389 { 1390 res.result(boost::beast::http::status::bad_request); 1391 addMessageToErrorJson(res.jsonValue, queryNotSupported()); 1392 } 1393 1394 /** 1395 * @internal 1396 * @brief Formats CreateLimitReachedForResource message into JSON 1397 * 1398 * See header file for more information 1399 * @endinternal 1400 */ 1401 nlohmann::json createLimitReachedForResource(void) 1402 { 1403 return nlohmann::json{ 1404 {"@odata.type", "#Message.v1_0_0.Message"}, 1405 {"MessageId", "Base.1.8.1.CreateLimitReachedForResource"}, 1406 {"Message", "The create operation failed because the resource has " 1407 "reached the limit of possible resources."}, 1408 {"MessageArgs", nlohmann::json::array()}, 1409 {"MessageSeverity", "Critical"}, 1410 {"Resolution", 1411 "Either delete resources and resubmit the request if the " 1412 "operation failed or do not resubmit the request."}}; 1413 } 1414 1415 void createLimitReachedForResource(crow::Response& res) 1416 { 1417 res.result(boost::beast::http::status::bad_request); 1418 addMessageToErrorJson(res.jsonValue, createLimitReachedForResource()); 1419 } 1420 1421 /** 1422 * @internal 1423 * @brief Formats GeneralError message into JSON 1424 * 1425 * See header file for more information 1426 * @endinternal 1427 */ 1428 nlohmann::json generalError(void) 1429 { 1430 return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, 1431 {"MessageId", "Base.1.8.1.GeneralError"}, 1432 {"Message", 1433 "A general error has occurred. See Resolution for " 1434 "information on how to resolve the error."}, 1435 {"MessageArgs", nlohmann::json::array()}, 1436 {"MessageSeverity", "Critical"}, 1437 {"Resolution", "None."}}; 1438 } 1439 1440 void generalError(crow::Response& res) 1441 { 1442 res.result(boost::beast::http::status::internal_server_error); 1443 addMessageToErrorJson(res.jsonValue, generalError()); 1444 } 1445 1446 /** 1447 * @internal 1448 * @brief Formats Success message into JSON 1449 * 1450 * See header file for more information 1451 * @endinternal 1452 */ 1453 nlohmann::json success(void) 1454 { 1455 return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, 1456 {"MessageId", "Base.1.8.1.Success"}, 1457 {"Message", "Successfully Completed Request"}, 1458 {"MessageArgs", nlohmann::json::array()}, 1459 {"MessageSeverity", "OK"}, 1460 {"Resolution", "None"}}; 1461 } 1462 1463 void success(crow::Response& res) 1464 { 1465 // don't set res.result here because success is the default and any 1466 // error should overwrite the default 1467 addMessageToJsonRoot(res.jsonValue, success()); 1468 } 1469 1470 /** 1471 * @internal 1472 * @brief Formats Created message into JSON 1473 * 1474 * See header file for more information 1475 * @endinternal 1476 */ 1477 nlohmann::json created(void) 1478 { 1479 return nlohmann::json{ 1480 {"@odata.type", "#Message.v1_0_0.Message"}, 1481 {"MessageId", "Base.1.8.1.Created"}, 1482 {"Message", "The resource has been created successfully"}, 1483 {"MessageArgs", nlohmann::json::array()}, 1484 {"MessageSeverity", "OK"}, 1485 {"Resolution", "None"}}; 1486 } 1487 1488 void created(crow::Response& res) 1489 { 1490 res.result(boost::beast::http::status::created); 1491 addMessageToJsonRoot(res.jsonValue, created()); 1492 } 1493 1494 /** 1495 * @internal 1496 * @brief Formats NoOperation message into JSON 1497 * 1498 * See header file for more information 1499 * @endinternal 1500 */ 1501 nlohmann::json noOperation(void) 1502 { 1503 return nlohmann::json{ 1504 {"@odata.type", "#Message.v1_0_0.Message"}, 1505 {"MessageId", "Base.1.8.1.NoOperation"}, 1506 {"Message", "The request body submitted contain no data to act " 1507 "upon and no changes to the resource took place."}, 1508 {"MessageArgs", nlohmann::json::array()}, 1509 {"MessageSeverity", "Warning"}, 1510 {"Resolution", 1511 "Add properties in the JSON object and resubmit the request."}}; 1512 } 1513 1514 void noOperation(crow::Response& res) 1515 { 1516 res.result(boost::beast::http::status::bad_request); 1517 addMessageToErrorJson(res.jsonValue, noOperation()); 1518 } 1519 1520 /** 1521 * @internal 1522 * @brief Formats PropertyUnknown message into JSON for the specified 1523 * property 1524 * 1525 * See header file for more information 1526 * @endinternal 1527 */ 1528 nlohmann::json propertyUnknown(const std::string& arg1) 1529 { 1530 return nlohmann::json{ 1531 {"@odata.type", "#Message.v1_0_0.Message"}, 1532 {"MessageId", "Base.1.8.1.PropertyUnknown"}, 1533 {"Message", "The property " + arg1 + 1534 " is not in the list of valid properties for " 1535 "the resource."}, 1536 {"MessageArgs", {arg1}}, 1537 {"MessageSeverity", "Warning"}, 1538 {"Resolution", "Remove the unknown property from the request " 1539 "body and resubmit " 1540 "the request if the operation failed."}}; 1541 } 1542 1543 void propertyUnknown(crow::Response& res, const std::string& arg1) 1544 { 1545 res.result(boost::beast::http::status::bad_request); 1546 addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1); 1547 } 1548 1549 /** 1550 * @internal 1551 * @brief Formats NoValidSession message into JSON 1552 * 1553 * See header file for more information 1554 * @endinternal 1555 */ 1556 nlohmann::json noValidSession(void) 1557 { 1558 return nlohmann::json{ 1559 {"@odata.type", "#Message.v1_0_0.Message"}, 1560 {"MessageId", "Base.1.8.1.NoValidSession"}, 1561 {"Message", 1562 "There is no valid session established with the implementation."}, 1563 {"MessageArgs", nlohmann::json::array()}, 1564 {"MessageSeverity", "Critical"}, 1565 {"Resolution", 1566 "Establish a session before attempting any operations."}}; 1567 } 1568 1569 void noValidSession(crow::Response& res) 1570 { 1571 res.result(boost::beast::http::status::forbidden); 1572 addMessageToErrorJson(res.jsonValue, noValidSession()); 1573 } 1574 1575 /** 1576 * @internal 1577 * @brief Formats InvalidObject message into JSON 1578 * 1579 * See header file for more information 1580 * @endinternal 1581 */ 1582 nlohmann::json invalidObject(const std::string& arg1) 1583 { 1584 return nlohmann::json{ 1585 {"@odata.type", "#Message.v1_0_0.Message"}, 1586 {"MessageId", "Base.1.8.1.InvalidObject"}, 1587 {"Message", "The object at " + arg1 + " is invalid."}, 1588 {"MessageArgs", {arg1}}, 1589 {"MessageSeverity", "Critical"}, 1590 {"Resolution", 1591 "Either the object is malformed or the URI is not correct. " 1592 "Correct the condition and resubmit the request if it failed."}}; 1593 } 1594 1595 void invalidObject(crow::Response& res, const std::string& arg1) 1596 { 1597 res.result(boost::beast::http::status::bad_request); 1598 addMessageToErrorJson(res.jsonValue, invalidObject(arg1)); 1599 } 1600 1601 /** 1602 * @internal 1603 * @brief Formats ResourceInStandby message into JSON 1604 * 1605 * See header file for more information 1606 * @endinternal 1607 */ 1608 nlohmann::json resourceInStandby(void) 1609 { 1610 return nlohmann::json{ 1611 {"@odata.type", "#Message.v1_0_0.Message"}, 1612 {"MessageId", "Base.1.8.1.ResourceInStandby"}, 1613 {"Message", "The request could not be performed because the " 1614 "resource is in standby."}, 1615 {"MessageArgs", nlohmann::json::array()}, 1616 {"MessageSeverity", "Critical"}, 1617 {"Resolution", "Ensure that the resource is in the correct power " 1618 "state and resubmit the request."}}; 1619 } 1620 1621 void resourceInStandby(crow::Response& res) 1622 { 1623 res.result(boost::beast::http::status::service_unavailable); 1624 addMessageToErrorJson(res.jsonValue, resourceInStandby()); 1625 } 1626 1627 /** 1628 * @internal 1629 * @brief Formats ActionParameterValueTypeError message into JSON 1630 * 1631 * See header file for more information 1632 * @endinternal 1633 */ 1634 nlohmann::json actionParameterValueTypeError(const std::string& arg1, 1635 const std::string& arg2, 1636 const std::string& arg3) 1637 { 1638 return nlohmann::json{ 1639 {"@odata.type", "#Message.v1_0_0.Message"}, 1640 {"MessageId", "Base.1.8.1.ActionParameterValueTypeError"}, 1641 {"Message", 1642 "The value " + arg1 + " for the parameter " + arg2 + 1643 " in the action " + arg3 + 1644 " is of a different type than the parameter can accept."}, 1645 {"MessageArgs", {arg1, arg2, arg3}}, 1646 {"MessageSeverity", "Warning"}, 1647 {"Resolution", 1648 "Correct the value for the parameter in the request body and " 1649 "resubmit the request if the operation failed."}}; 1650 } 1651 1652 void actionParameterValueTypeError(crow::Response& res, const std::string& arg1, 1653 const std::string& arg2, 1654 const std::string& arg3) 1655 { 1656 res.result(boost::beast::http::status::bad_request); 1657 addMessageToErrorJson(res.jsonValue, 1658 actionParameterValueTypeError(arg1, arg2, arg3)); 1659 } 1660 1661 /** 1662 * @internal 1663 * @brief Formats SessionLimitExceeded message into JSON 1664 * 1665 * See header file for more information 1666 * @endinternal 1667 */ 1668 nlohmann::json sessionLimitExceeded(void) 1669 { 1670 return nlohmann::json{ 1671 {"@odata.type", "#Message.v1_0_0.Message"}, 1672 {"MessageId", "Base.1.8.1.SessionLimitExceeded"}, 1673 {"Message", "The session establishment failed due to the number of " 1674 "simultaneous sessions exceeding the limit of the " 1675 "implementation."}, 1676 {"MessageArgs", nlohmann::json::array()}, 1677 {"MessageSeverity", "Critical"}, 1678 {"Resolution", "Reduce the number of other sessions before trying " 1679 "to establish the session or increase the limit of " 1680 "simultaneous sessions (if supported)."}}; 1681 } 1682 1683 void sessionLimitExceeded(crow::Response& res) 1684 { 1685 res.result(boost::beast::http::status::service_unavailable); 1686 addMessageToErrorJson(res.jsonValue, sessionLimitExceeded()); 1687 } 1688 1689 /** 1690 * @internal 1691 * @brief Formats ActionNotSupported message into JSON 1692 * 1693 * See header file for more information 1694 * @endinternal 1695 */ 1696 nlohmann::json actionNotSupported(const std::string& arg1) 1697 { 1698 return nlohmann::json{ 1699 {"@odata.type", "#Message.v1_0_0.Message"}, 1700 {"MessageId", "Base.1.8.1.ActionNotSupported"}, 1701 {"Message", 1702 "The action " + arg1 + " is not supported by the resource."}, 1703 {"MessageArgs", {arg1}}, 1704 {"MessageSeverity", "Critical"}, 1705 {"Resolution", 1706 "The action supplied cannot be resubmitted to the implementation. " 1707 " Perhaps the action was invalid, the wrong resource was the " 1708 "target or the implementation documentation may be of " 1709 "assistance."}}; 1710 } 1711 1712 void actionNotSupported(crow::Response& res, const std::string& arg1) 1713 { 1714 res.result(boost::beast::http::status::bad_request); 1715 addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1)); 1716 } 1717 1718 /** 1719 * @internal 1720 * @brief Formats InvalidIndex message into JSON 1721 * 1722 * See header file for more information 1723 * @endinternal 1724 */ 1725 nlohmann::json invalidIndex(const int& arg1) 1726 { 1727 return nlohmann::json{ 1728 {"@odata.type", "#Message.v1_0_0.Message"}, 1729 {"MessageId", "Base.1.8.1.InvalidIndex"}, 1730 {"Message", "The Index " + std::to_string(arg1) + 1731 " is not a valid offset into the array."}, 1732 {"MessageArgs", {std::to_string(arg1)}}, 1733 {"MessageSeverity", "Warning"}, 1734 {"Resolution", "Verify the index value provided is within the " 1735 "bounds of the array."}}; 1736 } 1737 1738 void invalidIndex(crow::Response& res, const int& arg1) 1739 { 1740 res.result(boost::beast::http::status::bad_request); 1741 addMessageToErrorJson(res.jsonValue, invalidIndex(arg1)); 1742 } 1743 1744 /** 1745 * @internal 1746 * @brief Formats EmptyJSON message into JSON 1747 * 1748 * See header file for more information 1749 * @endinternal 1750 */ 1751 nlohmann::json emptyJSON(void) 1752 { 1753 return nlohmann::json{ 1754 {"@odata.type", "#Message.v1_0_0.Message"}, 1755 {"MessageId", "Base.1.8.1.EmptyJSON"}, 1756 {"Message", "The request body submitted contained an empty JSON " 1757 "object and the service is unable to process it."}, 1758 {"MessageArgs", nlohmann::json::array()}, 1759 {"MessageSeverity", "Warning"}, 1760 {"Resolution", 1761 "Add properties in the JSON object and resubmit the request."}}; 1762 } 1763 1764 void emptyJSON(crow::Response& res) 1765 { 1766 res.result(boost::beast::http::status::bad_request); 1767 addMessageToErrorJson(res.jsonValue, emptyJSON()); 1768 } 1769 1770 /** 1771 * @internal 1772 * @brief Formats QueryNotSupportedOnResource message into JSON 1773 * 1774 * See header file for more information 1775 * @endinternal 1776 */ 1777 nlohmann::json queryNotSupportedOnResource(void) 1778 { 1779 return nlohmann::json{ 1780 {"@odata.type", "#Message.v1_0_0.Message"}, 1781 {"MessageId", "Base.1.8.1.QueryNotSupportedOnResource"}, 1782 {"Message", "Querying is not supported on the requested resource."}, 1783 {"MessageArgs", nlohmann::json::array()}, 1784 {"MessageSeverity", "Warning"}, 1785 {"Resolution", "Remove the query parameters and resubmit the " 1786 "request if the operation failed."}}; 1787 } 1788 1789 void queryNotSupportedOnResource(crow::Response& res) 1790 { 1791 res.result(boost::beast::http::status::forbidden); 1792 addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource()); 1793 } 1794 1795 /** 1796 * @internal 1797 * @brief Formats QueryNotSupportedOnOperation message into JSON 1798 * 1799 * See header file for more information 1800 * @endinternal 1801 */ 1802 nlohmann::json queryNotSupportedOnOperation(void) 1803 { 1804 return nlohmann::json{ 1805 {"@odata.type", "#Message.v1_0_0.Message"}, 1806 {"MessageId", "Base.1.8.1.QueryNotSupportedOnOperation"}, 1807 {"Message", "Querying is not supported with the requested operation."}, 1808 {"MessageArgs", nlohmann::json::array()}, 1809 {"MessageSeverity", "Warning"}, 1810 {"Resolution", "Remove the query parameters and resubmit the request " 1811 "if the operation failed."}}; 1812 } 1813 1814 void queryNotSupportedOnOperation(crow::Response& res) 1815 { 1816 res.result(boost::beast::http::status::forbidden); 1817 addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation()); 1818 } 1819 1820 /** 1821 * @internal 1822 * @brief Formats QueryCombinationInvalid message into JSON 1823 * 1824 * See header file for more information 1825 * @endinternal 1826 */ 1827 nlohmann::json queryCombinationInvalid(void) 1828 { 1829 return nlohmann::json{ 1830 {"@odata.type", "#Message.v1_0_0.Message"}, 1831 {"MessageId", "Base.1.8.1.QueryCombinationInvalid"}, 1832 {"Message", "Two or more query parameters in the request cannot be " 1833 "used together."}, 1834 {"MessageArgs", nlohmann::json::array()}, 1835 {"MessageSeverity", "Warning"}, 1836 {"Resolution", "Remove one or more of the query parameters and " 1837 "resubmit the request if the operation failed."}}; 1838 } 1839 1840 void queryCombinationInvalid(crow::Response& res) 1841 { 1842 res.result(boost::beast::http::status::bad_request); 1843 addMessageToErrorJson(res.jsonValue, queryCombinationInvalid()); 1844 } 1845 1846 /** 1847 * @internal 1848 * @brief Formats InsufficientPrivilege message into JSON 1849 * 1850 * See header file for more information 1851 * @endinternal 1852 */ 1853 nlohmann::json insufficientPrivilege(void) 1854 { 1855 return nlohmann::json{ 1856 {"@odata.type", "#Message.v1_0_0.Message"}, 1857 {"MessageId", "Base.1.8.1.InsufficientPrivilege"}, 1858 {"Message", "There are insufficient privileges for the account or " 1859 "credentials associated with the current session to " 1860 "perform the requested operation."}, 1861 {"MessageArgs", nlohmann::json::array()}, 1862 {"MessageSeverity", "Critical"}, 1863 {"Resolution", 1864 "Either abandon the operation or change the associated access " 1865 "rights and resubmit the request if the operation failed."}}; 1866 } 1867 1868 void insufficientPrivilege(crow::Response& res) 1869 { 1870 res.result(boost::beast::http::status::forbidden); 1871 addMessageToErrorJson(res.jsonValue, insufficientPrivilege()); 1872 } 1873 1874 /** 1875 * @internal 1876 * @brief Formats PropertyValueModified message into JSON 1877 * 1878 * See header file for more information 1879 * @endinternal 1880 */ 1881 nlohmann::json propertyValueModified(const std::string& arg1, 1882 const std::string& arg2) 1883 { 1884 return nlohmann::json{ 1885 {"@odata.type", "#Message.v1_0_0.Message"}, 1886 {"MessageId", "Base.1.8.1.PropertyValueModified"}, 1887 {"Message", "The property " + arg1 + " was assigned the value " + arg2 + 1888 " due to modification by the service."}, 1889 {"MessageArgs", {arg1, arg2}}, 1890 {"MessageSeverity", "Warning"}, 1891 {"Resolution", "No resolution is required."}}; 1892 } 1893 1894 void propertyValueModified(crow::Response& res, const std::string& arg1, 1895 const std::string& arg2) 1896 { 1897 res.result(boost::beast::http::status::ok); 1898 addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1); 1899 } 1900 1901 /** 1902 * @internal 1903 * @brief Formats AccountNotModified message into JSON 1904 * 1905 * See header file for more information 1906 * @endinternal 1907 */ 1908 nlohmann::json accountNotModified(void) 1909 { 1910 return nlohmann::json{ 1911 {"@odata.type", "#Message.v1_0_0.Message"}, 1912 {"MessageId", "Base.1.8.1.AccountNotModified"}, 1913 {"Message", "The account modification request failed."}, 1914 {"MessageArgs", nlohmann::json::array()}, 1915 {"MessageSeverity", "Warning"}, 1916 {"Resolution", "The modification may have failed due to permission " 1917 "issues or issues with the request body."}}; 1918 } 1919 1920 void accountNotModified(crow::Response& res) 1921 { 1922 res.result(boost::beast::http::status::bad_request); 1923 addMessageToErrorJson(res.jsonValue, accountNotModified()); 1924 } 1925 1926 /** 1927 * @internal 1928 * @brief Formats QueryParameterValueFormatError message into JSON 1929 * 1930 * See header file for more information 1931 * @endinternal 1932 */ 1933 nlohmann::json queryParameterValueFormatError(const std::string& arg1, 1934 const std::string& arg2) 1935 { 1936 return nlohmann::json{ 1937 {"@odata.type", "#Message.v1_0_0.Message"}, 1938 {"MessageId", "Base.1.8.1.QueryParameterValueFormatError"}, 1939 {"Message", 1940 "The value " + arg1 + " for the parameter " + arg2 + 1941 " is of a different format than the parameter can accept."}, 1942 {"MessageArgs", {arg1, arg2}}, 1943 {"MessageSeverity", "Warning"}, 1944 {"Resolution", 1945 "Correct the value for the query parameter in the request and " 1946 "resubmit the request if the operation failed."}}; 1947 } 1948 1949 void queryParameterValueFormatError(crow::Response& res, 1950 const std::string& arg1, 1951 const std::string& arg2) 1952 { 1953 res.result(boost::beast::http::status::bad_request); 1954 addMessageToErrorJson(res.jsonValue, 1955 queryParameterValueFormatError(arg1, arg2)); 1956 } 1957 1958 /** 1959 * @internal 1960 * @brief Formats PropertyMissing message into JSON for the specified 1961 * property 1962 * 1963 * See header file for more information 1964 * @endinternal 1965 */ 1966 nlohmann::json propertyMissing(const std::string& arg1) 1967 { 1968 return nlohmann::json{ 1969 {"@odata.type", "#Message.v1_0_0.Message"}, 1970 {"MessageId", "Base.1.8.1.PropertyMissing"}, 1971 {"Message", "The property " + arg1 + 1972 " is a required property and must be included in " 1973 "the request."}, 1974 {"MessageArgs", {arg1}}, 1975 {"MessageSeverity", "Warning"}, 1976 {"Resolution", 1977 "Ensure that the property is in the request body and has a " 1978 "valid " 1979 "value and resubmit the request if the operation failed."}}; 1980 } 1981 1982 void propertyMissing(crow::Response& res, const std::string& arg1) 1983 { 1984 res.result(boost::beast::http::status::bad_request); 1985 addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1); 1986 } 1987 1988 /** 1989 * @internal 1990 * @brief Formats ResourceExhaustion message into JSON 1991 * 1992 * See header file for more information 1993 * @endinternal 1994 */ 1995 nlohmann::json resourceExhaustion(const std::string& arg1) 1996 { 1997 return nlohmann::json{ 1998 {"@odata.type", "#Message.v1_0_0.Message"}, 1999 {"MessageId", "Base.1.8.1.ResourceExhaustion"}, 2000 {"Message", "The resource " + arg1 + 2001 " was unable to satisfy the request due to " 2002 "unavailability of resources."}, 2003 {"MessageArgs", {arg1}}, 2004 {"MessageSeverity", "Critical"}, 2005 {"Resolution", "Ensure that the resources are available and " 2006 "resubmit the request."}}; 2007 } 2008 2009 void resourceExhaustion(crow::Response& res, const std::string& arg1) 2010 { 2011 res.result(boost::beast::http::status::service_unavailable); 2012 addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1)); 2013 } 2014 2015 /** 2016 * @internal 2017 * @brief Formats AccountModified message into JSON 2018 * 2019 * See header file for more information 2020 * @endinternal 2021 */ 2022 nlohmann::json accountModified(void) 2023 { 2024 return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, 2025 {"MessageId", "Base.1.8.1.AccountModified"}, 2026 {"Message", "The account was successfully modified."}, 2027 {"MessageArgs", nlohmann::json::array()}, 2028 {"MessageSeverity", "OK"}, 2029 {"Resolution", "No resolution is required."}}; 2030 } 2031 2032 void accountModified(crow::Response& res) 2033 { 2034 res.result(boost::beast::http::status::ok); 2035 addMessageToErrorJson(res.jsonValue, accountModified()); 2036 } 2037 2038 /** 2039 * @internal 2040 * @brief Formats QueryParameterOutOfRange message into JSON 2041 * 2042 * See header file for more information 2043 * @endinternal 2044 */ 2045 nlohmann::json queryParameterOutOfRange(const std::string& arg1, 2046 const std::string& arg2, 2047 const std::string& arg3) 2048 { 2049 return nlohmann::json{ 2050 {"@odata.type", "#Message.v1_0_0.Message"}, 2051 {"MessageId", "Base.1.8.1.QueryParameterOutOfRange"}, 2052 {"Message", "The value " + arg1 + " for the query parameter " + arg2 + 2053 " is out of range " + arg3 + "."}, 2054 {"MessageArgs", {arg1, arg2, arg3}}, 2055 {"MessageSeverity", "Warning"}, 2056 {"Resolution", 2057 "Reduce the value for the query parameter to a value that is " 2058 "within range, such as a start or count value that is within " 2059 "bounds of the number of resources in a collection or a page that " 2060 "is within the range of valid pages."}}; 2061 } 2062 2063 void queryParameterOutOfRange(crow::Response& res, const std::string& arg1, 2064 const std::string& arg2, const std::string& arg3) 2065 { 2066 res.result(boost::beast::http::status::bad_request); 2067 addMessageToErrorJson(res.jsonValue, 2068 queryParameterOutOfRange(arg1, arg2, arg3)); 2069 } 2070 2071 /** 2072 * @internal 2073 * @brief Formats PasswordChangeRequired message into JSON 2074 * 2075 * See header file for more information 2076 * @endinternal 2077 */ 2078 void passwordChangeRequired(crow::Response& res, const std::string& arg1) 2079 { 2080 messages::addMessageToJsonRoot( 2081 res.jsonValue, 2082 nlohmann::json{ 2083 {"@odata.type", "/redfish/v1/$metadata#Message.v1_5_0.Message"}, 2084 {"MessageId", "Base.1.8.1.PasswordChangeRequired"}, 2085 {"Message", "The password provided for this account must be " 2086 "changed before access is granted. PATCH the " 2087 "'Password' property for this account located at " 2088 "the target URI '" + 2089 arg1 + "' to complete this process."}, 2090 {"MessageArgs", {arg1}}, 2091 {"MessageSeverity", "Critical"}, 2092 {"Resolution", "Change the password for this account using " 2093 "a PATCH to the 'Password' property at the URI " 2094 "provided."}}); 2095 } 2096 2097 void invalidUpload(crow::Response& res, const std::string& arg1, 2098 const std::string& arg2) 2099 { 2100 res.result(boost::beast::http::status::bad_request); 2101 addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2)); 2102 } 2103 2104 /** 2105 * @internal 2106 * @brief Formats Invalid File message into JSON 2107 * 2108 * See header file for more information 2109 * @endinternal 2110 */ 2111 nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2) 2112 { 2113 return nlohmann::json{ 2114 {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 2115 {"MessageId", "OpenBMC.0.1.0.InvalidUpload"}, 2116 {"Message", "Invalid file uploaded to " + arg1 + ": " + arg2 + "."}, 2117 {"MessageArgs", {arg1, arg2}}, 2118 {"MessageSeverity", "Warning"}, 2119 {"Resolution", "None."}}; 2120 } 2121 2122 /** 2123 * @internal 2124 * @brief Formats MutualExclusiveProperties into JSON 2125 * 2126 * See header file for more information 2127 * @endinternal 2128 */ 2129 nlohmann::json mutualExclusiveProperties(const std::string& arg1, 2130 const std::string& arg2) 2131 { 2132 return nlohmann::json{ 2133 {"@odata.type", "#Message.v1_0_0.Message"}, 2134 {"MessageId", "Base.1.5.0.MutualExclusiveProperties"}, 2135 {"Message", "The properties " + arg1 + " and " + arg2 + 2136 " are mutually exclusive."}, 2137 {"MessageArgs", {arg1, arg2}}, 2138 {"MessageSeverity", "Warning"}, 2139 {"Resolution", 2140 "Ensure that the request body doesn't contain mutually exclusive " 2141 "properties and resubmit the request."}}; 2142 } 2143 2144 void mutualExclusiveProperties(crow::Response& res, const std::string& arg1, 2145 const std::string& arg2) 2146 { 2147 res.result(boost::beast::http::status::bad_request); 2148 addMessageToErrorJson(res.jsonValue, mutualExclusiveProperties(arg1, arg2)); 2149 } 2150 2151 } // namespace messages 2152 2153 } // namespace redfish 2154