1 /*
2 // Copyright (c) 2018 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 #include "error_messages.hpp"
17 
18 #include "http_response.hpp"
19 #include "logging.hpp"
20 #include "nlohmann/json.hpp"
21 #include "registries.hpp"
22 #include "registries/base_message_registry.hpp"
23 #include "source_location.hpp"
24 
25 #include <boost/beast/http/field.hpp>
26 #include <boost/beast/http/status.hpp>
27 
28 #include <array>
29 #include <cstddef>
30 #include <span>
31 #include <string>
32 #include <utility>
33 
34 // IWYU pragma: no_include <stddef.h>
35 
36 namespace redfish
37 {
38 
39 namespace messages
40 {
41 
42 static void addMessageToErrorJson(nlohmann::json& target,
43                                   const nlohmann::json& message)
44 {
45     auto& error = target["error"];
46 
47     // If this is the first error message, fill in the information from the
48     // first error message to the top level struct
49     if (!error.is_object())
50     {
51         auto messageIdIterator = message.find("MessageId");
52         if (messageIdIterator == message.end())
53         {
54             BMCWEB_LOG_CRITICAL
55                 << "Attempt to add error message without MessageId";
56             return;
57         }
58 
59         auto messageFieldIterator = message.find("Message");
60         if (messageFieldIterator == message.end())
61         {
62             BMCWEB_LOG_CRITICAL
63                 << "Attempt to add error message without Message";
64             return;
65         }
66         error["code"] = *messageIdIterator;
67         error["message"] = *messageFieldIterator;
68     }
69     else
70     {
71         // More than 1 error occurred, so the message has to be generic
72         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
73         error["message"] = "A general error has occurred. See Resolution for "
74                            "information on how to resolve the error.";
75     }
76 
77     // This check could technically be done in 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(const 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,
214                           const boost::urls::url_view& arg1)
215 {
216     res.result(boost::beast::http::status::bad_request);
217     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
218 }
219 
220 /**
221  * @internal
222  * @brief Formats ActionParameterValueFormatError message into JSON
223  *
224  * See header file for more information
225  * @endinternal
226  */
227 nlohmann::json actionParameterValueFormatError(std::string_view arg1,
228                                                std::string_view arg2,
229                                                std::string_view arg3)
230 {
231     return getLog(
232         redfish::registries::base::Index::actionParameterValueFormatError,
233         std::to_array({arg1, arg2, arg3}));
234 }
235 
236 void actionParameterValueFormatError(crow::Response& res, std::string_view arg1,
237                                      std::string_view arg2,
238                                      std::string_view arg3)
239 {
240     res.result(boost::beast::http::status::bad_request);
241     addMessageToErrorJson(res.jsonValue,
242                           actionParameterValueFormatError(arg1, arg2, arg3));
243 }
244 
245 /**
246  * @internal
247  * @brief Formats ActionParameterValueNotInList message into JSON
248  *
249  * See header file for more information
250  * @endinternal
251  */
252 nlohmann::json actionParameterValueNotInList(std::string_view arg1,
253                                              std::string_view arg2,
254                                              std::string_view arg3)
255 {
256     return getLog(
257         redfish::registries::base::Index::actionParameterValueNotInList,
258         std::to_array({arg1, arg2, arg3}));
259 }
260 
261 void actionParameterValueNotInList(crow::Response& res, std::string_view arg1,
262                                    std::string_view arg2, std::string_view arg3)
263 {
264     res.result(boost::beast::http::status::bad_request);
265     addMessageToErrorJson(res.jsonValue,
266                           actionParameterValueNotInList(arg1, arg2, arg3));
267 }
268 
269 /**
270  * @internal
271  * @brief Formats InternalError message into JSON
272  *
273  * See header file for more information
274  * @endinternal
275  */
276 nlohmann::json internalError(void)
277 {
278     return getLog(redfish::registries::base::Index::internalError, {});
279 }
280 
281 void internalError(crow::Response& res, const bmcweb::source_location location)
282 {
283     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
284                         << location.line() << ":" << location.column() << ") `"
285                         << location.function_name() << "`: ";
286     res.result(boost::beast::http::status::internal_server_error);
287     addMessageToErrorJson(res.jsonValue, internalError());
288 }
289 
290 /**
291  * @internal
292  * @brief Formats UnrecognizedRequestBody message into JSON
293  *
294  * See header file for more information
295  * @endinternal
296  */
297 nlohmann::json unrecognizedRequestBody(void)
298 {
299     return getLog(redfish::registries::base::Index::unrecognizedRequestBody,
300                   {});
301 }
302 
303 void unrecognizedRequestBody(crow::Response& res)
304 {
305     res.result(boost::beast::http::status::bad_request);
306     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
307 }
308 
309 /**
310  * @internal
311  * @brief Formats ResourceAtUriUnauthorized message into JSON
312  *
313  * See header file for more information
314  * @endinternal
315  */
316 nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1,
317                                          std::string_view arg2)
318 {
319     return getLog(redfish::registries::base::Index::resourceAtUriUnauthorized,
320                   std::to_array<std::string_view>({arg1.buffer(), arg2}));
321 }
322 
323 void resourceAtUriUnauthorized(crow::Response& res,
324                                const boost::urls::url_view& arg1,
325                                std::string_view arg2)
326 {
327     res.result(boost::beast::http::status::unauthorized);
328     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
329 }
330 
331 /**
332  * @internal
333  * @brief Formats ActionParameterUnknown message into JSON
334  *
335  * See header file for more information
336  * @endinternal
337  */
338 nlohmann::json actionParameterUnknown(std::string_view arg1,
339                                       std::string_view arg2)
340 {
341     return getLog(redfish::registries::base::Index::actionParameterUnknown,
342                   std::to_array({arg1, arg2}));
343 }
344 
345 void actionParameterUnknown(crow::Response& res, std::string_view arg1,
346                             std::string_view arg2)
347 {
348     res.result(boost::beast::http::status::bad_request);
349     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
350 }
351 
352 /**
353  * @internal
354  * @brief Formats ResourceCannotBeDeleted message into JSON
355  *
356  * See header file for more information
357  * @endinternal
358  */
359 nlohmann::json resourceCannotBeDeleted(void)
360 {
361     return getLog(redfish::registries::base::Index::resourceCannotBeDeleted,
362                   {});
363 }
364 
365 void resourceCannotBeDeleted(crow::Response& res)
366 {
367     res.result(boost::beast::http::status::method_not_allowed);
368     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
369 }
370 
371 /**
372  * @internal
373  * @brief Formats PropertyDuplicate message into JSON
374  *
375  * See header file for more information
376  * @endinternal
377  */
378 nlohmann::json propertyDuplicate(std::string_view arg1)
379 {
380     return getLog(redfish::registries::base::Index::propertyDuplicate,
381                   std::to_array({arg1}));
382 }
383 
384 void propertyDuplicate(crow::Response& res, std::string_view arg1)
385 {
386     res.result(boost::beast::http::status::bad_request);
387     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
388 }
389 
390 /**
391  * @internal
392  * @brief Formats ServiceTemporarilyUnavailable message into JSON
393  *
394  * See header file for more information
395  * @endinternal
396  */
397 nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
398 {
399     return getLog(
400         redfish::registries::base::Index::serviceTemporarilyUnavailable,
401         std::to_array({arg1}));
402 }
403 
404 void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
405 {
406     res.addHeader(boost::beast::http::field::retry_after, arg1);
407     res.result(boost::beast::http::status::service_unavailable);
408     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
409 }
410 
411 /**
412  * @internal
413  * @brief Formats ResourceAlreadyExists message into JSON
414  *
415  * See header file for more information
416  * @endinternal
417  */
418 nlohmann::json resourceAlreadyExists(std::string_view arg1,
419                                      std::string_view arg2,
420                                      std::string_view arg3)
421 {
422     return getLog(redfish::registries::base::Index::resourceAlreadyExists,
423                   std::to_array({arg1, arg2, arg3}));
424 }
425 
426 void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
427                            std::string_view arg2, std::string_view arg3)
428 {
429     res.result(boost::beast::http::status::bad_request);
430     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
431                      arg2);
432 }
433 
434 /**
435  * @internal
436  * @brief Formats AccountForSessionNoLongerExists message into JSON
437  *
438  * See header file for more information
439  * @endinternal
440  */
441 nlohmann::json accountForSessionNoLongerExists(void)
442 {
443     return getLog(
444         redfish::registries::base::Index::accountForSessionNoLongerExists, {});
445 }
446 
447 void accountForSessionNoLongerExists(crow::Response& res)
448 {
449     res.result(boost::beast::http::status::forbidden);
450     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
451 }
452 
453 /**
454  * @internal
455  * @brief Formats CreateFailedMissingReqProperties message into JSON
456  *
457  * See header file for more information
458  * @endinternal
459  */
460 nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
461 {
462     return getLog(
463         redfish::registries::base::Index::createFailedMissingReqProperties,
464         std::to_array({arg1}));
465 }
466 
467 void createFailedMissingReqProperties(crow::Response& res,
468                                       std::string_view arg1)
469 {
470     res.result(boost::beast::http::status::bad_request);
471     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
472                      arg1);
473 }
474 
475 /**
476  * @internal
477  * @brief Formats PropertyValueFormatError message into JSON for the specified
478  * property
479  *
480  * See header file for more information
481  * @endinternal
482  */
483 nlohmann::json propertyValueFormatError(std::string_view arg1,
484                                         std::string_view arg2)
485 {
486     return getLog(redfish::registries::base::Index::propertyValueFormatError,
487                   std::to_array({arg1, arg2}));
488 }
489 
490 void propertyValueFormatError(crow::Response& res, std::string_view arg1,
491                               std::string_view arg2)
492 {
493     res.result(boost::beast::http::status::bad_request);
494     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
495 }
496 
497 /**
498  * @internal
499  * @brief Formats PropertyValueNotInList message into JSON for the specified
500  * property
501  *
502  * See header file for more information
503  * @endinternal
504  */
505 nlohmann::json propertyValueNotInList(std::string_view arg1,
506                                       std::string_view arg2)
507 {
508     return getLog(redfish::registries::base::Index::propertyValueNotInList,
509                   std::to_array({arg1, arg2}));
510 }
511 
512 void propertyValueNotInList(crow::Response& res, std::string_view arg1,
513                             std::string_view arg2)
514 {
515     res.result(boost::beast::http::status::bad_request);
516     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
517 }
518 
519 /**
520  * @internal
521  * @brief Formats PropertyValueOutOfRange message into JSON
522  *
523  * See header file for more information
524  * @endinternal
525  */
526 nlohmann::json propertyValueOutOfRange(std::string_view arg1,
527                                        std::string_view arg2)
528 {
529     return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
530                   std::to_array({arg1, arg2}));
531 }
532 
533 void propertyValueOutOfRange(crow::Response& res, std::string_view arg1,
534                              std::string_view arg2)
535 {
536     res.result(boost::beast::http::status::bad_request);
537     addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2));
538 }
539 
540 /**
541  * @internal
542  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
543  *
544  * See header file for more information
545  * @endinternal
546  */
547 nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1)
548 {
549     return getLog(
550         redfish::registries::base::Index::resourceAtUriInUnknownFormat,
551         std::to_array<std::string_view>({arg1.buffer()}));
552 }
553 
554 void resourceAtUriInUnknownFormat(crow::Response& res,
555                                   const boost::urls::url_view& arg1)
556 {
557     res.result(boost::beast::http::status::bad_request);
558     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
559 }
560 
561 /**
562  * @internal
563  * @brief Formats ServiceDisabled message into JSON
564  *
565  * See header file for more information
566  * @endinternal
567  */
568 nlohmann::json serviceDisabled(std::string_view arg1)
569 {
570     return getLog(redfish::registries::base::Index::serviceDisabled,
571                   std::to_array({arg1}));
572 }
573 
574 void serviceDisabled(crow::Response& res, std::string_view arg1)
575 {
576     res.result(boost::beast::http::status::service_unavailable);
577     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
578 }
579 
580 /**
581  * @internal
582  * @brief Formats ServiceInUnknownState message into JSON
583  *
584  * See header file for more information
585  * @endinternal
586  */
587 nlohmann::json serviceInUnknownState(void)
588 {
589     return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
590 }
591 
592 void serviceInUnknownState(crow::Response& res)
593 {
594     res.result(boost::beast::http::status::service_unavailable);
595     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
596 }
597 
598 /**
599  * @internal
600  * @brief Formats EventSubscriptionLimitExceeded message into JSON
601  *
602  * See header file for more information
603  * @endinternal
604  */
605 nlohmann::json eventSubscriptionLimitExceeded(void)
606 {
607     return getLog(
608         redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
609 }
610 
611 void eventSubscriptionLimitExceeded(crow::Response& res)
612 {
613     res.result(boost::beast::http::status::service_unavailable);
614     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
615 }
616 
617 /**
618  * @internal
619  * @brief Formats ActionParameterMissing message into JSON
620  *
621  * See header file for more information
622  * @endinternal
623  */
624 nlohmann::json actionParameterMissing(std::string_view arg1,
625                                       std::string_view arg2)
626 {
627     return getLog(redfish::registries::base::Index::actionParameterMissing,
628                   std::to_array({arg1, arg2}));
629 }
630 
631 void actionParameterMissing(crow::Response& res, std::string_view arg1,
632                             std::string_view arg2)
633 {
634     res.result(boost::beast::http::status::bad_request);
635     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
636 }
637 
638 /**
639  * @internal
640  * @brief Formats StringValueTooLong message into JSON
641  *
642  * See header file for more information
643  * @endinternal
644  */
645 nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
646 {
647     std::string arg2String = std::to_string(arg2);
648     return getLog(redfish::registries::base::Index::stringValueTooLong,
649                   std::to_array({arg1, std::string_view(arg2String)}));
650 }
651 
652 void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
653 {
654     res.result(boost::beast::http::status::bad_request);
655     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
656 }
657 
658 /**
659  * @internal
660  * @brief Formats SessionTerminated message into JSON
661  *
662  * See header file for more information
663  * @endinternal
664  */
665 nlohmann::json sessionTerminated(void)
666 {
667     return getLog(redfish::registries::base::Index::sessionTerminated, {});
668 }
669 
670 void sessionTerminated(crow::Response& res)
671 {
672     res.result(boost::beast::http::status::ok);
673     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
674 }
675 
676 /**
677  * @internal
678  * @brief Formats SubscriptionTerminated message into JSON
679  *
680  * See header file for more information
681  * @endinternal
682  */
683 nlohmann::json subscriptionTerminated(void)
684 {
685     return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
686 }
687 
688 void subscriptionTerminated(crow::Response& res)
689 {
690     res.result(boost::beast::http::status::ok);
691     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
692 }
693 
694 /**
695  * @internal
696  * @brief Formats ResourceTypeIncompatible message into JSON
697  *
698  * See header file for more information
699  * @endinternal
700  */
701 nlohmann::json resourceTypeIncompatible(std::string_view arg1,
702                                         std::string_view arg2)
703 {
704     return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
705                   std::to_array({arg1, arg2}));
706 }
707 
708 void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
709                               std::string_view arg2)
710 {
711     res.result(boost::beast::http::status::bad_request);
712     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
713 }
714 
715 /**
716  * @internal
717  * @brief Formats ResetRequired message into JSON
718  *
719  * See header file for more information
720  * @endinternal
721  */
722 nlohmann::json resetRequired(const boost::urls::url_view& arg1,
723                              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, const 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                                              const 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                                    const 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(const 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,
879                               const boost::urls::url_view& arg1)
880 {
881     res.result(boost::beast::http::status::bad_request);
882     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
883 }
884 
885 /**
886  * @internal
887  * @brief Formats MaximumErrorsExceeded message into JSON
888  *
889  * See header file for more information
890  * @endinternal
891  */
892 nlohmann::json maximumErrorsExceeded(void)
893 {
894     return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
895 }
896 
897 void maximumErrorsExceeded(crow::Response& res)
898 {
899     res.result(boost::beast::http::status::internal_server_error);
900     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
901 }
902 
903 /**
904  * @internal
905  * @brief Formats PreconditionFailed message into JSON
906  *
907  * See header file for more information
908  * @endinternal
909  */
910 nlohmann::json preconditionFailed(void)
911 {
912     return getLog(redfish::registries::base::Index::preconditionFailed, {});
913 }
914 
915 void preconditionFailed(crow::Response& res)
916 {
917     res.result(boost::beast::http::status::precondition_failed);
918     addMessageToErrorJson(res.jsonValue, preconditionFailed());
919 }
920 
921 /**
922  * @internal
923  * @brief Formats PreconditionRequired message into JSON
924  *
925  * See header file for more information
926  * @endinternal
927  */
928 nlohmann::json preconditionRequired(void)
929 {
930     return getLog(redfish::registries::base::Index::preconditionRequired, {});
931 }
932 
933 void preconditionRequired(crow::Response& res)
934 {
935     res.result(boost::beast::http::status::bad_request);
936     addMessageToErrorJson(res.jsonValue, preconditionRequired());
937 }
938 
939 /**
940  * @internal
941  * @brief Formats OperationFailed message into JSON
942  *
943  * See header file for more information
944  * @endinternal
945  */
946 nlohmann::json operationFailed(void)
947 {
948     return getLog(redfish::registries::base::Index::operationFailed, {});
949 }
950 
951 void operationFailed(crow::Response& res)
952 {
953     res.result(boost::beast::http::status::bad_gateway);
954     addMessageToErrorJson(res.jsonValue, operationFailed());
955 }
956 
957 /**
958  * @internal
959  * @brief Formats OperationTimeout message into JSON
960  *
961  * See header file for more information
962  * @endinternal
963  */
964 nlohmann::json operationTimeout(void)
965 {
966     return getLog(redfish::registries::base::Index::operationTimeout, {});
967 }
968 
969 void operationTimeout(crow::Response& res)
970 {
971     res.result(boost::beast::http::status::internal_server_error);
972     addMessageToErrorJson(res.jsonValue, operationTimeout());
973 }
974 
975 /**
976  * @internal
977  * @brief Formats PropertyValueTypeError message into JSON for the specified
978  * property
979  *
980  * See header file for more information
981  * @endinternal
982  */
983 nlohmann::json propertyValueTypeError(std::string_view arg1,
984                                       std::string_view arg2)
985 {
986     return getLog(redfish::registries::base::Index::propertyValueTypeError,
987                   std::to_array({arg1, arg2}));
988 }
989 
990 void propertyValueTypeError(crow::Response& res, std::string_view arg1,
991                             std::string_view arg2)
992 {
993     res.result(boost::beast::http::status::bad_request);
994     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
995 }
996 
997 /**
998  * @internal
999  * @brief Formats ResourceNotFound message into JSONd
1000  *
1001  * See header file for more information
1002  * @endinternal
1003  */
1004 nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
1005 {
1006     return getLog(redfish::registries::base::Index::resourceNotFound,
1007                   std::to_array({arg1, arg2}));
1008 }
1009 
1010 void resourceNotFound(crow::Response& res, std::string_view arg1,
1011                       std::string_view arg2)
1012 {
1013     res.result(boost::beast::http::status::not_found);
1014     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
1015 }
1016 
1017 /**
1018  * @internal
1019  * @brief Formats CouldNotEstablishConnection message into JSON
1020  *
1021  * See header file for more information
1022  * @endinternal
1023  */
1024 nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1)
1025 {
1026     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
1027                   std::to_array<std::string_view>({arg1.buffer()}));
1028 }
1029 
1030 void couldNotEstablishConnection(crow::Response& res,
1031                                  const boost::urls::url_view& arg1)
1032 {
1033     res.result(boost::beast::http::status::not_found);
1034     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
1035 }
1036 
1037 /**
1038  * @internal
1039  * @brief Formats PropertyNotWritable message into JSON for the specified
1040  * property
1041  *
1042  * See header file for more information
1043  * @endinternal
1044  */
1045 nlohmann::json propertyNotWritable(std::string_view arg1)
1046 {
1047     return getLog(redfish::registries::base::Index::propertyNotWritable,
1048                   std::to_array({arg1}));
1049 }
1050 
1051 void propertyNotWritable(crow::Response& res, std::string_view arg1)
1052 {
1053     res.result(boost::beast::http::status::forbidden);
1054     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1055 }
1056 
1057 /**
1058  * @internal
1059  * @brief Formats QueryParameterValueTypeError message into JSON
1060  *
1061  * See header file for more information
1062  * @endinternal
1063  */
1064 nlohmann::json queryParameterValueTypeError(std::string_view arg1,
1065                                             std::string_view arg2)
1066 {
1067     return getLog(
1068         redfish::registries::base::Index::queryParameterValueTypeError,
1069         std::to_array({arg1, arg2}));
1070 }
1071 
1072 void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
1073                                   std::string_view arg2)
1074 {
1075     res.result(boost::beast::http::status::bad_request);
1076     addMessageToErrorJson(res.jsonValue,
1077                           queryParameterValueTypeError(arg1, arg2));
1078 }
1079 
1080 /**
1081  * @internal
1082  * @brief Formats ServiceShuttingDown message into JSON
1083  *
1084  * See header file for more information
1085  * @endinternal
1086  */
1087 nlohmann::json serviceShuttingDown(void)
1088 {
1089     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
1090 }
1091 
1092 void serviceShuttingDown(crow::Response& res)
1093 {
1094     res.result(boost::beast::http::status::service_unavailable);
1095     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1096 }
1097 
1098 /**
1099  * @internal
1100  * @brief Formats ActionParameterDuplicate message into JSON
1101  *
1102  * See header file for more information
1103  * @endinternal
1104  */
1105 nlohmann::json actionParameterDuplicate(std::string_view arg1,
1106                                         std::string_view arg2)
1107 {
1108     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
1109                   std::to_array({arg1, arg2}));
1110 }
1111 
1112 void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
1113                               std::string_view arg2)
1114 {
1115     res.result(boost::beast::http::status::bad_request);
1116     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1117 }
1118 
1119 /**
1120  * @internal
1121  * @brief Formats ActionParameterNotSupported message into JSON
1122  *
1123  * See header file for more information
1124  * @endinternal
1125  */
1126 nlohmann::json actionParameterNotSupported(std::string_view arg1,
1127                                            std::string_view arg2)
1128 {
1129     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
1130                   std::to_array({arg1, arg2}));
1131 }
1132 
1133 void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
1134                                  std::string_view arg2)
1135 {
1136     res.result(boost::beast::http::status::bad_request);
1137     addMessageToErrorJson(res.jsonValue,
1138                           actionParameterNotSupported(arg1, arg2));
1139 }
1140 
1141 /**
1142  * @internal
1143  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1144  *
1145  * See header file for more information
1146  * @endinternal
1147  */
1148 nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1,
1149                                             std::string_view arg2)
1150 {
1151     return getLog(
1152         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
1153         std::to_array<std::string_view>({arg1.buffer(), arg2}));
1154 }
1155 
1156 void sourceDoesNotSupportProtocol(crow::Response& res,
1157                                   const boost::urls::url_view& arg1,
1158                                   std::string_view arg2)
1159 {
1160     res.result(boost::beast::http::status::bad_request);
1161     addMessageToErrorJson(res.jsonValue,
1162                           sourceDoesNotSupportProtocol(arg1, arg2));
1163 }
1164 
1165 /**
1166  * @internal
1167  * @brief Formats StrictAccountTypes message into JSON
1168  *
1169  * See header file for more information
1170  * @endinternal
1171  */
1172 nlohmann::json strictAccountTypes(std::string_view arg1)
1173 {
1174     return getLog(redfish::registries::base::Index::strictAccountTypes,
1175                   std::to_array({arg1}));
1176 }
1177 
1178 void strictAccountTypes(crow::Response& res, std::string_view arg1)
1179 {
1180     res.result(boost::beast::http::status::bad_request);
1181     addMessageToErrorJson(res.jsonValue, strictAccountTypes(arg1));
1182 }
1183 
1184 /**
1185  * @internal
1186  * @brief Formats AccountRemoved message into JSON
1187  *
1188  * See header file for more information
1189  * @endinternal
1190  */
1191 nlohmann::json accountRemoved(void)
1192 {
1193     return getLog(redfish::registries::base::Index::accountRemoved, {});
1194 }
1195 
1196 void accountRemoved(crow::Response& res)
1197 {
1198     res.result(boost::beast::http::status::ok);
1199     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1200 }
1201 
1202 /**
1203  * @internal
1204  * @brief Formats AccessDenied message into JSON
1205  *
1206  * See header file for more information
1207  * @endinternal
1208  */
1209 nlohmann::json accessDenied(const boost::urls::url_view& arg1)
1210 {
1211     return getLog(redfish::registries::base::Index::accessDenied,
1212                   std::to_array<std::string_view>({arg1.buffer()}));
1213 }
1214 
1215 void accessDenied(crow::Response& res, const boost::urls::url_view& arg1)
1216 {
1217     res.result(boost::beast::http::status::forbidden);
1218     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1219 }
1220 
1221 /**
1222  * @internal
1223  * @brief Formats QueryNotSupported message into JSON
1224  *
1225  * See header file for more information
1226  * @endinternal
1227  */
1228 nlohmann::json queryNotSupported(void)
1229 {
1230     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1231 }
1232 
1233 void queryNotSupported(crow::Response& res)
1234 {
1235     res.result(boost::beast::http::status::bad_request);
1236     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1237 }
1238 
1239 /**
1240  * @internal
1241  * @brief Formats CreateLimitReachedForResource message into JSON
1242  *
1243  * See header file for more information
1244  * @endinternal
1245  */
1246 nlohmann::json createLimitReachedForResource(void)
1247 {
1248     return getLog(
1249         redfish::registries::base::Index::createLimitReachedForResource, {});
1250 }
1251 
1252 void createLimitReachedForResource(crow::Response& res)
1253 {
1254     res.result(boost::beast::http::status::bad_request);
1255     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1256 }
1257 
1258 /**
1259  * @internal
1260  * @brief Formats GeneralError message into JSON
1261  *
1262  * See header file for more information
1263  * @endinternal
1264  */
1265 nlohmann::json generalError(void)
1266 {
1267     return getLog(redfish::registries::base::Index::generalError, {});
1268 }
1269 
1270 void generalError(crow::Response& res)
1271 {
1272     res.result(boost::beast::http::status::internal_server_error);
1273     addMessageToErrorJson(res.jsonValue, generalError());
1274 }
1275 
1276 /**
1277  * @internal
1278  * @brief Formats Success message into JSON
1279  *
1280  * See header file for more information
1281  * @endinternal
1282  */
1283 nlohmann::json success(void)
1284 {
1285     return getLog(redfish::registries::base::Index::success, {});
1286 }
1287 
1288 void success(crow::Response& res)
1289 {
1290     // don't set res.result here because success is the default and any
1291     // error should overwrite the default
1292     addMessageToJsonRoot(res.jsonValue, success());
1293 }
1294 
1295 /**
1296  * @internal
1297  * @brief Formats Created message into JSON
1298  *
1299  * See header file for more information
1300  * @endinternal
1301  */
1302 nlohmann::json created(void)
1303 {
1304     return getLog(redfish::registries::base::Index::created, {});
1305 }
1306 
1307 void created(crow::Response& res)
1308 {
1309     res.result(boost::beast::http::status::created);
1310     addMessageToJsonRoot(res.jsonValue, created());
1311 }
1312 
1313 /**
1314  * @internal
1315  * @brief Formats NoOperation message into JSON
1316  *
1317  * See header file for more information
1318  * @endinternal
1319  */
1320 nlohmann::json noOperation(void)
1321 {
1322     return getLog(redfish::registries::base::Index::noOperation, {});
1323 }
1324 
1325 void noOperation(crow::Response& res)
1326 {
1327     res.result(boost::beast::http::status::bad_request);
1328     addMessageToErrorJson(res.jsonValue, noOperation());
1329 }
1330 
1331 /**
1332  * @internal
1333  * @brief Formats PropertyUnknown message into JSON for the specified
1334  * property
1335  *
1336  * See header file for more information
1337  * @endinternal
1338  */
1339 nlohmann::json propertyUnknown(std::string_view arg1)
1340 {
1341     return getLog(redfish::registries::base::Index::propertyUnknown,
1342                   std::to_array({arg1}));
1343 }
1344 
1345 void propertyUnknown(crow::Response& res, std::string_view arg1)
1346 {
1347     res.result(boost::beast::http::status::bad_request);
1348     addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1));
1349 }
1350 
1351 /**
1352  * @internal
1353  * @brief Formats NoValidSession message into JSON
1354  *
1355  * See header file for more information
1356  * @endinternal
1357  */
1358 nlohmann::json noValidSession(void)
1359 {
1360     return getLog(redfish::registries::base::Index::noValidSession, {});
1361 }
1362 
1363 void noValidSession(crow::Response& res)
1364 {
1365     res.result(boost::beast::http::status::forbidden);
1366     addMessageToErrorJson(res.jsonValue, noValidSession());
1367 }
1368 
1369 /**
1370  * @internal
1371  * @brief Formats InvalidObject message into JSON
1372  *
1373  * See header file for more information
1374  * @endinternal
1375  */
1376 nlohmann::json invalidObject(const boost::urls::url_view& arg1)
1377 {
1378     return getLog(redfish::registries::base::Index::invalidObject,
1379                   std::to_array<std::string_view>({arg1.buffer()}));
1380 }
1381 
1382 void invalidObject(crow::Response& res, const boost::urls::url_view& arg1)
1383 {
1384     res.result(boost::beast::http::status::bad_request);
1385     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1386 }
1387 
1388 /**
1389  * @internal
1390  * @brief Formats ResourceInStandby message into JSON
1391  *
1392  * See header file for more information
1393  * @endinternal
1394  */
1395 nlohmann::json resourceInStandby(void)
1396 {
1397     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1398 }
1399 
1400 void resourceInStandby(crow::Response& res)
1401 {
1402     res.result(boost::beast::http::status::service_unavailable);
1403     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1404 }
1405 
1406 /**
1407  * @internal
1408  * @brief Formats ActionParameterValueTypeError message into JSON
1409  *
1410  * See header file for more information
1411  * @endinternal
1412  */
1413 nlohmann::json actionParameterValueTypeError(std::string_view arg1,
1414                                              std::string_view arg2,
1415                                              std::string_view arg3)
1416 {
1417     return getLog(
1418         redfish::registries::base::Index::actionParameterValueTypeError,
1419         std::to_array({arg1, arg2, arg3}));
1420 }
1421 
1422 void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
1423                                    std::string_view arg2, std::string_view arg3)
1424 {
1425     res.result(boost::beast::http::status::bad_request);
1426     addMessageToErrorJson(res.jsonValue,
1427                           actionParameterValueTypeError(arg1, arg2, arg3));
1428 }
1429 
1430 /**
1431  * @internal
1432  * @brief Formats SessionLimitExceeded message into JSON
1433  *
1434  * See header file for more information
1435  * @endinternal
1436  */
1437 nlohmann::json sessionLimitExceeded(void)
1438 {
1439     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1440 }
1441 
1442 void sessionLimitExceeded(crow::Response& res)
1443 {
1444     res.result(boost::beast::http::status::service_unavailable);
1445     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1446 }
1447 
1448 /**
1449  * @internal
1450  * @brief Formats ActionNotSupported message into JSON
1451  *
1452  * See header file for more information
1453  * @endinternal
1454  */
1455 nlohmann::json actionNotSupported(std::string_view arg1)
1456 {
1457     return getLog(redfish::registries::base::Index::actionNotSupported,
1458                   std::to_array({arg1}));
1459 }
1460 
1461 void actionNotSupported(crow::Response& res, std::string_view arg1)
1462 {
1463     res.result(boost::beast::http::status::bad_request);
1464     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1465 }
1466 
1467 /**
1468  * @internal
1469  * @brief Formats InvalidIndex message into JSON
1470  *
1471  * See header file for more information
1472  * @endinternal
1473  */
1474 nlohmann::json invalidIndex(int64_t arg1)
1475 {
1476     std::string arg1Str = std::to_string(arg1);
1477     return getLog(redfish::registries::base::Index::invalidIndex,
1478                   std::to_array<std::string_view>({arg1Str}));
1479 }
1480 
1481 void invalidIndex(crow::Response& res, int64_t arg1)
1482 {
1483     res.result(boost::beast::http::status::bad_request);
1484     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1485 }
1486 
1487 /**
1488  * @internal
1489  * @brief Formats EmptyJSON message into JSON
1490  *
1491  * See header file for more information
1492  * @endinternal
1493  */
1494 nlohmann::json emptyJSON(void)
1495 {
1496     return getLog(redfish::registries::base::Index::emptyJSON, {});
1497 }
1498 
1499 void emptyJSON(crow::Response& res)
1500 {
1501     res.result(boost::beast::http::status::bad_request);
1502     addMessageToErrorJson(res.jsonValue, emptyJSON());
1503 }
1504 
1505 /**
1506  * @internal
1507  * @brief Formats QueryNotSupportedOnResource message into JSON
1508  *
1509  * See header file for more information
1510  * @endinternal
1511  */
1512 nlohmann::json queryNotSupportedOnResource(void)
1513 {
1514     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1515                   {});
1516 }
1517 
1518 void queryNotSupportedOnResource(crow::Response& res)
1519 {
1520     res.result(boost::beast::http::status::bad_request);
1521     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1522 }
1523 
1524 /**
1525  * @internal
1526  * @brief Formats QueryNotSupportedOnOperation message into JSON
1527  *
1528  * See header file for more information
1529  * @endinternal
1530  */
1531 nlohmann::json queryNotSupportedOnOperation(void)
1532 {
1533     return getLog(
1534         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1535 }
1536 
1537 void queryNotSupportedOnOperation(crow::Response& res)
1538 {
1539     res.result(boost::beast::http::status::bad_request);
1540     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1541 }
1542 
1543 /**
1544  * @internal
1545  * @brief Formats QueryCombinationInvalid message into JSON
1546  *
1547  * See header file for more information
1548  * @endinternal
1549  */
1550 nlohmann::json queryCombinationInvalid(void)
1551 {
1552     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1553                   {});
1554 }
1555 
1556 void queryCombinationInvalid(crow::Response& res)
1557 {
1558     res.result(boost::beast::http::status::bad_request);
1559     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1560 }
1561 
1562 /**
1563  * @internal
1564  * @brief Formats InsufficientPrivilege message into JSON
1565  *
1566  * See header file for more information
1567  * @endinternal
1568  */
1569 nlohmann::json insufficientPrivilege(void)
1570 {
1571     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1572 }
1573 
1574 void insufficientPrivilege(crow::Response& res)
1575 {
1576     res.result(boost::beast::http::status::forbidden);
1577     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1578 }
1579 
1580 /**
1581  * @internal
1582  * @brief Formats PropertyValueModified message into JSON
1583  *
1584  * See header file for more information
1585  * @endinternal
1586  */
1587 nlohmann::json propertyValueModified(std::string_view arg1,
1588                                      std::string_view arg2)
1589 {
1590     return getLog(redfish::registries::base::Index::propertyValueModified,
1591                   std::to_array({arg1, arg2}));
1592 }
1593 
1594 void propertyValueModified(crow::Response& res, std::string_view arg1,
1595                            std::string_view arg2)
1596 {
1597     res.result(boost::beast::http::status::ok);
1598     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1599 }
1600 
1601 /**
1602  * @internal
1603  * @brief Formats AccountNotModified message into JSON
1604  *
1605  * See header file for more information
1606  * @endinternal
1607  */
1608 nlohmann::json accountNotModified(void)
1609 {
1610     return getLog(redfish::registries::base::Index::accountNotModified, {});
1611 }
1612 
1613 void accountNotModified(crow::Response& res)
1614 {
1615     res.result(boost::beast::http::status::bad_request);
1616     addMessageToErrorJson(res.jsonValue, accountNotModified());
1617 }
1618 
1619 /**
1620  * @internal
1621  * @brief Formats QueryParameterValueFormatError message into JSON
1622  *
1623  * See header file for more information
1624  * @endinternal
1625  */
1626 nlohmann::json queryParameterValueFormatError(std::string_view arg1,
1627                                               std::string_view arg2)
1628 {
1629     return getLog(
1630         redfish::registries::base::Index::queryParameterValueFormatError,
1631         std::to_array({arg1, arg2}));
1632 }
1633 
1634 void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
1635                                     std::string_view arg2)
1636 {
1637     res.result(boost::beast::http::status::bad_request);
1638     addMessageToErrorJson(res.jsonValue,
1639                           queryParameterValueFormatError(arg1, arg2));
1640 }
1641 
1642 /**
1643  * @internal
1644  * @brief Formats PropertyMissing message into JSON for the specified
1645  * property
1646  *
1647  * See header file for more information
1648  * @endinternal
1649  */
1650 nlohmann::json propertyMissing(std::string_view arg1)
1651 {
1652     return getLog(redfish::registries::base::Index::propertyMissing,
1653                   std::to_array({arg1}));
1654 }
1655 
1656 void propertyMissing(crow::Response& res, std::string_view arg1)
1657 {
1658     res.result(boost::beast::http::status::bad_request);
1659     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1660 }
1661 
1662 /**
1663  * @internal
1664  * @brief Formats ResourceExhaustion message into JSON
1665  *
1666  * See header file for more information
1667  * @endinternal
1668  */
1669 nlohmann::json resourceExhaustion(std::string_view arg1)
1670 {
1671     return getLog(redfish::registries::base::Index::resourceExhaustion,
1672                   std::to_array({arg1}));
1673 }
1674 
1675 void resourceExhaustion(crow::Response& res, std::string_view arg1)
1676 {
1677     res.result(boost::beast::http::status::service_unavailable);
1678     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1679 }
1680 
1681 /**
1682  * @internal
1683  * @brief Formats AccountModified message into JSON
1684  *
1685  * See header file for more information
1686  * @endinternal
1687  */
1688 nlohmann::json accountModified(void)
1689 {
1690     return getLog(redfish::registries::base::Index::accountModified, {});
1691 }
1692 
1693 void accountModified(crow::Response& res)
1694 {
1695     res.result(boost::beast::http::status::ok);
1696     addMessageToErrorJson(res.jsonValue, accountModified());
1697 }
1698 
1699 /**
1700  * @internal
1701  * @brief Formats QueryParameterOutOfRange message into JSON
1702  *
1703  * See header file for more information
1704  * @endinternal
1705  */
1706 nlohmann::json queryParameterOutOfRange(std::string_view arg1,
1707                                         std::string_view arg2,
1708                                         std::string_view arg3)
1709 {
1710     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
1711                   std::to_array({arg1, arg2, arg3}));
1712 }
1713 
1714 void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
1715                               std::string_view arg2, std::string_view arg3)
1716 {
1717     res.result(boost::beast::http::status::bad_request);
1718     addMessageToErrorJson(res.jsonValue,
1719                           queryParameterOutOfRange(arg1, arg2, arg3));
1720 }
1721 
1722 nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1)
1723 {
1724     return getLog(redfish::registries::base::Index::passwordChangeRequired,
1725                   std::to_array<std::string_view>({arg1.buffer()}));
1726 }
1727 
1728 /**
1729  * @internal
1730  * @brief Formats PasswordChangeRequired message into JSON
1731  *
1732  * See header file for more information
1733  * @endinternal
1734  */
1735 void passwordChangeRequired(crow::Response& res,
1736                             const 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 void invalidUpload(crow::Response& res, std::string_view arg1,
1778                    std::string_view arg2)
1779 {
1780     res.result(boost::beast::http::status::bad_request);
1781     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
1782 }
1783 
1784 /**
1785  * @internal
1786  * @brief Formats Invalid File message into JSON
1787  *
1788  * See header file for more information
1789  * @endinternal
1790  */
1791 nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
1792 {
1793     std::string msg = "Invalid file uploaded to ";
1794     msg += arg1;
1795     msg += ": ";
1796     msg += arg2;
1797     msg += ".";
1798 
1799     nlohmann::json::object_t ret;
1800     ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message";
1801     ret["MessageId"] = "OpenBMC.0.2.InvalidUpload";
1802     ret["Message"] = std::move(msg);
1803     nlohmann::json::array_t args;
1804     args.push_back(arg1);
1805     args.push_back(arg2);
1806     ret["MessageArgs"] = std::move(args);
1807     ret["MessageSeverity"] = "Warning";
1808     ret["Resolution"] = "None.";
1809     return ret;
1810 }
1811 
1812 } // namespace messages
1813 
1814 } // namespace redfish
1815