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