xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision 2e8c4bda9c4b2809ca76bb227f818592515a3e4a)
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(const nlohmann::json& arg1,
983                                       std::string_view arg2)
984 {
985     std::string arg1Str = arg1.dump(2, ' ', true,
986                                     nlohmann::json::error_handler_t::replace);
987     return getLog(redfish::registries::base::Index::propertyValueTypeError,
988                   std::to_array<std::string_view>({arg1Str, arg2}));
989 }
990 
991 void propertyValueTypeError(crow::Response& res, const nlohmann::json& arg1,
992                             std::string_view arg2)
993 {
994     res.result(boost::beast::http::status::bad_request);
995     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
996 }
997 
998 /**
999  * @internal
1000  * @brief Formats ResourceNotFound message into JSONd
1001  *
1002  * See header file for more information
1003  * @endinternal
1004  */
1005 nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
1006 {
1007     return getLog(redfish::registries::base::Index::resourceNotFound,
1008                   std::to_array({arg1, arg2}));
1009 }
1010 
1011 void resourceNotFound(crow::Response& res, std::string_view arg1,
1012                       std::string_view arg2)
1013 {
1014     res.result(boost::beast::http::status::not_found);
1015     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
1016 }
1017 
1018 /**
1019  * @internal
1020  * @brief Formats CouldNotEstablishConnection message into JSON
1021  *
1022  * See header file for more information
1023  * @endinternal
1024  */
1025 nlohmann::json couldNotEstablishConnection(boost::urls::url_view arg1)
1026 {
1027     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
1028                   std::to_array<std::string_view>({arg1.buffer()}));
1029 }
1030 
1031 void couldNotEstablishConnection(crow::Response& res,
1032                                  boost::urls::url_view arg1)
1033 {
1034     res.result(boost::beast::http::status::not_found);
1035     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
1036 }
1037 
1038 /**
1039  * @internal
1040  * @brief Formats PropertyNotWritable message into JSON for the specified
1041  * property
1042  *
1043  * See header file for more information
1044  * @endinternal
1045  */
1046 nlohmann::json propertyNotWritable(std::string_view arg1)
1047 {
1048     return getLog(redfish::registries::base::Index::propertyNotWritable,
1049                   std::to_array({arg1}));
1050 }
1051 
1052 void propertyNotWritable(crow::Response& res, std::string_view arg1)
1053 {
1054     res.result(boost::beast::http::status::forbidden);
1055     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1056 }
1057 
1058 /**
1059  * @internal
1060  * @brief Formats QueryParameterValueTypeError message into JSON
1061  *
1062  * See header file for more information
1063  * @endinternal
1064  */
1065 nlohmann::json queryParameterValueTypeError(std::string_view arg1,
1066                                             std::string_view arg2)
1067 {
1068     return getLog(
1069         redfish::registries::base::Index::queryParameterValueTypeError,
1070         std::to_array({arg1, arg2}));
1071 }
1072 
1073 void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
1074                                   std::string_view arg2)
1075 {
1076     res.result(boost::beast::http::status::bad_request);
1077     addMessageToErrorJson(res.jsonValue,
1078                           queryParameterValueTypeError(arg1, arg2));
1079 }
1080 
1081 /**
1082  * @internal
1083  * @brief Formats ServiceShuttingDown message into JSON
1084  *
1085  * See header file for more information
1086  * @endinternal
1087  */
1088 nlohmann::json serviceShuttingDown(void)
1089 {
1090     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
1091 }
1092 
1093 void serviceShuttingDown(crow::Response& res)
1094 {
1095     res.result(boost::beast::http::status::service_unavailable);
1096     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1097 }
1098 
1099 /**
1100  * @internal
1101  * @brief Formats ActionParameterDuplicate message into JSON
1102  *
1103  * See header file for more information
1104  * @endinternal
1105  */
1106 nlohmann::json actionParameterDuplicate(std::string_view arg1,
1107                                         std::string_view arg2)
1108 {
1109     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
1110                   std::to_array({arg1, arg2}));
1111 }
1112 
1113 void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
1114                               std::string_view arg2)
1115 {
1116     res.result(boost::beast::http::status::bad_request);
1117     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1118 }
1119 
1120 /**
1121  * @internal
1122  * @brief Formats ActionParameterNotSupported message into JSON
1123  *
1124  * See header file for more information
1125  * @endinternal
1126  */
1127 nlohmann::json actionParameterNotSupported(std::string_view arg1,
1128                                            std::string_view arg2)
1129 {
1130     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
1131                   std::to_array({arg1, arg2}));
1132 }
1133 
1134 void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
1135                                  std::string_view arg2)
1136 {
1137     res.result(boost::beast::http::status::bad_request);
1138     addMessageToErrorJson(res.jsonValue,
1139                           actionParameterNotSupported(arg1, arg2));
1140 }
1141 
1142 /**
1143  * @internal
1144  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1145  *
1146  * See header file for more information
1147  * @endinternal
1148  */
1149 nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1,
1150                                             std::string_view arg2)
1151 {
1152     return getLog(
1153         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
1154         std::to_array<std::string_view>({arg1.buffer(), arg2}));
1155 }
1156 
1157 void sourceDoesNotSupportProtocol(crow::Response& res,
1158                                   boost::urls::url_view arg1,
1159                                   std::string_view arg2)
1160 {
1161     res.result(boost::beast::http::status::bad_request);
1162     addMessageToErrorJson(res.jsonValue,
1163                           sourceDoesNotSupportProtocol(arg1, arg2));
1164 }
1165 
1166 /**
1167  * @internal
1168  * @brief Formats StrictAccountTypes message into JSON
1169  *
1170  * See header file for more information
1171  * @endinternal
1172  */
1173 nlohmann::json strictAccountTypes(std::string_view arg1)
1174 {
1175     return getLog(redfish::registries::base::Index::strictAccountTypes,
1176                   std::to_array({arg1}));
1177 }
1178 
1179 void strictAccountTypes(crow::Response& res, std::string_view arg1)
1180 {
1181     res.result(boost::beast::http::status::bad_request);
1182     addMessageToErrorJson(res.jsonValue, strictAccountTypes(arg1));
1183 }
1184 
1185 /**
1186  * @internal
1187  * @brief Formats AccountRemoved message into JSON
1188  *
1189  * See header file for more information
1190  * @endinternal
1191  */
1192 nlohmann::json accountRemoved(void)
1193 {
1194     return getLog(redfish::registries::base::Index::accountRemoved, {});
1195 }
1196 
1197 void accountRemoved(crow::Response& res)
1198 {
1199     res.result(boost::beast::http::status::ok);
1200     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1201 }
1202 
1203 /**
1204  * @internal
1205  * @brief Formats AccessDenied message into JSON
1206  *
1207  * See header file for more information
1208  * @endinternal
1209  */
1210 nlohmann::json accessDenied(boost::urls::url_view arg1)
1211 {
1212     return getLog(redfish::registries::base::Index::accessDenied,
1213                   std::to_array<std::string_view>({arg1.buffer()}));
1214 }
1215 
1216 void accessDenied(crow::Response& res, boost::urls::url_view arg1)
1217 {
1218     res.result(boost::beast::http::status::forbidden);
1219     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1220 }
1221 
1222 /**
1223  * @internal
1224  * @brief Formats QueryNotSupported message into JSON
1225  *
1226  * See header file for more information
1227  * @endinternal
1228  */
1229 nlohmann::json queryNotSupported(void)
1230 {
1231     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1232 }
1233 
1234 void queryNotSupported(crow::Response& res)
1235 {
1236     res.result(boost::beast::http::status::bad_request);
1237     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1238 }
1239 
1240 /**
1241  * @internal
1242  * @brief Formats CreateLimitReachedForResource message into JSON
1243  *
1244  * See header file for more information
1245  * @endinternal
1246  */
1247 nlohmann::json createLimitReachedForResource(void)
1248 {
1249     return getLog(
1250         redfish::registries::base::Index::createLimitReachedForResource, {});
1251 }
1252 
1253 void createLimitReachedForResource(crow::Response& res)
1254 {
1255     res.result(boost::beast::http::status::bad_request);
1256     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1257 }
1258 
1259 /**
1260  * @internal
1261  * @brief Formats GeneralError message into JSON
1262  *
1263  * See header file for more information
1264  * @endinternal
1265  */
1266 nlohmann::json generalError(void)
1267 {
1268     return getLog(redfish::registries::base::Index::generalError, {});
1269 }
1270 
1271 void generalError(crow::Response& res)
1272 {
1273     res.result(boost::beast::http::status::internal_server_error);
1274     addMessageToErrorJson(res.jsonValue, generalError());
1275 }
1276 
1277 /**
1278  * @internal
1279  * @brief Formats Success message into JSON
1280  *
1281  * See header file for more information
1282  * @endinternal
1283  */
1284 nlohmann::json success(void)
1285 {
1286     return getLog(redfish::registries::base::Index::success, {});
1287 }
1288 
1289 void success(crow::Response& res)
1290 {
1291     // don't set res.result here because success is the default and any
1292     // error should overwrite the default
1293     addMessageToJsonRoot(res.jsonValue, success());
1294 }
1295 
1296 /**
1297  * @internal
1298  * @brief Formats Created message into JSON
1299  *
1300  * See header file for more information
1301  * @endinternal
1302  */
1303 nlohmann::json created(void)
1304 {
1305     return getLog(redfish::registries::base::Index::created, {});
1306 }
1307 
1308 void created(crow::Response& res)
1309 {
1310     res.result(boost::beast::http::status::created);
1311     addMessageToJsonRoot(res.jsonValue, created());
1312 }
1313 
1314 /**
1315  * @internal
1316  * @brief Formats NoOperation message into JSON
1317  *
1318  * See header file for more information
1319  * @endinternal
1320  */
1321 nlohmann::json noOperation(void)
1322 {
1323     return getLog(redfish::registries::base::Index::noOperation, {});
1324 }
1325 
1326 void noOperation(crow::Response& res)
1327 {
1328     res.result(boost::beast::http::status::bad_request);
1329     addMessageToErrorJson(res.jsonValue, noOperation());
1330 }
1331 
1332 /**
1333  * @internal
1334  * @brief Formats PropertyUnknown message into JSON for the specified
1335  * property
1336  *
1337  * See header file for more information
1338  * @endinternal
1339  */
1340 nlohmann::json propertyUnknown(std::string_view arg1)
1341 {
1342     return getLog(redfish::registries::base::Index::propertyUnknown,
1343                   std::to_array({arg1}));
1344 }
1345 
1346 void propertyUnknown(crow::Response& res, std::string_view arg1)
1347 {
1348     res.result(boost::beast::http::status::bad_request);
1349     addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1));
1350 }
1351 
1352 /**
1353  * @internal
1354  * @brief Formats NoValidSession message into JSON
1355  *
1356  * See header file for more information
1357  * @endinternal
1358  */
1359 nlohmann::json noValidSession(void)
1360 {
1361     return getLog(redfish::registries::base::Index::noValidSession, {});
1362 }
1363 
1364 void noValidSession(crow::Response& res)
1365 {
1366     res.result(boost::beast::http::status::forbidden);
1367     addMessageToErrorJson(res.jsonValue, noValidSession());
1368 }
1369 
1370 /**
1371  * @internal
1372  * @brief Formats InvalidObject message into JSON
1373  *
1374  * See header file for more information
1375  * @endinternal
1376  */
1377 nlohmann::json invalidObject(boost::urls::url_view arg1)
1378 {
1379     return getLog(redfish::registries::base::Index::invalidObject,
1380                   std::to_array<std::string_view>({arg1.buffer()}));
1381 }
1382 
1383 void invalidObject(crow::Response& res, boost::urls::url_view arg1)
1384 {
1385     res.result(boost::beast::http::status::bad_request);
1386     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1387 }
1388 
1389 /**
1390  * @internal
1391  * @brief Formats ResourceInStandby message into JSON
1392  *
1393  * See header file for more information
1394  * @endinternal
1395  */
1396 nlohmann::json resourceInStandby(void)
1397 {
1398     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1399 }
1400 
1401 void resourceInStandby(crow::Response& res)
1402 {
1403     res.result(boost::beast::http::status::service_unavailable);
1404     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1405 }
1406 
1407 /**
1408  * @internal
1409  * @brief Formats ActionParameterValueTypeError message into JSON
1410  *
1411  * See header file for more information
1412  * @endinternal
1413  */
1414 nlohmann::json actionParameterValueTypeError(std::string_view arg1,
1415                                              std::string_view arg2,
1416                                              std::string_view arg3)
1417 {
1418     return getLog(
1419         redfish::registries::base::Index::actionParameterValueTypeError,
1420         std::to_array({arg1, arg2, arg3}));
1421 }
1422 
1423 void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
1424                                    std::string_view arg2, std::string_view arg3)
1425 {
1426     res.result(boost::beast::http::status::bad_request);
1427     addMessageToErrorJson(res.jsonValue,
1428                           actionParameterValueTypeError(arg1, arg2, arg3));
1429 }
1430 
1431 /**
1432  * @internal
1433  * @brief Formats SessionLimitExceeded message into JSON
1434  *
1435  * See header file for more information
1436  * @endinternal
1437  */
1438 nlohmann::json sessionLimitExceeded(void)
1439 {
1440     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1441 }
1442 
1443 void sessionLimitExceeded(crow::Response& res)
1444 {
1445     res.result(boost::beast::http::status::service_unavailable);
1446     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1447 }
1448 
1449 /**
1450  * @internal
1451  * @brief Formats ActionNotSupported message into JSON
1452  *
1453  * See header file for more information
1454  * @endinternal
1455  */
1456 nlohmann::json actionNotSupported(std::string_view arg1)
1457 {
1458     return getLog(redfish::registries::base::Index::actionNotSupported,
1459                   std::to_array({arg1}));
1460 }
1461 
1462 void actionNotSupported(crow::Response& res, std::string_view arg1)
1463 {
1464     res.result(boost::beast::http::status::bad_request);
1465     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1466 }
1467 
1468 /**
1469  * @internal
1470  * @brief Formats InvalidIndex message into JSON
1471  *
1472  * See header file for more information
1473  * @endinternal
1474  */
1475 nlohmann::json invalidIndex(int64_t arg1)
1476 {
1477     std::string arg1Str = std::to_string(arg1);
1478     return getLog(redfish::registries::base::Index::invalidIndex,
1479                   std::to_array<std::string_view>({arg1Str}));
1480 }
1481 
1482 void invalidIndex(crow::Response& res, int64_t arg1)
1483 {
1484     res.result(boost::beast::http::status::bad_request);
1485     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1486 }
1487 
1488 /**
1489  * @internal
1490  * @brief Formats EmptyJSON message into JSON
1491  *
1492  * See header file for more information
1493  * @endinternal
1494  */
1495 nlohmann::json emptyJSON(void)
1496 {
1497     return getLog(redfish::registries::base::Index::emptyJSON, {});
1498 }
1499 
1500 void emptyJSON(crow::Response& res)
1501 {
1502     res.result(boost::beast::http::status::bad_request);
1503     addMessageToErrorJson(res.jsonValue, emptyJSON());
1504 }
1505 
1506 /**
1507  * @internal
1508  * @brief Formats QueryNotSupportedOnResource message into JSON
1509  *
1510  * See header file for more information
1511  * @endinternal
1512  */
1513 nlohmann::json queryNotSupportedOnResource(void)
1514 {
1515     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1516                   {});
1517 }
1518 
1519 void queryNotSupportedOnResource(crow::Response& res)
1520 {
1521     res.result(boost::beast::http::status::bad_request);
1522     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1523 }
1524 
1525 /**
1526  * @internal
1527  * @brief Formats QueryNotSupportedOnOperation message into JSON
1528  *
1529  * See header file for more information
1530  * @endinternal
1531  */
1532 nlohmann::json queryNotSupportedOnOperation(void)
1533 {
1534     return getLog(
1535         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1536 }
1537 
1538 void queryNotSupportedOnOperation(crow::Response& res)
1539 {
1540     res.result(boost::beast::http::status::bad_request);
1541     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1542 }
1543 
1544 /**
1545  * @internal
1546  * @brief Formats QueryCombinationInvalid message into JSON
1547  *
1548  * See header file for more information
1549  * @endinternal
1550  */
1551 nlohmann::json queryCombinationInvalid(void)
1552 {
1553     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1554                   {});
1555 }
1556 
1557 void queryCombinationInvalid(crow::Response& res)
1558 {
1559     res.result(boost::beast::http::status::bad_request);
1560     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1561 }
1562 
1563 /**
1564  * @internal
1565  * @brief Formats InsufficientPrivilege message into JSON
1566  *
1567  * See header file for more information
1568  * @endinternal
1569  */
1570 nlohmann::json insufficientPrivilege(void)
1571 {
1572     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1573 }
1574 
1575 void insufficientPrivilege(crow::Response& res)
1576 {
1577     res.result(boost::beast::http::status::forbidden);
1578     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1579 }
1580 
1581 /**
1582  * @internal
1583  * @brief Formats PropertyValueModified message into JSON
1584  *
1585  * See header file for more information
1586  * @endinternal
1587  */
1588 nlohmann::json propertyValueModified(std::string_view arg1,
1589                                      std::string_view arg2)
1590 {
1591     return getLog(redfish::registries::base::Index::propertyValueModified,
1592                   std::to_array({arg1, arg2}));
1593 }
1594 
1595 void propertyValueModified(crow::Response& res, std::string_view arg1,
1596                            std::string_view arg2)
1597 {
1598     res.result(boost::beast::http::status::ok);
1599     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1600 }
1601 
1602 /**
1603  * @internal
1604  * @brief Formats AccountNotModified message into JSON
1605  *
1606  * See header file for more information
1607  * @endinternal
1608  */
1609 nlohmann::json accountNotModified(void)
1610 {
1611     return getLog(redfish::registries::base::Index::accountNotModified, {});
1612 }
1613 
1614 void accountNotModified(crow::Response& res)
1615 {
1616     res.result(boost::beast::http::status::bad_request);
1617     addMessageToErrorJson(res.jsonValue, accountNotModified());
1618 }
1619 
1620 /**
1621  * @internal
1622  * @brief Formats QueryParameterValueFormatError message into JSON
1623  *
1624  * See header file for more information
1625  * @endinternal
1626  */
1627 nlohmann::json queryParameterValueFormatError(std::string_view arg1,
1628                                               std::string_view arg2)
1629 {
1630     return getLog(
1631         redfish::registries::base::Index::queryParameterValueFormatError,
1632         std::to_array({arg1, arg2}));
1633 }
1634 
1635 void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
1636                                     std::string_view arg2)
1637 {
1638     res.result(boost::beast::http::status::bad_request);
1639     addMessageToErrorJson(res.jsonValue,
1640                           queryParameterValueFormatError(arg1, arg2));
1641 }
1642 
1643 /**
1644  * @internal
1645  * @brief Formats PropertyMissing message into JSON for the specified
1646  * property
1647  *
1648  * See header file for more information
1649  * @endinternal
1650  */
1651 nlohmann::json propertyMissing(std::string_view arg1)
1652 {
1653     return getLog(redfish::registries::base::Index::propertyMissing,
1654                   std::to_array({arg1}));
1655 }
1656 
1657 void propertyMissing(crow::Response& res, std::string_view arg1)
1658 {
1659     res.result(boost::beast::http::status::bad_request);
1660     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1661 }
1662 
1663 /**
1664  * @internal
1665  * @brief Formats ResourceExhaustion message into JSON
1666  *
1667  * See header file for more information
1668  * @endinternal
1669  */
1670 nlohmann::json resourceExhaustion(std::string_view arg1)
1671 {
1672     return getLog(redfish::registries::base::Index::resourceExhaustion,
1673                   std::to_array({arg1}));
1674 }
1675 
1676 void resourceExhaustion(crow::Response& res, std::string_view arg1)
1677 {
1678     res.result(boost::beast::http::status::service_unavailable);
1679     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1680 }
1681 
1682 /**
1683  * @internal
1684  * @brief Formats AccountModified message into JSON
1685  *
1686  * See header file for more information
1687  * @endinternal
1688  */
1689 nlohmann::json accountModified(void)
1690 {
1691     return getLog(redfish::registries::base::Index::accountModified, {});
1692 }
1693 
1694 void accountModified(crow::Response& res)
1695 {
1696     res.result(boost::beast::http::status::ok);
1697     addMessageToErrorJson(res.jsonValue, accountModified());
1698 }
1699 
1700 /**
1701  * @internal
1702  * @brief Formats QueryParameterOutOfRange message into JSON
1703  *
1704  * See header file for more information
1705  * @endinternal
1706  */
1707 nlohmann::json queryParameterOutOfRange(std::string_view arg1,
1708                                         std::string_view arg2,
1709                                         std::string_view arg3)
1710 {
1711     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
1712                   std::to_array({arg1, arg2, arg3}));
1713 }
1714 
1715 void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
1716                               std::string_view arg2, std::string_view arg3)
1717 {
1718     res.result(boost::beast::http::status::bad_request);
1719     addMessageToErrorJson(res.jsonValue,
1720                           queryParameterOutOfRange(arg1, arg2, arg3));
1721 }
1722 
1723 nlohmann::json passwordChangeRequired(boost::urls::url_view arg1)
1724 {
1725     return getLog(redfish::registries::base::Index::passwordChangeRequired,
1726                   std::to_array<std::string_view>({arg1.buffer()}));
1727 }
1728 
1729 /**
1730  * @internal
1731  * @brief Formats PasswordChangeRequired message into JSON
1732  *
1733  * See header file for more information
1734  * @endinternal
1735  */
1736 void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1)
1737 {
1738     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
1739 }
1740 
1741 /**
1742  * @internal
1743  * @brief Formats InsufficientStorage message into JSON
1744  *
1745  * See header file for more information
1746  * @endinternal
1747  */
1748 nlohmann::json insufficientStorage()
1749 {
1750     return getLog(redfish::registries::base::Index::insufficientStorage, {});
1751 }
1752 
1753 void insufficientStorage(crow::Response& res)
1754 {
1755     res.result(boost::beast::http::status::insufficient_storage);
1756     addMessageToErrorJson(res.jsonValue, insufficientStorage());
1757 }
1758 
1759 /**
1760  * @internal
1761  * @brief Formats OperationNotAllowed message into JSON
1762  *
1763  * See header file for more information
1764  * @endinternal
1765  */
1766 nlohmann::json operationNotAllowed()
1767 {
1768     return getLog(redfish::registries::base::Index::operationNotAllowed, {});
1769 }
1770 
1771 void operationNotAllowed(crow::Response& res)
1772 {
1773     res.result(boost::beast::http::status::method_not_allowed);
1774     addMessageToErrorJson(res.jsonValue, operationNotAllowed());
1775 }
1776 
1777 /**
1778  * @internal
1779  * @brief Formats ArraySizeTooLong message into JSON
1780  *
1781  * See header file for more information
1782  * @endinternal
1783  */
1784 nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length)
1785 {
1786     std::string valStr = std::to_string(length);
1787     return getLog(redfish::registries::base::Index::arraySizeTooLong,
1788                   std::to_array<std::string_view>({property, valStr}));
1789 }
1790 
1791 void arraySizeTooLong(crow::Response& res, std::string_view property,
1792                       uint64_t length)
1793 {
1794     res.result(boost::beast::http::status::method_not_allowed);
1795     addMessageToErrorJson(res.jsonValue, arraySizeTooLong(property, length));
1796 }
1797 
1798 void invalidUpload(crow::Response& res, std::string_view arg1,
1799                    std::string_view arg2)
1800 {
1801     res.result(boost::beast::http::status::bad_request);
1802     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
1803 }
1804 
1805 /**
1806  * @internal
1807  * @brief Formats Invalid File message into JSON
1808  *
1809  * See header file for more information
1810  * @endinternal
1811  */
1812 nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
1813 {
1814     std::string msg = "Invalid file uploaded to ";
1815     msg += arg1;
1816     msg += ": ";
1817     msg += arg2;
1818     msg += ".";
1819 
1820     nlohmann::json::object_t ret;
1821     ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message";
1822     ret["MessageId"] = "OpenBMC.0.2.InvalidUpload";
1823     ret["Message"] = std::move(msg);
1824     nlohmann::json::array_t args;
1825     args.emplace_back(arg1);
1826     args.emplace_back(arg2);
1827     ret["MessageArgs"] = std::move(args);
1828     ret["MessageSeverity"] = "Warning";
1829     ret["Resolution"] = "None.";
1830     return ret;
1831 }
1832 
1833 } // namespace messages
1834 
1835 } // namespace redfish
1836