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