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