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