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