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