xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision d9fcfcc174eb0e195105f3ba2e95456db29a4132)
1f4c4dcf4SKowalski, Kamil /*
2f4c4dcf4SKowalski, Kamil // Copyright (c) 2018 Intel Corporation
3f4c4dcf4SKowalski, Kamil //
4f4c4dcf4SKowalski, Kamil // Licensed under the Apache License, Version 2.0 (the "License");
5f4c4dcf4SKowalski, Kamil // you may not use this file except in compliance with the License.
6f4c4dcf4SKowalski, Kamil // You may obtain a copy of the License at
7f4c4dcf4SKowalski, Kamil //
8f4c4dcf4SKowalski, Kamil //      http://www.apache.org/licenses/LICENSE-2.0
9f4c4dcf4SKowalski, Kamil //
10f4c4dcf4SKowalski, Kamil // Unless required by applicable law or agreed to in writing, software
11f4c4dcf4SKowalski, Kamil // distributed under the License is distributed on an "AS IS" BASIS,
12f4c4dcf4SKowalski, Kamil // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13f4c4dcf4SKowalski, Kamil // See the License for the specific language governing permissions and
14f4c4dcf4SKowalski, Kamil // limitations under the License.
15f4c4dcf4SKowalski, Kamil */
160442ef92SNan Zhou #include "error_messages.hpp"
179ea15c35SEd Tanous 
180442ef92SNan Zhou #include "http_response.hpp"
190442ef92SNan Zhou #include "logging.hpp"
200442ef92SNan Zhou #include "registries.hpp"
210442ef92SNan Zhou #include "registries/base_message_registry.hpp"
220442ef92SNan Zhou 
230442ef92SNan Zhou #include <boost/beast/http/field.hpp>
249ea15c35SEd Tanous #include <boost/beast/http/status.hpp>
25faf100f9SEd Tanous #include <nlohmann/json.hpp>
26f4c4dcf4SKowalski, Kamil 
271668ce6dSEd Tanous #include <array>
280442ef92SNan Zhou #include <cstddef>
29d85418e3SPatrick Williams #include <source_location>
300442ef92SNan Zhou #include <span>
310442ef92SNan Zhou #include <string>
320442ef92SNan Zhou #include <utility>
330442ef92SNan Zhou 
340442ef92SNan Zhou // IWYU pragma: no_include <stddef.h>
351668ce6dSEd Tanous 
361abe55efSEd Tanous namespace redfish
371abe55efSEd Tanous {
381abe55efSEd Tanous 
391abe55efSEd Tanous namespace messages
401abe55efSEd Tanous {
41f4c4dcf4SKowalski, Kamil 
42f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target,
431abe55efSEd Tanous                                   const nlohmann::json& message)
441abe55efSEd Tanous {
45f4c4dcf4SKowalski, Kamil     auto& error = target["error"];
46f4c4dcf4SKowalski, Kamil 
471abe55efSEd Tanous     // If this is the first error message, fill in the information from the
481abe55efSEd Tanous     // first error message to the top level struct
491abe55efSEd Tanous     if (!error.is_object())
501abe55efSEd Tanous     {
51c074230bSJason M. Bills         auto messageIdIterator = message.find("MessageId");
52c074230bSJason M. Bills         if (messageIdIterator == message.end())
531abe55efSEd Tanous         {
541abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
551abe55efSEd Tanous                 << "Attempt to add error message without MessageId";
56f4c4dcf4SKowalski, Kamil             return;
57f4c4dcf4SKowalski, Kamil         }
58f4c4dcf4SKowalski, Kamil 
59c074230bSJason M. Bills         auto messageFieldIterator = message.find("Message");
60c074230bSJason M. Bills         if (messageFieldIterator == message.end())
611abe55efSEd Tanous         {
621abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
631abe55efSEd Tanous                 << "Attempt to add error message without Message";
64f4c4dcf4SKowalski, Kamil             return;
65f4c4dcf4SKowalski, Kamil         }
661476687dSEd Tanous         error["code"] = *messageIdIterator;
671476687dSEd Tanous         error["message"] = *messageFieldIterator;
681abe55efSEd Tanous     }
691abe55efSEd Tanous     else
701abe55efSEd Tanous     {
71f4c4dcf4SKowalski, Kamil         // More than 1 error occurred, so the message has to be generic
7255c7b7a2SEd Tanous         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
73cc9139ecSJason M. Bills         error["message"] = "A general error has occurred. See Resolution for "
74cc9139ecSJason M. Bills                            "information on how to resolve the error.";
75f4c4dcf4SKowalski, Kamil     }
76f4c4dcf4SKowalski, Kamil 
773590bd1dSNan Zhou     // This check could technically be done in the default construction
78f4c4dcf4SKowalski, Kamil     // branch above, but because we need the pointer to the extended info field
79f4c4dcf4SKowalski, Kamil     // anyway, it's more efficient to do it here.
80c074230bSJason M. Bills     auto& extendedInfo = error[messages::messageAnnotation];
81c074230bSJason M. Bills     if (!extendedInfo.is_array())
821abe55efSEd Tanous     {
83c074230bSJason M. Bills         extendedInfo = nlohmann::json::array();
84f4c4dcf4SKowalski, Kamil     }
85f4c4dcf4SKowalski, Kamil 
86c074230bSJason M. Bills     extendedInfo.push_back(message);
87f4c4dcf4SKowalski, Kamil }
88f4c4dcf4SKowalski, Kamil 
893590bd1dSNan Zhou void moveErrorsToErrorJson(nlohmann::json& target, nlohmann::json& source)
903590bd1dSNan Zhou {
913590bd1dSNan Zhou     if (!source.is_object())
923590bd1dSNan Zhou     {
933590bd1dSNan Zhou         return;
943590bd1dSNan Zhou     }
953590bd1dSNan Zhou     auto errorIt = source.find("error");
963590bd1dSNan Zhou     if (errorIt == source.end())
973590bd1dSNan Zhou     {
983590bd1dSNan Zhou         // caller puts error message in root
993590bd1dSNan Zhou         messages::addMessageToErrorJson(target, source);
1003590bd1dSNan Zhou         source.clear();
1013590bd1dSNan Zhou         return;
1023590bd1dSNan Zhou     }
1033590bd1dSNan Zhou     auto extendedInfoIt = errorIt->find(messages::messageAnnotation);
1043590bd1dSNan Zhou     if (extendedInfoIt == errorIt->end())
1053590bd1dSNan Zhou     {
1063590bd1dSNan Zhou         return;
1073590bd1dSNan Zhou     }
1083590bd1dSNan Zhou     const nlohmann::json::array_t* extendedInfo =
1093590bd1dSNan Zhou         (*extendedInfoIt).get_ptr<const nlohmann::json::array_t*>();
1103590bd1dSNan Zhou     if (extendedInfo == nullptr)
1113590bd1dSNan Zhou     {
1123590bd1dSNan Zhou         source.erase(errorIt);
1133590bd1dSNan Zhou         return;
1143590bd1dSNan Zhou     }
1153590bd1dSNan Zhou     for (const nlohmann::json& message : *extendedInfo)
1163590bd1dSNan Zhou     {
1173590bd1dSNan Zhou         addMessageToErrorJson(target, message);
1183590bd1dSNan Zhou     }
1193590bd1dSNan Zhou     source.erase(errorIt);
1203590bd1dSNan Zhou }
1213590bd1dSNan Zhou 
122f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target,
123f12894f8SJason M. Bills                                  const nlohmann::json& message)
1241abe55efSEd Tanous {
1251abe55efSEd Tanous     if (!target[messages::messageAnnotation].is_array())
1261abe55efSEd Tanous     {
127f4c4dcf4SKowalski, Kamil         // Force object to be an array
12855c7b7a2SEd Tanous         target[messages::messageAnnotation] = nlohmann::json::array();
129f4c4dcf4SKowalski, Kamil     }
130f4c4dcf4SKowalski, Kamil 
13155c7b7a2SEd Tanous     target[messages::messageAnnotation].push_back(message);
132f4c4dcf4SKowalski, Kamil }
133f4c4dcf4SKowalski, Kamil 
134f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target,
135f12894f8SJason M. Bills                              const nlohmann::json& message,
1361668ce6dSEd Tanous                              std::string_view fieldPath)
1371abe55efSEd Tanous {
1381668ce6dSEd Tanous     std::string extendedInfo(fieldPath);
1391668ce6dSEd Tanous     extendedInfo += messages::messageAnnotation;
140f4c4dcf4SKowalski, Kamil 
1411668ce6dSEd Tanous     nlohmann::json& field = target[extendedInfo];
1421668ce6dSEd Tanous     if (!field.is_array())
1431abe55efSEd Tanous     {
144f4c4dcf4SKowalski, Kamil         // Force object to be an array
1451668ce6dSEd Tanous         field = nlohmann::json::array();
146f4c4dcf4SKowalski, Kamil     }
147f4c4dcf4SKowalski, Kamil 
148f4c4dcf4SKowalski, Kamil     // Object exists and it is an array so we can just push in the message
1491668ce6dSEd Tanous     field.push_back(message);
150f4c4dcf4SKowalski, Kamil }
151f4c4dcf4SKowalski, Kamil 
152f7725d79SEd Tanous static nlohmann::json getLog(redfish::registries::base::Index name,
153b6cd31e1SEd Tanous                              std::span<const std::string_view> args)
154b6cd31e1SEd Tanous {
155b6cd31e1SEd Tanous     size_t index = static_cast<size_t>(name);
156fffb8c1fSEd Tanous     if (index >= redfish::registries::base::registry.size())
157b6cd31e1SEd Tanous     {
158b6cd31e1SEd Tanous         return {};
159b6cd31e1SEd Tanous     }
16065e4f1f7SEd Tanous     return getLogFromRegistry(redfish::registries::base::header,
16165e4f1f7SEd Tanous                               redfish::registries::base::registry, index, args);
162b6cd31e1SEd Tanous }
163b6cd31e1SEd Tanous 
164f4c4dcf4SKowalski, Kamil /**
165f4c4dcf4SKowalski, Kamil  * @internal
166f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
167f4c4dcf4SKowalski, Kamil  *
168f4c4dcf4SKowalski, Kamil  * See header file for more information
169f4c4dcf4SKowalski, Kamil  * @endinternal
170f4c4dcf4SKowalski, Kamil  */
171*d9fcfcc1SEd Tanous nlohmann::json resourceInUse()
1721abe55efSEd Tanous {
173fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInUse, {});
174b5c07418SJames Feist }
175b5c07418SJames Feist 
176b5c07418SJames Feist void resourceInUse(crow::Response& res)
177b5c07418SJames Feist {
178b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
179b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
180f4c4dcf4SKowalski, Kamil }
181f4c4dcf4SKowalski, Kamil 
182f4c4dcf4SKowalski, Kamil /**
183f4c4dcf4SKowalski, Kamil  * @internal
184f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
185f4c4dcf4SKowalski, Kamil  *
186f4c4dcf4SKowalski, Kamil  * See header file for more information
187f4c4dcf4SKowalski, Kamil  * @endinternal
188f4c4dcf4SKowalski, Kamil  */
189*d9fcfcc1SEd Tanous nlohmann::json malformedJSON()
1901abe55efSEd Tanous {
191fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::malformedJSON, {});
192b5c07418SJames Feist }
193b5c07418SJames Feist 
194b5c07418SJames Feist void malformedJSON(crow::Response& res)
195b5c07418SJames Feist {
196b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
197b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
198f4c4dcf4SKowalski, Kamil }
199f4c4dcf4SKowalski, Kamil 
200f4c4dcf4SKowalski, Kamil /**
201f4c4dcf4SKowalski, Kamil  * @internal
202f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
203f4c4dcf4SKowalski, Kamil  *
204f4c4dcf4SKowalski, Kamil  * See header file for more information
205f4c4dcf4SKowalski, Kamil  * @endinternal
206f4c4dcf4SKowalski, Kamil  */
207d9f466b3SEd Tanous nlohmann::json resourceMissingAtURI(boost::urls::url_view arg1)
2081abe55efSEd Tanous {
209079360aeSEd Tanous     std::array<std::string_view, 1> args{arg1.buffer()};
210fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceMissingAtURI, args);
211b5c07418SJames Feist }
212b5c07418SJames Feist 
213d9f466b3SEd Tanous void resourceMissingAtURI(crow::Response& res, boost::urls::url_view arg1)
214b5c07418SJames Feist {
215b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
216b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
217f4c4dcf4SKowalski, Kamil }
218f4c4dcf4SKowalski, Kamil 
219f4c4dcf4SKowalski, Kamil /**
220f4c4dcf4SKowalski, Kamil  * @internal
221f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
222f4c4dcf4SKowalski, Kamil  *
223f4c4dcf4SKowalski, Kamil  * See header file for more information
224f4c4dcf4SKowalski, Kamil  * @endinternal
225f4c4dcf4SKowalski, Kamil  */
22695b3ad73SEd Tanous nlohmann::json actionParameterValueFormatError(const nlohmann::json& arg1,
2271668ce6dSEd Tanous                                                std::string_view arg2,
2281668ce6dSEd Tanous                                                std::string_view arg3)
2291abe55efSEd Tanous {
23095b3ad73SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
23195b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
232fffb8c1fSEd Tanous     return getLog(
233fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueFormatError,
23495b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2, arg3}));
235b5c07418SJames Feist }
236b5c07418SJames Feist 
23795b3ad73SEd Tanous void actionParameterValueFormatError(crow::Response& res,
23895b3ad73SEd Tanous                                      const nlohmann::json& arg1,
2391668ce6dSEd Tanous                                      std::string_view arg2,
2401668ce6dSEd Tanous                                      std::string_view arg3)
241b5c07418SJames Feist {
242b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
243b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
244b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
245f4c4dcf4SKowalski, Kamil }
246f4c4dcf4SKowalski, Kamil 
247f4c4dcf4SKowalski, Kamil /**
248f4c4dcf4SKowalski, Kamil  * @internal
2494ef82a15SAlex Schendel  * @brief Formats ActionParameterValueNotInList message into JSON
2504ef82a15SAlex Schendel  *
2514ef82a15SAlex Schendel  * See header file for more information
2524ef82a15SAlex Schendel  * @endinternal
2534ef82a15SAlex Schendel  */
2544ef82a15SAlex Schendel nlohmann::json actionParameterValueNotInList(std::string_view arg1,
2554ef82a15SAlex Schendel                                              std::string_view arg2,
2564ef82a15SAlex Schendel                                              std::string_view arg3)
2574ef82a15SAlex Schendel {
2584ef82a15SAlex Schendel     return getLog(
2594ef82a15SAlex Schendel         redfish::registries::base::Index::actionParameterValueNotInList,
2604ef82a15SAlex Schendel         std::to_array({arg1, arg2, arg3}));
2614ef82a15SAlex Schendel }
2624ef82a15SAlex Schendel 
2634ef82a15SAlex Schendel void actionParameterValueNotInList(crow::Response& res, std::string_view arg1,
2644ef82a15SAlex Schendel                                    std::string_view arg2, std::string_view arg3)
2654ef82a15SAlex Schendel {
2664ef82a15SAlex Schendel     res.result(boost::beast::http::status::bad_request);
2674ef82a15SAlex Schendel     addMessageToErrorJson(res.jsonValue,
2684ef82a15SAlex Schendel                           actionParameterValueNotInList(arg1, arg2, arg3));
2694ef82a15SAlex Schendel }
2704ef82a15SAlex Schendel 
2714ef82a15SAlex Schendel /**
2724ef82a15SAlex Schendel  * @internal
273f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
274f4c4dcf4SKowalski, Kamil  *
275f4c4dcf4SKowalski, Kamil  * See header file for more information
276f4c4dcf4SKowalski, Kamil  * @endinternal
277f4c4dcf4SKowalski, Kamil  */
278*d9fcfcc1SEd Tanous nlohmann::json internalError()
2791abe55efSEd Tanous {
280fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::internalError, {});
281b5c07418SJames Feist }
282b5c07418SJames Feist 
283d85418e3SPatrick Williams void internalError(crow::Response& res, const std::source_location location)
284b5c07418SJames Feist {
285df5415fcSEd Tanous     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
286df5415fcSEd Tanous                         << location.line() << ":" << location.column() << ") `"
287df5415fcSEd Tanous                         << location.function_name() << "`: ";
288b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
289b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
290f12894f8SJason M. Bills }
291f12894f8SJason M. Bills 
292f12894f8SJason M. Bills /**
293f12894f8SJason M. Bills  * @internal
294f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
295f4c4dcf4SKowalski, Kamil  *
296f4c4dcf4SKowalski, Kamil  * See header file for more information
297f4c4dcf4SKowalski, Kamil  * @endinternal
298f4c4dcf4SKowalski, Kamil  */
299*d9fcfcc1SEd Tanous nlohmann::json unrecognizedRequestBody()
3001abe55efSEd Tanous {
301fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::unrecognizedRequestBody,
302fffb8c1fSEd Tanous                   {});
303b5c07418SJames Feist }
304b5c07418SJames Feist 
305b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
306b5c07418SJames Feist {
307b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
308b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
309f4c4dcf4SKowalski, Kamil }
310f4c4dcf4SKowalski, Kamil 
311f4c4dcf4SKowalski, Kamil /**
312f4c4dcf4SKowalski, Kamil  * @internal
313f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
314f4c4dcf4SKowalski, Kamil  *
315f4c4dcf4SKowalski, Kamil  * See header file for more information
316f4c4dcf4SKowalski, Kamil  * @endinternal
317f4c4dcf4SKowalski, Kamil  */
318d9f466b3SEd Tanous nlohmann::json resourceAtUriUnauthorized(boost::urls::url_view arg1,
3191668ce6dSEd Tanous                                          std::string_view arg2)
3201abe55efSEd Tanous {
321079360aeSEd Tanous     return getLog(redfish::registries::base::Index::resourceAtUriUnauthorized,
322079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer(), arg2}));
323b5c07418SJames Feist }
324b5c07418SJames Feist 
325d9f466b3SEd Tanous void resourceAtUriUnauthorized(crow::Response& res, boost::urls::url_view arg1,
3261668ce6dSEd Tanous                                std::string_view arg2)
327b5c07418SJames Feist {
328b5c07418SJames Feist     res.result(boost::beast::http::status::unauthorized);
329b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
330f4c4dcf4SKowalski, Kamil }
331f4c4dcf4SKowalski, Kamil 
332f4c4dcf4SKowalski, Kamil /**
333f4c4dcf4SKowalski, Kamil  * @internal
334f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterUnknown message into JSON
335f4c4dcf4SKowalski, Kamil  *
336f4c4dcf4SKowalski, Kamil  * See header file for more information
337f4c4dcf4SKowalski, Kamil  * @endinternal
338f4c4dcf4SKowalski, Kamil  */
3391668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1,
3401668ce6dSEd Tanous                                       std::string_view arg2)
341b5c07418SJames Feist {
342fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterUnknown,
3431668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
344b5c07418SJames Feist }
345b5c07418SJames Feist 
3461668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1,
3471668ce6dSEd Tanous                             std::string_view arg2)
3481abe55efSEd Tanous {
349f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
350b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
351f4c4dcf4SKowalski, Kamil }
352f4c4dcf4SKowalski, Kamil 
353f4c4dcf4SKowalski, Kamil /**
354f4c4dcf4SKowalski, Kamil  * @internal
355f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceCannotBeDeleted message into JSON
356f4c4dcf4SKowalski, Kamil  *
357f4c4dcf4SKowalski, Kamil  * See header file for more information
358f4c4dcf4SKowalski, Kamil  * @endinternal
359f4c4dcf4SKowalski, Kamil  */
360*d9fcfcc1SEd Tanous nlohmann::json resourceCannotBeDeleted()
3611abe55efSEd Tanous {
362fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCannotBeDeleted,
363fffb8c1fSEd Tanous                   {});
364b5c07418SJames Feist }
365b5c07418SJames Feist 
366b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res)
367b5c07418SJames Feist {
36844c70412SEd Tanous     res.result(boost::beast::http::status::method_not_allowed);
369b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
370f4c4dcf4SKowalski, Kamil }
371f4c4dcf4SKowalski, Kamil 
372f4c4dcf4SKowalski, Kamil /**
373f4c4dcf4SKowalski, Kamil  * @internal
374f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyDuplicate message into JSON
375f4c4dcf4SKowalski, Kamil  *
376f4c4dcf4SKowalski, Kamil  * See header file for more information
377f4c4dcf4SKowalski, Kamil  * @endinternal
378f4c4dcf4SKowalski, Kamil  */
3791668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1)
3801abe55efSEd Tanous {
381fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyDuplicate,
3821668ce6dSEd Tanous                   std::to_array({arg1}));
383b5c07418SJames Feist }
384b5c07418SJames Feist 
3851668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1)
386b5c07418SJames Feist {
387b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
388b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
389f4c4dcf4SKowalski, Kamil }
390f4c4dcf4SKowalski, Kamil 
391f4c4dcf4SKowalski, Kamil /**
392f4c4dcf4SKowalski, Kamil  * @internal
393f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
394f4c4dcf4SKowalski, Kamil  *
395f4c4dcf4SKowalski, Kamil  * See header file for more information
396f4c4dcf4SKowalski, Kamil  * @endinternal
397f4c4dcf4SKowalski, Kamil  */
3981668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
3991abe55efSEd Tanous {
400b6cd31e1SEd Tanous     return getLog(
401fffb8c1fSEd Tanous         redfish::registries::base::Index::serviceTemporarilyUnavailable,
4021668ce6dSEd Tanous         std::to_array({arg1}));
403b5c07418SJames Feist }
404b5c07418SJames Feist 
4051668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
406b5c07418SJames Feist {
407d9f6c621SEd Tanous     res.addHeader(boost::beast::http::field::retry_after, arg1);
408b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
409b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
410f4c4dcf4SKowalski, Kamil }
411f4c4dcf4SKowalski, Kamil 
412f4c4dcf4SKowalski, Kamil /**
413f4c4dcf4SKowalski, Kamil  * @internal
414f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
415f4c4dcf4SKowalski, Kamil  *
416f4c4dcf4SKowalski, Kamil  * See header file for more information
417f4c4dcf4SKowalski, Kamil  * @endinternal
418f4c4dcf4SKowalski, Kamil  */
4191668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1,
4201668ce6dSEd Tanous                                      std::string_view arg2,
4211668ce6dSEd Tanous                                      std::string_view arg3)
4221abe55efSEd Tanous {
423fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceAlreadyExists,
4241668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
425b5c07418SJames Feist }
426b5c07418SJames Feist 
4271668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
4281668ce6dSEd Tanous                            std::string_view arg2, std::string_view arg3)
429b5c07418SJames Feist {
430b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
431b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
432a08b46ccSJason M. Bills                      arg2);
433f4c4dcf4SKowalski, Kamil }
434f4c4dcf4SKowalski, Kamil 
435f4c4dcf4SKowalski, Kamil /**
436f4c4dcf4SKowalski, Kamil  * @internal
437f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
438f4c4dcf4SKowalski, Kamil  *
439f4c4dcf4SKowalski, Kamil  * See header file for more information
440f4c4dcf4SKowalski, Kamil  * @endinternal
441f4c4dcf4SKowalski, Kamil  */
442*d9fcfcc1SEd Tanous nlohmann::json accountForSessionNoLongerExists()
4431abe55efSEd Tanous {
444fffb8c1fSEd Tanous     return getLog(
445fffb8c1fSEd Tanous         redfish::registries::base::Index::accountForSessionNoLongerExists, {});
446b5c07418SJames Feist }
447b5c07418SJames Feist 
448b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
449b5c07418SJames Feist {
450b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
451b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
452f4c4dcf4SKowalski, Kamil }
453f4c4dcf4SKowalski, Kamil 
454f4c4dcf4SKowalski, Kamil /**
455f4c4dcf4SKowalski, Kamil  * @internal
456f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
457f4c4dcf4SKowalski, Kamil  *
458f4c4dcf4SKowalski, Kamil  * See header file for more information
459f4c4dcf4SKowalski, Kamil  * @endinternal
460f4c4dcf4SKowalski, Kamil  */
4611668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
4621abe55efSEd Tanous {
463fffb8c1fSEd Tanous     return getLog(
464fffb8c1fSEd Tanous         redfish::registries::base::Index::createFailedMissingReqProperties,
4651668ce6dSEd Tanous         std::to_array({arg1}));
466b5c07418SJames Feist }
467b5c07418SJames Feist 
468b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
4691668ce6dSEd Tanous                                       std::string_view arg1)
470b5c07418SJames Feist {
471b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
472b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
473a08b46ccSJason M. Bills                      arg1);
474f12894f8SJason M. Bills }
475f12894f8SJason M. Bills 
476f12894f8SJason M. Bills /**
477f12894f8SJason M. Bills  * @internal
478f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
479f12894f8SJason M. Bills  * property
480f12894f8SJason M. Bills  *
481f12894f8SJason M. Bills  * See header file for more information
482f12894f8SJason M. Bills  * @endinternal
483f12894f8SJason M. Bills  */
484f818b04dSEd Tanous nlohmann::json propertyValueFormatError(const nlohmann::json& arg1,
4851668ce6dSEd Tanous                                         std::string_view arg2)
486f12894f8SJason M. Bills {
487f818b04dSEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
488f818b04dSEd Tanous                                     nlohmann::json::error_handler_t::replace);
489fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueFormatError,
490f818b04dSEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
491b5c07418SJames Feist }
492b5c07418SJames Feist 
493f818b04dSEd Tanous void propertyValueFormatError(crow::Response& res, const nlohmann::json& arg1,
4941668ce6dSEd Tanous                               std::string_view arg2)
495b5c07418SJames Feist {
496b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
497b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
498f12894f8SJason M. Bills }
499f12894f8SJason M. Bills 
500f12894f8SJason M. Bills /**
501f12894f8SJason M. Bills  * @internal
502f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
503f12894f8SJason M. Bills  * property
504f12894f8SJason M. Bills  *
505f12894f8SJason M. Bills  * See header file for more information
506f12894f8SJason M. Bills  * @endinternal
507f12894f8SJason M. Bills  */
508e2616cc5SEd Tanous 
509e2616cc5SEd Tanous nlohmann::json propertyValueNotInList(const nlohmann::json& arg1,
5101668ce6dSEd Tanous                                       std::string_view arg2)
511f12894f8SJason M. Bills {
512e2616cc5SEd Tanous     std::string arg1Str = arg1.dump(-1, ' ', true,
513e2616cc5SEd Tanous                                     nlohmann::json::error_handler_t::replace);
514fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueNotInList,
515e2616cc5SEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
516b5c07418SJames Feist }
517b5c07418SJames Feist 
518e2616cc5SEd Tanous void propertyValueNotInList(crow::Response& res, const nlohmann::json& arg1,
5191668ce6dSEd Tanous                             std::string_view arg2)
520b5c07418SJames Feist {
521b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
522b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
523f4c4dcf4SKowalski, Kamil }
524f4c4dcf4SKowalski, Kamil 
525f4c4dcf4SKowalski, Kamil /**
526f4c4dcf4SKowalski, Kamil  * @internal
527227a2b0aSJiaqing Zhao  * @brief Formats PropertyValueOutOfRange message into JSON
528227a2b0aSJiaqing Zhao  *
529227a2b0aSJiaqing Zhao  * See header file for more information
530227a2b0aSJiaqing Zhao  * @endinternal
531227a2b0aSJiaqing Zhao  */
53295b3ad73SEd Tanous nlohmann::json propertyValueOutOfRange(const nlohmann::json& arg1,
533227a2b0aSJiaqing Zhao                                        std::string_view arg2)
534227a2b0aSJiaqing Zhao {
53595b3ad73SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
53695b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
537227a2b0aSJiaqing Zhao     return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
53895b3ad73SEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
539227a2b0aSJiaqing Zhao }
540227a2b0aSJiaqing Zhao 
54195b3ad73SEd Tanous void propertyValueOutOfRange(crow::Response& res, const nlohmann::json& arg1,
542227a2b0aSJiaqing Zhao                              std::string_view arg2)
543227a2b0aSJiaqing Zhao {
544227a2b0aSJiaqing Zhao     res.result(boost::beast::http::status::bad_request);
545227a2b0aSJiaqing Zhao     addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2));
546227a2b0aSJiaqing Zhao }
547227a2b0aSJiaqing Zhao 
548227a2b0aSJiaqing Zhao /**
549227a2b0aSJiaqing Zhao  * @internal
550f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
551f4c4dcf4SKowalski, Kamil  *
552f4c4dcf4SKowalski, Kamil  * See header file for more information
553f4c4dcf4SKowalski, Kamil  * @endinternal
554f4c4dcf4SKowalski, Kamil  */
555d9f466b3SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(boost::urls::url_view arg1)
5561abe55efSEd Tanous {
557b6cd31e1SEd Tanous     return getLog(
558fffb8c1fSEd Tanous         redfish::registries::base::Index::resourceAtUriInUnknownFormat,
559079360aeSEd Tanous         std::to_array<std::string_view>({arg1.buffer()}));
560b5c07418SJames Feist }
561b5c07418SJames Feist 
562ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res,
563d9f466b3SEd Tanous                                   boost::urls::url_view arg1)
564b5c07418SJames Feist {
565b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
566b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
567f4c4dcf4SKowalski, Kamil }
568f4c4dcf4SKowalski, Kamil 
569f4c4dcf4SKowalski, Kamil /**
570f4c4dcf4SKowalski, Kamil  * @internal
57181856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
57281856681SAsmitha Karunanithi  *
57381856681SAsmitha Karunanithi  * See header file for more information
57481856681SAsmitha Karunanithi  * @endinternal
57581856681SAsmitha Karunanithi  */
5761668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1)
57781856681SAsmitha Karunanithi {
578fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceDisabled,
5791668ce6dSEd Tanous                   std::to_array({arg1}));
58081856681SAsmitha Karunanithi }
58181856681SAsmitha Karunanithi 
5821668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1)
58381856681SAsmitha Karunanithi {
58481856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
58581856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
58681856681SAsmitha Karunanithi }
58781856681SAsmitha Karunanithi 
58881856681SAsmitha Karunanithi /**
58981856681SAsmitha Karunanithi  * @internal
590f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
591f4c4dcf4SKowalski, Kamil  *
592f4c4dcf4SKowalski, Kamil  * See header file for more information
593f4c4dcf4SKowalski, Kamil  * @endinternal
594f4c4dcf4SKowalski, Kamil  */
595*d9fcfcc1SEd Tanous nlohmann::json serviceInUnknownState()
5961abe55efSEd Tanous {
597fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
598b5c07418SJames Feist }
599b5c07418SJames Feist 
600b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
601b5c07418SJames Feist {
602b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
603b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
604f4c4dcf4SKowalski, Kamil }
605f4c4dcf4SKowalski, Kamil 
606f4c4dcf4SKowalski, Kamil /**
607f4c4dcf4SKowalski, Kamil  * @internal
608f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
609f4c4dcf4SKowalski, Kamil  *
610f4c4dcf4SKowalski, Kamil  * See header file for more information
611f4c4dcf4SKowalski, Kamil  * @endinternal
612f4c4dcf4SKowalski, Kamil  */
613*d9fcfcc1SEd Tanous nlohmann::json eventSubscriptionLimitExceeded()
6141abe55efSEd Tanous {
615fffb8c1fSEd Tanous     return getLog(
616fffb8c1fSEd Tanous         redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
617b5c07418SJames Feist }
618b5c07418SJames Feist 
619b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
620b5c07418SJames Feist {
621789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
622b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
623f4c4dcf4SKowalski, Kamil }
624f4c4dcf4SKowalski, Kamil 
625f4c4dcf4SKowalski, Kamil /**
626f4c4dcf4SKowalski, Kamil  * @internal
627f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
628f4c4dcf4SKowalski, Kamil  *
629f4c4dcf4SKowalski, Kamil  * See header file for more information
630f4c4dcf4SKowalski, Kamil  * @endinternal
631f4c4dcf4SKowalski, Kamil  */
6321668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1,
6331668ce6dSEd Tanous                                       std::string_view arg2)
6341abe55efSEd Tanous {
635fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterMissing,
6361668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
637b5c07418SJames Feist }
638b5c07418SJames Feist 
6391668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1,
6401668ce6dSEd Tanous                             std::string_view arg2)
641b5c07418SJames Feist {
642b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
643b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
644f4c4dcf4SKowalski, Kamil }
645f4c4dcf4SKowalski, Kamil 
646f4c4dcf4SKowalski, Kamil /**
647f4c4dcf4SKowalski, Kamil  * @internal
648f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
649f4c4dcf4SKowalski, Kamil  *
650f4c4dcf4SKowalski, Kamil  * See header file for more information
651f4c4dcf4SKowalski, Kamil  * @endinternal
652f4c4dcf4SKowalski, Kamil  */
6531668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
6541abe55efSEd Tanous {
655b6cd31e1SEd Tanous     std::string arg2String = std::to_string(arg2);
656fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::stringValueTooLong,
6571668ce6dSEd Tanous                   std::to_array({arg1, std::string_view(arg2String)}));
658b5c07418SJames Feist }
659b5c07418SJames Feist 
6601668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
661b5c07418SJames Feist {
662b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
663b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
664f4c4dcf4SKowalski, Kamil }
665f4c4dcf4SKowalski, Kamil 
666f4c4dcf4SKowalski, Kamil /**
667f4c4dcf4SKowalski, Kamil  * @internal
668cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
669cc9139ecSJason M. Bills  *
670cc9139ecSJason M. Bills  * See header file for more information
671cc9139ecSJason M. Bills  * @endinternal
672cc9139ecSJason M. Bills  */
673*d9fcfcc1SEd Tanous nlohmann::json sessionTerminated()
674cc9139ecSJason M. Bills {
675fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionTerminated, {});
676b5c07418SJames Feist }
677b5c07418SJames Feist 
678b5c07418SJames Feist void sessionTerminated(crow::Response& res)
679b5c07418SJames Feist {
680b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
681b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
682cc9139ecSJason M. Bills }
683cc9139ecSJason M. Bills 
684cc9139ecSJason M. Bills /**
685cc9139ecSJason M. Bills  * @internal
686684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
687684bb4b8SJason M. Bills  *
688684bb4b8SJason M. Bills  * See header file for more information
689684bb4b8SJason M. Bills  * @endinternal
690684bb4b8SJason M. Bills  */
691*d9fcfcc1SEd Tanous nlohmann::json subscriptionTerminated()
692684bb4b8SJason M. Bills {
693fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
694684bb4b8SJason M. Bills }
695684bb4b8SJason M. Bills 
696684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
697684bb4b8SJason M. Bills {
698684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
699684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
700684bb4b8SJason M. Bills }
701684bb4b8SJason M. Bills 
702684bb4b8SJason M. Bills /**
703684bb4b8SJason M. Bills  * @internal
704cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
705cc9139ecSJason M. Bills  *
706cc9139ecSJason M. Bills  * See header file for more information
707cc9139ecSJason M. Bills  * @endinternal
708cc9139ecSJason M. Bills  */
7091668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1,
7101668ce6dSEd Tanous                                         std::string_view arg2)
711cc9139ecSJason M. Bills {
712fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
7131668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
714b5c07418SJames Feist }
715b5c07418SJames Feist 
7161668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
7171668ce6dSEd Tanous                               std::string_view arg2)
718b5c07418SJames Feist {
719b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
720b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
721cc9139ecSJason M. Bills }
722cc9139ecSJason M. Bills 
723cc9139ecSJason M. Bills /**
724cc9139ecSJason M. Bills  * @internal
725684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
726684bb4b8SJason M. Bills  *
727684bb4b8SJason M. Bills  * See header file for more information
728684bb4b8SJason M. Bills  * @endinternal
729684bb4b8SJason M. Bills  */
730d9f466b3SEd Tanous nlohmann::json resetRequired(boost::urls::url_view arg1, std::string_view arg2)
731684bb4b8SJason M. Bills {
732fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
733079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer(), arg2}));
734684bb4b8SJason M. Bills }
735684bb4b8SJason M. Bills 
736d9f466b3SEd Tanous void resetRequired(crow::Response& res, boost::urls::url_view arg1,
7371668ce6dSEd Tanous                    std::string_view arg2)
738684bb4b8SJason M. Bills {
739684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
740684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
741684bb4b8SJason M. Bills }
742684bb4b8SJason M. Bills 
743684bb4b8SJason M. Bills /**
744684bb4b8SJason M. Bills  * @internal
745684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
746684bb4b8SJason M. Bills  *
747684bb4b8SJason M. Bills  * See header file for more information
748684bb4b8SJason M. Bills  * @endinternal
749684bb4b8SJason M. Bills  */
7501668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
751684bb4b8SJason M. Bills {
752fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
7531668ce6dSEd Tanous                   std::to_array({arg1}));
754684bb4b8SJason M. Bills }
755684bb4b8SJason M. Bills 
7561668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
757684bb4b8SJason M. Bills {
758684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
759684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
760684bb4b8SJason M. Bills }
761684bb4b8SJason M. Bills 
762684bb4b8SJason M. Bills /**
763684bb4b8SJason M. Bills  * @internal
764684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
765684bb4b8SJason M. Bills  *
766684bb4b8SJason M. Bills  * See header file for more information
767684bb4b8SJason M. Bills  * @endinternal
768684bb4b8SJason M. Bills  */
7691668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
770684bb4b8SJason M. Bills {
771b6cd31e1SEd Tanous     return getLog(
772fffb8c1fSEd Tanous         redfish::registries::base::Index::chassisPowerStateOffRequired,
7731668ce6dSEd Tanous         std::to_array({arg1}));
774684bb4b8SJason M. Bills }
775684bb4b8SJason M. Bills 
7761668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1)
777684bb4b8SJason M. Bills {
778684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
779684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
780684bb4b8SJason M. Bills }
781684bb4b8SJason M. Bills 
782684bb4b8SJason M. Bills /**
783684bb4b8SJason M. Bills  * @internal
784684bb4b8SJason M. Bills  * @brief Formats PropertyValueConflict message into JSON
785684bb4b8SJason M. Bills  *
786684bb4b8SJason M. Bills  * See header file for more information
787684bb4b8SJason M. Bills  * @endinternal
788684bb4b8SJason M. Bills  */
7891668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1,
7901668ce6dSEd Tanous                                      std::string_view arg2)
791684bb4b8SJason M. Bills {
792fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueConflict,
7931668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
794684bb4b8SJason M. Bills }
795684bb4b8SJason M. Bills 
7961668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1,
7971668ce6dSEd Tanous                            std::string_view arg2)
798684bb4b8SJason M. Bills {
799684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
800684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
801684bb4b8SJason M. Bills }
802684bb4b8SJason M. Bills 
803684bb4b8SJason M. Bills /**
804684bb4b8SJason M. Bills  * @internal
8052a6af81cSRamesh Iyyar  * @brief Formats PropertyValueResourceConflict message into JSON
8062a6af81cSRamesh Iyyar  *
8072a6af81cSRamesh Iyyar  * See header file for more information
8082a6af81cSRamesh Iyyar  * @endinternal
8092a6af81cSRamesh Iyyar  */
8102a6af81cSRamesh Iyyar nlohmann::json propertyValueResourceConflict(std::string_view arg1,
81195b3ad73SEd Tanous                                              const nlohmann::json& arg2,
812d9f466b3SEd Tanous                                              boost::urls::url_view arg3)
8132a6af81cSRamesh Iyyar {
81495b3ad73SEd Tanous     std::string arg2Str = arg2.dump(2, ' ', true,
81595b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
81695b3ad73SEd Tanous 
8172a6af81cSRamesh Iyyar     return getLog(
8182a6af81cSRamesh Iyyar         redfish::registries::base::Index::propertyValueResourceConflict,
81995b3ad73SEd Tanous         std::to_array<std::string_view>({arg1, arg2Str, arg3.buffer()}));
8202a6af81cSRamesh Iyyar }
8212a6af81cSRamesh Iyyar 
8222a6af81cSRamesh Iyyar void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
82395b3ad73SEd Tanous                                    const nlohmann::json& arg2,
824d9f466b3SEd Tanous                                    boost::urls::url_view arg3)
8252a6af81cSRamesh Iyyar {
8262a6af81cSRamesh Iyyar     res.result(boost::beast::http::status::conflict);
8272a6af81cSRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
8282a6af81cSRamesh Iyyar                           propertyValueResourceConflict(arg1, arg2, arg3));
8292a6af81cSRamesh Iyyar }
8302a6af81cSRamesh Iyyar 
8312a6af81cSRamesh Iyyar /**
8322a6af81cSRamesh Iyyar  * @internal
83324861a28SRamesh Iyyar  * @brief Formats PropertyValueExternalConflict message into JSON
83424861a28SRamesh Iyyar  *
83524861a28SRamesh Iyyar  * See header file for more information
83624861a28SRamesh Iyyar  * @endinternal
83724861a28SRamesh Iyyar  */
83824861a28SRamesh Iyyar nlohmann::json propertyValueExternalConflict(std::string_view arg1,
83995b3ad73SEd Tanous                                              const nlohmann::json& arg2)
84024861a28SRamesh Iyyar {
84195b3ad73SEd Tanous     std::string arg2Str = arg2.dump(2, ' ', true,
84295b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
84395b3ad73SEd Tanous 
84424861a28SRamesh Iyyar     return getLog(
84524861a28SRamesh Iyyar         redfish::registries::base::Index::propertyValueExternalConflict,
84695b3ad73SEd Tanous         std::to_array<std::string_view>({arg1, arg2Str}));
84724861a28SRamesh Iyyar }
84824861a28SRamesh Iyyar 
84924861a28SRamesh Iyyar void propertyValueExternalConflict(crow::Response& res, std::string_view arg1,
85095b3ad73SEd Tanous                                    const nlohmann::json& arg2)
85124861a28SRamesh Iyyar {
85224861a28SRamesh Iyyar     res.result(boost::beast::http::status::conflict);
85324861a28SRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
85424861a28SRamesh Iyyar                           propertyValueExternalConflict(arg1, arg2));
85524861a28SRamesh Iyyar }
85624861a28SRamesh Iyyar 
85724861a28SRamesh Iyyar /**
85824861a28SRamesh Iyyar  * @internal
859684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
860684bb4b8SJason M. Bills  *
861684bb4b8SJason M. Bills  * See header file for more information
862684bb4b8SJason M. Bills  * @endinternal
863684bb4b8SJason M. Bills  */
86414fbced6SEd Tanous nlohmann::json propertyValueIncorrect(const nlohmann::json& arg1,
8651668ce6dSEd Tanous                                       std::string_view arg2)
866684bb4b8SJason M. Bills {
86714fbced6SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
86814fbced6SEd Tanous                                     nlohmann::json::error_handler_t::replace);
869fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueIncorrect,
87014fbced6SEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
871684bb4b8SJason M. Bills }
872684bb4b8SJason M. Bills 
87314fbced6SEd Tanous void propertyValueIncorrect(crow::Response& res, const nlohmann::json& arg1,
8741668ce6dSEd Tanous                             std::string_view arg2)
875684bb4b8SJason M. Bills {
876684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
877684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
878684bb4b8SJason M. Bills }
879684bb4b8SJason M. Bills 
880684bb4b8SJason M. Bills /**
881684bb4b8SJason M. Bills  * @internal
882684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
883684bb4b8SJason M. Bills  *
884684bb4b8SJason M. Bills  * See header file for more information
885684bb4b8SJason M. Bills  * @endinternal
886684bb4b8SJason M. Bills  */
887d9f466b3SEd Tanous nlohmann::json resourceCreationConflict(boost::urls::url_view arg1)
888684bb4b8SJason M. Bills {
889fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCreationConflict,
890079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
891684bb4b8SJason M. Bills }
892684bb4b8SJason M. Bills 
893d9f466b3SEd Tanous void resourceCreationConflict(crow::Response& res, boost::urls::url_view arg1)
894684bb4b8SJason M. Bills {
895684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
896684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
897684bb4b8SJason M. Bills }
898684bb4b8SJason M. Bills 
899684bb4b8SJason M. Bills /**
900684bb4b8SJason M. Bills  * @internal
901684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded message into JSON
902684bb4b8SJason M. Bills  *
903684bb4b8SJason M. Bills  * See header file for more information
904684bb4b8SJason M. Bills  * @endinternal
905684bb4b8SJason M. Bills  */
906*d9fcfcc1SEd Tanous nlohmann::json maximumErrorsExceeded()
907684bb4b8SJason M. Bills {
908fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
909684bb4b8SJason M. Bills }
910684bb4b8SJason M. Bills 
911684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
912684bb4b8SJason M. Bills {
913684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
914684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
915684bb4b8SJason M. Bills }
916684bb4b8SJason M. Bills 
917684bb4b8SJason M. Bills /**
918684bb4b8SJason M. Bills  * @internal
919684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
920684bb4b8SJason M. Bills  *
921684bb4b8SJason M. Bills  * See header file for more information
922684bb4b8SJason M. Bills  * @endinternal
923684bb4b8SJason M. Bills  */
924*d9fcfcc1SEd Tanous nlohmann::json preconditionFailed()
925684bb4b8SJason M. Bills {
926fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionFailed, {});
927684bb4b8SJason M. Bills }
928684bb4b8SJason M. Bills 
929684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
930684bb4b8SJason M. Bills {
9314df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
932684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
933684bb4b8SJason M. Bills }
934684bb4b8SJason M. Bills 
935684bb4b8SJason M. Bills /**
936684bb4b8SJason M. Bills  * @internal
937684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
938684bb4b8SJason M. Bills  *
939684bb4b8SJason M. Bills  * See header file for more information
940684bb4b8SJason M. Bills  * @endinternal
941684bb4b8SJason M. Bills  */
942*d9fcfcc1SEd Tanous nlohmann::json preconditionRequired()
943684bb4b8SJason M. Bills {
944fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionRequired, {});
945684bb4b8SJason M. Bills }
946684bb4b8SJason M. Bills 
947684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
948684bb4b8SJason M. Bills {
949684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
950684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
951684bb4b8SJason M. Bills }
952684bb4b8SJason M. Bills 
953684bb4b8SJason M. Bills /**
954684bb4b8SJason M. Bills  * @internal
955684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
956684bb4b8SJason M. Bills  *
957684bb4b8SJason M. Bills  * See header file for more information
958684bb4b8SJason M. Bills  * @endinternal
959684bb4b8SJason M. Bills  */
960*d9fcfcc1SEd Tanous nlohmann::json operationFailed()
961684bb4b8SJason M. Bills {
962fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationFailed, {});
963684bb4b8SJason M. Bills }
964684bb4b8SJason M. Bills 
965684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
966684bb4b8SJason M. Bills {
9678868776eSEd Tanous     res.result(boost::beast::http::status::bad_gateway);
968684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
969684bb4b8SJason M. Bills }
970684bb4b8SJason M. Bills 
971684bb4b8SJason M. Bills /**
972684bb4b8SJason M. Bills  * @internal
973684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
974684bb4b8SJason M. Bills  *
975684bb4b8SJason M. Bills  * See header file for more information
976684bb4b8SJason M. Bills  * @endinternal
977684bb4b8SJason M. Bills  */
978*d9fcfcc1SEd Tanous nlohmann::json operationTimeout()
979684bb4b8SJason M. Bills {
980fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationTimeout, {});
981684bb4b8SJason M. Bills }
982684bb4b8SJason M. Bills 
983684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
984684bb4b8SJason M. Bills {
985684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
986684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
987684bb4b8SJason M. Bills }
988684bb4b8SJason M. Bills 
989684bb4b8SJason M. Bills /**
990684bb4b8SJason M. Bills  * @internal
991f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
992f12894f8SJason M. Bills  * property
993f12894f8SJason M. Bills  *
994f12894f8SJason M. Bills  * See header file for more information
995f12894f8SJason M. Bills  * @endinternal
996f12894f8SJason M. Bills  */
9972e8c4bdaSEd Tanous nlohmann::json propertyValueTypeError(const nlohmann::json& arg1,
9981668ce6dSEd Tanous                                       std::string_view arg2)
999f12894f8SJason M. Bills {
10002e8c4bdaSEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
10012e8c4bdaSEd Tanous                                     nlohmann::json::error_handler_t::replace);
1002fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueTypeError,
10032e8c4bdaSEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
1004b5c07418SJames Feist }
1005b5c07418SJames Feist 
10062e8c4bdaSEd Tanous void propertyValueTypeError(crow::Response& res, const nlohmann::json& arg1,
10071668ce6dSEd Tanous                             std::string_view arg2)
1008b5c07418SJames Feist {
1009b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1010b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
1011f4c4dcf4SKowalski, Kamil }
1012f4c4dcf4SKowalski, Kamil 
1013f4c4dcf4SKowalski, Kamil /**
1014f4c4dcf4SKowalski, Kamil  * @internal
1015b6cd31e1SEd Tanous  * @brief Formats ResourceNotFound message into JSONd
1016f4c4dcf4SKowalski, Kamil  *
1017f4c4dcf4SKowalski, Kamil  * See header file for more information
1018f4c4dcf4SKowalski, Kamil  * @endinternal
1019f4c4dcf4SKowalski, Kamil  */
10201668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
10211abe55efSEd Tanous {
1022fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceNotFound,
10231668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1024b5c07418SJames Feist }
1025b5c07418SJames Feist 
10261668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1,
10271668ce6dSEd Tanous                       std::string_view arg2)
1028b5c07418SJames Feist {
1029b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1030b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
1031f4c4dcf4SKowalski, Kamil }
1032f4c4dcf4SKowalski, Kamil 
1033f4c4dcf4SKowalski, Kamil /**
1034f4c4dcf4SKowalski, Kamil  * @internal
1035f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
1036f4c4dcf4SKowalski, Kamil  *
1037f4c4dcf4SKowalski, Kamil  * See header file for more information
1038f4c4dcf4SKowalski, Kamil  * @endinternal
1039f4c4dcf4SKowalski, Kamil  */
1040d9f466b3SEd Tanous nlohmann::json couldNotEstablishConnection(boost::urls::url_view arg1)
10411abe55efSEd Tanous {
1042fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
1043079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1044b5c07418SJames Feist }
1045b5c07418SJames Feist 
1046ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res,
1047d9f466b3SEd Tanous                                  boost::urls::url_view arg1)
1048b5c07418SJames Feist {
1049b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1050b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
1051f4c4dcf4SKowalski, Kamil }
1052f4c4dcf4SKowalski, Kamil 
1053f4c4dcf4SKowalski, Kamil /**
1054f4c4dcf4SKowalski, Kamil  * @internal
1055f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
1056f12894f8SJason M. Bills  * property
1057f12894f8SJason M. Bills  *
1058f12894f8SJason M. Bills  * See header file for more information
1059f12894f8SJason M. Bills  * @endinternal
1060f12894f8SJason M. Bills  */
10611668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1)
1062f12894f8SJason M. Bills {
1063fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyNotWritable,
10641668ce6dSEd Tanous                   std::to_array({arg1}));
1065b5c07418SJames Feist }
1066b5c07418SJames Feist 
10671668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1)
1068b5c07418SJames Feist {
1069b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1070b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1071f4c4dcf4SKowalski, Kamil }
1072f4c4dcf4SKowalski, Kamil 
1073f4c4dcf4SKowalski, Kamil /**
1074f4c4dcf4SKowalski, Kamil  * @internal
1075f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
1076f4c4dcf4SKowalski, Kamil  *
1077f4c4dcf4SKowalski, Kamil  * See header file for more information
1078f4c4dcf4SKowalski, Kamil  * @endinternal
1079f4c4dcf4SKowalski, Kamil  */
108095b3ad73SEd Tanous nlohmann::json queryParameterValueTypeError(const nlohmann::json& arg1,
10811668ce6dSEd Tanous                                             std::string_view arg2)
10821abe55efSEd Tanous {
108395b3ad73SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
108495b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
1085b6cd31e1SEd Tanous     return getLog(
1086fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueTypeError,
108795b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2}));
1088b5c07418SJames Feist }
1089b5c07418SJames Feist 
109095b3ad73SEd Tanous void queryParameterValueTypeError(crow::Response& res,
109195b3ad73SEd Tanous                                   const nlohmann::json& arg1,
10921668ce6dSEd Tanous                                   std::string_view arg2)
1093b5c07418SJames Feist {
1094b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1095b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1096b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
1097f4c4dcf4SKowalski, Kamil }
1098f4c4dcf4SKowalski, Kamil 
1099f4c4dcf4SKowalski, Kamil /**
1100f4c4dcf4SKowalski, Kamil  * @internal
1101f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
1102f4c4dcf4SKowalski, Kamil  *
1103f4c4dcf4SKowalski, Kamil  * See header file for more information
1104f4c4dcf4SKowalski, Kamil  * @endinternal
1105f4c4dcf4SKowalski, Kamil  */
1106*d9fcfcc1SEd Tanous nlohmann::json serviceShuttingDown()
11071abe55efSEd Tanous {
1108fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
1109b5c07418SJames Feist }
1110b5c07418SJames Feist 
1111b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
1112b5c07418SJames Feist {
1113b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1114b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1115f4c4dcf4SKowalski, Kamil }
1116f4c4dcf4SKowalski, Kamil 
1117f4c4dcf4SKowalski, Kamil /**
1118f4c4dcf4SKowalski, Kamil  * @internal
1119f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
1120f4c4dcf4SKowalski, Kamil  *
1121f4c4dcf4SKowalski, Kamil  * See header file for more information
1122f4c4dcf4SKowalski, Kamil  * @endinternal
1123f4c4dcf4SKowalski, Kamil  */
11241668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1,
11251668ce6dSEd Tanous                                         std::string_view arg2)
11261abe55efSEd Tanous {
1127fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
11281668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1129b5c07418SJames Feist }
1130b5c07418SJames Feist 
11311668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
11321668ce6dSEd Tanous                               std::string_view arg2)
1133b5c07418SJames Feist {
1134b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1135b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1136f4c4dcf4SKowalski, Kamil }
1137f4c4dcf4SKowalski, Kamil 
1138f4c4dcf4SKowalski, Kamil /**
1139f4c4dcf4SKowalski, Kamil  * @internal
1140f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1141f4c4dcf4SKowalski, Kamil  *
1142f4c4dcf4SKowalski, Kamil  * See header file for more information
1143f4c4dcf4SKowalski, Kamil  * @endinternal
1144f4c4dcf4SKowalski, Kamil  */
11451668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1,
11461668ce6dSEd Tanous                                            std::string_view arg2)
11471abe55efSEd Tanous {
1148fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
11491668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1150b5c07418SJames Feist }
1151b5c07418SJames Feist 
11521668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
11531668ce6dSEd Tanous                                  std::string_view arg2)
1154b5c07418SJames Feist {
1155b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1156b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1157b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1158f4c4dcf4SKowalski, Kamil }
1159f4c4dcf4SKowalski, Kamil 
1160f4c4dcf4SKowalski, Kamil /**
1161f4c4dcf4SKowalski, Kamil  * @internal
1162f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1163f4c4dcf4SKowalski, Kamil  *
1164f4c4dcf4SKowalski, Kamil  * See header file for more information
1165f4c4dcf4SKowalski, Kamil  * @endinternal
1166f4c4dcf4SKowalski, Kamil  */
1167d9f466b3SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1,
11681668ce6dSEd Tanous                                             std::string_view arg2)
11691abe55efSEd Tanous {
1170b6cd31e1SEd Tanous     return getLog(
1171fffb8c1fSEd Tanous         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
1172079360aeSEd Tanous         std::to_array<std::string_view>({arg1.buffer(), arg2}));
1173b5c07418SJames Feist }
1174b5c07418SJames Feist 
1175ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res,
1176d9f466b3SEd Tanous                                   boost::urls::url_view arg1,
11771668ce6dSEd Tanous                                   std::string_view arg2)
1178b5c07418SJames Feist {
1179b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1180b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1181b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1182f4c4dcf4SKowalski, Kamil }
1183f4c4dcf4SKowalski, Kamil 
1184f4c4dcf4SKowalski, Kamil /**
1185f4c4dcf4SKowalski, Kamil  * @internal
1186b4ad4c05SShantappa Teekappanavar  * @brief Formats StrictAccountTypes message into JSON
1187b4ad4c05SShantappa Teekappanavar  *
1188b4ad4c05SShantappa Teekappanavar  * See header file for more information
1189b4ad4c05SShantappa Teekappanavar  * @endinternal
1190b4ad4c05SShantappa Teekappanavar  */
1191b4ad4c05SShantappa Teekappanavar nlohmann::json strictAccountTypes(std::string_view arg1)
1192b4ad4c05SShantappa Teekappanavar {
1193b4ad4c05SShantappa Teekappanavar     return getLog(redfish::registries::base::Index::strictAccountTypes,
1194b4ad4c05SShantappa Teekappanavar                   std::to_array({arg1}));
1195b4ad4c05SShantappa Teekappanavar }
1196b4ad4c05SShantappa Teekappanavar 
1197b4ad4c05SShantappa Teekappanavar void strictAccountTypes(crow::Response& res, std::string_view arg1)
1198b4ad4c05SShantappa Teekappanavar {
1199b4ad4c05SShantappa Teekappanavar     res.result(boost::beast::http::status::bad_request);
1200b4ad4c05SShantappa Teekappanavar     addMessageToErrorJson(res.jsonValue, strictAccountTypes(arg1));
1201b4ad4c05SShantappa Teekappanavar }
1202b4ad4c05SShantappa Teekappanavar 
1203b4ad4c05SShantappa Teekappanavar /**
1204b4ad4c05SShantappa Teekappanavar  * @internal
1205f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1206f4c4dcf4SKowalski, Kamil  *
1207f4c4dcf4SKowalski, Kamil  * See header file for more information
1208f4c4dcf4SKowalski, Kamil  * @endinternal
1209f4c4dcf4SKowalski, Kamil  */
1210*d9fcfcc1SEd Tanous nlohmann::json accountRemoved()
12111abe55efSEd Tanous {
1212fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountRemoved, {});
1213b5c07418SJames Feist }
1214b5c07418SJames Feist 
1215b5c07418SJames Feist void accountRemoved(crow::Response& res)
1216b5c07418SJames Feist {
1217b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1218b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1219f4c4dcf4SKowalski, Kamil }
1220f4c4dcf4SKowalski, Kamil 
1221f4c4dcf4SKowalski, Kamil /**
1222f4c4dcf4SKowalski, Kamil  * @internal
1223f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1224f4c4dcf4SKowalski, Kamil  *
1225f4c4dcf4SKowalski, Kamil  * See header file for more information
1226f4c4dcf4SKowalski, Kamil  * @endinternal
1227f4c4dcf4SKowalski, Kamil  */
1228d9f466b3SEd Tanous nlohmann::json accessDenied(boost::urls::url_view arg1)
12291abe55efSEd Tanous {
1230fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accessDenied,
1231079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1232b5c07418SJames Feist }
1233b5c07418SJames Feist 
1234d9f466b3SEd Tanous void accessDenied(crow::Response& res, boost::urls::url_view arg1)
1235b5c07418SJames Feist {
1236b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1237b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1238f4c4dcf4SKowalski, Kamil }
1239f4c4dcf4SKowalski, Kamil 
1240f4c4dcf4SKowalski, Kamil /**
1241f4c4dcf4SKowalski, Kamil  * @internal
1242f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1243f4c4dcf4SKowalski, Kamil  *
1244f4c4dcf4SKowalski, Kamil  * See header file for more information
1245f4c4dcf4SKowalski, Kamil  * @endinternal
1246f4c4dcf4SKowalski, Kamil  */
1247*d9fcfcc1SEd Tanous nlohmann::json queryNotSupported()
12481abe55efSEd Tanous {
1249fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1250b5c07418SJames Feist }
1251b5c07418SJames Feist 
1252b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1253b5c07418SJames Feist {
1254b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1255b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1256f4c4dcf4SKowalski, Kamil }
1257f4c4dcf4SKowalski, Kamil 
1258f4c4dcf4SKowalski, Kamil /**
1259f4c4dcf4SKowalski, Kamil  * @internal
1260f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1261f4c4dcf4SKowalski, Kamil  *
1262f4c4dcf4SKowalski, Kamil  * See header file for more information
1263f4c4dcf4SKowalski, Kamil  * @endinternal
1264f4c4dcf4SKowalski, Kamil  */
1265*d9fcfcc1SEd Tanous nlohmann::json createLimitReachedForResource()
12661abe55efSEd Tanous {
1267b6cd31e1SEd Tanous     return getLog(
1268fffb8c1fSEd Tanous         redfish::registries::base::Index::createLimitReachedForResource, {});
1269b5c07418SJames Feist }
1270b5c07418SJames Feist 
1271b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1272b5c07418SJames Feist {
1273b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1274b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1275f4c4dcf4SKowalski, Kamil }
1276f4c4dcf4SKowalski, Kamil 
1277f4c4dcf4SKowalski, Kamil /**
1278f4c4dcf4SKowalski, Kamil  * @internal
1279f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1280f4c4dcf4SKowalski, Kamil  *
1281f4c4dcf4SKowalski, Kamil  * See header file for more information
1282f4c4dcf4SKowalski, Kamil  * @endinternal
1283f4c4dcf4SKowalski, Kamil  */
1284*d9fcfcc1SEd Tanous nlohmann::json generalError()
12851abe55efSEd Tanous {
1286fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::generalError, {});
1287b5c07418SJames Feist }
1288b5c07418SJames Feist 
1289b5c07418SJames Feist void generalError(crow::Response& res)
1290b5c07418SJames Feist {
1291b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1292b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1293f4c4dcf4SKowalski, Kamil }
1294f4c4dcf4SKowalski, Kamil 
1295f4c4dcf4SKowalski, Kamil /**
1296f4c4dcf4SKowalski, Kamil  * @internal
1297f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1298f4c4dcf4SKowalski, Kamil  *
1299f4c4dcf4SKowalski, Kamil  * See header file for more information
1300f4c4dcf4SKowalski, Kamil  * @endinternal
1301f4c4dcf4SKowalski, Kamil  */
1302*d9fcfcc1SEd Tanous nlohmann::json success()
13031abe55efSEd Tanous {
1304fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::success, {});
1305b5c07418SJames Feist }
1306b5c07418SJames Feist 
1307b5c07418SJames Feist void success(crow::Response& res)
1308b5c07418SJames Feist {
1309b5c07418SJames Feist     // don't set res.result here because success is the default and any
1310b5c07418SJames Feist     // error should overwrite the default
1311b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1312f12894f8SJason M. Bills }
1313f12894f8SJason M. Bills 
1314f12894f8SJason M. Bills /**
1315f12894f8SJason M. Bills  * @internal
1316f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1317f4c4dcf4SKowalski, Kamil  *
1318f4c4dcf4SKowalski, Kamil  * See header file for more information
1319f4c4dcf4SKowalski, Kamil  * @endinternal
1320f4c4dcf4SKowalski, Kamil  */
1321*d9fcfcc1SEd Tanous nlohmann::json created()
13221abe55efSEd Tanous {
1323fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::created, {});
1324b5c07418SJames Feist }
1325b5c07418SJames Feist 
1326b5c07418SJames Feist void created(crow::Response& res)
1327b5c07418SJames Feist {
1328b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1329b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1330f4c4dcf4SKowalski, Kamil }
1331f4c4dcf4SKowalski, Kamil 
1332f4c4dcf4SKowalski, Kamil /**
1333f4c4dcf4SKowalski, Kamil  * @internal
1334cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1335cc9139ecSJason M. Bills  *
1336cc9139ecSJason M. Bills  * See header file for more information
1337cc9139ecSJason M. Bills  * @endinternal
1338cc9139ecSJason M. Bills  */
1339*d9fcfcc1SEd Tanous nlohmann::json noOperation()
1340cc9139ecSJason M. Bills {
1341fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noOperation, {});
1342b5c07418SJames Feist }
1343b5c07418SJames Feist 
1344b5c07418SJames Feist void noOperation(crow::Response& res)
1345b5c07418SJames Feist {
1346b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1347b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1348cc9139ecSJason M. Bills }
1349cc9139ecSJason M. Bills 
1350cc9139ecSJason M. Bills /**
1351cc9139ecSJason M. Bills  * @internal
1352b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1353b5c07418SJames Feist  * property
1354f12894f8SJason M. Bills  *
1355f12894f8SJason M. Bills  * See header file for more information
1356f12894f8SJason M. Bills  * @endinternal
1357f12894f8SJason M. Bills  */
13581668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1)
1359b5c07418SJames Feist {
1360fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyUnknown,
13611668ce6dSEd Tanous                   std::to_array({arg1}));
1362b5c07418SJames Feist }
1363b5c07418SJames Feist 
13641668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1)
1365f12894f8SJason M. Bills {
1366f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
13677b1dd2f9SEd Tanous     addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1));
1368f4c4dcf4SKowalski, Kamil }
1369f4c4dcf4SKowalski, Kamil 
1370f4c4dcf4SKowalski, Kamil /**
1371f4c4dcf4SKowalski, Kamil  * @internal
1372f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1373f4c4dcf4SKowalski, Kamil  *
1374f4c4dcf4SKowalski, Kamil  * See header file for more information
1375f4c4dcf4SKowalski, Kamil  * @endinternal
1376f4c4dcf4SKowalski, Kamil  */
1377*d9fcfcc1SEd Tanous nlohmann::json noValidSession()
13781abe55efSEd Tanous {
1379fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noValidSession, {});
1380b5c07418SJames Feist }
1381b5c07418SJames Feist 
1382b5c07418SJames Feist void noValidSession(crow::Response& res)
1383b5c07418SJames Feist {
1384b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1385b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1386f4c4dcf4SKowalski, Kamil }
1387f4c4dcf4SKowalski, Kamil 
1388f4c4dcf4SKowalski, Kamil /**
1389f4c4dcf4SKowalski, Kamil  * @internal
1390f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1391f4c4dcf4SKowalski, Kamil  *
1392f4c4dcf4SKowalski, Kamil  * See header file for more information
1393f4c4dcf4SKowalski, Kamil  * @endinternal
1394f4c4dcf4SKowalski, Kamil  */
1395d9f466b3SEd Tanous nlohmann::json invalidObject(boost::urls::url_view arg1)
13961abe55efSEd Tanous {
1397fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidObject,
1398079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1399b5c07418SJames Feist }
1400b5c07418SJames Feist 
1401d9f466b3SEd Tanous void invalidObject(crow::Response& res, boost::urls::url_view arg1)
1402b5c07418SJames Feist {
1403b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1404b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1405f4c4dcf4SKowalski, Kamil }
1406f4c4dcf4SKowalski, Kamil 
1407f4c4dcf4SKowalski, Kamil /**
1408f4c4dcf4SKowalski, Kamil  * @internal
1409f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1410f4c4dcf4SKowalski, Kamil  *
1411f4c4dcf4SKowalski, Kamil  * See header file for more information
1412f4c4dcf4SKowalski, Kamil  * @endinternal
1413f4c4dcf4SKowalski, Kamil  */
1414*d9fcfcc1SEd Tanous nlohmann::json resourceInStandby()
14151abe55efSEd Tanous {
1416fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1417b5c07418SJames Feist }
1418b5c07418SJames Feist 
1419b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1420b5c07418SJames Feist {
1421b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1422b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1423f4c4dcf4SKowalski, Kamil }
1424f4c4dcf4SKowalski, Kamil 
1425f4c4dcf4SKowalski, Kamil /**
1426f4c4dcf4SKowalski, Kamil  * @internal
1427f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1428f4c4dcf4SKowalski, Kamil  *
1429f4c4dcf4SKowalski, Kamil  * See header file for more information
1430f4c4dcf4SKowalski, Kamil  * @endinternal
1431f4c4dcf4SKowalski, Kamil  */
143295b3ad73SEd Tanous nlohmann::json actionParameterValueTypeError(const nlohmann::json& arg1,
14331668ce6dSEd Tanous                                              std::string_view arg2,
14341668ce6dSEd Tanous                                              std::string_view arg3)
14351abe55efSEd Tanous {
143695b3ad73SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
143795b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
1438b6cd31e1SEd Tanous     return getLog(
1439fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueTypeError,
144095b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2, arg3}));
1441b5c07418SJames Feist }
1442b5c07418SJames Feist 
144395b3ad73SEd Tanous void actionParameterValueTypeError(crow::Response& res,
144495b3ad73SEd Tanous                                    const nlohmann::json& arg1,
14451668ce6dSEd Tanous                                    std::string_view arg2, std::string_view arg3)
1446b5c07418SJames Feist {
1447b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1448b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1449b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1450f4c4dcf4SKowalski, Kamil }
1451f4c4dcf4SKowalski, Kamil 
1452f4c4dcf4SKowalski, Kamil /**
1453f4c4dcf4SKowalski, Kamil  * @internal
1454f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1455f4c4dcf4SKowalski, Kamil  *
1456f4c4dcf4SKowalski, Kamil  * See header file for more information
1457f4c4dcf4SKowalski, Kamil  * @endinternal
1458f4c4dcf4SKowalski, Kamil  */
1459*d9fcfcc1SEd Tanous nlohmann::json sessionLimitExceeded()
14601abe55efSEd Tanous {
1461fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1462b5c07418SJames Feist }
1463b5c07418SJames Feist 
1464b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1465b5c07418SJames Feist {
1466b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1467b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1468f4c4dcf4SKowalski, Kamil }
1469f4c4dcf4SKowalski, Kamil 
1470f4c4dcf4SKowalski, Kamil /**
1471f4c4dcf4SKowalski, Kamil  * @internal
1472f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1473f4c4dcf4SKowalski, Kamil  *
1474f4c4dcf4SKowalski, Kamil  * See header file for more information
1475f4c4dcf4SKowalski, Kamil  * @endinternal
1476f4c4dcf4SKowalski, Kamil  */
14771668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1)
14781abe55efSEd Tanous {
1479fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionNotSupported,
14801668ce6dSEd Tanous                   std::to_array({arg1}));
1481b5c07418SJames Feist }
1482b5c07418SJames Feist 
14831668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1)
1484b5c07418SJames Feist {
1485b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1486b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1487f4c4dcf4SKowalski, Kamil }
1488f4c4dcf4SKowalski, Kamil 
1489f4c4dcf4SKowalski, Kamil /**
1490f4c4dcf4SKowalski, Kamil  * @internal
1491f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1492f4c4dcf4SKowalski, Kamil  *
1493f4c4dcf4SKowalski, Kamil  * See header file for more information
1494f4c4dcf4SKowalski, Kamil  * @endinternal
1495f4c4dcf4SKowalski, Kamil  */
14965187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
14971abe55efSEd Tanous {
1498b6cd31e1SEd Tanous     std::string arg1Str = std::to_string(arg1);
1499fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidIndex,
15001668ce6dSEd Tanous                   std::to_array<std::string_view>({arg1Str}));
1501b5c07418SJames Feist }
1502b5c07418SJames Feist 
15035187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1504b5c07418SJames Feist {
1505b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1506b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1507f4c4dcf4SKowalski, Kamil }
1508f4c4dcf4SKowalski, Kamil 
1509f4c4dcf4SKowalski, Kamil /**
1510f4c4dcf4SKowalski, Kamil  * @internal
1511f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1512f4c4dcf4SKowalski, Kamil  *
1513f4c4dcf4SKowalski, Kamil  * See header file for more information
1514f4c4dcf4SKowalski, Kamil  * @endinternal
1515f4c4dcf4SKowalski, Kamil  */
1516*d9fcfcc1SEd Tanous nlohmann::json emptyJSON()
15171abe55efSEd Tanous {
1518fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::emptyJSON, {});
1519b5c07418SJames Feist }
1520b5c07418SJames Feist 
1521b5c07418SJames Feist void emptyJSON(crow::Response& res)
1522b5c07418SJames Feist {
1523b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1524b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1525f4c4dcf4SKowalski, Kamil }
1526f4c4dcf4SKowalski, Kamil 
1527f4c4dcf4SKowalski, Kamil /**
1528f4c4dcf4SKowalski, Kamil  * @internal
1529f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1530f4c4dcf4SKowalski, Kamil  *
1531f4c4dcf4SKowalski, Kamil  * See header file for more information
1532f4c4dcf4SKowalski, Kamil  * @endinternal
1533f4c4dcf4SKowalski, Kamil  */
1534*d9fcfcc1SEd Tanous nlohmann::json queryNotSupportedOnResource()
15351abe55efSEd Tanous {
1536fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1537b6cd31e1SEd Tanous                   {});
1538b5c07418SJames Feist }
1539b5c07418SJames Feist 
1540b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1541b5c07418SJames Feist {
15426a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1543b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1544f4c4dcf4SKowalski, Kamil }
1545f4c4dcf4SKowalski, Kamil 
1546f4c4dcf4SKowalski, Kamil /**
1547f4c4dcf4SKowalski, Kamil  * @internal
1548684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1549684bb4b8SJason M. Bills  *
1550684bb4b8SJason M. Bills  * See header file for more information
1551684bb4b8SJason M. Bills  * @endinternal
1552684bb4b8SJason M. Bills  */
1553*d9fcfcc1SEd Tanous nlohmann::json queryNotSupportedOnOperation()
1554684bb4b8SJason M. Bills {
1555b6cd31e1SEd Tanous     return getLog(
1556fffb8c1fSEd Tanous         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1557684bb4b8SJason M. Bills }
1558684bb4b8SJason M. Bills 
1559684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1560684bb4b8SJason M. Bills {
15616a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1562684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1563684bb4b8SJason M. Bills }
1564684bb4b8SJason M. Bills 
1565684bb4b8SJason M. Bills /**
1566684bb4b8SJason M. Bills  * @internal
1567684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1568684bb4b8SJason M. Bills  *
1569684bb4b8SJason M. Bills  * See header file for more information
1570684bb4b8SJason M. Bills  * @endinternal
1571684bb4b8SJason M. Bills  */
1572*d9fcfcc1SEd Tanous nlohmann::json queryCombinationInvalid()
1573684bb4b8SJason M. Bills {
1574fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1575fffb8c1fSEd Tanous                   {});
1576684bb4b8SJason M. Bills }
1577684bb4b8SJason M. Bills 
1578684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1579684bb4b8SJason M. Bills {
1580684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1581684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1582684bb4b8SJason M. Bills }
1583684bb4b8SJason M. Bills 
1584684bb4b8SJason M. Bills /**
1585684bb4b8SJason M. Bills  * @internal
1586f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1587f4c4dcf4SKowalski, Kamil  *
1588f4c4dcf4SKowalski, Kamil  * See header file for more information
1589f4c4dcf4SKowalski, Kamil  * @endinternal
1590f4c4dcf4SKowalski, Kamil  */
1591*d9fcfcc1SEd Tanous nlohmann::json insufficientPrivilege()
15921abe55efSEd Tanous {
1593fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1594b5c07418SJames Feist }
1595b5c07418SJames Feist 
1596b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1597b5c07418SJames Feist {
1598b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1599b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1600f4c4dcf4SKowalski, Kamil }
1601f4c4dcf4SKowalski, Kamil 
1602f4c4dcf4SKowalski, Kamil /**
1603f4c4dcf4SKowalski, Kamil  * @internal
1604f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1605f4c4dcf4SKowalski, Kamil  *
1606f4c4dcf4SKowalski, Kamil  * See header file for more information
1607f4c4dcf4SKowalski, Kamil  * @endinternal
1608f4c4dcf4SKowalski, Kamil  */
16091668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1,
161095b3ad73SEd Tanous                                      const nlohmann::json& arg2)
1611b5c07418SJames Feist {
161295b3ad73SEd Tanous     std::string arg2Str = arg2.dump(2, ' ', true,
161395b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
1614fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueModified,
161595b3ad73SEd Tanous                   std::to_array<std::string_view>({arg1, arg2Str}));
1616b5c07418SJames Feist }
1617b5c07418SJames Feist 
16181668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1,
161995b3ad73SEd Tanous                            const nlohmann::json& arg2)
16201abe55efSEd Tanous {
1621f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1622b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1623f4c4dcf4SKowalski, Kamil }
1624f4c4dcf4SKowalski, Kamil 
1625f4c4dcf4SKowalski, Kamil /**
1626f4c4dcf4SKowalski, Kamil  * @internal
1627f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1628f4c4dcf4SKowalski, Kamil  *
1629f4c4dcf4SKowalski, Kamil  * See header file for more information
1630f4c4dcf4SKowalski, Kamil  * @endinternal
1631f4c4dcf4SKowalski, Kamil  */
1632*d9fcfcc1SEd Tanous nlohmann::json accountNotModified()
16331abe55efSEd Tanous {
1634fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountNotModified, {});
1635b5c07418SJames Feist }
1636b5c07418SJames Feist 
1637b5c07418SJames Feist void accountNotModified(crow::Response& res)
1638b5c07418SJames Feist {
1639b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1640b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1641f4c4dcf4SKowalski, Kamil }
1642f4c4dcf4SKowalski, Kamil 
1643f4c4dcf4SKowalski, Kamil /**
1644f4c4dcf4SKowalski, Kamil  * @internal
1645f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1646f4c4dcf4SKowalski, Kamil  *
1647f4c4dcf4SKowalski, Kamil  * See header file for more information
1648f4c4dcf4SKowalski, Kamil  * @endinternal
1649f4c4dcf4SKowalski, Kamil  */
165095b3ad73SEd Tanous nlohmann::json queryParameterValueFormatError(const nlohmann::json& arg1,
16511668ce6dSEd Tanous                                               std::string_view arg2)
16521abe55efSEd Tanous {
165395b3ad73SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
165495b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
1655fffb8c1fSEd Tanous     return getLog(
1656fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueFormatError,
165795b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2}));
1658b5c07418SJames Feist }
1659b5c07418SJames Feist 
166095b3ad73SEd Tanous void queryParameterValueFormatError(crow::Response& res,
166195b3ad73SEd Tanous                                     const nlohmann::json& arg1,
16621668ce6dSEd Tanous                                     std::string_view arg2)
1663b5c07418SJames Feist {
1664b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1665b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1666b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
1667f4c4dcf4SKowalski, Kamil }
1668f4c4dcf4SKowalski, Kamil 
1669f4c4dcf4SKowalski, Kamil /**
1670f4c4dcf4SKowalski, Kamil  * @internal
1671b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
1672b5c07418SJames Feist  * property
1673f12894f8SJason M. Bills  *
1674f12894f8SJason M. Bills  * See header file for more information
1675f12894f8SJason M. Bills  * @endinternal
1676f12894f8SJason M. Bills  */
16771668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1)
1678f12894f8SJason M. Bills {
1679fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyMissing,
16801668ce6dSEd Tanous                   std::to_array({arg1}));
1681b5c07418SJames Feist }
1682b5c07418SJames Feist 
16831668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1)
1684b5c07418SJames Feist {
1685b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1686b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1687f4c4dcf4SKowalski, Kamil }
1688f4c4dcf4SKowalski, Kamil 
1689f4c4dcf4SKowalski, Kamil /**
1690f4c4dcf4SKowalski, Kamil  * @internal
1691f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
1692f4c4dcf4SKowalski, Kamil  *
1693f4c4dcf4SKowalski, Kamil  * See header file for more information
1694f4c4dcf4SKowalski, Kamil  * @endinternal
1695f4c4dcf4SKowalski, Kamil  */
16961668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1)
16971abe55efSEd Tanous {
1698fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceExhaustion,
16991668ce6dSEd Tanous                   std::to_array({arg1}));
1700b5c07418SJames Feist }
1701b5c07418SJames Feist 
17021668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1)
1703b5c07418SJames Feist {
1704b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1705b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1706f4c4dcf4SKowalski, Kamil }
1707f4c4dcf4SKowalski, Kamil 
1708f4c4dcf4SKowalski, Kamil /**
1709f4c4dcf4SKowalski, Kamil  * @internal
1710f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
1711f4c4dcf4SKowalski, Kamil  *
1712f4c4dcf4SKowalski, Kamil  * See header file for more information
1713f4c4dcf4SKowalski, Kamil  * @endinternal
1714f4c4dcf4SKowalski, Kamil  */
1715*d9fcfcc1SEd Tanous nlohmann::json accountModified()
17161abe55efSEd Tanous {
1717fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountModified, {});
1718b5c07418SJames Feist }
1719b5c07418SJames Feist 
1720b5c07418SJames Feist void accountModified(crow::Response& res)
1721b5c07418SJames Feist {
1722b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1723b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
1724f4c4dcf4SKowalski, Kamil }
1725f4c4dcf4SKowalski, Kamil 
1726f4c4dcf4SKowalski, Kamil /**
1727f4c4dcf4SKowalski, Kamil  * @internal
1728f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
1729f4c4dcf4SKowalski, Kamil  *
1730f4c4dcf4SKowalski, Kamil  * See header file for more information
1731f4c4dcf4SKowalski, Kamil  * @endinternal
1732f4c4dcf4SKowalski, Kamil  */
17331668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1,
17341668ce6dSEd Tanous                                         std::string_view arg2,
17351668ce6dSEd Tanous                                         std::string_view arg3)
17361abe55efSEd Tanous {
1737fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
17381668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
1739b5c07418SJames Feist }
1740b5c07418SJames Feist 
17411668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
17421668ce6dSEd Tanous                               std::string_view arg2, std::string_view arg3)
1743b5c07418SJames Feist {
1744b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1745b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1746b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
1747f4c4dcf4SKowalski, Kamil }
1748f4c4dcf4SKowalski, Kamil 
1749d9f466b3SEd Tanous nlohmann::json passwordChangeRequired(boost::urls::url_view arg1)
1750b6cd31e1SEd Tanous {
1751fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::passwordChangeRequired,
1752079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1753b6cd31e1SEd Tanous }
1754b6cd31e1SEd Tanous 
17553bf4e632SJoseph Reynolds /**
17563bf4e632SJoseph Reynolds  * @internal
17573bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
17583bf4e632SJoseph Reynolds  *
17593bf4e632SJoseph Reynolds  * See header file for more information
17603bf4e632SJoseph Reynolds  * @endinternal
17613bf4e632SJoseph Reynolds  */
1762d9f466b3SEd Tanous void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1)
17633bf4e632SJoseph Reynolds {
1764b6cd31e1SEd Tanous     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
17653bf4e632SJoseph Reynolds }
17663bf4e632SJoseph Reynolds 
17674cde5d90SJames Feist /**
17684cde5d90SJames Feist  * @internal
1769ae688313SNan Zhou  * @brief Formats InsufficientStorage message into JSON
1770ae688313SNan Zhou  *
1771ae688313SNan Zhou  * See header file for more information
1772ae688313SNan Zhou  * @endinternal
1773ae688313SNan Zhou  */
1774ae688313SNan Zhou nlohmann::json insufficientStorage()
1775ae688313SNan Zhou {
1776ae688313SNan Zhou     return getLog(redfish::registries::base::Index::insufficientStorage, {});
1777ae688313SNan Zhou }
1778ae688313SNan Zhou 
1779ae688313SNan Zhou void insufficientStorage(crow::Response& res)
1780ae688313SNan Zhou {
1781ae688313SNan Zhou     res.result(boost::beast::http::status::insufficient_storage);
1782ae688313SNan Zhou     addMessageToErrorJson(res.jsonValue, insufficientStorage());
1783ae688313SNan Zhou }
1784ae688313SNan Zhou 
1785ae688313SNan Zhou /**
1786ae688313SNan Zhou  * @internal
178744c70412SEd Tanous  * @brief Formats OperationNotAllowed message into JSON
178844c70412SEd Tanous  *
178944c70412SEd Tanous  * See header file for more information
179044c70412SEd Tanous  * @endinternal
179144c70412SEd Tanous  */
179244c70412SEd Tanous nlohmann::json operationNotAllowed()
179344c70412SEd Tanous {
179444c70412SEd Tanous     return getLog(redfish::registries::base::Index::operationNotAllowed, {});
179544c70412SEd Tanous }
179644c70412SEd Tanous 
179744c70412SEd Tanous void operationNotAllowed(crow::Response& res)
179844c70412SEd Tanous {
179944c70412SEd Tanous     res.result(boost::beast::http::status::method_not_allowed);
180044c70412SEd Tanous     addMessageToErrorJson(res.jsonValue, operationNotAllowed());
180144c70412SEd Tanous }
180244c70412SEd Tanous 
1803600af5f1SAppaRao Puli /**
1804600af5f1SAppaRao Puli  * @internal
1805600af5f1SAppaRao Puli  * @brief Formats ArraySizeTooLong message into JSON
1806600af5f1SAppaRao Puli  *
1807600af5f1SAppaRao Puli  * See header file for more information
1808600af5f1SAppaRao Puli  * @endinternal
1809600af5f1SAppaRao Puli  */
1810600af5f1SAppaRao Puli nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length)
1811600af5f1SAppaRao Puli {
1812600af5f1SAppaRao Puli     std::string valStr = std::to_string(length);
1813600af5f1SAppaRao Puli     return getLog(redfish::registries::base::Index::arraySizeTooLong,
1814600af5f1SAppaRao Puli                   std::to_array<std::string_view>({property, valStr}));
1815600af5f1SAppaRao Puli }
1816600af5f1SAppaRao Puli 
1817600af5f1SAppaRao Puli void arraySizeTooLong(crow::Response& res, std::string_view property,
1818600af5f1SAppaRao Puli                       uint64_t length)
1819600af5f1SAppaRao Puli {
1820600af5f1SAppaRao Puli     res.result(boost::beast::http::status::method_not_allowed);
1821600af5f1SAppaRao Puli     addMessageToErrorJson(res.jsonValue, arraySizeTooLong(property, length));
1822600af5f1SAppaRao Puli }
1823600af5f1SAppaRao Puli 
182444c70412SEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1,
182544c70412SEd Tanous                    std::string_view arg2)
182644c70412SEd Tanous {
182744c70412SEd Tanous     res.result(boost::beast::http::status::bad_request);
182844c70412SEd Tanous     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
182944c70412SEd Tanous }
183044c70412SEd Tanous 
183144c70412SEd Tanous /**
183244c70412SEd Tanous  * @internal
18334cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
18344cde5d90SJames Feist  *
18354cde5d90SJames Feist  * See header file for more information
18364cde5d90SJames Feist  * @endinternal
18374cde5d90SJames Feist  */
18381668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
18394cde5d90SJames Feist {
18401668ce6dSEd Tanous     std::string msg = "Invalid file uploaded to ";
18411668ce6dSEd Tanous     msg += arg1;
18421668ce6dSEd Tanous     msg += ": ";
18431668ce6dSEd Tanous     msg += arg2;
18441668ce6dSEd Tanous     msg += ".";
1845613dabeaSEd Tanous 
1846613dabeaSEd Tanous     nlohmann::json::object_t ret;
1847613dabeaSEd Tanous     ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message";
1848613dabeaSEd Tanous     ret["MessageId"] = "OpenBMC.0.2.InvalidUpload";
1849613dabeaSEd Tanous     ret["Message"] = std::move(msg);
1850613dabeaSEd Tanous     nlohmann::json::array_t args;
1851ad539545SPatrick Williams     args.emplace_back(arg1);
1852ad539545SPatrick Williams     args.emplace_back(arg2);
1853613dabeaSEd Tanous     ret["MessageArgs"] = std::move(args);
1854613dabeaSEd Tanous     ret["MessageSeverity"] = "Warning";
1855613dabeaSEd Tanous     ret["Resolution"] = "None.";
1856613dabeaSEd Tanous     return ret;
18574cde5d90SJames Feist }
1858ae688313SNan Zhou 
1859f4c4dcf4SKowalski, Kamil } // namespace messages
1860f4c4dcf4SKowalski, Kamil 
1861d425c6f6SEd Tanous } // namespace redfish
1862