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