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 "error_messages.hpp"
17 
18 #include "http_response.hpp"
19 #include "logging.hpp"
20 #include "nlohmann/json.hpp"
21 #include "registries.hpp"
22 #include "registries/base_message_registry.hpp"
23 #include "source_location.hpp"
24 
25 #include <boost/beast/http/field.hpp>
26 #include <boost/beast/http/status.hpp>
27 
28 #include <array>
29 #include <cstddef>
30 #include <span>
31 #include <string>
32 #include <utility>
33 
34 // IWYU pragma: no_include <stddef.h>
35 
36 namespace redfish
37 {
38 
39 namespace messages
40 {
41 
42 static void addMessageToErrorJson(nlohmann::json& target,
43                                   const nlohmann::json& message)
44 {
45     auto& error = target["error"];
46 
47     // If this is the first error message, fill in the information from the
48     // first error message to the top level struct
49     if (!error.is_object())
50     {
51         auto messageIdIterator = message.find("MessageId");
52         if (messageIdIterator == message.end())
53         {
54             BMCWEB_LOG_CRITICAL
55                 << "Attempt to add error message without MessageId";
56             return;
57         }
58 
59         auto messageFieldIterator = message.find("Message");
60         if (messageFieldIterator == message.end())
61         {
62             BMCWEB_LOG_CRITICAL
63                 << "Attempt to add error message without Message";
64             return;
65         }
66         error["code"] = *messageIdIterator;
67         error["message"] = *messageFieldIterator;
68     }
69     else
70     {
71         // More than 1 error occurred, so the message has to be generic
72         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
73         error["message"] = "A general error has occurred. See Resolution for "
74                            "information on how to resolve the error.";
75     }
76 
77     // This check could technically be done in in the default construction
78     // branch above, but because we need the pointer to the extended info field
79     // anyway, it's more efficient to do it here.
80     auto& extendedInfo = error[messages::messageAnnotation];
81     if (!extendedInfo.is_array())
82     {
83         extendedInfo = nlohmann::json::array();
84     }
85 
86     extendedInfo.push_back(message);
87 }
88 
89 static void addMessageToJsonRoot(nlohmann::json& target,
90                                  const nlohmann::json& message)
91 {
92     if (!target[messages::messageAnnotation].is_array())
93     {
94         // Force object to be an array
95         target[messages::messageAnnotation] = nlohmann::json::array();
96     }
97 
98     target[messages::messageAnnotation].push_back(message);
99 }
100 
101 static void addMessageToJson(nlohmann::json& target,
102                              const nlohmann::json& message,
103                              std::string_view fieldPath)
104 {
105     std::string extendedInfo(fieldPath);
106     extendedInfo += messages::messageAnnotation;
107 
108     nlohmann::json& field = target[extendedInfo];
109     if (!field.is_array())
110     {
111         // Force object to be an array
112         field = nlohmann::json::array();
113     }
114 
115     // Object exists and it is an array so we can just push in the message
116     field.push_back(message);
117 }
118 
119 static nlohmann::json getLog(redfish::registries::base::Index name,
120                              std::span<const std::string_view> args)
121 {
122     size_t index = static_cast<size_t>(name);
123     if (index >= redfish::registries::base::registry.size())
124     {
125         return {};
126     }
127     return getLogFromRegistry(redfish::registries::base::header,
128                               redfish::registries::base::registry, index, args);
129 }
130 
131 /**
132  * @internal
133  * @brief Formats ResourceInUse message into JSON
134  *
135  * See header file for more information
136  * @endinternal
137  */
138 nlohmann::json resourceInUse(void)
139 {
140     return getLog(redfish::registries::base::Index::resourceInUse, {});
141 }
142 
143 void resourceInUse(crow::Response& res)
144 {
145     res.result(boost::beast::http::status::service_unavailable);
146     addMessageToErrorJson(res.jsonValue, resourceInUse());
147 }
148 
149 /**
150  * @internal
151  * @brief Formats MalformedJSON message into JSON
152  *
153  * See header file for more information
154  * @endinternal
155  */
156 nlohmann::json malformedJSON(void)
157 {
158     return getLog(redfish::registries::base::Index::malformedJSON, {});
159 }
160 
161 void malformedJSON(crow::Response& res)
162 {
163     res.result(boost::beast::http::status::bad_request);
164     addMessageToErrorJson(res.jsonValue, malformedJSON());
165 }
166 
167 /**
168  * @internal
169  * @brief Formats ResourceMissingAtURI message into JSON
170  *
171  * See header file for more information
172  * @endinternal
173  */
174 nlohmann::json resourceMissingAtURI(const boost::urls::url_view& arg1)
175 {
176     std::array<std::string_view, 1> args{
177         std::string_view{arg1.data(), arg1.size()}};
178     return getLog(redfish::registries::base::Index::resourceMissingAtURI, args);
179 }
180 
181 void resourceMissingAtURI(crow::Response& res,
182                           const boost::urls::url_view& arg1)
183 {
184     res.result(boost::beast::http::status::bad_request);
185     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
186 }
187 
188 /**
189  * @internal
190  * @brief Formats ActionParameterValueFormatError message into JSON
191  *
192  * See header file for more information
193  * @endinternal
194  */
195 nlohmann::json actionParameterValueFormatError(std::string_view arg1,
196                                                std::string_view arg2,
197                                                std::string_view arg3)
198 {
199     return getLog(
200         redfish::registries::base::Index::actionParameterValueFormatError,
201         std::to_array({arg1, arg2, arg3}));
202 }
203 
204 void actionParameterValueFormatError(crow::Response& res, std::string_view arg1,
205                                      std::string_view arg2,
206                                      std::string_view arg3)
207 {
208     res.result(boost::beast::http::status::bad_request);
209     addMessageToErrorJson(res.jsonValue,
210                           actionParameterValueFormatError(arg1, arg2, arg3));
211 }
212 
213 /**
214  * @internal
215  * @brief Formats InternalError message into JSON
216  *
217  * See header file for more information
218  * @endinternal
219  */
220 nlohmann::json internalError(void)
221 {
222     return getLog(redfish::registries::base::Index::internalError, {});
223 }
224 
225 void internalError(crow::Response& res, const bmcweb::source_location location)
226 {
227     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
228                         << location.line() << ":" << location.column() << ") `"
229                         << location.function_name() << "`: ";
230     res.result(boost::beast::http::status::internal_server_error);
231     addMessageToErrorJson(res.jsonValue, internalError());
232 }
233 
234 /**
235  * @internal
236  * @brief Formats UnrecognizedRequestBody message into JSON
237  *
238  * See header file for more information
239  * @endinternal
240  */
241 nlohmann::json unrecognizedRequestBody(void)
242 {
243     return getLog(redfish::registries::base::Index::unrecognizedRequestBody,
244                   {});
245 }
246 
247 void unrecognizedRequestBody(crow::Response& res)
248 {
249     res.result(boost::beast::http::status::bad_request);
250     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
251 }
252 
253 /**
254  * @internal
255  * @brief Formats ResourceAtUriUnauthorized message into JSON
256  *
257  * See header file for more information
258  * @endinternal
259  */
260 nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1,
261                                          std::string_view arg2)
262 {
263     return getLog(
264         redfish::registries::base::Index::resourceAtUriUnauthorized,
265         std::to_array({std::string_view{arg1.data(), arg1.size()}, arg2}));
266 }
267 
268 void resourceAtUriUnauthorized(crow::Response& res,
269                                const boost::urls::url_view& arg1,
270                                std::string_view arg2)
271 {
272     res.result(boost::beast::http::status::unauthorized);
273     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
274 }
275 
276 /**
277  * @internal
278  * @brief Formats ActionParameterUnknown message into JSON
279  *
280  * See header file for more information
281  * @endinternal
282  */
283 nlohmann::json actionParameterUnknown(std::string_view arg1,
284                                       std::string_view arg2)
285 {
286     return getLog(redfish::registries::base::Index::actionParameterUnknown,
287                   std::to_array({arg1, arg2}));
288 }
289 
290 void actionParameterUnknown(crow::Response& res, std::string_view arg1,
291                             std::string_view arg2)
292 {
293     res.result(boost::beast::http::status::bad_request);
294     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
295 }
296 
297 /**
298  * @internal
299  * @brief Formats ResourceCannotBeDeleted message into JSON
300  *
301  * See header file for more information
302  * @endinternal
303  */
304 nlohmann::json resourceCannotBeDeleted(void)
305 {
306     return getLog(redfish::registries::base::Index::resourceCannotBeDeleted,
307                   {});
308 }
309 
310 void resourceCannotBeDeleted(crow::Response& res)
311 {
312     res.result(boost::beast::http::status::forbidden);
313     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
314 }
315 
316 /**
317  * @internal
318  * @brief Formats PropertyDuplicate message into JSON
319  *
320  * See header file for more information
321  * @endinternal
322  */
323 nlohmann::json propertyDuplicate(std::string_view arg1)
324 {
325     return getLog(redfish::registries::base::Index::propertyDuplicate,
326                   std::to_array({arg1}));
327 }
328 
329 void propertyDuplicate(crow::Response& res, std::string_view arg1)
330 {
331     res.result(boost::beast::http::status::bad_request);
332     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
333 }
334 
335 /**
336  * @internal
337  * @brief Formats ServiceTemporarilyUnavailable message into JSON
338  *
339  * See header file for more information
340  * @endinternal
341  */
342 nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
343 {
344     return getLog(
345         redfish::registries::base::Index::serviceTemporarilyUnavailable,
346         std::to_array({arg1}));
347 }
348 
349 void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
350 {
351     res.addHeader(boost::beast::http::field::retry_after, arg1);
352     res.result(boost::beast::http::status::service_unavailable);
353     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
354 }
355 
356 /**
357  * @internal
358  * @brief Formats ResourceAlreadyExists message into JSON
359  *
360  * See header file for more information
361  * @endinternal
362  */
363 nlohmann::json resourceAlreadyExists(std::string_view arg1,
364                                      std::string_view arg2,
365                                      std::string_view arg3)
366 {
367     return getLog(redfish::registries::base::Index::resourceAlreadyExists,
368                   std::to_array({arg1, arg2, arg3}));
369 }
370 
371 void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
372                            std::string_view arg2, std::string_view arg3)
373 {
374     res.result(boost::beast::http::status::bad_request);
375     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
376                      arg2);
377 }
378 
379 /**
380  * @internal
381  * @brief Formats AccountForSessionNoLongerExists message into JSON
382  *
383  * See header file for more information
384  * @endinternal
385  */
386 nlohmann::json accountForSessionNoLongerExists(void)
387 {
388     return getLog(
389         redfish::registries::base::Index::accountForSessionNoLongerExists, {});
390 }
391 
392 void accountForSessionNoLongerExists(crow::Response& res)
393 {
394     res.result(boost::beast::http::status::forbidden);
395     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
396 }
397 
398 /**
399  * @internal
400  * @brief Formats CreateFailedMissingReqProperties message into JSON
401  *
402  * See header file for more information
403  * @endinternal
404  */
405 nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
406 {
407     return getLog(
408         redfish::registries::base::Index::createFailedMissingReqProperties,
409         std::to_array({arg1}));
410 }
411 
412 void createFailedMissingReqProperties(crow::Response& res,
413                                       std::string_view arg1)
414 {
415     res.result(boost::beast::http::status::bad_request);
416     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
417                      arg1);
418 }
419 
420 /**
421  * @internal
422  * @brief Formats PropertyValueFormatError message into JSON for the specified
423  * property
424  *
425  * See header file for more information
426  * @endinternal
427  */
428 nlohmann::json propertyValueFormatError(std::string_view arg1,
429                                         std::string_view arg2)
430 {
431     return getLog(redfish::registries::base::Index::propertyValueFormatError,
432                   std::to_array({arg1, arg2}));
433 }
434 
435 void propertyValueFormatError(crow::Response& res, std::string_view arg1,
436                               std::string_view arg2)
437 {
438     res.result(boost::beast::http::status::bad_request);
439     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
440 }
441 
442 /**
443  * @internal
444  * @brief Formats PropertyValueNotInList message into JSON for the specified
445  * property
446  *
447  * See header file for more information
448  * @endinternal
449  */
450 nlohmann::json propertyValueNotInList(std::string_view arg1,
451                                       std::string_view arg2)
452 {
453     return getLog(redfish::registries::base::Index::propertyValueNotInList,
454                   std::to_array({arg1, arg2}));
455 }
456 
457 void propertyValueNotInList(crow::Response& res, std::string_view arg1,
458                             std::string_view arg2)
459 {
460     res.result(boost::beast::http::status::bad_request);
461     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
462 }
463 
464 /**
465  * @internal
466  * @brief Formats PropertyValueOutOfRange message into JSON
467  *
468  * See header file for more information
469  * @endinternal
470  */
471 nlohmann::json propertyValueOutOfRange(std::string_view arg1,
472                                        std::string_view arg2)
473 {
474     return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
475                   std::to_array({arg1, arg2}));
476 }
477 
478 void propertyValueOutOfRange(crow::Response& res, std::string_view arg1,
479                              std::string_view arg2)
480 {
481     res.result(boost::beast::http::status::bad_request);
482     addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2));
483 }
484 
485 /**
486  * @internal
487  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
488  *
489  * See header file for more information
490  * @endinternal
491  */
492 nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1)
493 {
494     std::string_view arg1str{arg1.data(), arg1.size()};
495     return getLog(
496         redfish::registries::base::Index::resourceAtUriInUnknownFormat,
497         std::to_array({arg1str}));
498 }
499 
500 void resourceAtUriInUnknownFormat(crow::Response& res,
501                                   const boost::urls::url_view& arg1)
502 {
503     res.result(boost::beast::http::status::bad_request);
504     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
505 }
506 
507 /**
508  * @internal
509  * @brief Formats ServiceDisabled message into JSON
510  *
511  * See header file for more information
512  * @endinternal
513  */
514 nlohmann::json serviceDisabled(std::string_view arg1)
515 {
516     return getLog(redfish::registries::base::Index::serviceDisabled,
517                   std::to_array({arg1}));
518 }
519 
520 void serviceDisabled(crow::Response& res, std::string_view arg1)
521 {
522     res.result(boost::beast::http::status::service_unavailable);
523     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
524 }
525 
526 /**
527  * @internal
528  * @brief Formats ServiceInUnknownState message into JSON
529  *
530  * See header file for more information
531  * @endinternal
532  */
533 nlohmann::json serviceInUnknownState(void)
534 {
535     return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
536 }
537 
538 void serviceInUnknownState(crow::Response& res)
539 {
540     res.result(boost::beast::http::status::service_unavailable);
541     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
542 }
543 
544 /**
545  * @internal
546  * @brief Formats EventSubscriptionLimitExceeded message into JSON
547  *
548  * See header file for more information
549  * @endinternal
550  */
551 nlohmann::json eventSubscriptionLimitExceeded(void)
552 {
553     return getLog(
554         redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
555 }
556 
557 void eventSubscriptionLimitExceeded(crow::Response& res)
558 {
559     res.result(boost::beast::http::status::service_unavailable);
560     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
561 }
562 
563 /**
564  * @internal
565  * @brief Formats ActionParameterMissing message into JSON
566  *
567  * See header file for more information
568  * @endinternal
569  */
570 nlohmann::json actionParameterMissing(std::string_view arg1,
571                                       std::string_view arg2)
572 {
573     return getLog(redfish::registries::base::Index::actionParameterMissing,
574                   std::to_array({arg1, arg2}));
575 }
576 
577 void actionParameterMissing(crow::Response& res, std::string_view arg1,
578                             std::string_view arg2)
579 {
580     res.result(boost::beast::http::status::bad_request);
581     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
582 }
583 
584 /**
585  * @internal
586  * @brief Formats StringValueTooLong message into JSON
587  *
588  * See header file for more information
589  * @endinternal
590  */
591 nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
592 {
593     std::string arg2String = std::to_string(arg2);
594     return getLog(redfish::registries::base::Index::stringValueTooLong,
595                   std::to_array({arg1, std::string_view(arg2String)}));
596 }
597 
598 void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
599 {
600     res.result(boost::beast::http::status::bad_request);
601     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
602 }
603 
604 /**
605  * @internal
606  * @brief Formats SessionTerminated message into JSON
607  *
608  * See header file for more information
609  * @endinternal
610  */
611 nlohmann::json sessionTerminated(void)
612 {
613     return getLog(redfish::registries::base::Index::sessionTerminated, {});
614 }
615 
616 void sessionTerminated(crow::Response& res)
617 {
618     res.result(boost::beast::http::status::ok);
619     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
620 }
621 
622 /**
623  * @internal
624  * @brief Formats SubscriptionTerminated message into JSON
625  *
626  * See header file for more information
627  * @endinternal
628  */
629 nlohmann::json subscriptionTerminated(void)
630 {
631     return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
632 }
633 
634 void subscriptionTerminated(crow::Response& res)
635 {
636     res.result(boost::beast::http::status::ok);
637     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
638 }
639 
640 /**
641  * @internal
642  * @brief Formats ResourceTypeIncompatible message into JSON
643  *
644  * See header file for more information
645  * @endinternal
646  */
647 nlohmann::json resourceTypeIncompatible(std::string_view arg1,
648                                         std::string_view arg2)
649 {
650     return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
651                   std::to_array({arg1, arg2}));
652 }
653 
654 void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
655                               std::string_view arg2)
656 {
657     res.result(boost::beast::http::status::bad_request);
658     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
659 }
660 
661 /**
662  * @internal
663  * @brief Formats ResetRequired message into JSON
664  *
665  * See header file for more information
666  * @endinternal
667  */
668 nlohmann::json resetRequired(const boost::urls::url_view& arg1,
669                              std::string_view arg2)
670 {
671     std::string_view arg1str(arg1.data(), arg1.size());
672     return getLog(redfish::registries::base::Index::resetRequired,
673                   std::to_array({arg1str, arg2}));
674 }
675 
676 void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
677                    std::string_view arg2)
678 {
679     res.result(boost::beast::http::status::bad_request);
680     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
681 }
682 
683 /**
684  * @internal
685  * @brief Formats ChassisPowerStateOnRequired message into JSON
686  *
687  * See header file for more information
688  * @endinternal
689  */
690 nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
691 {
692     return getLog(redfish::registries::base::Index::resetRequired,
693                   std::to_array({arg1}));
694 }
695 
696 void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
697 {
698     res.result(boost::beast::http::status::bad_request);
699     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
700 }
701 
702 /**
703  * @internal
704  * @brief Formats ChassisPowerStateOffRequired message into JSON
705  *
706  * See header file for more information
707  * @endinternal
708  */
709 nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
710 {
711     return getLog(
712         redfish::registries::base::Index::chassisPowerStateOffRequired,
713         std::to_array({arg1}));
714 }
715 
716 void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1)
717 {
718     res.result(boost::beast::http::status::bad_request);
719     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
720 }
721 
722 /**
723  * @internal
724  * @brief Formats PropertyValueConflict message into JSON
725  *
726  * See header file for more information
727  * @endinternal
728  */
729 nlohmann::json propertyValueConflict(std::string_view arg1,
730                                      std::string_view arg2)
731 {
732     return getLog(redfish::registries::base::Index::propertyValueConflict,
733                   std::to_array({arg1, arg2}));
734 }
735 
736 void propertyValueConflict(crow::Response& res, std::string_view arg1,
737                            std::string_view arg2)
738 {
739     res.result(boost::beast::http::status::bad_request);
740     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
741 }
742 
743 /**
744  * @internal
745  * @brief Formats PropertyValueResourceConflict message into JSON
746  *
747  * See header file for more information
748  * @endinternal
749  */
750 nlohmann::json propertyValueResourceConflict(std::string_view arg1,
751                                              std::string_view arg2,
752                                              const boost::urls::url_view& arg3)
753 {
754     return getLog(
755         redfish::registries::base::Index::propertyValueResourceConflict,
756         std::to_array(
757             {arg1, arg2, std::string_view{arg3.data(), arg3.size()}}));
758 }
759 
760 void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
761                                    std::string_view arg2,
762                                    const boost::urls::url_view& arg3)
763 {
764     res.result(boost::beast::http::status::conflict);
765     addMessageToErrorJson(res.jsonValue,
766                           propertyValueResourceConflict(arg1, arg2, arg3));
767 }
768 
769 /**
770  * @internal
771  * @brief Formats PropertyValueExternalConflict message into JSON
772  *
773  * See header file for more information
774  * @endinternal
775  */
776 nlohmann::json propertyValueExternalConflict(std::string_view arg1,
777                                              std::string_view arg2)
778 {
779     return getLog(
780         redfish::registries::base::Index::propertyValueExternalConflict,
781         std::to_array({arg1, arg2}));
782 }
783 
784 void propertyValueExternalConflict(crow::Response& res, std::string_view arg1,
785                                    std::string_view arg2)
786 {
787     res.result(boost::beast::http::status::conflict);
788     addMessageToErrorJson(res.jsonValue,
789                           propertyValueExternalConflict(arg1, arg2));
790 }
791 
792 /**
793  * @internal
794  * @brief Formats PropertyValueIncorrect message into JSON
795  *
796  * See header file for more information
797  * @endinternal
798  */
799 nlohmann::json propertyValueIncorrect(std::string_view arg1,
800                                       std::string_view arg2)
801 {
802     return getLog(redfish::registries::base::Index::propertyValueIncorrect,
803                   std::to_array({arg1, arg2}));
804 }
805 
806 void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
807                             std::string_view arg2)
808 {
809     res.result(boost::beast::http::status::bad_request);
810     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
811 }
812 
813 /**
814  * @internal
815  * @brief Formats ResourceCreationConflict message into JSON
816  *
817  * See header file for more information
818  * @endinternal
819  */
820 nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1)
821 {
822     std::string_view arg1str(arg1.data(), arg1.size());
823     return getLog(redfish::registries::base::Index::resourceCreationConflict,
824                   std::to_array({arg1str}));
825 }
826 
827 void resourceCreationConflict(crow::Response& res,
828                               const boost::urls::url_view& arg1)
829 {
830     res.result(boost::beast::http::status::bad_request);
831     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
832 }
833 
834 /**
835  * @internal
836  * @brief Formats MaximumErrorsExceeded message into JSON
837  *
838  * See header file for more information
839  * @endinternal
840  */
841 nlohmann::json maximumErrorsExceeded(void)
842 {
843     return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
844 }
845 
846 void maximumErrorsExceeded(crow::Response& res)
847 {
848     res.result(boost::beast::http::status::internal_server_error);
849     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
850 }
851 
852 /**
853  * @internal
854  * @brief Formats PreconditionFailed message into JSON
855  *
856  * See header file for more information
857  * @endinternal
858  */
859 nlohmann::json preconditionFailed(void)
860 {
861     return getLog(redfish::registries::base::Index::preconditionFailed, {});
862 }
863 
864 void preconditionFailed(crow::Response& res)
865 {
866     res.result(boost::beast::http::status::precondition_failed);
867     addMessageToErrorJson(res.jsonValue, preconditionFailed());
868 }
869 
870 /**
871  * @internal
872  * @brief Formats PreconditionRequired message into JSON
873  *
874  * See header file for more information
875  * @endinternal
876  */
877 nlohmann::json preconditionRequired(void)
878 {
879     return getLog(redfish::registries::base::Index::preconditionRequired, {});
880 }
881 
882 void preconditionRequired(crow::Response& res)
883 {
884     res.result(boost::beast::http::status::bad_request);
885     addMessageToErrorJson(res.jsonValue, preconditionRequired());
886 }
887 
888 /**
889  * @internal
890  * @brief Formats OperationFailed message into JSON
891  *
892  * See header file for more information
893  * @endinternal
894  */
895 nlohmann::json operationFailed(void)
896 {
897     return getLog(redfish::registries::base::Index::operationFailed, {});
898 }
899 
900 void operationFailed(crow::Response& res)
901 {
902     res.result(boost::beast::http::status::bad_gateway);
903     addMessageToErrorJson(res.jsonValue, operationFailed());
904 }
905 
906 /**
907  * @internal
908  * @brief Formats OperationTimeout message into JSON
909  *
910  * See header file for more information
911  * @endinternal
912  */
913 nlohmann::json operationTimeout(void)
914 {
915     return getLog(redfish::registries::base::Index::operationTimeout, {});
916 }
917 
918 void operationTimeout(crow::Response& res)
919 {
920     res.result(boost::beast::http::status::internal_server_error);
921     addMessageToErrorJson(res.jsonValue, operationTimeout());
922 }
923 
924 /**
925  * @internal
926  * @brief Formats PropertyValueTypeError message into JSON for the specified
927  * property
928  *
929  * See header file for more information
930  * @endinternal
931  */
932 nlohmann::json propertyValueTypeError(std::string_view arg1,
933                                       std::string_view arg2)
934 {
935     return getLog(redfish::registries::base::Index::propertyValueTypeError,
936                   std::to_array({arg1, arg2}));
937 }
938 
939 void propertyValueTypeError(crow::Response& res, std::string_view arg1,
940                             std::string_view arg2)
941 {
942     res.result(boost::beast::http::status::bad_request);
943     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
944 }
945 
946 /**
947  * @internal
948  * @brief Formats ResourceNotFound message into JSONd
949  *
950  * See header file for more information
951  * @endinternal
952  */
953 nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
954 {
955     return getLog(redfish::registries::base::Index::resourceNotFound,
956                   std::to_array({arg1, arg2}));
957 }
958 
959 void resourceNotFound(crow::Response& res, std::string_view arg1,
960                       std::string_view arg2)
961 {
962     res.result(boost::beast::http::status::not_found);
963     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
964 }
965 
966 /**
967  * @internal
968  * @brief Formats CouldNotEstablishConnection message into JSON
969  *
970  * See header file for more information
971  * @endinternal
972  */
973 nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1)
974 {
975     std::string_view arg1str(arg1.data(), arg1.size());
976     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
977                   std::to_array({arg1str}));
978 }
979 
980 void couldNotEstablishConnection(crow::Response& res,
981                                  const boost::urls::url_view& arg1)
982 {
983     res.result(boost::beast::http::status::not_found);
984     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
985 }
986 
987 /**
988  * @internal
989  * @brief Formats PropertyNotWritable message into JSON for the specified
990  * property
991  *
992  * See header file for more information
993  * @endinternal
994  */
995 nlohmann::json propertyNotWritable(std::string_view arg1)
996 {
997     return getLog(redfish::registries::base::Index::propertyNotWritable,
998                   std::to_array({arg1}));
999 }
1000 
1001 void propertyNotWritable(crow::Response& res, std::string_view arg1)
1002 {
1003     res.result(boost::beast::http::status::forbidden);
1004     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1005 }
1006 
1007 /**
1008  * @internal
1009  * @brief Formats QueryParameterValueTypeError message into JSON
1010  *
1011  * See header file for more information
1012  * @endinternal
1013  */
1014 nlohmann::json queryParameterValueTypeError(std::string_view arg1,
1015                                             std::string_view arg2)
1016 {
1017     return getLog(
1018         redfish::registries::base::Index::queryParameterValueTypeError,
1019         std::to_array({arg1, arg2}));
1020 }
1021 
1022 void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
1023                                   std::string_view arg2)
1024 {
1025     res.result(boost::beast::http::status::bad_request);
1026     addMessageToErrorJson(res.jsonValue,
1027                           queryParameterValueTypeError(arg1, arg2));
1028 }
1029 
1030 /**
1031  * @internal
1032  * @brief Formats ServiceShuttingDown message into JSON
1033  *
1034  * See header file for more information
1035  * @endinternal
1036  */
1037 nlohmann::json serviceShuttingDown(void)
1038 {
1039     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
1040 }
1041 
1042 void serviceShuttingDown(crow::Response& res)
1043 {
1044     res.result(boost::beast::http::status::service_unavailable);
1045     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1046 }
1047 
1048 /**
1049  * @internal
1050  * @brief Formats ActionParameterDuplicate message into JSON
1051  *
1052  * See header file for more information
1053  * @endinternal
1054  */
1055 nlohmann::json actionParameterDuplicate(std::string_view arg1,
1056                                         std::string_view arg2)
1057 {
1058     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
1059                   std::to_array({arg1, arg2}));
1060 }
1061 
1062 void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
1063                               std::string_view arg2)
1064 {
1065     res.result(boost::beast::http::status::bad_request);
1066     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1067 }
1068 
1069 /**
1070  * @internal
1071  * @brief Formats ActionParameterNotSupported message into JSON
1072  *
1073  * See header file for more information
1074  * @endinternal
1075  */
1076 nlohmann::json actionParameterNotSupported(std::string_view arg1,
1077                                            std::string_view arg2)
1078 {
1079     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
1080                   std::to_array({arg1, arg2}));
1081 }
1082 
1083 void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
1084                                  std::string_view arg2)
1085 {
1086     res.result(boost::beast::http::status::bad_request);
1087     addMessageToErrorJson(res.jsonValue,
1088                           actionParameterNotSupported(arg1, arg2));
1089 }
1090 
1091 /**
1092  * @internal
1093  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1094  *
1095  * See header file for more information
1096  * @endinternal
1097  */
1098 nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1,
1099                                             std::string_view arg2)
1100 {
1101     std::string_view arg1str(arg1.data(), arg1.size());
1102     return getLog(
1103         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
1104         std::to_array({arg1str, arg2}));
1105 }
1106 
1107 void sourceDoesNotSupportProtocol(crow::Response& res,
1108                                   const boost::urls::url_view& arg1,
1109                                   std::string_view arg2)
1110 {
1111     res.result(boost::beast::http::status::bad_request);
1112     addMessageToErrorJson(res.jsonValue,
1113                           sourceDoesNotSupportProtocol(arg1, arg2));
1114 }
1115 
1116 /**
1117  * @internal
1118  * @brief Formats AccountRemoved message into JSON
1119  *
1120  * See header file for more information
1121  * @endinternal
1122  */
1123 nlohmann::json accountRemoved(void)
1124 {
1125     return getLog(redfish::registries::base::Index::accountRemoved, {});
1126 }
1127 
1128 void accountRemoved(crow::Response& res)
1129 {
1130     res.result(boost::beast::http::status::ok);
1131     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1132 }
1133 
1134 /**
1135  * @internal
1136  * @brief Formats AccessDenied message into JSON
1137  *
1138  * See header file for more information
1139  * @endinternal
1140  */
1141 nlohmann::json accessDenied(const boost::urls::url_view& arg1)
1142 {
1143     std::string_view arg1str(arg1.data(), arg1.size());
1144     return getLog(redfish::registries::base::Index::accessDenied,
1145                   std::to_array({arg1str}));
1146 }
1147 
1148 void accessDenied(crow::Response& res, const boost::urls::url_view& arg1)
1149 {
1150     res.result(boost::beast::http::status::forbidden);
1151     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1152 }
1153 
1154 /**
1155  * @internal
1156  * @brief Formats QueryNotSupported message into JSON
1157  *
1158  * See header file for more information
1159  * @endinternal
1160  */
1161 nlohmann::json queryNotSupported(void)
1162 {
1163     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1164 }
1165 
1166 void queryNotSupported(crow::Response& res)
1167 {
1168     res.result(boost::beast::http::status::bad_request);
1169     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1170 }
1171 
1172 /**
1173  * @internal
1174  * @brief Formats CreateLimitReachedForResource message into JSON
1175  *
1176  * See header file for more information
1177  * @endinternal
1178  */
1179 nlohmann::json createLimitReachedForResource(void)
1180 {
1181     return getLog(
1182         redfish::registries::base::Index::createLimitReachedForResource, {});
1183 }
1184 
1185 void createLimitReachedForResource(crow::Response& res)
1186 {
1187     res.result(boost::beast::http::status::bad_request);
1188     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1189 }
1190 
1191 /**
1192  * @internal
1193  * @brief Formats GeneralError message into JSON
1194  *
1195  * See header file for more information
1196  * @endinternal
1197  */
1198 nlohmann::json generalError(void)
1199 {
1200     return getLog(redfish::registries::base::Index::generalError, {});
1201 }
1202 
1203 void generalError(crow::Response& res)
1204 {
1205     res.result(boost::beast::http::status::internal_server_error);
1206     addMessageToErrorJson(res.jsonValue, generalError());
1207 }
1208 
1209 /**
1210  * @internal
1211  * @brief Formats Success message into JSON
1212  *
1213  * See header file for more information
1214  * @endinternal
1215  */
1216 nlohmann::json success(void)
1217 {
1218     return getLog(redfish::registries::base::Index::success, {});
1219 }
1220 
1221 void success(crow::Response& res)
1222 {
1223     // don't set res.result here because success is the default and any
1224     // error should overwrite the default
1225     addMessageToJsonRoot(res.jsonValue, success());
1226 }
1227 
1228 /**
1229  * @internal
1230  * @brief Formats Created message into JSON
1231  *
1232  * See header file for more information
1233  * @endinternal
1234  */
1235 nlohmann::json created(void)
1236 {
1237     return getLog(redfish::registries::base::Index::created, {});
1238 }
1239 
1240 void created(crow::Response& res)
1241 {
1242     res.result(boost::beast::http::status::created);
1243     addMessageToJsonRoot(res.jsonValue, created());
1244 }
1245 
1246 /**
1247  * @internal
1248  * @brief Formats NoOperation message into JSON
1249  *
1250  * See header file for more information
1251  * @endinternal
1252  */
1253 nlohmann::json noOperation(void)
1254 {
1255     return getLog(redfish::registries::base::Index::noOperation, {});
1256 }
1257 
1258 void noOperation(crow::Response& res)
1259 {
1260     res.result(boost::beast::http::status::bad_request);
1261     addMessageToErrorJson(res.jsonValue, noOperation());
1262 }
1263 
1264 /**
1265  * @internal
1266  * @brief Formats PropertyUnknown message into JSON for the specified
1267  * property
1268  *
1269  * See header file for more information
1270  * @endinternal
1271  */
1272 nlohmann::json propertyUnknown(std::string_view arg1)
1273 {
1274     return getLog(redfish::registries::base::Index::propertyUnknown,
1275                   std::to_array({arg1}));
1276 }
1277 
1278 void propertyUnknown(crow::Response& res, std::string_view arg1)
1279 {
1280     res.result(boost::beast::http::status::bad_request);
1281     addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1));
1282 }
1283 
1284 /**
1285  * @internal
1286  * @brief Formats NoValidSession message into JSON
1287  *
1288  * See header file for more information
1289  * @endinternal
1290  */
1291 nlohmann::json noValidSession(void)
1292 {
1293     return getLog(redfish::registries::base::Index::noValidSession, {});
1294 }
1295 
1296 void noValidSession(crow::Response& res)
1297 {
1298     res.result(boost::beast::http::status::forbidden);
1299     addMessageToErrorJson(res.jsonValue, noValidSession());
1300 }
1301 
1302 /**
1303  * @internal
1304  * @brief Formats InvalidObject message into JSON
1305  *
1306  * See header file for more information
1307  * @endinternal
1308  */
1309 nlohmann::json invalidObject(const boost::urls::url_view& arg1)
1310 {
1311     std::string_view arg1str(arg1.data(), arg1.size());
1312     return getLog(redfish::registries::base::Index::invalidObject,
1313                   std::to_array({arg1str}));
1314 }
1315 
1316 void invalidObject(crow::Response& res, const boost::urls::url_view& arg1)
1317 {
1318     res.result(boost::beast::http::status::bad_request);
1319     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1320 }
1321 
1322 /**
1323  * @internal
1324  * @brief Formats ResourceInStandby message into JSON
1325  *
1326  * See header file for more information
1327  * @endinternal
1328  */
1329 nlohmann::json resourceInStandby(void)
1330 {
1331     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1332 }
1333 
1334 void resourceInStandby(crow::Response& res)
1335 {
1336     res.result(boost::beast::http::status::service_unavailable);
1337     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1338 }
1339 
1340 /**
1341  * @internal
1342  * @brief Formats ActionParameterValueTypeError message into JSON
1343  *
1344  * See header file for more information
1345  * @endinternal
1346  */
1347 nlohmann::json actionParameterValueTypeError(std::string_view arg1,
1348                                              std::string_view arg2,
1349                                              std::string_view arg3)
1350 {
1351     return getLog(
1352         redfish::registries::base::Index::actionParameterValueTypeError,
1353         std::to_array({arg1, arg2, arg3}));
1354 }
1355 
1356 void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
1357                                    std::string_view arg2, std::string_view arg3)
1358 {
1359     res.result(boost::beast::http::status::bad_request);
1360     addMessageToErrorJson(res.jsonValue,
1361                           actionParameterValueTypeError(arg1, arg2, arg3));
1362 }
1363 
1364 /**
1365  * @internal
1366  * @brief Formats SessionLimitExceeded message into JSON
1367  *
1368  * See header file for more information
1369  * @endinternal
1370  */
1371 nlohmann::json sessionLimitExceeded(void)
1372 {
1373     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1374 }
1375 
1376 void sessionLimitExceeded(crow::Response& res)
1377 {
1378     res.result(boost::beast::http::status::service_unavailable);
1379     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1380 }
1381 
1382 /**
1383  * @internal
1384  * @brief Formats ActionNotSupported message into JSON
1385  *
1386  * See header file for more information
1387  * @endinternal
1388  */
1389 nlohmann::json actionNotSupported(std::string_view arg1)
1390 {
1391     return getLog(redfish::registries::base::Index::actionNotSupported,
1392                   std::to_array({arg1}));
1393 }
1394 
1395 void actionNotSupported(crow::Response& res, std::string_view arg1)
1396 {
1397     res.result(boost::beast::http::status::bad_request);
1398     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1399 }
1400 
1401 /**
1402  * @internal
1403  * @brief Formats InvalidIndex message into JSON
1404  *
1405  * See header file for more information
1406  * @endinternal
1407  */
1408 nlohmann::json invalidIndex(int64_t arg1)
1409 {
1410     std::string arg1Str = std::to_string(arg1);
1411     return getLog(redfish::registries::base::Index::invalidIndex,
1412                   std::to_array<std::string_view>({arg1Str}));
1413 }
1414 
1415 void invalidIndex(crow::Response& res, int64_t arg1)
1416 {
1417     res.result(boost::beast::http::status::bad_request);
1418     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1419 }
1420 
1421 /**
1422  * @internal
1423  * @brief Formats EmptyJSON message into JSON
1424  *
1425  * See header file for more information
1426  * @endinternal
1427  */
1428 nlohmann::json emptyJSON(void)
1429 {
1430     return getLog(redfish::registries::base::Index::emptyJSON, {});
1431 }
1432 
1433 void emptyJSON(crow::Response& res)
1434 {
1435     res.result(boost::beast::http::status::bad_request);
1436     addMessageToErrorJson(res.jsonValue, emptyJSON());
1437 }
1438 
1439 /**
1440  * @internal
1441  * @brief Formats QueryNotSupportedOnResource message into JSON
1442  *
1443  * See header file for more information
1444  * @endinternal
1445  */
1446 nlohmann::json queryNotSupportedOnResource(void)
1447 {
1448     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1449                   {});
1450 }
1451 
1452 void queryNotSupportedOnResource(crow::Response& res)
1453 {
1454     res.result(boost::beast::http::status::bad_request);
1455     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1456 }
1457 
1458 /**
1459  * @internal
1460  * @brief Formats QueryNotSupportedOnOperation message into JSON
1461  *
1462  * See header file for more information
1463  * @endinternal
1464  */
1465 nlohmann::json queryNotSupportedOnOperation(void)
1466 {
1467     return getLog(
1468         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1469 }
1470 
1471 void queryNotSupportedOnOperation(crow::Response& res)
1472 {
1473     res.result(boost::beast::http::status::bad_request);
1474     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1475 }
1476 
1477 /**
1478  * @internal
1479  * @brief Formats QueryCombinationInvalid message into JSON
1480  *
1481  * See header file for more information
1482  * @endinternal
1483  */
1484 nlohmann::json queryCombinationInvalid(void)
1485 {
1486     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1487                   {});
1488 }
1489 
1490 void queryCombinationInvalid(crow::Response& res)
1491 {
1492     res.result(boost::beast::http::status::bad_request);
1493     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1494 }
1495 
1496 /**
1497  * @internal
1498  * @brief Formats InsufficientPrivilege message into JSON
1499  *
1500  * See header file for more information
1501  * @endinternal
1502  */
1503 nlohmann::json insufficientPrivilege(void)
1504 {
1505     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1506 }
1507 
1508 void insufficientPrivilege(crow::Response& res)
1509 {
1510     res.result(boost::beast::http::status::forbidden);
1511     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1512 }
1513 
1514 /**
1515  * @internal
1516  * @brief Formats PropertyValueModified message into JSON
1517  *
1518  * See header file for more information
1519  * @endinternal
1520  */
1521 nlohmann::json propertyValueModified(std::string_view arg1,
1522                                      std::string_view arg2)
1523 {
1524     return getLog(redfish::registries::base::Index::propertyValueModified,
1525                   std::to_array({arg1, arg2}));
1526 }
1527 
1528 void propertyValueModified(crow::Response& res, std::string_view arg1,
1529                            std::string_view arg2)
1530 {
1531     res.result(boost::beast::http::status::ok);
1532     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1533 }
1534 
1535 /**
1536  * @internal
1537  * @brief Formats AccountNotModified message into JSON
1538  *
1539  * See header file for more information
1540  * @endinternal
1541  */
1542 nlohmann::json accountNotModified(void)
1543 {
1544     return getLog(redfish::registries::base::Index::accountNotModified, {});
1545 }
1546 
1547 void accountNotModified(crow::Response& res)
1548 {
1549     res.result(boost::beast::http::status::bad_request);
1550     addMessageToErrorJson(res.jsonValue, accountNotModified());
1551 }
1552 
1553 /**
1554  * @internal
1555  * @brief Formats QueryParameterValueFormatError message into JSON
1556  *
1557  * See header file for more information
1558  * @endinternal
1559  */
1560 nlohmann::json queryParameterValueFormatError(std::string_view arg1,
1561                                               std::string_view arg2)
1562 {
1563     return getLog(
1564         redfish::registries::base::Index::queryParameterValueFormatError,
1565         std::to_array({arg1, arg2}));
1566 }
1567 
1568 void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
1569                                     std::string_view arg2)
1570 {
1571     res.result(boost::beast::http::status::bad_request);
1572     addMessageToErrorJson(res.jsonValue,
1573                           queryParameterValueFormatError(arg1, arg2));
1574 }
1575 
1576 /**
1577  * @internal
1578  * @brief Formats PropertyMissing message into JSON for the specified
1579  * property
1580  *
1581  * See header file for more information
1582  * @endinternal
1583  */
1584 nlohmann::json propertyMissing(std::string_view arg1)
1585 {
1586     return getLog(redfish::registries::base::Index::propertyMissing,
1587                   std::to_array({arg1}));
1588 }
1589 
1590 void propertyMissing(crow::Response& res, std::string_view arg1)
1591 {
1592     res.result(boost::beast::http::status::bad_request);
1593     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1594 }
1595 
1596 /**
1597  * @internal
1598  * @brief Formats ResourceExhaustion message into JSON
1599  *
1600  * See header file for more information
1601  * @endinternal
1602  */
1603 nlohmann::json resourceExhaustion(std::string_view arg1)
1604 {
1605     return getLog(redfish::registries::base::Index::resourceExhaustion,
1606                   std::to_array({arg1}));
1607 }
1608 
1609 void resourceExhaustion(crow::Response& res, std::string_view arg1)
1610 {
1611     res.result(boost::beast::http::status::service_unavailable);
1612     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1613 }
1614 
1615 /**
1616  * @internal
1617  * @brief Formats AccountModified message into JSON
1618  *
1619  * See header file for more information
1620  * @endinternal
1621  */
1622 nlohmann::json accountModified(void)
1623 {
1624     return getLog(redfish::registries::base::Index::accountModified, {});
1625 }
1626 
1627 void accountModified(crow::Response& res)
1628 {
1629     res.result(boost::beast::http::status::ok);
1630     addMessageToErrorJson(res.jsonValue, accountModified());
1631 }
1632 
1633 /**
1634  * @internal
1635  * @brief Formats QueryParameterOutOfRange message into JSON
1636  *
1637  * See header file for more information
1638  * @endinternal
1639  */
1640 nlohmann::json queryParameterOutOfRange(std::string_view arg1,
1641                                         std::string_view arg2,
1642                                         std::string_view arg3)
1643 {
1644     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
1645                   std::to_array({arg1, arg2, arg3}));
1646 }
1647 
1648 void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
1649                               std::string_view arg2, std::string_view arg3)
1650 {
1651     res.result(boost::beast::http::status::bad_request);
1652     addMessageToErrorJson(res.jsonValue,
1653                           queryParameterOutOfRange(arg1, arg2, arg3));
1654 }
1655 
1656 nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1)
1657 {
1658     std::string_view arg1str(arg1.data(), arg1.size());
1659     return getLog(redfish::registries::base::Index::passwordChangeRequired,
1660                   std::to_array({arg1str}));
1661 }
1662 
1663 /**
1664  * @internal
1665  * @brief Formats PasswordChangeRequired message into JSON
1666  *
1667  * See header file for more information
1668  * @endinternal
1669  */
1670 void passwordChangeRequired(crow::Response& res,
1671                             const boost::urls::url_view& arg1)
1672 {
1673     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
1674 }
1675 
1676 void invalidUpload(crow::Response& res, std::string_view arg1,
1677                    std::string_view arg2)
1678 {
1679     res.result(boost::beast::http::status::bad_request);
1680     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
1681 }
1682 
1683 /**
1684  * @internal
1685  * @brief Formats InsufficientStorage message into JSON
1686  *
1687  * See header file for more information
1688  * @endinternal
1689  */
1690 nlohmann::json insufficientStorage()
1691 {
1692     return getLog(redfish::registries::base::Index::insufficientStorage, {});
1693 }
1694 
1695 void insufficientStorage(crow::Response& res)
1696 {
1697     res.result(boost::beast::http::status::insufficient_storage);
1698     addMessageToErrorJson(res.jsonValue, insufficientStorage());
1699 }
1700 
1701 /**
1702  * @internal
1703  * @brief Formats Invalid File message into JSON
1704  *
1705  * See header file for more information
1706  * @endinternal
1707  */
1708 nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
1709 {
1710     std::string msg = "Invalid file uploaded to ";
1711     msg += arg1;
1712     msg += ": ";
1713     msg += arg2;
1714     msg += ".";
1715     return nlohmann::json{
1716         {"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"},
1717         {"MessageId", "OpenBMC.0.2.InvalidUpload"},
1718         {"Message", std::move(msg)},
1719         {"MessageArgs", {arg1, arg2}},
1720         {"MessageSeverity", "Warning"},
1721         {"Resolution", "None."}};
1722 }
1723 
1724 } // namespace messages
1725 
1726 } // namespace redfish
1727