xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision a08b46ccf0fc0081cecc4843484c4f0eb13f5a9a)
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 #include <crow/logging.h>
17 
18 #include <error_messages.hpp>
19 
20 namespace redfish
21 {
22 
23 namespace messages
24 {
25 
26 static void addMessageToErrorJson(nlohmann::json& target,
27                                   const nlohmann::json& message)
28 {
29     auto& error = target["error"];
30 
31     // If this is the first error message, fill in the information from the
32     // first error message to the top level struct
33     if (!error.is_object())
34     {
35         auto message_id_iterator = message.find("MessageId");
36         if (message_id_iterator == message.end())
37         {
38             BMCWEB_LOG_CRITICAL
39                 << "Attempt to add error message without MessageId";
40             return;
41         }
42 
43         auto message_field_iterator = message.find("Message");
44         if (message_field_iterator == message.end())
45         {
46             BMCWEB_LOG_CRITICAL
47                 << "Attempt to add error message without Message";
48             return;
49         }
50         // clang-format off
51     error = {
52         {"code", *message_id_iterator},
53         {"message", *message_field_iterator}
54     };
55         // clang-format on
56     }
57     else
58     {
59         // More than 1 error occurred, so the message has to be generic
60         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
61         error["message"] = "A general error has occurred. See Resolution for "
62                            "information on how to resolve the error.";
63     }
64 
65     // This check could technically be done in in the default construction
66     // branch above, but because we need the pointer to the extended info field
67     // anyway, it's more efficient to do it here.
68     auto& extended_info = error[messages::messageAnnotation];
69     if (!extended_info.is_array())
70     {
71         extended_info = nlohmann::json::array();
72     }
73 
74     extended_info.push_back(message);
75 }
76 
77 static void addMessageToJsonRoot(nlohmann::json& target,
78                                  const nlohmann::json& message)
79 {
80     if (!target[messages::messageAnnotation].is_array())
81     {
82         // Force object to be an array
83         target[messages::messageAnnotation] = nlohmann::json::array();
84     }
85 
86     target[messages::messageAnnotation].push_back(message);
87 }
88 
89 static void addMessageToJson(nlohmann::json& target,
90                              const nlohmann::json& message,
91                              const std::string& fieldPath)
92 {
93     std::string extendedInfo(fieldPath + messages::messageAnnotation);
94 
95     if (!target[extendedInfo].is_array())
96     {
97         // Force object to be an array
98         target[extendedInfo] = nlohmann::json::array();
99     }
100 
101     // Object exists and it is an array so we can just push in the message
102     target[extendedInfo].push_back(message);
103 }
104 
105 /**
106  * @internal
107  * @brief Formats ResourceInUse message into JSON
108  *
109  * See header file for more information
110  * @endinternal
111  */
112 void resourceInUse(crow::Response& res)
113 {
114     res.result(boost::beast::http::status::service_unavailable);
115     addMessageToErrorJson(
116         res.jsonValue,
117         nlohmann::json{
118             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
119             {"MessageId", "Base.1.4.0.ResourceInUse"},
120             {"Message", "The change to the requested resource failed because "
121                         "the resource is in use or in transition."},
122             {"Severity", "Warning"},
123             {"Resolution", "Remove the condition and resubmit the request if "
124                            "the operation failed."}});
125 }
126 
127 /**
128  * @internal
129  * @brief Formats MalformedJSON message into JSON
130  *
131  * See header file for more information
132  * @endinternal
133  */
134 void malformedJSON(crow::Response& res)
135 {
136     res.result(boost::beast::http::status::bad_request);
137     addMessageToErrorJson(
138         res.jsonValue,
139         nlohmann::json{
140             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
141             {"MessageId", "Base.1.4.0.MalformedJSON"},
142             {"Message", "The request body submitted was malformed JSON and "
143                         "could not be parsed by the receiving service."},
144             {"Severity", "Critical"},
145             {"Resolution", "Ensure that the request body is valid JSON and "
146                            "resubmit the request."}});
147 }
148 
149 /**
150  * @internal
151  * @brief Formats ResourceMissingAtURI message into JSON
152  *
153  * See header file for more information
154  * @endinternal
155  */
156 void resourceMissingAtURI(crow::Response& res, const std::string& arg1)
157 {
158     res.result(boost::beast::http::status::bad_request);
159     addMessageToErrorJson(
160         res.jsonValue,
161         nlohmann::json{
162             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
163             {"MessageId", "Base.1.4.0.ResourceMissingAtURI"},
164             {"Message", "The resource at the URI " + arg1 + " was not found."},
165             {"Severity", "Critical"},
166             {"Resolution", "Place a valid resource at the URI or correct the "
167                            "URI and resubmit the request."}});
168 }
169 
170 /**
171  * @internal
172  * @brief Formats ActionParameterValueFormatError message into JSON
173  *
174  * See header file for more information
175  * @endinternal
176  */
177 void actionParameterValueFormatError(crow::Response& res,
178                                      const std::string& arg1,
179                                      const std::string& arg2,
180                                      const std::string& arg3)
181 {
182     res.result(boost::beast::http::status::bad_request);
183     addMessageToErrorJson(
184         res.jsonValue,
185         nlohmann::json{
186             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
187             {"MessageId", "Base.1.4.0.ActionParameterValueFormatError"},
188             {"Message",
189              "The value " + arg1 + " for the parameter " + arg2 +
190                  " in the action " + arg3 +
191                  " is of a different format than the parameter can accept."},
192             {"Severity", "Warning"},
193             {"Resolution",
194              "Correct the value for the parameter in the request body and "
195              "resubmit the request if the operation failed."}});
196 }
197 
198 /**
199  * @internal
200  * @brief Formats InternalError message into JSON
201  *
202  * See header file for more information
203  * @endinternal
204  */
205 void internalError(crow::Response& res)
206 {
207     res.result(boost::beast::http::status::internal_server_error);
208     addMessageToErrorJson(
209         res.jsonValue,
210         nlohmann::json{
211             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
212             {"MessageId", "Base.1.4.0.InternalError"},
213             {"Message", "The request failed due to an internal service error.  "
214                         "The service is still operational."},
215             {"Severity", "Critical"},
216             {"Resolution", "Resubmit the request.  If the problem persists, "
217                            "consider resetting the service."}});
218 }
219 
220 /**
221  * @internal
222  * @brief Formats UnrecognizedRequestBody message into JSON
223  *
224  * See header file for more information
225  * @endinternal
226  */
227 void unrecognizedRequestBody(crow::Response& res)
228 {
229     res.result(boost::beast::http::status::bad_request);
230     addMessageToErrorJson(
231         res.jsonValue,
232         nlohmann::json{
233             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
234             {"MessageId", "Base.1.4.0.UnrecognizedRequestBody"},
235             {"Message", "The service detected a malformed request body that it "
236                         "was unable to interpret."},
237             {"Severity", "Warning"},
238             {"Resolution", "Correct the request body and resubmit the request "
239                            "if it failed."}});
240 }
241 
242 /**
243  * @internal
244  * @brief Formats ResourceAtUriUnauthorized message into JSON
245  *
246  * See header file for more information
247  * @endinternal
248  */
249 void resourceAtUriUnauthorized(crow::Response& res, const std::string& arg1,
250                                const std::string& arg2)
251 {
252     res.result(boost::beast::http::status::forbidden);
253     addMessageToErrorJson(
254         res.jsonValue,
255         nlohmann::json{
256             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
257             {"MessageId", "Base.1.4.0.ResourceAtUriUnauthorized"},
258             {"Message", "While accessing the resource at " + arg1 +
259                             ", the service received an authorization error " +
260                             arg2 + "."},
261             {"Severity", "Critical"},
262             {"Resolution", "Ensure that the appropriate access is provided for "
263                            "the service in order for it to access the URI."}});
264 }
265 
266 /**
267  * @internal
268  * @brief Formats ActionParameterUnknown message into JSON
269  *
270  * See header file for more information
271  * @endinternal
272  */
273 void actionParameterUnknown(crow::Response& res, const std::string& arg1,
274                             const std::string& arg2)
275 {
276     res.result(boost::beast::http::status::bad_request);
277     addMessageToErrorJson(
278         res.jsonValue,
279         nlohmann::json{
280             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
281             {"MessageId", "Base.1.4.0.ActionParameterUnknown"},
282             {"Message", "The action " + arg1 +
283                             " was submitted with the invalid parameter " +
284                             arg2 + "."},
285             {"Severity", "Warning"},
286             {"Resolution", "Correct the invalid parameter and resubmit the "
287                            "request if the operation failed."}});
288 }
289 
290 /**
291  * @internal
292  * @brief Formats ResourceCannotBeDeleted message into JSON
293  *
294  * See header file for more information
295  * @endinternal
296  */
297 void resourceCannotBeDeleted(crow::Response& res)
298 {
299     res.result(boost::beast::http::status::forbidden);
300     addMessageToErrorJson(
301         res.jsonValue,
302         nlohmann::json{
303             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
304             {"MessageId", "Base.1.4.0.ResourceCannotBeDeleted"},
305             {"Message", "The delete request failed because the resource "
306                         "requested cannot be deleted."},
307             {"Severity", "Critical"},
308             {"Resolution",
309              "Do not attempt to delete a non-deletable resource."}});
310 }
311 
312 /**
313  * @internal
314  * @brief Formats PropertyDuplicate message into JSON
315  *
316  * See header file for more information
317  * @endinternal
318  */
319 void propertyDuplicate(crow::Response& res, const std::string& arg1)
320 {
321     res.result(boost::beast::http::status::bad_request);
322     addMessageToJson(
323         res.jsonValue,
324         nlohmann::json{
325             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
326             {"MessageId", "Base.1.4.0.PropertyDuplicate"},
327             {"Message",
328              "The property " + arg1 + " was duplicated in the request."},
329             {"Severity", "Warning"},
330             {"Resolution",
331              "Remove the duplicate property from the request body and resubmit "
332              "the request if the operation failed."}},
333         arg1);
334 }
335 
336 /**
337  * @internal
338  * @brief Formats ServiceTemporarilyUnavailable message into JSON
339  *
340  * See header file for more information
341  * @endinternal
342  */
343 void serviceTemporarilyUnavailable(crow::Response& res, const std::string& arg1)
344 {
345     res.result(boost::beast::http::status::service_unavailable);
346     addMessageToErrorJson(
347         res.jsonValue,
348         nlohmann::json{
349             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
350             {"MessageId", "Base.1.4.0.ServiceTemporarilyUnavailable"},
351             {"Message", "The service is temporarily unavailable.  Retry in " +
352                             arg1 + " seconds."},
353             {"Severity", "Critical"},
354             {"Resolution", "Wait for the indicated retry duration and retry "
355                            "the operation."}});
356 }
357 
358 /**
359  * @internal
360  * @brief Formats ResourceAlreadyExists message into JSON
361  *
362  * See header file for more information
363  * @endinternal
364  */
365 void resourceAlreadyExists(crow::Response& res, const std::string& arg1,
366                            const std::string& arg2, const std::string& arg3)
367 {
368     res.result(boost::beast::http::status::bad_request);
369     addMessageToJson(
370         res.jsonValue,
371         nlohmann::json{
372             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
373             {"MessageId", "Base.1.4.0.ResourceAlreadyExists"},
374             {"Message", "The requested resource of type " + arg1 +
375                             " with the property " + arg2 + " with the value " +
376                             arg3 + " already exists."},
377             {"Severity", "Critical"},
378             {"Resolution", "Do not repeat the create operation as the resource "
379                            "has already been created."}},
380         arg2);
381 }
382 
383 /**
384  * @internal
385  * @brief Formats AccountForSessionNoLongerExists message into JSON
386  *
387  * See header file for more information
388  * @endinternal
389  */
390 void accountForSessionNoLongerExists(crow::Response& res)
391 {
392     res.result(boost::beast::http::status::forbidden);
393     addMessageToErrorJson(
394         res.jsonValue,
395         nlohmann::json{
396             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
397             {"MessageId", "Base.1.4.0.AccountForSessionNoLongerExists"},
398             {"Message", "The account for the current session has been removed, "
399                         "thus the current session has been removed as well."},
400             {"Severity", "OK"},
401             {"Resolution", "Attempt to connect with a valid account."}});
402 }
403 
404 /**
405  * @internal
406  * @brief Formats CreateFailedMissingReqProperties message into JSON
407  *
408  * See header file for more information
409  * @endinternal
410  */
411 void createFailedMissingReqProperties(crow::Response& res,
412                                       const std::string& arg1)
413 {
414     res.result(boost::beast::http::status::bad_request);
415     addMessageToJson(
416         res.jsonValue,
417         nlohmann::json{
418             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
419             {"MessageId", "Base.1.4.0.CreateFailedMissingReqProperties"},
420             {"Message",
421              "The create operation failed because the required property " +
422                  arg1 + " was missing from the request."},
423             {"Severity", "Critical"},
424             {"Resolution",
425              "Correct the body to include the required property with a valid "
426              "value and resubmit the request if the operation failed."}},
427         arg1);
428 }
429 
430 /**
431  * @internal
432  * @brief Formats PropertyValueFormatError message into JSON for the specified
433  * property
434  *
435  * See header file for more information
436  * @endinternal
437  */
438 void propertyValueFormatError(crow::Response& res, const std::string& arg1,
439                               const std::string& arg2)
440 {
441     res.result(boost::beast::http::status::bad_request);
442     addMessageToJson(
443         res.jsonValue,
444         nlohmann::json{
445             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
446             {"MessageId", "Base.1.4.0.PropertyValueFormatError"},
447             {"Message",
448              "The value " + arg1 + " for the property " + arg2 +
449                  " is of a different format than the property can accept."},
450             {"Severity", "Warning"},
451             {"Resolution",
452              "Correct the value for the property in the request body and "
453              "resubmit the request if the operation failed."}},
454         arg2);
455 }
456 
457 /**
458  * @internal
459  * @brief Formats PropertyValueNotInList message into JSON for the specified
460  * property
461  *
462  * See header file for more information
463  * @endinternal
464  */
465 void propertyValueNotInList(crow::Response& res, const std::string& arg1,
466                             const std::string& arg2)
467 {
468     res.result(boost::beast::http::status::bad_request);
469     addMessageToJson(
470         res.jsonValue,
471         nlohmann::json{
472             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
473             {"MessageId", "Base.1.4.0.PropertyValueNotInList"},
474             {"Message", "The value " + arg1 + " for the property " + arg2 +
475                             " is not in the list of acceptable values."},
476             {"Severity", "Warning"},
477             {"Resolution",
478              "Choose a value from the enumeration list that the implementation "
479              "can support and resubmit the request if the operation failed."}},
480         arg2);
481 }
482 
483 /**
484  * @internal
485  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
486  *
487  * See header file for more information
488  * @endinternal
489  */
490 void resourceAtUriInUnknownFormat(crow::Response& res, const std::string& arg1)
491 {
492     res.result(boost::beast::http::status::bad_request);
493     addMessageToErrorJson(
494         res.jsonValue,
495         nlohmann::json{
496             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
497             {"MessageId", "Base.1.4.0.ResourceAtUriInUnknownFormat"},
498             {"Message", "The resource at " + arg1 +
499                             " is in a format not recognized by the service."},
500             {"Severity", "Critical"},
501             {"Resolution", "Place an image or resource or file that is "
502                            "recognized by the service at the URI."}});
503 }
504 
505 /**
506  * @internal
507  * @brief Formats ServiceInUnknownState message into JSON
508  *
509  * See header file for more information
510  * @endinternal
511  */
512 void serviceInUnknownState(crow::Response& res)
513 {
514     res.result(boost::beast::http::status::service_unavailable);
515     addMessageToErrorJson(
516         res.jsonValue,
517         nlohmann::json{
518             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
519             {"MessageId", "Base.1.4.0.ServiceInUnknownState"},
520             {"Message",
521              "The operation failed because the service is in an unknown state "
522              "and can no longer take incoming requests."},
523             {"Severity", "Critical"},
524             {"Resolution", "Restart the service and resubmit the request if "
525                            "the operation failed."}});
526 }
527 
528 /**
529  * @internal
530  * @brief Formats EventSubscriptionLimitExceeded message into JSON
531  *
532  * See header file for more information
533  * @endinternal
534  */
535 void eventSubscriptionLimitExceeded(crow::Response& res)
536 {
537     res.result(boost::beast::http::status::forbidden);
538     addMessageToErrorJson(
539         res.jsonValue,
540         nlohmann::json{
541             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
542             {"MessageId", "Base.1.4.0.EventSubscriptionLimitExceeded"},
543             {"Message",
544              "The event subscription failed due to the number of simultaneous "
545              "subscriptions exceeding the limit of the implementation."},
546             {"Severity", "Critical"},
547             {"Resolution",
548              "Reduce the number of other subscriptions before trying to "
549              "establish the event subscription or increase the limit of "
550              "simultaneous subscriptions (if supported)."}});
551 }
552 
553 /**
554  * @internal
555  * @brief Formats ActionParameterMissing message into JSON
556  *
557  * See header file for more information
558  * @endinternal
559  */
560 void actionParameterMissing(crow::Response& res, const std::string& arg1,
561                             const std::string& arg2)
562 {
563     res.result(boost::beast::http::status::bad_request);
564     addMessageToErrorJson(
565         res.jsonValue,
566         nlohmann::json{
567             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
568             {"MessageId", "Base.1.4.0.ActionParameterMissing"},
569             {"Message", "The action " + arg1 + " requires the parameter " +
570                             arg2 + " to be present in the request body."},
571             {"Severity", "Critical"},
572             {"Resolution",
573              "Supply the action with the required parameter in the request "
574              "body when the request is resubmitted."}});
575 }
576 
577 /**
578  * @internal
579  * @brief Formats StringValueTooLong message into JSON
580  *
581  * See header file for more information
582  * @endinternal
583  */
584 void stringValueTooLong(crow::Response& res, const std::string& arg1,
585                         const int& arg2)
586 {
587     res.result(boost::beast::http::status::bad_request);
588     addMessageToErrorJson(
589         res.jsonValue,
590         nlohmann::json{
591             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
592             {"MessageId", "Base.1.4.0.StringValueTooLong"},
593             {"Message", "The string " + arg1 + " exceeds the length limit " +
594                             std::to_string(arg2) + "."},
595             {"Severity", "Warning"},
596             {"Resolution",
597              "Resubmit the request with an appropriate string length."}});
598 }
599 
600 /**
601  * @internal
602  * @brief Formats SessionTerminated message into JSON
603  *
604  * See header file for more information
605  * @endinternal
606  */
607 void sessionTerminated(crow::Response& res)
608 {
609     res.result(boost::beast::http::status::ok);
610     addMessageToJsonRoot(
611         res.jsonValue,
612         nlohmann::json{
613             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
614             {"MessageId", "Base.1.4.0.SessionTerminated"},
615             {"Message", "The session was successfully terminated."},
616             {"Severity", "OK"},
617             {"Resolution", "No resolution is required."}});
618 }
619 
620 /**
621  * @internal
622  * @brief Formats ResourceTypeIncompatible message into JSON
623  *
624  * See header file for more information
625  * @endinternal
626  */
627 void resourceTypeIncompatible(crow::Response& res, const std::string& arg1,
628                               const std::string& arg2)
629 {
630     res.result(boost::beast::http::status::bad_request);
631     addMessageToErrorJson(
632         res.jsonValue,
633         nlohmann::json{
634             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
635             {"MessageId", "Base.1.4.0.ResourceTypeIncompatible"},
636             {"Message", "The @odata.type of the request body " + arg1 +
637                             " is incompatible with the @odata.type of the "
638                             "resource which is " +
639                             arg2 + "."},
640             {"Severity", "Critical"},
641             {"Resolution", "Resubmit the request with a payload compatible "
642                            "with the resource's schema."}});
643 }
644 
645 /**
646  * @internal
647  * @brief Formats PropertyValueTypeError message into JSON for the specified
648  * property
649  *
650  * See header file for more information
651  * @endinternal
652  */
653 void propertyValueTypeError(crow::Response& res, const std::string& arg1,
654                             const std::string& arg2)
655 {
656     res.result(boost::beast::http::status::bad_request);
657     addMessageToJson(
658         res.jsonValue,
659         nlohmann::json{
660             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
661             {"MessageId", "Base.1.4.0.PropertyValueTypeError"},
662             {"Message",
663              "The value " + arg1 + " for the property " + arg2 +
664                  " is of a different type than the property can accept."},
665             {"Severity", "Warning"},
666             {"Resolution",
667              "Correct the value for the property in the request body and "
668              "resubmit the request if the operation failed."}},
669         arg2);
670 }
671 
672 /**
673  * @internal
674  * @brief Formats ResourceNotFound message into JSON
675  *
676  * See header file for more information
677  * @endinternal
678  */
679 void resourceNotFound(crow::Response& res, const std::string& arg1,
680                       const std::string& arg2)
681 {
682     res.result(boost::beast::http::status::not_found);
683     addMessageToErrorJson(
684         res.jsonValue,
685         nlohmann::json{
686             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
687             {"MessageId", "Base.1.4.0.ResourceNotFound"},
688             {"Message", "The requested resource of type " + arg1 + " named " +
689                             arg2 + " was not found."},
690             {"Severity", "Critical"},
691             {"Resolution",
692              "Provide a valid resource identifier and resubmit the request."}});
693 }
694 
695 /**
696  * @internal
697  * @brief Formats CouldNotEstablishConnection message into JSON
698  *
699  * See header file for more information
700  * @endinternal
701  */
702 void couldNotEstablishConnection(crow::Response& res, const std::string& arg1)
703 {
704     res.result(boost::beast::http::status::not_found);
705     addMessageToErrorJson(
706         res.jsonValue,
707         nlohmann::json{
708             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
709             {"MessageId", "Base.1.4.0.CouldNotEstablishConnection"},
710             {"Message",
711              "The service failed to establish a Connection with the URI " +
712                  arg1 + "."},
713             {"Severity", "Critical"},
714             {"Resolution",
715              "Ensure that the URI contains a valid and reachable node name, "
716              "protocol information and other URI components."}});
717 }
718 
719 /**
720  * @internal
721  * @brief Formats PropertyNotWritable message into JSON for the specified
722  * property
723  *
724  * See header file for more information
725  * @endinternal
726  */
727 void propertyNotWritable(crow::Response& res, const std::string& arg1)
728 {
729     res.result(boost::beast::http::status::forbidden);
730     addMessageToJson(
731         res.jsonValue,
732         nlohmann::json{
733             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
734             {"MessageId", "Base.1.4.0.PropertyNotWritable"},
735             {"Message",
736              "The property " + arg1 +
737                  " is a read only property and cannot be assigned a value."},
738             {"Severity", "Warning"},
739             {"Resolution", "Remove the property from the request body and "
740                            "resubmit the request if the operation failed."}},
741         arg1);
742 }
743 
744 /**
745  * @internal
746  * @brief Formats QueryParameterValueTypeError message into JSON
747  *
748  * See header file for more information
749  * @endinternal
750  */
751 void queryParameterValueTypeError(crow::Response& res, const std::string& arg1,
752                                   const std::string& arg2)
753 {
754     res.result(boost::beast::http::status::bad_request);
755     addMessageToErrorJson(
756         res.jsonValue,
757         nlohmann::json{
758             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
759             {"MessageId", "Base.1.4.0.QueryParameterValueTypeError"},
760             {"Message",
761              "The value " + arg1 + " for the query parameter " + arg2 +
762                  " is of a different type than the parameter can accept."},
763             {"Severity", "Warning"},
764             {"Resolution",
765              "Correct the value for the query parameter in the request and "
766              "resubmit the request if the operation failed."}});
767 }
768 
769 /**
770  * @internal
771  * @brief Formats ServiceShuttingDown message into JSON
772  *
773  * See header file for more information
774  * @endinternal
775  */
776 void serviceShuttingDown(crow::Response& res)
777 {
778     res.result(boost::beast::http::status::service_unavailable);
779     addMessageToErrorJson(
780         res.jsonValue,
781         nlohmann::json{
782             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
783             {"MessageId", "Base.1.4.0.ServiceShuttingDown"},
784             {"Message", "The operation failed because the service is shutting "
785                         "down and can no longer take incoming requests."},
786             {"Severity", "Critical"},
787             {"Resolution", "When the service becomes available, resubmit the "
788                            "request if the operation failed."}});
789 }
790 
791 /**
792  * @internal
793  * @brief Formats ActionParameterDuplicate message into JSON
794  *
795  * See header file for more information
796  * @endinternal
797  */
798 void actionParameterDuplicate(crow::Response& res, const std::string& arg1,
799                               const std::string& arg2)
800 {
801     res.result(boost::beast::http::status::bad_request);
802     addMessageToErrorJson(
803         res.jsonValue,
804         nlohmann::json{
805             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
806             {"MessageId", "Base.1.4.0.ActionParameterDuplicate"},
807             {"Message",
808              "The action " + arg1 +
809                  " was submitted with more than one value for the parameter " +
810                  arg2 + "."},
811             {"Severity", "Warning"},
812             {"Resolution",
813              "Resubmit the action with only one instance of the parameter in "
814              "the request body if the operation failed."}});
815 }
816 
817 /**
818  * @internal
819  * @brief Formats ActionParameterNotSupported message into JSON
820  *
821  * See header file for more information
822  * @endinternal
823  */
824 void actionParameterNotSupported(crow::Response& res, const std::string& arg1,
825                                  const std::string& arg2)
826 {
827     res.result(boost::beast::http::status::bad_request);
828     addMessageToErrorJson(
829         res.jsonValue,
830         nlohmann::json{
831             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
832             {"MessageId", "Base.1.4.0.ActionParameterNotSupported"},
833             {"Message", "The parameter " + arg1 + " for the action " + arg2 +
834                             " is not supported on the target resource."},
835             {"Severity", "Warning"},
836             {"Resolution", "Remove the parameter supplied and resubmit the "
837                            "request if the operation failed."}});
838 }
839 
840 /**
841  * @internal
842  * @brief Formats SourceDoesNotSupportProtocol message into JSON
843  *
844  * See header file for more information
845  * @endinternal
846  */
847 void sourceDoesNotSupportProtocol(crow::Response& res, const std::string& arg1,
848                                   const std::string& arg2)
849 {
850     res.result(boost::beast::http::status::bad_request);
851     addMessageToErrorJson(
852         res.jsonValue,
853         nlohmann::json{
854             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
855             {"MessageId", "Base.1.4.0.SourceDoesNotSupportProtocol"},
856             {"Message", "The other end of the Connection at " + arg1 +
857                             " does not support the specified protocol " + arg2 +
858                             "."},
859             {"Severity", "Critical"},
860             {"Resolution", "Change protocols or URIs. "}});
861 }
862 
863 /**
864  * @internal
865  * @brief Formats AccountRemoved message into JSON
866  *
867  * See header file for more information
868  * @endinternal
869  */
870 void accountRemoved(crow::Response& res)
871 {
872     res.result(boost::beast::http::status::ok);
873     addMessageToJsonRoot(
874         res.jsonValue,
875         nlohmann::json{
876             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
877             {"MessageId", "Base.1.4.0.AccountRemoved"},
878             {"Message", "The account was successfully removed."},
879             {"Severity", "OK"},
880             {"Resolution", "No resolution is required."}});
881 }
882 
883 /**
884  * @internal
885  * @brief Formats AccessDenied message into JSON
886  *
887  * See header file for more information
888  * @endinternal
889  */
890 void accessDenied(crow::Response& res, const std::string& arg1)
891 {
892     res.result(boost::beast::http::status::forbidden);
893     addMessageToErrorJson(
894         res.jsonValue,
895         nlohmann::json{
896             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
897             {"MessageId", "Base.1.4.0.AccessDenied"},
898             {"Message", "While attempting to establish a Connection to " +
899                             arg1 + ", the service denied access."},
900             {"Severity", "Critical"},
901             {"Resolution", "Attempt to ensure that the URI is correct and that "
902                            "the service has the appropriate credentials."}});
903 }
904 
905 /**
906  * @internal
907  * @brief Formats QueryNotSupported message into JSON
908  *
909  * See header file for more information
910  * @endinternal
911  */
912 void queryNotSupported(crow::Response& res)
913 {
914     res.result(boost::beast::http::status::bad_request);
915     addMessageToErrorJson(
916         res.jsonValue,
917         nlohmann::json{
918             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
919             {"MessageId", "Base.1.4.0.QueryNotSupported"},
920             {"Message", "Querying is not supported by the implementation."},
921             {"Severity", "Warning"},
922             {"Resolution", "Remove the query parameters and resubmit the "
923                            "request if the operation failed."}});
924 }
925 
926 /**
927  * @internal
928  * @brief Formats CreateLimitReachedForResource message into JSON
929  *
930  * See header file for more information
931  * @endinternal
932  */
933 void createLimitReachedForResource(crow::Response& res)
934 {
935     res.result(boost::beast::http::status::bad_request);
936     addMessageToErrorJson(
937         res.jsonValue,
938         nlohmann::json{
939             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
940             {"MessageId", "Base.1.4.0.CreateLimitReachedForResource"},
941             {"Message", "The create operation failed because the resource has "
942                         "reached the limit of possible resources."},
943             {"Severity", "Critical"},
944             {"Resolution",
945              "Either delete resources and resubmit the request if the "
946              "operation failed or do not resubmit the request."}});
947 }
948 
949 /**
950  * @internal
951  * @brief Formats GeneralError message into JSON
952  *
953  * See header file for more information
954  * @endinternal
955  */
956 void generalError(crow::Response& res)
957 {
958     res.result(boost::beast::http::status::internal_server_error);
959     addMessageToErrorJson(
960         res.jsonValue,
961         nlohmann::json{
962             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
963             {"MessageId", "Base.1.4.0.GeneralError"},
964             {"Message", "A general error has occurred. See Resolution for "
965                         "information on how to resolve the error."},
966             {"Severity", "Critical"},
967             {"Resolution", "None."}});
968 }
969 
970 /**
971  * @internal
972  * @brief Formats Success message into JSON
973  *
974  * See header file for more information
975  * @endinternal
976  */
977 void success(crow::Response& res)
978 {
979     res.result(boost::beast::http::status::ok);
980     addMessageToJsonRoot(
981         res.jsonValue,
982         nlohmann::json{
983             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
984             {"MessageId", "Base.1.4.0.Success"},
985             {"Message", "Successfully Completed Request"},
986             {"Severity", "OK"},
987             {"Resolution", "None"}});
988 }
989 
990 /**
991  * @internal
992  * @brief Formats Created message into JSON
993  *
994  * See header file for more information
995  * @endinternal
996  */
997 void created(crow::Response& res)
998 {
999     res.result(boost::beast::http::status::created);
1000     addMessageToJsonRoot(
1001         res.jsonValue,
1002         nlohmann::json{
1003             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1004             {"MessageId", "Base.1.4.0.Created"},
1005             {"Message", "The resource has been created successfully"},
1006             {"Severity", "OK"},
1007             {"Resolution", "None"}});
1008 }
1009 
1010 /**
1011  * @internal
1012  * @brief Formats NoOperation message into JSON
1013  *
1014  * See header file for more information
1015  * @endinternal
1016  */
1017 void noOperation(crow::Response& res)
1018 {
1019     res.result(boost::beast::http::status::bad_request);
1020     addMessageToErrorJson(
1021         res.jsonValue,
1022         nlohmann::json{
1023             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1024             {"MessageId", "Base.1.4.0.NoOperation"},
1025             {"Message", "The request body submitted contain no data to act "
1026                         "upon and no changes to the resource took place."},
1027             {"Severity", "Warning"},
1028             {"Resolution",
1029              "Add properties in the JSON object and resubmit the request."}});
1030 }
1031 
1032 /**
1033  * @internal
1034  * @brief Formats PropertyUnknown message into JSON for the specified property
1035  *
1036  * See header file for more information
1037  * @endinternal
1038  */
1039 void propertyUnknown(crow::Response& res, const std::string& arg1)
1040 {
1041     res.result(boost::beast::http::status::bad_request);
1042     addMessageToJson(
1043         res.jsonValue,
1044         nlohmann::json{
1045             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1046             {"MessageId", "Base.1.4.0.PropertyUnknown"},
1047             {"Message",
1048              "The property " + arg1 +
1049                  " is not in the list of valid properties for the resource."},
1050             {"Severity", "Warning"},
1051             {"Resolution",
1052              "Remove the unknown property from the request body and resubmit "
1053              "the request if the operation failed."}},
1054         arg1);
1055 }
1056 
1057 /**
1058  * @internal
1059  * @brief Formats NoValidSession message into JSON
1060  *
1061  * See header file for more information
1062  * @endinternal
1063  */
1064 void noValidSession(crow::Response& res)
1065 {
1066     res.result(boost::beast::http::status::forbidden);
1067     addMessageToErrorJson(
1068         res.jsonValue,
1069         nlohmann::json{
1070             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1071             {"MessageId", "Base.1.4.0.NoValidSession"},
1072             {"Message",
1073              "There is no valid session established with the implementation."},
1074             {"Severity", "Critical"},
1075             {"Resolution",
1076              "Establish as session before attempting any operations."}});
1077 }
1078 
1079 /**
1080  * @internal
1081  * @brief Formats InvalidObject message into JSON
1082  *
1083  * See header file for more information
1084  * @endinternal
1085  */
1086 void invalidObject(crow::Response& res, const std::string& arg1)
1087 {
1088     res.result(boost::beast::http::status::bad_request);
1089     addMessageToErrorJson(
1090         res.jsonValue,
1091         nlohmann::json{
1092             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1093             {"MessageId", "Base.1.4.0.InvalidObject"},
1094             {"Message", "The object at " + arg1 + " is invalid."},
1095             {"Severity", "Critical"},
1096             {"Resolution",
1097              "Either the object is malformed or the URI is not correct.  "
1098              "Correct the condition and resubmit the request if it failed."}});
1099 }
1100 
1101 /**
1102  * @internal
1103  * @brief Formats ResourceInStandby message into JSON
1104  *
1105  * See header file for more information
1106  * @endinternal
1107  */
1108 void resourceInStandby(crow::Response& res)
1109 {
1110     res.result(boost::beast::http::status::service_unavailable);
1111     addMessageToErrorJson(
1112         res.jsonValue,
1113         nlohmann::json{
1114             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1115             {"MessageId", "Base.1.4.0.ResourceInStandby"},
1116             {"Message", "The request could not be performed because the "
1117                         "resource is in standby."},
1118             {"Severity", "Critical"},
1119             {"Resolution", "Ensure that the resource is in the correct power "
1120                            "state and resubmit the request."}});
1121 }
1122 
1123 /**
1124  * @internal
1125  * @brief Formats ActionParameterValueTypeError message into JSON
1126  *
1127  * See header file for more information
1128  * @endinternal
1129  */
1130 void actionParameterValueTypeError(crow::Response& res, const std::string& arg1,
1131                                    const std::string& arg2,
1132                                    const std::string& arg3)
1133 {
1134     res.result(boost::beast::http::status::bad_request);
1135     addMessageToErrorJson(
1136         res.jsonValue,
1137         nlohmann::json{
1138             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1139             {"MessageId", "Base.1.4.0.ActionParameterValueTypeError"},
1140             {"Message",
1141              "The value " + arg1 + " for the parameter " + arg2 +
1142                  " in the action " + arg3 +
1143                  " is of a different type than the parameter can accept."},
1144             {"Severity", "Warning"},
1145             {"Resolution",
1146              "Correct the value for the parameter in the request body and "
1147              "resubmit the request if the operation failed."}});
1148 }
1149 
1150 /**
1151  * @internal
1152  * @brief Formats SessionLimitExceeded message into JSON
1153  *
1154  * See header file for more information
1155  * @endinternal
1156  */
1157 void sessionLimitExceeded(crow::Response& res)
1158 {
1159     res.result(boost::beast::http::status::service_unavailable);
1160     addMessageToErrorJson(
1161         res.jsonValue,
1162         nlohmann::json{
1163             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1164             {"MessageId", "Base.1.4.0.SessionLimitExceeded"},
1165             {"Message", "The session establishment failed due to the number of "
1166                         "simultaneous sessions exceeding the limit of the "
1167                         "implementation."},
1168             {"Severity", "Critical"},
1169             {"Resolution", "Reduce the number of other sessions before trying "
1170                            "to establish the session or increase the limit of "
1171                            "simultaneous sessions (if supported)."}});
1172 }
1173 
1174 /**
1175  * @internal
1176  * @brief Formats ActionNotSupported message into JSON
1177  *
1178  * See header file for more information
1179  * @endinternal
1180  */
1181 void actionNotSupported(crow::Response& res, const std::string& arg1)
1182 {
1183     res.result(boost::beast::http::status::bad_request);
1184     addMessageToErrorJson(
1185         res.jsonValue,
1186         nlohmann::json{
1187             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1188             {"MessageId", "Base.1.4.0.ActionNotSupported"},
1189             {"Message",
1190              "The action " + arg1 + " is not supported by the resource."},
1191             {"Severity", "Critical"},
1192             {"Resolution",
1193              "The action supplied cannot be resubmitted to the implementation. "
1194              " Perhaps the action was invalid, the wrong resource was the "
1195              "target or the implementation documentation may be of "
1196              "assistance."}});
1197 }
1198 
1199 /**
1200  * @internal
1201  * @brief Formats InvalidIndex message into JSON
1202  *
1203  * See header file for more information
1204  * @endinternal
1205  */
1206 void invalidIndex(crow::Response& res, const int& arg1)
1207 {
1208     res.result(boost::beast::http::status::bad_request);
1209     addMessageToErrorJson(
1210         res.jsonValue,
1211         nlohmann::json{
1212             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1213             {"MessageId", "Base.1.4.0.InvalidIndex"},
1214             {"Message", "The index " + std::to_string(arg1) +
1215                             " is not a valid offset into the array."},
1216             {"Severity", "Warning"},
1217             {"Resolution", "Verify the index value provided is within the "
1218                            "bounds of the array."}});
1219 }
1220 
1221 /**
1222  * @internal
1223  * @brief Formats EmptyJSON message into JSON
1224  *
1225  * See header file for more information
1226  * @endinternal
1227  */
1228 void emptyJSON(crow::Response& res)
1229 {
1230     res.result(boost::beast::http::status::bad_request);
1231     addMessageToErrorJson(
1232         res.jsonValue,
1233         nlohmann::json{
1234             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1235             {"MessageId", "Base.1.4.0.EmptyJSON"},
1236             {"Message", "The request body submitted contained an empty JSON "
1237                         "object and the service is unable to process it."},
1238             {"Severity", "Warning"},
1239             {"Resolution",
1240              "Add properties in the JSON object and resubmit the request."}});
1241 }
1242 
1243 /**
1244  * @internal
1245  * @brief Formats QueryNotSupportedOnResource message into JSON
1246  *
1247  * See header file for more information
1248  * @endinternal
1249  */
1250 void queryNotSupportedOnResource(crow::Response& res)
1251 {
1252     res.result(boost::beast::http::status::forbidden);
1253     addMessageToErrorJson(
1254         res.jsonValue,
1255         nlohmann::json{
1256             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1257             {"MessageId", "Base.1.4.0.QueryNotSupportedOnResource"},
1258             {"Message", "Querying is not supported on the requested resource."},
1259             {"Severity", "Warning"},
1260             {"Resolution", "Remove the query parameters and resubmit the "
1261                            "request if the operation failed."}});
1262 }
1263 
1264 /**
1265  * @internal
1266  * @brief Formats InsufficientPrivilege message into JSON
1267  *
1268  * See header file for more information
1269  * @endinternal
1270  */
1271 void insufficientPrivilege(crow::Response& res)
1272 {
1273     res.result(boost::beast::http::status::forbidden);
1274     addMessageToErrorJson(
1275         res.jsonValue,
1276         nlohmann::json{
1277             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1278             {"MessageId", "Base.1.4.0.InsufficientPrivilege"},
1279             {"Message", "There are insufficient privileges for the account or "
1280                         "credentials associated with the current session to "
1281                         "perform the requested operation."},
1282             {"Severity", "Critical"},
1283             {"Resolution",
1284              "Either abandon the operation or change the associated access "
1285              "rights and resubmit the request if the operation failed."}});
1286 }
1287 
1288 /**
1289  * @internal
1290  * @brief Formats PropertyValueModified message into JSON
1291  *
1292  * See header file for more information
1293  * @endinternal
1294  */
1295 void propertyValueModified(crow::Response& res, const std::string& arg1,
1296                            const std::string& arg2)
1297 {
1298     res.result(boost::beast::http::status::ok);
1299     addMessageToJson(
1300         res.jsonValue,
1301         nlohmann::json{
1302             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1303             {"MessageId", "Base.1.4.0.PropertyValueModified"},
1304             {"Message", "The property " + arg1 + " was assigned the value " +
1305                             arg2 + " due to modification by the service."},
1306             {"Severity", "Warning"},
1307             {"Resolution", "No resolution is required."}},
1308         arg1);
1309 }
1310 
1311 /**
1312  * @internal
1313  * @brief Formats AccountNotModified message into JSON
1314  *
1315  * See header file for more information
1316  * @endinternal
1317  */
1318 void accountNotModified(crow::Response& res)
1319 {
1320     res.result(boost::beast::http::status::bad_request);
1321     addMessageToErrorJson(
1322         res.jsonValue,
1323         nlohmann::json{
1324             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1325             {"MessageId", "Base.1.4.0.AccountNotModified"},
1326             {"Message", "The account modification request failed."},
1327             {"Severity", "Warning"},
1328             {"Resolution", "The modification may have failed due to permission "
1329                            "issues or issues with the request body."}});
1330 }
1331 
1332 /**
1333  * @internal
1334  * @brief Formats QueryParameterValueFormatError message into JSON
1335  *
1336  * See header file for more information
1337  * @endinternal
1338  */
1339 void queryParameterValueFormatError(crow::Response& res,
1340                                     const std::string& arg1,
1341                                     const std::string& arg2)
1342 {
1343     res.result(boost::beast::http::status::bad_request);
1344     addMessageToErrorJson(
1345         res.jsonValue,
1346         nlohmann::json{
1347             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1348             {"MessageId", "Base.1.4.0.QueryParameterValueFormatError"},
1349             {"Message",
1350              "The value " + arg1 + " for the parameter " + arg2 +
1351                  " is of a different format than the parameter can accept."},
1352             {"Severity", "Warning"},
1353             {"Resolution",
1354              "Correct the value for the query parameter in the request and "
1355              "resubmit the request if the operation failed."}});
1356 }
1357 
1358 /**
1359  * @internal
1360  * @brief Formats PropertyMissing message into JSON for the specified property
1361  *
1362  * See header file for more information
1363  * @endinternal
1364  */
1365 void propertyMissing(crow::Response& res, const std::string& arg1)
1366 {
1367     res.result(boost::beast::http::status::bad_request);
1368     addMessageToJson(
1369         res.jsonValue,
1370         nlohmann::json{
1371             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1372             {"MessageId", "Base.1.4.0.PropertyMissing"},
1373             {"Message", "The property " + arg1 +
1374                             " is a required property and must be included in "
1375                             "the request."},
1376             {"Severity", "Warning"},
1377             {"Resolution",
1378              "Ensure that the property is in the request body and has a valid "
1379              "value and resubmit the request if the operation failed."}},
1380         arg1);
1381 }
1382 
1383 /**
1384  * @internal
1385  * @brief Formats ResourceExhaustion message into JSON
1386  *
1387  * See header file for more information
1388  * @endinternal
1389  */
1390 void resourceExhaustion(crow::Response& res, const std::string& arg1)
1391 {
1392     res.result(boost::beast::http::status::service_unavailable);
1393     addMessageToErrorJson(
1394         res.jsonValue,
1395         nlohmann::json{
1396             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1397             {"MessageId", "Base.1.4.0.ResourceExhaustion"},
1398             {"Message", "The resource " + arg1 +
1399                             " was unable to satisfy the request due to "
1400                             "unavailability of resources."},
1401             {"Severity", "Critical"},
1402             {"Resolution", "Ensure that the resources are available and "
1403                            "resubmit the request."}});
1404 }
1405 
1406 /**
1407  * @internal
1408  * @brief Formats AccountModified message into JSON
1409  *
1410  * See header file for more information
1411  * @endinternal
1412  */
1413 void accountModified(crow::Response& res)
1414 {
1415     res.result(boost::beast::http::status::ok);
1416     addMessageToErrorJson(
1417         res.jsonValue,
1418         nlohmann::json{
1419             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1420             {"MessageId", "Base.1.4.0.AccountModified"},
1421             {"Message", "The account was successfully modified."},
1422             {"Severity", "OK"},
1423             {"Resolution", "No resolution is required."}});
1424 }
1425 
1426 /**
1427  * @internal
1428  * @brief Formats QueryParameterOutOfRange message into JSON
1429  *
1430  * See header file for more information
1431  * @endinternal
1432  */
1433 void queryParameterOutOfRange(crow::Response& res, const std::string& arg1,
1434                               const std::string& arg2, const std::string& arg3)
1435 {
1436     res.result(boost::beast::http::status::bad_request);
1437     addMessageToErrorJson(
1438         res.jsonValue,
1439         nlohmann::json{
1440             {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1441             {"MessageId", "Base.1.4.0.QueryParameterOutOfRange"},
1442             {"Message", "The value " + arg1 + " for the query parameter " +
1443                             arg2 + " is out of range " + arg3 + "."},
1444             {"Severity", "Warning"},
1445             {"Resolution",
1446              "Reduce the value for the query parameter to a value that is "
1447              "within range, such as a start or count value that is within "
1448              "bounds of the number of resources in a collection or a page that "
1449              "is within the range of valid pages."}});
1450 }
1451 
1452 } // namespace messages
1453 
1454 } // namespace redfish
1455