xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision 99bf026224d6ea60be27bd36793ddfaea5537d2a)
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         {
5462598e31SEd Tanous             BMCWEB_LOG_CRITICAL(
5562598e31SEd 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         {
6262598e31SEd Tanous             BMCWEB_LOG_CRITICAL("Attempt to add error message without Message");
63f4c4dcf4SKowalski, Kamil             return;
64f4c4dcf4SKowalski, Kamil         }
651476687dSEd Tanous         error["code"] = *messageIdIterator;
661476687dSEd Tanous         error["message"] = *messageFieldIterator;
671abe55efSEd Tanous     }
681abe55efSEd Tanous     else
691abe55efSEd Tanous     {
70f4c4dcf4SKowalski, Kamil         // More than 1 error occurred, so the message has to be generic
7155c7b7a2SEd Tanous         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
72cc9139ecSJason M. Bills         error["message"] = "A general error has occurred. See Resolution for "
73cc9139ecSJason M. Bills                            "information on how to resolve the error.";
74f4c4dcf4SKowalski, Kamil     }
75f4c4dcf4SKowalski, Kamil 
763590bd1dSNan Zhou     // This check could technically be done in the default construction
77f4c4dcf4SKowalski, Kamil     // branch above, but because we need the pointer to the extended info field
78f4c4dcf4SKowalski, Kamil     // anyway, it's more efficient to do it here.
79c074230bSJason M. Bills     auto& extendedInfo = error[messages::messageAnnotation];
80c074230bSJason M. Bills     if (!extendedInfo.is_array())
811abe55efSEd Tanous     {
82c074230bSJason M. Bills         extendedInfo = nlohmann::json::array();
83f4c4dcf4SKowalski, Kamil     }
84f4c4dcf4SKowalski, Kamil 
85c074230bSJason M. Bills     extendedInfo.push_back(message);
86f4c4dcf4SKowalski, Kamil }
87f4c4dcf4SKowalski, Kamil 
883590bd1dSNan Zhou void moveErrorsToErrorJson(nlohmann::json& target, nlohmann::json& source)
893590bd1dSNan Zhou {
903590bd1dSNan Zhou     if (!source.is_object())
913590bd1dSNan Zhou     {
923590bd1dSNan Zhou         return;
933590bd1dSNan Zhou     }
943590bd1dSNan Zhou     auto errorIt = source.find("error");
953590bd1dSNan Zhou     if (errorIt == source.end())
963590bd1dSNan Zhou     {
973590bd1dSNan Zhou         // caller puts error message in root
983590bd1dSNan Zhou         messages::addMessageToErrorJson(target, source);
993590bd1dSNan Zhou         source.clear();
1003590bd1dSNan Zhou         return;
1013590bd1dSNan Zhou     }
1023590bd1dSNan Zhou     auto extendedInfoIt = errorIt->find(messages::messageAnnotation);
1033590bd1dSNan Zhou     if (extendedInfoIt == errorIt->end())
1043590bd1dSNan Zhou     {
1053590bd1dSNan Zhou         return;
1063590bd1dSNan Zhou     }
1073590bd1dSNan Zhou     const nlohmann::json::array_t* extendedInfo =
1083590bd1dSNan Zhou         (*extendedInfoIt).get_ptr<const nlohmann::json::array_t*>();
1093590bd1dSNan Zhou     if (extendedInfo == nullptr)
1103590bd1dSNan Zhou     {
1113590bd1dSNan Zhou         source.erase(errorIt);
1123590bd1dSNan Zhou         return;
1133590bd1dSNan Zhou     }
1143590bd1dSNan Zhou     for (const nlohmann::json& message : *extendedInfo)
1153590bd1dSNan Zhou     {
1163590bd1dSNan Zhou         addMessageToErrorJson(target, message);
1173590bd1dSNan Zhou     }
1183590bd1dSNan Zhou     source.erase(errorIt);
1193590bd1dSNan Zhou }
1203590bd1dSNan Zhou 
121f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target,
122f12894f8SJason M. Bills                                  const nlohmann::json& message)
1231abe55efSEd Tanous {
1241abe55efSEd Tanous     if (!target[messages::messageAnnotation].is_array())
1251abe55efSEd Tanous     {
126f4c4dcf4SKowalski, Kamil         // Force object to be an array
12755c7b7a2SEd Tanous         target[messages::messageAnnotation] = nlohmann::json::array();
128f4c4dcf4SKowalski, Kamil     }
129f4c4dcf4SKowalski, Kamil 
13055c7b7a2SEd Tanous     target[messages::messageAnnotation].push_back(message);
131f4c4dcf4SKowalski, Kamil }
132f4c4dcf4SKowalski, Kamil 
133f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target,
134f12894f8SJason M. Bills                              const nlohmann::json& message,
1351668ce6dSEd Tanous                              std::string_view fieldPath)
1361abe55efSEd Tanous {
1371668ce6dSEd Tanous     std::string extendedInfo(fieldPath);
1381668ce6dSEd Tanous     extendedInfo += messages::messageAnnotation;
139f4c4dcf4SKowalski, Kamil 
1401668ce6dSEd Tanous     nlohmann::json& field = target[extendedInfo];
1411668ce6dSEd Tanous     if (!field.is_array())
1421abe55efSEd Tanous     {
143f4c4dcf4SKowalski, Kamil         // Force object to be an array
1441668ce6dSEd Tanous         field = nlohmann::json::array();
145f4c4dcf4SKowalski, Kamil     }
146f4c4dcf4SKowalski, Kamil 
147f4c4dcf4SKowalski, Kamil     // Object exists and it is an array so we can just push in the message
1481668ce6dSEd Tanous     field.push_back(message);
149f4c4dcf4SKowalski, Kamil }
150f4c4dcf4SKowalski, Kamil 
151f7725d79SEd Tanous static nlohmann::json getLog(redfish::registries::base::Index name,
152b6cd31e1SEd Tanous                              std::span<const std::string_view> args)
153b6cd31e1SEd Tanous {
154b6cd31e1SEd Tanous     size_t index = static_cast<size_t>(name);
155fffb8c1fSEd Tanous     if (index >= redfish::registries::base::registry.size())
156b6cd31e1SEd Tanous     {
157b6cd31e1SEd Tanous         return {};
158b6cd31e1SEd Tanous     }
15965e4f1f7SEd Tanous     return getLogFromRegistry(redfish::registries::base::header,
16065e4f1f7SEd Tanous                               redfish::registries::base::registry, index, args);
161b6cd31e1SEd Tanous }
162b6cd31e1SEd Tanous 
163f4c4dcf4SKowalski, Kamil /**
164f4c4dcf4SKowalski, Kamil  * @internal
165f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
166f4c4dcf4SKowalski, Kamil  *
167f4c4dcf4SKowalski, Kamil  * See header file for more information
168f4c4dcf4SKowalski, Kamil  * @endinternal
169f4c4dcf4SKowalski, Kamil  */
170d9fcfcc1SEd Tanous nlohmann::json resourceInUse()
1711abe55efSEd Tanous {
172fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInUse, {});
173b5c07418SJames Feist }
174b5c07418SJames Feist 
175b5c07418SJames Feist void resourceInUse(crow::Response& res)
176b5c07418SJames Feist {
177b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
178b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
179f4c4dcf4SKowalski, Kamil }
180f4c4dcf4SKowalski, Kamil 
181f4c4dcf4SKowalski, Kamil /**
182f4c4dcf4SKowalski, Kamil  * @internal
183f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
184f4c4dcf4SKowalski, Kamil  *
185f4c4dcf4SKowalski, Kamil  * See header file for more information
186f4c4dcf4SKowalski, Kamil  * @endinternal
187f4c4dcf4SKowalski, Kamil  */
188d9fcfcc1SEd Tanous nlohmann::json malformedJSON()
1891abe55efSEd Tanous {
190fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::malformedJSON, {});
191b5c07418SJames Feist }
192b5c07418SJames Feist 
193b5c07418SJames Feist void malformedJSON(crow::Response& res)
194b5c07418SJames Feist {
195b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
196b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
197f4c4dcf4SKowalski, Kamil }
198f4c4dcf4SKowalski, Kamil 
199f4c4dcf4SKowalski, Kamil /**
200f4c4dcf4SKowalski, Kamil  * @internal
201f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
202f4c4dcf4SKowalski, Kamil  *
203f4c4dcf4SKowalski, Kamil  * See header file for more information
204f4c4dcf4SKowalski, Kamil  * @endinternal
205f4c4dcf4SKowalski, Kamil  */
206d9f466b3SEd Tanous nlohmann::json resourceMissingAtURI(boost::urls::url_view arg1)
2071abe55efSEd Tanous {
208079360aeSEd Tanous     std::array<std::string_view, 1> args{arg1.buffer()};
209fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceMissingAtURI, args);
210b5c07418SJames Feist }
211b5c07418SJames Feist 
212d9f466b3SEd Tanous void resourceMissingAtURI(crow::Response& res, boost::urls::url_view arg1)
213b5c07418SJames Feist {
214b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
215b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
216f4c4dcf4SKowalski, Kamil }
217f4c4dcf4SKowalski, Kamil 
218f4c4dcf4SKowalski, Kamil /**
219f4c4dcf4SKowalski, Kamil  * @internal
220f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
221f4c4dcf4SKowalski, Kamil  *
222f4c4dcf4SKowalski, Kamil  * See header file for more information
223f4c4dcf4SKowalski, Kamil  * @endinternal
224f4c4dcf4SKowalski, Kamil  */
22595b3ad73SEd Tanous nlohmann::json actionParameterValueFormatError(const nlohmann::json& arg1,
2261668ce6dSEd Tanous                                                std::string_view arg2,
2271668ce6dSEd Tanous                                                std::string_view arg3)
2281abe55efSEd Tanous {
22995b3ad73SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
23095b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
231fffb8c1fSEd Tanous     return getLog(
232fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueFormatError,
23395b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2, arg3}));
234b5c07418SJames Feist }
235b5c07418SJames Feist 
23695b3ad73SEd Tanous void actionParameterValueFormatError(crow::Response& res,
23795b3ad73SEd Tanous                                      const nlohmann::json& arg1,
2381668ce6dSEd Tanous                                      std::string_view arg2,
2391668ce6dSEd Tanous                                      std::string_view arg3)
240b5c07418SJames Feist {
241b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
242b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
243b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
244f4c4dcf4SKowalski, Kamil }
245f4c4dcf4SKowalski, Kamil 
246f4c4dcf4SKowalski, Kamil /**
247f4c4dcf4SKowalski, Kamil  * @internal
2484ef82a15SAlex Schendel  * @brief Formats ActionParameterValueNotInList message into JSON
2494ef82a15SAlex Schendel  *
2504ef82a15SAlex Schendel  * See header file for more information
2514ef82a15SAlex Schendel  * @endinternal
2524ef82a15SAlex Schendel  */
2534ef82a15SAlex Schendel nlohmann::json actionParameterValueNotInList(std::string_view arg1,
2544ef82a15SAlex Schendel                                              std::string_view arg2,
2554ef82a15SAlex Schendel                                              std::string_view arg3)
2564ef82a15SAlex Schendel {
2574ef82a15SAlex Schendel     return getLog(
2584ef82a15SAlex Schendel         redfish::registries::base::Index::actionParameterValueNotInList,
2594ef82a15SAlex Schendel         std::to_array({arg1, arg2, arg3}));
2604ef82a15SAlex Schendel }
2614ef82a15SAlex Schendel 
2624ef82a15SAlex Schendel void actionParameterValueNotInList(crow::Response& res, std::string_view arg1,
2634ef82a15SAlex Schendel                                    std::string_view arg2, std::string_view arg3)
2644ef82a15SAlex Schendel {
2654ef82a15SAlex Schendel     res.result(boost::beast::http::status::bad_request);
2664ef82a15SAlex Schendel     addMessageToErrorJson(res.jsonValue,
2674ef82a15SAlex Schendel                           actionParameterValueNotInList(arg1, arg2, arg3));
2684ef82a15SAlex Schendel }
2694ef82a15SAlex Schendel 
2704ef82a15SAlex Schendel /**
2714ef82a15SAlex Schendel  * @internal
272f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
273f4c4dcf4SKowalski, Kamil  *
274f4c4dcf4SKowalski, Kamil  * See header file for more information
275f4c4dcf4SKowalski, Kamil  * @endinternal
276f4c4dcf4SKowalski, Kamil  */
277d9fcfcc1SEd Tanous nlohmann::json internalError()
2781abe55efSEd Tanous {
279fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::internalError, {});
280b5c07418SJames Feist }
281b5c07418SJames Feist 
282d85418e3SPatrick Williams void internalError(crow::Response& res, const std::source_location location)
283b5c07418SJames Feist {
28462598e31SEd Tanous     BMCWEB_LOG_CRITICAL("Internal Error {}({}:{}) `{}`: ", location.file_name(),
28562598e31SEd Tanous                         location.line(), location.column(),
28662598e31SEd Tanous                         location.function_name());
287b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
288b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
289f12894f8SJason M. Bills }
290f12894f8SJason M. Bills 
291f12894f8SJason M. Bills /**
292f12894f8SJason M. Bills  * @internal
293f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
294f4c4dcf4SKowalski, Kamil  *
295f4c4dcf4SKowalski, Kamil  * See header file for more information
296f4c4dcf4SKowalski, Kamil  * @endinternal
297f4c4dcf4SKowalski, Kamil  */
298d9fcfcc1SEd Tanous nlohmann::json unrecognizedRequestBody()
2991abe55efSEd Tanous {
300fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::unrecognizedRequestBody,
301fffb8c1fSEd Tanous                   {});
302b5c07418SJames Feist }
303b5c07418SJames Feist 
304b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
305b5c07418SJames Feist {
306b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
307b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
308f4c4dcf4SKowalski, Kamil }
309f4c4dcf4SKowalski, Kamil 
310f4c4dcf4SKowalski, Kamil /**
311f4c4dcf4SKowalski, Kamil  * @internal
312f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
313f4c4dcf4SKowalski, Kamil  *
314f4c4dcf4SKowalski, Kamil  * See header file for more information
315f4c4dcf4SKowalski, Kamil  * @endinternal
316f4c4dcf4SKowalski, Kamil  */
317d9f466b3SEd Tanous nlohmann::json resourceAtUriUnauthorized(boost::urls::url_view arg1,
3181668ce6dSEd Tanous                                          std::string_view arg2)
3191abe55efSEd Tanous {
320079360aeSEd Tanous     return getLog(redfish::registries::base::Index::resourceAtUriUnauthorized,
321079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer(), arg2}));
322b5c07418SJames Feist }
323b5c07418SJames Feist 
324d9f466b3SEd Tanous void resourceAtUriUnauthorized(crow::Response& res, boost::urls::url_view arg1,
3251668ce6dSEd Tanous                                std::string_view arg2)
326b5c07418SJames Feist {
327b5c07418SJames Feist     res.result(boost::beast::http::status::unauthorized);
328b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
329f4c4dcf4SKowalski, Kamil }
330f4c4dcf4SKowalski, Kamil 
331f4c4dcf4SKowalski, Kamil /**
332f4c4dcf4SKowalski, Kamil  * @internal
333f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterUnknown message into JSON
334f4c4dcf4SKowalski, Kamil  *
335f4c4dcf4SKowalski, Kamil  * See header file for more information
336f4c4dcf4SKowalski, Kamil  * @endinternal
337f4c4dcf4SKowalski, Kamil  */
3381668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1,
3391668ce6dSEd Tanous                                       std::string_view arg2)
340b5c07418SJames Feist {
341fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterUnknown,
3421668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
343b5c07418SJames Feist }
344b5c07418SJames Feist 
3451668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1,
3461668ce6dSEd Tanous                             std::string_view arg2)
3471abe55efSEd Tanous {
348f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
349b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
350f4c4dcf4SKowalski, Kamil }
351f4c4dcf4SKowalski, Kamil 
352f4c4dcf4SKowalski, Kamil /**
353f4c4dcf4SKowalski, Kamil  * @internal
354f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceCannotBeDeleted message into JSON
355f4c4dcf4SKowalski, Kamil  *
356f4c4dcf4SKowalski, Kamil  * See header file for more information
357f4c4dcf4SKowalski, Kamil  * @endinternal
358f4c4dcf4SKowalski, Kamil  */
359d9fcfcc1SEd Tanous nlohmann::json resourceCannotBeDeleted()
3601abe55efSEd Tanous {
361fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCannotBeDeleted,
362fffb8c1fSEd Tanous                   {});
363b5c07418SJames Feist }
364b5c07418SJames Feist 
365b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res)
366b5c07418SJames Feist {
36744c70412SEd Tanous     res.result(boost::beast::http::status::method_not_allowed);
368b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
369f4c4dcf4SKowalski, Kamil }
370f4c4dcf4SKowalski, Kamil 
371f4c4dcf4SKowalski, Kamil /**
372f4c4dcf4SKowalski, Kamil  * @internal
373f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyDuplicate message into JSON
374f4c4dcf4SKowalski, Kamil  *
375f4c4dcf4SKowalski, Kamil  * See header file for more information
376f4c4dcf4SKowalski, Kamil  * @endinternal
377f4c4dcf4SKowalski, Kamil  */
3781668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1)
3791abe55efSEd Tanous {
380fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyDuplicate,
3811668ce6dSEd Tanous                   std::to_array({arg1}));
382b5c07418SJames Feist }
383b5c07418SJames Feist 
3841668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1)
385b5c07418SJames Feist {
386b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
387b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
388f4c4dcf4SKowalski, Kamil }
389f4c4dcf4SKowalski, Kamil 
390f4c4dcf4SKowalski, Kamil /**
391f4c4dcf4SKowalski, Kamil  * @internal
392f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
393f4c4dcf4SKowalski, Kamil  *
394f4c4dcf4SKowalski, Kamil  * See header file for more information
395f4c4dcf4SKowalski, Kamil  * @endinternal
396f4c4dcf4SKowalski, Kamil  */
3971668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
3981abe55efSEd Tanous {
399b6cd31e1SEd Tanous     return getLog(
400fffb8c1fSEd Tanous         redfish::registries::base::Index::serviceTemporarilyUnavailable,
4011668ce6dSEd Tanous         std::to_array({arg1}));
402b5c07418SJames Feist }
403b5c07418SJames Feist 
4041668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
405b5c07418SJames Feist {
406d9f6c621SEd Tanous     res.addHeader(boost::beast::http::field::retry_after, arg1);
407b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
408b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
409f4c4dcf4SKowalski, Kamil }
410f4c4dcf4SKowalski, Kamil 
411f4c4dcf4SKowalski, Kamil /**
412f4c4dcf4SKowalski, Kamil  * @internal
413f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
414f4c4dcf4SKowalski, Kamil  *
415f4c4dcf4SKowalski, Kamil  * See header file for more information
416f4c4dcf4SKowalski, Kamil  * @endinternal
417f4c4dcf4SKowalski, Kamil  */
4181668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1,
4191668ce6dSEd Tanous                                      std::string_view arg2,
4201668ce6dSEd Tanous                                      std::string_view arg3)
4211abe55efSEd Tanous {
422fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceAlreadyExists,
4231668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
424b5c07418SJames Feist }
425b5c07418SJames Feist 
4261668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
4271668ce6dSEd Tanous                            std::string_view arg2, std::string_view arg3)
428b5c07418SJames Feist {
429b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
430b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
431a08b46ccSJason M. Bills                      arg2);
432f4c4dcf4SKowalski, Kamil }
433f4c4dcf4SKowalski, Kamil 
434f4c4dcf4SKowalski, Kamil /**
435f4c4dcf4SKowalski, Kamil  * @internal
436f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
437f4c4dcf4SKowalski, Kamil  *
438f4c4dcf4SKowalski, Kamil  * See header file for more information
439f4c4dcf4SKowalski, Kamil  * @endinternal
440f4c4dcf4SKowalski, Kamil  */
441d9fcfcc1SEd Tanous nlohmann::json accountForSessionNoLongerExists()
4421abe55efSEd Tanous {
443fffb8c1fSEd Tanous     return getLog(
444fffb8c1fSEd Tanous         redfish::registries::base::Index::accountForSessionNoLongerExists, {});
445b5c07418SJames Feist }
446b5c07418SJames Feist 
447b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
448b5c07418SJames Feist {
449b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
450b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
451f4c4dcf4SKowalski, Kamil }
452f4c4dcf4SKowalski, Kamil 
453f4c4dcf4SKowalski, Kamil /**
454f4c4dcf4SKowalski, Kamil  * @internal
455f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
456f4c4dcf4SKowalski, Kamil  *
457f4c4dcf4SKowalski, Kamil  * See header file for more information
458f4c4dcf4SKowalski, Kamil  * @endinternal
459f4c4dcf4SKowalski, Kamil  */
4601668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
4611abe55efSEd Tanous {
462fffb8c1fSEd Tanous     return getLog(
463fffb8c1fSEd Tanous         redfish::registries::base::Index::createFailedMissingReqProperties,
4641668ce6dSEd Tanous         std::to_array({arg1}));
465b5c07418SJames Feist }
466b5c07418SJames Feist 
467b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
4681668ce6dSEd Tanous                                       std::string_view arg1)
469b5c07418SJames Feist {
470b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
471b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
472a08b46ccSJason M. Bills                      arg1);
473f12894f8SJason M. Bills }
474f12894f8SJason M. Bills 
475f12894f8SJason M. Bills /**
476f12894f8SJason M. Bills  * @internal
477f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
478f12894f8SJason M. Bills  * property
479f12894f8SJason M. Bills  *
480f12894f8SJason M. Bills  * See header file for more information
481f12894f8SJason M. Bills  * @endinternal
482f12894f8SJason M. Bills  */
483f818b04dSEd Tanous nlohmann::json propertyValueFormatError(const nlohmann::json& arg1,
4841668ce6dSEd Tanous                                         std::string_view arg2)
485f12894f8SJason M. Bills {
486f818b04dSEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
487f818b04dSEd Tanous                                     nlohmann::json::error_handler_t::replace);
488fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueFormatError,
489f818b04dSEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
490b5c07418SJames Feist }
491b5c07418SJames Feist 
492f818b04dSEd Tanous void propertyValueFormatError(crow::Response& res, const nlohmann::json& arg1,
4931668ce6dSEd Tanous                               std::string_view arg2)
494b5c07418SJames Feist {
495b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
496b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
497f12894f8SJason M. Bills }
498f12894f8SJason M. Bills 
499f12894f8SJason M. Bills /**
500f12894f8SJason M. Bills  * @internal
501f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
502f12894f8SJason M. Bills  * property
503f12894f8SJason M. Bills  *
504f12894f8SJason M. Bills  * See header file for more information
505f12894f8SJason M. Bills  * @endinternal
506f12894f8SJason M. Bills  */
507e2616cc5SEd Tanous 
508e2616cc5SEd Tanous nlohmann::json propertyValueNotInList(const nlohmann::json& arg1,
5091668ce6dSEd Tanous                                       std::string_view arg2)
510f12894f8SJason M. Bills {
511e2616cc5SEd Tanous     std::string arg1Str = arg1.dump(-1, ' ', true,
512e2616cc5SEd Tanous                                     nlohmann::json::error_handler_t::replace);
513fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueNotInList,
514e2616cc5SEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
515b5c07418SJames Feist }
516b5c07418SJames Feist 
517e2616cc5SEd Tanous void propertyValueNotInList(crow::Response& res, const nlohmann::json& arg1,
5181668ce6dSEd Tanous                             std::string_view arg2)
519b5c07418SJames Feist {
520b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
521b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
522f4c4dcf4SKowalski, Kamil }
523f4c4dcf4SKowalski, Kamil 
524f4c4dcf4SKowalski, Kamil /**
525f4c4dcf4SKowalski, Kamil  * @internal
526227a2b0aSJiaqing Zhao  * @brief Formats PropertyValueOutOfRange message into JSON
527227a2b0aSJiaqing Zhao  *
528227a2b0aSJiaqing Zhao  * See header file for more information
529227a2b0aSJiaqing Zhao  * @endinternal
530227a2b0aSJiaqing Zhao  */
53195b3ad73SEd Tanous nlohmann::json propertyValueOutOfRange(const nlohmann::json& arg1,
532227a2b0aSJiaqing Zhao                                        std::string_view arg2)
533227a2b0aSJiaqing Zhao {
53495b3ad73SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
53595b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
536227a2b0aSJiaqing Zhao     return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
53795b3ad73SEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
538227a2b0aSJiaqing Zhao }
539227a2b0aSJiaqing Zhao 
54095b3ad73SEd Tanous void propertyValueOutOfRange(crow::Response& res, const nlohmann::json& arg1,
541227a2b0aSJiaqing Zhao                              std::string_view arg2)
542227a2b0aSJiaqing Zhao {
543227a2b0aSJiaqing Zhao     res.result(boost::beast::http::status::bad_request);
544227a2b0aSJiaqing Zhao     addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2));
545227a2b0aSJiaqing Zhao }
546227a2b0aSJiaqing Zhao 
547227a2b0aSJiaqing Zhao /**
548227a2b0aSJiaqing Zhao  * @internal
549f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
550f4c4dcf4SKowalski, Kamil  *
551f4c4dcf4SKowalski, Kamil  * See header file for more information
552f4c4dcf4SKowalski, Kamil  * @endinternal
553f4c4dcf4SKowalski, Kamil  */
554d9f466b3SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(boost::urls::url_view arg1)
5551abe55efSEd Tanous {
556b6cd31e1SEd Tanous     return getLog(
557fffb8c1fSEd Tanous         redfish::registries::base::Index::resourceAtUriInUnknownFormat,
558079360aeSEd Tanous         std::to_array<std::string_view>({arg1.buffer()}));
559b5c07418SJames Feist }
560b5c07418SJames Feist 
561ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res,
562d9f466b3SEd Tanous                                   boost::urls::url_view arg1)
563b5c07418SJames Feist {
564b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
565b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
566f4c4dcf4SKowalski, Kamil }
567f4c4dcf4SKowalski, Kamil 
568f4c4dcf4SKowalski, Kamil /**
569f4c4dcf4SKowalski, Kamil  * @internal
57081856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
57181856681SAsmitha Karunanithi  *
57281856681SAsmitha Karunanithi  * See header file for more information
57381856681SAsmitha Karunanithi  * @endinternal
57481856681SAsmitha Karunanithi  */
5751668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1)
57681856681SAsmitha Karunanithi {
577fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceDisabled,
5781668ce6dSEd Tanous                   std::to_array({arg1}));
57981856681SAsmitha Karunanithi }
58081856681SAsmitha Karunanithi 
5811668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1)
58281856681SAsmitha Karunanithi {
58381856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
58481856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
58581856681SAsmitha Karunanithi }
58681856681SAsmitha Karunanithi 
58781856681SAsmitha Karunanithi /**
58881856681SAsmitha Karunanithi  * @internal
589f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
590f4c4dcf4SKowalski, Kamil  *
591f4c4dcf4SKowalski, Kamil  * See header file for more information
592f4c4dcf4SKowalski, Kamil  * @endinternal
593f4c4dcf4SKowalski, Kamil  */
594d9fcfcc1SEd Tanous nlohmann::json serviceInUnknownState()
5951abe55efSEd Tanous {
596fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
597b5c07418SJames Feist }
598b5c07418SJames Feist 
599b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
600b5c07418SJames Feist {
601b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
602b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
603f4c4dcf4SKowalski, Kamil }
604f4c4dcf4SKowalski, Kamil 
605f4c4dcf4SKowalski, Kamil /**
606f4c4dcf4SKowalski, Kamil  * @internal
607f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
608f4c4dcf4SKowalski, Kamil  *
609f4c4dcf4SKowalski, Kamil  * See header file for more information
610f4c4dcf4SKowalski, Kamil  * @endinternal
611f4c4dcf4SKowalski, Kamil  */
612d9fcfcc1SEd Tanous nlohmann::json eventSubscriptionLimitExceeded()
6131abe55efSEd Tanous {
614fffb8c1fSEd Tanous     return getLog(
615fffb8c1fSEd Tanous         redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
616b5c07418SJames Feist }
617b5c07418SJames Feist 
618b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
619b5c07418SJames Feist {
620789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
621b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
622f4c4dcf4SKowalski, Kamil }
623f4c4dcf4SKowalski, Kamil 
624f4c4dcf4SKowalski, Kamil /**
625f4c4dcf4SKowalski, Kamil  * @internal
626f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
627f4c4dcf4SKowalski, Kamil  *
628f4c4dcf4SKowalski, Kamil  * See header file for more information
629f4c4dcf4SKowalski, Kamil  * @endinternal
630f4c4dcf4SKowalski, Kamil  */
6311668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1,
6321668ce6dSEd Tanous                                       std::string_view arg2)
6331abe55efSEd Tanous {
634fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterMissing,
6351668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
636b5c07418SJames Feist }
637b5c07418SJames Feist 
6381668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1,
6391668ce6dSEd Tanous                             std::string_view arg2)
640b5c07418SJames Feist {
641b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
642b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
643f4c4dcf4SKowalski, Kamil }
644f4c4dcf4SKowalski, Kamil 
645f4c4dcf4SKowalski, Kamil /**
646f4c4dcf4SKowalski, Kamil  * @internal
647f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
648f4c4dcf4SKowalski, Kamil  *
649f4c4dcf4SKowalski, Kamil  * See header file for more information
650f4c4dcf4SKowalski, Kamil  * @endinternal
651f4c4dcf4SKowalski, Kamil  */
6521668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
6531abe55efSEd Tanous {
654b6cd31e1SEd Tanous     std::string arg2String = std::to_string(arg2);
655fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::stringValueTooLong,
6561668ce6dSEd Tanous                   std::to_array({arg1, std::string_view(arg2String)}));
657b5c07418SJames Feist }
658b5c07418SJames Feist 
6591668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
660b5c07418SJames Feist {
661b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
662b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
663f4c4dcf4SKowalski, Kamil }
664f4c4dcf4SKowalski, Kamil 
665f4c4dcf4SKowalski, Kamil /**
666f4c4dcf4SKowalski, Kamil  * @internal
667cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
668cc9139ecSJason M. Bills  *
669cc9139ecSJason M. Bills  * See header file for more information
670cc9139ecSJason M. Bills  * @endinternal
671cc9139ecSJason M. Bills  */
672d9fcfcc1SEd Tanous nlohmann::json sessionTerminated()
673cc9139ecSJason M. Bills {
674fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionTerminated, {});
675b5c07418SJames Feist }
676b5c07418SJames Feist 
677b5c07418SJames Feist void sessionTerminated(crow::Response& res)
678b5c07418SJames Feist {
679b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
680b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
681cc9139ecSJason M. Bills }
682cc9139ecSJason M. Bills 
683cc9139ecSJason M. Bills /**
684cc9139ecSJason M. Bills  * @internal
685684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
686684bb4b8SJason M. Bills  *
687684bb4b8SJason M. Bills  * See header file for more information
688684bb4b8SJason M. Bills  * @endinternal
689684bb4b8SJason M. Bills  */
690d9fcfcc1SEd Tanous nlohmann::json subscriptionTerminated()
691684bb4b8SJason M. Bills {
692fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
693684bb4b8SJason M. Bills }
694684bb4b8SJason M. Bills 
695684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
696684bb4b8SJason M. Bills {
697684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
698684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
699684bb4b8SJason M. Bills }
700684bb4b8SJason M. Bills 
701684bb4b8SJason M. Bills /**
702684bb4b8SJason M. Bills  * @internal
703cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
704cc9139ecSJason M. Bills  *
705cc9139ecSJason M. Bills  * See header file for more information
706cc9139ecSJason M. Bills  * @endinternal
707cc9139ecSJason M. Bills  */
7081668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1,
7091668ce6dSEd Tanous                                         std::string_view arg2)
710cc9139ecSJason M. Bills {
711fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
7121668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
713b5c07418SJames Feist }
714b5c07418SJames Feist 
7151668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
7161668ce6dSEd Tanous                               std::string_view arg2)
717b5c07418SJames Feist {
718b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
719b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
720cc9139ecSJason M. Bills }
721cc9139ecSJason M. Bills 
722cc9139ecSJason M. Bills /**
723cc9139ecSJason M. Bills  * @internal
724684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
725684bb4b8SJason M. Bills  *
726684bb4b8SJason M. Bills  * See header file for more information
727684bb4b8SJason M. Bills  * @endinternal
728684bb4b8SJason M. Bills  */
729d9f466b3SEd Tanous nlohmann::json resetRequired(boost::urls::url_view arg1, std::string_view arg2)
730684bb4b8SJason M. Bills {
731fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
732079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer(), arg2}));
733684bb4b8SJason M. Bills }
734684bb4b8SJason M. Bills 
735d9f466b3SEd Tanous void resetRequired(crow::Response& res, boost::urls::url_view arg1,
7361668ce6dSEd Tanous                    std::string_view arg2)
737684bb4b8SJason M. Bills {
738684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
739684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
740684bb4b8SJason M. Bills }
741684bb4b8SJason M. Bills 
742684bb4b8SJason M. Bills /**
743684bb4b8SJason M. Bills  * @internal
744684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
745684bb4b8SJason M. Bills  *
746684bb4b8SJason M. Bills  * See header file for more information
747684bb4b8SJason M. Bills  * @endinternal
748684bb4b8SJason M. Bills  */
7491668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
750684bb4b8SJason M. Bills {
751fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
7521668ce6dSEd Tanous                   std::to_array({arg1}));
753684bb4b8SJason M. Bills }
754684bb4b8SJason M. Bills 
7551668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
756684bb4b8SJason M. Bills {
757684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
758684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
759684bb4b8SJason M. Bills }
760684bb4b8SJason M. Bills 
761684bb4b8SJason M. Bills /**
762684bb4b8SJason M. Bills  * @internal
763684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
764684bb4b8SJason M. Bills  *
765684bb4b8SJason M. Bills  * See header file for more information
766684bb4b8SJason M. Bills  * @endinternal
767684bb4b8SJason M. Bills  */
7681668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
769684bb4b8SJason M. Bills {
770b6cd31e1SEd Tanous     return getLog(
771fffb8c1fSEd Tanous         redfish::registries::base::Index::chassisPowerStateOffRequired,
7721668ce6dSEd Tanous         std::to_array({arg1}));
773684bb4b8SJason M. Bills }
774684bb4b8SJason M. Bills 
7751668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1)
776684bb4b8SJason M. Bills {
777684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
778684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
779684bb4b8SJason M. Bills }
780684bb4b8SJason M. Bills 
781684bb4b8SJason M. Bills /**
782684bb4b8SJason M. Bills  * @internal
783684bb4b8SJason M. Bills  * @brief Formats PropertyValueConflict message into JSON
784684bb4b8SJason M. Bills  *
785684bb4b8SJason M. Bills  * See header file for more information
786684bb4b8SJason M. Bills  * @endinternal
787684bb4b8SJason M. Bills  */
7881668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1,
7891668ce6dSEd Tanous                                      std::string_view arg2)
790684bb4b8SJason M. Bills {
791fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueConflict,
7921668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
793684bb4b8SJason M. Bills }
794684bb4b8SJason M. Bills 
7951668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1,
7961668ce6dSEd Tanous                            std::string_view arg2)
797684bb4b8SJason M. Bills {
798684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
799684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
800684bb4b8SJason M. Bills }
801684bb4b8SJason M. Bills 
802684bb4b8SJason M. Bills /**
803684bb4b8SJason M. Bills  * @internal
8042a6af81cSRamesh Iyyar  * @brief Formats PropertyValueResourceConflict message into JSON
8052a6af81cSRamesh Iyyar  *
8062a6af81cSRamesh Iyyar  * See header file for more information
8072a6af81cSRamesh Iyyar  * @endinternal
8082a6af81cSRamesh Iyyar  */
8092a6af81cSRamesh Iyyar nlohmann::json propertyValueResourceConflict(std::string_view arg1,
81095b3ad73SEd Tanous                                              const nlohmann::json& arg2,
811d9f466b3SEd Tanous                                              boost::urls::url_view arg3)
8122a6af81cSRamesh Iyyar {
81395b3ad73SEd Tanous     std::string arg2Str = arg2.dump(2, ' ', true,
81495b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
81595b3ad73SEd Tanous 
8162a6af81cSRamesh Iyyar     return getLog(
8172a6af81cSRamesh Iyyar         redfish::registries::base::Index::propertyValueResourceConflict,
81895b3ad73SEd Tanous         std::to_array<std::string_view>({arg1, arg2Str, arg3.buffer()}));
8192a6af81cSRamesh Iyyar }
8202a6af81cSRamesh Iyyar 
8212a6af81cSRamesh Iyyar void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
82295b3ad73SEd Tanous                                    const nlohmann::json& arg2,
823d9f466b3SEd Tanous                                    boost::urls::url_view arg3)
8242a6af81cSRamesh Iyyar {
8252a6af81cSRamesh Iyyar     res.result(boost::beast::http::status::conflict);
8262a6af81cSRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
8272a6af81cSRamesh Iyyar                           propertyValueResourceConflict(arg1, arg2, arg3));
8282a6af81cSRamesh Iyyar }
8292a6af81cSRamesh Iyyar 
8302a6af81cSRamesh Iyyar /**
8312a6af81cSRamesh Iyyar  * @internal
83224861a28SRamesh Iyyar  * @brief Formats PropertyValueExternalConflict message into JSON
83324861a28SRamesh Iyyar  *
83424861a28SRamesh Iyyar  * See header file for more information
83524861a28SRamesh Iyyar  * @endinternal
83624861a28SRamesh Iyyar  */
83724861a28SRamesh Iyyar nlohmann::json propertyValueExternalConflict(std::string_view arg1,
83895b3ad73SEd Tanous                                              const nlohmann::json& arg2)
83924861a28SRamesh Iyyar {
84095b3ad73SEd Tanous     std::string arg2Str = arg2.dump(2, ' ', true,
84195b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
84295b3ad73SEd Tanous 
84324861a28SRamesh Iyyar     return getLog(
84424861a28SRamesh Iyyar         redfish::registries::base::Index::propertyValueExternalConflict,
84595b3ad73SEd Tanous         std::to_array<std::string_view>({arg1, arg2Str}));
84624861a28SRamesh Iyyar }
84724861a28SRamesh Iyyar 
84824861a28SRamesh Iyyar void propertyValueExternalConflict(crow::Response& res, std::string_view arg1,
84995b3ad73SEd Tanous                                    const nlohmann::json& arg2)
85024861a28SRamesh Iyyar {
85124861a28SRamesh Iyyar     res.result(boost::beast::http::status::conflict);
85224861a28SRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
85324861a28SRamesh Iyyar                           propertyValueExternalConflict(arg1, arg2));
85424861a28SRamesh Iyyar }
85524861a28SRamesh Iyyar 
85624861a28SRamesh Iyyar /**
85724861a28SRamesh Iyyar  * @internal
858684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
859684bb4b8SJason M. Bills  *
860684bb4b8SJason M. Bills  * See header file for more information
861684bb4b8SJason M. Bills  * @endinternal
862684bb4b8SJason M. Bills  */
86314fbced6SEd Tanous nlohmann::json propertyValueIncorrect(const nlohmann::json& arg1,
8641668ce6dSEd Tanous                                       std::string_view arg2)
865684bb4b8SJason M. Bills {
86614fbced6SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
86714fbced6SEd Tanous                                     nlohmann::json::error_handler_t::replace);
868fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueIncorrect,
86914fbced6SEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
870684bb4b8SJason M. Bills }
871684bb4b8SJason M. Bills 
87214fbced6SEd Tanous void propertyValueIncorrect(crow::Response& res, const nlohmann::json& arg1,
8731668ce6dSEd Tanous                             std::string_view arg2)
874684bb4b8SJason M. Bills {
875684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
876684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
877684bb4b8SJason M. Bills }
878684bb4b8SJason M. Bills 
879684bb4b8SJason M. Bills /**
880684bb4b8SJason M. Bills  * @internal
881684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
882684bb4b8SJason M. Bills  *
883684bb4b8SJason M. Bills  * See header file for more information
884684bb4b8SJason M. Bills  * @endinternal
885684bb4b8SJason M. Bills  */
886d9f466b3SEd Tanous nlohmann::json resourceCreationConflict(boost::urls::url_view arg1)
887684bb4b8SJason M. Bills {
888fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCreationConflict,
889079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
890684bb4b8SJason M. Bills }
891684bb4b8SJason M. Bills 
892d9f466b3SEd Tanous void resourceCreationConflict(crow::Response& res, boost::urls::url_view arg1)
893684bb4b8SJason M. Bills {
894684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
895684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
896684bb4b8SJason M. Bills }
897684bb4b8SJason M. Bills 
898684bb4b8SJason M. Bills /**
899684bb4b8SJason M. Bills  * @internal
900684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded message into JSON
901684bb4b8SJason M. Bills  *
902684bb4b8SJason M. Bills  * See header file for more information
903684bb4b8SJason M. Bills  * @endinternal
904684bb4b8SJason M. Bills  */
905d9fcfcc1SEd Tanous nlohmann::json maximumErrorsExceeded()
906684bb4b8SJason M. Bills {
907fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
908684bb4b8SJason M. Bills }
909684bb4b8SJason M. Bills 
910684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
911684bb4b8SJason M. Bills {
912684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
913684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
914684bb4b8SJason M. Bills }
915684bb4b8SJason M. Bills 
916684bb4b8SJason M. Bills /**
917684bb4b8SJason M. Bills  * @internal
918684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
919684bb4b8SJason M. Bills  *
920684bb4b8SJason M. Bills  * See header file for more information
921684bb4b8SJason M. Bills  * @endinternal
922684bb4b8SJason M. Bills  */
923d9fcfcc1SEd Tanous nlohmann::json preconditionFailed()
924684bb4b8SJason M. Bills {
925fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionFailed, {});
926684bb4b8SJason M. Bills }
927684bb4b8SJason M. Bills 
928684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
929684bb4b8SJason M. Bills {
9304df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
931684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
932684bb4b8SJason M. Bills }
933684bb4b8SJason M. Bills 
934684bb4b8SJason M. Bills /**
935684bb4b8SJason M. Bills  * @internal
936684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
937684bb4b8SJason M. Bills  *
938684bb4b8SJason M. Bills  * See header file for more information
939684bb4b8SJason M. Bills  * @endinternal
940684bb4b8SJason M. Bills  */
941d9fcfcc1SEd Tanous nlohmann::json preconditionRequired()
942684bb4b8SJason M. Bills {
943fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionRequired, {});
944684bb4b8SJason M. Bills }
945684bb4b8SJason M. Bills 
946684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
947684bb4b8SJason M. Bills {
948684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
949684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
950684bb4b8SJason M. Bills }
951684bb4b8SJason M. Bills 
952684bb4b8SJason M. Bills /**
953684bb4b8SJason M. Bills  * @internal
954684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
955684bb4b8SJason M. Bills  *
956684bb4b8SJason M. Bills  * See header file for more information
957684bb4b8SJason M. Bills  * @endinternal
958684bb4b8SJason M. Bills  */
959d9fcfcc1SEd Tanous nlohmann::json operationFailed()
960684bb4b8SJason M. Bills {
961fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationFailed, {});
962684bb4b8SJason M. Bills }
963684bb4b8SJason M. Bills 
964684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
965684bb4b8SJason M. Bills {
9668868776eSEd Tanous     res.result(boost::beast::http::status::bad_gateway);
967684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
968684bb4b8SJason M. Bills }
969684bb4b8SJason M. Bills 
970684bb4b8SJason M. Bills /**
971684bb4b8SJason M. Bills  * @internal
972684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
973684bb4b8SJason M. Bills  *
974684bb4b8SJason M. Bills  * See header file for more information
975684bb4b8SJason M. Bills  * @endinternal
976684bb4b8SJason M. Bills  */
977d9fcfcc1SEd Tanous nlohmann::json operationTimeout()
978684bb4b8SJason M. Bills {
979fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationTimeout, {});
980684bb4b8SJason M. Bills }
981684bb4b8SJason M. Bills 
982684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
983684bb4b8SJason M. Bills {
984684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
985684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
986684bb4b8SJason M. Bills }
987684bb4b8SJason M. Bills 
988684bb4b8SJason M. Bills /**
989684bb4b8SJason M. Bills  * @internal
990f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
991f12894f8SJason M. Bills  * property
992f12894f8SJason M. Bills  *
993f12894f8SJason M. Bills  * See header file for more information
994f12894f8SJason M. Bills  * @endinternal
995f12894f8SJason M. Bills  */
9962e8c4bdaSEd Tanous nlohmann::json propertyValueTypeError(const nlohmann::json& arg1,
9971668ce6dSEd Tanous                                       std::string_view arg2)
998f12894f8SJason M. Bills {
9992e8c4bdaSEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
10002e8c4bdaSEd Tanous                                     nlohmann::json::error_handler_t::replace);
1001fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueTypeError,
10022e8c4bdaSEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
1003b5c07418SJames Feist }
1004b5c07418SJames Feist 
10052e8c4bdaSEd Tanous void propertyValueTypeError(crow::Response& res, const nlohmann::json& arg1,
10061668ce6dSEd Tanous                             std::string_view arg2)
1007b5c07418SJames Feist {
1008b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1009b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
1010f4c4dcf4SKowalski, Kamil }
1011f4c4dcf4SKowalski, Kamil 
1012f4c4dcf4SKowalski, Kamil /**
1013f4c4dcf4SKowalski, Kamil  * @internal
1014b6cd31e1SEd Tanous  * @brief Formats ResourceNotFound message into JSONd
1015f4c4dcf4SKowalski, Kamil  *
1016f4c4dcf4SKowalski, Kamil  * See header file for more information
1017f4c4dcf4SKowalski, Kamil  * @endinternal
1018f4c4dcf4SKowalski, Kamil  */
10191668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
10201abe55efSEd Tanous {
1021fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceNotFound,
10221668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1023b5c07418SJames Feist }
1024b5c07418SJames Feist 
10251668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1,
10261668ce6dSEd Tanous                       std::string_view arg2)
1027b5c07418SJames Feist {
1028b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1029b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
1030f4c4dcf4SKowalski, Kamil }
1031f4c4dcf4SKowalski, Kamil 
1032f4c4dcf4SKowalski, Kamil /**
1033f4c4dcf4SKowalski, Kamil  * @internal
1034f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
1035f4c4dcf4SKowalski, Kamil  *
1036f4c4dcf4SKowalski, Kamil  * See header file for more information
1037f4c4dcf4SKowalski, Kamil  * @endinternal
1038f4c4dcf4SKowalski, Kamil  */
1039d9f466b3SEd Tanous nlohmann::json couldNotEstablishConnection(boost::urls::url_view arg1)
10401abe55efSEd Tanous {
1041fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
1042079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1043b5c07418SJames Feist }
1044b5c07418SJames Feist 
1045ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res,
1046d9f466b3SEd Tanous                                  boost::urls::url_view arg1)
1047b5c07418SJames Feist {
1048b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1049b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
1050f4c4dcf4SKowalski, Kamil }
1051f4c4dcf4SKowalski, Kamil 
1052f4c4dcf4SKowalski, Kamil /**
1053f4c4dcf4SKowalski, Kamil  * @internal
1054f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
1055f12894f8SJason M. Bills  * property
1056f12894f8SJason M. Bills  *
1057f12894f8SJason M. Bills  * See header file for more information
1058f12894f8SJason M. Bills  * @endinternal
1059f12894f8SJason M. Bills  */
10601668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1)
1061f12894f8SJason M. Bills {
1062fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyNotWritable,
10631668ce6dSEd Tanous                   std::to_array({arg1}));
1064b5c07418SJames Feist }
1065b5c07418SJames Feist 
10661668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1)
1067b5c07418SJames Feist {
1068b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1069b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1070f4c4dcf4SKowalski, Kamil }
1071f4c4dcf4SKowalski, Kamil 
1072f4c4dcf4SKowalski, Kamil /**
1073f4c4dcf4SKowalski, Kamil  * @internal
1074f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
1075f4c4dcf4SKowalski, Kamil  *
1076f4c4dcf4SKowalski, Kamil  * See header file for more information
1077f4c4dcf4SKowalski, Kamil  * @endinternal
1078f4c4dcf4SKowalski, Kamil  */
107995b3ad73SEd Tanous nlohmann::json queryParameterValueTypeError(const nlohmann::json& arg1,
10801668ce6dSEd Tanous                                             std::string_view arg2)
10811abe55efSEd Tanous {
108295b3ad73SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
108395b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
1084b6cd31e1SEd Tanous     return getLog(
1085fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueTypeError,
108695b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2}));
1087b5c07418SJames Feist }
1088b5c07418SJames Feist 
108995b3ad73SEd Tanous void queryParameterValueTypeError(crow::Response& res,
109095b3ad73SEd Tanous                                   const nlohmann::json& arg1,
10911668ce6dSEd Tanous                                   std::string_view arg2)
1092b5c07418SJames Feist {
1093b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1094b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1095b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
1096f4c4dcf4SKowalski, Kamil }
1097f4c4dcf4SKowalski, Kamil 
1098f4c4dcf4SKowalski, Kamil /**
1099f4c4dcf4SKowalski, Kamil  * @internal
1100f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
1101f4c4dcf4SKowalski, Kamil  *
1102f4c4dcf4SKowalski, Kamil  * See header file for more information
1103f4c4dcf4SKowalski, Kamil  * @endinternal
1104f4c4dcf4SKowalski, Kamil  */
1105d9fcfcc1SEd Tanous nlohmann::json serviceShuttingDown()
11061abe55efSEd Tanous {
1107fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
1108b5c07418SJames Feist }
1109b5c07418SJames Feist 
1110b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
1111b5c07418SJames Feist {
1112b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1113b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1114f4c4dcf4SKowalski, Kamil }
1115f4c4dcf4SKowalski, Kamil 
1116f4c4dcf4SKowalski, Kamil /**
1117f4c4dcf4SKowalski, Kamil  * @internal
1118f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
1119f4c4dcf4SKowalski, Kamil  *
1120f4c4dcf4SKowalski, Kamil  * See header file for more information
1121f4c4dcf4SKowalski, Kamil  * @endinternal
1122f4c4dcf4SKowalski, Kamil  */
11231668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1,
11241668ce6dSEd Tanous                                         std::string_view arg2)
11251abe55efSEd Tanous {
1126fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
11271668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1128b5c07418SJames Feist }
1129b5c07418SJames Feist 
11301668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
11311668ce6dSEd Tanous                               std::string_view arg2)
1132b5c07418SJames Feist {
1133b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1134b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1135f4c4dcf4SKowalski, Kamil }
1136f4c4dcf4SKowalski, Kamil 
1137f4c4dcf4SKowalski, Kamil /**
1138f4c4dcf4SKowalski, Kamil  * @internal
1139f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1140f4c4dcf4SKowalski, Kamil  *
1141f4c4dcf4SKowalski, Kamil  * See header file for more information
1142f4c4dcf4SKowalski, Kamil  * @endinternal
1143f4c4dcf4SKowalski, Kamil  */
11441668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1,
11451668ce6dSEd Tanous                                            std::string_view arg2)
11461abe55efSEd Tanous {
1147fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
11481668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1149b5c07418SJames Feist }
1150b5c07418SJames Feist 
11511668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
11521668ce6dSEd Tanous                                  std::string_view arg2)
1153b5c07418SJames Feist {
1154b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1155b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1156b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1157f4c4dcf4SKowalski, Kamil }
1158f4c4dcf4SKowalski, Kamil 
1159f4c4dcf4SKowalski, Kamil /**
1160f4c4dcf4SKowalski, Kamil  * @internal
1161f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1162f4c4dcf4SKowalski, Kamil  *
1163f4c4dcf4SKowalski, Kamil  * See header file for more information
1164f4c4dcf4SKowalski, Kamil  * @endinternal
1165f4c4dcf4SKowalski, Kamil  */
1166d9f466b3SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1,
11671668ce6dSEd Tanous                                             std::string_view arg2)
11681abe55efSEd Tanous {
1169b6cd31e1SEd Tanous     return getLog(
1170fffb8c1fSEd Tanous         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
1171079360aeSEd Tanous         std::to_array<std::string_view>({arg1.buffer(), arg2}));
1172b5c07418SJames Feist }
1173b5c07418SJames Feist 
1174ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res,
1175d9f466b3SEd Tanous                                   boost::urls::url_view arg1,
11761668ce6dSEd Tanous                                   std::string_view arg2)
1177b5c07418SJames Feist {
1178b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1179b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1180b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1181f4c4dcf4SKowalski, Kamil }
1182f4c4dcf4SKowalski, Kamil 
1183f4c4dcf4SKowalski, Kamil /**
1184f4c4dcf4SKowalski, Kamil  * @internal
1185b4ad4c05SShantappa Teekappanavar  * @brief Formats StrictAccountTypes message into JSON
1186b4ad4c05SShantappa Teekappanavar  *
1187b4ad4c05SShantappa Teekappanavar  * See header file for more information
1188b4ad4c05SShantappa Teekappanavar  * @endinternal
1189b4ad4c05SShantappa Teekappanavar  */
1190b4ad4c05SShantappa Teekappanavar nlohmann::json strictAccountTypes(std::string_view arg1)
1191b4ad4c05SShantappa Teekappanavar {
1192b4ad4c05SShantappa Teekappanavar     return getLog(redfish::registries::base::Index::strictAccountTypes,
1193b4ad4c05SShantappa Teekappanavar                   std::to_array({arg1}));
1194b4ad4c05SShantappa Teekappanavar }
1195b4ad4c05SShantappa Teekappanavar 
1196b4ad4c05SShantappa Teekappanavar void strictAccountTypes(crow::Response& res, std::string_view arg1)
1197b4ad4c05SShantappa Teekappanavar {
1198b4ad4c05SShantappa Teekappanavar     res.result(boost::beast::http::status::bad_request);
1199b4ad4c05SShantappa Teekappanavar     addMessageToErrorJson(res.jsonValue, strictAccountTypes(arg1));
1200b4ad4c05SShantappa Teekappanavar }
1201b4ad4c05SShantappa Teekappanavar 
1202b4ad4c05SShantappa Teekappanavar /**
1203b4ad4c05SShantappa Teekappanavar  * @internal
1204f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1205f4c4dcf4SKowalski, Kamil  *
1206f4c4dcf4SKowalski, Kamil  * See header file for more information
1207f4c4dcf4SKowalski, Kamil  * @endinternal
1208f4c4dcf4SKowalski, Kamil  */
1209d9fcfcc1SEd Tanous nlohmann::json accountRemoved()
12101abe55efSEd Tanous {
1211fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountRemoved, {});
1212b5c07418SJames Feist }
1213b5c07418SJames Feist 
1214b5c07418SJames Feist void accountRemoved(crow::Response& res)
1215b5c07418SJames Feist {
1216b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1217b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1218f4c4dcf4SKowalski, Kamil }
1219f4c4dcf4SKowalski, Kamil 
1220f4c4dcf4SKowalski, Kamil /**
1221f4c4dcf4SKowalski, Kamil  * @internal
1222f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1223f4c4dcf4SKowalski, Kamil  *
1224f4c4dcf4SKowalski, Kamil  * See header file for more information
1225f4c4dcf4SKowalski, Kamil  * @endinternal
1226f4c4dcf4SKowalski, Kamil  */
1227d9f466b3SEd Tanous nlohmann::json accessDenied(boost::urls::url_view arg1)
12281abe55efSEd Tanous {
1229fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accessDenied,
1230079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1231b5c07418SJames Feist }
1232b5c07418SJames Feist 
1233d9f466b3SEd Tanous void accessDenied(crow::Response& res, boost::urls::url_view arg1)
1234b5c07418SJames Feist {
1235b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1236b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1237f4c4dcf4SKowalski, Kamil }
1238f4c4dcf4SKowalski, Kamil 
1239f4c4dcf4SKowalski, Kamil /**
1240f4c4dcf4SKowalski, Kamil  * @internal
1241f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1242f4c4dcf4SKowalski, Kamil  *
1243f4c4dcf4SKowalski, Kamil  * See header file for more information
1244f4c4dcf4SKowalski, Kamil  * @endinternal
1245f4c4dcf4SKowalski, Kamil  */
1246d9fcfcc1SEd Tanous nlohmann::json queryNotSupported()
12471abe55efSEd Tanous {
1248fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1249b5c07418SJames Feist }
1250b5c07418SJames Feist 
1251b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1252b5c07418SJames Feist {
1253b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1254b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1255f4c4dcf4SKowalski, Kamil }
1256f4c4dcf4SKowalski, Kamil 
1257f4c4dcf4SKowalski, Kamil /**
1258f4c4dcf4SKowalski, Kamil  * @internal
1259f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1260f4c4dcf4SKowalski, Kamil  *
1261f4c4dcf4SKowalski, Kamil  * See header file for more information
1262f4c4dcf4SKowalski, Kamil  * @endinternal
1263f4c4dcf4SKowalski, Kamil  */
1264d9fcfcc1SEd Tanous nlohmann::json createLimitReachedForResource()
12651abe55efSEd Tanous {
1266b6cd31e1SEd Tanous     return getLog(
1267fffb8c1fSEd Tanous         redfish::registries::base::Index::createLimitReachedForResource, {});
1268b5c07418SJames Feist }
1269b5c07418SJames Feist 
1270b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1271b5c07418SJames Feist {
1272b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1273b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1274f4c4dcf4SKowalski, Kamil }
1275f4c4dcf4SKowalski, Kamil 
1276f4c4dcf4SKowalski, Kamil /**
1277f4c4dcf4SKowalski, Kamil  * @internal
1278f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1279f4c4dcf4SKowalski, Kamil  *
1280f4c4dcf4SKowalski, Kamil  * See header file for more information
1281f4c4dcf4SKowalski, Kamil  * @endinternal
1282f4c4dcf4SKowalski, Kamil  */
1283d9fcfcc1SEd Tanous nlohmann::json generalError()
12841abe55efSEd Tanous {
1285fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::generalError, {});
1286b5c07418SJames Feist }
1287b5c07418SJames Feist 
1288b5c07418SJames Feist void generalError(crow::Response& res)
1289b5c07418SJames Feist {
1290b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1291b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1292f4c4dcf4SKowalski, Kamil }
1293f4c4dcf4SKowalski, Kamil 
1294f4c4dcf4SKowalski, Kamil /**
1295f4c4dcf4SKowalski, Kamil  * @internal
1296f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1297f4c4dcf4SKowalski, Kamil  *
1298f4c4dcf4SKowalski, Kamil  * See header file for more information
1299f4c4dcf4SKowalski, Kamil  * @endinternal
1300f4c4dcf4SKowalski, Kamil  */
1301d9fcfcc1SEd Tanous nlohmann::json success()
13021abe55efSEd Tanous {
1303fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::success, {});
1304b5c07418SJames Feist }
1305b5c07418SJames Feist 
1306b5c07418SJames Feist void success(crow::Response& res)
1307b5c07418SJames Feist {
1308b5c07418SJames Feist     // don't set res.result here because success is the default and any
1309b5c07418SJames Feist     // error should overwrite the default
1310b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1311f12894f8SJason M. Bills }
1312f12894f8SJason M. Bills 
1313f12894f8SJason M. Bills /**
1314f12894f8SJason M. Bills  * @internal
1315f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1316f4c4dcf4SKowalski, Kamil  *
1317f4c4dcf4SKowalski, Kamil  * See header file for more information
1318f4c4dcf4SKowalski, Kamil  * @endinternal
1319f4c4dcf4SKowalski, Kamil  */
1320d9fcfcc1SEd Tanous nlohmann::json created()
13211abe55efSEd Tanous {
1322fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::created, {});
1323b5c07418SJames Feist }
1324b5c07418SJames Feist 
1325b5c07418SJames Feist void created(crow::Response& res)
1326b5c07418SJames Feist {
1327b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1328b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1329f4c4dcf4SKowalski, Kamil }
1330f4c4dcf4SKowalski, Kamil 
1331f4c4dcf4SKowalski, Kamil /**
1332f4c4dcf4SKowalski, Kamil  * @internal
1333cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1334cc9139ecSJason M. Bills  *
1335cc9139ecSJason M. Bills  * See header file for more information
1336cc9139ecSJason M. Bills  * @endinternal
1337cc9139ecSJason M. Bills  */
1338d9fcfcc1SEd Tanous nlohmann::json noOperation()
1339cc9139ecSJason M. Bills {
1340fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noOperation, {});
1341b5c07418SJames Feist }
1342b5c07418SJames Feist 
1343b5c07418SJames Feist void noOperation(crow::Response& res)
1344b5c07418SJames Feist {
1345b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1346b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1347cc9139ecSJason M. Bills }
1348cc9139ecSJason M. Bills 
1349cc9139ecSJason M. Bills /**
1350cc9139ecSJason M. Bills  * @internal
1351b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1352b5c07418SJames Feist  * property
1353f12894f8SJason M. Bills  *
1354f12894f8SJason M. Bills  * See header file for more information
1355f12894f8SJason M. Bills  * @endinternal
1356f12894f8SJason M. Bills  */
13571668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1)
1358b5c07418SJames Feist {
1359fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyUnknown,
13601668ce6dSEd Tanous                   std::to_array({arg1}));
1361b5c07418SJames Feist }
1362b5c07418SJames Feist 
13631668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1)
1364f12894f8SJason M. Bills {
1365f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
13667b1dd2f9SEd Tanous     addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1));
1367f4c4dcf4SKowalski, Kamil }
1368f4c4dcf4SKowalski, Kamil 
1369f4c4dcf4SKowalski, Kamil /**
1370f4c4dcf4SKowalski, Kamil  * @internal
1371f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1372f4c4dcf4SKowalski, Kamil  *
1373f4c4dcf4SKowalski, Kamil  * See header file for more information
1374f4c4dcf4SKowalski, Kamil  * @endinternal
1375f4c4dcf4SKowalski, Kamil  */
1376d9fcfcc1SEd Tanous nlohmann::json noValidSession()
13771abe55efSEd Tanous {
1378fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noValidSession, {});
1379b5c07418SJames Feist }
1380b5c07418SJames Feist 
1381b5c07418SJames Feist void noValidSession(crow::Response& res)
1382b5c07418SJames Feist {
1383b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1384b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1385f4c4dcf4SKowalski, Kamil }
1386f4c4dcf4SKowalski, Kamil 
1387f4c4dcf4SKowalski, Kamil /**
1388f4c4dcf4SKowalski, Kamil  * @internal
1389f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1390f4c4dcf4SKowalski, Kamil  *
1391f4c4dcf4SKowalski, Kamil  * See header file for more information
1392f4c4dcf4SKowalski, Kamil  * @endinternal
1393f4c4dcf4SKowalski, Kamil  */
1394d9f466b3SEd Tanous nlohmann::json invalidObject(boost::urls::url_view arg1)
13951abe55efSEd Tanous {
1396fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidObject,
1397079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1398b5c07418SJames Feist }
1399b5c07418SJames Feist 
1400d9f466b3SEd Tanous void invalidObject(crow::Response& res, boost::urls::url_view arg1)
1401b5c07418SJames Feist {
1402b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1403b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1404f4c4dcf4SKowalski, Kamil }
1405f4c4dcf4SKowalski, Kamil 
1406f4c4dcf4SKowalski, Kamil /**
1407f4c4dcf4SKowalski, Kamil  * @internal
1408f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1409f4c4dcf4SKowalski, Kamil  *
1410f4c4dcf4SKowalski, Kamil  * See header file for more information
1411f4c4dcf4SKowalski, Kamil  * @endinternal
1412f4c4dcf4SKowalski, Kamil  */
1413d9fcfcc1SEd Tanous nlohmann::json resourceInStandby()
14141abe55efSEd Tanous {
1415fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1416b5c07418SJames Feist }
1417b5c07418SJames Feist 
1418b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1419b5c07418SJames Feist {
1420b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1421b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1422f4c4dcf4SKowalski, Kamil }
1423f4c4dcf4SKowalski, Kamil 
1424f4c4dcf4SKowalski, Kamil /**
1425f4c4dcf4SKowalski, Kamil  * @internal
1426f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1427f4c4dcf4SKowalski, Kamil  *
1428f4c4dcf4SKowalski, Kamil  * See header file for more information
1429f4c4dcf4SKowalski, Kamil  * @endinternal
1430f4c4dcf4SKowalski, Kamil  */
143195b3ad73SEd Tanous nlohmann::json actionParameterValueTypeError(const nlohmann::json& arg1,
14321668ce6dSEd Tanous                                              std::string_view arg2,
14331668ce6dSEd Tanous                                              std::string_view arg3)
14341abe55efSEd Tanous {
143595b3ad73SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
143695b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
1437b6cd31e1SEd Tanous     return getLog(
1438fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueTypeError,
143995b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2, arg3}));
1440b5c07418SJames Feist }
1441b5c07418SJames Feist 
144295b3ad73SEd Tanous void actionParameterValueTypeError(crow::Response& res,
144395b3ad73SEd Tanous                                    const nlohmann::json& arg1,
14441668ce6dSEd Tanous                                    std::string_view arg2, std::string_view arg3)
1445b5c07418SJames Feist {
1446b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1447b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1448b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1449f4c4dcf4SKowalski, Kamil }
1450f4c4dcf4SKowalski, Kamil 
1451f4c4dcf4SKowalski, Kamil /**
1452f4c4dcf4SKowalski, Kamil  * @internal
1453f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1454f4c4dcf4SKowalski, Kamil  *
1455f4c4dcf4SKowalski, Kamil  * See header file for more information
1456f4c4dcf4SKowalski, Kamil  * @endinternal
1457f4c4dcf4SKowalski, Kamil  */
1458d9fcfcc1SEd Tanous nlohmann::json sessionLimitExceeded()
14591abe55efSEd Tanous {
1460fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1461b5c07418SJames Feist }
1462b5c07418SJames Feist 
1463b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1464b5c07418SJames Feist {
1465b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1466b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1467f4c4dcf4SKowalski, Kamil }
1468f4c4dcf4SKowalski, Kamil 
1469f4c4dcf4SKowalski, Kamil /**
1470f4c4dcf4SKowalski, Kamil  * @internal
1471f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1472f4c4dcf4SKowalski, Kamil  *
1473f4c4dcf4SKowalski, Kamil  * See header file for more information
1474f4c4dcf4SKowalski, Kamil  * @endinternal
1475f4c4dcf4SKowalski, Kamil  */
14761668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1)
14771abe55efSEd Tanous {
1478fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionNotSupported,
14791668ce6dSEd Tanous                   std::to_array({arg1}));
1480b5c07418SJames Feist }
1481b5c07418SJames Feist 
14821668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1)
1483b5c07418SJames Feist {
1484b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1485b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1486f4c4dcf4SKowalski, Kamil }
1487f4c4dcf4SKowalski, Kamil 
1488f4c4dcf4SKowalski, Kamil /**
1489f4c4dcf4SKowalski, Kamil  * @internal
1490f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1491f4c4dcf4SKowalski, Kamil  *
1492f4c4dcf4SKowalski, Kamil  * See header file for more information
1493f4c4dcf4SKowalski, Kamil  * @endinternal
1494f4c4dcf4SKowalski, Kamil  */
14955187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
14961abe55efSEd Tanous {
1497b6cd31e1SEd Tanous     std::string arg1Str = std::to_string(arg1);
1498fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidIndex,
14991668ce6dSEd Tanous                   std::to_array<std::string_view>({arg1Str}));
1500b5c07418SJames Feist }
1501b5c07418SJames Feist 
15025187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1503b5c07418SJames Feist {
1504b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1505b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1506f4c4dcf4SKowalski, Kamil }
1507f4c4dcf4SKowalski, Kamil 
1508f4c4dcf4SKowalski, Kamil /**
1509f4c4dcf4SKowalski, Kamil  * @internal
1510f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1511f4c4dcf4SKowalski, Kamil  *
1512f4c4dcf4SKowalski, Kamil  * See header file for more information
1513f4c4dcf4SKowalski, Kamil  * @endinternal
1514f4c4dcf4SKowalski, Kamil  */
1515d9fcfcc1SEd Tanous nlohmann::json emptyJSON()
15161abe55efSEd Tanous {
1517fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::emptyJSON, {});
1518b5c07418SJames Feist }
1519b5c07418SJames Feist 
1520b5c07418SJames Feist void emptyJSON(crow::Response& res)
1521b5c07418SJames Feist {
1522b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1523b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1524f4c4dcf4SKowalski, Kamil }
1525f4c4dcf4SKowalski, Kamil 
1526f4c4dcf4SKowalski, Kamil /**
1527f4c4dcf4SKowalski, Kamil  * @internal
1528f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1529f4c4dcf4SKowalski, Kamil  *
1530f4c4dcf4SKowalski, Kamil  * See header file for more information
1531f4c4dcf4SKowalski, Kamil  * @endinternal
1532f4c4dcf4SKowalski, Kamil  */
1533d9fcfcc1SEd Tanous nlohmann::json queryNotSupportedOnResource()
15341abe55efSEd Tanous {
1535fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1536b6cd31e1SEd Tanous                   {});
1537b5c07418SJames Feist }
1538b5c07418SJames Feist 
1539b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1540b5c07418SJames Feist {
15416a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1542b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1543f4c4dcf4SKowalski, Kamil }
1544f4c4dcf4SKowalski, Kamil 
1545f4c4dcf4SKowalski, Kamil /**
1546f4c4dcf4SKowalski, Kamil  * @internal
1547684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1548684bb4b8SJason M. Bills  *
1549684bb4b8SJason M. Bills  * See header file for more information
1550684bb4b8SJason M. Bills  * @endinternal
1551684bb4b8SJason M. Bills  */
1552d9fcfcc1SEd Tanous nlohmann::json queryNotSupportedOnOperation()
1553684bb4b8SJason M. Bills {
1554b6cd31e1SEd Tanous     return getLog(
1555fffb8c1fSEd Tanous         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1556684bb4b8SJason M. Bills }
1557684bb4b8SJason M. Bills 
1558684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1559684bb4b8SJason M. Bills {
15606a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1561684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1562684bb4b8SJason M. Bills }
1563684bb4b8SJason M. Bills 
1564684bb4b8SJason M. Bills /**
1565684bb4b8SJason M. Bills  * @internal
1566684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1567684bb4b8SJason M. Bills  *
1568684bb4b8SJason M. Bills  * See header file for more information
1569684bb4b8SJason M. Bills  * @endinternal
1570684bb4b8SJason M. Bills  */
1571d9fcfcc1SEd Tanous nlohmann::json queryCombinationInvalid()
1572684bb4b8SJason M. Bills {
1573fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1574fffb8c1fSEd Tanous                   {});
1575684bb4b8SJason M. Bills }
1576684bb4b8SJason M. Bills 
1577684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1578684bb4b8SJason M. Bills {
1579684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1580684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1581684bb4b8SJason M. Bills }
1582684bb4b8SJason M. Bills 
1583684bb4b8SJason M. Bills /**
1584684bb4b8SJason M. Bills  * @internal
1585f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1586f4c4dcf4SKowalski, Kamil  *
1587f4c4dcf4SKowalski, Kamil  * See header file for more information
1588f4c4dcf4SKowalski, Kamil  * @endinternal
1589f4c4dcf4SKowalski, Kamil  */
1590d9fcfcc1SEd Tanous nlohmann::json insufficientPrivilege()
15911abe55efSEd Tanous {
1592fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1593b5c07418SJames Feist }
1594b5c07418SJames Feist 
1595b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1596b5c07418SJames Feist {
1597b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1598b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1599f4c4dcf4SKowalski, Kamil }
1600f4c4dcf4SKowalski, Kamil 
1601f4c4dcf4SKowalski, Kamil /**
1602f4c4dcf4SKowalski, Kamil  * @internal
1603f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1604f4c4dcf4SKowalski, Kamil  *
1605f4c4dcf4SKowalski, Kamil  * See header file for more information
1606f4c4dcf4SKowalski, Kamil  * @endinternal
1607f4c4dcf4SKowalski, Kamil  */
16081668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1,
160995b3ad73SEd Tanous                                      const nlohmann::json& arg2)
1610b5c07418SJames Feist {
161195b3ad73SEd Tanous     std::string arg2Str = arg2.dump(2, ' ', true,
161295b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
1613fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueModified,
161495b3ad73SEd Tanous                   std::to_array<std::string_view>({arg1, arg2Str}));
1615b5c07418SJames Feist }
1616b5c07418SJames Feist 
16171668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1,
161895b3ad73SEd Tanous                            const nlohmann::json& arg2)
16191abe55efSEd Tanous {
1620f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1621b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1622f4c4dcf4SKowalski, Kamil }
1623f4c4dcf4SKowalski, Kamil 
1624f4c4dcf4SKowalski, Kamil /**
1625f4c4dcf4SKowalski, Kamil  * @internal
1626f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1627f4c4dcf4SKowalski, Kamil  *
1628f4c4dcf4SKowalski, Kamil  * See header file for more information
1629f4c4dcf4SKowalski, Kamil  * @endinternal
1630f4c4dcf4SKowalski, Kamil  */
1631d9fcfcc1SEd Tanous nlohmann::json accountNotModified()
16321abe55efSEd Tanous {
1633fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountNotModified, {});
1634b5c07418SJames Feist }
1635b5c07418SJames Feist 
1636b5c07418SJames Feist void accountNotModified(crow::Response& res)
1637b5c07418SJames Feist {
1638b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1639b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1640f4c4dcf4SKowalski, Kamil }
1641f4c4dcf4SKowalski, Kamil 
1642f4c4dcf4SKowalski, Kamil /**
1643f4c4dcf4SKowalski, Kamil  * @internal
1644f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1645f4c4dcf4SKowalski, Kamil  *
1646f4c4dcf4SKowalski, Kamil  * See header file for more information
1647f4c4dcf4SKowalski, Kamil  * @endinternal
1648f4c4dcf4SKowalski, Kamil  */
164995b3ad73SEd Tanous nlohmann::json queryParameterValueFormatError(const nlohmann::json& arg1,
16501668ce6dSEd Tanous                                               std::string_view arg2)
16511abe55efSEd Tanous {
165295b3ad73SEd Tanous     std::string arg1Str = arg1.dump(2, ' ', true,
165395b3ad73SEd Tanous                                     nlohmann::json::error_handler_t::replace);
1654fffb8c1fSEd Tanous     return getLog(
1655fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueFormatError,
165695b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2}));
1657b5c07418SJames Feist }
1658b5c07418SJames Feist 
165995b3ad73SEd Tanous void queryParameterValueFormatError(crow::Response& res,
166095b3ad73SEd Tanous                                     const nlohmann::json& arg1,
16611668ce6dSEd Tanous                                     std::string_view arg2)
1662b5c07418SJames Feist {
1663b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1664b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1665b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
1666f4c4dcf4SKowalski, Kamil }
1667f4c4dcf4SKowalski, Kamil 
1668f4c4dcf4SKowalski, Kamil /**
1669f4c4dcf4SKowalski, Kamil  * @internal
1670b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
1671b5c07418SJames Feist  * property
1672f12894f8SJason M. Bills  *
1673f12894f8SJason M. Bills  * See header file for more information
1674f12894f8SJason M. Bills  * @endinternal
1675f12894f8SJason M. Bills  */
16761668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1)
1677f12894f8SJason M. Bills {
1678fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyMissing,
16791668ce6dSEd Tanous                   std::to_array({arg1}));
1680b5c07418SJames Feist }
1681b5c07418SJames Feist 
16821668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1)
1683b5c07418SJames Feist {
1684b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1685b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1686f4c4dcf4SKowalski, Kamil }
1687f4c4dcf4SKowalski, Kamil 
1688f4c4dcf4SKowalski, Kamil /**
1689f4c4dcf4SKowalski, Kamil  * @internal
1690f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
1691f4c4dcf4SKowalski, Kamil  *
1692f4c4dcf4SKowalski, Kamil  * See header file for more information
1693f4c4dcf4SKowalski, Kamil  * @endinternal
1694f4c4dcf4SKowalski, Kamil  */
16951668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1)
16961abe55efSEd Tanous {
1697fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceExhaustion,
16981668ce6dSEd Tanous                   std::to_array({arg1}));
1699b5c07418SJames Feist }
1700b5c07418SJames Feist 
17011668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1)
1702b5c07418SJames Feist {
1703b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1704b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1705f4c4dcf4SKowalski, Kamil }
1706f4c4dcf4SKowalski, Kamil 
1707f4c4dcf4SKowalski, Kamil /**
1708f4c4dcf4SKowalski, Kamil  * @internal
1709f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
1710f4c4dcf4SKowalski, Kamil  *
1711f4c4dcf4SKowalski, Kamil  * See header file for more information
1712f4c4dcf4SKowalski, Kamil  * @endinternal
1713f4c4dcf4SKowalski, Kamil  */
1714d9fcfcc1SEd Tanous nlohmann::json accountModified()
17151abe55efSEd Tanous {
1716fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountModified, {});
1717b5c07418SJames Feist }
1718b5c07418SJames Feist 
1719b5c07418SJames Feist void accountModified(crow::Response& res)
1720b5c07418SJames Feist {
1721b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1722b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
1723f4c4dcf4SKowalski, Kamil }
1724f4c4dcf4SKowalski, Kamil 
1725f4c4dcf4SKowalski, Kamil /**
1726f4c4dcf4SKowalski, Kamil  * @internal
1727f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
1728f4c4dcf4SKowalski, Kamil  *
1729f4c4dcf4SKowalski, Kamil  * See header file for more information
1730f4c4dcf4SKowalski, Kamil  * @endinternal
1731f4c4dcf4SKowalski, Kamil  */
17321668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1,
17331668ce6dSEd Tanous                                         std::string_view arg2,
17341668ce6dSEd Tanous                                         std::string_view arg3)
17351abe55efSEd Tanous {
1736fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
17371668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
1738b5c07418SJames Feist }
1739b5c07418SJames Feist 
17401668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
17411668ce6dSEd Tanous                               std::string_view arg2, std::string_view arg3)
1742b5c07418SJames Feist {
1743b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1744b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1745b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
1746f4c4dcf4SKowalski, Kamil }
1747f4c4dcf4SKowalski, Kamil 
1748d9f466b3SEd Tanous nlohmann::json passwordChangeRequired(boost::urls::url_view arg1)
1749b6cd31e1SEd Tanous {
1750fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::passwordChangeRequired,
1751079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1752b6cd31e1SEd Tanous }
1753b6cd31e1SEd Tanous 
17543bf4e632SJoseph Reynolds /**
17553bf4e632SJoseph Reynolds  * @internal
17563bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
17573bf4e632SJoseph Reynolds  *
17583bf4e632SJoseph Reynolds  * See header file for more information
17593bf4e632SJoseph Reynolds  * @endinternal
17603bf4e632SJoseph Reynolds  */
1761d9f466b3SEd Tanous void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1)
17623bf4e632SJoseph Reynolds {
1763b6cd31e1SEd Tanous     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
17643bf4e632SJoseph Reynolds }
17653bf4e632SJoseph Reynolds 
17664cde5d90SJames Feist /**
17674cde5d90SJames Feist  * @internal
1768ae688313SNan Zhou  * @brief Formats InsufficientStorage message into JSON
1769ae688313SNan Zhou  *
1770ae688313SNan Zhou  * See header file for more information
1771ae688313SNan Zhou  * @endinternal
1772ae688313SNan Zhou  */
1773ae688313SNan Zhou nlohmann::json insufficientStorage()
1774ae688313SNan Zhou {
1775ae688313SNan Zhou     return getLog(redfish::registries::base::Index::insufficientStorage, {});
1776ae688313SNan Zhou }
1777ae688313SNan Zhou 
1778ae688313SNan Zhou void insufficientStorage(crow::Response& res)
1779ae688313SNan Zhou {
1780ae688313SNan Zhou     res.result(boost::beast::http::status::insufficient_storage);
1781ae688313SNan Zhou     addMessageToErrorJson(res.jsonValue, insufficientStorage());
1782ae688313SNan Zhou }
1783ae688313SNan Zhou 
1784ae688313SNan Zhou /**
1785ae688313SNan Zhou  * @internal
178644c70412SEd Tanous  * @brief Formats OperationNotAllowed message into JSON
178744c70412SEd Tanous  *
178844c70412SEd Tanous  * See header file for more information
178944c70412SEd Tanous  * @endinternal
179044c70412SEd Tanous  */
179144c70412SEd Tanous nlohmann::json operationNotAllowed()
179244c70412SEd Tanous {
179344c70412SEd Tanous     return getLog(redfish::registries::base::Index::operationNotAllowed, {});
179444c70412SEd Tanous }
179544c70412SEd Tanous 
179644c70412SEd Tanous void operationNotAllowed(crow::Response& res)
179744c70412SEd Tanous {
179844c70412SEd Tanous     res.result(boost::beast::http::status::method_not_allowed);
179944c70412SEd Tanous     addMessageToErrorJson(res.jsonValue, operationNotAllowed());
180044c70412SEd Tanous }
180144c70412SEd Tanous 
1802600af5f1SAppaRao Puli /**
1803600af5f1SAppaRao Puli  * @internal
1804600af5f1SAppaRao Puli  * @brief Formats ArraySizeTooLong message into JSON
1805600af5f1SAppaRao Puli  *
1806600af5f1SAppaRao Puli  * See header file for more information
1807600af5f1SAppaRao Puli  * @endinternal
1808600af5f1SAppaRao Puli  */
1809600af5f1SAppaRao Puli nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length)
1810600af5f1SAppaRao Puli {
1811600af5f1SAppaRao Puli     std::string valStr = std::to_string(length);
1812600af5f1SAppaRao Puli     return getLog(redfish::registries::base::Index::arraySizeTooLong,
1813600af5f1SAppaRao Puli                   std::to_array<std::string_view>({property, valStr}));
1814600af5f1SAppaRao Puli }
1815600af5f1SAppaRao Puli 
1816600af5f1SAppaRao Puli void arraySizeTooLong(crow::Response& res, std::string_view property,
1817600af5f1SAppaRao Puli                       uint64_t length)
1818600af5f1SAppaRao Puli {
1819*99bf0262SDivya Jyoti     res.result(boost::beast::http::status::bad_request);
1820600af5f1SAppaRao Puli     addMessageToErrorJson(res.jsonValue, arraySizeTooLong(property, length));
1821600af5f1SAppaRao Puli }
1822600af5f1SAppaRao Puli 
182344c70412SEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1,
182444c70412SEd Tanous                    std::string_view arg2)
182544c70412SEd Tanous {
182644c70412SEd Tanous     res.result(boost::beast::http::status::bad_request);
182744c70412SEd Tanous     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
182844c70412SEd Tanous }
182944c70412SEd Tanous 
183044c70412SEd Tanous /**
183144c70412SEd Tanous  * @internal
18324cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
18334cde5d90SJames Feist  *
18344cde5d90SJames Feist  * See header file for more information
18354cde5d90SJames Feist  * @endinternal
18364cde5d90SJames Feist  */
18371668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
18384cde5d90SJames Feist {
18391668ce6dSEd Tanous     std::string msg = "Invalid file uploaded to ";
18401668ce6dSEd Tanous     msg += arg1;
18411668ce6dSEd Tanous     msg += ": ";
18421668ce6dSEd Tanous     msg += arg2;
18431668ce6dSEd Tanous     msg += ".";
1844613dabeaSEd Tanous 
1845613dabeaSEd Tanous     nlohmann::json::object_t ret;
1846613dabeaSEd Tanous     ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message";
1847613dabeaSEd Tanous     ret["MessageId"] = "OpenBMC.0.2.InvalidUpload";
1848613dabeaSEd Tanous     ret["Message"] = std::move(msg);
1849613dabeaSEd Tanous     nlohmann::json::array_t args;
1850ad539545SPatrick Williams     args.emplace_back(arg1);
1851ad539545SPatrick Williams     args.emplace_back(arg2);
1852613dabeaSEd Tanous     ret["MessageArgs"] = std::move(args);
1853613dabeaSEd Tanous     ret["MessageSeverity"] = "Warning";
1854613dabeaSEd Tanous     ret["Resolution"] = "None.";
1855613dabeaSEd Tanous     return ret;
18564cde5d90SJames Feist }
1857ae688313SNan Zhou 
1858f4c4dcf4SKowalski, Kamil } // namespace messages
1859f4c4dcf4SKowalski, Kamil 
1860d425c6f6SEd Tanous } // namespace redfish
1861