xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision 1668ce6d0d427088b7bb8ab7c2927763fb57c8c3)
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 */
169ea15c35SEd Tanous #include "http_response.hpp"
17b6cd31e1SEd Tanous #include "registries/base_message_registry.hpp"
189ea15c35SEd Tanous 
199ea15c35SEd Tanous #include <boost/beast/http/status.hpp>
20ace85d60SEd Tanous #include <boost/url/url.hpp>
211abe55efSEd Tanous #include <error_messages.hpp>
2204e438cbSEd Tanous #include <logging.hpp>
239ea15c35SEd Tanous #include <nlohmann/json.hpp>
24f4c4dcf4SKowalski, Kamil 
25*1668ce6dSEd Tanous #include <array>
26*1668ce6dSEd Tanous 
271abe55efSEd Tanous namespace redfish
281abe55efSEd Tanous {
291abe55efSEd Tanous 
301abe55efSEd Tanous namespace messages
311abe55efSEd Tanous {
32f4c4dcf4SKowalski, Kamil 
33f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target,
341abe55efSEd Tanous                                   const nlohmann::json& message)
351abe55efSEd Tanous {
36f4c4dcf4SKowalski, Kamil     auto& error = target["error"];
37f4c4dcf4SKowalski, Kamil 
381abe55efSEd Tanous     // If this is the first error message, fill in the information from the
391abe55efSEd Tanous     // first error message to the top level struct
401abe55efSEd Tanous     if (!error.is_object())
411abe55efSEd Tanous     {
42c074230bSJason M. Bills         auto messageIdIterator = message.find("MessageId");
43c074230bSJason M. Bills         if (messageIdIterator == message.end())
441abe55efSEd Tanous         {
451abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
461abe55efSEd Tanous                 << "Attempt to add error message without MessageId";
47f4c4dcf4SKowalski, Kamil             return;
48f4c4dcf4SKowalski, Kamil         }
49f4c4dcf4SKowalski, Kamil 
50c074230bSJason M. Bills         auto messageFieldIterator = message.find("Message");
51c074230bSJason M. Bills         if (messageFieldIterator == message.end())
521abe55efSEd Tanous         {
531abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
541abe55efSEd Tanous                 << "Attempt to add error message without Message";
55f4c4dcf4SKowalski, Kamil             return;
56f4c4dcf4SKowalski, Kamil         }
57c21055aaSEd Tanous         error = {{"code", *messageIdIterator},
58c21055aaSEd Tanous                  {"message", *messageFieldIterator}};
591abe55efSEd Tanous     }
601abe55efSEd Tanous     else
611abe55efSEd Tanous     {
62f4c4dcf4SKowalski, Kamil         // More than 1 error occurred, so the message has to be generic
6355c7b7a2SEd Tanous         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
64cc9139ecSJason M. Bills         error["message"] = "A general error has occurred. See Resolution for "
65cc9139ecSJason M. Bills                            "information on how to resolve the error.";
66f4c4dcf4SKowalski, Kamil     }
67f4c4dcf4SKowalski, Kamil 
68f4c4dcf4SKowalski, Kamil     // This check could technically be done in in the default construction
69f4c4dcf4SKowalski, Kamil     // branch above, but because we need the pointer to the extended info field
70f4c4dcf4SKowalski, Kamil     // anyway, it's more efficient to do it here.
71c074230bSJason M. Bills     auto& extendedInfo = error[messages::messageAnnotation];
72c074230bSJason M. Bills     if (!extendedInfo.is_array())
731abe55efSEd Tanous     {
74c074230bSJason M. Bills         extendedInfo = nlohmann::json::array();
75f4c4dcf4SKowalski, Kamil     }
76f4c4dcf4SKowalski, Kamil 
77c074230bSJason M. Bills     extendedInfo.push_back(message);
78f4c4dcf4SKowalski, Kamil }
79f4c4dcf4SKowalski, Kamil 
80f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target,
81f12894f8SJason M. Bills                                  const nlohmann::json& message)
821abe55efSEd Tanous {
831abe55efSEd Tanous     if (!target[messages::messageAnnotation].is_array())
841abe55efSEd Tanous     {
85f4c4dcf4SKowalski, Kamil         // Force object to be an array
8655c7b7a2SEd Tanous         target[messages::messageAnnotation] = nlohmann::json::array();
87f4c4dcf4SKowalski, Kamil     }
88f4c4dcf4SKowalski, Kamil 
8955c7b7a2SEd Tanous     target[messages::messageAnnotation].push_back(message);
90f4c4dcf4SKowalski, Kamil }
91f4c4dcf4SKowalski, Kamil 
92f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target,
93f12894f8SJason M. Bills                              const nlohmann::json& message,
94*1668ce6dSEd Tanous                              std::string_view fieldPath)
951abe55efSEd Tanous {
96*1668ce6dSEd Tanous     std::string extendedInfo(fieldPath);
97*1668ce6dSEd Tanous     extendedInfo += messages::messageAnnotation;
98f4c4dcf4SKowalski, Kamil 
99*1668ce6dSEd Tanous     nlohmann::json& field = target[extendedInfo];
100*1668ce6dSEd Tanous     if (!field.is_array())
1011abe55efSEd Tanous     {
102f4c4dcf4SKowalski, Kamil         // Force object to be an array
103*1668ce6dSEd Tanous         field = nlohmann::json::array();
104f4c4dcf4SKowalski, Kamil     }
105f4c4dcf4SKowalski, Kamil 
106f4c4dcf4SKowalski, Kamil     // Object exists and it is an array so we can just push in the message
107*1668ce6dSEd Tanous     field.push_back(message);
108f4c4dcf4SKowalski, Kamil }
109f4c4dcf4SKowalski, Kamil 
110b6cd31e1SEd Tanous nlohmann::json getLog(redfish::message_registries::base::Index name,
111b6cd31e1SEd Tanous                       std::span<const std::string_view> args)
112b6cd31e1SEd Tanous {
113b6cd31e1SEd Tanous     size_t index = static_cast<size_t>(name);
114b6cd31e1SEd Tanous     if (index >= redfish::message_registries::base::registry.size())
115b6cd31e1SEd Tanous     {
116b6cd31e1SEd Tanous         return {};
117b6cd31e1SEd Tanous     }
118b6cd31e1SEd Tanous     const redfish::message_registries::MessageEntry& entry =
119b6cd31e1SEd Tanous         redfish::message_registries::base::registry[index];
120b6cd31e1SEd Tanous     // Intentionally make a copy of the string, so we can append in the
121b6cd31e1SEd Tanous     // parameters.
122b6cd31e1SEd Tanous     std::string msg = entry.second.message;
123b6cd31e1SEd Tanous     redfish::message_registries::fillMessageArgs(args, msg);
124b6cd31e1SEd Tanous     nlohmann::json jArgs = nlohmann::json::array();
125b6cd31e1SEd Tanous     for (const std::string_view arg : args)
126b6cd31e1SEd Tanous     {
127b6cd31e1SEd Tanous         jArgs.push_back(arg);
128b6cd31e1SEd Tanous     }
129b6cd31e1SEd Tanous     std::string msgId = redfish::message_registries::base::header.id;
130b6cd31e1SEd Tanous     msgId += ".";
131b6cd31e1SEd Tanous     msgId += entry.first;
132b6cd31e1SEd Tanous     return {{"@odata.type", "#Message.v1_1_1.Message"},
133b6cd31e1SEd Tanous             {"MessageId", std::move(msgId)},
134b6cd31e1SEd Tanous             {"Message", std::move(msg)},
135b6cd31e1SEd Tanous             {"MessageArgs", std::move(jArgs)},
136b6cd31e1SEd Tanous             {"MessageSeverity", entry.second.severity},
137b6cd31e1SEd Tanous             {"Resolution", entry.second.resolution}};
138b6cd31e1SEd Tanous }
139b6cd31e1SEd Tanous 
140f4c4dcf4SKowalski, Kamil /**
141f4c4dcf4SKowalski, Kamil  * @internal
142f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
143f4c4dcf4SKowalski, Kamil  *
144f4c4dcf4SKowalski, Kamil  * See header file for more information
145f4c4dcf4SKowalski, Kamil  * @endinternal
146f4c4dcf4SKowalski, Kamil  */
147b5c07418SJames Feist nlohmann::json resourceInUse(void)
1481abe55efSEd Tanous {
149b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resourceInUse, {});
150b5c07418SJames Feist }
151b5c07418SJames Feist 
152b5c07418SJames Feist void resourceInUse(crow::Response& res)
153b5c07418SJames Feist {
154b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
155b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
156f4c4dcf4SKowalski, Kamil }
157f4c4dcf4SKowalski, Kamil 
158f4c4dcf4SKowalski, Kamil /**
159f4c4dcf4SKowalski, Kamil  * @internal
160f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
161f4c4dcf4SKowalski, Kamil  *
162f4c4dcf4SKowalski, Kamil  * See header file for more information
163f4c4dcf4SKowalski, Kamil  * @endinternal
164f4c4dcf4SKowalski, Kamil  */
165b5c07418SJames Feist nlohmann::json malformedJSON(void)
1661abe55efSEd Tanous {
167b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::malformedJSON, {});
168b5c07418SJames Feist }
169b5c07418SJames Feist 
170b5c07418SJames Feist void malformedJSON(crow::Response& res)
171b5c07418SJames Feist {
172b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
173b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
174f4c4dcf4SKowalski, Kamil }
175f4c4dcf4SKowalski, Kamil 
176f4c4dcf4SKowalski, Kamil /**
177f4c4dcf4SKowalski, Kamil  * @internal
178f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
179f4c4dcf4SKowalski, Kamil  *
180f4c4dcf4SKowalski, Kamil  * See header file for more information
181f4c4dcf4SKowalski, Kamil  * @endinternal
182f4c4dcf4SKowalski, Kamil  */
183ace85d60SEd Tanous nlohmann::json resourceMissingAtURI(const boost::urls::url_view& arg1)
1841abe55efSEd Tanous {
185b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
186b6cd31e1SEd Tanous         std::string_view{arg1.data(), arg1.size()}};
187b6cd31e1SEd Tanous     return getLog(
188b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceMissingAtURI, args);
189b5c07418SJames Feist }
190b5c07418SJames Feist 
191ace85d60SEd Tanous void resourceMissingAtURI(crow::Response& res,
192ace85d60SEd Tanous                           const boost::urls::url_view& arg1)
193b5c07418SJames Feist {
194b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
195b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
196f4c4dcf4SKowalski, Kamil }
197f4c4dcf4SKowalski, Kamil 
198f4c4dcf4SKowalski, Kamil /**
199f4c4dcf4SKowalski, Kamil  * @internal
200f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
201f4c4dcf4SKowalski, Kamil  *
202f4c4dcf4SKowalski, Kamil  * See header file for more information
203f4c4dcf4SKowalski, Kamil  * @endinternal
204f4c4dcf4SKowalski, Kamil  */
205*1668ce6dSEd Tanous nlohmann::json actionParameterValueFormatError(std::string_view arg1,
206*1668ce6dSEd Tanous                                                std::string_view arg2,
207*1668ce6dSEd Tanous                                                std::string_view arg3)
2081abe55efSEd Tanous {
209b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::
210b6cd31e1SEd Tanous                       actionParameterValueFormatError,
211*1668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
212b5c07418SJames Feist }
213b5c07418SJames Feist 
214*1668ce6dSEd Tanous void actionParameterValueFormatError(crow::Response& res, std::string_view arg1,
215*1668ce6dSEd Tanous                                      std::string_view arg2,
216*1668ce6dSEd Tanous                                      std::string_view arg3)
217b5c07418SJames Feist {
218b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
219b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
220b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
221f4c4dcf4SKowalski, Kamil }
222f4c4dcf4SKowalski, Kamil 
223f4c4dcf4SKowalski, Kamil /**
224f4c4dcf4SKowalski, Kamil  * @internal
225f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
226f4c4dcf4SKowalski, Kamil  *
227f4c4dcf4SKowalski, Kamil  * See header file for more information
228f4c4dcf4SKowalski, Kamil  * @endinternal
229f4c4dcf4SKowalski, Kamil  */
230b5c07418SJames Feist nlohmann::json internalError(void)
2311abe55efSEd Tanous {
232b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::internalError, {});
233b5c07418SJames Feist }
234b5c07418SJames Feist 
235df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location)
236b5c07418SJames Feist {
237df5415fcSEd Tanous     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
238df5415fcSEd Tanous                         << location.line() << ":" << location.column() << ") `"
239df5415fcSEd Tanous                         << location.function_name() << "`: ";
240b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
241b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
242f12894f8SJason M. Bills }
243f12894f8SJason M. Bills 
244f12894f8SJason M. Bills /**
245f12894f8SJason M. Bills  * @internal
246f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
247f4c4dcf4SKowalski, Kamil  *
248f4c4dcf4SKowalski, Kamil  * See header file for more information
249f4c4dcf4SKowalski, Kamil  * @endinternal
250f4c4dcf4SKowalski, Kamil  */
251b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void)
2521abe55efSEd Tanous {
253b6cd31e1SEd Tanous     return getLog(
254b6cd31e1SEd Tanous         redfish::message_registries::base::Index::unrecognizedRequestBody, {});
255b5c07418SJames Feist }
256b5c07418SJames Feist 
257b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
258b5c07418SJames Feist {
259b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
260b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
261f4c4dcf4SKowalski, Kamil }
262f4c4dcf4SKowalski, Kamil 
263f4c4dcf4SKowalski, Kamil /**
264f4c4dcf4SKowalski, Kamil  * @internal
265f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
266f4c4dcf4SKowalski, Kamil  *
267f4c4dcf4SKowalski, Kamil  * See header file for more information
268f4c4dcf4SKowalski, Kamil  * @endinternal
269f4c4dcf4SKowalski, Kamil  */
270ace85d60SEd Tanous nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1,
271*1668ce6dSEd Tanous                                          std::string_view arg2)
2721abe55efSEd Tanous {
273b6cd31e1SEd Tanous     return getLog(
274b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceAtUriUnauthorized,
275*1668ce6dSEd Tanous         std::to_array({std::string_view{arg1.data(), arg1.size()}, arg2}));
276b5c07418SJames Feist }
277b5c07418SJames Feist 
278ace85d60SEd Tanous void resourceAtUriUnauthorized(crow::Response& res,
279ace85d60SEd Tanous                                const boost::urls::url_view& arg1,
280*1668ce6dSEd Tanous                                std::string_view arg2)
281b5c07418SJames Feist {
282b5c07418SJames Feist     res.result(boost::beast::http::status::unauthorized);
283b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
284f4c4dcf4SKowalski, Kamil }
285f4c4dcf4SKowalski, Kamil 
286f4c4dcf4SKowalski, Kamil /**
287f4c4dcf4SKowalski, Kamil  * @internal
288f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterUnknown message into JSON
289f4c4dcf4SKowalski, Kamil  *
290f4c4dcf4SKowalski, Kamil  * See header file for more information
291f4c4dcf4SKowalski, Kamil  * @endinternal
292f4c4dcf4SKowalski, Kamil  */
293*1668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1,
294*1668ce6dSEd Tanous                                       std::string_view arg2)
295b5c07418SJames Feist {
296b6cd31e1SEd Tanous     return getLog(
297*1668ce6dSEd Tanous         redfish::message_registries::base::Index::actionParameterUnknown,
298*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
299b5c07418SJames Feist }
300b5c07418SJames Feist 
301*1668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1,
302*1668ce6dSEd Tanous                             std::string_view arg2)
3031abe55efSEd Tanous {
304f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
305b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
306f4c4dcf4SKowalski, Kamil }
307f4c4dcf4SKowalski, Kamil 
308f4c4dcf4SKowalski, Kamil /**
309f4c4dcf4SKowalski, Kamil  * @internal
310f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceCannotBeDeleted message into JSON
311f4c4dcf4SKowalski, Kamil  *
312f4c4dcf4SKowalski, Kamil  * See header file for more information
313f4c4dcf4SKowalski, Kamil  * @endinternal
314f4c4dcf4SKowalski, Kamil  */
315b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void)
3161abe55efSEd Tanous {
317b6cd31e1SEd Tanous     return getLog(
318b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceCannotBeDeleted, {});
319b5c07418SJames Feist }
320b5c07418SJames Feist 
321b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res)
322b5c07418SJames Feist {
323b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
324b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
325f4c4dcf4SKowalski, Kamil }
326f4c4dcf4SKowalski, Kamil 
327f4c4dcf4SKowalski, Kamil /**
328f4c4dcf4SKowalski, Kamil  * @internal
329f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyDuplicate message into JSON
330f4c4dcf4SKowalski, Kamil  *
331f4c4dcf4SKowalski, Kamil  * See header file for more information
332f4c4dcf4SKowalski, Kamil  * @endinternal
333f4c4dcf4SKowalski, Kamil  */
334*1668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1)
3351abe55efSEd Tanous {
336b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::propertyDuplicate,
337*1668ce6dSEd Tanous                   std::to_array({arg1}));
338b5c07418SJames Feist }
339b5c07418SJames Feist 
340*1668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1)
341b5c07418SJames Feist {
342b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
343b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
344f4c4dcf4SKowalski, Kamil }
345f4c4dcf4SKowalski, Kamil 
346f4c4dcf4SKowalski, Kamil /**
347f4c4dcf4SKowalski, Kamil  * @internal
348f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
349f4c4dcf4SKowalski, Kamil  *
350f4c4dcf4SKowalski, Kamil  * See header file for more information
351f4c4dcf4SKowalski, Kamil  * @endinternal
352f4c4dcf4SKowalski, Kamil  */
353*1668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
3541abe55efSEd Tanous {
355b6cd31e1SEd Tanous     return getLog(
356b6cd31e1SEd Tanous         redfish::message_registries::base::Index::serviceTemporarilyUnavailable,
357*1668ce6dSEd Tanous         std::to_array({arg1}));
358b5c07418SJames Feist }
359b5c07418SJames Feist 
360*1668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
361b5c07418SJames Feist {
362b5c07418SJames Feist     res.addHeader("Retry-After", arg1);
363b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
364b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
365f4c4dcf4SKowalski, Kamil }
366f4c4dcf4SKowalski, Kamil 
367f4c4dcf4SKowalski, Kamil /**
368f4c4dcf4SKowalski, Kamil  * @internal
369f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
370f4c4dcf4SKowalski, Kamil  *
371f4c4dcf4SKowalski, Kamil  * See header file for more information
372f4c4dcf4SKowalski, Kamil  * @endinternal
373f4c4dcf4SKowalski, Kamil  */
374*1668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1,
375*1668ce6dSEd Tanous                                      std::string_view arg2,
376*1668ce6dSEd Tanous                                      std::string_view arg3)
3771abe55efSEd Tanous {
378b6cd31e1SEd Tanous     return getLog(
379*1668ce6dSEd Tanous         redfish::message_registries::base::Index::resourceAlreadyExists,
380*1668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
381b5c07418SJames Feist }
382b5c07418SJames Feist 
383*1668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
384*1668ce6dSEd Tanous                            std::string_view arg2, std::string_view arg3)
385b5c07418SJames Feist {
386b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
387b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
388a08b46ccSJason M. Bills                      arg2);
389f4c4dcf4SKowalski, Kamil }
390f4c4dcf4SKowalski, Kamil 
391f4c4dcf4SKowalski, Kamil /**
392f4c4dcf4SKowalski, Kamil  * @internal
393f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
394f4c4dcf4SKowalski, Kamil  *
395f4c4dcf4SKowalski, Kamil  * See header file for more information
396f4c4dcf4SKowalski, Kamil  * @endinternal
397f4c4dcf4SKowalski, Kamil  */
398b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void)
3991abe55efSEd Tanous {
400b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::
401b6cd31e1SEd Tanous                       accountForSessionNoLongerExists,
402b6cd31e1SEd Tanous                   {});
403b5c07418SJames Feist }
404b5c07418SJames Feist 
405b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
406b5c07418SJames Feist {
407b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
408b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
409f4c4dcf4SKowalski, Kamil }
410f4c4dcf4SKowalski, Kamil 
411f4c4dcf4SKowalski, Kamil /**
412f4c4dcf4SKowalski, Kamil  * @internal
413f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
414f4c4dcf4SKowalski, Kamil  *
415f4c4dcf4SKowalski, Kamil  * See header file for more information
416f4c4dcf4SKowalski, Kamil  * @endinternal
417f4c4dcf4SKowalski, Kamil  */
418*1668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
4191abe55efSEd Tanous {
420b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::
421b6cd31e1SEd Tanous                       createFailedMissingReqProperties,
422*1668ce6dSEd Tanous                   std::to_array({arg1}));
423b5c07418SJames Feist }
424b5c07418SJames Feist 
425b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
426*1668ce6dSEd Tanous                                       std::string_view arg1)
427b5c07418SJames Feist {
428b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
429b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
430a08b46ccSJason M. Bills                      arg1);
431f12894f8SJason M. Bills }
432f12894f8SJason M. Bills 
433f12894f8SJason M. Bills /**
434f12894f8SJason M. Bills  * @internal
435f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
436f12894f8SJason M. Bills  * property
437f12894f8SJason M. Bills  *
438f12894f8SJason M. Bills  * See header file for more information
439f12894f8SJason M. Bills  * @endinternal
440f12894f8SJason M. Bills  */
441*1668ce6dSEd Tanous nlohmann::json propertyValueFormatError(std::string_view arg1,
442*1668ce6dSEd Tanous                                         std::string_view arg2)
443f12894f8SJason M. Bills {
444b6cd31e1SEd Tanous     return getLog(
445b6cd31e1SEd Tanous         redfish::message_registries::base::Index::propertyValueFormatError,
446*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
447b5c07418SJames Feist }
448b5c07418SJames Feist 
449*1668ce6dSEd Tanous void propertyValueFormatError(crow::Response& res, std::string_view arg1,
450*1668ce6dSEd Tanous                               std::string_view arg2)
451b5c07418SJames Feist {
452b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
453b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
454f12894f8SJason M. Bills }
455f12894f8SJason M. Bills 
456f12894f8SJason M. Bills /**
457f12894f8SJason M. Bills  * @internal
458f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
459f12894f8SJason M. Bills  * property
460f12894f8SJason M. Bills  *
461f12894f8SJason M. Bills  * See header file for more information
462f12894f8SJason M. Bills  * @endinternal
463f12894f8SJason M. Bills  */
464*1668ce6dSEd Tanous nlohmann::json propertyValueNotInList(std::string_view arg1,
465*1668ce6dSEd Tanous                                       std::string_view arg2)
466f12894f8SJason M. Bills {
467b6cd31e1SEd Tanous     return getLog(
468*1668ce6dSEd Tanous         redfish::message_registries::base::Index::propertyValueNotInList,
469*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
470b5c07418SJames Feist }
471b5c07418SJames Feist 
472*1668ce6dSEd Tanous void propertyValueNotInList(crow::Response& res, std::string_view arg1,
473*1668ce6dSEd Tanous                             std::string_view arg2)
474b5c07418SJames Feist {
475b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
476b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
477f4c4dcf4SKowalski, Kamil }
478f4c4dcf4SKowalski, Kamil 
479f4c4dcf4SKowalski, Kamil /**
480f4c4dcf4SKowalski, Kamil  * @internal
481f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
482f4c4dcf4SKowalski, Kamil  *
483f4c4dcf4SKowalski, Kamil  * See header file for more information
484f4c4dcf4SKowalski, Kamil  * @endinternal
485f4c4dcf4SKowalski, Kamil  */
486ace85d60SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1)
4871abe55efSEd Tanous {
488*1668ce6dSEd Tanous     std::string_view arg1str{arg1.data(), arg1.size()};
489b6cd31e1SEd Tanous     return getLog(
490b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceAtUriInUnknownFormat,
491*1668ce6dSEd Tanous         std::to_array({arg1str}));
492b5c07418SJames Feist }
493b5c07418SJames Feist 
494ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res,
495ace85d60SEd Tanous                                   const boost::urls::url_view& arg1)
496b5c07418SJames Feist {
497b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
498b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
499f4c4dcf4SKowalski, Kamil }
500f4c4dcf4SKowalski, Kamil 
501f4c4dcf4SKowalski, Kamil /**
502f4c4dcf4SKowalski, Kamil  * @internal
50381856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
50481856681SAsmitha Karunanithi  *
50581856681SAsmitha Karunanithi  * See header file for more information
50681856681SAsmitha Karunanithi  * @endinternal
50781856681SAsmitha Karunanithi  */
508*1668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1)
50981856681SAsmitha Karunanithi {
510b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::serviceDisabled,
511*1668ce6dSEd Tanous                   std::to_array({arg1}));
51281856681SAsmitha Karunanithi }
51381856681SAsmitha Karunanithi 
514*1668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1)
51581856681SAsmitha Karunanithi {
51681856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
51781856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
51881856681SAsmitha Karunanithi }
51981856681SAsmitha Karunanithi 
52081856681SAsmitha Karunanithi /**
52181856681SAsmitha Karunanithi  * @internal
522f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
523f4c4dcf4SKowalski, Kamil  *
524f4c4dcf4SKowalski, Kamil  * See header file for more information
525f4c4dcf4SKowalski, Kamil  * @endinternal
526f4c4dcf4SKowalski, Kamil  */
527b5c07418SJames Feist nlohmann::json serviceInUnknownState(void)
5281abe55efSEd Tanous {
529b6cd31e1SEd Tanous     return getLog(
530b6cd31e1SEd Tanous         redfish::message_registries::base::Index::serviceInUnknownState, {});
531b5c07418SJames Feist }
532b5c07418SJames Feist 
533b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
534b5c07418SJames Feist {
535b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
536b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
537f4c4dcf4SKowalski, Kamil }
538f4c4dcf4SKowalski, Kamil 
539f4c4dcf4SKowalski, Kamil /**
540f4c4dcf4SKowalski, Kamil  * @internal
541f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
542f4c4dcf4SKowalski, Kamil  *
543f4c4dcf4SKowalski, Kamil  * See header file for more information
544f4c4dcf4SKowalski, Kamil  * @endinternal
545f4c4dcf4SKowalski, Kamil  */
546b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void)
5471abe55efSEd Tanous {
548b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::
549b6cd31e1SEd Tanous                       eventSubscriptionLimitExceeded,
550b6cd31e1SEd Tanous                   {});
551b5c07418SJames Feist }
552b5c07418SJames Feist 
553b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
554b5c07418SJames Feist {
555789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
556b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
557f4c4dcf4SKowalski, Kamil }
558f4c4dcf4SKowalski, Kamil 
559f4c4dcf4SKowalski, Kamil /**
560f4c4dcf4SKowalski, Kamil  * @internal
561f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
562f4c4dcf4SKowalski, Kamil  *
563f4c4dcf4SKowalski, Kamil  * See header file for more information
564f4c4dcf4SKowalski, Kamil  * @endinternal
565f4c4dcf4SKowalski, Kamil  */
566*1668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1,
567*1668ce6dSEd Tanous                                       std::string_view arg2)
5681abe55efSEd Tanous {
569b6cd31e1SEd Tanous     return getLog(
570*1668ce6dSEd Tanous         redfish::message_registries::base::Index::actionParameterMissing,
571*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
572b5c07418SJames Feist }
573b5c07418SJames Feist 
574*1668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1,
575*1668ce6dSEd Tanous                             std::string_view arg2)
576b5c07418SJames Feist {
577b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
578b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
579f4c4dcf4SKowalski, Kamil }
580f4c4dcf4SKowalski, Kamil 
581f4c4dcf4SKowalski, Kamil /**
582f4c4dcf4SKowalski, Kamil  * @internal
583f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
584f4c4dcf4SKowalski, Kamil  *
585f4c4dcf4SKowalski, Kamil  * See header file for more information
586f4c4dcf4SKowalski, Kamil  * @endinternal
587f4c4dcf4SKowalski, Kamil  */
588*1668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
5891abe55efSEd Tanous {
590b6cd31e1SEd Tanous     std::string arg2String = std::to_string(arg2);
591b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::stringValueTooLong,
592*1668ce6dSEd Tanous                   std::to_array({arg1, std::string_view(arg2String)}));
593b5c07418SJames Feist }
594b5c07418SJames Feist 
595*1668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
596b5c07418SJames Feist {
597b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
598b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
599f4c4dcf4SKowalski, Kamil }
600f4c4dcf4SKowalski, Kamil 
601f4c4dcf4SKowalski, Kamil /**
602f4c4dcf4SKowalski, Kamil  * @internal
603cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
604cc9139ecSJason M. Bills  *
605cc9139ecSJason M. Bills  * See header file for more information
606cc9139ecSJason M. Bills  * @endinternal
607cc9139ecSJason M. Bills  */
608b5c07418SJames Feist nlohmann::json sessionTerminated(void)
609cc9139ecSJason M. Bills {
610b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::sessionTerminated,
611b6cd31e1SEd Tanous                   {});
612b5c07418SJames Feist }
613b5c07418SJames Feist 
614b5c07418SJames Feist void sessionTerminated(crow::Response& res)
615b5c07418SJames Feist {
616b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
617b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
618cc9139ecSJason M. Bills }
619cc9139ecSJason M. Bills 
620cc9139ecSJason M. Bills /**
621cc9139ecSJason M. Bills  * @internal
622684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
623684bb4b8SJason M. Bills  *
624684bb4b8SJason M. Bills  * See header file for more information
625684bb4b8SJason M. Bills  * @endinternal
626684bb4b8SJason M. Bills  */
627684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void)
628684bb4b8SJason M. Bills {
629b6cd31e1SEd Tanous     return getLog(
630b6cd31e1SEd Tanous         redfish::message_registries::base::Index::subscriptionTerminated, {});
631684bb4b8SJason M. Bills }
632684bb4b8SJason M. Bills 
633684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
634684bb4b8SJason M. Bills {
635684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
636684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
637684bb4b8SJason M. Bills }
638684bb4b8SJason M. Bills 
639684bb4b8SJason M. Bills /**
640684bb4b8SJason M. Bills  * @internal
641cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
642cc9139ecSJason M. Bills  *
643cc9139ecSJason M. Bills  * See header file for more information
644cc9139ecSJason M. Bills  * @endinternal
645cc9139ecSJason M. Bills  */
646*1668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1,
647*1668ce6dSEd Tanous                                         std::string_view arg2)
648cc9139ecSJason M. Bills {
649b6cd31e1SEd Tanous     return getLog(
650b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceTypeIncompatible,
651*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
652b5c07418SJames Feist }
653b5c07418SJames Feist 
654*1668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
655*1668ce6dSEd Tanous                               std::string_view arg2)
656b5c07418SJames Feist {
657b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
658b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
659cc9139ecSJason M. Bills }
660cc9139ecSJason M. Bills 
661cc9139ecSJason M. Bills /**
662cc9139ecSJason M. Bills  * @internal
663684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
664684bb4b8SJason M. Bills  *
665684bb4b8SJason M. Bills  * See header file for more information
666684bb4b8SJason M. Bills  * @endinternal
667684bb4b8SJason M. Bills  */
668ace85d60SEd Tanous nlohmann::json resetRequired(const boost::urls::url_view& arg1,
669*1668ce6dSEd Tanous                              std::string_view arg2)
670684bb4b8SJason M. Bills {
671*1668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
672b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resetRequired,
673*1668ce6dSEd Tanous                   std::to_array({arg1str, arg2}));
674684bb4b8SJason M. Bills }
675684bb4b8SJason M. Bills 
676ace85d60SEd Tanous void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
677*1668ce6dSEd Tanous                    std::string_view arg2)
678684bb4b8SJason M. Bills {
679684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
680684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
681684bb4b8SJason M. Bills }
682684bb4b8SJason M. Bills 
683684bb4b8SJason M. Bills /**
684684bb4b8SJason M. Bills  * @internal
685684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
686684bb4b8SJason M. Bills  *
687684bb4b8SJason M. Bills  * See header file for more information
688684bb4b8SJason M. Bills  * @endinternal
689684bb4b8SJason M. Bills  */
690*1668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
691684bb4b8SJason M. Bills {
692b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resetRequired,
693*1668ce6dSEd Tanous                   std::to_array({arg1}));
694684bb4b8SJason M. Bills }
695684bb4b8SJason M. Bills 
696*1668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
697684bb4b8SJason M. Bills {
698684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
699684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
700684bb4b8SJason M. Bills }
701684bb4b8SJason M. Bills 
702684bb4b8SJason M. Bills /**
703684bb4b8SJason M. Bills  * @internal
704684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
705684bb4b8SJason M. Bills  *
706684bb4b8SJason M. Bills  * See header file for more information
707684bb4b8SJason M. Bills  * @endinternal
708684bb4b8SJason M. Bills  */
709*1668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
710684bb4b8SJason M. Bills {
711b6cd31e1SEd Tanous     return getLog(
712b6cd31e1SEd Tanous         redfish::message_registries::base::Index::chassisPowerStateOffRequired,
713*1668ce6dSEd Tanous         std::to_array({arg1}));
714684bb4b8SJason M. Bills }
715684bb4b8SJason M. Bills 
716*1668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1)
717684bb4b8SJason M. Bills {
718684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
719684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
720684bb4b8SJason M. Bills }
721684bb4b8SJason M. Bills 
722684bb4b8SJason M. Bills /**
723684bb4b8SJason M. Bills  * @internal
724684bb4b8SJason M. Bills  * @brief Formats PropertyValueConflict message into JSON
725684bb4b8SJason M. Bills  *
726684bb4b8SJason M. Bills  * See header file for more information
727684bb4b8SJason M. Bills  * @endinternal
728684bb4b8SJason M. Bills  */
729*1668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1,
730*1668ce6dSEd Tanous                                      std::string_view arg2)
731684bb4b8SJason M. Bills {
732b6cd31e1SEd Tanous     return getLog(
733*1668ce6dSEd Tanous         redfish::message_registries::base::Index::propertyValueConflict,
734*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
735684bb4b8SJason M. Bills }
736684bb4b8SJason M. Bills 
737*1668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1,
738*1668ce6dSEd Tanous                            std::string_view arg2)
739684bb4b8SJason M. Bills {
740684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
741684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
742684bb4b8SJason M. Bills }
743684bb4b8SJason M. Bills 
744684bb4b8SJason M. Bills /**
745684bb4b8SJason M. Bills  * @internal
746684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
747684bb4b8SJason M. Bills  *
748684bb4b8SJason M. Bills  * See header file for more information
749684bb4b8SJason M. Bills  * @endinternal
750684bb4b8SJason M. Bills  */
751*1668ce6dSEd Tanous nlohmann::json propertyValueIncorrect(std::string_view arg1,
752*1668ce6dSEd Tanous                                       std::string_view arg2)
753684bb4b8SJason M. Bills {
754b6cd31e1SEd Tanous     return getLog(
755*1668ce6dSEd Tanous         redfish::message_registries::base::Index::propertyValueIncorrect,
756*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
757684bb4b8SJason M. Bills }
758684bb4b8SJason M. Bills 
759*1668ce6dSEd Tanous void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
760*1668ce6dSEd Tanous                             std::string_view arg2)
761684bb4b8SJason M. Bills {
762684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
763684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
764684bb4b8SJason M. Bills }
765684bb4b8SJason M. Bills 
766684bb4b8SJason M. Bills /**
767684bb4b8SJason M. Bills  * @internal
768684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
769684bb4b8SJason M. Bills  *
770684bb4b8SJason M. Bills  * See header file for more information
771684bb4b8SJason M. Bills  * @endinternal
772684bb4b8SJason M. Bills  */
773ace85d60SEd Tanous nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1)
774684bb4b8SJason M. Bills {
775*1668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
776b6cd31e1SEd Tanous     return getLog(
777b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceCreationConflict,
778*1668ce6dSEd Tanous         std::to_array({arg1str}));
779684bb4b8SJason M. Bills }
780684bb4b8SJason M. Bills 
781ace85d60SEd Tanous void resourceCreationConflict(crow::Response& res,
782ace85d60SEd Tanous                               const boost::urls::url_view& arg1)
783684bb4b8SJason M. Bills {
784684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
785684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
786684bb4b8SJason M. Bills }
787684bb4b8SJason M. Bills 
788684bb4b8SJason M. Bills /**
789684bb4b8SJason M. Bills  * @internal
790684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded message into JSON
791684bb4b8SJason M. Bills  *
792684bb4b8SJason M. Bills  * See header file for more information
793684bb4b8SJason M. Bills  * @endinternal
794684bb4b8SJason M. Bills  */
795684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void)
796684bb4b8SJason M. Bills {
797b6cd31e1SEd Tanous     return getLog(
798b6cd31e1SEd Tanous         redfish::message_registries::base::Index::maximumErrorsExceeded, {});
799684bb4b8SJason M. Bills }
800684bb4b8SJason M. Bills 
801684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
802684bb4b8SJason M. Bills {
803684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
804684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
805684bb4b8SJason M. Bills }
806684bb4b8SJason M. Bills 
807684bb4b8SJason M. Bills /**
808684bb4b8SJason M. Bills  * @internal
809684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
810684bb4b8SJason M. Bills  *
811684bb4b8SJason M. Bills  * See header file for more information
812684bb4b8SJason M. Bills  * @endinternal
813684bb4b8SJason M. Bills  */
814684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void)
815684bb4b8SJason M. Bills {
816b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::preconditionFailed,
817b6cd31e1SEd Tanous                   {});
818684bb4b8SJason M. Bills }
819684bb4b8SJason M. Bills 
820684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
821684bb4b8SJason M. Bills {
8224df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
823684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
824684bb4b8SJason M. Bills }
825684bb4b8SJason M. Bills 
826684bb4b8SJason M. Bills /**
827684bb4b8SJason M. Bills  * @internal
828684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
829684bb4b8SJason M. Bills  *
830684bb4b8SJason M. Bills  * See header file for more information
831684bb4b8SJason M. Bills  * @endinternal
832684bb4b8SJason M. Bills  */
833684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void)
834684bb4b8SJason M. Bills {
835b6cd31e1SEd Tanous     return getLog(
836b6cd31e1SEd Tanous         redfish::message_registries::base::Index::preconditionRequired, {});
837684bb4b8SJason M. Bills }
838684bb4b8SJason M. Bills 
839684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
840684bb4b8SJason M. Bills {
841684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
842684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
843684bb4b8SJason M. Bills }
844684bb4b8SJason M. Bills 
845684bb4b8SJason M. Bills /**
846684bb4b8SJason M. Bills  * @internal
847684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
848684bb4b8SJason M. Bills  *
849684bb4b8SJason M. Bills  * See header file for more information
850684bb4b8SJason M. Bills  * @endinternal
851684bb4b8SJason M. Bills  */
852684bb4b8SJason M. Bills nlohmann::json operationFailed(void)
853684bb4b8SJason M. Bills {
854b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::operationFailed,
855b6cd31e1SEd Tanous                   {});
856684bb4b8SJason M. Bills }
857684bb4b8SJason M. Bills 
858684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
859684bb4b8SJason M. Bills {
860684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
861684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
862684bb4b8SJason M. Bills }
863684bb4b8SJason M. Bills 
864684bb4b8SJason M. Bills /**
865684bb4b8SJason M. Bills  * @internal
866684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
867684bb4b8SJason M. Bills  *
868684bb4b8SJason M. Bills  * See header file for more information
869684bb4b8SJason M. Bills  * @endinternal
870684bb4b8SJason M. Bills  */
871684bb4b8SJason M. Bills nlohmann::json operationTimeout(void)
872684bb4b8SJason M. Bills {
873b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::operationTimeout,
874b6cd31e1SEd Tanous                   {});
875684bb4b8SJason M. Bills }
876684bb4b8SJason M. Bills 
877684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
878684bb4b8SJason M. Bills {
879684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
880684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
881684bb4b8SJason M. Bills }
882684bb4b8SJason M. Bills 
883684bb4b8SJason M. Bills /**
884684bb4b8SJason M. Bills  * @internal
885f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
886f12894f8SJason M. Bills  * property
887f12894f8SJason M. Bills  *
888f12894f8SJason M. Bills  * See header file for more information
889f12894f8SJason M. Bills  * @endinternal
890f12894f8SJason M. Bills  */
891*1668ce6dSEd Tanous nlohmann::json propertyValueTypeError(std::string_view arg1,
892*1668ce6dSEd Tanous                                       std::string_view arg2)
893f12894f8SJason M. Bills {
894b6cd31e1SEd Tanous     return getLog(
895*1668ce6dSEd Tanous         redfish::message_registries::base::Index::propertyValueTypeError,
896*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
897b5c07418SJames Feist }
898b5c07418SJames Feist 
899*1668ce6dSEd Tanous void propertyValueTypeError(crow::Response& res, std::string_view arg1,
900*1668ce6dSEd Tanous                             std::string_view arg2)
901b5c07418SJames Feist {
902b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
903b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
904f4c4dcf4SKowalski, Kamil }
905f4c4dcf4SKowalski, Kamil 
906f4c4dcf4SKowalski, Kamil /**
907f4c4dcf4SKowalski, Kamil  * @internal
908b6cd31e1SEd Tanous  * @brief Formats ResourceNotFound message into JSONd
909f4c4dcf4SKowalski, Kamil  *
910f4c4dcf4SKowalski, Kamil  * See header file for more information
911f4c4dcf4SKowalski, Kamil  * @endinternal
912f4c4dcf4SKowalski, Kamil  */
913*1668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
9141abe55efSEd Tanous {
915b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resourceNotFound,
916*1668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
917b5c07418SJames Feist }
918b5c07418SJames Feist 
919*1668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1,
920*1668ce6dSEd Tanous                       std::string_view arg2)
921b5c07418SJames Feist {
922b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
923b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
924f4c4dcf4SKowalski, Kamil }
925f4c4dcf4SKowalski, Kamil 
926f4c4dcf4SKowalski, Kamil /**
927f4c4dcf4SKowalski, Kamil  * @internal
928f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
929f4c4dcf4SKowalski, Kamil  *
930f4c4dcf4SKowalski, Kamil  * See header file for more information
931f4c4dcf4SKowalski, Kamil  * @endinternal
932f4c4dcf4SKowalski, Kamil  */
933ace85d60SEd Tanous nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1)
9341abe55efSEd Tanous {
935*1668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
936b6cd31e1SEd Tanous     return getLog(
937b6cd31e1SEd Tanous         redfish::message_registries::base::Index::couldNotEstablishConnection,
938*1668ce6dSEd Tanous         std::to_array({arg1str}));
939b5c07418SJames Feist }
940b5c07418SJames Feist 
941ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res,
942ace85d60SEd Tanous                                  const boost::urls::url_view& arg1)
943b5c07418SJames Feist {
944b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
945b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
946f4c4dcf4SKowalski, Kamil }
947f4c4dcf4SKowalski, Kamil 
948f4c4dcf4SKowalski, Kamil /**
949f4c4dcf4SKowalski, Kamil  * @internal
950f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
951f12894f8SJason M. Bills  * property
952f12894f8SJason M. Bills  *
953f12894f8SJason M. Bills  * See header file for more information
954f12894f8SJason M. Bills  * @endinternal
955f12894f8SJason M. Bills  */
956*1668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1)
957f12894f8SJason M. Bills {
958b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::propertyNotWritable,
959*1668ce6dSEd Tanous                   std::to_array({arg1}));
960b5c07418SJames Feist }
961b5c07418SJames Feist 
962*1668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1)
963b5c07418SJames Feist {
964b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
965b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
966f4c4dcf4SKowalski, Kamil }
967f4c4dcf4SKowalski, Kamil 
968f4c4dcf4SKowalski, Kamil /**
969f4c4dcf4SKowalski, Kamil  * @internal
970f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
971f4c4dcf4SKowalski, Kamil  *
972f4c4dcf4SKowalski, Kamil  * See header file for more information
973f4c4dcf4SKowalski, Kamil  * @endinternal
974f4c4dcf4SKowalski, Kamil  */
975*1668ce6dSEd Tanous nlohmann::json queryParameterValueTypeError(std::string_view arg1,
976*1668ce6dSEd Tanous                                             std::string_view arg2)
9771abe55efSEd Tanous {
978b6cd31e1SEd Tanous     return getLog(
979b6cd31e1SEd Tanous         redfish::message_registries::base::Index::queryParameterValueTypeError,
980*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
981b5c07418SJames Feist }
982b5c07418SJames Feist 
983*1668ce6dSEd Tanous void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
984*1668ce6dSEd Tanous                                   std::string_view arg2)
985b5c07418SJames Feist {
986b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
987b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
988b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
989f4c4dcf4SKowalski, Kamil }
990f4c4dcf4SKowalski, Kamil 
991f4c4dcf4SKowalski, Kamil /**
992f4c4dcf4SKowalski, Kamil  * @internal
993f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
994f4c4dcf4SKowalski, Kamil  *
995f4c4dcf4SKowalski, Kamil  * See header file for more information
996f4c4dcf4SKowalski, Kamil  * @endinternal
997f4c4dcf4SKowalski, Kamil  */
998b5c07418SJames Feist nlohmann::json serviceShuttingDown(void)
9991abe55efSEd Tanous {
1000b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::serviceShuttingDown,
1001b6cd31e1SEd Tanous                   {});
1002b5c07418SJames Feist }
1003b5c07418SJames Feist 
1004b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
1005b5c07418SJames Feist {
1006b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1007b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1008f4c4dcf4SKowalski, Kamil }
1009f4c4dcf4SKowalski, Kamil 
1010f4c4dcf4SKowalski, Kamil /**
1011f4c4dcf4SKowalski, Kamil  * @internal
1012f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
1013f4c4dcf4SKowalski, Kamil  *
1014f4c4dcf4SKowalski, Kamil  * See header file for more information
1015f4c4dcf4SKowalski, Kamil  * @endinternal
1016f4c4dcf4SKowalski, Kamil  */
1017*1668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1,
1018*1668ce6dSEd Tanous                                         std::string_view arg2)
10191abe55efSEd Tanous {
1020b6cd31e1SEd Tanous     return getLog(
1021b6cd31e1SEd Tanous         redfish::message_registries::base::Index::actionParameterDuplicate,
1022*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
1023b5c07418SJames Feist }
1024b5c07418SJames Feist 
1025*1668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
1026*1668ce6dSEd Tanous                               std::string_view arg2)
1027b5c07418SJames Feist {
1028b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1029b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1030f4c4dcf4SKowalski, Kamil }
1031f4c4dcf4SKowalski, Kamil 
1032f4c4dcf4SKowalski, Kamil /**
1033f4c4dcf4SKowalski, Kamil  * @internal
1034f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1035f4c4dcf4SKowalski, Kamil  *
1036f4c4dcf4SKowalski, Kamil  * See header file for more information
1037f4c4dcf4SKowalski, Kamil  * @endinternal
1038f4c4dcf4SKowalski, Kamil  */
1039*1668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1,
1040*1668ce6dSEd Tanous                                            std::string_view arg2)
10411abe55efSEd Tanous {
1042b6cd31e1SEd Tanous     return getLog(
1043b6cd31e1SEd Tanous         redfish::message_registries::base::Index::actionParameterNotSupported,
1044*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
1045b5c07418SJames Feist }
1046b5c07418SJames Feist 
1047*1668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
1048*1668ce6dSEd Tanous                                  std::string_view arg2)
1049b5c07418SJames Feist {
1050b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1051b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1052b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1053f4c4dcf4SKowalski, Kamil }
1054f4c4dcf4SKowalski, Kamil 
1055f4c4dcf4SKowalski, Kamil /**
1056f4c4dcf4SKowalski, Kamil  * @internal
1057f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1058f4c4dcf4SKowalski, Kamil  *
1059f4c4dcf4SKowalski, Kamil  * See header file for more information
1060f4c4dcf4SKowalski, Kamil  * @endinternal
1061f4c4dcf4SKowalski, Kamil  */
1062ace85d60SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1,
1063*1668ce6dSEd Tanous                                             std::string_view arg2)
10641abe55efSEd Tanous {
1065*1668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1066b6cd31e1SEd Tanous     return getLog(
1067b6cd31e1SEd Tanous         redfish::message_registries::base::Index::sourceDoesNotSupportProtocol,
1068*1668ce6dSEd Tanous         std::to_array({arg1str, arg2}));
1069b5c07418SJames Feist }
1070b5c07418SJames Feist 
1071ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res,
1072ace85d60SEd Tanous                                   const boost::urls::url_view& arg1,
1073*1668ce6dSEd Tanous                                   std::string_view arg2)
1074b5c07418SJames Feist {
1075b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1076b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1077b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1078f4c4dcf4SKowalski, Kamil }
1079f4c4dcf4SKowalski, Kamil 
1080f4c4dcf4SKowalski, Kamil /**
1081f4c4dcf4SKowalski, Kamil  * @internal
1082f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1083f4c4dcf4SKowalski, Kamil  *
1084f4c4dcf4SKowalski, Kamil  * See header file for more information
1085f4c4dcf4SKowalski, Kamil  * @endinternal
1086f4c4dcf4SKowalski, Kamil  */
1087b5c07418SJames Feist nlohmann::json accountRemoved(void)
10881abe55efSEd Tanous {
1089b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::accountRemoved, {});
1090b5c07418SJames Feist }
1091b5c07418SJames Feist 
1092b5c07418SJames Feist void accountRemoved(crow::Response& res)
1093b5c07418SJames Feist {
1094b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1095b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1096f4c4dcf4SKowalski, Kamil }
1097f4c4dcf4SKowalski, Kamil 
1098f4c4dcf4SKowalski, Kamil /**
1099f4c4dcf4SKowalski, Kamil  * @internal
1100f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1101f4c4dcf4SKowalski, Kamil  *
1102f4c4dcf4SKowalski, Kamil  * See header file for more information
1103f4c4dcf4SKowalski, Kamil  * @endinternal
1104f4c4dcf4SKowalski, Kamil  */
1105ace85d60SEd Tanous nlohmann::json accessDenied(const boost::urls::url_view& arg1)
11061abe55efSEd Tanous {
1107*1668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1108*1668ce6dSEd Tanous     return getLog(redfish::message_registries::base::Index::accessDenied,
1109*1668ce6dSEd Tanous                   std::to_array({arg1str}));
1110b5c07418SJames Feist }
1111b5c07418SJames Feist 
1112ace85d60SEd Tanous void accessDenied(crow::Response& res, const boost::urls::url_view& arg1)
1113b5c07418SJames Feist {
1114b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1115b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1116f4c4dcf4SKowalski, Kamil }
1117f4c4dcf4SKowalski, Kamil 
1118f4c4dcf4SKowalski, Kamil /**
1119f4c4dcf4SKowalski, Kamil  * @internal
1120f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1121f4c4dcf4SKowalski, Kamil  *
1122f4c4dcf4SKowalski, Kamil  * See header file for more information
1123f4c4dcf4SKowalski, Kamil  * @endinternal
1124f4c4dcf4SKowalski, Kamil  */
1125b5c07418SJames Feist nlohmann::json queryNotSupported(void)
11261abe55efSEd Tanous {
1127b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::queryNotSupported,
1128b6cd31e1SEd Tanous                   {});
1129b5c07418SJames Feist }
1130b5c07418SJames Feist 
1131b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1132b5c07418SJames Feist {
1133b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1134b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1135f4c4dcf4SKowalski, Kamil }
1136f4c4dcf4SKowalski, Kamil 
1137f4c4dcf4SKowalski, Kamil /**
1138f4c4dcf4SKowalski, Kamil  * @internal
1139f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1140f4c4dcf4SKowalski, Kamil  *
1141f4c4dcf4SKowalski, Kamil  * See header file for more information
1142f4c4dcf4SKowalski, Kamil  * @endinternal
1143f4c4dcf4SKowalski, Kamil  */
1144b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void)
11451abe55efSEd Tanous {
1146b6cd31e1SEd Tanous     return getLog(
1147b6cd31e1SEd Tanous         redfish::message_registries::base::Index::createLimitReachedForResource,
1148b6cd31e1SEd Tanous         {});
1149b5c07418SJames Feist }
1150b5c07418SJames Feist 
1151b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1152b5c07418SJames Feist {
1153b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1154b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1155f4c4dcf4SKowalski, Kamil }
1156f4c4dcf4SKowalski, Kamil 
1157f4c4dcf4SKowalski, Kamil /**
1158f4c4dcf4SKowalski, Kamil  * @internal
1159f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1160f4c4dcf4SKowalski, Kamil  *
1161f4c4dcf4SKowalski, Kamil  * See header file for more information
1162f4c4dcf4SKowalski, Kamil  * @endinternal
1163f4c4dcf4SKowalski, Kamil  */
1164b5c07418SJames Feist nlohmann::json generalError(void)
11651abe55efSEd Tanous {
1166b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::generalError, {});
1167b5c07418SJames Feist }
1168b5c07418SJames Feist 
1169b5c07418SJames Feist void generalError(crow::Response& res)
1170b5c07418SJames Feist {
1171b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1172b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1173f4c4dcf4SKowalski, Kamil }
1174f4c4dcf4SKowalski, Kamil 
1175f4c4dcf4SKowalski, Kamil /**
1176f4c4dcf4SKowalski, Kamil  * @internal
1177f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1178f4c4dcf4SKowalski, Kamil  *
1179f4c4dcf4SKowalski, Kamil  * See header file for more information
1180f4c4dcf4SKowalski, Kamil  * @endinternal
1181f4c4dcf4SKowalski, Kamil  */
1182b5c07418SJames Feist nlohmann::json success(void)
11831abe55efSEd Tanous {
1184b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::success, {});
1185b5c07418SJames Feist }
1186b5c07418SJames Feist 
1187b5c07418SJames Feist void success(crow::Response& res)
1188b5c07418SJames Feist {
1189b5c07418SJames Feist     // don't set res.result here because success is the default and any
1190b5c07418SJames Feist     // error should overwrite the default
1191b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1192f12894f8SJason M. Bills }
1193f12894f8SJason M. Bills 
1194f12894f8SJason M. Bills /**
1195f12894f8SJason M. Bills  * @internal
1196f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1197f4c4dcf4SKowalski, Kamil  *
1198f4c4dcf4SKowalski, Kamil  * See header file for more information
1199f4c4dcf4SKowalski, Kamil  * @endinternal
1200f4c4dcf4SKowalski, Kamil  */
1201b5c07418SJames Feist nlohmann::json created(void)
12021abe55efSEd Tanous {
1203b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::created, {});
1204b5c07418SJames Feist }
1205b5c07418SJames Feist 
1206b5c07418SJames Feist void created(crow::Response& res)
1207b5c07418SJames Feist {
1208b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1209b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1210f4c4dcf4SKowalski, Kamil }
1211f4c4dcf4SKowalski, Kamil 
1212f4c4dcf4SKowalski, Kamil /**
1213f4c4dcf4SKowalski, Kamil  * @internal
1214cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1215cc9139ecSJason M. Bills  *
1216cc9139ecSJason M. Bills  * See header file for more information
1217cc9139ecSJason M. Bills  * @endinternal
1218cc9139ecSJason M. Bills  */
1219b5c07418SJames Feist nlohmann::json noOperation(void)
1220cc9139ecSJason M. Bills {
1221b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::noOperation, {});
1222b5c07418SJames Feist }
1223b5c07418SJames Feist 
1224b5c07418SJames Feist void noOperation(crow::Response& res)
1225b5c07418SJames Feist {
1226b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1227b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1228cc9139ecSJason M. Bills }
1229cc9139ecSJason M. Bills 
1230cc9139ecSJason M. Bills /**
1231cc9139ecSJason M. Bills  * @internal
1232b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1233b5c07418SJames Feist  * property
1234f12894f8SJason M. Bills  *
1235f12894f8SJason M. Bills  * See header file for more information
1236f12894f8SJason M. Bills  * @endinternal
1237f12894f8SJason M. Bills  */
1238*1668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1)
1239b5c07418SJames Feist {
1240b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::propertyUnknown,
1241*1668ce6dSEd Tanous                   std::to_array({arg1}));
1242b5c07418SJames Feist }
1243b5c07418SJames Feist 
1244*1668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1)
1245f12894f8SJason M. Bills {
1246f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1247b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1);
1248f4c4dcf4SKowalski, Kamil }
1249f4c4dcf4SKowalski, Kamil 
1250f4c4dcf4SKowalski, Kamil /**
1251f4c4dcf4SKowalski, Kamil  * @internal
1252f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1253f4c4dcf4SKowalski, Kamil  *
1254f4c4dcf4SKowalski, Kamil  * See header file for more information
1255f4c4dcf4SKowalski, Kamil  * @endinternal
1256f4c4dcf4SKowalski, Kamil  */
1257b5c07418SJames Feist nlohmann::json noValidSession(void)
12581abe55efSEd Tanous {
1259b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::noValidSession, {});
1260b5c07418SJames Feist }
1261b5c07418SJames Feist 
1262b5c07418SJames Feist void noValidSession(crow::Response& res)
1263b5c07418SJames Feist {
1264b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1265b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1266f4c4dcf4SKowalski, Kamil }
1267f4c4dcf4SKowalski, Kamil 
1268f4c4dcf4SKowalski, Kamil /**
1269f4c4dcf4SKowalski, Kamil  * @internal
1270f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1271f4c4dcf4SKowalski, Kamil  *
1272f4c4dcf4SKowalski, Kamil  * See header file for more information
1273f4c4dcf4SKowalski, Kamil  * @endinternal
1274f4c4dcf4SKowalski, Kamil  */
1275ace85d60SEd Tanous nlohmann::json invalidObject(const boost::urls::url_view& arg1)
12761abe55efSEd Tanous {
1277*1668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1278b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::invalidObject,
1279*1668ce6dSEd Tanous                   std::to_array({arg1str}));
1280b5c07418SJames Feist }
1281b5c07418SJames Feist 
1282ace85d60SEd Tanous void invalidObject(crow::Response& res, const boost::urls::url_view& arg1)
1283b5c07418SJames Feist {
1284b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1285b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1286f4c4dcf4SKowalski, Kamil }
1287f4c4dcf4SKowalski, Kamil 
1288f4c4dcf4SKowalski, Kamil /**
1289f4c4dcf4SKowalski, Kamil  * @internal
1290f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1291f4c4dcf4SKowalski, Kamil  *
1292f4c4dcf4SKowalski, Kamil  * See header file for more information
1293f4c4dcf4SKowalski, Kamil  * @endinternal
1294f4c4dcf4SKowalski, Kamil  */
1295b5c07418SJames Feist nlohmann::json resourceInStandby(void)
12961abe55efSEd Tanous {
1297b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resourceInStandby,
1298b6cd31e1SEd Tanous                   {});
1299b5c07418SJames Feist }
1300b5c07418SJames Feist 
1301b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1302b5c07418SJames Feist {
1303b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1304b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1305f4c4dcf4SKowalski, Kamil }
1306f4c4dcf4SKowalski, Kamil 
1307f4c4dcf4SKowalski, Kamil /**
1308f4c4dcf4SKowalski, Kamil  * @internal
1309f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1310f4c4dcf4SKowalski, Kamil  *
1311f4c4dcf4SKowalski, Kamil  * See header file for more information
1312f4c4dcf4SKowalski, Kamil  * @endinternal
1313f4c4dcf4SKowalski, Kamil  */
1314*1668ce6dSEd Tanous nlohmann::json actionParameterValueTypeError(std::string_view arg1,
1315*1668ce6dSEd Tanous                                              std::string_view arg2,
1316*1668ce6dSEd Tanous                                              std::string_view arg3)
13171abe55efSEd Tanous {
1318b6cd31e1SEd Tanous     return getLog(
1319b6cd31e1SEd Tanous         redfish::message_registries::base::Index::actionParameterValueTypeError,
1320*1668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
1321b5c07418SJames Feist }
1322b5c07418SJames Feist 
1323*1668ce6dSEd Tanous void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
1324*1668ce6dSEd Tanous                                    std::string_view arg2, std::string_view arg3)
1325b5c07418SJames Feist {
1326b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1327b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1328b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1329f4c4dcf4SKowalski, Kamil }
1330f4c4dcf4SKowalski, Kamil 
1331f4c4dcf4SKowalski, Kamil /**
1332f4c4dcf4SKowalski, Kamil  * @internal
1333f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1334f4c4dcf4SKowalski, Kamil  *
1335f4c4dcf4SKowalski, Kamil  * See header file for more information
1336f4c4dcf4SKowalski, Kamil  * @endinternal
1337f4c4dcf4SKowalski, Kamil  */
1338b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void)
13391abe55efSEd Tanous {
1340b6cd31e1SEd Tanous     return getLog(
1341b6cd31e1SEd Tanous         redfish::message_registries::base::Index::sessionLimitExceeded, {});
1342b5c07418SJames Feist }
1343b5c07418SJames Feist 
1344b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1345b5c07418SJames Feist {
1346b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1347b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1348f4c4dcf4SKowalski, Kamil }
1349f4c4dcf4SKowalski, Kamil 
1350f4c4dcf4SKowalski, Kamil /**
1351f4c4dcf4SKowalski, Kamil  * @internal
1352f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1353f4c4dcf4SKowalski, Kamil  *
1354f4c4dcf4SKowalski, Kamil  * See header file for more information
1355f4c4dcf4SKowalski, Kamil  * @endinternal
1356f4c4dcf4SKowalski, Kamil  */
1357*1668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1)
13581abe55efSEd Tanous {
1359b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::actionNotSupported,
1360*1668ce6dSEd Tanous                   std::to_array({arg1}));
1361b5c07418SJames Feist }
1362b5c07418SJames Feist 
1363*1668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1)
1364b5c07418SJames Feist {
1365b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1366b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1367f4c4dcf4SKowalski, Kamil }
1368f4c4dcf4SKowalski, Kamil 
1369f4c4dcf4SKowalski, Kamil /**
1370f4c4dcf4SKowalski, Kamil  * @internal
1371f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1372f4c4dcf4SKowalski, Kamil  *
1373f4c4dcf4SKowalski, Kamil  * See header file for more information
1374f4c4dcf4SKowalski, Kamil  * @endinternal
1375f4c4dcf4SKowalski, Kamil  */
13765187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
13771abe55efSEd Tanous {
1378b6cd31e1SEd Tanous     std::string arg1Str = std::to_string(arg1);
1379*1668ce6dSEd Tanous     return getLog(redfish::message_registries::base::Index::invalidIndex,
1380*1668ce6dSEd Tanous                   std::to_array<std::string_view>({arg1Str}));
1381b5c07418SJames Feist }
1382b5c07418SJames Feist 
13835187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1384b5c07418SJames Feist {
1385b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1386b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1387f4c4dcf4SKowalski, Kamil }
1388f4c4dcf4SKowalski, Kamil 
1389f4c4dcf4SKowalski, Kamil /**
1390f4c4dcf4SKowalski, Kamil  * @internal
1391f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1392f4c4dcf4SKowalski, Kamil  *
1393f4c4dcf4SKowalski, Kamil  * See header file for more information
1394f4c4dcf4SKowalski, Kamil  * @endinternal
1395f4c4dcf4SKowalski, Kamil  */
1396b5c07418SJames Feist nlohmann::json emptyJSON(void)
13971abe55efSEd Tanous {
1398b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::emptyJSON, {});
1399b5c07418SJames Feist }
1400b5c07418SJames Feist 
1401b5c07418SJames Feist void emptyJSON(crow::Response& res)
1402b5c07418SJames Feist {
1403b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1404b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1405f4c4dcf4SKowalski, Kamil }
1406f4c4dcf4SKowalski, Kamil 
1407f4c4dcf4SKowalski, Kamil /**
1408f4c4dcf4SKowalski, Kamil  * @internal
1409f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1410f4c4dcf4SKowalski, Kamil  *
1411f4c4dcf4SKowalski, Kamil  * See header file for more information
1412f4c4dcf4SKowalski, Kamil  * @endinternal
1413f4c4dcf4SKowalski, Kamil  */
1414b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void)
14151abe55efSEd Tanous {
1416b6cd31e1SEd Tanous     return getLog(
1417b6cd31e1SEd Tanous         redfish::message_registries::base::Index::queryNotSupportedOnResource,
1418b6cd31e1SEd Tanous         {});
1419b5c07418SJames Feist }
1420b5c07418SJames Feist 
1421b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1422b5c07418SJames Feist {
1423b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1424b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1425f4c4dcf4SKowalski, Kamil }
1426f4c4dcf4SKowalski, Kamil 
1427f4c4dcf4SKowalski, Kamil /**
1428f4c4dcf4SKowalski, Kamil  * @internal
1429684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1430684bb4b8SJason M. Bills  *
1431684bb4b8SJason M. Bills  * See header file for more information
1432684bb4b8SJason M. Bills  * @endinternal
1433684bb4b8SJason M. Bills  */
1434684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void)
1435684bb4b8SJason M. Bills {
1436b6cd31e1SEd Tanous     return getLog(
1437b6cd31e1SEd Tanous         redfish::message_registries::base::Index::queryNotSupportedOnOperation,
1438b6cd31e1SEd Tanous         {});
1439684bb4b8SJason M. Bills }
1440684bb4b8SJason M. Bills 
1441684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1442684bb4b8SJason M. Bills {
1443684bb4b8SJason M. Bills     res.result(boost::beast::http::status::forbidden);
1444684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1445684bb4b8SJason M. Bills }
1446684bb4b8SJason M. Bills 
1447684bb4b8SJason M. Bills /**
1448684bb4b8SJason M. Bills  * @internal
1449684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1450684bb4b8SJason M. Bills  *
1451684bb4b8SJason M. Bills  * See header file for more information
1452684bb4b8SJason M. Bills  * @endinternal
1453684bb4b8SJason M. Bills  */
1454684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void)
1455684bb4b8SJason M. Bills {
1456b6cd31e1SEd Tanous     return getLog(
1457b6cd31e1SEd Tanous         redfish::message_registries::base::Index::queryCombinationInvalid, {});
1458684bb4b8SJason M. Bills }
1459684bb4b8SJason M. Bills 
1460684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1461684bb4b8SJason M. Bills {
1462684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1463684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1464684bb4b8SJason M. Bills }
1465684bb4b8SJason M. Bills 
1466684bb4b8SJason M. Bills /**
1467684bb4b8SJason M. Bills  * @internal
1468f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1469f4c4dcf4SKowalski, Kamil  *
1470f4c4dcf4SKowalski, Kamil  * See header file for more information
1471f4c4dcf4SKowalski, Kamil  * @endinternal
1472f4c4dcf4SKowalski, Kamil  */
1473b5c07418SJames Feist nlohmann::json insufficientPrivilege(void)
14741abe55efSEd Tanous {
1475b6cd31e1SEd Tanous     return getLog(
1476b6cd31e1SEd Tanous         redfish::message_registries::base::Index::insufficientPrivilege, {});
1477b5c07418SJames Feist }
1478b5c07418SJames Feist 
1479b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1480b5c07418SJames Feist {
1481b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1482b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1483f4c4dcf4SKowalski, Kamil }
1484f4c4dcf4SKowalski, Kamil 
1485f4c4dcf4SKowalski, Kamil /**
1486f4c4dcf4SKowalski, Kamil  * @internal
1487f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1488f4c4dcf4SKowalski, Kamil  *
1489f4c4dcf4SKowalski, Kamil  * See header file for more information
1490f4c4dcf4SKowalski, Kamil  * @endinternal
1491f4c4dcf4SKowalski, Kamil  */
1492*1668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1,
1493*1668ce6dSEd Tanous                                      std::string_view arg2)
1494b5c07418SJames Feist {
1495b6cd31e1SEd Tanous     return getLog(
1496*1668ce6dSEd Tanous         redfish::message_registries::base::Index::propertyValueModified,
1497*1668ce6dSEd Tanous         std::to_array({arg1, arg2}));
1498b5c07418SJames Feist }
1499b5c07418SJames Feist 
1500*1668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1,
1501*1668ce6dSEd Tanous                            std::string_view arg2)
15021abe55efSEd Tanous {
1503f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1504b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1505f4c4dcf4SKowalski, Kamil }
1506f4c4dcf4SKowalski, Kamil 
1507f4c4dcf4SKowalski, Kamil /**
1508f4c4dcf4SKowalski, Kamil  * @internal
1509f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1510f4c4dcf4SKowalski, Kamil  *
1511f4c4dcf4SKowalski, Kamil  * See header file for more information
1512f4c4dcf4SKowalski, Kamil  * @endinternal
1513f4c4dcf4SKowalski, Kamil  */
1514b5c07418SJames Feist nlohmann::json accountNotModified(void)
15151abe55efSEd Tanous {
1516b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::accountNotModified,
1517b6cd31e1SEd Tanous                   {});
1518b5c07418SJames Feist }
1519b5c07418SJames Feist 
1520b5c07418SJames Feist void accountNotModified(crow::Response& res)
1521b5c07418SJames Feist {
1522b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1523b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1524f4c4dcf4SKowalski, Kamil }
1525f4c4dcf4SKowalski, Kamil 
1526f4c4dcf4SKowalski, Kamil /**
1527f4c4dcf4SKowalski, Kamil  * @internal
1528f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1529f4c4dcf4SKowalski, Kamil  *
1530f4c4dcf4SKowalski, Kamil  * See header file for more information
1531f4c4dcf4SKowalski, Kamil  * @endinternal
1532f4c4dcf4SKowalski, Kamil  */
1533*1668ce6dSEd Tanous nlohmann::json queryParameterValueFormatError(std::string_view arg1,
1534*1668ce6dSEd Tanous                                               std::string_view arg2)
15351abe55efSEd Tanous {
1536b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::
1537b6cd31e1SEd Tanous                       queryParameterValueFormatError,
1538*1668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1539b5c07418SJames Feist }
1540b5c07418SJames Feist 
1541*1668ce6dSEd Tanous void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
1542*1668ce6dSEd Tanous                                     std::string_view arg2)
1543b5c07418SJames Feist {
1544b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1545b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1546b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
1547f4c4dcf4SKowalski, Kamil }
1548f4c4dcf4SKowalski, Kamil 
1549f4c4dcf4SKowalski, Kamil /**
1550f4c4dcf4SKowalski, Kamil  * @internal
1551b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
1552b5c07418SJames Feist  * property
1553f12894f8SJason M. Bills  *
1554f12894f8SJason M. Bills  * See header file for more information
1555f12894f8SJason M. Bills  * @endinternal
1556f12894f8SJason M. Bills  */
1557*1668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1)
1558f12894f8SJason M. Bills {
1559b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::propertyMissing,
1560*1668ce6dSEd Tanous                   std::to_array({arg1}));
1561b5c07418SJames Feist }
1562b5c07418SJames Feist 
1563*1668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1)
1564b5c07418SJames Feist {
1565b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1566b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1567f4c4dcf4SKowalski, Kamil }
1568f4c4dcf4SKowalski, Kamil 
1569f4c4dcf4SKowalski, Kamil /**
1570f4c4dcf4SKowalski, Kamil  * @internal
1571f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
1572f4c4dcf4SKowalski, Kamil  *
1573f4c4dcf4SKowalski, Kamil  * See header file for more information
1574f4c4dcf4SKowalski, Kamil  * @endinternal
1575f4c4dcf4SKowalski, Kamil  */
1576*1668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1)
15771abe55efSEd Tanous {
1578b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resourceExhaustion,
1579*1668ce6dSEd Tanous                   std::to_array({arg1}));
1580b5c07418SJames Feist }
1581b5c07418SJames Feist 
1582*1668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1)
1583b5c07418SJames Feist {
1584b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1585b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1586f4c4dcf4SKowalski, Kamil }
1587f4c4dcf4SKowalski, Kamil 
1588f4c4dcf4SKowalski, Kamil /**
1589f4c4dcf4SKowalski, Kamil  * @internal
1590f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
1591f4c4dcf4SKowalski, Kamil  *
1592f4c4dcf4SKowalski, Kamil  * See header file for more information
1593f4c4dcf4SKowalski, Kamil  * @endinternal
1594f4c4dcf4SKowalski, Kamil  */
1595b5c07418SJames Feist nlohmann::json accountModified(void)
15961abe55efSEd Tanous {
1597b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::accountModified,
1598b6cd31e1SEd Tanous                   {});
1599b5c07418SJames Feist }
1600b5c07418SJames Feist 
1601b5c07418SJames Feist void accountModified(crow::Response& res)
1602b5c07418SJames Feist {
1603b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1604b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
1605f4c4dcf4SKowalski, Kamil }
1606f4c4dcf4SKowalski, Kamil 
1607f4c4dcf4SKowalski, Kamil /**
1608f4c4dcf4SKowalski, Kamil  * @internal
1609f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
1610f4c4dcf4SKowalski, Kamil  *
1611f4c4dcf4SKowalski, Kamil  * See header file for more information
1612f4c4dcf4SKowalski, Kamil  * @endinternal
1613f4c4dcf4SKowalski, Kamil  */
1614*1668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1,
1615*1668ce6dSEd Tanous                                         std::string_view arg2,
1616*1668ce6dSEd Tanous                                         std::string_view arg3)
16171abe55efSEd Tanous {
1618b6cd31e1SEd Tanous     return getLog(
1619b6cd31e1SEd Tanous         redfish::message_registries::base::Index::queryParameterOutOfRange,
1620*1668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
1621b5c07418SJames Feist }
1622b5c07418SJames Feist 
1623*1668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
1624*1668ce6dSEd Tanous                               std::string_view arg2, std::string_view arg3)
1625b5c07418SJames Feist {
1626b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1627b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1628b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
1629f4c4dcf4SKowalski, Kamil }
1630f4c4dcf4SKowalski, Kamil 
1631b6cd31e1SEd Tanous nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1)
1632b6cd31e1SEd Tanous {
1633*1668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1634b6cd31e1SEd Tanous     return getLog(
1635*1668ce6dSEd Tanous         redfish::message_registries::base::Index::passwordChangeRequired,
1636*1668ce6dSEd Tanous         std::to_array({arg1str}));
1637b6cd31e1SEd Tanous }
1638b6cd31e1SEd Tanous 
16393bf4e632SJoseph Reynolds /**
16403bf4e632SJoseph Reynolds  * @internal
16413bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
16423bf4e632SJoseph Reynolds  *
16433bf4e632SJoseph Reynolds  * See header file for more information
16443bf4e632SJoseph Reynolds  * @endinternal
16453bf4e632SJoseph Reynolds  */
1646ace85d60SEd Tanous void passwordChangeRequired(crow::Response& res,
1647ace85d60SEd Tanous                             const boost::urls::url_view& arg1)
16483bf4e632SJoseph Reynolds {
1649b6cd31e1SEd Tanous     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
16503bf4e632SJoseph Reynolds }
16513bf4e632SJoseph Reynolds 
1652*1668ce6dSEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1,
1653*1668ce6dSEd Tanous                    std::string_view arg2)
16544cde5d90SJames Feist {
16554cde5d90SJames Feist     res.result(boost::beast::http::status::bad_request);
16564cde5d90SJames Feist     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
16574cde5d90SJames Feist }
16584cde5d90SJames Feist 
16594cde5d90SJames Feist /**
16604cde5d90SJames Feist  * @internal
16614cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
16624cde5d90SJames Feist  *
16634cde5d90SJames Feist  * See header file for more information
16644cde5d90SJames Feist  * @endinternal
16654cde5d90SJames Feist  */
1666*1668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
16674cde5d90SJames Feist {
1668*1668ce6dSEd Tanous     std::string msg = "Invalid file uploaded to ";
1669*1668ce6dSEd Tanous     msg += arg1;
1670*1668ce6dSEd Tanous     msg += ": ";
1671*1668ce6dSEd Tanous     msg += arg2;
1672*1668ce6dSEd Tanous     msg += ".";
16734cde5d90SJames Feist     return nlohmann::json{
16743e082749SAsmitha Karunanithi         {"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"},
16754a0bf539SManojkiran Eda         {"MessageId", "OpenBMC.0.2.InvalidUpload"},
1676*1668ce6dSEd Tanous         {"Message", std::move(msg)},
16774cde5d90SJames Feist         {"MessageArgs", {arg1, arg2}},
1678684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
16794cde5d90SJames Feist         {"Resolution", "None."}};
16804cde5d90SJames Feist }
1681f4c4dcf4SKowalski, Kamil } // namespace messages
1682f4c4dcf4SKowalski, Kamil 
1683d425c6f6SEd Tanous } // namespace redfish
1684