xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision b54eb49f2a7ad0c3c7ce4e1ff50fce18a3522c4c)
1f4c4dcf4SKowalski, Kamil /*
2f4c4dcf4SKowalski, Kamil // Copyright (c) 2018 Intel Corporation
3f4c4dcf4SKowalski, Kamil //
4f4c4dcf4SKowalski, Kamil // Licensed under the Apache License, Version 2.0 (the "License");
5f4c4dcf4SKowalski, Kamil // you may not use this file except in compliance with the License.
6f4c4dcf4SKowalski, Kamil // You may obtain a copy of the License at
7f4c4dcf4SKowalski, Kamil //
8f4c4dcf4SKowalski, Kamil //      http://www.apache.org/licenses/LICENSE-2.0
9f4c4dcf4SKowalski, Kamil //
10f4c4dcf4SKowalski, Kamil // Unless required by applicable law or agreed to in writing, software
11f4c4dcf4SKowalski, Kamil // distributed under the License is distributed on an "AS IS" BASIS,
12f4c4dcf4SKowalski, Kamil // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13f4c4dcf4SKowalski, Kamil // See the License for the specific language governing permissions and
14f4c4dcf4SKowalski, Kamil // limitations under the License.
15f4c4dcf4SKowalski, Kamil */
160442ef92SNan Zhou #include "error_messages.hpp"
179ea15c35SEd Tanous 
180442ef92SNan Zhou #include "http_response.hpp"
190442ef92SNan Zhou #include "logging.hpp"
200442ef92SNan Zhou #include "registries.hpp"
210442ef92SNan Zhou #include "registries/base_message_registry.hpp"
220442ef92SNan Zhou 
230442ef92SNan Zhou #include <boost/beast/http/field.hpp>
249ea15c35SEd Tanous #include <boost/beast/http/status.hpp>
254a7fbefdSEd Tanous #include <boost/url/url_view_base.hpp>
26faf100f9SEd Tanous #include <nlohmann/json.hpp>
27f4c4dcf4SKowalski, Kamil 
281668ce6dSEd Tanous #include <array>
290442ef92SNan Zhou #include <cstddef>
30f0b59af4SEd Tanous #include <cstdint>
31d85418e3SPatrick Williams #include <source_location>
320442ef92SNan Zhou #include <span>
330442ef92SNan Zhou #include <string>
34f0b59af4SEd Tanous #include <string_view>
350442ef92SNan Zhou #include <utility>
360442ef92SNan Zhou 
370442ef92SNan Zhou // IWYU pragma: no_include <stddef.h>
381668ce6dSEd Tanous 
391abe55efSEd Tanous namespace redfish
401abe55efSEd Tanous {
411abe55efSEd Tanous 
421abe55efSEd Tanous namespace messages
431abe55efSEd Tanous {
44f4c4dcf4SKowalski, Kamil 
45f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target,
461abe55efSEd Tanous                                   const nlohmann::json& message)
471abe55efSEd Tanous {
48f4c4dcf4SKowalski, Kamil     auto& error = target["error"];
49f4c4dcf4SKowalski, Kamil 
501abe55efSEd Tanous     // If this is the first error message, fill in the information from the
511abe55efSEd Tanous     // first error message to the top level struct
521abe55efSEd Tanous     if (!error.is_object())
531abe55efSEd Tanous     {
54c074230bSJason M. Bills         auto messageIdIterator = message.find("MessageId");
55c074230bSJason M. Bills         if (messageIdIterator == message.end())
561abe55efSEd Tanous         {
5762598e31SEd Tanous             BMCWEB_LOG_CRITICAL(
5862598e31SEd Tanous                 "Attempt to add error message without MessageId");
59f4c4dcf4SKowalski, Kamil             return;
60f4c4dcf4SKowalski, Kamil         }
61f4c4dcf4SKowalski, Kamil 
62c074230bSJason M. Bills         auto messageFieldIterator = message.find("Message");
63c074230bSJason M. Bills         if (messageFieldIterator == message.end())
641abe55efSEd Tanous         {
6562598e31SEd Tanous             BMCWEB_LOG_CRITICAL("Attempt to add error message without Message");
66f4c4dcf4SKowalski, Kamil             return;
67f4c4dcf4SKowalski, Kamil         }
681476687dSEd Tanous         error["code"] = *messageIdIterator;
691476687dSEd Tanous         error["message"] = *messageFieldIterator;
701abe55efSEd Tanous     }
711abe55efSEd Tanous     else
721abe55efSEd Tanous     {
73f4c4dcf4SKowalski, Kamil         // More than 1 error occurred, so the message has to be generic
7455c7b7a2SEd Tanous         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
75cc9139ecSJason M. Bills         error["message"] = "A general error has occurred. See Resolution for "
76cc9139ecSJason M. Bills                            "information on how to resolve the error.";
77f4c4dcf4SKowalski, Kamil     }
78f4c4dcf4SKowalski, Kamil 
793590bd1dSNan Zhou     // This check could technically be done in the default construction
80f4c4dcf4SKowalski, Kamil     // branch above, but because we need the pointer to the extended info field
81f4c4dcf4SKowalski, Kamil     // anyway, it's more efficient to do it here.
82c074230bSJason M. Bills     auto& extendedInfo = error[messages::messageAnnotation];
83c074230bSJason M. Bills     if (!extendedInfo.is_array())
841abe55efSEd Tanous     {
85c074230bSJason M. Bills         extendedInfo = nlohmann::json::array();
86f4c4dcf4SKowalski, Kamil     }
87f4c4dcf4SKowalski, Kamil 
88c074230bSJason M. Bills     extendedInfo.push_back(message);
89f4c4dcf4SKowalski, Kamil }
90f4c4dcf4SKowalski, Kamil 
913590bd1dSNan Zhou void moveErrorsToErrorJson(nlohmann::json& target, nlohmann::json& source)
923590bd1dSNan Zhou {
933590bd1dSNan Zhou     if (!source.is_object())
943590bd1dSNan Zhou     {
953590bd1dSNan Zhou         return;
963590bd1dSNan Zhou     }
973590bd1dSNan Zhou     auto errorIt = source.find("error");
983590bd1dSNan Zhou     if (errorIt == source.end())
993590bd1dSNan Zhou     {
1003590bd1dSNan Zhou         // caller puts error message in root
1013590bd1dSNan Zhou         messages::addMessageToErrorJson(target, source);
1023590bd1dSNan Zhou         source.clear();
1033590bd1dSNan Zhou         return;
1043590bd1dSNan Zhou     }
1053590bd1dSNan Zhou     auto extendedInfoIt = errorIt->find(messages::messageAnnotation);
1063590bd1dSNan Zhou     if (extendedInfoIt == errorIt->end())
1073590bd1dSNan Zhou     {
1083590bd1dSNan Zhou         return;
1093590bd1dSNan Zhou     }
1103590bd1dSNan Zhou     const nlohmann::json::array_t* extendedInfo =
1113590bd1dSNan Zhou         (*extendedInfoIt).get_ptr<const nlohmann::json::array_t*>();
1123590bd1dSNan Zhou     if (extendedInfo == nullptr)
1133590bd1dSNan Zhou     {
1143590bd1dSNan Zhou         source.erase(errorIt);
1153590bd1dSNan Zhou         return;
1163590bd1dSNan Zhou     }
1173590bd1dSNan Zhou     for (const nlohmann::json& message : *extendedInfo)
1183590bd1dSNan Zhou     {
1193590bd1dSNan Zhou         addMessageToErrorJson(target, message);
1203590bd1dSNan Zhou     }
1213590bd1dSNan Zhou     source.erase(errorIt);
1223590bd1dSNan Zhou }
1233590bd1dSNan Zhou 
124f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target,
125f12894f8SJason M. Bills                                  const nlohmann::json& message)
1261abe55efSEd Tanous {
1271abe55efSEd Tanous     if (!target[messages::messageAnnotation].is_array())
1281abe55efSEd Tanous     {
129f4c4dcf4SKowalski, Kamil         // Force object to be an array
13055c7b7a2SEd Tanous         target[messages::messageAnnotation] = nlohmann::json::array();
131f4c4dcf4SKowalski, Kamil     }
132f4c4dcf4SKowalski, Kamil 
13355c7b7a2SEd Tanous     target[messages::messageAnnotation].push_back(message);
134f4c4dcf4SKowalski, Kamil }
135f4c4dcf4SKowalski, Kamil 
136f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target,
137f12894f8SJason M. Bills                              const nlohmann::json& message,
1381668ce6dSEd Tanous                              std::string_view fieldPath)
1391abe55efSEd Tanous {
1401668ce6dSEd Tanous     std::string extendedInfo(fieldPath);
1411668ce6dSEd Tanous     extendedInfo += messages::messageAnnotation;
142f4c4dcf4SKowalski, Kamil 
1431668ce6dSEd Tanous     nlohmann::json& field = target[extendedInfo];
1441668ce6dSEd Tanous     if (!field.is_array())
1451abe55efSEd Tanous     {
146f4c4dcf4SKowalski, Kamil         // Force object to be an array
1471668ce6dSEd Tanous         field = nlohmann::json::array();
148f4c4dcf4SKowalski, Kamil     }
149f4c4dcf4SKowalski, Kamil 
150f4c4dcf4SKowalski, Kamil     // Object exists and it is an array so we can just push in the message
1511668ce6dSEd Tanous     field.push_back(message);
152f4c4dcf4SKowalski, Kamil }
153f4c4dcf4SKowalski, Kamil 
154f7725d79SEd Tanous static nlohmann::json getLog(redfish::registries::base::Index name,
155b6cd31e1SEd Tanous                              std::span<const std::string_view> args)
156b6cd31e1SEd Tanous {
157b6cd31e1SEd Tanous     size_t index = static_cast<size_t>(name);
158fffb8c1fSEd Tanous     if (index >= redfish::registries::base::registry.size())
159b6cd31e1SEd Tanous     {
160b6cd31e1SEd Tanous         return {};
161b6cd31e1SEd Tanous     }
16265e4f1f7SEd Tanous     return getLogFromRegistry(redfish::registries::base::header,
16365e4f1f7SEd Tanous                               redfish::registries::base::registry, index, args);
164b6cd31e1SEd Tanous }
165b6cd31e1SEd Tanous 
166f4c4dcf4SKowalski, Kamil /**
167f4c4dcf4SKowalski, Kamil  * @internal
168f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
169f4c4dcf4SKowalski, Kamil  *
170f4c4dcf4SKowalski, Kamil  * See header file for more information
171f4c4dcf4SKowalski, Kamil  * @endinternal
172f4c4dcf4SKowalski, Kamil  */
173d9fcfcc1SEd Tanous nlohmann::json resourceInUse()
1741abe55efSEd Tanous {
175fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInUse, {});
176b5c07418SJames Feist }
177b5c07418SJames Feist 
178b5c07418SJames Feist void resourceInUse(crow::Response& res)
179b5c07418SJames Feist {
180b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
181b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
182f4c4dcf4SKowalski, Kamil }
183f4c4dcf4SKowalski, Kamil 
184f4c4dcf4SKowalski, Kamil /**
185f4c4dcf4SKowalski, Kamil  * @internal
186f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
187f4c4dcf4SKowalski, Kamil  *
188f4c4dcf4SKowalski, Kamil  * See header file for more information
189f4c4dcf4SKowalski, Kamil  * @endinternal
190f4c4dcf4SKowalski, Kamil  */
191d9fcfcc1SEd Tanous nlohmann::json malformedJSON()
1921abe55efSEd Tanous {
193fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::malformedJSON, {});
194b5c07418SJames Feist }
195b5c07418SJames Feist 
196b5c07418SJames Feist void malformedJSON(crow::Response& res)
197b5c07418SJames Feist {
198b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
199b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
200f4c4dcf4SKowalski, Kamil }
201f4c4dcf4SKowalski, Kamil 
202f4c4dcf4SKowalski, Kamil /**
203f4c4dcf4SKowalski, Kamil  * @internal
204f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
205f4c4dcf4SKowalski, Kamil  *
206f4c4dcf4SKowalski, Kamil  * See header file for more information
207f4c4dcf4SKowalski, Kamil  * @endinternal
208f4c4dcf4SKowalski, Kamil  */
2094a7fbefdSEd Tanous nlohmann::json resourceMissingAtURI(const boost::urls::url_view_base& arg1)
2101abe55efSEd Tanous {
211079360aeSEd Tanous     std::array<std::string_view, 1> args{arg1.buffer()};
212fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceMissingAtURI, args);
213b5c07418SJames Feist }
214b5c07418SJames Feist 
2154a7fbefdSEd Tanous void resourceMissingAtURI(crow::Response& res,
2164a7fbefdSEd Tanous                           const boost::urls::url_view_base& arg1)
217b5c07418SJames Feist {
218b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
219b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
220f4c4dcf4SKowalski, Kamil }
221f4c4dcf4SKowalski, Kamil 
222f4c4dcf4SKowalski, Kamil /**
223f4c4dcf4SKowalski, Kamil  * @internal
224f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
225f4c4dcf4SKowalski, Kamil  *
226f4c4dcf4SKowalski, Kamil  * See header file for more information
227f4c4dcf4SKowalski, Kamil  * @endinternal
228f4c4dcf4SKowalski, Kamil  */
229bd79bce8SPatrick Williams nlohmann::json actionParameterValueFormatError(
230bd79bce8SPatrick Williams     const nlohmann::json& arg1, std::string_view arg2, std::string_view arg3)
2311abe55efSEd Tanous {
232bd79bce8SPatrick Williams     std::string arg1Str =
233bd79bce8SPatrick Williams         arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
234fffb8c1fSEd Tanous     return getLog(
235fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueFormatError,
23695b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2, arg3}));
237b5c07418SJames Feist }
238b5c07418SJames Feist 
239bd79bce8SPatrick Williams void actionParameterValueFormatError(
240bd79bce8SPatrick Williams     crow::Response& res, const nlohmann::json& arg1, std::string_view arg2,
2411668ce6dSEd Tanous     std::string_view arg3)
242b5c07418SJames Feist {
243b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
244b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
245b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
246f4c4dcf4SKowalski, Kamil }
247f4c4dcf4SKowalski, Kamil 
248f4c4dcf4SKowalski, Kamil /**
249f4c4dcf4SKowalski, Kamil  * @internal
2504ef82a15SAlex Schendel  * @brief Formats ActionParameterValueNotInList message into JSON
2514ef82a15SAlex Schendel  *
2524ef82a15SAlex Schendel  * See header file for more information
2534ef82a15SAlex Schendel  * @endinternal
2544ef82a15SAlex Schendel  */
255bd79bce8SPatrick Williams nlohmann::json actionParameterValueNotInList(
256bd79bce8SPatrick Williams     std::string_view arg1, std::string_view arg2, std::string_view arg3)
2574ef82a15SAlex Schendel {
2584ef82a15SAlex Schendel     return getLog(
2594ef82a15SAlex Schendel         redfish::registries::base::Index::actionParameterValueNotInList,
2604ef82a15SAlex Schendel         std::to_array({arg1, arg2, arg3}));
2614ef82a15SAlex Schendel }
2624ef82a15SAlex Schendel 
2634ef82a15SAlex Schendel void actionParameterValueNotInList(crow::Response& res, std::string_view arg1,
2644ef82a15SAlex Schendel                                    std::string_view arg2, std::string_view arg3)
2654ef82a15SAlex Schendel {
2664ef82a15SAlex Schendel     res.result(boost::beast::http::status::bad_request);
2674ef82a15SAlex Schendel     addMessageToErrorJson(res.jsonValue,
2684ef82a15SAlex Schendel                           actionParameterValueNotInList(arg1, arg2, arg3));
2694ef82a15SAlex Schendel }
2704ef82a15SAlex Schendel 
2714ef82a15SAlex Schendel /**
2724ef82a15SAlex Schendel  * @internal
273f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
274f4c4dcf4SKowalski, Kamil  *
275f4c4dcf4SKowalski, Kamil  * See header file for more information
276f4c4dcf4SKowalski, Kamil  * @endinternal
277f4c4dcf4SKowalski, Kamil  */
278d9fcfcc1SEd Tanous nlohmann::json internalError()
2791abe55efSEd Tanous {
280fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::internalError, {});
281b5c07418SJames Feist }
282b5c07418SJames Feist 
283d85418e3SPatrick Williams void internalError(crow::Response& res, const std::source_location location)
284b5c07418SJames Feist {
28562598e31SEd Tanous     BMCWEB_LOG_CRITICAL("Internal Error {}({}:{}) `{}`: ", location.file_name(),
28662598e31SEd Tanous                         location.line(), location.column(),
28762598e31SEd Tanous                         location.function_name());
288b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
289b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
290f12894f8SJason M. Bills }
291f12894f8SJason M. Bills 
292f12894f8SJason M. Bills /**
293f12894f8SJason M. Bills  * @internal
294f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
295f4c4dcf4SKowalski, Kamil  *
296f4c4dcf4SKowalski, Kamil  * See header file for more information
297f4c4dcf4SKowalski, Kamil  * @endinternal
298f4c4dcf4SKowalski, Kamil  */
299d9fcfcc1SEd Tanous nlohmann::json unrecognizedRequestBody()
3001abe55efSEd Tanous {
301fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::unrecognizedRequestBody,
302fffb8c1fSEd Tanous                   {});
303b5c07418SJames Feist }
304b5c07418SJames Feist 
305b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
306b5c07418SJames Feist {
307b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
308b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
309f4c4dcf4SKowalski, Kamil }
310f4c4dcf4SKowalski, Kamil 
311f4c4dcf4SKowalski, Kamil /**
312f4c4dcf4SKowalski, Kamil  * @internal
313f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
314f4c4dcf4SKowalski, Kamil  *
315f4c4dcf4SKowalski, Kamil  * See header file for more information
316f4c4dcf4SKowalski, Kamil  * @endinternal
317f4c4dcf4SKowalski, Kamil  */
3184a7fbefdSEd Tanous nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view_base& arg1,
3191668ce6dSEd Tanous                                          std::string_view arg2)
3201abe55efSEd Tanous {
321079360aeSEd Tanous     return getLog(redfish::registries::base::Index::resourceAtUriUnauthorized,
322079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer(), arg2}));
323b5c07418SJames Feist }
324b5c07418SJames Feist 
3254a7fbefdSEd Tanous void resourceAtUriUnauthorized(crow::Response& res,
3264a7fbefdSEd Tanous                                const boost::urls::url_view_base& arg1,
3271668ce6dSEd Tanous                                std::string_view arg2)
328b5c07418SJames Feist {
329b5c07418SJames Feist     res.result(boost::beast::http::status::unauthorized);
330b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
331f4c4dcf4SKowalski, Kamil }
332f4c4dcf4SKowalski, Kamil 
333f4c4dcf4SKowalski, Kamil /**
334f4c4dcf4SKowalski, Kamil  * @internal
335f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterUnknown message into JSON
336f4c4dcf4SKowalski, Kamil  *
337f4c4dcf4SKowalski, Kamil  * See header file for more information
338f4c4dcf4SKowalski, Kamil  * @endinternal
339f4c4dcf4SKowalski, Kamil  */
3401668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1,
3411668ce6dSEd Tanous                                       std::string_view arg2)
342b5c07418SJames Feist {
343fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterUnknown,
3441668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
345b5c07418SJames Feist }
346b5c07418SJames Feist 
3471668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1,
3481668ce6dSEd Tanous                             std::string_view arg2)
3491abe55efSEd Tanous {
350f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
351b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
352f4c4dcf4SKowalski, Kamil }
353f4c4dcf4SKowalski, Kamil 
354f4c4dcf4SKowalski, Kamil /**
355f4c4dcf4SKowalski, Kamil  * @internal
356f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceCannotBeDeleted message into JSON
357f4c4dcf4SKowalski, Kamil  *
358f4c4dcf4SKowalski, Kamil  * See header file for more information
359f4c4dcf4SKowalski, Kamil  * @endinternal
360f4c4dcf4SKowalski, Kamil  */
361d9fcfcc1SEd Tanous nlohmann::json resourceCannotBeDeleted()
3621abe55efSEd Tanous {
363fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCannotBeDeleted,
364fffb8c1fSEd Tanous                   {});
365b5c07418SJames Feist }
366b5c07418SJames Feist 
367b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res)
368b5c07418SJames Feist {
36944c70412SEd Tanous     res.result(boost::beast::http::status::method_not_allowed);
370b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
371f4c4dcf4SKowalski, Kamil }
372f4c4dcf4SKowalski, Kamil 
373f4c4dcf4SKowalski, Kamil /**
374f4c4dcf4SKowalski, Kamil  * @internal
375f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyDuplicate message into JSON
376f4c4dcf4SKowalski, Kamil  *
377f4c4dcf4SKowalski, Kamil  * See header file for more information
378f4c4dcf4SKowalski, Kamil  * @endinternal
379f4c4dcf4SKowalski, Kamil  */
3801668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1)
3811abe55efSEd Tanous {
382fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyDuplicate,
3831668ce6dSEd Tanous                   std::to_array({arg1}));
384b5c07418SJames Feist }
385b5c07418SJames Feist 
3861668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1)
387b5c07418SJames Feist {
388b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
389b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
390f4c4dcf4SKowalski, Kamil }
391f4c4dcf4SKowalski, Kamil 
392f4c4dcf4SKowalski, Kamil /**
393f4c4dcf4SKowalski, Kamil  * @internal
394f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
395f4c4dcf4SKowalski, Kamil  *
396f4c4dcf4SKowalski, Kamil  * See header file for more information
397f4c4dcf4SKowalski, Kamil  * @endinternal
398f4c4dcf4SKowalski, Kamil  */
3991668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
4001abe55efSEd Tanous {
401b6cd31e1SEd Tanous     return getLog(
402fffb8c1fSEd Tanous         redfish::registries::base::Index::serviceTemporarilyUnavailable,
4031668ce6dSEd Tanous         std::to_array({arg1}));
404b5c07418SJames Feist }
405b5c07418SJames Feist 
4061668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
407b5c07418SJames Feist {
408d9f6c621SEd Tanous     res.addHeader(boost::beast::http::field::retry_after, arg1);
409b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
410b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
411f4c4dcf4SKowalski, Kamil }
412f4c4dcf4SKowalski, Kamil 
413f4c4dcf4SKowalski, Kamil /**
414f4c4dcf4SKowalski, Kamil  * @internal
415f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
416f4c4dcf4SKowalski, Kamil  *
417f4c4dcf4SKowalski, Kamil  * See header file for more information
418f4c4dcf4SKowalski, Kamil  * @endinternal
419f4c4dcf4SKowalski, Kamil  */
420bd79bce8SPatrick Williams nlohmann::json resourceAlreadyExists(
421bd79bce8SPatrick Williams     std::string_view arg1, std::string_view arg2, std::string_view arg3)
4221abe55efSEd Tanous {
423fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceAlreadyExists,
4241668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
425b5c07418SJames Feist }
426b5c07418SJames Feist 
4271668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
4281668ce6dSEd Tanous                            std::string_view arg2, std::string_view arg3)
429b5c07418SJames Feist {
430b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
431b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
432a08b46ccSJason M. Bills                      arg2);
433f4c4dcf4SKowalski, Kamil }
434f4c4dcf4SKowalski, Kamil 
435f4c4dcf4SKowalski, Kamil /**
436f4c4dcf4SKowalski, Kamil  * @internal
437f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
438f4c4dcf4SKowalski, Kamil  *
439f4c4dcf4SKowalski, Kamil  * See header file for more information
440f4c4dcf4SKowalski, Kamil  * @endinternal
441f4c4dcf4SKowalski, Kamil  */
442d9fcfcc1SEd Tanous nlohmann::json accountForSessionNoLongerExists()
4431abe55efSEd Tanous {
444fffb8c1fSEd Tanous     return getLog(
445fffb8c1fSEd Tanous         redfish::registries::base::Index::accountForSessionNoLongerExists, {});
446b5c07418SJames Feist }
447b5c07418SJames Feist 
448b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
449b5c07418SJames Feist {
450b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
451b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
452f4c4dcf4SKowalski, Kamil }
453f4c4dcf4SKowalski, Kamil 
454f4c4dcf4SKowalski, Kamil /**
455f4c4dcf4SKowalski, Kamil  * @internal
456f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
457f4c4dcf4SKowalski, Kamil  *
458f4c4dcf4SKowalski, Kamil  * See header file for more information
459f4c4dcf4SKowalski, Kamil  * @endinternal
460f4c4dcf4SKowalski, Kamil  */
4611668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
4621abe55efSEd Tanous {
463fffb8c1fSEd Tanous     return getLog(
464fffb8c1fSEd Tanous         redfish::registries::base::Index::createFailedMissingReqProperties,
4651668ce6dSEd Tanous         std::to_array({arg1}));
466b5c07418SJames Feist }
467b5c07418SJames Feist 
468b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
4691668ce6dSEd Tanous                                       std::string_view arg1)
470b5c07418SJames Feist {
471b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
472b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
473a08b46ccSJason M. Bills                      arg1);
474f12894f8SJason M. Bills }
475f12894f8SJason M. Bills 
476f12894f8SJason M. Bills /**
477f12894f8SJason M. Bills  * @internal
478f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
479f12894f8SJason M. Bills  * property
480f12894f8SJason M. Bills  *
481f12894f8SJason M. Bills  * See header file for more information
482f12894f8SJason M. Bills  * @endinternal
483f12894f8SJason M. Bills  */
484f818b04dSEd Tanous nlohmann::json propertyValueFormatError(const nlohmann::json& arg1,
4851668ce6dSEd Tanous                                         std::string_view arg2)
486f12894f8SJason M. Bills {
487bd79bce8SPatrick Williams     std::string arg1Str =
488bd79bce8SPatrick Williams         arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
489fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueFormatError,
490f818b04dSEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
491b5c07418SJames Feist }
492b5c07418SJames Feist 
493f818b04dSEd Tanous void propertyValueFormatError(crow::Response& res, const nlohmann::json& arg1,
4941668ce6dSEd Tanous                               std::string_view arg2)
495b5c07418SJames Feist {
496b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
497b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
498f12894f8SJason M. Bills }
499f12894f8SJason M. Bills 
500f12894f8SJason M. Bills /**
501f12894f8SJason M. Bills  * @internal
502f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
503f12894f8SJason M. Bills  * property
504f12894f8SJason M. Bills  *
505f12894f8SJason M. Bills  * See header file for more information
506f12894f8SJason M. Bills  * @endinternal
507f12894f8SJason M. Bills  */
508e2616cc5SEd Tanous 
509e2616cc5SEd Tanous nlohmann::json propertyValueNotInList(const nlohmann::json& arg1,
5101668ce6dSEd Tanous                                       std::string_view arg2)
511f12894f8SJason M. Bills {
512bd79bce8SPatrick Williams     std::string arg1Str =
513bd79bce8SPatrick Williams         arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
514fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueNotInList,
515e2616cc5SEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
516b5c07418SJames Feist }
517b5c07418SJames Feist 
518e2616cc5SEd Tanous void propertyValueNotInList(crow::Response& res, const nlohmann::json& arg1,
5191668ce6dSEd Tanous                             std::string_view arg2)
520b5c07418SJames Feist {
521b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
522b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
523f4c4dcf4SKowalski, Kamil }
524f4c4dcf4SKowalski, Kamil 
525f4c4dcf4SKowalski, Kamil /**
526f4c4dcf4SKowalski, Kamil  * @internal
527227a2b0aSJiaqing Zhao  * @brief Formats PropertyValueOutOfRange message into JSON
528227a2b0aSJiaqing Zhao  *
529227a2b0aSJiaqing Zhao  * See header file for more information
530227a2b0aSJiaqing Zhao  * @endinternal
531227a2b0aSJiaqing Zhao  */
53295b3ad73SEd Tanous nlohmann::json propertyValueOutOfRange(const nlohmann::json& arg1,
533227a2b0aSJiaqing Zhao                                        std::string_view arg2)
534227a2b0aSJiaqing Zhao {
535bd79bce8SPatrick Williams     std::string arg1Str =
536bd79bce8SPatrick Williams         arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
537227a2b0aSJiaqing Zhao     return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
53895b3ad73SEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
539227a2b0aSJiaqing Zhao }
540227a2b0aSJiaqing Zhao 
54195b3ad73SEd Tanous void propertyValueOutOfRange(crow::Response& res, const nlohmann::json& arg1,
542227a2b0aSJiaqing Zhao                              std::string_view arg2)
543227a2b0aSJiaqing Zhao {
544227a2b0aSJiaqing Zhao     res.result(boost::beast::http::status::bad_request);
545227a2b0aSJiaqing Zhao     addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2));
546227a2b0aSJiaqing Zhao }
547227a2b0aSJiaqing Zhao 
548227a2b0aSJiaqing Zhao /**
549227a2b0aSJiaqing Zhao  * @internal
550f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
551f4c4dcf4SKowalski, Kamil  *
552f4c4dcf4SKowalski, Kamil  * See header file for more information
553f4c4dcf4SKowalski, Kamil  * @endinternal
554f4c4dcf4SKowalski, Kamil  */
5554a7fbefdSEd Tanous nlohmann::json
5564a7fbefdSEd Tanous     resourceAtUriInUnknownFormat(const boost::urls::url_view_base& arg1)
5571abe55efSEd Tanous {
558b6cd31e1SEd Tanous     return getLog(
559fffb8c1fSEd Tanous         redfish::registries::base::Index::resourceAtUriInUnknownFormat,
560079360aeSEd Tanous         std::to_array<std::string_view>({arg1.buffer()}));
561b5c07418SJames Feist }
562b5c07418SJames Feist 
563ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res,
5644a7fbefdSEd Tanous                                   const boost::urls::url_view_base& arg1)
565b5c07418SJames Feist {
566b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
567b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
568f4c4dcf4SKowalski, Kamil }
569f4c4dcf4SKowalski, Kamil 
570f4c4dcf4SKowalski, Kamil /**
571f4c4dcf4SKowalski, Kamil  * @internal
57281856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
57381856681SAsmitha Karunanithi  *
57481856681SAsmitha Karunanithi  * See header file for more information
57581856681SAsmitha Karunanithi  * @endinternal
57681856681SAsmitha Karunanithi  */
5771668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1)
57881856681SAsmitha Karunanithi {
579fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceDisabled,
5801668ce6dSEd Tanous                   std::to_array({arg1}));
58181856681SAsmitha Karunanithi }
58281856681SAsmitha Karunanithi 
5831668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1)
58481856681SAsmitha Karunanithi {
58581856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
58681856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
58781856681SAsmitha Karunanithi }
58881856681SAsmitha Karunanithi 
58981856681SAsmitha Karunanithi /**
59081856681SAsmitha Karunanithi  * @internal
591f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
592f4c4dcf4SKowalski, Kamil  *
593f4c4dcf4SKowalski, Kamil  * See header file for more information
594f4c4dcf4SKowalski, Kamil  * @endinternal
595f4c4dcf4SKowalski, Kamil  */
596d9fcfcc1SEd Tanous nlohmann::json serviceInUnknownState()
5971abe55efSEd Tanous {
598fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
599b5c07418SJames Feist }
600b5c07418SJames Feist 
601b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
602b5c07418SJames Feist {
603b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
604b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
605f4c4dcf4SKowalski, Kamil }
606f4c4dcf4SKowalski, Kamil 
607f4c4dcf4SKowalski, Kamil /**
608f4c4dcf4SKowalski, Kamil  * @internal
609f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
610f4c4dcf4SKowalski, Kamil  *
611f4c4dcf4SKowalski, Kamil  * See header file for more information
612f4c4dcf4SKowalski, Kamil  * @endinternal
613f4c4dcf4SKowalski, Kamil  */
614d9fcfcc1SEd Tanous nlohmann::json eventSubscriptionLimitExceeded()
6151abe55efSEd Tanous {
616fffb8c1fSEd Tanous     return getLog(
617fffb8c1fSEd Tanous         redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
618b5c07418SJames Feist }
619b5c07418SJames Feist 
620b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
621b5c07418SJames Feist {
622789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
623b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
624f4c4dcf4SKowalski, Kamil }
625f4c4dcf4SKowalski, Kamil 
626f4c4dcf4SKowalski, Kamil /**
627f4c4dcf4SKowalski, Kamil  * @internal
628f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
629f4c4dcf4SKowalski, Kamil  *
630f4c4dcf4SKowalski, Kamil  * See header file for more information
631f4c4dcf4SKowalski, Kamil  * @endinternal
632f4c4dcf4SKowalski, Kamil  */
6331668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1,
6341668ce6dSEd Tanous                                       std::string_view arg2)
6351abe55efSEd Tanous {
636fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterMissing,
6371668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
638b5c07418SJames Feist }
639b5c07418SJames Feist 
6401668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1,
6411668ce6dSEd Tanous                             std::string_view arg2)
642b5c07418SJames Feist {
643b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
644b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
645f4c4dcf4SKowalski, Kamil }
646f4c4dcf4SKowalski, Kamil 
647f4c4dcf4SKowalski, Kamil /**
648f4c4dcf4SKowalski, Kamil  * @internal
649f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
650f4c4dcf4SKowalski, Kamil  *
651f4c4dcf4SKowalski, Kamil  * See header file for more information
652f4c4dcf4SKowalski, Kamil  * @endinternal
653f4c4dcf4SKowalski, Kamil  */
6541668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
6551abe55efSEd Tanous {
656b6cd31e1SEd Tanous     std::string arg2String = std::to_string(arg2);
657fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::stringValueTooLong,
6581668ce6dSEd Tanous                   std::to_array({arg1, std::string_view(arg2String)}));
659b5c07418SJames Feist }
660b5c07418SJames Feist 
6611668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
662b5c07418SJames Feist {
663b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
664b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
665f4c4dcf4SKowalski, Kamil }
666f4c4dcf4SKowalski, Kamil 
667f4c4dcf4SKowalski, Kamil /**
668f4c4dcf4SKowalski, Kamil  * @internal
669cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
670cc9139ecSJason M. Bills  *
671cc9139ecSJason M. Bills  * See header file for more information
672cc9139ecSJason M. Bills  * @endinternal
673cc9139ecSJason M. Bills  */
674d9fcfcc1SEd Tanous nlohmann::json sessionTerminated()
675cc9139ecSJason M. Bills {
676fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionTerminated, {});
677b5c07418SJames Feist }
678b5c07418SJames Feist 
679b5c07418SJames Feist void sessionTerminated(crow::Response& res)
680b5c07418SJames Feist {
681b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
682b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
683cc9139ecSJason M. Bills }
684cc9139ecSJason M. Bills 
685cc9139ecSJason M. Bills /**
686cc9139ecSJason M. Bills  * @internal
687684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
688684bb4b8SJason M. Bills  *
689684bb4b8SJason M. Bills  * See header file for more information
690684bb4b8SJason M. Bills  * @endinternal
691684bb4b8SJason M. Bills  */
692d9fcfcc1SEd Tanous nlohmann::json subscriptionTerminated()
693684bb4b8SJason M. Bills {
694fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
695684bb4b8SJason M. Bills }
696684bb4b8SJason M. Bills 
697684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
698684bb4b8SJason M. Bills {
699684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
700684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
701684bb4b8SJason M. Bills }
702684bb4b8SJason M. Bills 
703684bb4b8SJason M. Bills /**
704684bb4b8SJason M. Bills  * @internal
705cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
706cc9139ecSJason M. Bills  *
707cc9139ecSJason M. Bills  * See header file for more information
708cc9139ecSJason M. Bills  * @endinternal
709cc9139ecSJason M. Bills  */
7101668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1,
7111668ce6dSEd Tanous                                         std::string_view arg2)
712cc9139ecSJason M. Bills {
713fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
7141668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
715b5c07418SJames Feist }
716b5c07418SJames Feist 
7171668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
7181668ce6dSEd Tanous                               std::string_view arg2)
719b5c07418SJames Feist {
720b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
721b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
722cc9139ecSJason M. Bills }
723cc9139ecSJason M. Bills 
724cc9139ecSJason M. Bills /**
725cc9139ecSJason M. Bills  * @internal
726684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
727684bb4b8SJason M. Bills  *
728684bb4b8SJason M. Bills  * See header file for more information
729684bb4b8SJason M. Bills  * @endinternal
730684bb4b8SJason M. Bills  */
7314a7fbefdSEd Tanous nlohmann::json resetRequired(const boost::urls::url_view_base& arg1,
7324a7fbefdSEd Tanous                              std::string_view arg2)
733684bb4b8SJason M. Bills {
734fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
735079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer(), arg2}));
736684bb4b8SJason M. Bills }
737684bb4b8SJason M. Bills 
7384a7fbefdSEd Tanous void resetRequired(crow::Response& res, const boost::urls::url_view_base& arg1,
7391668ce6dSEd Tanous                    std::string_view arg2)
740684bb4b8SJason M. Bills {
741684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
742684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
743684bb4b8SJason M. Bills }
744684bb4b8SJason M. Bills 
745684bb4b8SJason M. Bills /**
746684bb4b8SJason M. Bills  * @internal
747684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
748684bb4b8SJason M. Bills  *
749684bb4b8SJason M. Bills  * See header file for more information
750684bb4b8SJason M. Bills  * @endinternal
751684bb4b8SJason M. Bills  */
7521668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
753684bb4b8SJason M. Bills {
754fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
7551668ce6dSEd Tanous                   std::to_array({arg1}));
756684bb4b8SJason M. Bills }
757684bb4b8SJason M. Bills 
7581668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
759684bb4b8SJason M. Bills {
760684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
761684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
762684bb4b8SJason M. Bills }
763684bb4b8SJason M. Bills 
764684bb4b8SJason M. Bills /**
765684bb4b8SJason M. Bills  * @internal
766684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
767684bb4b8SJason M. Bills  *
768684bb4b8SJason M. Bills  * See header file for more information
769684bb4b8SJason M. Bills  * @endinternal
770684bb4b8SJason M. Bills  */
7711668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
772684bb4b8SJason M. Bills {
773b6cd31e1SEd Tanous     return getLog(
774fffb8c1fSEd Tanous         redfish::registries::base::Index::chassisPowerStateOffRequired,
7751668ce6dSEd Tanous         std::to_array({arg1}));
776684bb4b8SJason M. Bills }
777684bb4b8SJason M. Bills 
7781668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1)
779684bb4b8SJason M. Bills {
780684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
781684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
782684bb4b8SJason M. Bills }
783684bb4b8SJason M. Bills 
784684bb4b8SJason M. Bills /**
785684bb4b8SJason M. Bills  * @internal
786684bb4b8SJason M. Bills  * @brief Formats PropertyValueConflict message into JSON
787684bb4b8SJason M. Bills  *
788684bb4b8SJason M. Bills  * See header file for more information
789684bb4b8SJason M. Bills  * @endinternal
790684bb4b8SJason M. Bills  */
7911668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1,
7921668ce6dSEd Tanous                                      std::string_view arg2)
793684bb4b8SJason M. Bills {
794fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueConflict,
7951668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
796684bb4b8SJason M. Bills }
797684bb4b8SJason M. Bills 
7981668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1,
7991668ce6dSEd Tanous                            std::string_view arg2)
800684bb4b8SJason M. Bills {
801684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
802684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
803684bb4b8SJason M. Bills }
804684bb4b8SJason M. Bills 
805684bb4b8SJason M. Bills /**
806684bb4b8SJason M. Bills  * @internal
8072a6af81cSRamesh Iyyar  * @brief Formats PropertyValueResourceConflict message into JSON
8082a6af81cSRamesh Iyyar  *
8092a6af81cSRamesh Iyyar  * See header file for more information
8102a6af81cSRamesh Iyyar  * @endinternal
8112a6af81cSRamesh Iyyar  */
812bd79bce8SPatrick Williams nlohmann::json propertyValueResourceConflict(
813bd79bce8SPatrick Williams     std::string_view arg1, const nlohmann::json& arg2,
8144a7fbefdSEd Tanous     const boost::urls::url_view_base& arg3)
8152a6af81cSRamesh Iyyar {
816bd79bce8SPatrick Williams     std::string arg2Str =
817bd79bce8SPatrick Williams         arg2.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
81895b3ad73SEd Tanous 
8192a6af81cSRamesh Iyyar     return getLog(
8202a6af81cSRamesh Iyyar         redfish::registries::base::Index::propertyValueResourceConflict,
82195b3ad73SEd Tanous         std::to_array<std::string_view>({arg1, arg2Str, arg3.buffer()}));
8222a6af81cSRamesh Iyyar }
8232a6af81cSRamesh Iyyar 
8242a6af81cSRamesh Iyyar void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
82595b3ad73SEd Tanous                                    const nlohmann::json& arg2,
8264a7fbefdSEd Tanous                                    const boost::urls::url_view_base& arg3)
8272a6af81cSRamesh Iyyar {
8282a6af81cSRamesh Iyyar     res.result(boost::beast::http::status::conflict);
8292a6af81cSRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
8302a6af81cSRamesh Iyyar                           propertyValueResourceConflict(arg1, arg2, arg3));
8312a6af81cSRamesh Iyyar }
8322a6af81cSRamesh Iyyar 
8332a6af81cSRamesh Iyyar /**
8342a6af81cSRamesh Iyyar  * @internal
83524861a28SRamesh Iyyar  * @brief Formats PropertyValueExternalConflict message into JSON
83624861a28SRamesh Iyyar  *
83724861a28SRamesh Iyyar  * See header file for more information
83824861a28SRamesh Iyyar  * @endinternal
83924861a28SRamesh Iyyar  */
84024861a28SRamesh Iyyar nlohmann::json propertyValueExternalConflict(std::string_view arg1,
84195b3ad73SEd Tanous                                              const nlohmann::json& arg2)
84224861a28SRamesh Iyyar {
843bd79bce8SPatrick Williams     std::string arg2Str =
844bd79bce8SPatrick Williams         arg2.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
84595b3ad73SEd Tanous 
84624861a28SRamesh Iyyar     return getLog(
84724861a28SRamesh Iyyar         redfish::registries::base::Index::propertyValueExternalConflict,
84895b3ad73SEd Tanous         std::to_array<std::string_view>({arg1, arg2Str}));
84924861a28SRamesh Iyyar }
85024861a28SRamesh Iyyar 
85124861a28SRamesh Iyyar void propertyValueExternalConflict(crow::Response& res, std::string_view arg1,
85295b3ad73SEd Tanous                                    const nlohmann::json& arg2)
85324861a28SRamesh Iyyar {
85424861a28SRamesh Iyyar     res.result(boost::beast::http::status::conflict);
85524861a28SRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
85624861a28SRamesh Iyyar                           propertyValueExternalConflict(arg1, arg2));
85724861a28SRamesh Iyyar }
85824861a28SRamesh Iyyar 
85924861a28SRamesh Iyyar /**
86024861a28SRamesh Iyyar  * @internal
861684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
862684bb4b8SJason M. Bills  *
863684bb4b8SJason M. Bills  * See header file for more information
864684bb4b8SJason M. Bills  * @endinternal
865684bb4b8SJason M. Bills  */
866367b3dceSGinu George nlohmann::json propertyValueIncorrect(std::string_view arg1,
867367b3dceSGinu George                                       const nlohmann::json& arg2)
868684bb4b8SJason M. Bills {
869bd79bce8SPatrick Williams     std::string arg2Str =
870bd79bce8SPatrick Williams         arg2.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
871fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueIncorrect,
872367b3dceSGinu George                   std::to_array<std::string_view>({arg1, arg2Str}));
873684bb4b8SJason M. Bills }
874684bb4b8SJason M. Bills 
875367b3dceSGinu George void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
876367b3dceSGinu George                             const nlohmann::json& arg2)
877684bb4b8SJason M. Bills {
878684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
879684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
880684bb4b8SJason M. Bills }
881684bb4b8SJason M. Bills 
882684bb4b8SJason M. Bills /**
883684bb4b8SJason M. Bills  * @internal
884684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
885684bb4b8SJason M. Bills  *
886684bb4b8SJason M. Bills  * See header file for more information
887684bb4b8SJason M. Bills  * @endinternal
888684bb4b8SJason M. Bills  */
8894a7fbefdSEd Tanous nlohmann::json resourceCreationConflict(const boost::urls::url_view_base& arg1)
890684bb4b8SJason M. Bills {
891fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCreationConflict,
892079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
893684bb4b8SJason M. Bills }
894684bb4b8SJason M. Bills 
8954a7fbefdSEd Tanous void resourceCreationConflict(crow::Response& res,
8964a7fbefdSEd Tanous                               const boost::urls::url_view_base& arg1)
897684bb4b8SJason M. Bills {
898684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
899684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
900684bb4b8SJason M. Bills }
901684bb4b8SJason M. Bills 
902684bb4b8SJason M. Bills /**
903684bb4b8SJason M. Bills  * @internal
904684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded message into JSON
905684bb4b8SJason M. Bills  *
906684bb4b8SJason M. Bills  * See header file for more information
907684bb4b8SJason M. Bills  * @endinternal
908684bb4b8SJason M. Bills  */
909d9fcfcc1SEd Tanous nlohmann::json maximumErrorsExceeded()
910684bb4b8SJason M. Bills {
911fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
912684bb4b8SJason M. Bills }
913684bb4b8SJason M. Bills 
914684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
915684bb4b8SJason M. Bills {
916684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
917684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
918684bb4b8SJason M. Bills }
919684bb4b8SJason M. Bills 
920684bb4b8SJason M. Bills /**
921684bb4b8SJason M. Bills  * @internal
922684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
923684bb4b8SJason M. Bills  *
924684bb4b8SJason M. Bills  * See header file for more information
925684bb4b8SJason M. Bills  * @endinternal
926684bb4b8SJason M. Bills  */
927d9fcfcc1SEd Tanous nlohmann::json preconditionFailed()
928684bb4b8SJason M. Bills {
929fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionFailed, {});
930684bb4b8SJason M. Bills }
931684bb4b8SJason M. Bills 
932684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
933684bb4b8SJason M. Bills {
9344df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
935684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
936684bb4b8SJason M. Bills }
937684bb4b8SJason M. Bills 
938684bb4b8SJason M. Bills /**
939684bb4b8SJason M. Bills  * @internal
940684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
941684bb4b8SJason M. Bills  *
942684bb4b8SJason M. Bills  * See header file for more information
943684bb4b8SJason M. Bills  * @endinternal
944684bb4b8SJason M. Bills  */
945d9fcfcc1SEd Tanous nlohmann::json preconditionRequired()
946684bb4b8SJason M. Bills {
947fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionRequired, {});
948684bb4b8SJason M. Bills }
949684bb4b8SJason M. Bills 
950684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
951684bb4b8SJason M. Bills {
952684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
953684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
954684bb4b8SJason M. Bills }
955684bb4b8SJason M. Bills 
956684bb4b8SJason M. Bills /**
957684bb4b8SJason M. Bills  * @internal
958684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
959684bb4b8SJason M. Bills  *
960684bb4b8SJason M. Bills  * See header file for more information
961684bb4b8SJason M. Bills  * @endinternal
962684bb4b8SJason M. Bills  */
963d9fcfcc1SEd Tanous nlohmann::json operationFailed()
964684bb4b8SJason M. Bills {
965fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationFailed, {});
966684bb4b8SJason M. Bills }
967684bb4b8SJason M. Bills 
968684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
969684bb4b8SJason M. Bills {
9708868776eSEd Tanous     res.result(boost::beast::http::status::bad_gateway);
971684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
972684bb4b8SJason M. Bills }
973684bb4b8SJason M. Bills 
974684bb4b8SJason M. Bills /**
975684bb4b8SJason M. Bills  * @internal
976684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
977684bb4b8SJason M. Bills  *
978684bb4b8SJason M. Bills  * See header file for more information
979684bb4b8SJason M. Bills  * @endinternal
980684bb4b8SJason M. Bills  */
981d9fcfcc1SEd Tanous nlohmann::json operationTimeout()
982684bb4b8SJason M. Bills {
983fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationTimeout, {});
984684bb4b8SJason M. Bills }
985684bb4b8SJason M. Bills 
986684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
987684bb4b8SJason M. Bills {
988684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
989684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
990684bb4b8SJason M. Bills }
991684bb4b8SJason M. Bills 
992684bb4b8SJason M. Bills /**
993684bb4b8SJason M. Bills  * @internal
994f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
995f12894f8SJason M. Bills  * property
996f12894f8SJason M. Bills  *
997f12894f8SJason M. Bills  * See header file for more information
998f12894f8SJason M. Bills  * @endinternal
999f12894f8SJason M. Bills  */
10002e8c4bdaSEd Tanous nlohmann::json propertyValueTypeError(const nlohmann::json& arg1,
10011668ce6dSEd Tanous                                       std::string_view arg2)
1002f12894f8SJason M. Bills {
1003bd79bce8SPatrick Williams     std::string arg1Str =
1004bd79bce8SPatrick Williams         arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
1005fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueTypeError,
10062e8c4bdaSEd Tanous                   std::to_array<std::string_view>({arg1Str, arg2}));
1007b5c07418SJames Feist }
1008b5c07418SJames Feist 
10092e8c4bdaSEd Tanous void propertyValueTypeError(crow::Response& res, const nlohmann::json& arg1,
10101668ce6dSEd Tanous                             std::string_view arg2)
1011b5c07418SJames Feist {
1012b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1013b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
1014f4c4dcf4SKowalski, Kamil }
1015f4c4dcf4SKowalski, Kamil 
1016f4c4dcf4SKowalski, Kamil /**
1017f4c4dcf4SKowalski, Kamil  * @internal
1018*b54eb49fSEd Tanous  * @brief Formats PropertyValueError message into JSON for the specified
1019*b54eb49fSEd Tanous  * property
1020*b54eb49fSEd Tanous  *
1021*b54eb49fSEd Tanous  * See header file for more information
1022*b54eb49fSEd Tanous  * @endinternal
1023*b54eb49fSEd Tanous  */
1024*b54eb49fSEd Tanous nlohmann::json propertyValueError(std::string_view arg1)
1025*b54eb49fSEd Tanous {
1026*b54eb49fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueError,
1027*b54eb49fSEd Tanous                   std::to_array<std::string_view>({arg1}));
1028*b54eb49fSEd Tanous }
1029*b54eb49fSEd Tanous 
1030*b54eb49fSEd Tanous void propertyValueError(crow::Response& res, std::string_view arg1)
1031*b54eb49fSEd Tanous {
1032*b54eb49fSEd Tanous     res.result(boost::beast::http::status::bad_request);
1033*b54eb49fSEd Tanous     addMessageToJson(res.jsonValue, propertyValueError(arg1), arg1);
1034*b54eb49fSEd Tanous }
1035*b54eb49fSEd Tanous 
1036*b54eb49fSEd Tanous /**
1037*b54eb49fSEd Tanous  * @internal
1038b6cd31e1SEd Tanous  * @brief Formats ResourceNotFound message into JSONd
1039f4c4dcf4SKowalski, Kamil  *
1040f4c4dcf4SKowalski, Kamil  * See header file for more information
1041f4c4dcf4SKowalski, Kamil  * @endinternal
1042f4c4dcf4SKowalski, Kamil  */
10431668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
10441abe55efSEd Tanous {
1045fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceNotFound,
10461668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1047b5c07418SJames Feist }
1048b5c07418SJames Feist 
10491668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1,
10501668ce6dSEd Tanous                       std::string_view arg2)
1051b5c07418SJames Feist {
1052b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1053b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
1054f4c4dcf4SKowalski, Kamil }
1055f4c4dcf4SKowalski, Kamil 
1056f4c4dcf4SKowalski, Kamil /**
1057f4c4dcf4SKowalski, Kamil  * @internal
1058f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
1059f4c4dcf4SKowalski, Kamil  *
1060f4c4dcf4SKowalski, Kamil  * See header file for more information
1061f4c4dcf4SKowalski, Kamil  * @endinternal
1062f4c4dcf4SKowalski, Kamil  */
10634a7fbefdSEd Tanous nlohmann::json
10644a7fbefdSEd Tanous     couldNotEstablishConnection(const boost::urls::url_view_base& arg1)
10651abe55efSEd Tanous {
1066fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
1067079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1068b5c07418SJames Feist }
1069b5c07418SJames Feist 
1070ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res,
10714a7fbefdSEd Tanous                                  const boost::urls::url_view_base& arg1)
1072b5c07418SJames Feist {
1073b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1074b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
1075f4c4dcf4SKowalski, Kamil }
1076f4c4dcf4SKowalski, Kamil 
1077f4c4dcf4SKowalski, Kamil /**
1078f4c4dcf4SKowalski, Kamil  * @internal
1079f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
1080f12894f8SJason M. Bills  * property
1081f12894f8SJason M. Bills  *
1082f12894f8SJason M. Bills  * See header file for more information
1083f12894f8SJason M. Bills  * @endinternal
1084f12894f8SJason M. Bills  */
10851668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1)
1086f12894f8SJason M. Bills {
1087fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyNotWritable,
10881668ce6dSEd Tanous                   std::to_array({arg1}));
1089b5c07418SJames Feist }
1090b5c07418SJames Feist 
10911668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1)
1092b5c07418SJames Feist {
1093b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1094b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1095f4c4dcf4SKowalski, Kamil }
1096f4c4dcf4SKowalski, Kamil 
1097f4c4dcf4SKowalski, Kamil /**
1098f4c4dcf4SKowalski, Kamil  * @internal
1099f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
1100f4c4dcf4SKowalski, Kamil  *
1101f4c4dcf4SKowalski, Kamil  * See header file for more information
1102f4c4dcf4SKowalski, Kamil  * @endinternal
1103f4c4dcf4SKowalski, Kamil  */
110495b3ad73SEd Tanous nlohmann::json queryParameterValueTypeError(const nlohmann::json& arg1,
11051668ce6dSEd Tanous                                             std::string_view arg2)
11061abe55efSEd Tanous {
1107bd79bce8SPatrick Williams     std::string arg1Str =
1108bd79bce8SPatrick Williams         arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
1109b6cd31e1SEd Tanous     return getLog(
1110fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueTypeError,
111195b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2}));
1112b5c07418SJames Feist }
1113b5c07418SJames Feist 
1114bd79bce8SPatrick Williams void queryParameterValueTypeError(
1115bd79bce8SPatrick Williams     crow::Response& res, const nlohmann::json& arg1, std::string_view arg2)
1116b5c07418SJames Feist {
1117b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1118b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1119b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
1120f4c4dcf4SKowalski, Kamil }
1121f4c4dcf4SKowalski, Kamil 
1122f4c4dcf4SKowalski, Kamil /**
1123f4c4dcf4SKowalski, Kamil  * @internal
1124f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
1125f4c4dcf4SKowalski, Kamil  *
1126f4c4dcf4SKowalski, Kamil  * See header file for more information
1127f4c4dcf4SKowalski, Kamil  * @endinternal
1128f4c4dcf4SKowalski, Kamil  */
1129d9fcfcc1SEd Tanous nlohmann::json serviceShuttingDown()
11301abe55efSEd Tanous {
1131fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
1132b5c07418SJames Feist }
1133b5c07418SJames Feist 
1134b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
1135b5c07418SJames Feist {
1136b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1137b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1138f4c4dcf4SKowalski, Kamil }
1139f4c4dcf4SKowalski, Kamil 
1140f4c4dcf4SKowalski, Kamil /**
1141f4c4dcf4SKowalski, Kamil  * @internal
1142f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
1143f4c4dcf4SKowalski, Kamil  *
1144f4c4dcf4SKowalski, Kamil  * See header file for more information
1145f4c4dcf4SKowalski, Kamil  * @endinternal
1146f4c4dcf4SKowalski, Kamil  */
11471668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1,
11481668ce6dSEd Tanous                                         std::string_view arg2)
11491abe55efSEd Tanous {
1150fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
11511668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1152b5c07418SJames Feist }
1153b5c07418SJames Feist 
11541668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
11551668ce6dSEd Tanous                               std::string_view arg2)
1156b5c07418SJames Feist {
1157b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1158b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1159f4c4dcf4SKowalski, Kamil }
1160f4c4dcf4SKowalski, Kamil 
1161f4c4dcf4SKowalski, Kamil /**
1162f4c4dcf4SKowalski, Kamil  * @internal
1163f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1164f4c4dcf4SKowalski, Kamil  *
1165f4c4dcf4SKowalski, Kamil  * See header file for more information
1166f4c4dcf4SKowalski, Kamil  * @endinternal
1167f4c4dcf4SKowalski, Kamil  */
11681668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1,
11691668ce6dSEd Tanous                                            std::string_view arg2)
11701abe55efSEd Tanous {
1171fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
11721668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1173b5c07418SJames Feist }
1174b5c07418SJames Feist 
11751668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
11761668ce6dSEd Tanous                                  std::string_view arg2)
1177b5c07418SJames Feist {
1178b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1179b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1180b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1181f4c4dcf4SKowalski, Kamil }
1182f4c4dcf4SKowalski, Kamil 
1183f4c4dcf4SKowalski, Kamil /**
1184f4c4dcf4SKowalski, Kamil  * @internal
1185f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1186f4c4dcf4SKowalski, Kamil  *
1187f4c4dcf4SKowalski, Kamil  * See header file for more information
1188f4c4dcf4SKowalski, Kamil  * @endinternal
1189f4c4dcf4SKowalski, Kamil  */
1190bd79bce8SPatrick Williams nlohmann::json sourceDoesNotSupportProtocol(
1191bd79bce8SPatrick Williams     const boost::urls::url_view_base& arg1, std::string_view arg2)
11921abe55efSEd Tanous {
1193b6cd31e1SEd Tanous     return getLog(
1194fffb8c1fSEd Tanous         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
1195079360aeSEd Tanous         std::to_array<std::string_view>({arg1.buffer(), arg2}));
1196b5c07418SJames Feist }
1197b5c07418SJames Feist 
1198ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res,
11994a7fbefdSEd Tanous                                   const boost::urls::url_view_base& arg1,
12001668ce6dSEd Tanous                                   std::string_view arg2)
1201b5c07418SJames Feist {
1202b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1203b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1204b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1205f4c4dcf4SKowalski, Kamil }
1206f4c4dcf4SKowalski, Kamil 
1207f4c4dcf4SKowalski, Kamil /**
1208f4c4dcf4SKowalski, Kamil  * @internal
1209b4ad4c05SShantappa Teekappanavar  * @brief Formats StrictAccountTypes message into JSON
1210b4ad4c05SShantappa Teekappanavar  *
1211b4ad4c05SShantappa Teekappanavar  * See header file for more information
1212b4ad4c05SShantappa Teekappanavar  * @endinternal
1213b4ad4c05SShantappa Teekappanavar  */
1214b4ad4c05SShantappa Teekappanavar nlohmann::json strictAccountTypes(std::string_view arg1)
1215b4ad4c05SShantappa Teekappanavar {
1216b4ad4c05SShantappa Teekappanavar     return getLog(redfish::registries::base::Index::strictAccountTypes,
1217b4ad4c05SShantappa Teekappanavar                   std::to_array({arg1}));
1218b4ad4c05SShantappa Teekappanavar }
1219b4ad4c05SShantappa Teekappanavar 
1220b4ad4c05SShantappa Teekappanavar void strictAccountTypes(crow::Response& res, std::string_view arg1)
1221b4ad4c05SShantappa Teekappanavar {
1222b4ad4c05SShantappa Teekappanavar     res.result(boost::beast::http::status::bad_request);
1223b4ad4c05SShantappa Teekappanavar     addMessageToErrorJson(res.jsonValue, strictAccountTypes(arg1));
1224b4ad4c05SShantappa Teekappanavar }
1225b4ad4c05SShantappa Teekappanavar 
1226b4ad4c05SShantappa Teekappanavar /**
1227b4ad4c05SShantappa Teekappanavar  * @internal
1228f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1229f4c4dcf4SKowalski, Kamil  *
1230f4c4dcf4SKowalski, Kamil  * See header file for more information
1231f4c4dcf4SKowalski, Kamil  * @endinternal
1232f4c4dcf4SKowalski, Kamil  */
1233d9fcfcc1SEd Tanous nlohmann::json accountRemoved()
12341abe55efSEd Tanous {
1235fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountRemoved, {});
1236b5c07418SJames Feist }
1237b5c07418SJames Feist 
1238b5c07418SJames Feist void accountRemoved(crow::Response& res)
1239b5c07418SJames Feist {
1240b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1241b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1242f4c4dcf4SKowalski, Kamil }
1243f4c4dcf4SKowalski, Kamil 
1244f4c4dcf4SKowalski, Kamil /**
1245f4c4dcf4SKowalski, Kamil  * @internal
1246f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1247f4c4dcf4SKowalski, Kamil  *
1248f4c4dcf4SKowalski, Kamil  * See header file for more information
1249f4c4dcf4SKowalski, Kamil  * @endinternal
1250f4c4dcf4SKowalski, Kamil  */
12514a7fbefdSEd Tanous nlohmann::json accessDenied(const boost::urls::url_view_base& arg1)
12521abe55efSEd Tanous {
1253fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accessDenied,
1254079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1255b5c07418SJames Feist }
1256b5c07418SJames Feist 
12574a7fbefdSEd Tanous void accessDenied(crow::Response& res, const boost::urls::url_view_base& arg1)
1258b5c07418SJames Feist {
1259b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1260b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1261f4c4dcf4SKowalski, Kamil }
1262f4c4dcf4SKowalski, Kamil 
1263f4c4dcf4SKowalski, Kamil /**
1264f4c4dcf4SKowalski, Kamil  * @internal
1265f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1266f4c4dcf4SKowalski, Kamil  *
1267f4c4dcf4SKowalski, Kamil  * See header file for more information
1268f4c4dcf4SKowalski, Kamil  * @endinternal
1269f4c4dcf4SKowalski, Kamil  */
1270d9fcfcc1SEd Tanous nlohmann::json queryNotSupported()
12711abe55efSEd Tanous {
1272fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1273b5c07418SJames Feist }
1274b5c07418SJames Feist 
1275b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1276b5c07418SJames Feist {
1277b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1278b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1279f4c4dcf4SKowalski, Kamil }
1280f4c4dcf4SKowalski, Kamil 
1281f4c4dcf4SKowalski, Kamil /**
1282f4c4dcf4SKowalski, Kamil  * @internal
1283f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1284f4c4dcf4SKowalski, Kamil  *
1285f4c4dcf4SKowalski, Kamil  * See header file for more information
1286f4c4dcf4SKowalski, Kamil  * @endinternal
1287f4c4dcf4SKowalski, Kamil  */
1288d9fcfcc1SEd Tanous nlohmann::json createLimitReachedForResource()
12891abe55efSEd Tanous {
1290b6cd31e1SEd Tanous     return getLog(
1291fffb8c1fSEd Tanous         redfish::registries::base::Index::createLimitReachedForResource, {});
1292b5c07418SJames Feist }
1293b5c07418SJames Feist 
1294b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1295b5c07418SJames Feist {
1296b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1297b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1298f4c4dcf4SKowalski, Kamil }
1299f4c4dcf4SKowalski, Kamil 
1300f4c4dcf4SKowalski, Kamil /**
1301f4c4dcf4SKowalski, Kamil  * @internal
1302f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1303f4c4dcf4SKowalski, Kamil  *
1304f4c4dcf4SKowalski, Kamil  * See header file for more information
1305f4c4dcf4SKowalski, Kamil  * @endinternal
1306f4c4dcf4SKowalski, Kamil  */
1307d9fcfcc1SEd Tanous nlohmann::json generalError()
13081abe55efSEd Tanous {
1309fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::generalError, {});
1310b5c07418SJames Feist }
1311b5c07418SJames Feist 
1312b5c07418SJames Feist void generalError(crow::Response& res)
1313b5c07418SJames Feist {
1314b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1315b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1316f4c4dcf4SKowalski, Kamil }
1317f4c4dcf4SKowalski, Kamil 
1318f4c4dcf4SKowalski, Kamil /**
1319f4c4dcf4SKowalski, Kamil  * @internal
1320f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1321f4c4dcf4SKowalski, Kamil  *
1322f4c4dcf4SKowalski, Kamil  * See header file for more information
1323f4c4dcf4SKowalski, Kamil  * @endinternal
1324f4c4dcf4SKowalski, Kamil  */
1325d9fcfcc1SEd Tanous nlohmann::json success()
13261abe55efSEd Tanous {
1327fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::success, {});
1328b5c07418SJames Feist }
1329b5c07418SJames Feist 
1330b5c07418SJames Feist void success(crow::Response& res)
1331b5c07418SJames Feist {
1332b5c07418SJames Feist     // don't set res.result here because success is the default and any
1333b5c07418SJames Feist     // error should overwrite the default
1334b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1335f12894f8SJason M. Bills }
1336f12894f8SJason M. Bills 
1337f12894f8SJason M. Bills /**
1338f12894f8SJason M. Bills  * @internal
1339f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1340f4c4dcf4SKowalski, Kamil  *
1341f4c4dcf4SKowalski, Kamil  * See header file for more information
1342f4c4dcf4SKowalski, Kamil  * @endinternal
1343f4c4dcf4SKowalski, Kamil  */
1344d9fcfcc1SEd Tanous nlohmann::json created()
13451abe55efSEd Tanous {
1346fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::created, {});
1347b5c07418SJames Feist }
1348b5c07418SJames Feist 
1349b5c07418SJames Feist void created(crow::Response& res)
1350b5c07418SJames Feist {
1351b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1352b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1353f4c4dcf4SKowalski, Kamil }
1354f4c4dcf4SKowalski, Kamil 
1355f4c4dcf4SKowalski, Kamil /**
1356f4c4dcf4SKowalski, Kamil  * @internal
1357cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1358cc9139ecSJason M. Bills  *
1359cc9139ecSJason M. Bills  * See header file for more information
1360cc9139ecSJason M. Bills  * @endinternal
1361cc9139ecSJason M. Bills  */
1362d9fcfcc1SEd Tanous nlohmann::json noOperation()
1363cc9139ecSJason M. Bills {
1364fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noOperation, {});
1365b5c07418SJames Feist }
1366b5c07418SJames Feist 
1367b5c07418SJames Feist void noOperation(crow::Response& res)
1368b5c07418SJames Feist {
1369b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1370b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1371cc9139ecSJason M. Bills }
1372cc9139ecSJason M. Bills 
1373cc9139ecSJason M. Bills /**
1374cc9139ecSJason M. Bills  * @internal
1375b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1376b5c07418SJames Feist  * property
1377f12894f8SJason M. Bills  *
1378f12894f8SJason M. Bills  * See header file for more information
1379f12894f8SJason M. Bills  * @endinternal
1380f12894f8SJason M. Bills  */
13811668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1)
1382b5c07418SJames Feist {
1383fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyUnknown,
13841668ce6dSEd Tanous                   std::to_array({arg1}));
1385b5c07418SJames Feist }
1386b5c07418SJames Feist 
13871668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1)
1388f12894f8SJason M. Bills {
1389f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
13907b1dd2f9SEd Tanous     addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1));
1391f4c4dcf4SKowalski, Kamil }
1392f4c4dcf4SKowalski, Kamil 
1393f4c4dcf4SKowalski, Kamil /**
1394f4c4dcf4SKowalski, Kamil  * @internal
1395f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1396f4c4dcf4SKowalski, Kamil  *
1397f4c4dcf4SKowalski, Kamil  * See header file for more information
1398f4c4dcf4SKowalski, Kamil  * @endinternal
1399f4c4dcf4SKowalski, Kamil  */
1400d9fcfcc1SEd Tanous nlohmann::json noValidSession()
14011abe55efSEd Tanous {
1402fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noValidSession, {});
1403b5c07418SJames Feist }
1404b5c07418SJames Feist 
1405b5c07418SJames Feist void noValidSession(crow::Response& res)
1406b5c07418SJames Feist {
1407b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1408b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1409f4c4dcf4SKowalski, Kamil }
1410f4c4dcf4SKowalski, Kamil 
1411f4c4dcf4SKowalski, Kamil /**
1412f4c4dcf4SKowalski, Kamil  * @internal
1413f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1414f4c4dcf4SKowalski, Kamil  *
1415f4c4dcf4SKowalski, Kamil  * See header file for more information
1416f4c4dcf4SKowalski, Kamil  * @endinternal
1417f4c4dcf4SKowalski, Kamil  */
14184a7fbefdSEd Tanous nlohmann::json invalidObject(const boost::urls::url_view_base& arg1)
14191abe55efSEd Tanous {
1420fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidObject,
1421079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1422b5c07418SJames Feist }
1423b5c07418SJames Feist 
14244a7fbefdSEd Tanous void invalidObject(crow::Response& res, const boost::urls::url_view_base& arg1)
1425b5c07418SJames Feist {
1426b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1427b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1428f4c4dcf4SKowalski, Kamil }
1429f4c4dcf4SKowalski, Kamil 
1430f4c4dcf4SKowalski, Kamil /**
1431f4c4dcf4SKowalski, Kamil  * @internal
1432f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1433f4c4dcf4SKowalski, Kamil  *
1434f4c4dcf4SKowalski, Kamil  * See header file for more information
1435f4c4dcf4SKowalski, Kamil  * @endinternal
1436f4c4dcf4SKowalski, Kamil  */
1437d9fcfcc1SEd Tanous nlohmann::json resourceInStandby()
14381abe55efSEd Tanous {
1439fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1440b5c07418SJames Feist }
1441b5c07418SJames Feist 
1442b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1443b5c07418SJames Feist {
1444b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1445b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1446f4c4dcf4SKowalski, Kamil }
1447f4c4dcf4SKowalski, Kamil 
1448f4c4dcf4SKowalski, Kamil /**
1449f4c4dcf4SKowalski, Kamil  * @internal
1450f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1451f4c4dcf4SKowalski, Kamil  *
1452f4c4dcf4SKowalski, Kamil  * See header file for more information
1453f4c4dcf4SKowalski, Kamil  * @endinternal
1454f4c4dcf4SKowalski, Kamil  */
1455bd79bce8SPatrick Williams nlohmann::json actionParameterValueTypeError(
1456bd79bce8SPatrick Williams     const nlohmann::json& arg1, std::string_view arg2, std::string_view arg3)
14571abe55efSEd Tanous {
1458bd79bce8SPatrick Williams     std::string arg1Str =
1459bd79bce8SPatrick Williams         arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
1460b6cd31e1SEd Tanous     return getLog(
1461fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueTypeError,
146295b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2, arg3}));
1463b5c07418SJames Feist }
1464b5c07418SJames Feist 
146595b3ad73SEd Tanous void actionParameterValueTypeError(crow::Response& res,
146695b3ad73SEd Tanous                                    const nlohmann::json& arg1,
14671668ce6dSEd Tanous                                    std::string_view arg2, std::string_view arg3)
1468b5c07418SJames Feist {
1469b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1470b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1471b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1472f4c4dcf4SKowalski, Kamil }
1473f4c4dcf4SKowalski, Kamil 
1474f4c4dcf4SKowalski, Kamil /**
1475f4c4dcf4SKowalski, Kamil  * @internal
14761827b4f1SAsmitha Karunanithi  * @brief Formats actionParameterValueError message into JSON
14771827b4f1SAsmitha Karunanithi  *
14781827b4f1SAsmitha Karunanithi  * See header file for more information
14791827b4f1SAsmitha Karunanithi  * @endinternal
14801827b4f1SAsmitha Karunanithi  */
14811827b4f1SAsmitha Karunanithi nlohmann::json actionParameterValueError(const nlohmann::json& arg1,
14821827b4f1SAsmitha Karunanithi                                          std::string_view arg2)
14831827b4f1SAsmitha Karunanithi {
1484bd79bce8SPatrick Williams     std::string arg1Str =
1485bd79bce8SPatrick Williams         arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
14861827b4f1SAsmitha Karunanithi     return getLog(redfish::registries::base::Index::actionParameterValueError,
14871827b4f1SAsmitha Karunanithi                   std::to_array<std::string_view>({arg1Str, arg2}));
14881827b4f1SAsmitha Karunanithi }
14891827b4f1SAsmitha Karunanithi 
14901827b4f1SAsmitha Karunanithi void actionParameterValueError(crow::Response& res, const nlohmann::json& arg1,
14911827b4f1SAsmitha Karunanithi                                std::string_view arg2)
14921827b4f1SAsmitha Karunanithi {
14931827b4f1SAsmitha Karunanithi     res.result(boost::beast::http::status::bad_request);
14941827b4f1SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, actionParameterValueError(arg1, arg2));
14951827b4f1SAsmitha Karunanithi }
14961827b4f1SAsmitha Karunanithi 
14971827b4f1SAsmitha Karunanithi /**
14981827b4f1SAsmitha Karunanithi  * @internal
1499f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1500f4c4dcf4SKowalski, Kamil  *
1501f4c4dcf4SKowalski, Kamil  * See header file for more information
1502f4c4dcf4SKowalski, Kamil  * @endinternal
1503f4c4dcf4SKowalski, Kamil  */
1504d9fcfcc1SEd Tanous nlohmann::json sessionLimitExceeded()
15051abe55efSEd Tanous {
1506fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1507b5c07418SJames Feist }
1508b5c07418SJames Feist 
1509b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1510b5c07418SJames Feist {
1511b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1512b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1513f4c4dcf4SKowalski, Kamil }
1514f4c4dcf4SKowalski, Kamil 
1515f4c4dcf4SKowalski, Kamil /**
1516f4c4dcf4SKowalski, Kamil  * @internal
1517f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1518f4c4dcf4SKowalski, Kamil  *
1519f4c4dcf4SKowalski, Kamil  * See header file for more information
1520f4c4dcf4SKowalski, Kamil  * @endinternal
1521f4c4dcf4SKowalski, Kamil  */
15221668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1)
15231abe55efSEd Tanous {
1524fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionNotSupported,
15251668ce6dSEd Tanous                   std::to_array({arg1}));
1526b5c07418SJames Feist }
1527b5c07418SJames Feist 
15281668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1)
1529b5c07418SJames Feist {
1530b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1531b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1532f4c4dcf4SKowalski, Kamil }
1533f4c4dcf4SKowalski, Kamil 
1534f4c4dcf4SKowalski, Kamil /**
1535f4c4dcf4SKowalski, Kamil  * @internal
1536f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1537f4c4dcf4SKowalski, Kamil  *
1538f4c4dcf4SKowalski, Kamil  * See header file for more information
1539f4c4dcf4SKowalski, Kamil  * @endinternal
1540f4c4dcf4SKowalski, Kamil  */
15415187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
15421abe55efSEd Tanous {
1543b6cd31e1SEd Tanous     std::string arg1Str = std::to_string(arg1);
1544fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidIndex,
15451668ce6dSEd Tanous                   std::to_array<std::string_view>({arg1Str}));
1546b5c07418SJames Feist }
1547b5c07418SJames Feist 
15485187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1549b5c07418SJames Feist {
1550b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1551b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1552f4c4dcf4SKowalski, Kamil }
1553f4c4dcf4SKowalski, Kamil 
1554f4c4dcf4SKowalski, Kamil /**
1555f4c4dcf4SKowalski, Kamil  * @internal
1556f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1557f4c4dcf4SKowalski, Kamil  *
1558f4c4dcf4SKowalski, Kamil  * See header file for more information
1559f4c4dcf4SKowalski, Kamil  * @endinternal
1560f4c4dcf4SKowalski, Kamil  */
1561d9fcfcc1SEd Tanous nlohmann::json emptyJSON()
15621abe55efSEd Tanous {
1563fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::emptyJSON, {});
1564b5c07418SJames Feist }
1565b5c07418SJames Feist 
1566b5c07418SJames Feist void emptyJSON(crow::Response& res)
1567b5c07418SJames Feist {
1568b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1569b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1570f4c4dcf4SKowalski, Kamil }
1571f4c4dcf4SKowalski, Kamil 
1572f4c4dcf4SKowalski, Kamil /**
1573f4c4dcf4SKowalski, Kamil  * @internal
1574f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1575f4c4dcf4SKowalski, Kamil  *
1576f4c4dcf4SKowalski, Kamil  * See header file for more information
1577f4c4dcf4SKowalski, Kamil  * @endinternal
1578f4c4dcf4SKowalski, Kamil  */
1579d9fcfcc1SEd Tanous nlohmann::json queryNotSupportedOnResource()
15801abe55efSEd Tanous {
1581fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1582b6cd31e1SEd Tanous                   {});
1583b5c07418SJames Feist }
1584b5c07418SJames Feist 
1585b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1586b5c07418SJames Feist {
15876a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1588b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1589f4c4dcf4SKowalski, Kamil }
1590f4c4dcf4SKowalski, Kamil 
1591f4c4dcf4SKowalski, Kamil /**
1592f4c4dcf4SKowalski, Kamil  * @internal
1593684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1594684bb4b8SJason M. Bills  *
1595684bb4b8SJason M. Bills  * See header file for more information
1596684bb4b8SJason M. Bills  * @endinternal
1597684bb4b8SJason M. Bills  */
1598d9fcfcc1SEd Tanous nlohmann::json queryNotSupportedOnOperation()
1599684bb4b8SJason M. Bills {
1600b6cd31e1SEd Tanous     return getLog(
1601fffb8c1fSEd Tanous         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1602684bb4b8SJason M. Bills }
1603684bb4b8SJason M. Bills 
1604684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1605684bb4b8SJason M. Bills {
16066a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1607684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1608684bb4b8SJason M. Bills }
1609684bb4b8SJason M. Bills 
1610684bb4b8SJason M. Bills /**
1611684bb4b8SJason M. Bills  * @internal
1612684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1613684bb4b8SJason M. Bills  *
1614684bb4b8SJason M. Bills  * See header file for more information
1615684bb4b8SJason M. Bills  * @endinternal
1616684bb4b8SJason M. Bills  */
1617d9fcfcc1SEd Tanous nlohmann::json queryCombinationInvalid()
1618684bb4b8SJason M. Bills {
1619fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1620fffb8c1fSEd Tanous                   {});
1621684bb4b8SJason M. Bills }
1622684bb4b8SJason M. Bills 
1623684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1624684bb4b8SJason M. Bills {
1625684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1626684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1627684bb4b8SJason M. Bills }
1628684bb4b8SJason M. Bills 
1629684bb4b8SJason M. Bills /**
1630684bb4b8SJason M. Bills  * @internal
1631fa345c78SEd Tanous  * @brief Formats EventBufferExceeded message into JSON
1632fa345c78SEd Tanous  *
1633fa345c78SEd Tanous  * See header file for more information
1634fa345c78SEd Tanous  * @endinternal
1635fa345c78SEd Tanous  */
1636fa345c78SEd Tanous nlohmann::json eventBufferExceeded()
1637fa345c78SEd Tanous {
1638fa345c78SEd Tanous     return getLog(redfish::registries::base::Index::eventBufferExceeded, {});
1639fa345c78SEd Tanous }
1640fa345c78SEd Tanous 
1641fa345c78SEd Tanous void eventBufferExceeded(crow::Response& res)
1642fa345c78SEd Tanous {
1643fa345c78SEd Tanous     res.result(boost::beast::http::status::bad_request);
1644fa345c78SEd Tanous     addMessageToErrorJson(res.jsonValue, eventBufferExceeded());
1645fa345c78SEd Tanous }
1646fa345c78SEd Tanous 
1647fa345c78SEd Tanous /**
1648fa345c78SEd Tanous  * @internal
1649f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1650f4c4dcf4SKowalski, Kamil  *
1651f4c4dcf4SKowalski, Kamil  * See header file for more information
1652f4c4dcf4SKowalski, Kamil  * @endinternal
1653f4c4dcf4SKowalski, Kamil  */
1654d9fcfcc1SEd Tanous nlohmann::json insufficientPrivilege()
16551abe55efSEd Tanous {
1656fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1657b5c07418SJames Feist }
1658b5c07418SJames Feist 
1659b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1660b5c07418SJames Feist {
1661b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1662b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1663f4c4dcf4SKowalski, Kamil }
1664f4c4dcf4SKowalski, Kamil 
1665f4c4dcf4SKowalski, Kamil /**
1666f4c4dcf4SKowalski, Kamil  * @internal
1667f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1668f4c4dcf4SKowalski, Kamil  *
1669f4c4dcf4SKowalski, Kamil  * See header file for more information
1670f4c4dcf4SKowalski, Kamil  * @endinternal
1671f4c4dcf4SKowalski, Kamil  */
16721668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1,
167395b3ad73SEd Tanous                                      const nlohmann::json& arg2)
1674b5c07418SJames Feist {
1675bd79bce8SPatrick Williams     std::string arg2Str =
1676bd79bce8SPatrick Williams         arg2.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
1677fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueModified,
167895b3ad73SEd Tanous                   std::to_array<std::string_view>({arg1, arg2Str}));
1679b5c07418SJames Feist }
1680b5c07418SJames Feist 
16811668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1,
168295b3ad73SEd Tanous                            const nlohmann::json& arg2)
16831abe55efSEd Tanous {
1684f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1685b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1686f4c4dcf4SKowalski, Kamil }
1687f4c4dcf4SKowalski, Kamil 
1688f4c4dcf4SKowalski, Kamil /**
1689f4c4dcf4SKowalski, Kamil  * @internal
1690f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1691f4c4dcf4SKowalski, Kamil  *
1692f4c4dcf4SKowalski, Kamil  * See header file for more information
1693f4c4dcf4SKowalski, Kamil  * @endinternal
1694f4c4dcf4SKowalski, Kamil  */
1695d9fcfcc1SEd Tanous nlohmann::json accountNotModified()
16961abe55efSEd Tanous {
1697fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountNotModified, {});
1698b5c07418SJames Feist }
1699b5c07418SJames Feist 
1700b5c07418SJames Feist void accountNotModified(crow::Response& res)
1701b5c07418SJames Feist {
1702b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1703b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1704f4c4dcf4SKowalski, Kamil }
1705f4c4dcf4SKowalski, Kamil 
1706f4c4dcf4SKowalski, Kamil /**
1707f4c4dcf4SKowalski, Kamil  * @internal
1708f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1709f4c4dcf4SKowalski, Kamil  *
1710f4c4dcf4SKowalski, Kamil  * See header file for more information
1711f4c4dcf4SKowalski, Kamil  * @endinternal
1712f4c4dcf4SKowalski, Kamil  */
171395b3ad73SEd Tanous nlohmann::json queryParameterValueFormatError(const nlohmann::json& arg1,
17141668ce6dSEd Tanous                                               std::string_view arg2)
17151abe55efSEd Tanous {
1716bd79bce8SPatrick Williams     std::string arg1Str =
1717bd79bce8SPatrick Williams         arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
1718fffb8c1fSEd Tanous     return getLog(
1719fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueFormatError,
172095b3ad73SEd Tanous         std::to_array<std::string_view>({arg1Str, arg2}));
1721b5c07418SJames Feist }
1722b5c07418SJames Feist 
1723bd79bce8SPatrick Williams void queryParameterValueFormatError(
1724bd79bce8SPatrick Williams     crow::Response& res, const nlohmann::json& arg1, std::string_view arg2)
1725b5c07418SJames Feist {
1726b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1727b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1728b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
1729f4c4dcf4SKowalski, Kamil }
1730f4c4dcf4SKowalski, Kamil 
1731f4c4dcf4SKowalski, Kamil /**
1732f4c4dcf4SKowalski, Kamil  * @internal
1733b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
1734b5c07418SJames Feist  * property
1735f12894f8SJason M. Bills  *
1736f12894f8SJason M. Bills  * See header file for more information
1737f12894f8SJason M. Bills  * @endinternal
1738f12894f8SJason M. Bills  */
17391668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1)
1740f12894f8SJason M. Bills {
1741fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyMissing,
17421668ce6dSEd Tanous                   std::to_array({arg1}));
1743b5c07418SJames Feist }
1744b5c07418SJames Feist 
17451668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1)
1746b5c07418SJames Feist {
1747b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1748b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1749f4c4dcf4SKowalski, Kamil }
1750f4c4dcf4SKowalski, Kamil 
1751f4c4dcf4SKowalski, Kamil /**
1752f4c4dcf4SKowalski, Kamil  * @internal
1753f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
1754f4c4dcf4SKowalski, Kamil  *
1755f4c4dcf4SKowalski, Kamil  * See header file for more information
1756f4c4dcf4SKowalski, Kamil  * @endinternal
1757f4c4dcf4SKowalski, Kamil  */
17581668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1)
17591abe55efSEd Tanous {
1760fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceExhaustion,
17611668ce6dSEd Tanous                   std::to_array({arg1}));
1762b5c07418SJames Feist }
1763b5c07418SJames Feist 
17641668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1)
1765b5c07418SJames Feist {
1766b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1767b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1768f4c4dcf4SKowalski, Kamil }
1769f4c4dcf4SKowalski, Kamil 
1770f4c4dcf4SKowalski, Kamil /**
1771f4c4dcf4SKowalski, Kamil  * @internal
1772f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
1773f4c4dcf4SKowalski, Kamil  *
1774f4c4dcf4SKowalski, Kamil  * See header file for more information
1775f4c4dcf4SKowalski, Kamil  * @endinternal
1776f4c4dcf4SKowalski, Kamil  */
1777d9fcfcc1SEd Tanous nlohmann::json accountModified()
17781abe55efSEd Tanous {
1779fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountModified, {});
1780b5c07418SJames Feist }
1781b5c07418SJames Feist 
1782b5c07418SJames Feist void accountModified(crow::Response& res)
1783b5c07418SJames Feist {
1784b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1785b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
1786f4c4dcf4SKowalski, Kamil }
1787f4c4dcf4SKowalski, Kamil 
1788f4c4dcf4SKowalski, Kamil /**
1789f4c4dcf4SKowalski, Kamil  * @internal
1790f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
1791f4c4dcf4SKowalski, Kamil  *
1792f4c4dcf4SKowalski, Kamil  * See header file for more information
1793f4c4dcf4SKowalski, Kamil  * @endinternal
1794f4c4dcf4SKowalski, Kamil  */
1795bd79bce8SPatrick Williams nlohmann::json queryParameterOutOfRange(
1796bd79bce8SPatrick Williams     std::string_view arg1, std::string_view arg2, std::string_view arg3)
17971abe55efSEd Tanous {
1798fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
17991668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
1800b5c07418SJames Feist }
1801b5c07418SJames Feist 
18021668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
18031668ce6dSEd Tanous                               std::string_view arg2, std::string_view arg3)
1804b5c07418SJames Feist {
1805b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1806b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1807b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
1808f4c4dcf4SKowalski, Kamil }
1809f4c4dcf4SKowalski, Kamil 
18104a7fbefdSEd Tanous nlohmann::json passwordChangeRequired(const boost::urls::url_view_base& arg1)
1811b6cd31e1SEd Tanous {
1812fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::passwordChangeRequired,
1813079360aeSEd Tanous                   std::to_array<std::string_view>({arg1.buffer()}));
1814b6cd31e1SEd Tanous }
1815b6cd31e1SEd Tanous 
18163bf4e632SJoseph Reynolds /**
18173bf4e632SJoseph Reynolds  * @internal
18183bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
18193bf4e632SJoseph Reynolds  *
18203bf4e632SJoseph Reynolds  * See header file for more information
18213bf4e632SJoseph Reynolds  * @endinternal
18223bf4e632SJoseph Reynolds  */
18234a7fbefdSEd Tanous void passwordChangeRequired(crow::Response& res,
18244a7fbefdSEd Tanous                             const boost::urls::url_view_base& arg1)
18253bf4e632SJoseph Reynolds {
1826b6cd31e1SEd Tanous     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
18273bf4e632SJoseph Reynolds }
18283bf4e632SJoseph Reynolds 
18294cde5d90SJames Feist /**
18304cde5d90SJames Feist  * @internal
1831ae688313SNan Zhou  * @brief Formats InsufficientStorage message into JSON
1832ae688313SNan Zhou  *
1833ae688313SNan Zhou  * See header file for more information
1834ae688313SNan Zhou  * @endinternal
1835ae688313SNan Zhou  */
1836ae688313SNan Zhou nlohmann::json insufficientStorage()
1837ae688313SNan Zhou {
1838ae688313SNan Zhou     return getLog(redfish::registries::base::Index::insufficientStorage, {});
1839ae688313SNan Zhou }
1840ae688313SNan Zhou 
1841ae688313SNan Zhou void insufficientStorage(crow::Response& res)
1842ae688313SNan Zhou {
1843ae688313SNan Zhou     res.result(boost::beast::http::status::insufficient_storage);
1844ae688313SNan Zhou     addMessageToErrorJson(res.jsonValue, insufficientStorage());
1845ae688313SNan Zhou }
1846ae688313SNan Zhou 
1847ae688313SNan Zhou /**
1848ae688313SNan Zhou  * @internal
184944c70412SEd Tanous  * @brief Formats OperationNotAllowed message into JSON
185044c70412SEd Tanous  *
185144c70412SEd Tanous  * See header file for more information
185244c70412SEd Tanous  * @endinternal
185344c70412SEd Tanous  */
185444c70412SEd Tanous nlohmann::json operationNotAllowed()
185544c70412SEd Tanous {
185644c70412SEd Tanous     return getLog(redfish::registries::base::Index::operationNotAllowed, {});
185744c70412SEd Tanous }
185844c70412SEd Tanous 
185944c70412SEd Tanous void operationNotAllowed(crow::Response& res)
186044c70412SEd Tanous {
186144c70412SEd Tanous     res.result(boost::beast::http::status::method_not_allowed);
186244c70412SEd Tanous     addMessageToErrorJson(res.jsonValue, operationNotAllowed());
186344c70412SEd Tanous }
186444c70412SEd Tanous 
1865600af5f1SAppaRao Puli /**
1866600af5f1SAppaRao Puli  * @internal
1867600af5f1SAppaRao Puli  * @brief Formats ArraySizeTooLong message into JSON
1868600af5f1SAppaRao Puli  *
1869600af5f1SAppaRao Puli  * See header file for more information
1870600af5f1SAppaRao Puli  * @endinternal
1871600af5f1SAppaRao Puli  */
1872600af5f1SAppaRao Puli nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length)
1873600af5f1SAppaRao Puli {
1874600af5f1SAppaRao Puli     std::string valStr = std::to_string(length);
1875600af5f1SAppaRao Puli     return getLog(redfish::registries::base::Index::arraySizeTooLong,
1876600af5f1SAppaRao Puli                   std::to_array<std::string_view>({property, valStr}));
1877600af5f1SAppaRao Puli }
1878600af5f1SAppaRao Puli 
1879600af5f1SAppaRao Puli void arraySizeTooLong(crow::Response& res, std::string_view property,
1880600af5f1SAppaRao Puli                       uint64_t length)
1881600af5f1SAppaRao Puli {
188299bf0262SDivya Jyoti     res.result(boost::beast::http::status::bad_request);
1883600af5f1SAppaRao Puli     addMessageToErrorJson(res.jsonValue, arraySizeTooLong(property, length));
1884600af5f1SAppaRao Puli }
1885600af5f1SAppaRao Puli 
188644c70412SEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1,
188744c70412SEd Tanous                    std::string_view arg2)
188844c70412SEd Tanous {
188944c70412SEd Tanous     res.result(boost::beast::http::status::bad_request);
189044c70412SEd Tanous     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
189144c70412SEd Tanous }
189244c70412SEd Tanous 
189344c70412SEd Tanous /**
189444c70412SEd Tanous  * @internal
18954cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
18964cde5d90SJames Feist  *
18974cde5d90SJames Feist  * See header file for more information
18984cde5d90SJames Feist  * @endinternal
18994cde5d90SJames Feist  */
19001668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
19014cde5d90SJames Feist {
19021668ce6dSEd Tanous     std::string msg = "Invalid file uploaded to ";
19031668ce6dSEd Tanous     msg += arg1;
19041668ce6dSEd Tanous     msg += ": ";
19051668ce6dSEd Tanous     msg += arg2;
19061668ce6dSEd Tanous     msg += ".";
1907613dabeaSEd Tanous 
1908613dabeaSEd Tanous     nlohmann::json::object_t ret;
1909613dabeaSEd Tanous     ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message";
1910613dabeaSEd Tanous     ret["MessageId"] = "OpenBMC.0.2.InvalidUpload";
1911613dabeaSEd Tanous     ret["Message"] = std::move(msg);
1912613dabeaSEd Tanous     nlohmann::json::array_t args;
1913ad539545SPatrick Williams     args.emplace_back(arg1);
1914ad539545SPatrick Williams     args.emplace_back(arg2);
1915613dabeaSEd Tanous     ret["MessageArgs"] = std::move(args);
1916613dabeaSEd Tanous     ret["MessageSeverity"] = "Warning";
1917613dabeaSEd Tanous     ret["Resolution"] = "None.";
1918613dabeaSEd Tanous     return ret;
19194cde5d90SJames Feist }
1920ae688313SNan Zhou 
1921f4c4dcf4SKowalski, Kamil } // namespace messages
1922f4c4dcf4SKowalski, Kamil 
1923d425c6f6SEd Tanous } // namespace redfish
1924