xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision 3590bd1dee5a0e56d4d282f0a1e3cf2c8804dfa1)
1f4c4dcf4SKowalski, Kamil /*
2f4c4dcf4SKowalski, Kamil // Copyright (c) 2018 Intel Corporation
3f4c4dcf4SKowalski, Kamil //
4f4c4dcf4SKowalski, Kamil // Licensed under the Apache License, Version 2.0 (the "License");
5f4c4dcf4SKowalski, Kamil // you may not use this file except in compliance with the License.
6f4c4dcf4SKowalski, Kamil // You may obtain a copy of the License at
7f4c4dcf4SKowalski, Kamil //
8f4c4dcf4SKowalski, Kamil //      http://www.apache.org/licenses/LICENSE-2.0
9f4c4dcf4SKowalski, Kamil //
10f4c4dcf4SKowalski, Kamil // Unless required by applicable law or agreed to in writing, software
11f4c4dcf4SKowalski, Kamil // distributed under the License is distributed on an "AS IS" BASIS,
12f4c4dcf4SKowalski, Kamil // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13f4c4dcf4SKowalski, Kamil // See the License for the specific language governing permissions and
14f4c4dcf4SKowalski, Kamil // limitations under the License.
15f4c4dcf4SKowalski, Kamil */
160442ef92SNan Zhou #include "error_messages.hpp"
179ea15c35SEd Tanous 
180442ef92SNan Zhou #include "http_response.hpp"
190442ef92SNan Zhou #include "logging.hpp"
200442ef92SNan Zhou #include "nlohmann/json.hpp"
210442ef92SNan Zhou #include "registries.hpp"
220442ef92SNan Zhou #include "registries/base_message_registry.hpp"
230442ef92SNan Zhou #include "source_location.hpp"
240442ef92SNan Zhou 
250442ef92SNan Zhou #include <boost/beast/http/field.hpp>
269ea15c35SEd Tanous #include <boost/beast/http/status.hpp>
27f4c4dcf4SKowalski, Kamil 
281668ce6dSEd Tanous #include <array>
290442ef92SNan Zhou #include <cstddef>
300442ef92SNan Zhou #include <span>
310442ef92SNan Zhou #include <string>
320442ef92SNan Zhou #include <utility>
330442ef92SNan Zhou 
340442ef92SNan Zhou // IWYU pragma: no_include <stddef.h>
351668ce6dSEd Tanous 
361abe55efSEd Tanous namespace redfish
371abe55efSEd Tanous {
381abe55efSEd Tanous 
391abe55efSEd Tanous namespace messages
401abe55efSEd Tanous {
41f4c4dcf4SKowalski, Kamil 
42f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target,
431abe55efSEd Tanous                                   const nlohmann::json& message)
441abe55efSEd Tanous {
45f4c4dcf4SKowalski, Kamil     auto& error = target["error"];
46f4c4dcf4SKowalski, Kamil 
471abe55efSEd Tanous     // If this is the first error message, fill in the information from the
481abe55efSEd Tanous     // first error message to the top level struct
491abe55efSEd Tanous     if (!error.is_object())
501abe55efSEd Tanous     {
51c074230bSJason M. Bills         auto messageIdIterator = message.find("MessageId");
52c074230bSJason M. Bills         if (messageIdIterator == message.end())
531abe55efSEd Tanous         {
541abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
551abe55efSEd Tanous                 << "Attempt to add error message without MessageId";
56f4c4dcf4SKowalski, Kamil             return;
57f4c4dcf4SKowalski, Kamil         }
58f4c4dcf4SKowalski, Kamil 
59c074230bSJason M. Bills         auto messageFieldIterator = message.find("Message");
60c074230bSJason M. Bills         if (messageFieldIterator == message.end())
611abe55efSEd Tanous         {
621abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
631abe55efSEd Tanous                 << "Attempt to add error message without Message";
64f4c4dcf4SKowalski, Kamil             return;
65f4c4dcf4SKowalski, Kamil         }
661476687dSEd Tanous         error["code"] = *messageIdIterator;
671476687dSEd Tanous         error["message"] = *messageFieldIterator;
681abe55efSEd Tanous     }
691abe55efSEd Tanous     else
701abe55efSEd Tanous     {
71f4c4dcf4SKowalski, Kamil         // More than 1 error occurred, so the message has to be generic
7255c7b7a2SEd Tanous         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
73cc9139ecSJason M. Bills         error["message"] = "A general error has occurred. See Resolution for "
74cc9139ecSJason M. Bills                            "information on how to resolve the error.";
75f4c4dcf4SKowalski, Kamil     }
76f4c4dcf4SKowalski, Kamil 
77*3590bd1dSNan Zhou     // This check could technically be done in the default construction
78f4c4dcf4SKowalski, Kamil     // branch above, but because we need the pointer to the extended info field
79f4c4dcf4SKowalski, Kamil     // anyway, it's more efficient to do it here.
80c074230bSJason M. Bills     auto& extendedInfo = error[messages::messageAnnotation];
81c074230bSJason M. Bills     if (!extendedInfo.is_array())
821abe55efSEd Tanous     {
83c074230bSJason M. Bills         extendedInfo = nlohmann::json::array();
84f4c4dcf4SKowalski, Kamil     }
85f4c4dcf4SKowalski, Kamil 
86c074230bSJason M. Bills     extendedInfo.push_back(message);
87f4c4dcf4SKowalski, Kamil }
88f4c4dcf4SKowalski, Kamil 
89*3590bd1dSNan Zhou void moveErrorsToErrorJson(nlohmann::json& target, nlohmann::json& source)
90*3590bd1dSNan Zhou {
91*3590bd1dSNan Zhou     if (!source.is_object())
92*3590bd1dSNan Zhou     {
93*3590bd1dSNan Zhou         return;
94*3590bd1dSNan Zhou     }
95*3590bd1dSNan Zhou     auto errorIt = source.find("error");
96*3590bd1dSNan Zhou     if (errorIt == source.end())
97*3590bd1dSNan Zhou     {
98*3590bd1dSNan Zhou         // caller puts error message in root
99*3590bd1dSNan Zhou         messages::addMessageToErrorJson(target, source);
100*3590bd1dSNan Zhou         source.clear();
101*3590bd1dSNan Zhou         return;
102*3590bd1dSNan Zhou     }
103*3590bd1dSNan Zhou     auto extendedInfoIt = errorIt->find(messages::messageAnnotation);
104*3590bd1dSNan Zhou     if (extendedInfoIt == errorIt->end())
105*3590bd1dSNan Zhou     {
106*3590bd1dSNan Zhou         return;
107*3590bd1dSNan Zhou     }
108*3590bd1dSNan Zhou     const nlohmann::json::array_t* extendedInfo =
109*3590bd1dSNan Zhou         (*extendedInfoIt).get_ptr<const nlohmann::json::array_t*>();
110*3590bd1dSNan Zhou     if (extendedInfo == nullptr)
111*3590bd1dSNan Zhou     {
112*3590bd1dSNan Zhou         source.erase(errorIt);
113*3590bd1dSNan Zhou         return;
114*3590bd1dSNan Zhou     }
115*3590bd1dSNan Zhou     for (const nlohmann::json& message : *extendedInfo)
116*3590bd1dSNan Zhou     {
117*3590bd1dSNan Zhou         addMessageToErrorJson(target, message);
118*3590bd1dSNan Zhou     }
119*3590bd1dSNan Zhou     source.erase(errorIt);
120*3590bd1dSNan Zhou }
121*3590bd1dSNan Zhou 
122f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target,
123f12894f8SJason M. Bills                                  const nlohmann::json& message)
1241abe55efSEd Tanous {
1251abe55efSEd Tanous     if (!target[messages::messageAnnotation].is_array())
1261abe55efSEd Tanous     {
127f4c4dcf4SKowalski, Kamil         // Force object to be an array
12855c7b7a2SEd Tanous         target[messages::messageAnnotation] = nlohmann::json::array();
129f4c4dcf4SKowalski, Kamil     }
130f4c4dcf4SKowalski, Kamil 
13155c7b7a2SEd Tanous     target[messages::messageAnnotation].push_back(message);
132f4c4dcf4SKowalski, Kamil }
133f4c4dcf4SKowalski, Kamil 
134f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target,
135f12894f8SJason M. Bills                              const nlohmann::json& message,
1361668ce6dSEd Tanous                              std::string_view fieldPath)
1371abe55efSEd Tanous {
1381668ce6dSEd Tanous     std::string extendedInfo(fieldPath);
1391668ce6dSEd Tanous     extendedInfo += messages::messageAnnotation;
140f4c4dcf4SKowalski, Kamil 
1411668ce6dSEd Tanous     nlohmann::json& field = target[extendedInfo];
1421668ce6dSEd Tanous     if (!field.is_array())
1431abe55efSEd Tanous     {
144f4c4dcf4SKowalski, Kamil         // Force object to be an array
1451668ce6dSEd Tanous         field = nlohmann::json::array();
146f4c4dcf4SKowalski, Kamil     }
147f4c4dcf4SKowalski, Kamil 
148f4c4dcf4SKowalski, Kamil     // Object exists and it is an array so we can just push in the message
1491668ce6dSEd Tanous     field.push_back(message);
150f4c4dcf4SKowalski, Kamil }
151f4c4dcf4SKowalski, Kamil 
152f7725d79SEd Tanous static nlohmann::json getLog(redfish::registries::base::Index name,
153b6cd31e1SEd Tanous                              std::span<const std::string_view> args)
154b6cd31e1SEd Tanous {
155b6cd31e1SEd Tanous     size_t index = static_cast<size_t>(name);
156fffb8c1fSEd Tanous     if (index >= redfish::registries::base::registry.size())
157b6cd31e1SEd Tanous     {
158b6cd31e1SEd Tanous         return {};
159b6cd31e1SEd Tanous     }
16065e4f1f7SEd Tanous     return getLogFromRegistry(redfish::registries::base::header,
16165e4f1f7SEd Tanous                               redfish::registries::base::registry, index, args);
162b6cd31e1SEd Tanous }
163b6cd31e1SEd Tanous 
164f4c4dcf4SKowalski, Kamil /**
165f4c4dcf4SKowalski, Kamil  * @internal
166f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
167f4c4dcf4SKowalski, Kamil  *
168f4c4dcf4SKowalski, Kamil  * See header file for more information
169f4c4dcf4SKowalski, Kamil  * @endinternal
170f4c4dcf4SKowalski, Kamil  */
171b5c07418SJames Feist nlohmann::json resourceInUse(void)
1721abe55efSEd Tanous {
173fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInUse, {});
174b5c07418SJames Feist }
175b5c07418SJames Feist 
176b5c07418SJames Feist void resourceInUse(crow::Response& res)
177b5c07418SJames Feist {
178b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
179b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
180f4c4dcf4SKowalski, Kamil }
181f4c4dcf4SKowalski, Kamil 
182f4c4dcf4SKowalski, Kamil /**
183f4c4dcf4SKowalski, Kamil  * @internal
184f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
185f4c4dcf4SKowalski, Kamil  *
186f4c4dcf4SKowalski, Kamil  * See header file for more information
187f4c4dcf4SKowalski, Kamil  * @endinternal
188f4c4dcf4SKowalski, Kamil  */
189b5c07418SJames Feist nlohmann::json malformedJSON(void)
1901abe55efSEd Tanous {
191fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::malformedJSON, {});
192b5c07418SJames Feist }
193b5c07418SJames Feist 
194b5c07418SJames Feist void malformedJSON(crow::Response& res)
195b5c07418SJames Feist {
196b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
197b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
198f4c4dcf4SKowalski, Kamil }
199f4c4dcf4SKowalski, Kamil 
200f4c4dcf4SKowalski, Kamil /**
201f4c4dcf4SKowalski, Kamil  * @internal
202f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
203f4c4dcf4SKowalski, Kamil  *
204f4c4dcf4SKowalski, Kamil  * See header file for more information
205f4c4dcf4SKowalski, Kamil  * @endinternal
206f4c4dcf4SKowalski, Kamil  */
207ace85d60SEd Tanous nlohmann::json resourceMissingAtURI(const boost::urls::url_view& arg1)
2081abe55efSEd Tanous {
209b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
210b6cd31e1SEd Tanous         std::string_view{arg1.data(), arg1.size()}};
211fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceMissingAtURI, args);
212b5c07418SJames Feist }
213b5c07418SJames Feist 
214ace85d60SEd Tanous void resourceMissingAtURI(crow::Response& res,
215ace85d60SEd Tanous                           const boost::urls::url_view& arg1)
216b5c07418SJames Feist {
217b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
218b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
219f4c4dcf4SKowalski, Kamil }
220f4c4dcf4SKowalski, Kamil 
221f4c4dcf4SKowalski, Kamil /**
222f4c4dcf4SKowalski, Kamil  * @internal
223f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
224f4c4dcf4SKowalski, Kamil  *
225f4c4dcf4SKowalski, Kamil  * See header file for more information
226f4c4dcf4SKowalski, Kamil  * @endinternal
227f4c4dcf4SKowalski, Kamil  */
2281668ce6dSEd Tanous nlohmann::json actionParameterValueFormatError(std::string_view arg1,
2291668ce6dSEd Tanous                                                std::string_view arg2,
2301668ce6dSEd Tanous                                                std::string_view arg3)
2311abe55efSEd Tanous {
232fffb8c1fSEd Tanous     return getLog(
233fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueFormatError,
2341668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
235b5c07418SJames Feist }
236b5c07418SJames Feist 
2371668ce6dSEd Tanous void actionParameterValueFormatError(crow::Response& res, std::string_view arg1,
2381668ce6dSEd Tanous                                      std::string_view arg2,
2391668ce6dSEd Tanous                                      std::string_view arg3)
240b5c07418SJames Feist {
241b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
242b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
243b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
244f4c4dcf4SKowalski, Kamil }
245f4c4dcf4SKowalski, Kamil 
246f4c4dcf4SKowalski, Kamil /**
247f4c4dcf4SKowalski, Kamil  * @internal
248f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
249f4c4dcf4SKowalski, Kamil  *
250f4c4dcf4SKowalski, Kamil  * See header file for more information
251f4c4dcf4SKowalski, Kamil  * @endinternal
252f4c4dcf4SKowalski, Kamil  */
253b5c07418SJames Feist nlohmann::json internalError(void)
2541abe55efSEd Tanous {
255fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::internalError, {});
256b5c07418SJames Feist }
257b5c07418SJames Feist 
258df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location)
259b5c07418SJames Feist {
260df5415fcSEd Tanous     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
261df5415fcSEd Tanous                         << location.line() << ":" << location.column() << ") `"
262df5415fcSEd Tanous                         << location.function_name() << "`: ";
263b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
264b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
265f12894f8SJason M. Bills }
266f12894f8SJason M. Bills 
267f12894f8SJason M. Bills /**
268f12894f8SJason M. Bills  * @internal
269f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
270f4c4dcf4SKowalski, Kamil  *
271f4c4dcf4SKowalski, Kamil  * See header file for more information
272f4c4dcf4SKowalski, Kamil  * @endinternal
273f4c4dcf4SKowalski, Kamil  */
274b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void)
2751abe55efSEd Tanous {
276fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::unrecognizedRequestBody,
277fffb8c1fSEd Tanous                   {});
278b5c07418SJames Feist }
279b5c07418SJames Feist 
280b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
281b5c07418SJames Feist {
282b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
283b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
284f4c4dcf4SKowalski, Kamil }
285f4c4dcf4SKowalski, Kamil 
286f4c4dcf4SKowalski, Kamil /**
287f4c4dcf4SKowalski, Kamil  * @internal
288f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
289f4c4dcf4SKowalski, Kamil  *
290f4c4dcf4SKowalski, Kamil  * See header file for more information
291f4c4dcf4SKowalski, Kamil  * @endinternal
292f4c4dcf4SKowalski, Kamil  */
293ace85d60SEd Tanous nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1,
2941668ce6dSEd Tanous                                          std::string_view arg2)
2951abe55efSEd Tanous {
296b6cd31e1SEd Tanous     return getLog(
297fffb8c1fSEd Tanous         redfish::registries::base::Index::resourceAtUriUnauthorized,
2981668ce6dSEd Tanous         std::to_array({std::string_view{arg1.data(), arg1.size()}, arg2}));
299b5c07418SJames Feist }
300b5c07418SJames Feist 
301ace85d60SEd Tanous void resourceAtUriUnauthorized(crow::Response& res,
302ace85d60SEd Tanous                                const boost::urls::url_view& arg1,
3031668ce6dSEd Tanous                                std::string_view arg2)
304b5c07418SJames Feist {
305b5c07418SJames Feist     res.result(boost::beast::http::status::unauthorized);
306b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
307f4c4dcf4SKowalski, Kamil }
308f4c4dcf4SKowalski, Kamil 
309f4c4dcf4SKowalski, Kamil /**
310f4c4dcf4SKowalski, Kamil  * @internal
311f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterUnknown message into JSON
312f4c4dcf4SKowalski, Kamil  *
313f4c4dcf4SKowalski, Kamil  * See header file for more information
314f4c4dcf4SKowalski, Kamil  * @endinternal
315f4c4dcf4SKowalski, Kamil  */
3161668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1,
3171668ce6dSEd Tanous                                       std::string_view arg2)
318b5c07418SJames Feist {
319fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterUnknown,
3201668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
321b5c07418SJames Feist }
322b5c07418SJames Feist 
3231668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1,
3241668ce6dSEd Tanous                             std::string_view arg2)
3251abe55efSEd Tanous {
326f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
327b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
328f4c4dcf4SKowalski, Kamil }
329f4c4dcf4SKowalski, Kamil 
330f4c4dcf4SKowalski, Kamil /**
331f4c4dcf4SKowalski, Kamil  * @internal
332f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceCannotBeDeleted message into JSON
333f4c4dcf4SKowalski, Kamil  *
334f4c4dcf4SKowalski, Kamil  * See header file for more information
335f4c4dcf4SKowalski, Kamil  * @endinternal
336f4c4dcf4SKowalski, Kamil  */
337b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void)
3381abe55efSEd Tanous {
339fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCannotBeDeleted,
340fffb8c1fSEd Tanous                   {});
341b5c07418SJames Feist }
342b5c07418SJames Feist 
343b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res)
344b5c07418SJames Feist {
34544c70412SEd Tanous     res.result(boost::beast::http::status::method_not_allowed);
346b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
347f4c4dcf4SKowalski, Kamil }
348f4c4dcf4SKowalski, Kamil 
349f4c4dcf4SKowalski, Kamil /**
350f4c4dcf4SKowalski, Kamil  * @internal
351f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyDuplicate message into JSON
352f4c4dcf4SKowalski, Kamil  *
353f4c4dcf4SKowalski, Kamil  * See header file for more information
354f4c4dcf4SKowalski, Kamil  * @endinternal
355f4c4dcf4SKowalski, Kamil  */
3561668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1)
3571abe55efSEd Tanous {
358fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyDuplicate,
3591668ce6dSEd Tanous                   std::to_array({arg1}));
360b5c07418SJames Feist }
361b5c07418SJames Feist 
3621668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1)
363b5c07418SJames Feist {
364b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
365b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
366f4c4dcf4SKowalski, Kamil }
367f4c4dcf4SKowalski, Kamil 
368f4c4dcf4SKowalski, Kamil /**
369f4c4dcf4SKowalski, Kamil  * @internal
370f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
371f4c4dcf4SKowalski, Kamil  *
372f4c4dcf4SKowalski, Kamil  * See header file for more information
373f4c4dcf4SKowalski, Kamil  * @endinternal
374f4c4dcf4SKowalski, Kamil  */
3751668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
3761abe55efSEd Tanous {
377b6cd31e1SEd Tanous     return getLog(
378fffb8c1fSEd Tanous         redfish::registries::base::Index::serviceTemporarilyUnavailable,
3791668ce6dSEd Tanous         std::to_array({arg1}));
380b5c07418SJames Feist }
381b5c07418SJames Feist 
3821668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
383b5c07418SJames Feist {
384d9f6c621SEd Tanous     res.addHeader(boost::beast::http::field::retry_after, arg1);
385b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
386b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
387f4c4dcf4SKowalski, Kamil }
388f4c4dcf4SKowalski, Kamil 
389f4c4dcf4SKowalski, Kamil /**
390f4c4dcf4SKowalski, Kamil  * @internal
391f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
392f4c4dcf4SKowalski, Kamil  *
393f4c4dcf4SKowalski, Kamil  * See header file for more information
394f4c4dcf4SKowalski, Kamil  * @endinternal
395f4c4dcf4SKowalski, Kamil  */
3961668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1,
3971668ce6dSEd Tanous                                      std::string_view arg2,
3981668ce6dSEd Tanous                                      std::string_view arg3)
3991abe55efSEd Tanous {
400fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceAlreadyExists,
4011668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
402b5c07418SJames Feist }
403b5c07418SJames Feist 
4041668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
4051668ce6dSEd Tanous                            std::string_view arg2, std::string_view arg3)
406b5c07418SJames Feist {
407b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
408b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
409a08b46ccSJason M. Bills                      arg2);
410f4c4dcf4SKowalski, Kamil }
411f4c4dcf4SKowalski, Kamil 
412f4c4dcf4SKowalski, Kamil /**
413f4c4dcf4SKowalski, Kamil  * @internal
414f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
415f4c4dcf4SKowalski, Kamil  *
416f4c4dcf4SKowalski, Kamil  * See header file for more information
417f4c4dcf4SKowalski, Kamil  * @endinternal
418f4c4dcf4SKowalski, Kamil  */
419b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void)
4201abe55efSEd Tanous {
421fffb8c1fSEd Tanous     return getLog(
422fffb8c1fSEd Tanous         redfish::registries::base::Index::accountForSessionNoLongerExists, {});
423b5c07418SJames Feist }
424b5c07418SJames Feist 
425b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
426b5c07418SJames Feist {
427b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
428b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
429f4c4dcf4SKowalski, Kamil }
430f4c4dcf4SKowalski, Kamil 
431f4c4dcf4SKowalski, Kamil /**
432f4c4dcf4SKowalski, Kamil  * @internal
433f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
434f4c4dcf4SKowalski, Kamil  *
435f4c4dcf4SKowalski, Kamil  * See header file for more information
436f4c4dcf4SKowalski, Kamil  * @endinternal
437f4c4dcf4SKowalski, Kamil  */
4381668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
4391abe55efSEd Tanous {
440fffb8c1fSEd Tanous     return getLog(
441fffb8c1fSEd Tanous         redfish::registries::base::Index::createFailedMissingReqProperties,
4421668ce6dSEd Tanous         std::to_array({arg1}));
443b5c07418SJames Feist }
444b5c07418SJames Feist 
445b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
4461668ce6dSEd Tanous                                       std::string_view arg1)
447b5c07418SJames Feist {
448b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
449b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
450a08b46ccSJason M. Bills                      arg1);
451f12894f8SJason M. Bills }
452f12894f8SJason M. Bills 
453f12894f8SJason M. Bills /**
454f12894f8SJason M. Bills  * @internal
455f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
456f12894f8SJason M. Bills  * property
457f12894f8SJason M. Bills  *
458f12894f8SJason M. Bills  * See header file for more information
459f12894f8SJason M. Bills  * @endinternal
460f12894f8SJason M. Bills  */
4611668ce6dSEd Tanous nlohmann::json propertyValueFormatError(std::string_view arg1,
4621668ce6dSEd Tanous                                         std::string_view arg2)
463f12894f8SJason M. Bills {
464fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueFormatError,
4651668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
466b5c07418SJames Feist }
467b5c07418SJames Feist 
4681668ce6dSEd Tanous void propertyValueFormatError(crow::Response& res, std::string_view arg1,
4691668ce6dSEd Tanous                               std::string_view arg2)
470b5c07418SJames Feist {
471b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
472b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
473f12894f8SJason M. Bills }
474f12894f8SJason M. Bills 
475f12894f8SJason M. Bills /**
476f12894f8SJason M. Bills  * @internal
477f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
478f12894f8SJason M. Bills  * property
479f12894f8SJason M. Bills  *
480f12894f8SJason M. Bills  * See header file for more information
481f12894f8SJason M. Bills  * @endinternal
482f12894f8SJason M. Bills  */
4831668ce6dSEd Tanous nlohmann::json propertyValueNotInList(std::string_view arg1,
4841668ce6dSEd Tanous                                       std::string_view arg2)
485f12894f8SJason M. Bills {
486fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueNotInList,
4871668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
488b5c07418SJames Feist }
489b5c07418SJames Feist 
4901668ce6dSEd Tanous void propertyValueNotInList(crow::Response& res, std::string_view arg1,
4911668ce6dSEd Tanous                             std::string_view arg2)
492b5c07418SJames Feist {
493b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
494b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
495f4c4dcf4SKowalski, Kamil }
496f4c4dcf4SKowalski, Kamil 
497f4c4dcf4SKowalski, Kamil /**
498f4c4dcf4SKowalski, Kamil  * @internal
499227a2b0aSJiaqing Zhao  * @brief Formats PropertyValueOutOfRange message into JSON
500227a2b0aSJiaqing Zhao  *
501227a2b0aSJiaqing Zhao  * See header file for more information
502227a2b0aSJiaqing Zhao  * @endinternal
503227a2b0aSJiaqing Zhao  */
504227a2b0aSJiaqing Zhao nlohmann::json propertyValueOutOfRange(std::string_view arg1,
505227a2b0aSJiaqing Zhao                                        std::string_view arg2)
506227a2b0aSJiaqing Zhao {
507227a2b0aSJiaqing Zhao     return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
508227a2b0aSJiaqing Zhao                   std::to_array({arg1, arg2}));
509227a2b0aSJiaqing Zhao }
510227a2b0aSJiaqing Zhao 
511227a2b0aSJiaqing Zhao void propertyValueOutOfRange(crow::Response& res, std::string_view arg1,
512227a2b0aSJiaqing Zhao                              std::string_view arg2)
513227a2b0aSJiaqing Zhao {
514227a2b0aSJiaqing Zhao     res.result(boost::beast::http::status::bad_request);
515227a2b0aSJiaqing Zhao     addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2));
516227a2b0aSJiaqing Zhao }
517227a2b0aSJiaqing Zhao 
518227a2b0aSJiaqing Zhao /**
519227a2b0aSJiaqing Zhao  * @internal
520f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
521f4c4dcf4SKowalski, Kamil  *
522f4c4dcf4SKowalski, Kamil  * See header file for more information
523f4c4dcf4SKowalski, Kamil  * @endinternal
524f4c4dcf4SKowalski, Kamil  */
525ace85d60SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1)
5261abe55efSEd Tanous {
5271668ce6dSEd Tanous     std::string_view arg1str{arg1.data(), arg1.size()};
528b6cd31e1SEd Tanous     return getLog(
529fffb8c1fSEd Tanous         redfish::registries::base::Index::resourceAtUriInUnknownFormat,
5301668ce6dSEd Tanous         std::to_array({arg1str}));
531b5c07418SJames Feist }
532b5c07418SJames Feist 
533ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res,
534ace85d60SEd Tanous                                   const boost::urls::url_view& arg1)
535b5c07418SJames Feist {
536b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
537b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
538f4c4dcf4SKowalski, Kamil }
539f4c4dcf4SKowalski, Kamil 
540f4c4dcf4SKowalski, Kamil /**
541f4c4dcf4SKowalski, Kamil  * @internal
54281856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
54381856681SAsmitha Karunanithi  *
54481856681SAsmitha Karunanithi  * See header file for more information
54581856681SAsmitha Karunanithi  * @endinternal
54681856681SAsmitha Karunanithi  */
5471668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1)
54881856681SAsmitha Karunanithi {
549fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceDisabled,
5501668ce6dSEd Tanous                   std::to_array({arg1}));
55181856681SAsmitha Karunanithi }
55281856681SAsmitha Karunanithi 
5531668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1)
55481856681SAsmitha Karunanithi {
55581856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
55681856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
55781856681SAsmitha Karunanithi }
55881856681SAsmitha Karunanithi 
55981856681SAsmitha Karunanithi /**
56081856681SAsmitha Karunanithi  * @internal
561f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
562f4c4dcf4SKowalski, Kamil  *
563f4c4dcf4SKowalski, Kamil  * See header file for more information
564f4c4dcf4SKowalski, Kamil  * @endinternal
565f4c4dcf4SKowalski, Kamil  */
566b5c07418SJames Feist nlohmann::json serviceInUnknownState(void)
5671abe55efSEd Tanous {
568fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
569b5c07418SJames Feist }
570b5c07418SJames Feist 
571b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
572b5c07418SJames Feist {
573b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
574b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
575f4c4dcf4SKowalski, Kamil }
576f4c4dcf4SKowalski, Kamil 
577f4c4dcf4SKowalski, Kamil /**
578f4c4dcf4SKowalski, Kamil  * @internal
579f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
580f4c4dcf4SKowalski, Kamil  *
581f4c4dcf4SKowalski, Kamil  * See header file for more information
582f4c4dcf4SKowalski, Kamil  * @endinternal
583f4c4dcf4SKowalski, Kamil  */
584b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void)
5851abe55efSEd Tanous {
586fffb8c1fSEd Tanous     return getLog(
587fffb8c1fSEd Tanous         redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
588b5c07418SJames Feist }
589b5c07418SJames Feist 
590b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
591b5c07418SJames Feist {
592789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
593b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
594f4c4dcf4SKowalski, Kamil }
595f4c4dcf4SKowalski, Kamil 
596f4c4dcf4SKowalski, Kamil /**
597f4c4dcf4SKowalski, Kamil  * @internal
598f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
599f4c4dcf4SKowalski, Kamil  *
600f4c4dcf4SKowalski, Kamil  * See header file for more information
601f4c4dcf4SKowalski, Kamil  * @endinternal
602f4c4dcf4SKowalski, Kamil  */
6031668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1,
6041668ce6dSEd Tanous                                       std::string_view arg2)
6051abe55efSEd Tanous {
606fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterMissing,
6071668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
608b5c07418SJames Feist }
609b5c07418SJames Feist 
6101668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1,
6111668ce6dSEd Tanous                             std::string_view arg2)
612b5c07418SJames Feist {
613b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
614b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
615f4c4dcf4SKowalski, Kamil }
616f4c4dcf4SKowalski, Kamil 
617f4c4dcf4SKowalski, Kamil /**
618f4c4dcf4SKowalski, Kamil  * @internal
619f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
620f4c4dcf4SKowalski, Kamil  *
621f4c4dcf4SKowalski, Kamil  * See header file for more information
622f4c4dcf4SKowalski, Kamil  * @endinternal
623f4c4dcf4SKowalski, Kamil  */
6241668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
6251abe55efSEd Tanous {
626b6cd31e1SEd Tanous     std::string arg2String = std::to_string(arg2);
627fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::stringValueTooLong,
6281668ce6dSEd Tanous                   std::to_array({arg1, std::string_view(arg2String)}));
629b5c07418SJames Feist }
630b5c07418SJames Feist 
6311668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
632b5c07418SJames Feist {
633b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
634b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
635f4c4dcf4SKowalski, Kamil }
636f4c4dcf4SKowalski, Kamil 
637f4c4dcf4SKowalski, Kamil /**
638f4c4dcf4SKowalski, Kamil  * @internal
639cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
640cc9139ecSJason M. Bills  *
641cc9139ecSJason M. Bills  * See header file for more information
642cc9139ecSJason M. Bills  * @endinternal
643cc9139ecSJason M. Bills  */
644b5c07418SJames Feist nlohmann::json sessionTerminated(void)
645cc9139ecSJason M. Bills {
646fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionTerminated, {});
647b5c07418SJames Feist }
648b5c07418SJames Feist 
649b5c07418SJames Feist void sessionTerminated(crow::Response& res)
650b5c07418SJames Feist {
651b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
652b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
653cc9139ecSJason M. Bills }
654cc9139ecSJason M. Bills 
655cc9139ecSJason M. Bills /**
656cc9139ecSJason M. Bills  * @internal
657684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
658684bb4b8SJason M. Bills  *
659684bb4b8SJason M. Bills  * See header file for more information
660684bb4b8SJason M. Bills  * @endinternal
661684bb4b8SJason M. Bills  */
662684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void)
663684bb4b8SJason M. Bills {
664fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
665684bb4b8SJason M. Bills }
666684bb4b8SJason M. Bills 
667684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
668684bb4b8SJason M. Bills {
669684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
670684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
671684bb4b8SJason M. Bills }
672684bb4b8SJason M. Bills 
673684bb4b8SJason M. Bills /**
674684bb4b8SJason M. Bills  * @internal
675cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
676cc9139ecSJason M. Bills  *
677cc9139ecSJason M. Bills  * See header file for more information
678cc9139ecSJason M. Bills  * @endinternal
679cc9139ecSJason M. Bills  */
6801668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1,
6811668ce6dSEd Tanous                                         std::string_view arg2)
682cc9139ecSJason M. Bills {
683fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
6841668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
685b5c07418SJames Feist }
686b5c07418SJames Feist 
6871668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
6881668ce6dSEd Tanous                               std::string_view arg2)
689b5c07418SJames Feist {
690b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
691b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
692cc9139ecSJason M. Bills }
693cc9139ecSJason M. Bills 
694cc9139ecSJason M. Bills /**
695cc9139ecSJason M. Bills  * @internal
696684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
697684bb4b8SJason M. Bills  *
698684bb4b8SJason M. Bills  * See header file for more information
699684bb4b8SJason M. Bills  * @endinternal
700684bb4b8SJason M. Bills  */
701ace85d60SEd Tanous nlohmann::json resetRequired(const boost::urls::url_view& arg1,
7021668ce6dSEd Tanous                              std::string_view arg2)
703684bb4b8SJason M. Bills {
7041668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
705fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
7061668ce6dSEd Tanous                   std::to_array({arg1str, arg2}));
707684bb4b8SJason M. Bills }
708684bb4b8SJason M. Bills 
709ace85d60SEd Tanous void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
7101668ce6dSEd Tanous                    std::string_view arg2)
711684bb4b8SJason M. Bills {
712684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
713684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
714684bb4b8SJason M. Bills }
715684bb4b8SJason M. Bills 
716684bb4b8SJason M. Bills /**
717684bb4b8SJason M. Bills  * @internal
718684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
719684bb4b8SJason M. Bills  *
720684bb4b8SJason M. Bills  * See header file for more information
721684bb4b8SJason M. Bills  * @endinternal
722684bb4b8SJason M. Bills  */
7231668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
724684bb4b8SJason M. Bills {
725fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
7261668ce6dSEd Tanous                   std::to_array({arg1}));
727684bb4b8SJason M. Bills }
728684bb4b8SJason M. Bills 
7291668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
730684bb4b8SJason M. Bills {
731684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
732684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
733684bb4b8SJason M. Bills }
734684bb4b8SJason M. Bills 
735684bb4b8SJason M. Bills /**
736684bb4b8SJason M. Bills  * @internal
737684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
738684bb4b8SJason M. Bills  *
739684bb4b8SJason M. Bills  * See header file for more information
740684bb4b8SJason M. Bills  * @endinternal
741684bb4b8SJason M. Bills  */
7421668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
743684bb4b8SJason M. Bills {
744b6cd31e1SEd Tanous     return getLog(
745fffb8c1fSEd Tanous         redfish::registries::base::Index::chassisPowerStateOffRequired,
7461668ce6dSEd Tanous         std::to_array({arg1}));
747684bb4b8SJason M. Bills }
748684bb4b8SJason M. Bills 
7491668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1)
750684bb4b8SJason M. Bills {
751684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
752684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
753684bb4b8SJason M. Bills }
754684bb4b8SJason M. Bills 
755684bb4b8SJason M. Bills /**
756684bb4b8SJason M. Bills  * @internal
757684bb4b8SJason M. Bills  * @brief Formats PropertyValueConflict message into JSON
758684bb4b8SJason M. Bills  *
759684bb4b8SJason M. Bills  * See header file for more information
760684bb4b8SJason M. Bills  * @endinternal
761684bb4b8SJason M. Bills  */
7621668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1,
7631668ce6dSEd Tanous                                      std::string_view arg2)
764684bb4b8SJason M. Bills {
765fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueConflict,
7661668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
767684bb4b8SJason M. Bills }
768684bb4b8SJason M. Bills 
7691668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1,
7701668ce6dSEd Tanous                            std::string_view arg2)
771684bb4b8SJason M. Bills {
772684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
773684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
774684bb4b8SJason M. Bills }
775684bb4b8SJason M. Bills 
776684bb4b8SJason M. Bills /**
777684bb4b8SJason M. Bills  * @internal
7782a6af81cSRamesh Iyyar  * @brief Formats PropertyValueResourceConflict message into JSON
7792a6af81cSRamesh Iyyar  *
7802a6af81cSRamesh Iyyar  * See header file for more information
7812a6af81cSRamesh Iyyar  * @endinternal
7822a6af81cSRamesh Iyyar  */
7832a6af81cSRamesh Iyyar nlohmann::json propertyValueResourceConflict(std::string_view arg1,
7842a6af81cSRamesh Iyyar                                              std::string_view arg2,
7852a6af81cSRamesh Iyyar                                              const boost::urls::url_view& arg3)
7862a6af81cSRamesh Iyyar {
7872a6af81cSRamesh Iyyar     return getLog(
7882a6af81cSRamesh Iyyar         redfish::registries::base::Index::propertyValueResourceConflict,
7892a6af81cSRamesh Iyyar         std::to_array(
7902a6af81cSRamesh Iyyar             {arg1, arg2, std::string_view{arg3.data(), arg3.size()}}));
7912a6af81cSRamesh Iyyar }
7922a6af81cSRamesh Iyyar 
7932a6af81cSRamesh Iyyar void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
7942a6af81cSRamesh Iyyar                                    std::string_view arg2,
7952a6af81cSRamesh Iyyar                                    const boost::urls::url_view& arg3)
7962a6af81cSRamesh Iyyar {
7972a6af81cSRamesh Iyyar     res.result(boost::beast::http::status::conflict);
7982a6af81cSRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
7992a6af81cSRamesh Iyyar                           propertyValueResourceConflict(arg1, arg2, arg3));
8002a6af81cSRamesh Iyyar }
8012a6af81cSRamesh Iyyar 
8022a6af81cSRamesh Iyyar /**
8032a6af81cSRamesh Iyyar  * @internal
80424861a28SRamesh Iyyar  * @brief Formats PropertyValueExternalConflict message into JSON
80524861a28SRamesh Iyyar  *
80624861a28SRamesh Iyyar  * See header file for more information
80724861a28SRamesh Iyyar  * @endinternal
80824861a28SRamesh Iyyar  */
80924861a28SRamesh Iyyar nlohmann::json propertyValueExternalConflict(std::string_view arg1,
81024861a28SRamesh Iyyar                                              std::string_view arg2)
81124861a28SRamesh Iyyar {
81224861a28SRamesh Iyyar     return getLog(
81324861a28SRamesh Iyyar         redfish::registries::base::Index::propertyValueExternalConflict,
81424861a28SRamesh Iyyar         std::to_array({arg1, arg2}));
81524861a28SRamesh Iyyar }
81624861a28SRamesh Iyyar 
81724861a28SRamesh Iyyar void propertyValueExternalConflict(crow::Response& res, std::string_view arg1,
81824861a28SRamesh Iyyar                                    std::string_view arg2)
81924861a28SRamesh Iyyar {
82024861a28SRamesh Iyyar     res.result(boost::beast::http::status::conflict);
82124861a28SRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
82224861a28SRamesh Iyyar                           propertyValueExternalConflict(arg1, arg2));
82324861a28SRamesh Iyyar }
82424861a28SRamesh Iyyar 
82524861a28SRamesh Iyyar /**
82624861a28SRamesh Iyyar  * @internal
827684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
828684bb4b8SJason M. Bills  *
829684bb4b8SJason M. Bills  * See header file for more information
830684bb4b8SJason M. Bills  * @endinternal
831684bb4b8SJason M. Bills  */
8321668ce6dSEd Tanous nlohmann::json propertyValueIncorrect(std::string_view arg1,
8331668ce6dSEd Tanous                                       std::string_view arg2)
834684bb4b8SJason M. Bills {
835fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueIncorrect,
8361668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
837684bb4b8SJason M. Bills }
838684bb4b8SJason M. Bills 
8391668ce6dSEd Tanous void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
8401668ce6dSEd Tanous                             std::string_view arg2)
841684bb4b8SJason M. Bills {
842684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
843684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
844684bb4b8SJason M. Bills }
845684bb4b8SJason M. Bills 
846684bb4b8SJason M. Bills /**
847684bb4b8SJason M. Bills  * @internal
848684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
849684bb4b8SJason M. Bills  *
850684bb4b8SJason M. Bills  * See header file for more information
851684bb4b8SJason M. Bills  * @endinternal
852684bb4b8SJason M. Bills  */
853ace85d60SEd Tanous nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1)
854684bb4b8SJason M. Bills {
8551668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
856fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCreationConflict,
8571668ce6dSEd Tanous                   std::to_array({arg1str}));
858684bb4b8SJason M. Bills }
859684bb4b8SJason M. Bills 
860ace85d60SEd Tanous void resourceCreationConflict(crow::Response& res,
861ace85d60SEd Tanous                               const boost::urls::url_view& arg1)
862684bb4b8SJason M. Bills {
863684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
864684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
865684bb4b8SJason M. Bills }
866684bb4b8SJason M. Bills 
867684bb4b8SJason M. Bills /**
868684bb4b8SJason M. Bills  * @internal
869684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded message into JSON
870684bb4b8SJason M. Bills  *
871684bb4b8SJason M. Bills  * See header file for more information
872684bb4b8SJason M. Bills  * @endinternal
873684bb4b8SJason M. Bills  */
874684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void)
875684bb4b8SJason M. Bills {
876fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
877684bb4b8SJason M. Bills }
878684bb4b8SJason M. Bills 
879684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
880684bb4b8SJason M. Bills {
881684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
882684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
883684bb4b8SJason M. Bills }
884684bb4b8SJason M. Bills 
885684bb4b8SJason M. Bills /**
886684bb4b8SJason M. Bills  * @internal
887684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
888684bb4b8SJason M. Bills  *
889684bb4b8SJason M. Bills  * See header file for more information
890684bb4b8SJason M. Bills  * @endinternal
891684bb4b8SJason M. Bills  */
892684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void)
893684bb4b8SJason M. Bills {
894fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionFailed, {});
895684bb4b8SJason M. Bills }
896684bb4b8SJason M. Bills 
897684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
898684bb4b8SJason M. Bills {
8994df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
900684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
901684bb4b8SJason M. Bills }
902684bb4b8SJason M. Bills 
903684bb4b8SJason M. Bills /**
904684bb4b8SJason M. Bills  * @internal
905684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
906684bb4b8SJason M. Bills  *
907684bb4b8SJason M. Bills  * See header file for more information
908684bb4b8SJason M. Bills  * @endinternal
909684bb4b8SJason M. Bills  */
910684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void)
911684bb4b8SJason M. Bills {
912fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionRequired, {});
913684bb4b8SJason M. Bills }
914684bb4b8SJason M. Bills 
915684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
916684bb4b8SJason M. Bills {
917684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
918684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
919684bb4b8SJason M. Bills }
920684bb4b8SJason M. Bills 
921684bb4b8SJason M. Bills /**
922684bb4b8SJason M. Bills  * @internal
923684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
924684bb4b8SJason M. Bills  *
925684bb4b8SJason M. Bills  * See header file for more information
926684bb4b8SJason M. Bills  * @endinternal
927684bb4b8SJason M. Bills  */
928684bb4b8SJason M. Bills nlohmann::json operationFailed(void)
929684bb4b8SJason M. Bills {
930fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationFailed, {});
931684bb4b8SJason M. Bills }
932684bb4b8SJason M. Bills 
933684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
934684bb4b8SJason M. Bills {
9358868776eSEd Tanous     res.result(boost::beast::http::status::bad_gateway);
936684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
937684bb4b8SJason M. Bills }
938684bb4b8SJason M. Bills 
939684bb4b8SJason M. Bills /**
940684bb4b8SJason M. Bills  * @internal
941684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
942684bb4b8SJason M. Bills  *
943684bb4b8SJason M. Bills  * See header file for more information
944684bb4b8SJason M. Bills  * @endinternal
945684bb4b8SJason M. Bills  */
946684bb4b8SJason M. Bills nlohmann::json operationTimeout(void)
947684bb4b8SJason M. Bills {
948fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationTimeout, {});
949684bb4b8SJason M. Bills }
950684bb4b8SJason M. Bills 
951684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
952684bb4b8SJason M. Bills {
953684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
954684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
955684bb4b8SJason M. Bills }
956684bb4b8SJason M. Bills 
957684bb4b8SJason M. Bills /**
958684bb4b8SJason M. Bills  * @internal
959f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
960f12894f8SJason M. Bills  * property
961f12894f8SJason M. Bills  *
962f12894f8SJason M. Bills  * See header file for more information
963f12894f8SJason M. Bills  * @endinternal
964f12894f8SJason M. Bills  */
9651668ce6dSEd Tanous nlohmann::json propertyValueTypeError(std::string_view arg1,
9661668ce6dSEd Tanous                                       std::string_view arg2)
967f12894f8SJason M. Bills {
968fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueTypeError,
9691668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
970b5c07418SJames Feist }
971b5c07418SJames Feist 
9721668ce6dSEd Tanous void propertyValueTypeError(crow::Response& res, std::string_view arg1,
9731668ce6dSEd Tanous                             std::string_view arg2)
974b5c07418SJames Feist {
975b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
976b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
977f4c4dcf4SKowalski, Kamil }
978f4c4dcf4SKowalski, Kamil 
979f4c4dcf4SKowalski, Kamil /**
980f4c4dcf4SKowalski, Kamil  * @internal
981b6cd31e1SEd Tanous  * @brief Formats ResourceNotFound message into JSONd
982f4c4dcf4SKowalski, Kamil  *
983f4c4dcf4SKowalski, Kamil  * See header file for more information
984f4c4dcf4SKowalski, Kamil  * @endinternal
985f4c4dcf4SKowalski, Kamil  */
9861668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
9871abe55efSEd Tanous {
988fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceNotFound,
9891668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
990b5c07418SJames Feist }
991b5c07418SJames Feist 
9921668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1,
9931668ce6dSEd Tanous                       std::string_view arg2)
994b5c07418SJames Feist {
995b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
996b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
997f4c4dcf4SKowalski, Kamil }
998f4c4dcf4SKowalski, Kamil 
999f4c4dcf4SKowalski, Kamil /**
1000f4c4dcf4SKowalski, Kamil  * @internal
1001f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
1002f4c4dcf4SKowalski, Kamil  *
1003f4c4dcf4SKowalski, Kamil  * See header file for more information
1004f4c4dcf4SKowalski, Kamil  * @endinternal
1005f4c4dcf4SKowalski, Kamil  */
1006ace85d60SEd Tanous nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1)
10071abe55efSEd Tanous {
10081668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1009fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
10101668ce6dSEd Tanous                   std::to_array({arg1str}));
1011b5c07418SJames Feist }
1012b5c07418SJames Feist 
1013ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res,
1014ace85d60SEd Tanous                                  const boost::urls::url_view& arg1)
1015b5c07418SJames Feist {
1016b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1017b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
1018f4c4dcf4SKowalski, Kamil }
1019f4c4dcf4SKowalski, Kamil 
1020f4c4dcf4SKowalski, Kamil /**
1021f4c4dcf4SKowalski, Kamil  * @internal
1022f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
1023f12894f8SJason M. Bills  * property
1024f12894f8SJason M. Bills  *
1025f12894f8SJason M. Bills  * See header file for more information
1026f12894f8SJason M. Bills  * @endinternal
1027f12894f8SJason M. Bills  */
10281668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1)
1029f12894f8SJason M. Bills {
1030fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyNotWritable,
10311668ce6dSEd Tanous                   std::to_array({arg1}));
1032b5c07418SJames Feist }
1033b5c07418SJames Feist 
10341668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1)
1035b5c07418SJames Feist {
1036b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1037b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1038f4c4dcf4SKowalski, Kamil }
1039f4c4dcf4SKowalski, Kamil 
1040f4c4dcf4SKowalski, Kamil /**
1041f4c4dcf4SKowalski, Kamil  * @internal
1042f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
1043f4c4dcf4SKowalski, Kamil  *
1044f4c4dcf4SKowalski, Kamil  * See header file for more information
1045f4c4dcf4SKowalski, Kamil  * @endinternal
1046f4c4dcf4SKowalski, Kamil  */
10471668ce6dSEd Tanous nlohmann::json queryParameterValueTypeError(std::string_view arg1,
10481668ce6dSEd Tanous                                             std::string_view arg2)
10491abe55efSEd Tanous {
1050b6cd31e1SEd Tanous     return getLog(
1051fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueTypeError,
10521668ce6dSEd Tanous         std::to_array({arg1, arg2}));
1053b5c07418SJames Feist }
1054b5c07418SJames Feist 
10551668ce6dSEd Tanous void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
10561668ce6dSEd Tanous                                   std::string_view arg2)
1057b5c07418SJames Feist {
1058b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1059b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1060b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
1061f4c4dcf4SKowalski, Kamil }
1062f4c4dcf4SKowalski, Kamil 
1063f4c4dcf4SKowalski, Kamil /**
1064f4c4dcf4SKowalski, Kamil  * @internal
1065f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
1066f4c4dcf4SKowalski, Kamil  *
1067f4c4dcf4SKowalski, Kamil  * See header file for more information
1068f4c4dcf4SKowalski, Kamil  * @endinternal
1069f4c4dcf4SKowalski, Kamil  */
1070b5c07418SJames Feist nlohmann::json serviceShuttingDown(void)
10711abe55efSEd Tanous {
1072fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
1073b5c07418SJames Feist }
1074b5c07418SJames Feist 
1075b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
1076b5c07418SJames Feist {
1077b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1078b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1079f4c4dcf4SKowalski, Kamil }
1080f4c4dcf4SKowalski, Kamil 
1081f4c4dcf4SKowalski, Kamil /**
1082f4c4dcf4SKowalski, Kamil  * @internal
1083f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
1084f4c4dcf4SKowalski, Kamil  *
1085f4c4dcf4SKowalski, Kamil  * See header file for more information
1086f4c4dcf4SKowalski, Kamil  * @endinternal
1087f4c4dcf4SKowalski, Kamil  */
10881668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1,
10891668ce6dSEd Tanous                                         std::string_view arg2)
10901abe55efSEd Tanous {
1091fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
10921668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1093b5c07418SJames Feist }
1094b5c07418SJames Feist 
10951668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
10961668ce6dSEd Tanous                               std::string_view arg2)
1097b5c07418SJames Feist {
1098b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1099b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1100f4c4dcf4SKowalski, Kamil }
1101f4c4dcf4SKowalski, Kamil 
1102f4c4dcf4SKowalski, Kamil /**
1103f4c4dcf4SKowalski, Kamil  * @internal
1104f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1105f4c4dcf4SKowalski, Kamil  *
1106f4c4dcf4SKowalski, Kamil  * See header file for more information
1107f4c4dcf4SKowalski, Kamil  * @endinternal
1108f4c4dcf4SKowalski, Kamil  */
11091668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1,
11101668ce6dSEd Tanous                                            std::string_view arg2)
11111abe55efSEd Tanous {
1112fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
11131668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1114b5c07418SJames Feist }
1115b5c07418SJames Feist 
11161668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
11171668ce6dSEd Tanous                                  std::string_view arg2)
1118b5c07418SJames Feist {
1119b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1120b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1121b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1122f4c4dcf4SKowalski, Kamil }
1123f4c4dcf4SKowalski, Kamil 
1124f4c4dcf4SKowalski, Kamil /**
1125f4c4dcf4SKowalski, Kamil  * @internal
1126f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1127f4c4dcf4SKowalski, Kamil  *
1128f4c4dcf4SKowalski, Kamil  * See header file for more information
1129f4c4dcf4SKowalski, Kamil  * @endinternal
1130f4c4dcf4SKowalski, Kamil  */
1131ace85d60SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1,
11321668ce6dSEd Tanous                                             std::string_view arg2)
11331abe55efSEd Tanous {
11341668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1135b6cd31e1SEd Tanous     return getLog(
1136fffb8c1fSEd Tanous         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
11371668ce6dSEd Tanous         std::to_array({arg1str, arg2}));
1138b5c07418SJames Feist }
1139b5c07418SJames Feist 
1140ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res,
1141ace85d60SEd Tanous                                   const boost::urls::url_view& arg1,
11421668ce6dSEd Tanous                                   std::string_view arg2)
1143b5c07418SJames Feist {
1144b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1145b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1146b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1147f4c4dcf4SKowalski, Kamil }
1148f4c4dcf4SKowalski, Kamil 
1149f4c4dcf4SKowalski, Kamil /**
1150f4c4dcf4SKowalski, Kamil  * @internal
1151f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1152f4c4dcf4SKowalski, Kamil  *
1153f4c4dcf4SKowalski, Kamil  * See header file for more information
1154f4c4dcf4SKowalski, Kamil  * @endinternal
1155f4c4dcf4SKowalski, Kamil  */
1156b5c07418SJames Feist nlohmann::json accountRemoved(void)
11571abe55efSEd Tanous {
1158fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountRemoved, {});
1159b5c07418SJames Feist }
1160b5c07418SJames Feist 
1161b5c07418SJames Feist void accountRemoved(crow::Response& res)
1162b5c07418SJames Feist {
1163b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1164b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1165f4c4dcf4SKowalski, Kamil }
1166f4c4dcf4SKowalski, Kamil 
1167f4c4dcf4SKowalski, Kamil /**
1168f4c4dcf4SKowalski, Kamil  * @internal
1169f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1170f4c4dcf4SKowalski, Kamil  *
1171f4c4dcf4SKowalski, Kamil  * See header file for more information
1172f4c4dcf4SKowalski, Kamil  * @endinternal
1173f4c4dcf4SKowalski, Kamil  */
1174ace85d60SEd Tanous nlohmann::json accessDenied(const boost::urls::url_view& arg1)
11751abe55efSEd Tanous {
11761668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1177fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accessDenied,
11781668ce6dSEd Tanous                   std::to_array({arg1str}));
1179b5c07418SJames Feist }
1180b5c07418SJames Feist 
1181ace85d60SEd Tanous void accessDenied(crow::Response& res, const boost::urls::url_view& arg1)
1182b5c07418SJames Feist {
1183b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1184b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1185f4c4dcf4SKowalski, Kamil }
1186f4c4dcf4SKowalski, Kamil 
1187f4c4dcf4SKowalski, Kamil /**
1188f4c4dcf4SKowalski, Kamil  * @internal
1189f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1190f4c4dcf4SKowalski, Kamil  *
1191f4c4dcf4SKowalski, Kamil  * See header file for more information
1192f4c4dcf4SKowalski, Kamil  * @endinternal
1193f4c4dcf4SKowalski, Kamil  */
1194b5c07418SJames Feist nlohmann::json queryNotSupported(void)
11951abe55efSEd Tanous {
1196fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1197b5c07418SJames Feist }
1198b5c07418SJames Feist 
1199b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1200b5c07418SJames Feist {
1201b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1202b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1203f4c4dcf4SKowalski, Kamil }
1204f4c4dcf4SKowalski, Kamil 
1205f4c4dcf4SKowalski, Kamil /**
1206f4c4dcf4SKowalski, Kamil  * @internal
1207f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1208f4c4dcf4SKowalski, Kamil  *
1209f4c4dcf4SKowalski, Kamil  * See header file for more information
1210f4c4dcf4SKowalski, Kamil  * @endinternal
1211f4c4dcf4SKowalski, Kamil  */
1212b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void)
12131abe55efSEd Tanous {
1214b6cd31e1SEd Tanous     return getLog(
1215fffb8c1fSEd Tanous         redfish::registries::base::Index::createLimitReachedForResource, {});
1216b5c07418SJames Feist }
1217b5c07418SJames Feist 
1218b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1219b5c07418SJames Feist {
1220b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1221b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1222f4c4dcf4SKowalski, Kamil }
1223f4c4dcf4SKowalski, Kamil 
1224f4c4dcf4SKowalski, Kamil /**
1225f4c4dcf4SKowalski, Kamil  * @internal
1226f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1227f4c4dcf4SKowalski, Kamil  *
1228f4c4dcf4SKowalski, Kamil  * See header file for more information
1229f4c4dcf4SKowalski, Kamil  * @endinternal
1230f4c4dcf4SKowalski, Kamil  */
1231b5c07418SJames Feist nlohmann::json generalError(void)
12321abe55efSEd Tanous {
1233fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::generalError, {});
1234b5c07418SJames Feist }
1235b5c07418SJames Feist 
1236b5c07418SJames Feist void generalError(crow::Response& res)
1237b5c07418SJames Feist {
1238b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1239b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1240f4c4dcf4SKowalski, Kamil }
1241f4c4dcf4SKowalski, Kamil 
1242f4c4dcf4SKowalski, Kamil /**
1243f4c4dcf4SKowalski, Kamil  * @internal
1244f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1245f4c4dcf4SKowalski, Kamil  *
1246f4c4dcf4SKowalski, Kamil  * See header file for more information
1247f4c4dcf4SKowalski, Kamil  * @endinternal
1248f4c4dcf4SKowalski, Kamil  */
1249b5c07418SJames Feist nlohmann::json success(void)
12501abe55efSEd Tanous {
1251fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::success, {});
1252b5c07418SJames Feist }
1253b5c07418SJames Feist 
1254b5c07418SJames Feist void success(crow::Response& res)
1255b5c07418SJames Feist {
1256b5c07418SJames Feist     // don't set res.result here because success is the default and any
1257b5c07418SJames Feist     // error should overwrite the default
1258b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1259f12894f8SJason M. Bills }
1260f12894f8SJason M. Bills 
1261f12894f8SJason M. Bills /**
1262f12894f8SJason M. Bills  * @internal
1263f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1264f4c4dcf4SKowalski, Kamil  *
1265f4c4dcf4SKowalski, Kamil  * See header file for more information
1266f4c4dcf4SKowalski, Kamil  * @endinternal
1267f4c4dcf4SKowalski, Kamil  */
1268b5c07418SJames Feist nlohmann::json created(void)
12691abe55efSEd Tanous {
1270fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::created, {});
1271b5c07418SJames Feist }
1272b5c07418SJames Feist 
1273b5c07418SJames Feist void created(crow::Response& res)
1274b5c07418SJames Feist {
1275b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1276b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1277f4c4dcf4SKowalski, Kamil }
1278f4c4dcf4SKowalski, Kamil 
1279f4c4dcf4SKowalski, Kamil /**
1280f4c4dcf4SKowalski, Kamil  * @internal
1281cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1282cc9139ecSJason M. Bills  *
1283cc9139ecSJason M. Bills  * See header file for more information
1284cc9139ecSJason M. Bills  * @endinternal
1285cc9139ecSJason M. Bills  */
1286b5c07418SJames Feist nlohmann::json noOperation(void)
1287cc9139ecSJason M. Bills {
1288fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noOperation, {});
1289b5c07418SJames Feist }
1290b5c07418SJames Feist 
1291b5c07418SJames Feist void noOperation(crow::Response& res)
1292b5c07418SJames Feist {
1293b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1294b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1295cc9139ecSJason M. Bills }
1296cc9139ecSJason M. Bills 
1297cc9139ecSJason M. Bills /**
1298cc9139ecSJason M. Bills  * @internal
1299b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1300b5c07418SJames Feist  * property
1301f12894f8SJason M. Bills  *
1302f12894f8SJason M. Bills  * See header file for more information
1303f12894f8SJason M. Bills  * @endinternal
1304f12894f8SJason M. Bills  */
13051668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1)
1306b5c07418SJames Feist {
1307fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyUnknown,
13081668ce6dSEd Tanous                   std::to_array({arg1}));
1309b5c07418SJames Feist }
1310b5c07418SJames Feist 
13111668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1)
1312f12894f8SJason M. Bills {
1313f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
13147b1dd2f9SEd Tanous     addMessageToErrorJson(res.jsonValue, propertyUnknown(arg1));
1315f4c4dcf4SKowalski, Kamil }
1316f4c4dcf4SKowalski, Kamil 
1317f4c4dcf4SKowalski, Kamil /**
1318f4c4dcf4SKowalski, Kamil  * @internal
1319f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1320f4c4dcf4SKowalski, Kamil  *
1321f4c4dcf4SKowalski, Kamil  * See header file for more information
1322f4c4dcf4SKowalski, Kamil  * @endinternal
1323f4c4dcf4SKowalski, Kamil  */
1324b5c07418SJames Feist nlohmann::json noValidSession(void)
13251abe55efSEd Tanous {
1326fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noValidSession, {});
1327b5c07418SJames Feist }
1328b5c07418SJames Feist 
1329b5c07418SJames Feist void noValidSession(crow::Response& res)
1330b5c07418SJames Feist {
1331b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1332b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1333f4c4dcf4SKowalski, Kamil }
1334f4c4dcf4SKowalski, Kamil 
1335f4c4dcf4SKowalski, Kamil /**
1336f4c4dcf4SKowalski, Kamil  * @internal
1337f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1338f4c4dcf4SKowalski, Kamil  *
1339f4c4dcf4SKowalski, Kamil  * See header file for more information
1340f4c4dcf4SKowalski, Kamil  * @endinternal
1341f4c4dcf4SKowalski, Kamil  */
1342ace85d60SEd Tanous nlohmann::json invalidObject(const boost::urls::url_view& arg1)
13431abe55efSEd Tanous {
13441668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1345fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidObject,
13461668ce6dSEd Tanous                   std::to_array({arg1str}));
1347b5c07418SJames Feist }
1348b5c07418SJames Feist 
1349ace85d60SEd Tanous void invalidObject(crow::Response& res, const boost::urls::url_view& arg1)
1350b5c07418SJames Feist {
1351b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1352b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1353f4c4dcf4SKowalski, Kamil }
1354f4c4dcf4SKowalski, Kamil 
1355f4c4dcf4SKowalski, Kamil /**
1356f4c4dcf4SKowalski, Kamil  * @internal
1357f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1358f4c4dcf4SKowalski, Kamil  *
1359f4c4dcf4SKowalski, Kamil  * See header file for more information
1360f4c4dcf4SKowalski, Kamil  * @endinternal
1361f4c4dcf4SKowalski, Kamil  */
1362b5c07418SJames Feist nlohmann::json resourceInStandby(void)
13631abe55efSEd Tanous {
1364fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1365b5c07418SJames Feist }
1366b5c07418SJames Feist 
1367b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1368b5c07418SJames Feist {
1369b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1370b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1371f4c4dcf4SKowalski, Kamil }
1372f4c4dcf4SKowalski, Kamil 
1373f4c4dcf4SKowalski, Kamil /**
1374f4c4dcf4SKowalski, Kamil  * @internal
1375f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1376f4c4dcf4SKowalski, Kamil  *
1377f4c4dcf4SKowalski, Kamil  * See header file for more information
1378f4c4dcf4SKowalski, Kamil  * @endinternal
1379f4c4dcf4SKowalski, Kamil  */
13801668ce6dSEd Tanous nlohmann::json actionParameterValueTypeError(std::string_view arg1,
13811668ce6dSEd Tanous                                              std::string_view arg2,
13821668ce6dSEd Tanous                                              std::string_view arg3)
13831abe55efSEd Tanous {
1384b6cd31e1SEd Tanous     return getLog(
1385fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueTypeError,
13861668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
1387b5c07418SJames Feist }
1388b5c07418SJames Feist 
13891668ce6dSEd Tanous void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
13901668ce6dSEd Tanous                                    std::string_view arg2, std::string_view arg3)
1391b5c07418SJames Feist {
1392b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1393b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1394b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1395f4c4dcf4SKowalski, Kamil }
1396f4c4dcf4SKowalski, Kamil 
1397f4c4dcf4SKowalski, Kamil /**
1398f4c4dcf4SKowalski, Kamil  * @internal
1399f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1400f4c4dcf4SKowalski, Kamil  *
1401f4c4dcf4SKowalski, Kamil  * See header file for more information
1402f4c4dcf4SKowalski, Kamil  * @endinternal
1403f4c4dcf4SKowalski, Kamil  */
1404b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void)
14051abe55efSEd Tanous {
1406fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1407b5c07418SJames Feist }
1408b5c07418SJames Feist 
1409b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1410b5c07418SJames Feist {
1411b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1412b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1413f4c4dcf4SKowalski, Kamil }
1414f4c4dcf4SKowalski, Kamil 
1415f4c4dcf4SKowalski, Kamil /**
1416f4c4dcf4SKowalski, Kamil  * @internal
1417f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1418f4c4dcf4SKowalski, Kamil  *
1419f4c4dcf4SKowalski, Kamil  * See header file for more information
1420f4c4dcf4SKowalski, Kamil  * @endinternal
1421f4c4dcf4SKowalski, Kamil  */
14221668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1)
14231abe55efSEd Tanous {
1424fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionNotSupported,
14251668ce6dSEd Tanous                   std::to_array({arg1}));
1426b5c07418SJames Feist }
1427b5c07418SJames Feist 
14281668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1)
1429b5c07418SJames Feist {
1430b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1431b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1432f4c4dcf4SKowalski, Kamil }
1433f4c4dcf4SKowalski, Kamil 
1434f4c4dcf4SKowalski, Kamil /**
1435f4c4dcf4SKowalski, Kamil  * @internal
1436f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1437f4c4dcf4SKowalski, Kamil  *
1438f4c4dcf4SKowalski, Kamil  * See header file for more information
1439f4c4dcf4SKowalski, Kamil  * @endinternal
1440f4c4dcf4SKowalski, Kamil  */
14415187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
14421abe55efSEd Tanous {
1443b6cd31e1SEd Tanous     std::string arg1Str = std::to_string(arg1);
1444fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidIndex,
14451668ce6dSEd Tanous                   std::to_array<std::string_view>({arg1Str}));
1446b5c07418SJames Feist }
1447b5c07418SJames Feist 
14485187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1449b5c07418SJames Feist {
1450b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1451b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1452f4c4dcf4SKowalski, Kamil }
1453f4c4dcf4SKowalski, Kamil 
1454f4c4dcf4SKowalski, Kamil /**
1455f4c4dcf4SKowalski, Kamil  * @internal
1456f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1457f4c4dcf4SKowalski, Kamil  *
1458f4c4dcf4SKowalski, Kamil  * See header file for more information
1459f4c4dcf4SKowalski, Kamil  * @endinternal
1460f4c4dcf4SKowalski, Kamil  */
1461b5c07418SJames Feist nlohmann::json emptyJSON(void)
14621abe55efSEd Tanous {
1463fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::emptyJSON, {});
1464b5c07418SJames Feist }
1465b5c07418SJames Feist 
1466b5c07418SJames Feist void emptyJSON(crow::Response& res)
1467b5c07418SJames Feist {
1468b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1469b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1470f4c4dcf4SKowalski, Kamil }
1471f4c4dcf4SKowalski, Kamil 
1472f4c4dcf4SKowalski, Kamil /**
1473f4c4dcf4SKowalski, Kamil  * @internal
1474f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1475f4c4dcf4SKowalski, Kamil  *
1476f4c4dcf4SKowalski, Kamil  * See header file for more information
1477f4c4dcf4SKowalski, Kamil  * @endinternal
1478f4c4dcf4SKowalski, Kamil  */
1479b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void)
14801abe55efSEd Tanous {
1481fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1482b6cd31e1SEd Tanous                   {});
1483b5c07418SJames Feist }
1484b5c07418SJames Feist 
1485b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1486b5c07418SJames Feist {
14876a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1488b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1489f4c4dcf4SKowalski, Kamil }
1490f4c4dcf4SKowalski, Kamil 
1491f4c4dcf4SKowalski, Kamil /**
1492f4c4dcf4SKowalski, Kamil  * @internal
1493684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1494684bb4b8SJason M. Bills  *
1495684bb4b8SJason M. Bills  * See header file for more information
1496684bb4b8SJason M. Bills  * @endinternal
1497684bb4b8SJason M. Bills  */
1498684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void)
1499684bb4b8SJason M. Bills {
1500b6cd31e1SEd Tanous     return getLog(
1501fffb8c1fSEd Tanous         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1502684bb4b8SJason M. Bills }
1503684bb4b8SJason M. Bills 
1504684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1505684bb4b8SJason M. Bills {
15066a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1507684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1508684bb4b8SJason M. Bills }
1509684bb4b8SJason M. Bills 
1510684bb4b8SJason M. Bills /**
1511684bb4b8SJason M. Bills  * @internal
1512684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1513684bb4b8SJason M. Bills  *
1514684bb4b8SJason M. Bills  * See header file for more information
1515684bb4b8SJason M. Bills  * @endinternal
1516684bb4b8SJason M. Bills  */
1517684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void)
1518684bb4b8SJason M. Bills {
1519fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1520fffb8c1fSEd Tanous                   {});
1521684bb4b8SJason M. Bills }
1522684bb4b8SJason M. Bills 
1523684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1524684bb4b8SJason M. Bills {
1525684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1526684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1527684bb4b8SJason M. Bills }
1528684bb4b8SJason M. Bills 
1529684bb4b8SJason M. Bills /**
1530684bb4b8SJason M. Bills  * @internal
1531f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1532f4c4dcf4SKowalski, Kamil  *
1533f4c4dcf4SKowalski, Kamil  * See header file for more information
1534f4c4dcf4SKowalski, Kamil  * @endinternal
1535f4c4dcf4SKowalski, Kamil  */
1536b5c07418SJames Feist nlohmann::json insufficientPrivilege(void)
15371abe55efSEd Tanous {
1538fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1539b5c07418SJames Feist }
1540b5c07418SJames Feist 
1541b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1542b5c07418SJames Feist {
1543b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1544b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1545f4c4dcf4SKowalski, Kamil }
1546f4c4dcf4SKowalski, Kamil 
1547f4c4dcf4SKowalski, Kamil /**
1548f4c4dcf4SKowalski, Kamil  * @internal
1549f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1550f4c4dcf4SKowalski, Kamil  *
1551f4c4dcf4SKowalski, Kamil  * See header file for more information
1552f4c4dcf4SKowalski, Kamil  * @endinternal
1553f4c4dcf4SKowalski, Kamil  */
15541668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1,
15551668ce6dSEd Tanous                                      std::string_view arg2)
1556b5c07418SJames Feist {
1557fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueModified,
15581668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1559b5c07418SJames Feist }
1560b5c07418SJames Feist 
15611668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1,
15621668ce6dSEd Tanous                            std::string_view arg2)
15631abe55efSEd Tanous {
1564f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1565b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1566f4c4dcf4SKowalski, Kamil }
1567f4c4dcf4SKowalski, Kamil 
1568f4c4dcf4SKowalski, Kamil /**
1569f4c4dcf4SKowalski, Kamil  * @internal
1570f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1571f4c4dcf4SKowalski, Kamil  *
1572f4c4dcf4SKowalski, Kamil  * See header file for more information
1573f4c4dcf4SKowalski, Kamil  * @endinternal
1574f4c4dcf4SKowalski, Kamil  */
1575b5c07418SJames Feist nlohmann::json accountNotModified(void)
15761abe55efSEd Tanous {
1577fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountNotModified, {});
1578b5c07418SJames Feist }
1579b5c07418SJames Feist 
1580b5c07418SJames Feist void accountNotModified(crow::Response& res)
1581b5c07418SJames Feist {
1582b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1583b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1584f4c4dcf4SKowalski, Kamil }
1585f4c4dcf4SKowalski, Kamil 
1586f4c4dcf4SKowalski, Kamil /**
1587f4c4dcf4SKowalski, Kamil  * @internal
1588f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1589f4c4dcf4SKowalski, Kamil  *
1590f4c4dcf4SKowalski, Kamil  * See header file for more information
1591f4c4dcf4SKowalski, Kamil  * @endinternal
1592f4c4dcf4SKowalski, Kamil  */
15931668ce6dSEd Tanous nlohmann::json queryParameterValueFormatError(std::string_view arg1,
15941668ce6dSEd Tanous                                               std::string_view arg2)
15951abe55efSEd Tanous {
1596fffb8c1fSEd Tanous     return getLog(
1597fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueFormatError,
15981668ce6dSEd Tanous         std::to_array({arg1, arg2}));
1599b5c07418SJames Feist }
1600b5c07418SJames Feist 
16011668ce6dSEd Tanous void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
16021668ce6dSEd Tanous                                     std::string_view arg2)
1603b5c07418SJames Feist {
1604b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1605b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1606b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
1607f4c4dcf4SKowalski, Kamil }
1608f4c4dcf4SKowalski, Kamil 
1609f4c4dcf4SKowalski, Kamil /**
1610f4c4dcf4SKowalski, Kamil  * @internal
1611b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
1612b5c07418SJames Feist  * property
1613f12894f8SJason M. Bills  *
1614f12894f8SJason M. Bills  * See header file for more information
1615f12894f8SJason M. Bills  * @endinternal
1616f12894f8SJason M. Bills  */
16171668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1)
1618f12894f8SJason M. Bills {
1619fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyMissing,
16201668ce6dSEd Tanous                   std::to_array({arg1}));
1621b5c07418SJames Feist }
1622b5c07418SJames Feist 
16231668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1)
1624b5c07418SJames Feist {
1625b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1626b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1627f4c4dcf4SKowalski, Kamil }
1628f4c4dcf4SKowalski, Kamil 
1629f4c4dcf4SKowalski, Kamil /**
1630f4c4dcf4SKowalski, Kamil  * @internal
1631f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
1632f4c4dcf4SKowalski, Kamil  *
1633f4c4dcf4SKowalski, Kamil  * See header file for more information
1634f4c4dcf4SKowalski, Kamil  * @endinternal
1635f4c4dcf4SKowalski, Kamil  */
16361668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1)
16371abe55efSEd Tanous {
1638fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceExhaustion,
16391668ce6dSEd Tanous                   std::to_array({arg1}));
1640b5c07418SJames Feist }
1641b5c07418SJames Feist 
16421668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1)
1643b5c07418SJames Feist {
1644b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1645b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1646f4c4dcf4SKowalski, Kamil }
1647f4c4dcf4SKowalski, Kamil 
1648f4c4dcf4SKowalski, Kamil /**
1649f4c4dcf4SKowalski, Kamil  * @internal
1650f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
1651f4c4dcf4SKowalski, Kamil  *
1652f4c4dcf4SKowalski, Kamil  * See header file for more information
1653f4c4dcf4SKowalski, Kamil  * @endinternal
1654f4c4dcf4SKowalski, Kamil  */
1655b5c07418SJames Feist nlohmann::json accountModified(void)
16561abe55efSEd Tanous {
1657fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountModified, {});
1658b5c07418SJames Feist }
1659b5c07418SJames Feist 
1660b5c07418SJames Feist void accountModified(crow::Response& res)
1661b5c07418SJames Feist {
1662b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1663b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
1664f4c4dcf4SKowalski, Kamil }
1665f4c4dcf4SKowalski, Kamil 
1666f4c4dcf4SKowalski, Kamil /**
1667f4c4dcf4SKowalski, Kamil  * @internal
1668f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
1669f4c4dcf4SKowalski, Kamil  *
1670f4c4dcf4SKowalski, Kamil  * See header file for more information
1671f4c4dcf4SKowalski, Kamil  * @endinternal
1672f4c4dcf4SKowalski, Kamil  */
16731668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1,
16741668ce6dSEd Tanous                                         std::string_view arg2,
16751668ce6dSEd Tanous                                         std::string_view arg3)
16761abe55efSEd Tanous {
1677fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
16781668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
1679b5c07418SJames Feist }
1680b5c07418SJames Feist 
16811668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
16821668ce6dSEd Tanous                               std::string_view arg2, std::string_view arg3)
1683b5c07418SJames Feist {
1684b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1685b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1686b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
1687f4c4dcf4SKowalski, Kamil }
1688f4c4dcf4SKowalski, Kamil 
1689b6cd31e1SEd Tanous nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1)
1690b6cd31e1SEd Tanous {
16911668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1692fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::passwordChangeRequired,
16931668ce6dSEd Tanous                   std::to_array({arg1str}));
1694b6cd31e1SEd Tanous }
1695b6cd31e1SEd Tanous 
16963bf4e632SJoseph Reynolds /**
16973bf4e632SJoseph Reynolds  * @internal
16983bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
16993bf4e632SJoseph Reynolds  *
17003bf4e632SJoseph Reynolds  * See header file for more information
17013bf4e632SJoseph Reynolds  * @endinternal
17023bf4e632SJoseph Reynolds  */
1703ace85d60SEd Tanous void passwordChangeRequired(crow::Response& res,
1704ace85d60SEd Tanous                             const boost::urls::url_view& arg1)
17053bf4e632SJoseph Reynolds {
1706b6cd31e1SEd Tanous     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
17073bf4e632SJoseph Reynolds }
17083bf4e632SJoseph Reynolds 
17094cde5d90SJames Feist /**
17104cde5d90SJames Feist  * @internal
1711ae688313SNan Zhou  * @brief Formats InsufficientStorage message into JSON
1712ae688313SNan Zhou  *
1713ae688313SNan Zhou  * See header file for more information
1714ae688313SNan Zhou  * @endinternal
1715ae688313SNan Zhou  */
1716ae688313SNan Zhou nlohmann::json insufficientStorage()
1717ae688313SNan Zhou {
1718ae688313SNan Zhou     return getLog(redfish::registries::base::Index::insufficientStorage, {});
1719ae688313SNan Zhou }
1720ae688313SNan Zhou 
1721ae688313SNan Zhou void insufficientStorage(crow::Response& res)
1722ae688313SNan Zhou {
1723ae688313SNan Zhou     res.result(boost::beast::http::status::insufficient_storage);
1724ae688313SNan Zhou     addMessageToErrorJson(res.jsonValue, insufficientStorage());
1725ae688313SNan Zhou }
1726ae688313SNan Zhou 
1727ae688313SNan Zhou /**
1728ae688313SNan Zhou  * @internal
172944c70412SEd Tanous  * @brief Formats OperationNotAllowed message into JSON
173044c70412SEd Tanous  *
173144c70412SEd Tanous  * See header file for more information
173244c70412SEd Tanous  * @endinternal
173344c70412SEd Tanous  */
173444c70412SEd Tanous nlohmann::json operationNotAllowed()
173544c70412SEd Tanous {
173644c70412SEd Tanous     return getLog(redfish::registries::base::Index::operationNotAllowed, {});
173744c70412SEd Tanous }
173844c70412SEd Tanous 
173944c70412SEd Tanous void operationNotAllowed(crow::Response& res)
174044c70412SEd Tanous {
174144c70412SEd Tanous     res.result(boost::beast::http::status::method_not_allowed);
174244c70412SEd Tanous     addMessageToErrorJson(res.jsonValue, operationNotAllowed());
174344c70412SEd Tanous }
174444c70412SEd Tanous 
174544c70412SEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1,
174644c70412SEd Tanous                    std::string_view arg2)
174744c70412SEd Tanous {
174844c70412SEd Tanous     res.result(boost::beast::http::status::bad_request);
174944c70412SEd Tanous     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
175044c70412SEd Tanous }
175144c70412SEd Tanous 
175244c70412SEd Tanous /**
175344c70412SEd Tanous  * @internal
17544cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
17554cde5d90SJames Feist  *
17564cde5d90SJames Feist  * See header file for more information
17574cde5d90SJames Feist  * @endinternal
17584cde5d90SJames Feist  */
17591668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
17604cde5d90SJames Feist {
17611668ce6dSEd Tanous     std::string msg = "Invalid file uploaded to ";
17621668ce6dSEd Tanous     msg += arg1;
17631668ce6dSEd Tanous     msg += ": ";
17641668ce6dSEd Tanous     msg += arg2;
17651668ce6dSEd Tanous     msg += ".";
1766613dabeaSEd Tanous 
1767613dabeaSEd Tanous     nlohmann::json::object_t ret;
1768613dabeaSEd Tanous     ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message";
1769613dabeaSEd Tanous     ret["MessageId"] = "OpenBMC.0.2.InvalidUpload";
1770613dabeaSEd Tanous     ret["Message"] = std::move(msg);
1771613dabeaSEd Tanous     nlohmann::json::array_t args;
1772613dabeaSEd Tanous     args.push_back(arg1);
1773613dabeaSEd Tanous     args.push_back(arg2);
1774613dabeaSEd Tanous     ret["MessageArgs"] = std::move(args);
1775613dabeaSEd Tanous     ret["MessageSeverity"] = "Warning";
1776613dabeaSEd Tanous     ret["Resolution"] = "None.";
1777613dabeaSEd Tanous     return ret;
17784cde5d90SJames Feist }
1779ae688313SNan Zhou 
1780f4c4dcf4SKowalski, Kamil } // namespace messages
1781f4c4dcf4SKowalski, Kamil 
1782d425c6f6SEd Tanous } // namespace redfish
1783