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