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