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