xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision d9f466b3b92f242343dcdecae83b40579f92c506)
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 "nlohmann/json.hpp"
210442ef92SNan Zhou #include "registries.hpp"
220442ef92SNan Zhou #include "registries/base_message_registry.hpp"
230442ef92SNan Zhou #include "source_location.hpp"
240442ef92SNan Zhou 
250442ef92SNan Zhou #include <boost/beast/http/field.hpp>
269ea15c35SEd Tanous #include <boost/beast/http/status.hpp>
27f4c4dcf4SKowalski, Kamil 
281668ce6dSEd Tanous #include <array>
290442ef92SNan Zhou #include <cstddef>
300442ef92SNan Zhou #include <span>
310442ef92SNan Zhou #include <string>
320442ef92SNan Zhou #include <utility>
330442ef92SNan Zhou 
340442ef92SNan Zhou // IWYU pragma: no_include <stddef.h>
351668ce6dSEd Tanous 
361abe55efSEd Tanous namespace redfish
371abe55efSEd Tanous {
381abe55efSEd Tanous 
391abe55efSEd Tanous namespace messages
401abe55efSEd Tanous {
41f4c4dcf4SKowalski, Kamil 
42f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target,
431abe55efSEd Tanous                                   const nlohmann::json& message)
441abe55efSEd Tanous {
45f4c4dcf4SKowalski, Kamil     auto& error = target["error"];
46f4c4dcf4SKowalski, Kamil 
471abe55efSEd Tanous     // If this is the first error message, fill in the information from the
481abe55efSEd Tanous     // first error message to the top level struct
491abe55efSEd Tanous     if (!error.is_object())
501abe55efSEd Tanous     {
51c074230bSJason M. Bills         auto messageIdIterator = message.find("MessageId");
52c074230bSJason M. Bills         if (messageIdIterator == message.end())
531abe55efSEd Tanous         {
541abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
551abe55efSEd Tanous                 << "Attempt to add error message without MessageId";
56f4c4dcf4SKowalski, Kamil             return;
57f4c4dcf4SKowalski, Kamil         }
58f4c4dcf4SKowalski, Kamil 
59c074230bSJason M. Bills         auto messageFieldIterator = message.find("Message");
60c074230bSJason M. Bills         if (messageFieldIterator == message.end())
611abe55efSEd Tanous         {
621abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
631abe55efSEd Tanous                 << "Attempt to add error message without Message";
64f4c4dcf4SKowalski, Kamil             return;
65f4c4dcf4SKowalski, Kamil         }
661476687dSEd Tanous         error["code"] = *messageIdIterator;
671476687dSEd Tanous         error["message"] = *messageFieldIterator;
681abe55efSEd Tanous     }
691abe55efSEd Tanous     else
701abe55efSEd Tanous     {
71f4c4dcf4SKowalski, Kamil         // More than 1 error occurred, so the message has to be generic
7255c7b7a2SEd Tanous         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
73cc9139ecSJason M. Bills         error["message"] = "A general error has occurred. See Resolution for "
74cc9139ecSJason M. Bills                            "information on how to resolve the error.";
75f4c4dcf4SKowalski, Kamil     }
76f4c4dcf4SKowalski, Kamil 
773590bd1dSNan Zhou     // This check could technically be done in the default construction
78f4c4dcf4SKowalski, Kamil     // branch above, but because we need the pointer to the extended info field
79f4c4dcf4SKowalski, Kamil     // anyway, it's more efficient to do it here.
80c074230bSJason M. Bills     auto& extendedInfo = error[messages::messageAnnotation];
81c074230bSJason M. Bills     if (!extendedInfo.is_array())
821abe55efSEd Tanous     {
83c074230bSJason M. Bills         extendedInfo = nlohmann::json::array();
84f4c4dcf4SKowalski, Kamil     }
85f4c4dcf4SKowalski, Kamil 
86c074230bSJason M. Bills     extendedInfo.push_back(message);
87f4c4dcf4SKowalski, Kamil }
88f4c4dcf4SKowalski, Kamil 
893590bd1dSNan Zhou void moveErrorsToErrorJson(nlohmann::json& target, nlohmann::json& source)
903590bd1dSNan Zhou {
913590bd1dSNan Zhou     if (!source.is_object())
923590bd1dSNan Zhou     {
933590bd1dSNan Zhou         return;
943590bd1dSNan Zhou     }
953590bd1dSNan Zhou     auto errorIt = source.find("error");
963590bd1dSNan Zhou     if (errorIt == source.end())
973590bd1dSNan Zhou     {
983590bd1dSNan Zhou         // caller puts error message in root
993590bd1dSNan Zhou         messages::addMessageToErrorJson(target, source);
1003590bd1dSNan Zhou         source.clear();
1013590bd1dSNan Zhou         return;
1023590bd1dSNan Zhou     }
1033590bd1dSNan Zhou     auto extendedInfoIt = errorIt->find(messages::messageAnnotation);
1043590bd1dSNan Zhou     if (extendedInfoIt == errorIt->end())
1053590bd1dSNan Zhou     {
1063590bd1dSNan Zhou         return;
1073590bd1dSNan Zhou     }
1083590bd1dSNan Zhou     const nlohmann::json::array_t* extendedInfo =
1093590bd1dSNan Zhou         (*extendedInfoIt).get_ptr<const nlohmann::json::array_t*>();
1103590bd1dSNan Zhou     if (extendedInfo == nullptr)
1113590bd1dSNan Zhou     {
1123590bd1dSNan Zhou         source.erase(errorIt);
1133590bd1dSNan Zhou         return;
1143590bd1dSNan Zhou     }
1153590bd1dSNan Zhou     for (const nlohmann::json& message : *extendedInfo)
1163590bd1dSNan Zhou     {
1173590bd1dSNan Zhou         addMessageToErrorJson(target, message);
1183590bd1dSNan Zhou     }
1193590bd1dSNan Zhou     source.erase(errorIt);
1203590bd1dSNan Zhou }
1213590bd1dSNan Zhou 
122f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target,
123f12894f8SJason M. Bills                                  const nlohmann::json& message)
1241abe55efSEd Tanous {
1251abe55efSEd Tanous     if (!target[messages::messageAnnotation].is_array())
1261abe55efSEd Tanous     {
127f4c4dcf4SKowalski, Kamil         // Force object to be an array
12855c7b7a2SEd Tanous         target[messages::messageAnnotation] = nlohmann::json::array();
129f4c4dcf4SKowalski, Kamil     }
130f4c4dcf4SKowalski, Kamil 
13155c7b7a2SEd Tanous     target[messages::messageAnnotation].push_back(message);
132f4c4dcf4SKowalski, Kamil }
133f4c4dcf4SKowalski, Kamil 
134f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target,
135f12894f8SJason M. Bills                              const nlohmann::json& message,
1361668ce6dSEd Tanous                              std::string_view fieldPath)
1371abe55efSEd Tanous {
1381668ce6dSEd Tanous     std::string extendedInfo(fieldPath);
1391668ce6dSEd Tanous     extendedInfo += messages::messageAnnotation;
140f4c4dcf4SKowalski, Kamil 
1411668ce6dSEd Tanous     nlohmann::json& field = target[extendedInfo];
1421668ce6dSEd Tanous     if (!field.is_array())
1431abe55efSEd Tanous     {
144f4c4dcf4SKowalski, Kamil         // Force object to be an array
1451668ce6dSEd Tanous         field = nlohmann::json::array();
146f4c4dcf4SKowalski, Kamil     }
147f4c4dcf4SKowalski, Kamil 
148f4c4dcf4SKowalski, Kamil     // Object exists and it is an array so we can just push in the message
1491668ce6dSEd Tanous     field.push_back(message);
150f4c4dcf4SKowalski, Kamil }
151f4c4dcf4SKowalski, Kamil 
152f7725d79SEd Tanous static nlohmann::json getLog(redfish::registries::base::Index name,
153b6cd31e1SEd Tanous                              std::span<const std::string_view> args)
154b6cd31e1SEd Tanous {
155b6cd31e1SEd Tanous     size_t index = static_cast<size_t>(name);
156fffb8c1fSEd Tanous     if (index >= redfish::registries::base::registry.size())
157b6cd31e1SEd Tanous     {
158b6cd31e1SEd Tanous         return {};
159b6cd31e1SEd Tanous     }
16065e4f1f7SEd Tanous     return getLogFromRegistry(redfish::registries::base::header,
16165e4f1f7SEd Tanous                               redfish::registries::base::registry, index, args);
162b6cd31e1SEd Tanous }
163b6cd31e1SEd Tanous 
164f4c4dcf4SKowalski, Kamil /**
165f4c4dcf4SKowalski, Kamil  * @internal
166f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
167f4c4dcf4SKowalski, Kamil  *
168f4c4dcf4SKowalski, Kamil  * See header file for more information
169f4c4dcf4SKowalski, Kamil  * @endinternal
170f4c4dcf4SKowalski, Kamil  */
171b5c07418SJames Feist nlohmann::json resourceInUse(void)
1721abe55efSEd Tanous {
173fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInUse, {});
174b5c07418SJames Feist }
175b5c07418SJames Feist 
176b5c07418SJames Feist void resourceInUse(crow::Response& res)
177b5c07418SJames Feist {
178b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
179b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
180f4c4dcf4SKowalski, Kamil }
181f4c4dcf4SKowalski, Kamil 
182f4c4dcf4SKowalski, Kamil /**
183f4c4dcf4SKowalski, Kamil  * @internal
184f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
185f4c4dcf4SKowalski, Kamil  *
186f4c4dcf4SKowalski, Kamil  * See header file for more information
187f4c4dcf4SKowalski, Kamil  * @endinternal
188f4c4dcf4SKowalski, Kamil  */
189b5c07418SJames Feist nlohmann::json malformedJSON(void)
1901abe55efSEd Tanous {
191fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::malformedJSON, {});
192b5c07418SJames Feist }
193b5c07418SJames Feist 
194b5c07418SJames Feist void malformedJSON(crow::Response& res)
195b5c07418SJames Feist {
196b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
197b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
198f4c4dcf4SKowalski, Kamil }
199f4c4dcf4SKowalski, Kamil 
200f4c4dcf4SKowalski, Kamil /**
201f4c4dcf4SKowalski, Kamil  * @internal
202f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
203f4c4dcf4SKowalski, Kamil  *
204f4c4dcf4SKowalski, Kamil  * See header file for more information
205f4c4dcf4SKowalski, Kamil  * @endinternal
206f4c4dcf4SKowalski, Kamil  */
207*d9f466b3SEd Tanous nlohmann::json resourceMissingAtURI(boost::urls::url_view arg1)
2081abe55efSEd Tanous {
209079360aeSEd Tanous     std::array<std::string_view, 1> args{arg1.buffer()};
210fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceMissingAtURI, args);
211b5c07418SJames Feist }
212b5c07418SJames Feist 
213*d9f466b3SEd Tanous void resourceMissingAtURI(crow::Response& res, boost::urls::url_view arg1)
214b5c07418SJames Feist {
215b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
216b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
217f4c4dcf4SKowalski, Kamil }
218f4c4dcf4SKowalski, Kamil 
219f4c4dcf4SKowalski, Kamil /**
220f4c4dcf4SKowalski, Kamil  * @internal
221f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
222f4c4dcf4SKowalski, Kamil  *
223f4c4dcf4SKowalski, Kamil  * See header file for more information
224f4c4dcf4SKowalski, Kamil  * @endinternal
225f4c4dcf4SKowalski, Kamil  */
2261668ce6dSEd Tanous nlohmann::json actionParameterValueFormatError(std::string_view arg1,
2271668ce6dSEd Tanous                                                std::string_view arg2,
2281668ce6dSEd Tanous                                                std::string_view arg3)
2291abe55efSEd Tanous {
230fffb8c1fSEd Tanous     return getLog(
231fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueFormatError,
2321668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
233b5c07418SJames Feist }
234b5c07418SJames Feist 
2351668ce6dSEd Tanous void actionParameterValueFormatError(crow::Response& res, std::string_view arg1,
2361668ce6dSEd Tanous                                      std::string_view arg2,
2371668ce6dSEd Tanous                                      std::string_view arg3)
238b5c07418SJames Feist {
239b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
240b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
241b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
242f4c4dcf4SKowalski, Kamil }
243f4c4dcf4SKowalski, Kamil 
244f4c4dcf4SKowalski, Kamil /**
245f4c4dcf4SKowalski, Kamil  * @internal
2464ef82a15SAlex Schendel  * @brief Formats ActionParameterValueNotInList message into JSON
2474ef82a15SAlex Schendel  *
2484ef82a15SAlex Schendel  * See header file for more information
2494ef82a15SAlex Schendel  * @endinternal
2504ef82a15SAlex Schendel  */
2514ef82a15SAlex Schendel nlohmann::json actionParameterValueNotInList(std::string_view arg1,
2524ef82a15SAlex Schendel                                              std::string_view arg2,
2534ef82a15SAlex Schendel                                              std::string_view arg3)
2544ef82a15SAlex Schendel {
2554ef82a15SAlex Schendel     return getLog(
2564ef82a15SAlex Schendel         redfish::registries::base::Index::actionParameterValueNotInList,
2574ef82a15SAlex Schendel         std::to_array({arg1, arg2, arg3}));
2584ef82a15SAlex Schendel }
2594ef82a15SAlex Schendel 
2604ef82a15SAlex Schendel void actionParameterValueNotInList(crow::Response& res, std::string_view arg1,
2614ef82a15SAlex Schendel                                    std::string_view arg2, std::string_view arg3)
2624ef82a15SAlex Schendel {
2634ef82a15SAlex Schendel     res.result(boost::beast::http::status::bad_request);
2644ef82a15SAlex Schendel     addMessageToErrorJson(res.jsonValue,
2654ef82a15SAlex Schendel                           actionParameterValueNotInList(arg1, arg2, arg3));
2664ef82a15SAlex Schendel }
2674ef82a15SAlex Schendel 
2684ef82a15SAlex Schendel /**
2694ef82a15SAlex Schendel  * @internal
270f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
271f4c4dcf4SKowalski, Kamil  *
272f4c4dcf4SKowalski, Kamil  * See header file for more information
273f4c4dcf4SKowalski, Kamil  * @endinternal
274f4c4dcf4SKowalski, Kamil  */
275b5c07418SJames Feist nlohmann::json internalError(void)
2761abe55efSEd Tanous {
277fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::internalError, {});
278b5c07418SJames Feist }
279b5c07418SJames Feist 
280df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location)
281b5c07418SJames Feist {
282df5415fcSEd Tanous     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
283df5415fcSEd Tanous                         << location.line() << ":" << location.column() << ") `"
284df5415fcSEd Tanous                         << location.function_name() << "`: ";
285b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
286b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
287f12894f8SJason M. Bills }
288f12894f8SJason M. Bills 
289f12894f8SJason M. Bills /**
290f12894f8SJason M. Bills  * @internal
291f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
292f4c4dcf4SKowalski, Kamil  *
293f4c4dcf4SKowalski, Kamil  * See header file for more information
294f4c4dcf4SKowalski, Kamil  * @endinternal
295f4c4dcf4SKowalski, Kamil  */
296b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void)
2971abe55efSEd Tanous {
298fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::unrecognizedRequestBody,
299fffb8c1fSEd Tanous                   {});
300b5c07418SJames Feist }
301b5c07418SJames Feist 
302b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
303b5c07418SJames Feist {
304b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
305b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
306f4c4dcf4SKowalski, Kamil }
307f4c4dcf4SKowalski, Kamil 
308f4c4dcf4SKowalski, Kamil /**
309f4c4dcf4SKowalski, Kamil  * @internal
310f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
311f4c4dcf4SKowalski, Kamil  *
312f4c4dcf4SKowalski, Kamil  * See header file for more information
313f4c4dcf4SKowalski, Kamil  * @endinternal
314f4c4dcf4SKowalski, Kamil  */
315*d9f466b3SEd Tanous nlohmann::json resourceAtUriUnauthorized(boost::urls::url_view arg1,
3161668ce6dSEd Tanous                                          std::string_view arg2)
3171abe55efSEd Tanous {
318079360aeSEd Tanous     return getLog(redfish::registries::base::Index::resourceAtUriUnauthorized,
319079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer(), arg2}));
320b5c07418SJames Feist }
321b5c07418SJames Feist 
322*d9f466b3SEd Tanous void resourceAtUriUnauthorized(crow::Response& res, boost::urls::url_view arg1,
3231668ce6dSEd Tanous                                std::string_view arg2)
324b5c07418SJames Feist {
325b5c07418SJames Feist     res.result(boost::beast::http::status::unauthorized);
326b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
327f4c4dcf4SKowalski, Kamil }
328f4c4dcf4SKowalski, Kamil 
329f4c4dcf4SKowalski, Kamil /**
330f4c4dcf4SKowalski, Kamil  * @internal
331f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterUnknown message into JSON
332f4c4dcf4SKowalski, Kamil  *
333f4c4dcf4SKowalski, Kamil  * See header file for more information
334f4c4dcf4SKowalski, Kamil  * @endinternal
335f4c4dcf4SKowalski, Kamil  */
3361668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1,
3371668ce6dSEd Tanous                                       std::string_view arg2)
338b5c07418SJames Feist {
339fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterUnknown,
3401668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
341b5c07418SJames Feist }
342b5c07418SJames Feist 
3431668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1,
3441668ce6dSEd Tanous                             std::string_view arg2)
3451abe55efSEd Tanous {
346f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
347b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
348f4c4dcf4SKowalski, Kamil }
349f4c4dcf4SKowalski, Kamil 
350f4c4dcf4SKowalski, Kamil /**
351f4c4dcf4SKowalski, Kamil  * @internal
352f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceCannotBeDeleted message into JSON
353f4c4dcf4SKowalski, Kamil  *
354f4c4dcf4SKowalski, Kamil  * See header file for more information
355f4c4dcf4SKowalski, Kamil  * @endinternal
356f4c4dcf4SKowalski, Kamil  */
357b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void)
3581abe55efSEd Tanous {
359fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCannotBeDeleted,
360fffb8c1fSEd Tanous                   {});
361b5c07418SJames Feist }
362b5c07418SJames Feist 
363b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res)
364b5c07418SJames Feist {
36544c70412SEd Tanous     res.result(boost::beast::http::status::method_not_allowed);
366b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
367f4c4dcf4SKowalski, Kamil }
368f4c4dcf4SKowalski, Kamil 
369f4c4dcf4SKowalski, Kamil /**
370f4c4dcf4SKowalski, Kamil  * @internal
371f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyDuplicate message into JSON
372f4c4dcf4SKowalski, Kamil  *
373f4c4dcf4SKowalski, Kamil  * See header file for more information
374f4c4dcf4SKowalski, Kamil  * @endinternal
375f4c4dcf4SKowalski, Kamil  */
3761668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1)
3771abe55efSEd Tanous {
378fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyDuplicate,
3791668ce6dSEd Tanous                   std::to_array({arg1}));
380b5c07418SJames Feist }
381b5c07418SJames Feist 
3821668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1)
383b5c07418SJames Feist {
384b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
385b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
386f4c4dcf4SKowalski, Kamil }
387f4c4dcf4SKowalski, Kamil 
388f4c4dcf4SKowalski, Kamil /**
389f4c4dcf4SKowalski, Kamil  * @internal
390f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
391f4c4dcf4SKowalski, Kamil  *
392f4c4dcf4SKowalski, Kamil  * See header file for more information
393f4c4dcf4SKowalski, Kamil  * @endinternal
394f4c4dcf4SKowalski, Kamil  */
3951668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
3961abe55efSEd Tanous {
397b6cd31e1SEd Tanous     return getLog(
398fffb8c1fSEd Tanous         redfish::registries::base::Index::serviceTemporarilyUnavailable,
3991668ce6dSEd Tanous         std::to_array({arg1}));
400b5c07418SJames Feist }
401b5c07418SJames Feist 
4021668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
403b5c07418SJames Feist {
404d9f6c621SEd Tanous     res.addHeader(boost::beast::http::field::retry_after, arg1);
405b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
406b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
407f4c4dcf4SKowalski, Kamil }
408f4c4dcf4SKowalski, Kamil 
409f4c4dcf4SKowalski, Kamil /**
410f4c4dcf4SKowalski, Kamil  * @internal
411f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
412f4c4dcf4SKowalski, Kamil  *
413f4c4dcf4SKowalski, Kamil  * See header file for more information
414f4c4dcf4SKowalski, Kamil  * @endinternal
415f4c4dcf4SKowalski, Kamil  */
4161668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1,
4171668ce6dSEd Tanous                                      std::string_view arg2,
4181668ce6dSEd Tanous                                      std::string_view arg3)
4191abe55efSEd Tanous {
420fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceAlreadyExists,
4211668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
422b5c07418SJames Feist }
423b5c07418SJames Feist 
4241668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
4251668ce6dSEd Tanous                            std::string_view arg2, std::string_view arg3)
426b5c07418SJames Feist {
427b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
428b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
429a08b46ccSJason M. Bills                      arg2);
430f4c4dcf4SKowalski, Kamil }
431f4c4dcf4SKowalski, Kamil 
432f4c4dcf4SKowalski, Kamil /**
433f4c4dcf4SKowalski, Kamil  * @internal
434f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
435f4c4dcf4SKowalski, Kamil  *
436f4c4dcf4SKowalski, Kamil  * See header file for more information
437f4c4dcf4SKowalski, Kamil  * @endinternal
438f4c4dcf4SKowalski, Kamil  */
439b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void)
4401abe55efSEd Tanous {
441fffb8c1fSEd Tanous     return getLog(
442fffb8c1fSEd Tanous         redfish::registries::base::Index::accountForSessionNoLongerExists, {});
443b5c07418SJames Feist }
444b5c07418SJames Feist 
445b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
446b5c07418SJames Feist {
447b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
448b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
449f4c4dcf4SKowalski, Kamil }
450f4c4dcf4SKowalski, Kamil 
451f4c4dcf4SKowalski, Kamil /**
452f4c4dcf4SKowalski, Kamil  * @internal
453f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
454f4c4dcf4SKowalski, Kamil  *
455f4c4dcf4SKowalski, Kamil  * See header file for more information
456f4c4dcf4SKowalski, Kamil  * @endinternal
457f4c4dcf4SKowalski, Kamil  */
4581668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
4591abe55efSEd Tanous {
460fffb8c1fSEd Tanous     return getLog(
461fffb8c1fSEd Tanous         redfish::registries::base::Index::createFailedMissingReqProperties,
4621668ce6dSEd Tanous         std::to_array({arg1}));
463b5c07418SJames Feist }
464b5c07418SJames Feist 
465b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
4661668ce6dSEd Tanous                                       std::string_view arg1)
467b5c07418SJames Feist {
468b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
469b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
470a08b46ccSJason M. Bills                      arg1);
471f12894f8SJason M. Bills }
472f12894f8SJason M. Bills 
473f12894f8SJason M. Bills /**
474f12894f8SJason M. Bills  * @internal
475f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
476f12894f8SJason M. Bills  * property
477f12894f8SJason M. Bills  *
478f12894f8SJason M. Bills  * See header file for more information
479f12894f8SJason M. Bills  * @endinternal
480f12894f8SJason M. Bills  */
4811668ce6dSEd Tanous nlohmann::json propertyValueFormatError(std::string_view arg1,
4821668ce6dSEd Tanous                                         std::string_view arg2)
483f12894f8SJason M. Bills {
484fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueFormatError,
4851668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
486b5c07418SJames Feist }
487b5c07418SJames Feist 
4881668ce6dSEd Tanous void propertyValueFormatError(crow::Response& res, std::string_view arg1,
4891668ce6dSEd Tanous                               std::string_view arg2)
490b5c07418SJames Feist {
491b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
492b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
493f12894f8SJason M. Bills }
494f12894f8SJason M. Bills 
495f12894f8SJason M. Bills /**
496f12894f8SJason M. Bills  * @internal
497f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
498f12894f8SJason M. Bills  * property
499f12894f8SJason M. Bills  *
500f12894f8SJason M. Bills  * See header file for more information
501f12894f8SJason M. Bills  * @endinternal
502f12894f8SJason M. Bills  */
5031668ce6dSEd Tanous nlohmann::json propertyValueNotInList(std::string_view arg1,
5041668ce6dSEd Tanous                                       std::string_view arg2)
505f12894f8SJason M. Bills {
506fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueNotInList,
5071668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
508b5c07418SJames Feist }
509b5c07418SJames Feist 
5101668ce6dSEd Tanous void propertyValueNotInList(crow::Response& res, std::string_view arg1,
5111668ce6dSEd Tanous                             std::string_view arg2)
512b5c07418SJames Feist {
513b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
514b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
515f4c4dcf4SKowalski, Kamil }
516f4c4dcf4SKowalski, Kamil 
517f4c4dcf4SKowalski, Kamil /**
518f4c4dcf4SKowalski, Kamil  * @internal
519227a2b0aSJiaqing Zhao  * @brief Formats PropertyValueOutOfRange message into JSON
520227a2b0aSJiaqing Zhao  *
521227a2b0aSJiaqing Zhao  * See header file for more information
522227a2b0aSJiaqing Zhao  * @endinternal
523227a2b0aSJiaqing Zhao  */
524227a2b0aSJiaqing Zhao nlohmann::json propertyValueOutOfRange(std::string_view arg1,
525227a2b0aSJiaqing Zhao                                        std::string_view arg2)
526227a2b0aSJiaqing Zhao {
527227a2b0aSJiaqing Zhao     return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
528227a2b0aSJiaqing Zhao                   std::to_array({arg1, arg2}));
529227a2b0aSJiaqing Zhao }
530227a2b0aSJiaqing Zhao 
531227a2b0aSJiaqing Zhao void propertyValueOutOfRange(crow::Response& res, std::string_view arg1,
532227a2b0aSJiaqing Zhao                              std::string_view arg2)
533227a2b0aSJiaqing Zhao {
534227a2b0aSJiaqing Zhao     res.result(boost::beast::http::status::bad_request);
535227a2b0aSJiaqing Zhao     addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2));
536227a2b0aSJiaqing Zhao }
537227a2b0aSJiaqing Zhao 
538227a2b0aSJiaqing Zhao /**
539227a2b0aSJiaqing Zhao  * @internal
540f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
541f4c4dcf4SKowalski, Kamil  *
542f4c4dcf4SKowalski, Kamil  * See header file for more information
543f4c4dcf4SKowalski, Kamil  * @endinternal
544f4c4dcf4SKowalski, Kamil  */
545*d9f466b3SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(boost::urls::url_view arg1)
5461abe55efSEd Tanous {
547b6cd31e1SEd Tanous     return getLog(
548fffb8c1fSEd Tanous         redfish::registries::base::Index::resourceAtUriInUnknownFormat,
549079360aeSEd Tanous         std::to_array<std::string_view>({arg1.buffer()}));
550b5c07418SJames Feist }
551b5c07418SJames Feist 
552ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res,
553*d9f466b3SEd Tanous                                   boost::urls::url_view arg1)
554b5c07418SJames Feist {
555b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
556b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
557f4c4dcf4SKowalski, Kamil }
558f4c4dcf4SKowalski, Kamil 
559f4c4dcf4SKowalski, Kamil /**
560f4c4dcf4SKowalski, Kamil  * @internal
56181856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
56281856681SAsmitha Karunanithi  *
56381856681SAsmitha Karunanithi  * See header file for more information
56481856681SAsmitha Karunanithi  * @endinternal
56581856681SAsmitha Karunanithi  */
5661668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1)
56781856681SAsmitha Karunanithi {
568fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceDisabled,
5691668ce6dSEd Tanous                   std::to_array({arg1}));
57081856681SAsmitha Karunanithi }
57181856681SAsmitha Karunanithi 
5721668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1)
57381856681SAsmitha Karunanithi {
57481856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
57581856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
57681856681SAsmitha Karunanithi }
57781856681SAsmitha Karunanithi 
57881856681SAsmitha Karunanithi /**
57981856681SAsmitha Karunanithi  * @internal
580f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
581f4c4dcf4SKowalski, Kamil  *
582f4c4dcf4SKowalski, Kamil  * See header file for more information
583f4c4dcf4SKowalski, Kamil  * @endinternal
584f4c4dcf4SKowalski, Kamil  */
585b5c07418SJames Feist nlohmann::json serviceInUnknownState(void)
5861abe55efSEd Tanous {
587fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
588b5c07418SJames Feist }
589b5c07418SJames Feist 
590b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
591b5c07418SJames Feist {
592b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
593b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
594f4c4dcf4SKowalski, Kamil }
595f4c4dcf4SKowalski, Kamil 
596f4c4dcf4SKowalski, Kamil /**
597f4c4dcf4SKowalski, Kamil  * @internal
598f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
599f4c4dcf4SKowalski, Kamil  *
600f4c4dcf4SKowalski, Kamil  * See header file for more information
601f4c4dcf4SKowalski, Kamil  * @endinternal
602f4c4dcf4SKowalski, Kamil  */
603b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void)
6041abe55efSEd Tanous {
605fffb8c1fSEd Tanous     return getLog(
606fffb8c1fSEd Tanous         redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
607b5c07418SJames Feist }
608b5c07418SJames Feist 
609b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
610b5c07418SJames Feist {
611789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
612b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
613f4c4dcf4SKowalski, Kamil }
614f4c4dcf4SKowalski, Kamil 
615f4c4dcf4SKowalski, Kamil /**
616f4c4dcf4SKowalski, Kamil  * @internal
617f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
618f4c4dcf4SKowalski, Kamil  *
619f4c4dcf4SKowalski, Kamil  * See header file for more information
620f4c4dcf4SKowalski, Kamil  * @endinternal
621f4c4dcf4SKowalski, Kamil  */
6221668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1,
6231668ce6dSEd Tanous                                       std::string_view arg2)
6241abe55efSEd Tanous {
625fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterMissing,
6261668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
627b5c07418SJames Feist }
628b5c07418SJames Feist 
6291668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1,
6301668ce6dSEd Tanous                             std::string_view arg2)
631b5c07418SJames Feist {
632b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
633b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
634f4c4dcf4SKowalski, Kamil }
635f4c4dcf4SKowalski, Kamil 
636f4c4dcf4SKowalski, Kamil /**
637f4c4dcf4SKowalski, Kamil  * @internal
638f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
639f4c4dcf4SKowalski, Kamil  *
640f4c4dcf4SKowalski, Kamil  * See header file for more information
641f4c4dcf4SKowalski, Kamil  * @endinternal
642f4c4dcf4SKowalski, Kamil  */
6431668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
6441abe55efSEd Tanous {
645b6cd31e1SEd Tanous     std::string arg2String = std::to_string(arg2);
646fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::stringValueTooLong,
6471668ce6dSEd Tanous                   std::to_array({arg1, std::string_view(arg2String)}));
648b5c07418SJames Feist }
649b5c07418SJames Feist 
6501668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
651b5c07418SJames Feist {
652b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
653b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
654f4c4dcf4SKowalski, Kamil }
655f4c4dcf4SKowalski, Kamil 
656f4c4dcf4SKowalski, Kamil /**
657f4c4dcf4SKowalski, Kamil  * @internal
658cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
659cc9139ecSJason M. Bills  *
660cc9139ecSJason M. Bills  * See header file for more information
661cc9139ecSJason M. Bills  * @endinternal
662cc9139ecSJason M. Bills  */
663b5c07418SJames Feist nlohmann::json sessionTerminated(void)
664cc9139ecSJason M. Bills {
665fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionTerminated, {});
666b5c07418SJames Feist }
667b5c07418SJames Feist 
668b5c07418SJames Feist void sessionTerminated(crow::Response& res)
669b5c07418SJames Feist {
670b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
671b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
672cc9139ecSJason M. Bills }
673cc9139ecSJason M. Bills 
674cc9139ecSJason M. Bills /**
675cc9139ecSJason M. Bills  * @internal
676684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
677684bb4b8SJason M. Bills  *
678684bb4b8SJason M. Bills  * See header file for more information
679684bb4b8SJason M. Bills  * @endinternal
680684bb4b8SJason M. Bills  */
681684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void)
682684bb4b8SJason M. Bills {
683fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
684684bb4b8SJason M. Bills }
685684bb4b8SJason M. Bills 
686684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
687684bb4b8SJason M. Bills {
688684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
689684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
690684bb4b8SJason M. Bills }
691684bb4b8SJason M. Bills 
692684bb4b8SJason M. Bills /**
693684bb4b8SJason M. Bills  * @internal
694cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
695cc9139ecSJason M. Bills  *
696cc9139ecSJason M. Bills  * See header file for more information
697cc9139ecSJason M. Bills  * @endinternal
698cc9139ecSJason M. Bills  */
6991668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1,
7001668ce6dSEd Tanous                                         std::string_view arg2)
701cc9139ecSJason M. Bills {
702fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
7031668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
704b5c07418SJames Feist }
705b5c07418SJames Feist 
7061668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
7071668ce6dSEd Tanous                               std::string_view arg2)
708b5c07418SJames Feist {
709b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
710b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
711cc9139ecSJason M. Bills }
712cc9139ecSJason M. Bills 
713cc9139ecSJason M. Bills /**
714cc9139ecSJason M. Bills  * @internal
715684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
716684bb4b8SJason M. Bills  *
717684bb4b8SJason M. Bills  * See header file for more information
718684bb4b8SJason M. Bills  * @endinternal
719684bb4b8SJason M. Bills  */
720*d9f466b3SEd Tanous nlohmann::json resetRequired(boost::urls::url_view arg1, std::string_view arg2)
721684bb4b8SJason M. Bills {
722fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
723079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer(), arg2}));
724684bb4b8SJason M. Bills }
725684bb4b8SJason M. Bills 
726*d9f466b3SEd Tanous void resetRequired(crow::Response& res, boost::urls::url_view arg1,
7271668ce6dSEd Tanous                    std::string_view arg2)
728684bb4b8SJason M. Bills {
729684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
730684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
731684bb4b8SJason M. Bills }
732684bb4b8SJason M. Bills 
733684bb4b8SJason M. Bills /**
734684bb4b8SJason M. Bills  * @internal
735684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
736684bb4b8SJason M. Bills  *
737684bb4b8SJason M. Bills  * See header file for more information
738684bb4b8SJason M. Bills  * @endinternal
739684bb4b8SJason M. Bills  */
7401668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
741684bb4b8SJason M. Bills {
742fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
7431668ce6dSEd Tanous                   std::to_array({arg1}));
744684bb4b8SJason M. Bills }
745684bb4b8SJason M. Bills 
7461668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
747684bb4b8SJason M. Bills {
748684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
749684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
750684bb4b8SJason M. Bills }
751684bb4b8SJason M. Bills 
752684bb4b8SJason M. Bills /**
753684bb4b8SJason M. Bills  * @internal
754684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
755684bb4b8SJason M. Bills  *
756684bb4b8SJason M. Bills  * See header file for more information
757684bb4b8SJason M. Bills  * @endinternal
758684bb4b8SJason M. Bills  */
7591668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
760684bb4b8SJason M. Bills {
761b6cd31e1SEd Tanous     return getLog(
762fffb8c1fSEd Tanous         redfish::registries::base::Index::chassisPowerStateOffRequired,
7631668ce6dSEd Tanous         std::to_array({arg1}));
764684bb4b8SJason M. Bills }
765684bb4b8SJason M. Bills 
7661668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1)
767684bb4b8SJason M. Bills {
768684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
769684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
770684bb4b8SJason M. Bills }
771684bb4b8SJason M. Bills 
772684bb4b8SJason M. Bills /**
773684bb4b8SJason M. Bills  * @internal
774684bb4b8SJason M. Bills  * @brief Formats PropertyValueConflict message into JSON
775684bb4b8SJason M. Bills  *
776684bb4b8SJason M. Bills  * See header file for more information
777684bb4b8SJason M. Bills  * @endinternal
778684bb4b8SJason M. Bills  */
7791668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1,
7801668ce6dSEd Tanous                                      std::string_view arg2)
781684bb4b8SJason M. Bills {
782fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueConflict,
7831668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
784684bb4b8SJason M. Bills }
785684bb4b8SJason M. Bills 
7861668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1,
7871668ce6dSEd Tanous                            std::string_view arg2)
788684bb4b8SJason M. Bills {
789684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
790684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
791684bb4b8SJason M. Bills }
792684bb4b8SJason M. Bills 
793684bb4b8SJason M. Bills /**
794684bb4b8SJason M. Bills  * @internal
7952a6af81cSRamesh Iyyar  * @brief Formats PropertyValueResourceConflict message into JSON
7962a6af81cSRamesh Iyyar  *
7972a6af81cSRamesh Iyyar  * See header file for more information
7982a6af81cSRamesh Iyyar  * @endinternal
7992a6af81cSRamesh Iyyar  */
8002a6af81cSRamesh Iyyar nlohmann::json propertyValueResourceConflict(std::string_view arg1,
8012a6af81cSRamesh Iyyar                                              std::string_view arg2,
802*d9f466b3SEd Tanous                                              boost::urls::url_view arg3)
8032a6af81cSRamesh Iyyar {
8042a6af81cSRamesh Iyyar     return getLog(
8052a6af81cSRamesh Iyyar         redfish::registries::base::Index::propertyValueResourceConflict,
806079360aeSEd Tanous         std::to_array<std::string_view>({arg1, arg2, arg3.buffer()}));
8072a6af81cSRamesh Iyyar }
8082a6af81cSRamesh Iyyar 
8092a6af81cSRamesh Iyyar void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
8102a6af81cSRamesh Iyyar                                    std::string_view arg2,
811*d9f466b3SEd Tanous                                    boost::urls::url_view arg3)
8122a6af81cSRamesh Iyyar {
8132a6af81cSRamesh Iyyar     res.result(boost::beast::http::status::conflict);
8142a6af81cSRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
8152a6af81cSRamesh Iyyar                           propertyValueResourceConflict(arg1, arg2, arg3));
8162a6af81cSRamesh Iyyar }
8172a6af81cSRamesh Iyyar 
8182a6af81cSRamesh Iyyar /**
8192a6af81cSRamesh Iyyar  * @internal
82024861a28SRamesh Iyyar  * @brief Formats PropertyValueExternalConflict message into JSON
82124861a28SRamesh Iyyar  *
82224861a28SRamesh Iyyar  * See header file for more information
82324861a28SRamesh Iyyar  * @endinternal
82424861a28SRamesh Iyyar  */
82524861a28SRamesh Iyyar nlohmann::json propertyValueExternalConflict(std::string_view arg1,
82624861a28SRamesh Iyyar                                              std::string_view arg2)
82724861a28SRamesh Iyyar {
82824861a28SRamesh Iyyar     return getLog(
82924861a28SRamesh Iyyar         redfish::registries::base::Index::propertyValueExternalConflict,
83024861a28SRamesh Iyyar         std::to_array({arg1, arg2}));
83124861a28SRamesh Iyyar }
83224861a28SRamesh Iyyar 
83324861a28SRamesh Iyyar void propertyValueExternalConflict(crow::Response& res, std::string_view arg1,
83424861a28SRamesh Iyyar                                    std::string_view arg2)
83524861a28SRamesh Iyyar {
83624861a28SRamesh Iyyar     res.result(boost::beast::http::status::conflict);
83724861a28SRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
83824861a28SRamesh Iyyar                           propertyValueExternalConflict(arg1, arg2));
83924861a28SRamesh Iyyar }
84024861a28SRamesh Iyyar 
84124861a28SRamesh Iyyar /**
84224861a28SRamesh Iyyar  * @internal
843684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
844684bb4b8SJason M. Bills  *
845684bb4b8SJason M. Bills  * See header file for more information
846684bb4b8SJason M. Bills  * @endinternal
847684bb4b8SJason M. Bills  */
8481668ce6dSEd Tanous nlohmann::json propertyValueIncorrect(std::string_view arg1,
8491668ce6dSEd Tanous                                       std::string_view arg2)
850684bb4b8SJason M. Bills {
851fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueIncorrect,
8521668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
853684bb4b8SJason M. Bills }
854684bb4b8SJason M. Bills 
8551668ce6dSEd Tanous void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
8561668ce6dSEd Tanous                             std::string_view arg2)
857684bb4b8SJason M. Bills {
858684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
859684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
860684bb4b8SJason M. Bills }
861684bb4b8SJason M. Bills 
862684bb4b8SJason M. Bills /**
863684bb4b8SJason M. Bills  * @internal
864684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
865684bb4b8SJason M. Bills  *
866684bb4b8SJason M. Bills  * See header file for more information
867684bb4b8SJason M. Bills  * @endinternal
868684bb4b8SJason M. Bills  */
869*d9f466b3SEd Tanous nlohmann::json resourceCreationConflict(boost::urls::url_view arg1)
870684bb4b8SJason M. Bills {
871fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCreationConflict,
872079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
873684bb4b8SJason M. Bills }
874684bb4b8SJason M. Bills 
875*d9f466b3SEd Tanous void resourceCreationConflict(crow::Response& res, boost::urls::url_view arg1)
876684bb4b8SJason M. Bills {
877684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
878684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
879684bb4b8SJason M. Bills }
880684bb4b8SJason M. Bills 
881684bb4b8SJason M. Bills /**
882684bb4b8SJason M. Bills  * @internal
883684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded message into JSON
884684bb4b8SJason M. Bills  *
885684bb4b8SJason M. Bills  * See header file for more information
886684bb4b8SJason M. Bills  * @endinternal
887684bb4b8SJason M. Bills  */
888684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void)
889684bb4b8SJason M. Bills {
890fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
891684bb4b8SJason M. Bills }
892684bb4b8SJason M. Bills 
893684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
894684bb4b8SJason M. Bills {
895684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
896684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
897684bb4b8SJason M. Bills }
898684bb4b8SJason M. Bills 
899684bb4b8SJason M. Bills /**
900684bb4b8SJason M. Bills  * @internal
901684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
902684bb4b8SJason M. Bills  *
903684bb4b8SJason M. Bills  * See header file for more information
904684bb4b8SJason M. Bills  * @endinternal
905684bb4b8SJason M. Bills  */
906684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void)
907684bb4b8SJason M. Bills {
908fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionFailed, {});
909684bb4b8SJason M. Bills }
910684bb4b8SJason M. Bills 
911684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
912684bb4b8SJason M. Bills {
9134df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
914684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
915684bb4b8SJason M. Bills }
916684bb4b8SJason M. Bills 
917684bb4b8SJason M. Bills /**
918684bb4b8SJason M. Bills  * @internal
919684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
920684bb4b8SJason M. Bills  *
921684bb4b8SJason M. Bills  * See header file for more information
922684bb4b8SJason M. Bills  * @endinternal
923684bb4b8SJason M. Bills  */
924684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void)
925684bb4b8SJason M. Bills {
926fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionRequired, {});
927684bb4b8SJason M. Bills }
928684bb4b8SJason M. Bills 
929684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
930684bb4b8SJason M. Bills {
931684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
932684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
933684bb4b8SJason M. Bills }
934684bb4b8SJason M. Bills 
935684bb4b8SJason M. Bills /**
936684bb4b8SJason M. Bills  * @internal
937684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
938684bb4b8SJason M. Bills  *
939684bb4b8SJason M. Bills  * See header file for more information
940684bb4b8SJason M. Bills  * @endinternal
941684bb4b8SJason M. Bills  */
942684bb4b8SJason M. Bills nlohmann::json operationFailed(void)
943684bb4b8SJason M. Bills {
944fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationFailed, {});
945684bb4b8SJason M. Bills }
946684bb4b8SJason M. Bills 
947684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
948684bb4b8SJason M. Bills {
9498868776eSEd Tanous     res.result(boost::beast::http::status::bad_gateway);
950684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
951684bb4b8SJason M. Bills }
952684bb4b8SJason M. Bills 
953684bb4b8SJason M. Bills /**
954684bb4b8SJason M. Bills  * @internal
955684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
956684bb4b8SJason M. Bills  *
957684bb4b8SJason M. Bills  * See header file for more information
958684bb4b8SJason M. Bills  * @endinternal
959684bb4b8SJason M. Bills  */
960684bb4b8SJason M. Bills nlohmann::json operationTimeout(void)
961684bb4b8SJason M. Bills {
962fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationTimeout, {});
963684bb4b8SJason M. Bills }
964684bb4b8SJason M. Bills 
965684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
966684bb4b8SJason M. Bills {
967684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
968684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
969684bb4b8SJason M. Bills }
970684bb4b8SJason M. Bills 
971684bb4b8SJason M. Bills /**
972684bb4b8SJason M. Bills  * @internal
973f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
974f12894f8SJason M. Bills  * property
975f12894f8SJason M. Bills  *
976f12894f8SJason M. Bills  * See header file for more information
977f12894f8SJason M. Bills  * @endinternal
978f12894f8SJason M. Bills  */
9791668ce6dSEd Tanous nlohmann::json propertyValueTypeError(std::string_view arg1,
9801668ce6dSEd Tanous                                       std::string_view arg2)
981f12894f8SJason M. Bills {
982fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueTypeError,
9831668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
984b5c07418SJames Feist }
985b5c07418SJames Feist 
9861668ce6dSEd Tanous void propertyValueTypeError(crow::Response& res, std::string_view arg1,
9871668ce6dSEd Tanous                             std::string_view arg2)
988b5c07418SJames Feist {
989b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
990b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
991f4c4dcf4SKowalski, Kamil }
992f4c4dcf4SKowalski, Kamil 
993f4c4dcf4SKowalski, Kamil /**
994f4c4dcf4SKowalski, Kamil  * @internal
995b6cd31e1SEd Tanous  * @brief Formats ResourceNotFound message into JSONd
996f4c4dcf4SKowalski, Kamil  *
997f4c4dcf4SKowalski, Kamil  * See header file for more information
998f4c4dcf4SKowalski, Kamil  * @endinternal
999f4c4dcf4SKowalski, Kamil  */
10001668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
10011abe55efSEd Tanous {
1002fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceNotFound,
10031668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1004b5c07418SJames Feist }
1005b5c07418SJames Feist 
10061668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1,
10071668ce6dSEd Tanous                       std::string_view arg2)
1008b5c07418SJames Feist {
1009b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1010b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
1011f4c4dcf4SKowalski, Kamil }
1012f4c4dcf4SKowalski, Kamil 
1013f4c4dcf4SKowalski, Kamil /**
1014f4c4dcf4SKowalski, Kamil  * @internal
1015f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
1016f4c4dcf4SKowalski, Kamil  *
1017f4c4dcf4SKowalski, Kamil  * See header file for more information
1018f4c4dcf4SKowalski, Kamil  * @endinternal
1019f4c4dcf4SKowalski, Kamil  */
1020*d9f466b3SEd Tanous nlohmann::json couldNotEstablishConnection(boost::urls::url_view arg1)
10211abe55efSEd Tanous {
1022fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
1023079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1024b5c07418SJames Feist }
1025b5c07418SJames Feist 
1026ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res,
1027*d9f466b3SEd Tanous                                  boost::urls::url_view arg1)
1028b5c07418SJames Feist {
1029b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1030b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
1031f4c4dcf4SKowalski, Kamil }
1032f4c4dcf4SKowalski, Kamil 
1033f4c4dcf4SKowalski, Kamil /**
1034f4c4dcf4SKowalski, Kamil  * @internal
1035f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
1036f12894f8SJason M. Bills  * property
1037f12894f8SJason M. Bills  *
1038f12894f8SJason M. Bills  * See header file for more information
1039f12894f8SJason M. Bills  * @endinternal
1040f12894f8SJason M. Bills  */
10411668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1)
1042f12894f8SJason M. Bills {
1043fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyNotWritable,
10441668ce6dSEd Tanous                   std::to_array({arg1}));
1045b5c07418SJames Feist }
1046b5c07418SJames Feist 
10471668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1)
1048b5c07418SJames Feist {
1049b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1050b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1051f4c4dcf4SKowalski, Kamil }
1052f4c4dcf4SKowalski, Kamil 
1053f4c4dcf4SKowalski, Kamil /**
1054f4c4dcf4SKowalski, Kamil  * @internal
1055f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
1056f4c4dcf4SKowalski, Kamil  *
1057f4c4dcf4SKowalski, Kamil  * See header file for more information
1058f4c4dcf4SKowalski, Kamil  * @endinternal
1059f4c4dcf4SKowalski, Kamil  */
10601668ce6dSEd Tanous nlohmann::json queryParameterValueTypeError(std::string_view arg1,
10611668ce6dSEd Tanous                                             std::string_view arg2)
10621abe55efSEd Tanous {
1063b6cd31e1SEd Tanous     return getLog(
1064fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueTypeError,
10651668ce6dSEd Tanous         std::to_array({arg1, arg2}));
1066b5c07418SJames Feist }
1067b5c07418SJames Feist 
10681668ce6dSEd Tanous void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
10691668ce6dSEd Tanous                                   std::string_view arg2)
1070b5c07418SJames Feist {
1071b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1072b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1073b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
1074f4c4dcf4SKowalski, Kamil }
1075f4c4dcf4SKowalski, Kamil 
1076f4c4dcf4SKowalski, Kamil /**
1077f4c4dcf4SKowalski, Kamil  * @internal
1078f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
1079f4c4dcf4SKowalski, Kamil  *
1080f4c4dcf4SKowalski, Kamil  * See header file for more information
1081f4c4dcf4SKowalski, Kamil  * @endinternal
1082f4c4dcf4SKowalski, Kamil  */
1083b5c07418SJames Feist nlohmann::json serviceShuttingDown(void)
10841abe55efSEd Tanous {
1085fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
1086b5c07418SJames Feist }
1087b5c07418SJames Feist 
1088b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
1089b5c07418SJames Feist {
1090b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1091b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1092f4c4dcf4SKowalski, Kamil }
1093f4c4dcf4SKowalski, Kamil 
1094f4c4dcf4SKowalski, Kamil /**
1095f4c4dcf4SKowalski, Kamil  * @internal
1096f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
1097f4c4dcf4SKowalski, Kamil  *
1098f4c4dcf4SKowalski, Kamil  * See header file for more information
1099f4c4dcf4SKowalski, Kamil  * @endinternal
1100f4c4dcf4SKowalski, Kamil  */
11011668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1,
11021668ce6dSEd Tanous                                         std::string_view arg2)
11031abe55efSEd Tanous {
1104fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
11051668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1106b5c07418SJames Feist }
1107b5c07418SJames Feist 
11081668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
11091668ce6dSEd Tanous                               std::string_view arg2)
1110b5c07418SJames Feist {
1111b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1112b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1113f4c4dcf4SKowalski, Kamil }
1114f4c4dcf4SKowalski, Kamil 
1115f4c4dcf4SKowalski, Kamil /**
1116f4c4dcf4SKowalski, Kamil  * @internal
1117f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1118f4c4dcf4SKowalski, Kamil  *
1119f4c4dcf4SKowalski, Kamil  * See header file for more information
1120f4c4dcf4SKowalski, Kamil  * @endinternal
1121f4c4dcf4SKowalski, Kamil  */
11221668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1,
11231668ce6dSEd Tanous                                            std::string_view arg2)
11241abe55efSEd Tanous {
1125fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
11261668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1127b5c07418SJames Feist }
1128b5c07418SJames Feist 
11291668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
11301668ce6dSEd Tanous                                  std::string_view arg2)
1131b5c07418SJames Feist {
1132b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1133b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1134b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1135f4c4dcf4SKowalski, Kamil }
1136f4c4dcf4SKowalski, Kamil 
1137f4c4dcf4SKowalski, Kamil /**
1138f4c4dcf4SKowalski, Kamil  * @internal
1139f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1140f4c4dcf4SKowalski, Kamil  *
1141f4c4dcf4SKowalski, Kamil  * See header file for more information
1142f4c4dcf4SKowalski, Kamil  * @endinternal
1143f4c4dcf4SKowalski, Kamil  */
1144*d9f466b3SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1,
11451668ce6dSEd Tanous                                             std::string_view arg2)
11461abe55efSEd Tanous {
1147b6cd31e1SEd Tanous     return getLog(
1148fffb8c1fSEd Tanous         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
1149079360aeSEd Tanous         std::to_array<std::string_view>({arg1.buffer(), arg2}));
1150b5c07418SJames Feist }
1151b5c07418SJames Feist 
1152ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res,
1153*d9f466b3SEd Tanous                                   boost::urls::url_view arg1,
11541668ce6dSEd Tanous                                   std::string_view arg2)
1155b5c07418SJames Feist {
1156b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1157b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1158b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1159f4c4dcf4SKowalski, Kamil }
1160f4c4dcf4SKowalski, Kamil 
1161f4c4dcf4SKowalski, Kamil /**
1162f4c4dcf4SKowalski, Kamil  * @internal
1163b4ad4c05SShantappa Teekappanavar  * @brief Formats StrictAccountTypes message into JSON
1164b4ad4c05SShantappa Teekappanavar  *
1165b4ad4c05SShantappa Teekappanavar  * See header file for more information
1166b4ad4c05SShantappa Teekappanavar  * @endinternal
1167b4ad4c05SShantappa Teekappanavar  */
1168b4ad4c05SShantappa Teekappanavar nlohmann::json strictAccountTypes(std::string_view arg1)
1169b4ad4c05SShantappa Teekappanavar {
1170b4ad4c05SShantappa Teekappanavar     return getLog(redfish::registries::base::Index::strictAccountTypes,
1171b4ad4c05SShantappa Teekappanavar                   std::to_array({arg1}));
1172b4ad4c05SShantappa Teekappanavar }
1173b4ad4c05SShantappa Teekappanavar 
1174b4ad4c05SShantappa Teekappanavar void strictAccountTypes(crow::Response& res, std::string_view arg1)
1175b4ad4c05SShantappa Teekappanavar {
1176b4ad4c05SShantappa Teekappanavar     res.result(boost::beast::http::status::bad_request);
1177b4ad4c05SShantappa Teekappanavar     addMessageToErrorJson(res.jsonValue, strictAccountTypes(arg1));
1178b4ad4c05SShantappa Teekappanavar }
1179b4ad4c05SShantappa Teekappanavar 
1180b4ad4c05SShantappa Teekappanavar /**
1181b4ad4c05SShantappa Teekappanavar  * @internal
1182f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1183f4c4dcf4SKowalski, Kamil  *
1184f4c4dcf4SKowalski, Kamil  * See header file for more information
1185f4c4dcf4SKowalski, Kamil  * @endinternal
1186f4c4dcf4SKowalski, Kamil  */
1187b5c07418SJames Feist nlohmann::json accountRemoved(void)
11881abe55efSEd Tanous {
1189fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountRemoved, {});
1190b5c07418SJames Feist }
1191b5c07418SJames Feist 
1192b5c07418SJames Feist void accountRemoved(crow::Response& res)
1193b5c07418SJames Feist {
1194b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1195b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1196f4c4dcf4SKowalski, Kamil }
1197f4c4dcf4SKowalski, Kamil 
1198f4c4dcf4SKowalski, Kamil /**
1199f4c4dcf4SKowalski, Kamil  * @internal
1200f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1201f4c4dcf4SKowalski, Kamil  *
1202f4c4dcf4SKowalski, Kamil  * See header file for more information
1203f4c4dcf4SKowalski, Kamil  * @endinternal
1204f4c4dcf4SKowalski, Kamil  */
1205*d9f466b3SEd Tanous nlohmann::json accessDenied(boost::urls::url_view arg1)
12061abe55efSEd Tanous {
1207fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accessDenied,
1208079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1209b5c07418SJames Feist }
1210b5c07418SJames Feist 
1211*d9f466b3SEd Tanous void accessDenied(crow::Response& res, boost::urls::url_view arg1)
1212b5c07418SJames Feist {
1213b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1214b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1215f4c4dcf4SKowalski, Kamil }
1216f4c4dcf4SKowalski, Kamil 
1217f4c4dcf4SKowalski, Kamil /**
1218f4c4dcf4SKowalski, Kamil  * @internal
1219f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1220f4c4dcf4SKowalski, Kamil  *
1221f4c4dcf4SKowalski, Kamil  * See header file for more information
1222f4c4dcf4SKowalski, Kamil  * @endinternal
1223f4c4dcf4SKowalski, Kamil  */
1224b5c07418SJames Feist nlohmann::json queryNotSupported(void)
12251abe55efSEd Tanous {
1226fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1227b5c07418SJames Feist }
1228b5c07418SJames Feist 
1229b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1230b5c07418SJames Feist {
1231b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1232b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1233f4c4dcf4SKowalski, Kamil }
1234f4c4dcf4SKowalski, Kamil 
1235f4c4dcf4SKowalski, Kamil /**
1236f4c4dcf4SKowalski, Kamil  * @internal
1237f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1238f4c4dcf4SKowalski, Kamil  *
1239f4c4dcf4SKowalski, Kamil  * See header file for more information
1240f4c4dcf4SKowalski, Kamil  * @endinternal
1241f4c4dcf4SKowalski, Kamil  */
1242b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void)
12431abe55efSEd Tanous {
1244b6cd31e1SEd Tanous     return getLog(
1245fffb8c1fSEd Tanous         redfish::registries::base::Index::createLimitReachedForResource, {});
1246b5c07418SJames Feist }
1247b5c07418SJames Feist 
1248b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1249b5c07418SJames Feist {
1250b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1251b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1252f4c4dcf4SKowalski, Kamil }
1253f4c4dcf4SKowalski, Kamil 
1254f4c4dcf4SKowalski, Kamil /**
1255f4c4dcf4SKowalski, Kamil  * @internal
1256f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1257f4c4dcf4SKowalski, Kamil  *
1258f4c4dcf4SKowalski, Kamil  * See header file for more information
1259f4c4dcf4SKowalski, Kamil  * @endinternal
1260f4c4dcf4SKowalski, Kamil  */
1261b5c07418SJames Feist nlohmann::json generalError(void)
12621abe55efSEd Tanous {
1263fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::generalError, {});
1264b5c07418SJames Feist }
1265b5c07418SJames Feist 
1266b5c07418SJames Feist void generalError(crow::Response& res)
1267b5c07418SJames Feist {
1268b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1269b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1270f4c4dcf4SKowalski, Kamil }
1271f4c4dcf4SKowalski, Kamil 
1272f4c4dcf4SKowalski, Kamil /**
1273f4c4dcf4SKowalski, Kamil  * @internal
1274f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1275f4c4dcf4SKowalski, Kamil  *
1276f4c4dcf4SKowalski, Kamil  * See header file for more information
1277f4c4dcf4SKowalski, Kamil  * @endinternal
1278f4c4dcf4SKowalski, Kamil  */
1279b5c07418SJames Feist nlohmann::json success(void)
12801abe55efSEd Tanous {
1281fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::success, {});
1282b5c07418SJames Feist }
1283b5c07418SJames Feist 
1284b5c07418SJames Feist void success(crow::Response& res)
1285b5c07418SJames Feist {
1286b5c07418SJames Feist     // don't set res.result here because success is the default and any
1287b5c07418SJames Feist     // error should overwrite the default
1288b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1289f12894f8SJason M. Bills }
1290f12894f8SJason M. Bills 
1291f12894f8SJason M. Bills /**
1292f12894f8SJason M. Bills  * @internal
1293f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1294f4c4dcf4SKowalski, Kamil  *
1295f4c4dcf4SKowalski, Kamil  * See header file for more information
1296f4c4dcf4SKowalski, Kamil  * @endinternal
1297f4c4dcf4SKowalski, Kamil  */
1298b5c07418SJames Feist nlohmann::json created(void)
12991abe55efSEd Tanous {
1300fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::created, {});
1301b5c07418SJames Feist }
1302b5c07418SJames Feist 
1303b5c07418SJames Feist void created(crow::Response& res)
1304b5c07418SJames Feist {
1305b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1306b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1307f4c4dcf4SKowalski, Kamil }
1308f4c4dcf4SKowalski, Kamil 
1309f4c4dcf4SKowalski, Kamil /**
1310f4c4dcf4SKowalski, Kamil  * @internal
1311cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1312cc9139ecSJason M. Bills  *
1313cc9139ecSJason M. Bills  * See header file for more information
1314cc9139ecSJason M. Bills  * @endinternal
1315cc9139ecSJason M. Bills  */
1316b5c07418SJames Feist nlohmann::json noOperation(void)
1317cc9139ecSJason M. Bills {
1318fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noOperation, {});
1319b5c07418SJames Feist }
1320b5c07418SJames Feist 
1321b5c07418SJames Feist void noOperation(crow::Response& res)
1322b5c07418SJames Feist {
1323b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1324b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1325cc9139ecSJason M. Bills }
1326cc9139ecSJason M. Bills 
1327cc9139ecSJason M. Bills /**
1328cc9139ecSJason M. Bills  * @internal
1329b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1330b5c07418SJames Feist  * property
1331f12894f8SJason M. Bills  *
1332f12894f8SJason M. Bills  * See header file for more information
1333f12894f8SJason M. Bills  * @endinternal
1334f12894f8SJason M. Bills  */
13351668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1)
1336b5c07418SJames Feist {
1337fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyUnknown,
13381668ce6dSEd Tanous                   std::to_array({arg1}));
1339b5c07418SJames Feist }
1340b5c07418SJames Feist 
13411668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1)
1342f12894f8SJason M. Bills {
1343f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
13447b1dd2f9SEd Tanous     addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1));
1345f4c4dcf4SKowalski, Kamil }
1346f4c4dcf4SKowalski, Kamil 
1347f4c4dcf4SKowalski, Kamil /**
1348f4c4dcf4SKowalski, Kamil  * @internal
1349f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1350f4c4dcf4SKowalski, Kamil  *
1351f4c4dcf4SKowalski, Kamil  * See header file for more information
1352f4c4dcf4SKowalski, Kamil  * @endinternal
1353f4c4dcf4SKowalski, Kamil  */
1354b5c07418SJames Feist nlohmann::json noValidSession(void)
13551abe55efSEd Tanous {
1356fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noValidSession, {});
1357b5c07418SJames Feist }
1358b5c07418SJames Feist 
1359b5c07418SJames Feist void noValidSession(crow::Response& res)
1360b5c07418SJames Feist {
1361b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1362b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1363f4c4dcf4SKowalski, Kamil }
1364f4c4dcf4SKowalski, Kamil 
1365f4c4dcf4SKowalski, Kamil /**
1366f4c4dcf4SKowalski, Kamil  * @internal
1367f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1368f4c4dcf4SKowalski, Kamil  *
1369f4c4dcf4SKowalski, Kamil  * See header file for more information
1370f4c4dcf4SKowalski, Kamil  * @endinternal
1371f4c4dcf4SKowalski, Kamil  */
1372*d9f466b3SEd Tanous nlohmann::json invalidObject(boost::urls::url_view arg1)
13731abe55efSEd Tanous {
1374fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidObject,
1375079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1376b5c07418SJames Feist }
1377b5c07418SJames Feist 
1378*d9f466b3SEd Tanous void invalidObject(crow::Response& res, boost::urls::url_view arg1)
1379b5c07418SJames Feist {
1380b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1381b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1382f4c4dcf4SKowalski, Kamil }
1383f4c4dcf4SKowalski, Kamil 
1384f4c4dcf4SKowalski, Kamil /**
1385f4c4dcf4SKowalski, Kamil  * @internal
1386f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1387f4c4dcf4SKowalski, Kamil  *
1388f4c4dcf4SKowalski, Kamil  * See header file for more information
1389f4c4dcf4SKowalski, Kamil  * @endinternal
1390f4c4dcf4SKowalski, Kamil  */
1391b5c07418SJames Feist nlohmann::json resourceInStandby(void)
13921abe55efSEd Tanous {
1393fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1394b5c07418SJames Feist }
1395b5c07418SJames Feist 
1396b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1397b5c07418SJames Feist {
1398b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1399b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1400f4c4dcf4SKowalski, Kamil }
1401f4c4dcf4SKowalski, Kamil 
1402f4c4dcf4SKowalski, Kamil /**
1403f4c4dcf4SKowalski, Kamil  * @internal
1404f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1405f4c4dcf4SKowalski, Kamil  *
1406f4c4dcf4SKowalski, Kamil  * See header file for more information
1407f4c4dcf4SKowalski, Kamil  * @endinternal
1408f4c4dcf4SKowalski, Kamil  */
14091668ce6dSEd Tanous nlohmann::json actionParameterValueTypeError(std::string_view arg1,
14101668ce6dSEd Tanous                                              std::string_view arg2,
14111668ce6dSEd Tanous                                              std::string_view arg3)
14121abe55efSEd Tanous {
1413b6cd31e1SEd Tanous     return getLog(
1414fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueTypeError,
14151668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
1416b5c07418SJames Feist }
1417b5c07418SJames Feist 
14181668ce6dSEd Tanous void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
14191668ce6dSEd Tanous                                    std::string_view arg2, std::string_view arg3)
1420b5c07418SJames Feist {
1421b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1422b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1423b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1424f4c4dcf4SKowalski, Kamil }
1425f4c4dcf4SKowalski, Kamil 
1426f4c4dcf4SKowalski, Kamil /**
1427f4c4dcf4SKowalski, Kamil  * @internal
1428f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1429f4c4dcf4SKowalski, Kamil  *
1430f4c4dcf4SKowalski, Kamil  * See header file for more information
1431f4c4dcf4SKowalski, Kamil  * @endinternal
1432f4c4dcf4SKowalski, Kamil  */
1433b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void)
14341abe55efSEd Tanous {
1435fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1436b5c07418SJames Feist }
1437b5c07418SJames Feist 
1438b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1439b5c07418SJames Feist {
1440b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1441b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1442f4c4dcf4SKowalski, Kamil }
1443f4c4dcf4SKowalski, Kamil 
1444f4c4dcf4SKowalski, Kamil /**
1445f4c4dcf4SKowalski, Kamil  * @internal
1446f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1447f4c4dcf4SKowalski, Kamil  *
1448f4c4dcf4SKowalski, Kamil  * See header file for more information
1449f4c4dcf4SKowalski, Kamil  * @endinternal
1450f4c4dcf4SKowalski, Kamil  */
14511668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1)
14521abe55efSEd Tanous {
1453fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionNotSupported,
14541668ce6dSEd Tanous                   std::to_array({arg1}));
1455b5c07418SJames Feist }
1456b5c07418SJames Feist 
14571668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1)
1458b5c07418SJames Feist {
1459b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1460b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1461f4c4dcf4SKowalski, Kamil }
1462f4c4dcf4SKowalski, Kamil 
1463f4c4dcf4SKowalski, Kamil /**
1464f4c4dcf4SKowalski, Kamil  * @internal
1465f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1466f4c4dcf4SKowalski, Kamil  *
1467f4c4dcf4SKowalski, Kamil  * See header file for more information
1468f4c4dcf4SKowalski, Kamil  * @endinternal
1469f4c4dcf4SKowalski, Kamil  */
14705187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
14711abe55efSEd Tanous {
1472b6cd31e1SEd Tanous     std::string arg1Str = std::to_string(arg1);
1473fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidIndex,
14741668ce6dSEd Tanous                   std::to_array<std::string_view>({arg1Str}));
1475b5c07418SJames Feist }
1476b5c07418SJames Feist 
14775187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1478b5c07418SJames Feist {
1479b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1480b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1481f4c4dcf4SKowalski, Kamil }
1482f4c4dcf4SKowalski, Kamil 
1483f4c4dcf4SKowalski, Kamil /**
1484f4c4dcf4SKowalski, Kamil  * @internal
1485f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1486f4c4dcf4SKowalski, Kamil  *
1487f4c4dcf4SKowalski, Kamil  * See header file for more information
1488f4c4dcf4SKowalski, Kamil  * @endinternal
1489f4c4dcf4SKowalski, Kamil  */
1490b5c07418SJames Feist nlohmann::json emptyJSON(void)
14911abe55efSEd Tanous {
1492fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::emptyJSON, {});
1493b5c07418SJames Feist }
1494b5c07418SJames Feist 
1495b5c07418SJames Feist void emptyJSON(crow::Response& res)
1496b5c07418SJames Feist {
1497b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1498b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1499f4c4dcf4SKowalski, Kamil }
1500f4c4dcf4SKowalski, Kamil 
1501f4c4dcf4SKowalski, Kamil /**
1502f4c4dcf4SKowalski, Kamil  * @internal
1503f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1504f4c4dcf4SKowalski, Kamil  *
1505f4c4dcf4SKowalski, Kamil  * See header file for more information
1506f4c4dcf4SKowalski, Kamil  * @endinternal
1507f4c4dcf4SKowalski, Kamil  */
1508b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void)
15091abe55efSEd Tanous {
1510fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1511b6cd31e1SEd Tanous                   {});
1512b5c07418SJames Feist }
1513b5c07418SJames Feist 
1514b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1515b5c07418SJames Feist {
15166a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1517b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1518f4c4dcf4SKowalski, Kamil }
1519f4c4dcf4SKowalski, Kamil 
1520f4c4dcf4SKowalski, Kamil /**
1521f4c4dcf4SKowalski, Kamil  * @internal
1522684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1523684bb4b8SJason M. Bills  *
1524684bb4b8SJason M. Bills  * See header file for more information
1525684bb4b8SJason M. Bills  * @endinternal
1526684bb4b8SJason M. Bills  */
1527684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void)
1528684bb4b8SJason M. Bills {
1529b6cd31e1SEd Tanous     return getLog(
1530fffb8c1fSEd Tanous         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1531684bb4b8SJason M. Bills }
1532684bb4b8SJason M. Bills 
1533684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1534684bb4b8SJason M. Bills {
15356a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1536684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1537684bb4b8SJason M. Bills }
1538684bb4b8SJason M. Bills 
1539684bb4b8SJason M. Bills /**
1540684bb4b8SJason M. Bills  * @internal
1541684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1542684bb4b8SJason M. Bills  *
1543684bb4b8SJason M. Bills  * See header file for more information
1544684bb4b8SJason M. Bills  * @endinternal
1545684bb4b8SJason M. Bills  */
1546684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void)
1547684bb4b8SJason M. Bills {
1548fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1549fffb8c1fSEd Tanous                   {});
1550684bb4b8SJason M. Bills }
1551684bb4b8SJason M. Bills 
1552684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1553684bb4b8SJason M. Bills {
1554684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1555684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1556684bb4b8SJason M. Bills }
1557684bb4b8SJason M. Bills 
1558684bb4b8SJason M. Bills /**
1559684bb4b8SJason M. Bills  * @internal
1560f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1561f4c4dcf4SKowalski, Kamil  *
1562f4c4dcf4SKowalski, Kamil  * See header file for more information
1563f4c4dcf4SKowalski, Kamil  * @endinternal
1564f4c4dcf4SKowalski, Kamil  */
1565b5c07418SJames Feist nlohmann::json insufficientPrivilege(void)
15661abe55efSEd Tanous {
1567fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1568b5c07418SJames Feist }
1569b5c07418SJames Feist 
1570b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1571b5c07418SJames Feist {
1572b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1573b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1574f4c4dcf4SKowalski, Kamil }
1575f4c4dcf4SKowalski, Kamil 
1576f4c4dcf4SKowalski, Kamil /**
1577f4c4dcf4SKowalski, Kamil  * @internal
1578f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1579f4c4dcf4SKowalski, Kamil  *
1580f4c4dcf4SKowalski, Kamil  * See header file for more information
1581f4c4dcf4SKowalski, Kamil  * @endinternal
1582f4c4dcf4SKowalski, Kamil  */
15831668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1,
15841668ce6dSEd Tanous                                      std::string_view arg2)
1585b5c07418SJames Feist {
1586fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueModified,
15871668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1588b5c07418SJames Feist }
1589b5c07418SJames Feist 
15901668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1,
15911668ce6dSEd Tanous                            std::string_view arg2)
15921abe55efSEd Tanous {
1593f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1594b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1595f4c4dcf4SKowalski, Kamil }
1596f4c4dcf4SKowalski, Kamil 
1597f4c4dcf4SKowalski, Kamil /**
1598f4c4dcf4SKowalski, Kamil  * @internal
1599f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1600f4c4dcf4SKowalski, Kamil  *
1601f4c4dcf4SKowalski, Kamil  * See header file for more information
1602f4c4dcf4SKowalski, Kamil  * @endinternal
1603f4c4dcf4SKowalski, Kamil  */
1604b5c07418SJames Feist nlohmann::json accountNotModified(void)
16051abe55efSEd Tanous {
1606fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountNotModified, {});
1607b5c07418SJames Feist }
1608b5c07418SJames Feist 
1609b5c07418SJames Feist void accountNotModified(crow::Response& res)
1610b5c07418SJames Feist {
1611b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1612b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1613f4c4dcf4SKowalski, Kamil }
1614f4c4dcf4SKowalski, Kamil 
1615f4c4dcf4SKowalski, Kamil /**
1616f4c4dcf4SKowalski, Kamil  * @internal
1617f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1618f4c4dcf4SKowalski, Kamil  *
1619f4c4dcf4SKowalski, Kamil  * See header file for more information
1620f4c4dcf4SKowalski, Kamil  * @endinternal
1621f4c4dcf4SKowalski, Kamil  */
16221668ce6dSEd Tanous nlohmann::json queryParameterValueFormatError(std::string_view arg1,
16231668ce6dSEd Tanous                                               std::string_view arg2)
16241abe55efSEd Tanous {
1625fffb8c1fSEd Tanous     return getLog(
1626fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueFormatError,
16271668ce6dSEd Tanous         std::to_array({arg1, arg2}));
1628b5c07418SJames Feist }
1629b5c07418SJames Feist 
16301668ce6dSEd Tanous void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
16311668ce6dSEd Tanous                                     std::string_view arg2)
1632b5c07418SJames Feist {
1633b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1634b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1635b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
1636f4c4dcf4SKowalski, Kamil }
1637f4c4dcf4SKowalski, Kamil 
1638f4c4dcf4SKowalski, Kamil /**
1639f4c4dcf4SKowalski, Kamil  * @internal
1640b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
1641b5c07418SJames Feist  * property
1642f12894f8SJason M. Bills  *
1643f12894f8SJason M. Bills  * See header file for more information
1644f12894f8SJason M. Bills  * @endinternal
1645f12894f8SJason M. Bills  */
16461668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1)
1647f12894f8SJason M. Bills {
1648fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyMissing,
16491668ce6dSEd Tanous                   std::to_array({arg1}));
1650b5c07418SJames Feist }
1651b5c07418SJames Feist 
16521668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1)
1653b5c07418SJames Feist {
1654b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1655b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1656f4c4dcf4SKowalski, Kamil }
1657f4c4dcf4SKowalski, Kamil 
1658f4c4dcf4SKowalski, Kamil /**
1659f4c4dcf4SKowalski, Kamil  * @internal
1660f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
1661f4c4dcf4SKowalski, Kamil  *
1662f4c4dcf4SKowalski, Kamil  * See header file for more information
1663f4c4dcf4SKowalski, Kamil  * @endinternal
1664f4c4dcf4SKowalski, Kamil  */
16651668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1)
16661abe55efSEd Tanous {
1667fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceExhaustion,
16681668ce6dSEd Tanous                   std::to_array({arg1}));
1669b5c07418SJames Feist }
1670b5c07418SJames Feist 
16711668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1)
1672b5c07418SJames Feist {
1673b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1674b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1675f4c4dcf4SKowalski, Kamil }
1676f4c4dcf4SKowalski, Kamil 
1677f4c4dcf4SKowalski, Kamil /**
1678f4c4dcf4SKowalski, Kamil  * @internal
1679f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
1680f4c4dcf4SKowalski, Kamil  *
1681f4c4dcf4SKowalski, Kamil  * See header file for more information
1682f4c4dcf4SKowalski, Kamil  * @endinternal
1683f4c4dcf4SKowalski, Kamil  */
1684b5c07418SJames Feist nlohmann::json accountModified(void)
16851abe55efSEd Tanous {
1686fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountModified, {});
1687b5c07418SJames Feist }
1688b5c07418SJames Feist 
1689b5c07418SJames Feist void accountModified(crow::Response& res)
1690b5c07418SJames Feist {
1691b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1692b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
1693f4c4dcf4SKowalski, Kamil }
1694f4c4dcf4SKowalski, Kamil 
1695f4c4dcf4SKowalski, Kamil /**
1696f4c4dcf4SKowalski, Kamil  * @internal
1697f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
1698f4c4dcf4SKowalski, Kamil  *
1699f4c4dcf4SKowalski, Kamil  * See header file for more information
1700f4c4dcf4SKowalski, Kamil  * @endinternal
1701f4c4dcf4SKowalski, Kamil  */
17021668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1,
17031668ce6dSEd Tanous                                         std::string_view arg2,
17041668ce6dSEd Tanous                                         std::string_view arg3)
17051abe55efSEd Tanous {
1706fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
17071668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
1708b5c07418SJames Feist }
1709b5c07418SJames Feist 
17101668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
17111668ce6dSEd Tanous                               std::string_view arg2, std::string_view arg3)
1712b5c07418SJames Feist {
1713b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1714b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1715b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
1716f4c4dcf4SKowalski, Kamil }
1717f4c4dcf4SKowalski, Kamil 
1718*d9f466b3SEd Tanous nlohmann::json passwordChangeRequired(boost::urls::url_view arg1)
1719b6cd31e1SEd Tanous {
1720fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::passwordChangeRequired,
1721079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1722b6cd31e1SEd Tanous }
1723b6cd31e1SEd Tanous 
17243bf4e632SJoseph Reynolds /**
17253bf4e632SJoseph Reynolds  * @internal
17263bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
17273bf4e632SJoseph Reynolds  *
17283bf4e632SJoseph Reynolds  * See header file for more information
17293bf4e632SJoseph Reynolds  * @endinternal
17303bf4e632SJoseph Reynolds  */
1731*d9f466b3SEd Tanous void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1)
17323bf4e632SJoseph Reynolds {
1733b6cd31e1SEd Tanous     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
17343bf4e632SJoseph Reynolds }
17353bf4e632SJoseph Reynolds 
17364cde5d90SJames Feist /**
17374cde5d90SJames Feist  * @internal
1738ae688313SNan Zhou  * @brief Formats InsufficientStorage message into JSON
1739ae688313SNan Zhou  *
1740ae688313SNan Zhou  * See header file for more information
1741ae688313SNan Zhou  * @endinternal
1742ae688313SNan Zhou  */
1743ae688313SNan Zhou nlohmann::json insufficientStorage()
1744ae688313SNan Zhou {
1745ae688313SNan Zhou     return getLog(redfish::registries::base::Index::insufficientStorage, {});
1746ae688313SNan Zhou }
1747ae688313SNan Zhou 
1748ae688313SNan Zhou void insufficientStorage(crow::Response& res)
1749ae688313SNan Zhou {
1750ae688313SNan Zhou     res.result(boost::beast::http::status::insufficient_storage);
1751ae688313SNan Zhou     addMessageToErrorJson(res.jsonValue, insufficientStorage());
1752ae688313SNan Zhou }
1753ae688313SNan Zhou 
1754ae688313SNan Zhou /**
1755ae688313SNan Zhou  * @internal
175644c70412SEd Tanous  * @brief Formats OperationNotAllowed message into JSON
175744c70412SEd Tanous  *
175844c70412SEd Tanous  * See header file for more information
175944c70412SEd Tanous  * @endinternal
176044c70412SEd Tanous  */
176144c70412SEd Tanous nlohmann::json operationNotAllowed()
176244c70412SEd Tanous {
176344c70412SEd Tanous     return getLog(redfish::registries::base::Index::operationNotAllowed, {});
176444c70412SEd Tanous }
176544c70412SEd Tanous 
176644c70412SEd Tanous void operationNotAllowed(crow::Response& res)
176744c70412SEd Tanous {
176844c70412SEd Tanous     res.result(boost::beast::http::status::method_not_allowed);
176944c70412SEd Tanous     addMessageToErrorJson(res.jsonValue, operationNotAllowed());
177044c70412SEd Tanous }
177144c70412SEd Tanous 
177244c70412SEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1,
177344c70412SEd Tanous                    std::string_view arg2)
177444c70412SEd Tanous {
177544c70412SEd Tanous     res.result(boost::beast::http::status::bad_request);
177644c70412SEd Tanous     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
177744c70412SEd Tanous }
177844c70412SEd Tanous 
177944c70412SEd Tanous /**
178044c70412SEd Tanous  * @internal
17814cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
17824cde5d90SJames Feist  *
17834cde5d90SJames Feist  * See header file for more information
17844cde5d90SJames Feist  * @endinternal
17854cde5d90SJames Feist  */
17861668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
17874cde5d90SJames Feist {
17881668ce6dSEd Tanous     std::string msg = "Invalid file uploaded to ";
17891668ce6dSEd Tanous     msg += arg1;
17901668ce6dSEd Tanous     msg += ": ";
17911668ce6dSEd Tanous     msg += arg2;
17921668ce6dSEd Tanous     msg += ".";
1793613dabeaSEd Tanous 
1794613dabeaSEd Tanous     nlohmann::json::object_t ret;
1795613dabeaSEd Tanous     ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message";
1796613dabeaSEd Tanous     ret["MessageId"] = "OpenBMC.0.2.InvalidUpload";
1797613dabeaSEd Tanous     ret["Message"] = std::move(msg);
1798613dabeaSEd Tanous     nlohmann::json::array_t args;
1799613dabeaSEd Tanous     args.push_back(arg1);
1800613dabeaSEd Tanous     args.push_back(arg2);
1801613dabeaSEd Tanous     ret["MessageArgs"] = std::move(args);
1802613dabeaSEd Tanous     ret["MessageSeverity"] = "Warning";
1803613dabeaSEd Tanous     ret["Resolution"] = "None.";
1804613dabeaSEd Tanous     return ret;
18054cde5d90SJames Feist }
1806ae688313SNan Zhou 
1807f4c4dcf4SKowalski, Kamil } // namespace messages
1808f4c4dcf4SKowalski, Kamil 
1809d425c6f6SEd Tanous } // namespace redfish
1810