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