xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision e2616cc5d2093715bbbb5a7ff6aa0c86b2c466d4)
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(std::string_view arg1,
482                                         std::string_view arg2)
483 {
484     return getLog(redfish::registries::base::Index::propertyValueFormatError,
485                   std::to_array({arg1, arg2}));
486 }
487 
488 void propertyValueFormatError(crow::Response& res, std::string_view arg1,
489                               std::string_view arg2)
490 {
491     res.result(boost::beast::http::status::bad_request);
492     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
493 }
494 
495 /**
496  * @internal
497  * @brief Formats PropertyValueNotInList message into JSON for the specified
498  * property
499  *
500  * See header file for more information
501  * @endinternal
502  */
503 
504 nlohmann::json propertyValueNotInList(const nlohmann::json& arg1,
505                                       std::string_view arg2)
506 {
507     std::string arg1Str = arg1.dump(-1, ' ', true,
508                                     nlohmann::json::error_handler_t::replace);
509     return getLog(redfish::registries::base::Index::propertyValueNotInList,
510                   std::to_array<std::string_view>({arg1Str, arg2}));
511 }
512 
513 void propertyValueNotInList(crow::Response& res, const nlohmann::json& arg1,
514                             std::string_view arg2)
515 {
516     res.result(boost::beast::http::status::bad_request);
517     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
518 }
519 
520 /**
521  * @internal
522  * @brief Formats PropertyValueOutOfRange message into JSON
523  *
524  * See header file for more information
525  * @endinternal
526  */
527 nlohmann::json propertyValueOutOfRange(std::string_view arg1,
528                                        std::string_view arg2)
529 {
530     return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
531                   std::to_array({arg1, arg2}));
532 }
533 
534 void propertyValueOutOfRange(crow::Response& res, std::string_view arg1,
535                              std::string_view arg2)
536 {
537     res.result(boost::beast::http::status::bad_request);
538     addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2));
539 }
540 
541 /**
542  * @internal
543  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
544  *
545  * See header file for more information
546  * @endinternal
547  */
548 nlohmann::json resourceAtUriInUnknownFormat(boost::urls::url_view arg1)
549 {
550     return getLog(
551         redfish::registries::base::Index::resourceAtUriInUnknownFormat,
552         std::to_array<std::string_view>({arg1.buffer()}));
553 }
554 
555 void resourceAtUriInUnknownFormat(crow::Response& res,
556                                   boost::urls::url_view arg1)
557 {
558     res.result(boost::beast::http::status::bad_request);
559     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
560 }
561 
562 /**
563  * @internal
564  * @brief Formats ServiceDisabled message into JSON
565  *
566  * See header file for more information
567  * @endinternal
568  */
569 nlohmann::json serviceDisabled(std::string_view arg1)
570 {
571     return getLog(redfish::registries::base::Index::serviceDisabled,
572                   std::to_array({arg1}));
573 }
574 
575 void serviceDisabled(crow::Response& res, std::string_view arg1)
576 {
577     res.result(boost::beast::http::status::service_unavailable);
578     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
579 }
580 
581 /**
582  * @internal
583  * @brief Formats ServiceInUnknownState message into JSON
584  *
585  * See header file for more information
586  * @endinternal
587  */
588 nlohmann::json serviceInUnknownState(void)
589 {
590     return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
591 }
592 
593 void serviceInUnknownState(crow::Response& res)
594 {
595     res.result(boost::beast::http::status::service_unavailable);
596     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
597 }
598 
599 /**
600  * @internal
601  * @brief Formats EventSubscriptionLimitExceeded message into JSON
602  *
603  * See header file for more information
604  * @endinternal
605  */
606 nlohmann::json eventSubscriptionLimitExceeded(void)
607 {
608     return getLog(
609         redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
610 }
611 
612 void eventSubscriptionLimitExceeded(crow::Response& res)
613 {
614     res.result(boost::beast::http::status::service_unavailable);
615     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
616 }
617 
618 /**
619  * @internal
620  * @brief Formats ActionParameterMissing message into JSON
621  *
622  * See header file for more information
623  * @endinternal
624  */
625 nlohmann::json actionParameterMissing(std::string_view arg1,
626                                       std::string_view arg2)
627 {
628     return getLog(redfish::registries::base::Index::actionParameterMissing,
629                   std::to_array({arg1, arg2}));
630 }
631 
632 void actionParameterMissing(crow::Response& res, std::string_view arg1,
633                             std::string_view arg2)
634 {
635     res.result(boost::beast::http::status::bad_request);
636     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
637 }
638 
639 /**
640  * @internal
641  * @brief Formats StringValueTooLong message into JSON
642  *
643  * See header file for more information
644  * @endinternal
645  */
646 nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
647 {
648     std::string arg2String = std::to_string(arg2);
649     return getLog(redfish::registries::base::Index::stringValueTooLong,
650                   std::to_array({arg1, std::string_view(arg2String)}));
651 }
652 
653 void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
654 {
655     res.result(boost::beast::http::status::bad_request);
656     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
657 }
658 
659 /**
660  * @internal
661  * @brief Formats SessionTerminated message into JSON
662  *
663  * See header file for more information
664  * @endinternal
665  */
666 nlohmann::json sessionTerminated(void)
667 {
668     return getLog(redfish::registries::base::Index::sessionTerminated, {});
669 }
670 
671 void sessionTerminated(crow::Response& res)
672 {
673     res.result(boost::beast::http::status::ok);
674     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
675 }
676 
677 /**
678  * @internal
679  * @brief Formats SubscriptionTerminated message into JSON
680  *
681  * See header file for more information
682  * @endinternal
683  */
684 nlohmann::json subscriptionTerminated(void)
685 {
686     return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
687 }
688 
689 void subscriptionTerminated(crow::Response& res)
690 {
691     res.result(boost::beast::http::status::ok);
692     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
693 }
694 
695 /**
696  * @internal
697  * @brief Formats ResourceTypeIncompatible message into JSON
698  *
699  * See header file for more information
700  * @endinternal
701  */
702 nlohmann::json resourceTypeIncompatible(std::string_view arg1,
703                                         std::string_view arg2)
704 {
705     return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
706                   std::to_array({arg1, arg2}));
707 }
708 
709 void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
710                               std::string_view arg2)
711 {
712     res.result(boost::beast::http::status::bad_request);
713     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
714 }
715 
716 /**
717  * @internal
718  * @brief Formats ResetRequired message into JSON
719  *
720  * See header file for more information
721  * @endinternal
722  */
723 nlohmann::json resetRequired(boost::urls::url_view arg1, std::string_view arg2)
724 {
725     return getLog(redfish::registries::base::Index::resetRequired,
726                   std::to_array<std::string_view>({arg1.buffer(), arg2}));
727 }
728 
729 void resetRequired(crow::Response& res, boost::urls::url_view arg1,
730                    std::string_view arg2)
731 {
732     res.result(boost::beast::http::status::bad_request);
733     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
734 }
735 
736 /**
737  * @internal
738  * @brief Formats ChassisPowerStateOnRequired message into JSON
739  *
740  * See header file for more information
741  * @endinternal
742  */
743 nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
744 {
745     return getLog(redfish::registries::base::Index::resetRequired,
746                   std::to_array({arg1}));
747 }
748 
749 void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
750 {
751     res.result(boost::beast::http::status::bad_request);
752     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
753 }
754 
755 /**
756  * @internal
757  * @brief Formats ChassisPowerStateOffRequired message into JSON
758  *
759  * See header file for more information
760  * @endinternal
761  */
762 nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
763 {
764     return getLog(
765         redfish::registries::base::Index::chassisPowerStateOffRequired,
766         std::to_array({arg1}));
767 }
768 
769 void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1)
770 {
771     res.result(boost::beast::http::status::bad_request);
772     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
773 }
774 
775 /**
776  * @internal
777  * @brief Formats PropertyValueConflict message into JSON
778  *
779  * See header file for more information
780  * @endinternal
781  */
782 nlohmann::json propertyValueConflict(std::string_view arg1,
783                                      std::string_view arg2)
784 {
785     return getLog(redfish::registries::base::Index::propertyValueConflict,
786                   std::to_array({arg1, arg2}));
787 }
788 
789 void propertyValueConflict(crow::Response& res, std::string_view arg1,
790                            std::string_view arg2)
791 {
792     res.result(boost::beast::http::status::bad_request);
793     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
794 }
795 
796 /**
797  * @internal
798  * @brief Formats PropertyValueResourceConflict message into JSON
799  *
800  * See header file for more information
801  * @endinternal
802  */
803 nlohmann::json propertyValueResourceConflict(std::string_view arg1,
804                                              std::string_view arg2,
805                                              boost::urls::url_view arg3)
806 {
807     return getLog(
808         redfish::registries::base::Index::propertyValueResourceConflict,
809         std::to_array<std::string_view>({arg1, arg2, arg3.buffer()}));
810 }
811 
812 void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
813                                    std::string_view arg2,
814                                    boost::urls::url_view arg3)
815 {
816     res.result(boost::beast::http::status::conflict);
817     addMessageToErrorJson(res.jsonValue,
818                           propertyValueResourceConflict(arg1, arg2, arg3));
819 }
820 
821 /**
822  * @internal
823  * @brief Formats PropertyValueExternalConflict message into JSON
824  *
825  * See header file for more information
826  * @endinternal
827  */
828 nlohmann::json propertyValueExternalConflict(std::string_view arg1,
829                                              std::string_view arg2)
830 {
831     return getLog(
832         redfish::registries::base::Index::propertyValueExternalConflict,
833         std::to_array({arg1, arg2}));
834 }
835 
836 void propertyValueExternalConflict(crow::Response& res, std::string_view arg1,
837                                    std::string_view arg2)
838 {
839     res.result(boost::beast::http::status::conflict);
840     addMessageToErrorJson(res.jsonValue,
841                           propertyValueExternalConflict(arg1, arg2));
842 }
843 
844 /**
845  * @internal
846  * @brief Formats PropertyValueIncorrect message into JSON
847  *
848  * See header file for more information
849  * @endinternal
850  */
851 nlohmann::json propertyValueIncorrect(std::string_view arg1,
852                                       std::string_view arg2)
853 {
854     return getLog(redfish::registries::base::Index::propertyValueIncorrect,
855                   std::to_array({arg1, arg2}));
856 }
857 
858 void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
859                             std::string_view arg2)
860 {
861     res.result(boost::beast::http::status::bad_request);
862     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
863 }
864 
865 /**
866  * @internal
867  * @brief Formats ResourceCreationConflict message into JSON
868  *
869  * See header file for more information
870  * @endinternal
871  */
872 nlohmann::json resourceCreationConflict(boost::urls::url_view arg1)
873 {
874     return getLog(redfish::registries::base::Index::resourceCreationConflict,
875                   std::to_array<std::string_view>({arg1.buffer()}));
876 }
877 
878 void resourceCreationConflict(crow::Response& res, boost::urls::url_view arg1)
879 {
880     res.result(boost::beast::http::status::bad_request);
881     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
882 }
883 
884 /**
885  * @internal
886  * @brief Formats MaximumErrorsExceeded message into JSON
887  *
888  * See header file for more information
889  * @endinternal
890  */
891 nlohmann::json maximumErrorsExceeded(void)
892 {
893     return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
894 }
895 
896 void maximumErrorsExceeded(crow::Response& res)
897 {
898     res.result(boost::beast::http::status::internal_server_error);
899     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
900 }
901 
902 /**
903  * @internal
904  * @brief Formats PreconditionFailed message into JSON
905  *
906  * See header file for more information
907  * @endinternal
908  */
909 nlohmann::json preconditionFailed(void)
910 {
911     return getLog(redfish::registries::base::Index::preconditionFailed, {});
912 }
913 
914 void preconditionFailed(crow::Response& res)
915 {
916     res.result(boost::beast::http::status::precondition_failed);
917     addMessageToErrorJson(res.jsonValue, preconditionFailed());
918 }
919 
920 /**
921  * @internal
922  * @brief Formats PreconditionRequired message into JSON
923  *
924  * See header file for more information
925  * @endinternal
926  */
927 nlohmann::json preconditionRequired(void)
928 {
929     return getLog(redfish::registries::base::Index::preconditionRequired, {});
930 }
931 
932 void preconditionRequired(crow::Response& res)
933 {
934     res.result(boost::beast::http::status::bad_request);
935     addMessageToErrorJson(res.jsonValue, preconditionRequired());
936 }
937 
938 /**
939  * @internal
940  * @brief Formats OperationFailed message into JSON
941  *
942  * See header file for more information
943  * @endinternal
944  */
945 nlohmann::json operationFailed(void)
946 {
947     return getLog(redfish::registries::base::Index::operationFailed, {});
948 }
949 
950 void operationFailed(crow::Response& res)
951 {
952     res.result(boost::beast::http::status::bad_gateway);
953     addMessageToErrorJson(res.jsonValue, operationFailed());
954 }
955 
956 /**
957  * @internal
958  * @brief Formats OperationTimeout message into JSON
959  *
960  * See header file for more information
961  * @endinternal
962  */
963 nlohmann::json operationTimeout(void)
964 {
965     return getLog(redfish::registries::base::Index::operationTimeout, {});
966 }
967 
968 void operationTimeout(crow::Response& res)
969 {
970     res.result(boost::beast::http::status::internal_server_error);
971     addMessageToErrorJson(res.jsonValue, operationTimeout());
972 }
973 
974 /**
975  * @internal
976  * @brief Formats PropertyValueTypeError message into JSON for the specified
977  * property
978  *
979  * See header file for more information
980  * @endinternal
981  */
982 nlohmann::json propertyValueTypeError(std::string_view arg1,
983                                       std::string_view arg2)
984 {
985     return getLog(redfish::registries::base::Index::propertyValueTypeError,
986                   std::to_array({arg1, arg2}));
987 }
988 
989 void propertyValueTypeError(crow::Response& res, std::string_view arg1,
990                             std::string_view arg2)
991 {
992     res.result(boost::beast::http::status::bad_request);
993     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
994 }
995 
996 /**
997  * @internal
998  * @brief Formats ResourceNotFound message into JSONd
999  *
1000  * See header file for more information
1001  * @endinternal
1002  */
1003 nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
1004 {
1005     return getLog(redfish::registries::base::Index::resourceNotFound,
1006                   std::to_array({arg1, arg2}));
1007 }
1008 
1009 void resourceNotFound(crow::Response& res, std::string_view arg1,
1010                       std::string_view arg2)
1011 {
1012     res.result(boost::beast::http::status::not_found);
1013     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
1014 }
1015 
1016 /**
1017  * @internal
1018  * @brief Formats CouldNotEstablishConnection message into JSON
1019  *
1020  * See header file for more information
1021  * @endinternal
1022  */
1023 nlohmann::json couldNotEstablishConnection(boost::urls::url_view arg1)
1024 {
1025     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
1026                   std::to_array<std::string_view>({arg1.buffer()}));
1027 }
1028 
1029 void couldNotEstablishConnection(crow::Response& res,
1030                                  boost::urls::url_view arg1)
1031 {
1032     res.result(boost::beast::http::status::not_found);
1033     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
1034 }
1035 
1036 /**
1037  * @internal
1038  * @brief Formats PropertyNotWritable message into JSON for the specified
1039  * property
1040  *
1041  * See header file for more information
1042  * @endinternal
1043  */
1044 nlohmann::json propertyNotWritable(std::string_view arg1)
1045 {
1046     return getLog(redfish::registries::base::Index::propertyNotWritable,
1047                   std::to_array({arg1}));
1048 }
1049 
1050 void propertyNotWritable(crow::Response& res, std::string_view arg1)
1051 {
1052     res.result(boost::beast::http::status::forbidden);
1053     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1054 }
1055 
1056 /**
1057  * @internal
1058  * @brief Formats QueryParameterValueTypeError message into JSON
1059  *
1060  * See header file for more information
1061  * @endinternal
1062  */
1063 nlohmann::json queryParameterValueTypeError(std::string_view arg1,
1064                                             std::string_view arg2)
1065 {
1066     return getLog(
1067         redfish::registries::base::Index::queryParameterValueTypeError,
1068         std::to_array({arg1, arg2}));
1069 }
1070 
1071 void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
1072                                   std::string_view arg2)
1073 {
1074     res.result(boost::beast::http::status::bad_request);
1075     addMessageToErrorJson(res.jsonValue,
1076                           queryParameterValueTypeError(arg1, arg2));
1077 }
1078 
1079 /**
1080  * @internal
1081  * @brief Formats ServiceShuttingDown message into JSON
1082  *
1083  * See header file for more information
1084  * @endinternal
1085  */
1086 nlohmann::json serviceShuttingDown(void)
1087 {
1088     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
1089 }
1090 
1091 void serviceShuttingDown(crow::Response& res)
1092 {
1093     res.result(boost::beast::http::status::service_unavailable);
1094     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1095 }
1096 
1097 /**
1098  * @internal
1099  * @brief Formats ActionParameterDuplicate message into JSON
1100  *
1101  * See header file for more information
1102  * @endinternal
1103  */
1104 nlohmann::json actionParameterDuplicate(std::string_view arg1,
1105                                         std::string_view arg2)
1106 {
1107     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
1108                   std::to_array({arg1, arg2}));
1109 }
1110 
1111 void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
1112                               std::string_view arg2)
1113 {
1114     res.result(boost::beast::http::status::bad_request);
1115     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1116 }
1117 
1118 /**
1119  * @internal
1120  * @brief Formats ActionParameterNotSupported message into JSON
1121  *
1122  * See header file for more information
1123  * @endinternal
1124  */
1125 nlohmann::json actionParameterNotSupported(std::string_view arg1,
1126                                            std::string_view arg2)
1127 {
1128     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
1129                   std::to_array({arg1, arg2}));
1130 }
1131 
1132 void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
1133                                  std::string_view arg2)
1134 {
1135     res.result(boost::beast::http::status::bad_request);
1136     addMessageToErrorJson(res.jsonValue,
1137                           actionParameterNotSupported(arg1, arg2));
1138 }
1139 
1140 /**
1141  * @internal
1142  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1143  *
1144  * See header file for more information
1145  * @endinternal
1146  */
1147 nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1,
1148                                             std::string_view arg2)
1149 {
1150     return getLog(
1151         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
1152         std::to_array<std::string_view>({arg1.buffer(), arg2}));
1153 }
1154 
1155 void sourceDoesNotSupportProtocol(crow::Response& res,
1156                                   boost::urls::url_view arg1,
1157                                   std::string_view arg2)
1158 {
1159     res.result(boost::beast::http::status::bad_request);
1160     addMessageToErrorJson(res.jsonValue,
1161                           sourceDoesNotSupportProtocol(arg1, arg2));
1162 }
1163 
1164 /**
1165  * @internal
1166  * @brief Formats StrictAccountTypes message into JSON
1167  *
1168  * See header file for more information
1169  * @endinternal
1170  */
1171 nlohmann::json strictAccountTypes(std::string_view arg1)
1172 {
1173     return getLog(redfish::registries::base::Index::strictAccountTypes,
1174                   std::to_array({arg1}));
1175 }
1176 
1177 void strictAccountTypes(crow::Response& res, std::string_view arg1)
1178 {
1179     res.result(boost::beast::http::status::bad_request);
1180     addMessageToErrorJson(res.jsonValue, strictAccountTypes(arg1));
1181 }
1182 
1183 /**
1184  * @internal
1185  * @brief Formats AccountRemoved message into JSON
1186  *
1187  * See header file for more information
1188  * @endinternal
1189  */
1190 nlohmann::json accountRemoved(void)
1191 {
1192     return getLog(redfish::registries::base::Index::accountRemoved, {});
1193 }
1194 
1195 void accountRemoved(crow::Response& res)
1196 {
1197     res.result(boost::beast::http::status::ok);
1198     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1199 }
1200 
1201 /**
1202  * @internal
1203  * @brief Formats AccessDenied message into JSON
1204  *
1205  * See header file for more information
1206  * @endinternal
1207  */
1208 nlohmann::json accessDenied(boost::urls::url_view arg1)
1209 {
1210     return getLog(redfish::registries::base::Index::accessDenied,
1211                   std::to_array<std::string_view>({arg1.buffer()}));
1212 }
1213 
1214 void accessDenied(crow::Response& res, boost::urls::url_view arg1)
1215 {
1216     res.result(boost::beast::http::status::forbidden);
1217     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1218 }
1219 
1220 /**
1221  * @internal
1222  * @brief Formats QueryNotSupported message into JSON
1223  *
1224  * See header file for more information
1225  * @endinternal
1226  */
1227 nlohmann::json queryNotSupported(void)
1228 {
1229     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1230 }
1231 
1232 void queryNotSupported(crow::Response& res)
1233 {
1234     res.result(boost::beast::http::status::bad_request);
1235     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1236 }
1237 
1238 /**
1239  * @internal
1240  * @brief Formats CreateLimitReachedForResource message into JSON
1241  *
1242  * See header file for more information
1243  * @endinternal
1244  */
1245 nlohmann::json createLimitReachedForResource(void)
1246 {
1247     return getLog(
1248         redfish::registries::base::Index::createLimitReachedForResource, {});
1249 }
1250 
1251 void createLimitReachedForResource(crow::Response& res)
1252 {
1253     res.result(boost::beast::http::status::bad_request);
1254     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1255 }
1256 
1257 /**
1258  * @internal
1259  * @brief Formats GeneralError message into JSON
1260  *
1261  * See header file for more information
1262  * @endinternal
1263  */
1264 nlohmann::json generalError(void)
1265 {
1266     return getLog(redfish::registries::base::Index::generalError, {});
1267 }
1268 
1269 void generalError(crow::Response& res)
1270 {
1271     res.result(boost::beast::http::status::internal_server_error);
1272     addMessageToErrorJson(res.jsonValue, generalError());
1273 }
1274 
1275 /**
1276  * @internal
1277  * @brief Formats Success message into JSON
1278  *
1279  * See header file for more information
1280  * @endinternal
1281  */
1282 nlohmann::json success(void)
1283 {
1284     return getLog(redfish::registries::base::Index::success, {});
1285 }
1286 
1287 void success(crow::Response& res)
1288 {
1289     // don't set res.result here because success is the default and any
1290     // error should overwrite the default
1291     addMessageToJsonRoot(res.jsonValue, success());
1292 }
1293 
1294 /**
1295  * @internal
1296  * @brief Formats Created message into JSON
1297  *
1298  * See header file for more information
1299  * @endinternal
1300  */
1301 nlohmann::json created(void)
1302 {
1303     return getLog(redfish::registries::base::Index::created, {});
1304 }
1305 
1306 void created(crow::Response& res)
1307 {
1308     res.result(boost::beast::http::status::created);
1309     addMessageToJsonRoot(res.jsonValue, created());
1310 }
1311 
1312 /**
1313  * @internal
1314  * @brief Formats NoOperation message into JSON
1315  *
1316  * See header file for more information
1317  * @endinternal
1318  */
1319 nlohmann::json noOperation(void)
1320 {
1321     return getLog(redfish::registries::base::Index::noOperation, {});
1322 }
1323 
1324 void noOperation(crow::Response& res)
1325 {
1326     res.result(boost::beast::http::status::bad_request);
1327     addMessageToErrorJson(res.jsonValue, noOperation());
1328 }
1329 
1330 /**
1331  * @internal
1332  * @brief Formats PropertyUnknown message into JSON for the specified
1333  * property
1334  *
1335  * See header file for more information
1336  * @endinternal
1337  */
1338 nlohmann::json propertyUnknown(std::string_view arg1)
1339 {
1340     return getLog(redfish::registries::base::Index::propertyUnknown,
1341                   std::to_array({arg1}));
1342 }
1343 
1344 void propertyUnknown(crow::Response& res, std::string_view arg1)
1345 {
1346     res.result(boost::beast::http::status::bad_request);
1347     addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1));
1348 }
1349 
1350 /**
1351  * @internal
1352  * @brief Formats NoValidSession message into JSON
1353  *
1354  * See header file for more information
1355  * @endinternal
1356  */
1357 nlohmann::json noValidSession(void)
1358 {
1359     return getLog(redfish::registries::base::Index::noValidSession, {});
1360 }
1361 
1362 void noValidSession(crow::Response& res)
1363 {
1364     res.result(boost::beast::http::status::forbidden);
1365     addMessageToErrorJson(res.jsonValue, noValidSession());
1366 }
1367 
1368 /**
1369  * @internal
1370  * @brief Formats InvalidObject message into JSON
1371  *
1372  * See header file for more information
1373  * @endinternal
1374  */
1375 nlohmann::json invalidObject(boost::urls::url_view arg1)
1376 {
1377     return getLog(redfish::registries::base::Index::invalidObject,
1378                   std::to_array<std::string_view>({arg1.buffer()}));
1379 }
1380 
1381 void invalidObject(crow::Response& res, boost::urls::url_view arg1)
1382 {
1383     res.result(boost::beast::http::status::bad_request);
1384     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1385 }
1386 
1387 /**
1388  * @internal
1389  * @brief Formats ResourceInStandby message into JSON
1390  *
1391  * See header file for more information
1392  * @endinternal
1393  */
1394 nlohmann::json resourceInStandby(void)
1395 {
1396     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1397 }
1398 
1399 void resourceInStandby(crow::Response& res)
1400 {
1401     res.result(boost::beast::http::status::service_unavailable);
1402     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1403 }
1404 
1405 /**
1406  * @internal
1407  * @brief Formats ActionParameterValueTypeError message into JSON
1408  *
1409  * See header file for more information
1410  * @endinternal
1411  */
1412 nlohmann::json actionParameterValueTypeError(std::string_view arg1,
1413                                              std::string_view arg2,
1414                                              std::string_view arg3)
1415 {
1416     return getLog(
1417         redfish::registries::base::Index::actionParameterValueTypeError,
1418         std::to_array({arg1, arg2, arg3}));
1419 }
1420 
1421 void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
1422                                    std::string_view arg2, std::string_view arg3)
1423 {
1424     res.result(boost::beast::http::status::bad_request);
1425     addMessageToErrorJson(res.jsonValue,
1426                           actionParameterValueTypeError(arg1, arg2, arg3));
1427 }
1428 
1429 /**
1430  * @internal
1431  * @brief Formats SessionLimitExceeded message into JSON
1432  *
1433  * See header file for more information
1434  * @endinternal
1435  */
1436 nlohmann::json sessionLimitExceeded(void)
1437 {
1438     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1439 }
1440 
1441 void sessionLimitExceeded(crow::Response& res)
1442 {
1443     res.result(boost::beast::http::status::service_unavailable);
1444     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1445 }
1446 
1447 /**
1448  * @internal
1449  * @brief Formats ActionNotSupported message into JSON
1450  *
1451  * See header file for more information
1452  * @endinternal
1453  */
1454 nlohmann::json actionNotSupported(std::string_view arg1)
1455 {
1456     return getLog(redfish::registries::base::Index::actionNotSupported,
1457                   std::to_array({arg1}));
1458 }
1459 
1460 void actionNotSupported(crow::Response& res, std::string_view arg1)
1461 {
1462     res.result(boost::beast::http::status::bad_request);
1463     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1464 }
1465 
1466 /**
1467  * @internal
1468  * @brief Formats InvalidIndex message into JSON
1469  *
1470  * See header file for more information
1471  * @endinternal
1472  */
1473 nlohmann::json invalidIndex(int64_t arg1)
1474 {
1475     std::string arg1Str = std::to_string(arg1);
1476     return getLog(redfish::registries::base::Index::invalidIndex,
1477                   std::to_array<std::string_view>({arg1Str}));
1478 }
1479 
1480 void invalidIndex(crow::Response& res, int64_t arg1)
1481 {
1482     res.result(boost::beast::http::status::bad_request);
1483     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1484 }
1485 
1486 /**
1487  * @internal
1488  * @brief Formats EmptyJSON message into JSON
1489  *
1490  * See header file for more information
1491  * @endinternal
1492  */
1493 nlohmann::json emptyJSON(void)
1494 {
1495     return getLog(redfish::registries::base::Index::emptyJSON, {});
1496 }
1497 
1498 void emptyJSON(crow::Response& res)
1499 {
1500     res.result(boost::beast::http::status::bad_request);
1501     addMessageToErrorJson(res.jsonValue, emptyJSON());
1502 }
1503 
1504 /**
1505  * @internal
1506  * @brief Formats QueryNotSupportedOnResource message into JSON
1507  *
1508  * See header file for more information
1509  * @endinternal
1510  */
1511 nlohmann::json queryNotSupportedOnResource(void)
1512 {
1513     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1514                   {});
1515 }
1516 
1517 void queryNotSupportedOnResource(crow::Response& res)
1518 {
1519     res.result(boost::beast::http::status::bad_request);
1520     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1521 }
1522 
1523 /**
1524  * @internal
1525  * @brief Formats QueryNotSupportedOnOperation message into JSON
1526  *
1527  * See header file for more information
1528  * @endinternal
1529  */
1530 nlohmann::json queryNotSupportedOnOperation(void)
1531 {
1532     return getLog(
1533         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1534 }
1535 
1536 void queryNotSupportedOnOperation(crow::Response& res)
1537 {
1538     res.result(boost::beast::http::status::bad_request);
1539     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1540 }
1541 
1542 /**
1543  * @internal
1544  * @brief Formats QueryCombinationInvalid message into JSON
1545  *
1546  * See header file for more information
1547  * @endinternal
1548  */
1549 nlohmann::json queryCombinationInvalid(void)
1550 {
1551     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1552                   {});
1553 }
1554 
1555 void queryCombinationInvalid(crow::Response& res)
1556 {
1557     res.result(boost::beast::http::status::bad_request);
1558     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1559 }
1560 
1561 /**
1562  * @internal
1563  * @brief Formats InsufficientPrivilege message into JSON
1564  *
1565  * See header file for more information
1566  * @endinternal
1567  */
1568 nlohmann::json insufficientPrivilege(void)
1569 {
1570     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1571 }
1572 
1573 void insufficientPrivilege(crow::Response& res)
1574 {
1575     res.result(boost::beast::http::status::forbidden);
1576     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1577 }
1578 
1579 /**
1580  * @internal
1581  * @brief Formats PropertyValueModified message into JSON
1582  *
1583  * See header file for more information
1584  * @endinternal
1585  */
1586 nlohmann::json propertyValueModified(std::string_view arg1,
1587                                      std::string_view arg2)
1588 {
1589     return getLog(redfish::registries::base::Index::propertyValueModified,
1590                   std::to_array({arg1, arg2}));
1591 }
1592 
1593 void propertyValueModified(crow::Response& res, std::string_view arg1,
1594                            std::string_view arg2)
1595 {
1596     res.result(boost::beast::http::status::ok);
1597     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1598 }
1599 
1600 /**
1601  * @internal
1602  * @brief Formats AccountNotModified message into JSON
1603  *
1604  * See header file for more information
1605  * @endinternal
1606  */
1607 nlohmann::json accountNotModified(void)
1608 {
1609     return getLog(redfish::registries::base::Index::accountNotModified, {});
1610 }
1611 
1612 void accountNotModified(crow::Response& res)
1613 {
1614     res.result(boost::beast::http::status::bad_request);
1615     addMessageToErrorJson(res.jsonValue, accountNotModified());
1616 }
1617 
1618 /**
1619  * @internal
1620  * @brief Formats QueryParameterValueFormatError message into JSON
1621  *
1622  * See header file for more information
1623  * @endinternal
1624  */
1625 nlohmann::json queryParameterValueFormatError(std::string_view arg1,
1626                                               std::string_view arg2)
1627 {
1628     return getLog(
1629         redfish::registries::base::Index::queryParameterValueFormatError,
1630         std::to_array({arg1, arg2}));
1631 }
1632 
1633 void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
1634                                     std::string_view arg2)
1635 {
1636     res.result(boost::beast::http::status::bad_request);
1637     addMessageToErrorJson(res.jsonValue,
1638                           queryParameterValueFormatError(arg1, arg2));
1639 }
1640 
1641 /**
1642  * @internal
1643  * @brief Formats PropertyMissing message into JSON for the specified
1644  * property
1645  *
1646  * See header file for more information
1647  * @endinternal
1648  */
1649 nlohmann::json propertyMissing(std::string_view arg1)
1650 {
1651     return getLog(redfish::registries::base::Index::propertyMissing,
1652                   std::to_array({arg1}));
1653 }
1654 
1655 void propertyMissing(crow::Response& res, std::string_view arg1)
1656 {
1657     res.result(boost::beast::http::status::bad_request);
1658     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1659 }
1660 
1661 /**
1662  * @internal
1663  * @brief Formats ResourceExhaustion message into JSON
1664  *
1665  * See header file for more information
1666  * @endinternal
1667  */
1668 nlohmann::json resourceExhaustion(std::string_view arg1)
1669 {
1670     return getLog(redfish::registries::base::Index::resourceExhaustion,
1671                   std::to_array({arg1}));
1672 }
1673 
1674 void resourceExhaustion(crow::Response& res, std::string_view arg1)
1675 {
1676     res.result(boost::beast::http::status::service_unavailable);
1677     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1678 }
1679 
1680 /**
1681  * @internal
1682  * @brief Formats AccountModified message into JSON
1683  *
1684  * See header file for more information
1685  * @endinternal
1686  */
1687 nlohmann::json accountModified(void)
1688 {
1689     return getLog(redfish::registries::base::Index::accountModified, {});
1690 }
1691 
1692 void accountModified(crow::Response& res)
1693 {
1694     res.result(boost::beast::http::status::ok);
1695     addMessageToErrorJson(res.jsonValue, accountModified());
1696 }
1697 
1698 /**
1699  * @internal
1700  * @brief Formats QueryParameterOutOfRange message into JSON
1701  *
1702  * See header file for more information
1703  * @endinternal
1704  */
1705 nlohmann::json queryParameterOutOfRange(std::string_view arg1,
1706                                         std::string_view arg2,
1707                                         std::string_view arg3)
1708 {
1709     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
1710                   std::to_array({arg1, arg2, arg3}));
1711 }
1712 
1713 void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
1714                               std::string_view arg2, std::string_view arg3)
1715 {
1716     res.result(boost::beast::http::status::bad_request);
1717     addMessageToErrorJson(res.jsonValue,
1718                           queryParameterOutOfRange(arg1, arg2, arg3));
1719 }
1720 
1721 nlohmann::json passwordChangeRequired(boost::urls::url_view arg1)
1722 {
1723     return getLog(redfish::registries::base::Index::passwordChangeRequired,
1724                   std::to_array<std::string_view>({arg1.buffer()}));
1725 }
1726 
1727 /**
1728  * @internal
1729  * @brief Formats PasswordChangeRequired message into JSON
1730  *
1731  * See header file for more information
1732  * @endinternal
1733  */
1734 void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1)
1735 {
1736     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
1737 }
1738 
1739 /**
1740  * @internal
1741  * @brief Formats InsufficientStorage message into JSON
1742  *
1743  * See header file for more information
1744  * @endinternal
1745  */
1746 nlohmann::json insufficientStorage()
1747 {
1748     return getLog(redfish::registries::base::Index::insufficientStorage, {});
1749 }
1750 
1751 void insufficientStorage(crow::Response& res)
1752 {
1753     res.result(boost::beast::http::status::insufficient_storage);
1754     addMessageToErrorJson(res.jsonValue, insufficientStorage());
1755 }
1756 
1757 /**
1758  * @internal
1759  * @brief Formats OperationNotAllowed message into JSON
1760  *
1761  * See header file for more information
1762  * @endinternal
1763  */
1764 nlohmann::json operationNotAllowed()
1765 {
1766     return getLog(redfish::registries::base::Index::operationNotAllowed, {});
1767 }
1768 
1769 void operationNotAllowed(crow::Response& res)
1770 {
1771     res.result(boost::beast::http::status::method_not_allowed);
1772     addMessageToErrorJson(res.jsonValue, operationNotAllowed());
1773 }
1774 
1775 /**
1776  * @internal
1777  * @brief Formats ArraySizeTooLong message into JSON
1778  *
1779  * See header file for more information
1780  * @endinternal
1781  */
1782 nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length)
1783 {
1784     std::string valStr = std::to_string(length);
1785     return getLog(redfish::registries::base::Index::arraySizeTooLong,
1786                   std::to_array<std::string_view>({property, valStr}));
1787 }
1788 
1789 void arraySizeTooLong(crow::Response& res, std::string_view property,
1790                       uint64_t length)
1791 {
1792     res.result(boost::beast::http::status::method_not_allowed);
1793     addMessageToErrorJson(res.jsonValue, arraySizeTooLong(property, length));
1794 }
1795 
1796 void invalidUpload(crow::Response& res, std::string_view arg1,
1797                    std::string_view arg2)
1798 {
1799     res.result(boost::beast::http::status::bad_request);
1800     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
1801 }
1802 
1803 /**
1804  * @internal
1805  * @brief Formats Invalid File message into JSON
1806  *
1807  * See header file for more information
1808  * @endinternal
1809  */
1810 nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
1811 {
1812     std::string msg = "Invalid file uploaded to ";
1813     msg += arg1;
1814     msg += ": ";
1815     msg += arg2;
1816     msg += ".";
1817 
1818     nlohmann::json::object_t ret;
1819     ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message";
1820     ret["MessageId"] = "OpenBMC.0.2.InvalidUpload";
1821     ret["Message"] = std::move(msg);
1822     nlohmann::json::array_t args;
1823     args.emplace_back(arg1);
1824     args.emplace_back(arg2);
1825     ret["MessageArgs"] = std::move(args);
1826     ret["MessageSeverity"] = "Warning";
1827     ret["Resolution"] = "None.";
1828     return ret;
1829 }
1830 
1831 } // namespace messages
1832 
1833 } // namespace redfish
1834