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