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 #pragma once 17 #include "http_response.hpp" 18 19 #include <nlohmann/json.hpp> 20 #include <source_location.hpp> 21 22 #include <string> 23 24 namespace redfish 25 { 26 27 namespace messages 28 { 29 30 constexpr const char* messageVersionPrefix = "Base.1.11.0."; 31 constexpr const char* messageAnnotation = "@Message.ExtendedInfo"; 32 33 /** 34 * @brief Formats ResourceInUse message into JSON 35 * Message body: "The change to the requested resource failed because the 36 * resource is in use or in transition." 37 * 38 * 39 * @returns Message ResourceInUse formatted to JSON */ 40 nlohmann::json resourceInUse(); 41 42 void resourceInUse(crow::Response& res); 43 44 /** 45 * @brief Formats MalformedJSON message into JSON 46 * Message body: "The request body submitted was malformed JSON and could not be 47 * parsed by the receiving service." 48 * 49 * 50 * @returns Message MalformedJSON formatted to JSON */ 51 nlohmann::json malformedJSON(); 52 53 void malformedJSON(crow::Response& res); 54 55 /** 56 * @brief Formats ResourceMissingAtURI message into JSON 57 * Message body: "The resource at the URI <arg1> was not found." 58 * 59 * @param[in] arg1 Parameter of message that will replace %1 in its body. 60 * 61 * @returns Message ResourceMissingAtURI formatted to JSON */ 62 nlohmann::json resourceMissingAtURI(const std::string& arg1); 63 64 void resourceMissingAtURI(crow::Response& res, const std::string& arg1); 65 66 /** 67 * @brief Formats ActionParameterValueFormatError message into JSON 68 * Message body: "The value <arg1> for the parameter <arg2> in the action <arg3> 69 * is of a different format than the parameter can accept." 70 * 71 * @param[in] arg1 Parameter of message that will replace %1 in its body. 72 * @param[in] arg2 Parameter of message that will replace %2 in its body. 73 * @param[in] arg3 Parameter of message that will replace %3 in its body. 74 * 75 * @returns Message ActionParameterValueFormatError formatted to JSON */ 76 nlohmann::json actionParameterValueFormatError(const std::string& arg1, 77 const std::string& arg2, 78 const std::string& arg3); 79 80 void actionParameterValueFormatError(crow::Response& res, 81 const std::string& arg1, 82 const std::string& arg2, 83 const std::string& arg3); 84 85 /** 86 * @brief Formats InternalError message into JSON 87 * Message body: "The request failed due to an internal service error. The 88 * service is still operational." 89 * 90 * 91 * @returns Message InternalError formatted to JSON */ 92 nlohmann::json internalError(); 93 94 void internalError(crow::Response& res, bmcweb::source_location location = 95 bmcweb::source_location::current()); 96 97 /** 98 * @brief Formats UnrecognizedRequestBody message into JSON 99 * Message body: "The service detected a malformed request body that it was 100 * unable to interpret." 101 * 102 * 103 * @returns Message UnrecognizedRequestBody formatted to JSON */ 104 nlohmann::json unrecognizedRequestBody(); 105 106 void unrecognizedRequestBody(crow::Response& res); 107 108 /** 109 * @brief Formats ResourceAtUriUnauthorized message into JSON 110 * Message body: "While accessing the resource at <arg1>, the service received 111 * an authorization error <arg2>." 112 * 113 * @param[in] arg1 Parameter of message that will replace %1 in its body. 114 * @param[in] arg2 Parameter of message that will replace %2 in its body. 115 * 116 * @returns Message ResourceAtUriUnauthorized formatted to JSON */ 117 nlohmann::json resourceAtUriUnauthorized(const std::string& arg1, 118 const std::string& arg2); 119 120 void resourceAtUriUnauthorized(crow::Response& res, const std::string& arg1, 121 const std::string& arg2); 122 123 /** 124 * @brief Formats ActionParameterUnknown message into JSON 125 * Message body: "The action <arg1> was submitted with the invalid parameter 126 * <arg2>." 127 * 128 * @param[in] arg1 Parameter of message that will replace %1 in its body. 129 * @param[in] arg2 Parameter of message that will replace %2 in its body. 130 * 131 * @returns Message ActionParameterUnknown formatted to JSON */ 132 nlohmann::json actionParameterUnknown(const std::string& arg1, 133 const std::string& arg2); 134 135 void actionParameterUnknown(crow::Response& res, const std::string& arg1, 136 const std::string& arg2); 137 138 /** 139 * @brief Formats ResourceCannotBeDeleted message into JSON 140 * Message body: "The delete request failed because the resource requested 141 * cannot be deleted." 142 * 143 * 144 * @returns Message ResourceCannotBeDeleted formatted to JSON */ 145 nlohmann::json resourceCannotBeDeleted(); 146 147 void resourceCannotBeDeleted(crow::Response& res); 148 149 /** 150 * @brief Formats PropertyDuplicate message into JSON 151 * Message body: "The property <arg1> was duplicated in the request." 152 * 153 * @param[in] arg1 Parameter of message that will replace %1 in its body. 154 * 155 * @returns Message PropertyDuplicate formatted to JSON */ 156 nlohmann::json propertyDuplicate(const std::string& arg1); 157 158 void propertyDuplicate(crow::Response& res, const std::string& arg1); 159 160 /** 161 * @brief Formats ServiceTemporarilyUnavailable message into JSON 162 * Message body: "The service is temporarily unavailable. Retry in <arg1> 163 * seconds." 164 * 165 * @param[in] arg1 Parameter of message that will replace %1 in its body. 166 * 167 * @returns Message ServiceTemporarilyUnavailable formatted to JSON */ 168 nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1); 169 170 void serviceTemporarilyUnavailable(crow::Response& res, 171 const std::string& arg1); 172 173 /** 174 * @brief Formats ResourceAlreadyExists message into JSON 175 * Message body: "The requested resource of type <arg1> with the property <arg2> 176 * with the value <arg3> already exists." 177 * 178 * @param[in] arg1 Parameter of message that will replace %1 in its body. 179 * @param[in] arg2 Parameter of message that will replace %2 in its body. 180 * @param[in] arg3 Parameter of message that will replace %3 in its body. 181 * 182 * @returns Message ResourceAlreadyExists formatted to JSON */ 183 nlohmann::json resourceAlreadyExists(const std::string& arg1, 184 const std::string& arg2, 185 const std::string& arg3); 186 187 void resourceAlreadyExists(crow::Response& res, const std::string& arg1, 188 const std::string& arg2, const std::string& arg3); 189 190 /** 191 * @brief Formats AccountForSessionNoLongerExists message into JSON 192 * Message body: "The account for the current session has been removed, thus the 193 * current session has been removed as well." 194 * 195 * 196 * @returns Message AccountForSessionNoLongerExists formatted to JSON */ 197 nlohmann::json accountForSessionNoLongerExists(); 198 199 void accountForSessionNoLongerExists(crow::Response& res); 200 201 /** 202 * @brief Formats CreateFailedMissingReqProperties message into JSON 203 * Message body: "The create operation failed because the required property 204 * <arg1> was missing from the request." 205 * 206 * @param[in] arg1 Parameter of message that will replace %1 in its body. 207 * 208 * @returns Message CreateFailedMissingReqProperties formatted to JSON */ 209 nlohmann::json createFailedMissingReqProperties(const std::string& arg1); 210 211 void createFailedMissingReqProperties(crow::Response& res, 212 const std::string& arg1); 213 214 /** 215 * @brief Formats PropertyValueFormatError message into JSON 216 * Message body: "The value <arg1> for the property <arg2> is of a different 217 * format than the property can accept." 218 * 219 * @param[in] arg1 Parameter of message that will replace %1 in its body. 220 * @param[in] arg2 Parameter of message that will replace %2 in its body. 221 * 222 * @returns Message PropertyValueFormatError formatted to JSON */ 223 nlohmann::json propertyValueFormatError(const std::string& arg1, 224 const std::string& arg2); 225 226 void propertyValueFormatError(crow::Response& res, const std::string& arg1, 227 const std::string& arg2); 228 229 /** 230 * @brief Formats PropertyValueNotInList message into JSON 231 * Message body: "The value <arg1> for the property <arg2> is not in the list of 232 * acceptable values." 233 * 234 * @param[in] arg1 Parameter of message that will replace %1 in its body. 235 * @param[in] arg2 Parameter of message that will replace %2 in its body. 236 * 237 * @returns Message PropertyValueNotInList formatted to JSON */ 238 nlohmann::json propertyValueNotInList(const std::string& arg1, 239 const std::string& arg2); 240 241 void propertyValueNotInList(crow::Response& res, const std::string& arg1, 242 const std::string& arg2); 243 244 /** 245 * @brief Formats ResourceAtUriInUnknownFormat message into JSON 246 * Message body: "The resource at <arg1> is in a format not recognized by the 247 * service." 248 * 249 * @param[in] arg1 Parameter of message that will replace %1 in its body. 250 * 251 * @returns Message ResourceAtUriInUnknownFormat formatted to JSON */ 252 nlohmann::json resourceAtUriInUnknownFormat(const std::string& arg1); 253 254 void resourceAtUriInUnknownFormat(crow::Response& res, const std::string& arg1); 255 256 /** 257 * @brief Formats ServiceDisabled message into JSON 258 * Message body: "The operation failed because the service at <arg1> is disabled 259 * and " cannot accept requests." 260 * 261 * @param[in] arg1 Parameter of message that will replace %1 in its body. 262 * 263 * @returns Message ServiceDisabled formatted to JSON */ 264 nlohmann::json serviceDisabled(const std::string& arg1); 265 266 void serviceDisabled(crow::Response& res, const std::string& arg1); 267 268 /** 269 * @brief Formats ServiceInUnknownState message into JSON 270 * Message body: "The operation failed because the service is in an unknown 271 * state and can no longer take incoming requests." 272 * 273 * 274 * @returns Message ServiceInUnknownState formatted to JSON */ 275 nlohmann::json serviceInUnknownState(); 276 277 void serviceInUnknownState(crow::Response& res); 278 279 /** 280 * @brief Formats EventSubscriptionLimitExceeded message into JSON 281 * Message body: "The event subscription failed due to the number of 282 * simultaneous subscriptions exceeding the limit of the implementation." 283 * 284 * 285 * @returns Message EventSubscriptionLimitExceeded formatted to JSON */ 286 nlohmann::json eventSubscriptionLimitExceeded(); 287 288 void eventSubscriptionLimitExceeded(crow::Response& res); 289 290 /** 291 * @brief Formats ActionParameterMissing message into JSON 292 * Message body: "The action <arg1> requires the parameter <arg2> to be present 293 * in the request body." 294 * 295 * @param[in] arg1 Parameter of message that will replace %1 in its body. 296 * @param[in] arg2 Parameter of message that will replace %2 in its body. 297 * 298 * @returns Message ActionParameterMissing formatted to JSON */ 299 nlohmann::json actionParameterMissing(const std::string& arg1, 300 const std::string& arg2); 301 302 void actionParameterMissing(crow::Response& res, const std::string& arg1, 303 const std::string& arg2); 304 305 /** 306 * @brief Formats StringValueTooLong message into JSON 307 * Message body: "The string <arg1> exceeds the length limit <arg2>." 308 * 309 * @param[in] arg1 Parameter of message that will replace %1 in its body. 310 * @param[in] arg2 Parameter of message that will replace %2 in its body. 311 * 312 * @returns Message StringValueTooLong formatted to JSON */ 313 nlohmann::json stringValueTooLong(const std::string& arg1, int arg2); 314 315 void stringValueTooLong(crow::Response& res, const std::string& arg1, int arg2); 316 317 /** 318 * @brief Formats SessionTerminated message into JSON 319 * Message body: "The session was successfully terminated." 320 * 321 * 322 * @returns Message SessionTerminated formatted to JSON */ 323 nlohmann::json sessionTerminated(); 324 325 void sessionTerminated(crow::Response& res); 326 327 /** 328 * @brief Formats SubscriptionTerminated message into JSON 329 * Message body: "The event subscription has been terminated." 330 * 331 * 332 * @returns Message SubscriptionTerminated formatted to JSON */ 333 nlohmann::json subscriptionTerminated(); 334 335 void subscriptionTerminated(crow::Response& res); 336 337 /** 338 * @brief Formats ResourceTypeIncompatible message into JSON 339 * Message body: "The @odata.type of the request body <arg1> is incompatible 340 * with the @odata.type of the resource which is <arg2>." 341 * 342 * @param[in] arg1 Parameter of message that will replace %1 in its body. 343 * @param[in] arg2 Parameter of message that will replace %2 in its body. 344 * 345 * @returns Message ResourceTypeIncompatible formatted to JSON */ 346 nlohmann::json resourceTypeIncompatible(const std::string& arg1, 347 const std::string& arg2); 348 349 void resourceTypeIncompatible(crow::Response& res, const std::string& arg1, 350 const std::string& arg2); 351 352 /** 353 * @brief Formats ResetRequired message into JSON 354 * Message body: "In order to complete the operation, a component reset is 355 * required with the Reset action URI '<arg1>' and ResetType '<arg2>'." 356 * 357 * @param[in] arg1 Parameter of message that will replace %1 in its body. 358 * @param[in] arg2 Parameter of message that will replace %2 in its body. 359 * 360 * @returns Message ResetRequired formatted to JSON */ 361 nlohmann::json resetRequired(const std::string& arg1, const std::string& arg2); 362 363 void resetRequired(crow::Response& res, const std::string& arg1, 364 const std::string& arg2); 365 366 /** 367 * @brief Formats ChassisPowerStateOnRequired message into JSON 368 * Message body: "The Chassis with Id '<arg1>' requires to be powered on to 369 * perform this request." 370 * 371 * @param[in] arg1 Parameter of message that will replace %1 in its body. 372 * 373 * @returns Message ChassisPowerStateOnRequired formatted to JSON */ 374 nlohmann::json chassisPowerStateOnRequired(const std::string& arg1); 375 376 void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1); 377 378 /** 379 * @brief Formats ChassisPowerStateOffRequired message into JSON 380 * Message body: "The Chassis with Id '<arg1>' requires to be powered off to 381 * perform this request." 382 * 383 * @param[in] arg1 Parameter of message that will replace %1 in its body. 384 * 385 * @returns Message ChassisPowerStateOffRequired formatted to JSON */ 386 nlohmann::json chassisPowerStateOffRequired(const std::string& arg1); 387 388 void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1); 389 390 /** 391 * @brief Formats PropertyValueConflict message into JSON 392 * Message body: "The property '<arg1>' could not be written because its value 393 * would conflict with the value of the '<arg2>' property." 394 * 395 * @param[in] arg1 Parameter of message that will replace %1 in its body. 396 * @param[in] arg2 Parameter of message that will replace %2 in its body. 397 * 398 * @returns Message PropertyValueConflict formatted to JSON */ 399 nlohmann::json propertyValueConflict(const std::string& arg1, 400 const std::string& arg2); 401 402 void propertyValueConflict(crow::Response& res, const std::string& arg1, 403 const std::string& arg2); 404 405 /** 406 * @brief Formats PropertyValueIncorrect message into JSON 407 * Message body: "The property '<arg1>' with the requested value of '<arg2>' 408 * could not be written because the value does not meet the constraints of the 409 * implementation." 410 * 411 * @param[in] arg1 Parameter of message that will replace %1 in its body. 412 * @param[in] arg2 Parameter of message that will replace %2 in its body. 413 * 414 * @returns Message PropertyValueIncorrect formatted to JSON */ 415 nlohmann::json propertyValueIncorrect(const std::string& arg1, 416 const std::string& arg2); 417 418 void propertyValueIncorrect(crow::Response& res, const std::string& arg1, 419 const std::string& arg2); 420 421 /** 422 * @brief Formats ResourceCreationConflict message into JSON 423 * Message body: "The resource could not be created. The service has a resource 424 * at URI '<arg1>' that conflicts with the creation request." 425 * 426 * @param[in] arg1 Parameter of message that will replace %1 in its body. 427 * 428 * @returns Message ResourceCreationConflict formatted to JSON */ 429 nlohmann::json resourceCreationConflict(const std::string& arg1); 430 431 void resourceCreationConflict(crow::Response& res, const std::string& arg1); 432 433 /** 434 * @brief Formats MaximumErrorsExceeded message into JSON 435 * Message body: "Too many errors have occurred to report them all." 436 * 437 * 438 * @returns Message MaximumErrorsExceeded formatted to JSON */ 439 nlohmann::json maximumErrorsExceeded(); 440 441 void maximumErrorsExceeded(crow::Response& res); 442 443 /** 444 * @brief Formats PreconditionFailed message into JSON 445 * Message body: "The ETag supplied did not match the ETag required to change 446 * this resource." 447 * 448 * 449 * @returns Message PreconditionFailed formatted to JSON */ 450 nlohmann::json preconditionFailed(); 451 452 void preconditionFailed(crow::Response& res); 453 454 /** 455 * @brief Formats PreconditionRequired message into JSON 456 * Message body: "A precondition header or annotation is required to change this 457 * resource." 458 * 459 * 460 * @returns Message PreconditionRequired formatted to JSON */ 461 nlohmann::json preconditionRequired(); 462 463 void preconditionRequired(crow::Response& res); 464 465 /** 466 * @brief Formats OperationFailed message into JSON 467 * Message body: "An error occurred internal to the service as part of the 468 * overall request. Partial results may have been returned." 469 * 470 * 471 * @returns Message OperationFailed formatted to JSON */ 472 nlohmann::json operationFailed(); 473 474 void operationFailed(crow::Response& res); 475 476 /** 477 * @brief Formats OperationTimeout message into JSON 478 * Message body: "A timeout internal to the service occured as part of the 479 * request. Partial results may have been returned." 480 * 481 * 482 * @returns Message OperationTimeout formatted to JSON */ 483 nlohmann::json operationTimeout(); 484 485 void operationTimeout(crow::Response& res); 486 487 /** 488 * @brief Formats PropertyValueTypeError message into JSON 489 * Message body: "The value <arg1> for the property <arg2> is of a different 490 * type than the property can accept." 491 * 492 * @param[in] arg1 Parameter of message that will replace %1 in its body. 493 * @param[in] arg2 Parameter of message that will replace %2 in its body. 494 * 495 * @returns Message PropertyValueTypeError formatted to JSON */ 496 nlohmann::json propertyValueTypeError(const std::string& arg1, 497 const std::string& arg2); 498 499 void propertyValueTypeError(crow::Response& res, const std::string& arg1, 500 const std::string& arg2); 501 502 /** 503 * @brief Formats ResourceNotFound message into JSON 504 * Message body: "The requested resource of type <arg1> named <arg2> was not 505 * found." 506 * 507 * @param[in] arg1 Parameter of message that will replace %1 in its body. 508 * @param[in] arg2 Parameter of message that will replace %2 in its body. 509 * 510 * @returns Message ResourceNotFound formatted to JSON */ 511 nlohmann::json resourceNotFound(const std::string& arg1, 512 const std::string& arg2); 513 514 void resourceNotFound(crow::Response& res, const std::string& arg1, 515 const std::string& arg2); 516 517 /** 518 * @brief Formats CouldNotEstablishConnection message into JSON 519 * Message body: "The service failed to establish a Connection with the URI 520 * <arg1>." 521 * 522 * @param[in] arg1 Parameter of message that will replace %1 in its body. 523 * 524 * @returns Message CouldNotEstablishConnection formatted to JSON */ 525 nlohmann::json couldNotEstablishConnection(const std::string& arg1); 526 527 void couldNotEstablishConnection(crow::Response& res, const std::string& arg1); 528 529 /** 530 * @brief Formats PropertyNotWritable message into JSON 531 * Message body: "The property <arg1> is a read only property and cannot be 532 * assigned a value." 533 * 534 * @param[in] arg1 Parameter of message that will replace %1 in its body. 535 * 536 * @returns Message PropertyNotWritable formatted to JSON */ 537 nlohmann::json propertyNotWritable(const std::string& arg1); 538 539 void propertyNotWritable(crow::Response& res, const std::string& arg1); 540 541 /** 542 * @brief Formats QueryParameterValueTypeError message into JSON 543 * Message body: "The value <arg1> for the query parameter <arg2> is of a 544 * different type than the parameter can accept." 545 * 546 * @param[in] arg1 Parameter of message that will replace %1 in its body. 547 * @param[in] arg2 Parameter of message that will replace %2 in its body. 548 * 549 * @returns Message QueryParameterValueTypeError formatted to JSON */ 550 nlohmann::json queryParameterValueTypeError(const std::string& arg1, 551 const std::string& arg2); 552 553 void queryParameterValueTypeError(crow::Response& res, const std::string& arg1, 554 const std::string& arg2); 555 556 /** 557 * @brief Formats ServiceShuttingDown message into JSON 558 * Message body: "The operation failed because the service is shutting down and 559 * can no longer take incoming requests." 560 * 561 * 562 * @returns Message ServiceShuttingDown formatted to JSON */ 563 nlohmann::json serviceShuttingDown(); 564 565 void serviceShuttingDown(crow::Response& res); 566 567 /** 568 * @brief Formats ActionParameterDuplicate message into JSON 569 * Message body: "The action <arg1> was submitted with more than one value for 570 * the parameter <arg2>." 571 * 572 * @param[in] arg1 Parameter of message that will replace %1 in its body. 573 * @param[in] arg2 Parameter of message that will replace %2 in its body. 574 * 575 * @returns Message ActionParameterDuplicate formatted to JSON */ 576 nlohmann::json actionParameterDuplicate(const std::string& arg1, 577 const std::string& arg2); 578 579 void actionParameterDuplicate(crow::Response& res, const std::string& arg1, 580 const std::string& arg2); 581 582 /** 583 * @brief Formats ActionParameterNotSupported message into JSON 584 * Message body: "The parameter <arg1> for the action <arg2> is not supported on 585 * the target resource." 586 * 587 * @param[in] arg1 Parameter of message that will replace %1 in its body. 588 * @param[in] arg2 Parameter of message that will replace %2 in its body. 589 * 590 * @returns Message ActionParameterNotSupported formatted to JSON */ 591 nlohmann::json actionParameterNotSupported(const std::string& arg1, 592 const std::string& arg2); 593 594 void actionParameterNotSupported(crow::Response& res, const std::string& arg1, 595 const std::string& arg2); 596 597 /** 598 * @brief Formats SourceDoesNotSupportProtocol message into JSON 599 * Message body: "The other end of the Connection at <arg1> does not support the 600 * specified protocol <arg2>." 601 * 602 * @param[in] arg1 Parameter of message that will replace %1 in its body. 603 * @param[in] arg2 Parameter of message that will replace %2 in its body. 604 * 605 * @returns Message SourceDoesNotSupportProtocol formatted to JSON */ 606 nlohmann::json sourceDoesNotSupportProtocol(const std::string& arg1, 607 const std::string& arg2); 608 609 void sourceDoesNotSupportProtocol(crow::Response& res, const std::string& arg1, 610 const std::string& arg2); 611 612 /** 613 * @brief Formats AccountRemoved message into JSON 614 * Message body: "The account was successfully removed." 615 * 616 * 617 * @returns Message AccountRemoved formatted to JSON */ 618 nlohmann::json accountRemoved(); 619 620 void accountRemoved(crow::Response& res); 621 622 /** 623 * @brief Formats AccessDenied message into JSON 624 * Message body: "While attempting to establish a Connection to <arg1>, the 625 * service denied access." 626 * 627 * @param[in] arg1 Parameter of message that will replace %1 in its body. 628 * 629 * @returns Message AccessDenied formatted to JSON */ 630 nlohmann::json accessDenied(const std::string& arg1); 631 632 void accessDenied(crow::Response& res, const std::string& arg1); 633 634 /** 635 * @brief Formats QueryNotSupported message into JSON 636 * Message body: "Querying is not supported by the implementation." 637 * 638 * 639 * @returns Message QueryNotSupported formatted to JSON */ 640 nlohmann::json queryNotSupported(); 641 642 void queryNotSupported(crow::Response& res); 643 644 /** 645 * @brief Formats CreateLimitReachedForResource message into JSON 646 * Message body: "The create operation failed because the resource has reached 647 * the limit of possible resources." 648 * 649 * 650 * @returns Message CreateLimitReachedForResource formatted to JSON */ 651 nlohmann::json createLimitReachedForResource(); 652 653 void createLimitReachedForResource(crow::Response& res); 654 655 /** 656 * @brief Formats GeneralError message into JSON 657 * Message body: "A general error has occurred. See ExtendedInfo for more 658 * information." 659 * 660 * 661 * @returns Message GeneralError formatted to JSON */ 662 nlohmann::json generalError(); 663 664 void generalError(crow::Response& res); 665 666 /** 667 * @brief Formats Success message into JSON 668 * Message body: "Successfully Completed Request" 669 * 670 * 671 * @returns Message Success formatted to JSON */ 672 nlohmann::json success(); 673 674 void success(crow::Response& res); 675 676 /** 677 * @brief Formats Created message into JSON 678 * Message body: "The resource has been created successfully" 679 * 680 * 681 * @returns Message Created formatted to JSON */ 682 nlohmann::json created(); 683 684 void created(crow::Response& res); 685 686 /** 687 * @brief Formats NoOperation message into JSON 688 * Message body: "The request body submitted contain no data to act upon and 689 * no changes to the resource took place." 690 * 691 * 692 * @returns Message NoOperation formatted to JSON */ 693 nlohmann::json noOperation(); 694 695 void noOperation(crow::Response& res); 696 697 /** 698 * @brief Formats PropertyUnknown message into JSON 699 * Message body: "The property <arg1> is not in the list of valid properties for 700 * the resource." 701 * 702 * @param[in] arg1 Parameter of message that will replace %1 in its body. 703 * 704 * @returns Message PropertyUnknown formatted to JSON */ 705 nlohmann::json propertyUnknown(const std::string& arg1); 706 707 void propertyUnknown(crow::Response& res, const std::string& arg1); 708 709 /** 710 * @brief Formats NoValidSession message into JSON 711 * Message body: "There is no valid session established with the 712 * implementation." 713 * 714 * 715 * @returns Message NoValidSession formatted to JSON */ 716 nlohmann::json noValidSession(); 717 718 void noValidSession(crow::Response& res); 719 720 /** 721 * @brief Formats InvalidObject message into JSON 722 * Message body: "The object at <arg1> is invalid." 723 * 724 * @param[in] arg1 Parameter of message that will replace %1 in its body. 725 * 726 * @returns Message InvalidObject formatted to JSON */ 727 nlohmann::json invalidObject(const std::string& arg1); 728 729 void invalidObject(crow::Response& res, const std::string& arg1); 730 731 /** 732 * @brief Formats ResourceInStandby message into JSON 733 * Message body: "The request could not be performed because the resource is in 734 * standby." 735 * 736 * 737 * @returns Message ResourceInStandby formatted to JSON */ 738 nlohmann::json resourceInStandby(); 739 740 void resourceInStandby(crow::Response& res); 741 742 /** 743 * @brief Formats ActionParameterValueTypeError message into JSON 744 * Message body: "The value <arg1> for the parameter <arg2> in the action <arg3> 745 * is of a different type than the parameter can accept." 746 * 747 * @param[in] arg1 Parameter of message that will replace %1 in its body. 748 * @param[in] arg2 Parameter of message that will replace %2 in its body. 749 * @param[in] arg3 Parameter of message that will replace %3 in its body. 750 * 751 * @returns Message ActionParameterValueTypeError formatted to JSON */ 752 nlohmann::json actionParameterValueTypeError(const std::string& arg1, 753 const std::string& arg2, 754 const std::string& arg3); 755 756 void actionParameterValueTypeError(crow::Response& res, const std::string& arg1, 757 const std::string& arg2, 758 const std::string& arg3); 759 760 /** 761 * @brief Formats SessionLimitExceeded message into JSON 762 * Message body: "The session establishment failed due to the number of 763 * simultaneous sessions exceeding the limit of the implementation." 764 * 765 * 766 * @returns Message SessionLimitExceeded formatted to JSON */ 767 nlohmann::json sessionLimitExceeded(); 768 769 void sessionLimitExceeded(crow::Response& res); 770 771 /** 772 * @brief Formats ActionNotSupported message into JSON 773 * Message body: "The action <arg1> is not supported by the resource." 774 * 775 * @param[in] arg1 Parameter of message that will replace %1 in its body. 776 * 777 * @returns Message ActionNotSupported formatted to JSON */ 778 nlohmann::json actionNotSupported(const std::string& arg1); 779 780 void actionNotSupported(crow::Response& res, const std::string& arg1); 781 782 /** 783 * @brief Formats InvalidIndex message into JSON 784 * Message body: "The index <arg1> is not a valid offset into the array." 785 * 786 * @param[in] arg1 Parameter of message that will replace %1 in its body. 787 * 788 * @returns Message InvalidIndex formatted to JSON */ 789 nlohmann::json invalidIndex(int64_t arg1); 790 791 void invalidIndex(crow::Response& res, int64_t arg1); 792 793 /** 794 * @brief Formats EmptyJSON message into JSON 795 * Message body: "The request body submitted contained an empty JSON object and 796 * the service is unable to process it." 797 * 798 * 799 * @returns Message EmptyJSON formatted to JSON */ 800 nlohmann::json emptyJSON(); 801 802 void emptyJSON(crow::Response& res); 803 804 /** 805 * @brief Formats QueryNotSupportedOnResource message into JSON 806 * Message body: "Querying is not supported on the requested resource." 807 * 808 * 809 * @returns Message QueryNotSupportedOnResource formatted to JSON */ 810 nlohmann::json queryNotSupportedOnResource(); 811 812 void queryNotSupportedOnResource(crow::Response& res); 813 814 /** 815 * @brief Formats QueryNotSupportedOnOperation message into JSON 816 * Message body: "Querying is not supported with the requested operation." 817 * 818 * 819 * @returns Message QueryNotSupportedOnOperation formatted to JSON */ 820 nlohmann::json queryNotSupportedOnOperation(); 821 822 void queryNotSupportedOnOperation(crow::Response& res); 823 824 /** 825 * @brief Formats QueryCombinationInvalid message into JSON 826 * Message body: "Two or more query parameters in the request cannot be used 827 * together." 828 * 829 * 830 * @returns Message QueryCombinationInvalid formatted to JSON */ 831 nlohmann::json queryCombinationInvalid(); 832 833 void queryCombinationInvalid(crow::Response& res); 834 835 /** 836 * @brief Formats InsufficientPrivilege message into JSON 837 * Message body: "There are insufficient privileges for the account or 838 * credentials associated with the current session to perform the requested 839 * operation." 840 * 841 * 842 * @returns Message InsufficientPrivilege formatted to JSON */ 843 nlohmann::json insufficientPrivilege(); 844 845 void insufficientPrivilege(crow::Response& res); 846 847 /** 848 * @brief Formats PropertyValueModified message into JSON 849 * Message body: "The property <arg1> was assigned the value <arg2> due to 850 * modification by the service." 851 * 852 * @param[in] arg1 Parameter of message that will replace %1 in its body. 853 * @param[in] arg2 Parameter of message that will replace %2 in its body. 854 * 855 * @returns Message PropertyValueModified formatted to JSON */ 856 nlohmann::json propertyValueModified(const std::string& arg1, 857 const std::string& arg2); 858 859 void propertyValueModified(crow::Response& res, const std::string& arg1, 860 const std::string& arg2); 861 862 /** 863 * @brief Formats AccountNotModified message into JSON 864 * Message body: "The account modification request failed." 865 * 866 * 867 * @returns Message AccountNotModified formatted to JSON */ 868 nlohmann::json accountNotModified(); 869 870 void accountNotModified(crow::Response& res); 871 872 /** 873 * @brief Formats QueryParameterValueFormatError message into JSON 874 * Message body: "The value <arg1> for the parameter <arg2> is of a different 875 * format than the parameter can accept." 876 * 877 * @param[in] arg1 Parameter of message that will replace %1 in its body. 878 * @param[in] arg2 Parameter of message that will replace %2 in its body. 879 * 880 * @returns Message QueryParameterValueFormatError formatted to JSON */ 881 882 nlohmann::json queryParameterValueFormatError(const std::string& arg1, 883 const std::string& arg2); 884 885 void queryParameterValueFormatError(crow::Response& res, 886 const std::string& arg1, 887 const std::string& arg2); 888 889 /** 890 * @brief Formats PropertyMissing message into JSON 891 * Message body: "The property <arg1> is a required property and must be 892 * included in the request." 893 * 894 * @param[in] arg1 Parameter of message that will replace %1 in its body. 895 * 896 * @returns Message PropertyMissing formatted to JSON */ 897 nlohmann::json propertyMissing(const std::string& arg1); 898 899 void propertyMissing(crow::Response& res, const std::string& arg1); 900 901 /** 902 * @brief Formats ResourceExhaustion message into JSON 903 * Message body: "The resource <arg1> was unable to satisfy the request due to 904 * unavailability of resources." 905 * 906 * @param[in] arg1 Parameter of message that will replace %1 in its body. 907 * 908 * @returns Message ResourceExhaustion formatted to JSON */ 909 nlohmann::json resourceExhaustion(const std::string& arg1); 910 911 void resourceExhaustion(crow::Response& res, const std::string& arg1); 912 913 /** 914 * @brief Formats AccountModified message into JSON 915 * Message body: "The account was successfully modified." 916 * 917 * 918 * @returns Message AccountModified formatted to JSON */ 919 nlohmann::json accountModified(); 920 921 void accountModified(crow::Response& res); 922 923 /** 924 * @brief Formats QueryParameterOutOfRange message into JSON 925 * Message body: "The value <arg1> for the query parameter <arg2> is out of 926 * range <arg3>." 927 * 928 * @param[in] arg1 Parameter of message that will replace %1 in its body. 929 * @param[in] arg2 Parameter of message that will replace %2 in its body. 930 * @param[in] arg3 Parameter of message that will replace %3 in its body. 931 * 932 * @returns Message QueryParameterOutOfRange formatted to JSON */ 933 nlohmann::json queryParameterOutOfRange(const std::string& arg1, 934 const std::string& arg2, 935 const std::string& arg3); 936 937 void queryParameterOutOfRange(crow::Response& res, const std::string& arg1, 938 const std::string& arg2, const std::string& arg3); 939 940 /** 941 * @brief Formats PasswordChangeRequired message into JSON 942 * Message body: The password provided for this account must be changed 943 * before access is granted. PATCH the 'Password' property for this 944 * account located at the target URI '%1' to complete this process. 945 * 946 * @param[in] arg1 Parameter of message that will replace %1 in its body. 947 * 948 * @returns Message PasswordChangeRequired formatted to JSON */ 949 void passwordChangeRequired(crow::Response& res, const std::string& arg1); 950 951 /** 952 * @brief Formats InvalidUpload message into JSON 953 * Message body: Invalid file uploaded to %1: %2.* 954 * @param[in] arg1 Parameter of message that will replace %1 in its body. 955 * @param[in] arg2 Parameter of message that will replace %2 in its body. 956 * 957 * @returns Message InvalidUpload formatted to JSON */ 958 nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2); 959 960 void invalidUpload(crow::Response& res, const std::string& arg1, 961 const std::string& arg2); 962 963 } // namespace messages 964 965 } // namespace redfish 966