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