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(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(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 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 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 ActionParameterValueError message into JSON 855 * Message body: "Indicates that a parameter was given an invalid value." 856 * The value for the parameter %1 in the action %2 is invalid. 857 * 858 * @param[in] arg1 Parameter of message that will replace %1 in its body. 859 * @param[in] arg2 Parameter of message that will replace %2 in its body. 860 * 861 * @returns Message ActionParameterValueError formatted to JSON */ 862 nlohmann::json actionParameterValueError(const nlohmann::json& arg1, 863 std::string_view arg2); 864 865 void actionParameterValueError(crow::Response& res, const nlohmann::json& arg1, 866 std::string_view arg2); 867 868 /** 869 * @brief Formats SessionLimitExceeded message into JSON 870 * Message body: "The session establishment failed due to the number of 871 * simultaneous sessions exceeding the limit of the implementation." 872 * 873 * 874 * @returns Message SessionLimitExceeded formatted to JSON */ 875 nlohmann::json sessionLimitExceeded(); 876 877 void sessionLimitExceeded(crow::Response& res); 878 879 /** 880 * @brief Formats ActionNotSupported message into JSON 881 * Message body: "The action <arg1> is not supported by the resource." 882 * 883 * @param[in] arg1 Parameter of message that will replace %1 in its body. 884 * 885 * @returns Message ActionNotSupported formatted to JSON */ 886 nlohmann::json actionNotSupported(std::string_view arg1); 887 888 void actionNotSupported(crow::Response& res, std::string_view arg1); 889 890 /** 891 * @brief Formats InvalidIndex message into JSON 892 * Message body: "The index <arg1> is not a valid offset into the array." 893 * 894 * @param[in] arg1 Parameter of message that will replace %1 in its body. 895 * 896 * @returns Message InvalidIndex formatted to JSON */ 897 nlohmann::json invalidIndex(int64_t arg1); 898 899 void invalidIndex(crow::Response& res, int64_t arg1); 900 901 /** 902 * @brief Formats EmptyJSON message into JSON 903 * Message body: "The request body submitted contained an empty JSON object and 904 * the service is unable to process it." 905 * 906 * 907 * @returns Message EmptyJSON formatted to JSON */ 908 nlohmann::json emptyJSON(); 909 910 void emptyJSON(crow::Response& res); 911 912 /** 913 * @brief Formats QueryNotSupportedOnResource message into JSON 914 * Message body: "Querying is not supported on the requested resource." 915 * 916 * 917 * @returns Message QueryNotSupportedOnResource formatted to JSON */ 918 nlohmann::json queryNotSupportedOnResource(); 919 920 void queryNotSupportedOnResource(crow::Response& res); 921 922 /** 923 * @brief Formats QueryNotSupportedOnOperation message into JSON 924 * Message body: "Querying is not supported with the requested operation." 925 * 926 * 927 * @returns Message QueryNotSupportedOnOperation formatted to JSON */ 928 nlohmann::json queryNotSupportedOnOperation(); 929 930 void queryNotSupportedOnOperation(crow::Response& res); 931 932 /** 933 * @brief Formats QueryCombinationInvalid message into JSON 934 * Message body: "Two or more query parameters in the request cannot be used 935 * together." 936 * 937 * 938 * @returns Message QueryCombinationInvalid formatted to JSON */ 939 nlohmann::json queryCombinationInvalid(); 940 941 void queryCombinationInvalid(crow::Response& res); 942 943 /** 944 * @brief Formats InsufficientPrivilege message into JSON 945 * Message body: "There are insufficient privileges for the account or 946 * credentials associated with the current session to perform the requested 947 * operation." 948 * 949 * 950 * @returns Message InsufficientPrivilege formatted to JSON */ 951 nlohmann::json insufficientPrivilege(); 952 953 void insufficientPrivilege(crow::Response& res); 954 955 /** 956 * @brief Formats PropertyValueModified message into JSON 957 * Message body: "The property <arg1> was assigned the value <arg2> due to 958 * modification by the service." 959 * 960 * @param[in] arg1 Parameter of message that will replace %1 in its body. 961 * @param[in] arg2 Parameter of message that will replace %2 in its body. 962 * 963 * @returns Message PropertyValueModified formatted to JSON */ 964 nlohmann::json propertyValueModified(std::string_view arg1, 965 const nlohmann::json& arg2); 966 967 void propertyValueModified(crow::Response& res, std::string_view arg1, 968 const nlohmann::json& arg2); 969 970 /** 971 * @brief Formats AccountNotModified message into JSON 972 * Message body: "The account modification request failed." 973 * 974 * 975 * @returns Message AccountNotModified formatted to JSON */ 976 nlohmann::json accountNotModified(); 977 978 void accountNotModified(crow::Response& res); 979 980 /** 981 * @brief Formats QueryParameterValueFormatError message into JSON 982 * Message body: "The value <arg1> for the parameter <arg2> is of a different 983 * format than the parameter can accept." 984 * 985 * @param[in] arg1 Parameter of message that will replace %1 in its body. 986 * @param[in] arg2 Parameter of message that will replace %2 in its body. 987 * 988 * @returns Message QueryParameterValueFormatError formatted to JSON */ 989 990 nlohmann::json queryParameterValueFormatError(const nlohmann::json& arg1, 991 std::string_view arg2); 992 993 void queryParameterValueFormatError(crow::Response& res, 994 const nlohmann::json& arg1, 995 std::string_view arg2); 996 997 /** 998 * @brief Formats PropertyMissing message into JSON 999 * Message body: "The property <arg1> is a required property and must be 1000 * included in the request." 1001 * 1002 * @param[in] arg1 Parameter of message that will replace %1 in its body. 1003 * 1004 * @returns Message PropertyMissing formatted to JSON */ 1005 nlohmann::json propertyMissing(std::string_view arg1); 1006 1007 void propertyMissing(crow::Response& res, std::string_view arg1); 1008 1009 /** 1010 * @brief Formats ResourceExhaustion message into JSON 1011 * Message body: "The resource <arg1> was unable to satisfy the request due to 1012 * unavailability of resources." 1013 * 1014 * @param[in] arg1 Parameter of message that will replace %1 in its body. 1015 * 1016 * @returns Message ResourceExhaustion formatted to JSON */ 1017 nlohmann::json resourceExhaustion(std::string_view arg1); 1018 1019 void resourceExhaustion(crow::Response& res, std::string_view arg1); 1020 1021 /** 1022 * @brief Formats AccountModified message into JSON 1023 * Message body: "The account was successfully modified." 1024 * 1025 * 1026 * @returns Message AccountModified formatted to JSON */ 1027 nlohmann::json accountModified(); 1028 1029 void accountModified(crow::Response& res); 1030 1031 /** 1032 * @brief Formats QueryParameterOutOfRange message into JSON 1033 * Message body: "The value <arg1> for the query parameter <arg2> is out of 1034 * range <arg3>." 1035 * 1036 * @param[in] arg1 Parameter of message that will replace %1 in its body. 1037 * @param[in] arg2 Parameter of message that will replace %2 in its body. 1038 * @param[in] arg3 Parameter of message that will replace %3 in its body. 1039 * 1040 * @returns Message QueryParameterOutOfRange formatted to JSON */ 1041 nlohmann::json queryParameterOutOfRange(std::string_view arg1, 1042 std::string_view arg2, 1043 std::string_view arg3); 1044 1045 void queryParameterOutOfRange(crow::Response& res, std::string_view arg1, 1046 std::string_view arg2, std::string_view arg3); 1047 1048 /** 1049 * @brief Formats PasswordChangeRequired message into JSON 1050 * Message body: The password provided for this account must be changed 1051 * before access is granted. PATCH the 'Password' property for this 1052 * account located at the target URI '%1' to complete this process. 1053 * 1054 * @param[in] arg1 Parameter of message that will replace %1 in its body. 1055 * 1056 * @returns Message PasswordChangeRequired formatted to JSON */ 1057 1058 nlohmann::json passwordChangeRequired(boost::urls::url_view arg1); 1059 1060 void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1); 1061 1062 /** 1063 * @brief Formats InvalidUpload message into JSON 1064 * Message body: Invalid file uploaded to %1: %2.* 1065 * @param[in] arg1 Parameter of message that will replace %1 in its body. 1066 * @param[in] arg2 Parameter of message that will replace %2 in its body. 1067 * 1068 * @returns Message InvalidUpload formatted to JSON */ 1069 nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2); 1070 1071 void invalidUpload(crow::Response& res, std::string_view arg1, 1072 std::string_view arg2); 1073 1074 /** 1075 * @brief Formats InsufficientStorage message into JSON 1076 * Message body: "Insufficient storage or memory available to complete the 1077 * request." 1078 * @returns Message InsufficientStorage formatted to JSON */ 1079 nlohmann::json insufficientStorage(); 1080 1081 void insufficientStorage(crow::Response& res); 1082 1083 /** 1084 * @brief Formats OperationNotAllowed message into JSON 1085 * Message body: "he HTTP method is not allowed on this resource." 1086 * @returns Message OperationNotAllowed formatted to JSON */ 1087 nlohmann::json operationNotAllowed(); 1088 1089 void operationNotAllowed(crow::Response& res); 1090 1091 /** 1092 * @brief Formats ArraySizeTooLong message into JSON 1093 * Message body: "Indicates that a string value passed to the given resource 1094 * exceeded its length limit." 1095 * @returns Message ArraySizeTooLong formatted to JSON */ 1096 nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length); 1097 1098 void arraySizeTooLong(crow::Response& res, std::string_view property, 1099 uint64_t length); 1100 1101 } // namespace messages 1102 1103 } // namespace redfish 1104