xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision b6cd31e162b25779a68344d3c0bde7c6cfb1af7f)
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"
17*b6cd31e1SEd 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 
251abe55efSEd Tanous namespace redfish
261abe55efSEd Tanous {
271abe55efSEd Tanous 
281abe55efSEd Tanous namespace messages
291abe55efSEd Tanous {
30f4c4dcf4SKowalski, Kamil 
31f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target,
321abe55efSEd Tanous                                   const nlohmann::json& message)
331abe55efSEd Tanous {
34f4c4dcf4SKowalski, Kamil     auto& error = target["error"];
35f4c4dcf4SKowalski, Kamil 
361abe55efSEd Tanous     // If this is the first error message, fill in the information from the
371abe55efSEd Tanous     // first error message to the top level struct
381abe55efSEd Tanous     if (!error.is_object())
391abe55efSEd Tanous     {
40c074230bSJason M. Bills         auto messageIdIterator = message.find("MessageId");
41c074230bSJason M. Bills         if (messageIdIterator == message.end())
421abe55efSEd Tanous         {
431abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
441abe55efSEd Tanous                 << "Attempt to add error message without MessageId";
45f4c4dcf4SKowalski, Kamil             return;
46f4c4dcf4SKowalski, Kamil         }
47f4c4dcf4SKowalski, Kamil 
48c074230bSJason M. Bills         auto messageFieldIterator = message.find("Message");
49c074230bSJason M. Bills         if (messageFieldIterator == message.end())
501abe55efSEd Tanous         {
511abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
521abe55efSEd Tanous                 << "Attempt to add error message without Message";
53f4c4dcf4SKowalski, Kamil             return;
54f4c4dcf4SKowalski, Kamil         }
55c21055aaSEd Tanous         error = {{"code", *messageIdIterator},
56c21055aaSEd Tanous                  {"message", *messageFieldIterator}};
571abe55efSEd Tanous     }
581abe55efSEd Tanous     else
591abe55efSEd Tanous     {
60f4c4dcf4SKowalski, Kamil         // More than 1 error occurred, so the message has to be generic
6155c7b7a2SEd Tanous         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
62cc9139ecSJason M. Bills         error["message"] = "A general error has occurred. See Resolution for "
63cc9139ecSJason M. Bills                            "information on how to resolve the error.";
64f4c4dcf4SKowalski, Kamil     }
65f4c4dcf4SKowalski, Kamil 
66f4c4dcf4SKowalski, Kamil     // This check could technically be done in in the default construction
67f4c4dcf4SKowalski, Kamil     // branch above, but because we need the pointer to the extended info field
68f4c4dcf4SKowalski, Kamil     // anyway, it's more efficient to do it here.
69c074230bSJason M. Bills     auto& extendedInfo = error[messages::messageAnnotation];
70c074230bSJason M. Bills     if (!extendedInfo.is_array())
711abe55efSEd Tanous     {
72c074230bSJason M. Bills         extendedInfo = nlohmann::json::array();
73f4c4dcf4SKowalski, Kamil     }
74f4c4dcf4SKowalski, Kamil 
75c074230bSJason M. Bills     extendedInfo.push_back(message);
76f4c4dcf4SKowalski, Kamil }
77f4c4dcf4SKowalski, Kamil 
78f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target,
79f12894f8SJason M. Bills                                  const nlohmann::json& message)
801abe55efSEd Tanous {
811abe55efSEd Tanous     if (!target[messages::messageAnnotation].is_array())
821abe55efSEd Tanous     {
83f4c4dcf4SKowalski, Kamil         // Force object to be an array
8455c7b7a2SEd Tanous         target[messages::messageAnnotation] = nlohmann::json::array();
85f4c4dcf4SKowalski, Kamil     }
86f4c4dcf4SKowalski, Kamil 
8755c7b7a2SEd Tanous     target[messages::messageAnnotation].push_back(message);
88f4c4dcf4SKowalski, Kamil }
89f4c4dcf4SKowalski, Kamil 
90f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target,
91f12894f8SJason M. Bills                              const nlohmann::json& message,
921abe55efSEd Tanous                              const std::string& fieldPath)
931abe55efSEd Tanous {
94a08b46ccSJason M. Bills     std::string extendedInfo(fieldPath + messages::messageAnnotation);
95f4c4dcf4SKowalski, Kamil 
961abe55efSEd Tanous     if (!target[extendedInfo].is_array())
971abe55efSEd Tanous     {
98f4c4dcf4SKowalski, Kamil         // Force object to be an array
99f4c4dcf4SKowalski, Kamil         target[extendedInfo] = nlohmann::json::array();
100f4c4dcf4SKowalski, Kamil     }
101f4c4dcf4SKowalski, Kamil 
102f4c4dcf4SKowalski, Kamil     // Object exists and it is an array so we can just push in the message
103f4c4dcf4SKowalski, Kamil     target[extendedInfo].push_back(message);
104f4c4dcf4SKowalski, Kamil }
105f4c4dcf4SKowalski, Kamil 
106*b6cd31e1SEd Tanous nlohmann::json getLog(redfish::message_registries::base::Index name,
107*b6cd31e1SEd Tanous                       std::span<const std::string_view> args)
108*b6cd31e1SEd Tanous {
109*b6cd31e1SEd Tanous     size_t index = static_cast<size_t>(name);
110*b6cd31e1SEd Tanous     if (index >= redfish::message_registries::base::registry.size())
111*b6cd31e1SEd Tanous     {
112*b6cd31e1SEd Tanous         return {};
113*b6cd31e1SEd Tanous     }
114*b6cd31e1SEd Tanous     const redfish::message_registries::MessageEntry& entry =
115*b6cd31e1SEd Tanous         redfish::message_registries::base::registry[index];
116*b6cd31e1SEd Tanous     // Intentionally make a copy of the string, so we can append in the
117*b6cd31e1SEd Tanous     // parameters.
118*b6cd31e1SEd Tanous     std::string msg = entry.second.message;
119*b6cd31e1SEd Tanous     redfish::message_registries::fillMessageArgs(args, msg);
120*b6cd31e1SEd Tanous     nlohmann::json jArgs = nlohmann::json::array();
121*b6cd31e1SEd Tanous     for (const std::string_view arg : args)
122*b6cd31e1SEd Tanous     {
123*b6cd31e1SEd Tanous         jArgs.push_back(arg);
124*b6cd31e1SEd Tanous     }
125*b6cd31e1SEd Tanous     std::string msgId = redfish::message_registries::base::header.id;
126*b6cd31e1SEd Tanous     msgId += ".";
127*b6cd31e1SEd Tanous     msgId += entry.first;
128*b6cd31e1SEd Tanous     return {{"@odata.type", "#Message.v1_1_1.Message"},
129*b6cd31e1SEd Tanous             {"MessageId", std::move(msgId)},
130*b6cd31e1SEd Tanous             {"Message", std::move(msg)},
131*b6cd31e1SEd Tanous             {"MessageArgs", std::move(jArgs)},
132*b6cd31e1SEd Tanous             {"MessageSeverity", entry.second.severity},
133*b6cd31e1SEd Tanous             {"Resolution", entry.second.resolution}};
134*b6cd31e1SEd Tanous }
135*b6cd31e1SEd Tanous 
136f4c4dcf4SKowalski, Kamil /**
137f4c4dcf4SKowalski, Kamil  * @internal
138f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
139f4c4dcf4SKowalski, Kamil  *
140f4c4dcf4SKowalski, Kamil  * See header file for more information
141f4c4dcf4SKowalski, Kamil  * @endinternal
142f4c4dcf4SKowalski, Kamil  */
143b5c07418SJames Feist nlohmann::json resourceInUse(void)
1441abe55efSEd Tanous {
145*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resourceInUse, {});
146b5c07418SJames Feist }
147b5c07418SJames Feist 
148b5c07418SJames Feist void resourceInUse(crow::Response& res)
149b5c07418SJames Feist {
150b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
151b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
152f4c4dcf4SKowalski, Kamil }
153f4c4dcf4SKowalski, Kamil 
154f4c4dcf4SKowalski, Kamil /**
155f4c4dcf4SKowalski, Kamil  * @internal
156f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
157f4c4dcf4SKowalski, Kamil  *
158f4c4dcf4SKowalski, Kamil  * See header file for more information
159f4c4dcf4SKowalski, Kamil  * @endinternal
160f4c4dcf4SKowalski, Kamil  */
161b5c07418SJames Feist nlohmann::json malformedJSON(void)
1621abe55efSEd Tanous {
163*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::malformedJSON, {});
164b5c07418SJames Feist }
165b5c07418SJames Feist 
166b5c07418SJames Feist void malformedJSON(crow::Response& res)
167b5c07418SJames Feist {
168b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
169b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
170f4c4dcf4SKowalski, Kamil }
171f4c4dcf4SKowalski, Kamil 
172f4c4dcf4SKowalski, Kamil /**
173f4c4dcf4SKowalski, Kamil  * @internal
174f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
175f4c4dcf4SKowalski, Kamil  *
176f4c4dcf4SKowalski, Kamil  * See header file for more information
177f4c4dcf4SKowalski, Kamil  * @endinternal
178f4c4dcf4SKowalski, Kamil  */
179ace85d60SEd Tanous nlohmann::json resourceMissingAtURI(const boost::urls::url_view& arg1)
1801abe55efSEd Tanous {
181*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
182*b6cd31e1SEd Tanous         std::string_view{arg1.data(), arg1.size()}};
183*b6cd31e1SEd Tanous     return getLog(
184*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceMissingAtURI, args);
185b5c07418SJames Feist }
186b5c07418SJames Feist 
187ace85d60SEd Tanous void resourceMissingAtURI(crow::Response& res,
188ace85d60SEd Tanous                           const boost::urls::url_view& arg1)
189b5c07418SJames Feist {
190b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
191b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
192f4c4dcf4SKowalski, Kamil }
193f4c4dcf4SKowalski, Kamil 
194f4c4dcf4SKowalski, Kamil /**
195f4c4dcf4SKowalski, Kamil  * @internal
196f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
197f4c4dcf4SKowalski, Kamil  *
198f4c4dcf4SKowalski, Kamil  * See header file for more information
199f4c4dcf4SKowalski, Kamil  * @endinternal
200f4c4dcf4SKowalski, Kamil  */
201b5c07418SJames Feist nlohmann::json actionParameterValueFormatError(const std::string& arg1,
202f4c4dcf4SKowalski, Kamil                                                const std::string& arg2,
2031abe55efSEd Tanous                                                const std::string& arg3)
2041abe55efSEd Tanous {
205*b6cd31e1SEd Tanous     std::array<std::string_view, 3> args{arg1, arg2, arg3};
206*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::
207*b6cd31e1SEd Tanous                       actionParameterValueFormatError,
208*b6cd31e1SEd Tanous                   args);
209b5c07418SJames Feist }
210b5c07418SJames Feist 
211b5c07418SJames Feist void actionParameterValueFormatError(crow::Response& res,
212b5c07418SJames Feist                                      const std::string& arg1,
213b5c07418SJames Feist                                      const std::string& arg2,
214b5c07418SJames Feist                                      const std::string& arg3)
215b5c07418SJames Feist {
216b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
217b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
218b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
219f4c4dcf4SKowalski, Kamil }
220f4c4dcf4SKowalski, Kamil 
221f4c4dcf4SKowalski, Kamil /**
222f4c4dcf4SKowalski, Kamil  * @internal
223f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
224f4c4dcf4SKowalski, Kamil  *
225f4c4dcf4SKowalski, Kamil  * See header file for more information
226f4c4dcf4SKowalski, Kamil  * @endinternal
227f4c4dcf4SKowalski, Kamil  */
228b5c07418SJames Feist nlohmann::json internalError(void)
2291abe55efSEd Tanous {
230*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::internalError, {});
231b5c07418SJames Feist }
232b5c07418SJames Feist 
233df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location)
234b5c07418SJames Feist {
235df5415fcSEd Tanous     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
236df5415fcSEd Tanous                         << location.line() << ":" << location.column() << ") `"
237df5415fcSEd Tanous                         << location.function_name() << "`: ";
238b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
239b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
240f12894f8SJason M. Bills }
241f12894f8SJason M. Bills 
242f12894f8SJason M. Bills /**
243f12894f8SJason M. Bills  * @internal
244f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
245f4c4dcf4SKowalski, Kamil  *
246f4c4dcf4SKowalski, Kamil  * See header file for more information
247f4c4dcf4SKowalski, Kamil  * @endinternal
248f4c4dcf4SKowalski, Kamil  */
249b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void)
2501abe55efSEd Tanous {
251*b6cd31e1SEd Tanous     return getLog(
252*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::unrecognizedRequestBody, {});
253b5c07418SJames Feist }
254b5c07418SJames Feist 
255b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
256b5c07418SJames Feist {
257b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
258b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
259f4c4dcf4SKowalski, Kamil }
260f4c4dcf4SKowalski, Kamil 
261f4c4dcf4SKowalski, Kamil /**
262f4c4dcf4SKowalski, Kamil  * @internal
263f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
264f4c4dcf4SKowalski, Kamil  *
265f4c4dcf4SKowalski, Kamil  * See header file for more information
266f4c4dcf4SKowalski, Kamil  * @endinternal
267f4c4dcf4SKowalski, Kamil  */
268ace85d60SEd Tanous nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1,
2691abe55efSEd Tanous                                          const std::string& arg2)
2701abe55efSEd Tanous {
271*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{
272*b6cd31e1SEd Tanous         std::string_view{arg1.data(), arg1.size()}, arg2};
273*b6cd31e1SEd Tanous     return getLog(
274*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceAtUriUnauthorized,
275*b6cd31e1SEd Tanous         args);
276b5c07418SJames Feist }
277b5c07418SJames Feist 
278ace85d60SEd Tanous void resourceAtUriUnauthorized(crow::Response& res,
279ace85d60SEd Tanous                                const boost::urls::url_view& arg1,
280b5c07418SJames Feist                                const std::string& 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  */
293b5c07418SJames Feist nlohmann::json actionParameterUnknown(const std::string& arg1,
294b5c07418SJames Feist                                       const std::string& arg2)
295b5c07418SJames Feist {
296*b6cd31e1SEd Tanous     std::array<std::string_view, 3> args{arg1, arg2};
297*b6cd31e1SEd Tanous     return getLog(
298*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::actionParameterUnknown, args);
299b5c07418SJames Feist }
300b5c07418SJames Feist 
301f12894f8SJason M. Bills void actionParameterUnknown(crow::Response& res, const std::string& arg1,
3021abe55efSEd Tanous                             const std::string& 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 {
317*b6cd31e1SEd Tanous     return getLog(
318*b6cd31e1SEd 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  */
334b5c07418SJames Feist nlohmann::json propertyDuplicate(const std::string& arg1)
3351abe55efSEd Tanous {
336*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1};
337*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::propertyDuplicate,
338*b6cd31e1SEd Tanous                   args);
339b5c07418SJames Feist }
340b5c07418SJames Feist 
341b5c07418SJames Feist void propertyDuplicate(crow::Response& res, const std::string& arg1)
342b5c07418SJames Feist {
343b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
344b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
345f4c4dcf4SKowalski, Kamil }
346f4c4dcf4SKowalski, Kamil 
347f4c4dcf4SKowalski, Kamil /**
348f4c4dcf4SKowalski, Kamil  * @internal
349f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
350f4c4dcf4SKowalski, Kamil  *
351f4c4dcf4SKowalski, Kamil  * See header file for more information
352f4c4dcf4SKowalski, Kamil  * @endinternal
353f4c4dcf4SKowalski, Kamil  */
354b5c07418SJames Feist nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1)
3551abe55efSEd Tanous {
356*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1};
357*b6cd31e1SEd Tanous     return getLog(
358*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::serviceTemporarilyUnavailable,
359*b6cd31e1SEd Tanous         args);
360b5c07418SJames Feist }
361b5c07418SJames Feist 
362b5c07418SJames Feist void serviceTemporarilyUnavailable(crow::Response& res, const std::string& arg1)
363b5c07418SJames Feist {
364b5c07418SJames Feist     res.addHeader("Retry-After", arg1);
365b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
366b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
367f4c4dcf4SKowalski, Kamil }
368f4c4dcf4SKowalski, Kamil 
369f4c4dcf4SKowalski, Kamil /**
370f4c4dcf4SKowalski, Kamil  * @internal
371f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
372f4c4dcf4SKowalski, Kamil  *
373f4c4dcf4SKowalski, Kamil  * See header file for more information
374f4c4dcf4SKowalski, Kamil  * @endinternal
375f4c4dcf4SKowalski, Kamil  */
376b5c07418SJames Feist nlohmann::json resourceAlreadyExists(const std::string& arg1,
377b5c07418SJames Feist                                      const std::string& arg2,
378b5c07418SJames Feist                                      const std::string& arg3)
3791abe55efSEd Tanous {
380*b6cd31e1SEd Tanous     std::array<std::string_view, 3> args{arg1, arg2, arg3};
381*b6cd31e1SEd Tanous     return getLog(
382*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceAlreadyExists, args);
383b5c07418SJames Feist }
384b5c07418SJames Feist 
385b5c07418SJames Feist void resourceAlreadyExists(crow::Response& res, const std::string& arg1,
386b5c07418SJames Feist                            const std::string& arg2, const std::string& arg3)
387b5c07418SJames Feist {
388b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
389b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
390a08b46ccSJason M. Bills                      arg2);
391f4c4dcf4SKowalski, Kamil }
392f4c4dcf4SKowalski, Kamil 
393f4c4dcf4SKowalski, Kamil /**
394f4c4dcf4SKowalski, Kamil  * @internal
395f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
396f4c4dcf4SKowalski, Kamil  *
397f4c4dcf4SKowalski, Kamil  * See header file for more information
398f4c4dcf4SKowalski, Kamil  * @endinternal
399f4c4dcf4SKowalski, Kamil  */
400b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void)
4011abe55efSEd Tanous {
402*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::
403*b6cd31e1SEd Tanous                       accountForSessionNoLongerExists,
404*b6cd31e1SEd Tanous                   {});
405b5c07418SJames Feist }
406b5c07418SJames Feist 
407b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
408b5c07418SJames Feist {
409b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
410b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
411f4c4dcf4SKowalski, Kamil }
412f4c4dcf4SKowalski, Kamil 
413f4c4dcf4SKowalski, Kamil /**
414f4c4dcf4SKowalski, Kamil  * @internal
415f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
416f4c4dcf4SKowalski, Kamil  *
417f4c4dcf4SKowalski, Kamil  * See header file for more information
418f4c4dcf4SKowalski, Kamil  * @endinternal
419f4c4dcf4SKowalski, Kamil  */
420b5c07418SJames Feist nlohmann::json createFailedMissingReqProperties(const std::string& arg1)
4211abe55efSEd Tanous {
422*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1};
423*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::
424*b6cd31e1SEd Tanous                       createFailedMissingReqProperties,
425*b6cd31e1SEd Tanous                   args);
426b5c07418SJames Feist }
427b5c07418SJames Feist 
428b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
429b5c07418SJames Feist                                       const std::string& arg1)
430b5c07418SJames Feist {
431b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
432b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
433a08b46ccSJason M. Bills                      arg1);
434f12894f8SJason M. Bills }
435f12894f8SJason M. Bills 
436f12894f8SJason M. Bills /**
437f12894f8SJason M. Bills  * @internal
438f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
439f12894f8SJason M. Bills  * property
440f12894f8SJason M. Bills  *
441f12894f8SJason M. Bills  * See header file for more information
442f12894f8SJason M. Bills  * @endinternal
443f12894f8SJason M. Bills  */
444b5c07418SJames Feist nlohmann::json propertyValueFormatError(const std::string& arg1,
445a08b46ccSJason M. Bills                                         const std::string& arg2)
446f12894f8SJason M. Bills {
447*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
448*b6cd31e1SEd Tanous     return getLog(
449*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::propertyValueFormatError,
450*b6cd31e1SEd Tanous         args);
451b5c07418SJames Feist }
452b5c07418SJames Feist 
453b5c07418SJames Feist void propertyValueFormatError(crow::Response& res, const std::string& arg1,
454b5c07418SJames Feist                               const std::string& arg2)
455b5c07418SJames Feist {
456b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
457b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
458f12894f8SJason M. Bills }
459f12894f8SJason M. Bills 
460f12894f8SJason M. Bills /**
461f12894f8SJason M. Bills  * @internal
462f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
463f12894f8SJason M. Bills  * property
464f12894f8SJason M. Bills  *
465f12894f8SJason M. Bills  * See header file for more information
466f12894f8SJason M. Bills  * @endinternal
467f12894f8SJason M. Bills  */
468b5c07418SJames Feist nlohmann::json propertyValueNotInList(const std::string& arg1,
469a08b46ccSJason M. Bills                                       const std::string& arg2)
470f12894f8SJason M. Bills {
471*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
472*b6cd31e1SEd Tanous     return getLog(
473*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::propertyValueNotInList, args);
474b5c07418SJames Feist }
475b5c07418SJames Feist 
476b5c07418SJames Feist void propertyValueNotInList(crow::Response& res, const std::string& arg1,
477b5c07418SJames Feist                             const std::string& arg2)
478b5c07418SJames Feist {
479b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
480b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
481f4c4dcf4SKowalski, Kamil }
482f4c4dcf4SKowalski, Kamil 
483f4c4dcf4SKowalski, Kamil /**
484f4c4dcf4SKowalski, Kamil  * @internal
485f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
486f4c4dcf4SKowalski, Kamil  *
487f4c4dcf4SKowalski, Kamil  * See header file for more information
488f4c4dcf4SKowalski, Kamil  * @endinternal
489f4c4dcf4SKowalski, Kamil  */
490ace85d60SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1)
4911abe55efSEd Tanous {
492*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
493*b6cd31e1SEd Tanous         std::string_view{arg1.data(), arg1.size()}};
494*b6cd31e1SEd Tanous     return getLog(
495*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceAtUriInUnknownFormat,
496*b6cd31e1SEd Tanous         args);
497b5c07418SJames Feist }
498b5c07418SJames Feist 
499ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res,
500ace85d60SEd Tanous                                   const boost::urls::url_view& arg1)
501b5c07418SJames Feist {
502b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
503b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
504f4c4dcf4SKowalski, Kamil }
505f4c4dcf4SKowalski, Kamil 
506f4c4dcf4SKowalski, Kamil /**
507f4c4dcf4SKowalski, Kamil  * @internal
50881856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
50981856681SAsmitha Karunanithi  *
51081856681SAsmitha Karunanithi  * See header file for more information
51181856681SAsmitha Karunanithi  * @endinternal
51281856681SAsmitha Karunanithi  */
51381856681SAsmitha Karunanithi nlohmann::json serviceDisabled(const std::string& arg1)
51481856681SAsmitha Karunanithi {
515*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1};
516*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::serviceDisabled,
517*b6cd31e1SEd Tanous                   args);
51881856681SAsmitha Karunanithi }
51981856681SAsmitha Karunanithi 
52081856681SAsmitha Karunanithi void serviceDisabled(crow::Response& res, const std::string& arg1)
52181856681SAsmitha Karunanithi {
52281856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
52381856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
52481856681SAsmitha Karunanithi }
52581856681SAsmitha Karunanithi 
52681856681SAsmitha Karunanithi /**
52781856681SAsmitha Karunanithi  * @internal
528f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
529f4c4dcf4SKowalski, Kamil  *
530f4c4dcf4SKowalski, Kamil  * See header file for more information
531f4c4dcf4SKowalski, Kamil  * @endinternal
532f4c4dcf4SKowalski, Kamil  */
533b5c07418SJames Feist nlohmann::json serviceInUnknownState(void)
5341abe55efSEd Tanous {
535*b6cd31e1SEd Tanous     return getLog(
536*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::serviceInUnknownState, {});
537b5c07418SJames Feist }
538b5c07418SJames Feist 
539b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
540b5c07418SJames Feist {
541b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
542b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
543f4c4dcf4SKowalski, Kamil }
544f4c4dcf4SKowalski, Kamil 
545f4c4dcf4SKowalski, Kamil /**
546f4c4dcf4SKowalski, Kamil  * @internal
547f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
548f4c4dcf4SKowalski, Kamil  *
549f4c4dcf4SKowalski, Kamil  * See header file for more information
550f4c4dcf4SKowalski, Kamil  * @endinternal
551f4c4dcf4SKowalski, Kamil  */
552b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void)
5531abe55efSEd Tanous {
554*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::
555*b6cd31e1SEd Tanous                       eventSubscriptionLimitExceeded,
556*b6cd31e1SEd Tanous                   {});
557b5c07418SJames Feist }
558b5c07418SJames Feist 
559b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
560b5c07418SJames Feist {
561789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
562b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
563f4c4dcf4SKowalski, Kamil }
564f4c4dcf4SKowalski, Kamil 
565f4c4dcf4SKowalski, Kamil /**
566f4c4dcf4SKowalski, Kamil  * @internal
567f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
568f4c4dcf4SKowalski, Kamil  *
569f4c4dcf4SKowalski, Kamil  * See header file for more information
570f4c4dcf4SKowalski, Kamil  * @endinternal
571f4c4dcf4SKowalski, Kamil  */
572b5c07418SJames Feist nlohmann::json actionParameterMissing(const std::string& arg1,
5731abe55efSEd Tanous                                       const std::string& arg2)
5741abe55efSEd Tanous {
575*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
576*b6cd31e1SEd Tanous     return getLog(
577*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::actionParameterMissing, args);
578b5c07418SJames Feist }
579b5c07418SJames Feist 
580b5c07418SJames Feist void actionParameterMissing(crow::Response& res, const std::string& arg1,
581b5c07418SJames Feist                             const std::string& arg2)
582b5c07418SJames Feist {
583b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
584b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
585f4c4dcf4SKowalski, Kamil }
586f4c4dcf4SKowalski, Kamil 
587f4c4dcf4SKowalski, Kamil /**
588f4c4dcf4SKowalski, Kamil  * @internal
589f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
590f4c4dcf4SKowalski, Kamil  *
591f4c4dcf4SKowalski, Kamil  * See header file for more information
592f4c4dcf4SKowalski, Kamil  * @endinternal
593f4c4dcf4SKowalski, Kamil  */
594331b2017SEd Tanous nlohmann::json stringValueTooLong(const std::string& arg1, int arg2)
5951abe55efSEd Tanous {
596*b6cd31e1SEd Tanous     std::string arg2String = std::to_string(arg2);
597*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2String};
598*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::stringValueTooLong,
599*b6cd31e1SEd Tanous                   args);
600b5c07418SJames Feist }
601b5c07418SJames Feist 
602331b2017SEd Tanous void stringValueTooLong(crow::Response& res, const std::string& arg1, int arg2)
603b5c07418SJames Feist {
604b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
605b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
606f4c4dcf4SKowalski, Kamil }
607f4c4dcf4SKowalski, Kamil 
608f4c4dcf4SKowalski, Kamil /**
609f4c4dcf4SKowalski, Kamil  * @internal
610cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
611cc9139ecSJason M. Bills  *
612cc9139ecSJason M. Bills  * See header file for more information
613cc9139ecSJason M. Bills  * @endinternal
614cc9139ecSJason M. Bills  */
615b5c07418SJames Feist nlohmann::json sessionTerminated(void)
616cc9139ecSJason M. Bills {
617*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::sessionTerminated,
618*b6cd31e1SEd Tanous                   {});
619b5c07418SJames Feist }
620b5c07418SJames Feist 
621b5c07418SJames Feist void sessionTerminated(crow::Response& res)
622b5c07418SJames Feist {
623b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
624b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
625cc9139ecSJason M. Bills }
626cc9139ecSJason M. Bills 
627cc9139ecSJason M. Bills /**
628cc9139ecSJason M. Bills  * @internal
629684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
630684bb4b8SJason M. Bills  *
631684bb4b8SJason M. Bills  * See header file for more information
632684bb4b8SJason M. Bills  * @endinternal
633684bb4b8SJason M. Bills  */
634684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void)
635684bb4b8SJason M. Bills {
636*b6cd31e1SEd Tanous     return getLog(
637*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::subscriptionTerminated, {});
638684bb4b8SJason M. Bills }
639684bb4b8SJason M. Bills 
640684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
641684bb4b8SJason M. Bills {
642684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
643684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
644684bb4b8SJason M. Bills }
645684bb4b8SJason M. Bills 
646684bb4b8SJason M. Bills /**
647684bb4b8SJason M. Bills  * @internal
648cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
649cc9139ecSJason M. Bills  *
650cc9139ecSJason M. Bills  * See header file for more information
651cc9139ecSJason M. Bills  * @endinternal
652cc9139ecSJason M. Bills  */
653b5c07418SJames Feist nlohmann::json resourceTypeIncompatible(const std::string& arg1,
654cc9139ecSJason M. Bills                                         const std::string& arg2)
655cc9139ecSJason M. Bills {
656*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
657*b6cd31e1SEd Tanous     return getLog(
658*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceTypeIncompatible,
659*b6cd31e1SEd Tanous         args);
660b5c07418SJames Feist }
661b5c07418SJames Feist 
662b5c07418SJames Feist void resourceTypeIncompatible(crow::Response& res, const std::string& arg1,
663b5c07418SJames Feist                               const std::string& arg2)
664b5c07418SJames Feist {
665b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
666b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
667cc9139ecSJason M. Bills }
668cc9139ecSJason M. Bills 
669cc9139ecSJason M. Bills /**
670cc9139ecSJason M. Bills  * @internal
671684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
672684bb4b8SJason M. Bills  *
673684bb4b8SJason M. Bills  * See header file for more information
674684bb4b8SJason M. Bills  * @endinternal
675684bb4b8SJason M. Bills  */
676ace85d60SEd Tanous nlohmann::json resetRequired(const boost::urls::url_view& arg1,
677ace85d60SEd Tanous                              const std::string& arg2)
678684bb4b8SJason M. Bills {
679*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{
680*b6cd31e1SEd Tanous         std::string_view(arg1.data(), arg1.size()), arg2};
681*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resetRequired,
682*b6cd31e1SEd Tanous                   args);
683684bb4b8SJason M. Bills }
684684bb4b8SJason M. Bills 
685ace85d60SEd Tanous void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
686684bb4b8SJason M. Bills                    const std::string& arg2)
687684bb4b8SJason M. Bills {
688684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
689684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
690684bb4b8SJason M. Bills }
691684bb4b8SJason M. Bills 
692684bb4b8SJason M. Bills /**
693684bb4b8SJason M. Bills  * @internal
694684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
695684bb4b8SJason M. Bills  *
696684bb4b8SJason M. Bills  * See header file for more information
697684bb4b8SJason M. Bills  * @endinternal
698684bb4b8SJason M. Bills  */
699684bb4b8SJason M. Bills nlohmann::json chassisPowerStateOnRequired(const std::string& arg1)
700684bb4b8SJason M. Bills {
701*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1};
702*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resetRequired,
703*b6cd31e1SEd Tanous                   args);
704684bb4b8SJason M. Bills }
705684bb4b8SJason M. Bills 
706684bb4b8SJason M. Bills void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1)
707684bb4b8SJason M. Bills {
708684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
709684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
710684bb4b8SJason M. Bills }
711684bb4b8SJason M. Bills 
712684bb4b8SJason M. Bills /**
713684bb4b8SJason M. Bills  * @internal
714684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
715684bb4b8SJason M. Bills  *
716684bb4b8SJason M. Bills  * See header file for more information
717684bb4b8SJason M. Bills  * @endinternal
718684bb4b8SJason M. Bills  */
719684bb4b8SJason M. Bills nlohmann::json chassisPowerStateOffRequired(const std::string& arg1)
720684bb4b8SJason M. Bills {
721*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1};
722*b6cd31e1SEd Tanous     return getLog(
723*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::chassisPowerStateOffRequired,
724*b6cd31e1SEd Tanous         args);
725684bb4b8SJason M. Bills }
726684bb4b8SJason M. Bills 
727684bb4b8SJason M. Bills void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1)
728684bb4b8SJason M. Bills {
729684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
730684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
731684bb4b8SJason M. Bills }
732684bb4b8SJason M. Bills 
733684bb4b8SJason M. Bills /**
734684bb4b8SJason M. Bills  * @internal
735684bb4b8SJason M. Bills  * @brief Formats PropertyValueConflict message into JSON
736684bb4b8SJason M. Bills  *
737684bb4b8SJason M. Bills  * See header file for more information
738684bb4b8SJason M. Bills  * @endinternal
739684bb4b8SJason M. Bills  */
740684bb4b8SJason M. Bills nlohmann::json propertyValueConflict(const std::string& arg1,
741684bb4b8SJason M. Bills                                      const std::string& arg2)
742684bb4b8SJason M. Bills {
743*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
744*b6cd31e1SEd Tanous     return getLog(
745*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::propertyValueConflict, args);
746684bb4b8SJason M. Bills }
747684bb4b8SJason M. Bills 
748684bb4b8SJason M. Bills void propertyValueConflict(crow::Response& res, const std::string& arg1,
749684bb4b8SJason M. Bills                            const std::string& arg2)
750684bb4b8SJason M. Bills {
751684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
752684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
753684bb4b8SJason M. Bills }
754684bb4b8SJason M. Bills 
755684bb4b8SJason M. Bills /**
756684bb4b8SJason M. Bills  * @internal
757684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
758684bb4b8SJason M. Bills  *
759684bb4b8SJason M. Bills  * See header file for more information
760684bb4b8SJason M. Bills  * @endinternal
761684bb4b8SJason M. Bills  */
762684bb4b8SJason M. Bills nlohmann::json propertyValueIncorrect(const std::string& arg1,
763684bb4b8SJason M. Bills                                       const std::string& arg2)
764684bb4b8SJason M. Bills {
765*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
766*b6cd31e1SEd Tanous     return getLog(
767*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::propertyValueIncorrect, args);
768684bb4b8SJason M. Bills }
769684bb4b8SJason M. Bills 
770684bb4b8SJason M. Bills void propertyValueIncorrect(crow::Response& res, const std::string& arg1,
771684bb4b8SJason M. Bills                             const std::string& arg2)
772684bb4b8SJason M. Bills {
773684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
774684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
775684bb4b8SJason M. Bills }
776684bb4b8SJason M. Bills 
777684bb4b8SJason M. Bills /**
778684bb4b8SJason M. Bills  * @internal
779684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
780684bb4b8SJason M. Bills  *
781684bb4b8SJason M. Bills  * See header file for more information
782684bb4b8SJason M. Bills  * @endinternal
783684bb4b8SJason M. Bills  */
784ace85d60SEd Tanous nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1)
785684bb4b8SJason M. Bills {
786*b6cd31e1SEd Tanous 
787*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
788*b6cd31e1SEd Tanous         std::string_view(arg1.data(), arg1.size())};
789*b6cd31e1SEd Tanous     return getLog(
790*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::resourceCreationConflict,
791*b6cd31e1SEd Tanous         args);
792684bb4b8SJason M. Bills }
793684bb4b8SJason M. Bills 
794ace85d60SEd Tanous void resourceCreationConflict(crow::Response& res,
795ace85d60SEd Tanous                               const boost::urls::url_view& arg1)
796684bb4b8SJason M. Bills {
797684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
798684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
799684bb4b8SJason M. Bills }
800684bb4b8SJason M. Bills 
801684bb4b8SJason M. Bills /**
802684bb4b8SJason M. Bills  * @internal
803684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded message into JSON
804684bb4b8SJason M. Bills  *
805684bb4b8SJason M. Bills  * See header file for more information
806684bb4b8SJason M. Bills  * @endinternal
807684bb4b8SJason M. Bills  */
808684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void)
809684bb4b8SJason M. Bills {
810*b6cd31e1SEd Tanous     return getLog(
811*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::maximumErrorsExceeded, {});
812684bb4b8SJason M. Bills }
813684bb4b8SJason M. Bills 
814684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
815684bb4b8SJason M. Bills {
816684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
817684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
818684bb4b8SJason M. Bills }
819684bb4b8SJason M. Bills 
820684bb4b8SJason M. Bills /**
821684bb4b8SJason M. Bills  * @internal
822684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
823684bb4b8SJason M. Bills  *
824684bb4b8SJason M. Bills  * See header file for more information
825684bb4b8SJason M. Bills  * @endinternal
826684bb4b8SJason M. Bills  */
827684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void)
828684bb4b8SJason M. Bills {
829*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::preconditionFailed,
830*b6cd31e1SEd Tanous                   {});
831684bb4b8SJason M. Bills }
832684bb4b8SJason M. Bills 
833684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
834684bb4b8SJason M. Bills {
8354df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
836684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
837684bb4b8SJason M. Bills }
838684bb4b8SJason M. Bills 
839684bb4b8SJason M. Bills /**
840684bb4b8SJason M. Bills  * @internal
841684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
842684bb4b8SJason M. Bills  *
843684bb4b8SJason M. Bills  * See header file for more information
844684bb4b8SJason M. Bills  * @endinternal
845684bb4b8SJason M. Bills  */
846684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void)
847684bb4b8SJason M. Bills {
848*b6cd31e1SEd Tanous     return getLog(
849*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::preconditionRequired, {});
850684bb4b8SJason M. Bills }
851684bb4b8SJason M. Bills 
852684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
853684bb4b8SJason M. Bills {
854684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
855684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
856684bb4b8SJason M. Bills }
857684bb4b8SJason M. Bills 
858684bb4b8SJason M. Bills /**
859684bb4b8SJason M. Bills  * @internal
860684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
861684bb4b8SJason M. Bills  *
862684bb4b8SJason M. Bills  * See header file for more information
863684bb4b8SJason M. Bills  * @endinternal
864684bb4b8SJason M. Bills  */
865684bb4b8SJason M. Bills nlohmann::json operationFailed(void)
866684bb4b8SJason M. Bills {
867*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::operationFailed,
868*b6cd31e1SEd Tanous                   {});
869684bb4b8SJason M. Bills }
870684bb4b8SJason M. Bills 
871684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
872684bb4b8SJason M. Bills {
873684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
874684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
875684bb4b8SJason M. Bills }
876684bb4b8SJason M. Bills 
877684bb4b8SJason M. Bills /**
878684bb4b8SJason M. Bills  * @internal
879684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
880684bb4b8SJason M. Bills  *
881684bb4b8SJason M. Bills  * See header file for more information
882684bb4b8SJason M. Bills  * @endinternal
883684bb4b8SJason M. Bills  */
884684bb4b8SJason M. Bills nlohmann::json operationTimeout(void)
885684bb4b8SJason M. Bills {
886*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::operationTimeout,
887*b6cd31e1SEd Tanous                   {});
888684bb4b8SJason M. Bills }
889684bb4b8SJason M. Bills 
890684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
891684bb4b8SJason M. Bills {
892684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
893684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
894684bb4b8SJason M. Bills }
895684bb4b8SJason M. Bills 
896684bb4b8SJason M. Bills /**
897684bb4b8SJason M. Bills  * @internal
898f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
899f12894f8SJason M. Bills  * property
900f12894f8SJason M. Bills  *
901f12894f8SJason M. Bills  * See header file for more information
902f12894f8SJason M. Bills  * @endinternal
903f12894f8SJason M. Bills  */
904b5c07418SJames Feist nlohmann::json propertyValueTypeError(const std::string& arg1,
905a08b46ccSJason M. Bills                                       const std::string& arg2)
906f12894f8SJason M. Bills {
907*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
908*b6cd31e1SEd Tanous     return getLog(
909*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::propertyValueTypeError, args);
910b5c07418SJames Feist }
911b5c07418SJames Feist 
912b5c07418SJames Feist void propertyValueTypeError(crow::Response& res, const std::string& arg1,
913b5c07418SJames Feist                             const std::string& arg2)
914b5c07418SJames Feist {
915b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
916b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
917f4c4dcf4SKowalski, Kamil }
918f4c4dcf4SKowalski, Kamil 
919f4c4dcf4SKowalski, Kamil /**
920f4c4dcf4SKowalski, Kamil  * @internal
921*b6cd31e1SEd Tanous  * @brief Formats ResourceNotFound message into JSONd
922f4c4dcf4SKowalski, Kamil  *
923f4c4dcf4SKowalski, Kamil  * See header file for more information
924f4c4dcf4SKowalski, Kamil  * @endinternal
925f4c4dcf4SKowalski, Kamil  */
926b5c07418SJames Feist nlohmann::json resourceNotFound(const std::string& arg1,
9271abe55efSEd Tanous                                 const std::string& arg2)
9281abe55efSEd Tanous {
929*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
930*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resourceNotFound,
931*b6cd31e1SEd Tanous                   args);
932b5c07418SJames Feist }
933b5c07418SJames Feist 
934b5c07418SJames Feist void resourceNotFound(crow::Response& res, const std::string& arg1,
935b5c07418SJames Feist                       const std::string& arg2)
936b5c07418SJames Feist {
937b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
938b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
939f4c4dcf4SKowalski, Kamil }
940f4c4dcf4SKowalski, Kamil 
941f4c4dcf4SKowalski, Kamil /**
942f4c4dcf4SKowalski, Kamil  * @internal
943f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
944f4c4dcf4SKowalski, Kamil  *
945f4c4dcf4SKowalski, Kamil  * See header file for more information
946f4c4dcf4SKowalski, Kamil  * @endinternal
947f4c4dcf4SKowalski, Kamil  */
948ace85d60SEd Tanous nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1)
9491abe55efSEd Tanous {
950*b6cd31e1SEd Tanous 
951*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
952*b6cd31e1SEd Tanous         std::string_view(arg1.data(), arg1.size())};
953*b6cd31e1SEd Tanous     return getLog(
954*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::couldNotEstablishConnection,
955*b6cd31e1SEd Tanous         args);
956b5c07418SJames Feist }
957b5c07418SJames Feist 
958ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res,
959ace85d60SEd Tanous                                  const boost::urls::url_view& arg1)
960b5c07418SJames Feist {
961b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
962b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
963f4c4dcf4SKowalski, Kamil }
964f4c4dcf4SKowalski, Kamil 
965f4c4dcf4SKowalski, Kamil /**
966f4c4dcf4SKowalski, Kamil  * @internal
967f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
968f12894f8SJason M. Bills  * property
969f12894f8SJason M. Bills  *
970f12894f8SJason M. Bills  * See header file for more information
971f12894f8SJason M. Bills  * @endinternal
972f12894f8SJason M. Bills  */
973b5c07418SJames Feist nlohmann::json propertyNotWritable(const std::string& arg1)
974f12894f8SJason M. Bills {
975*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1};
976*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::propertyNotWritable,
977*b6cd31e1SEd Tanous                   args);
978b5c07418SJames Feist }
979b5c07418SJames Feist 
980b5c07418SJames Feist void propertyNotWritable(crow::Response& res, const std::string& arg1)
981b5c07418SJames Feist {
982b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
983b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
984f4c4dcf4SKowalski, Kamil }
985f4c4dcf4SKowalski, Kamil 
986f4c4dcf4SKowalski, Kamil /**
987f4c4dcf4SKowalski, Kamil  * @internal
988f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
989f4c4dcf4SKowalski, Kamil  *
990f4c4dcf4SKowalski, Kamil  * See header file for more information
991f4c4dcf4SKowalski, Kamil  * @endinternal
992f4c4dcf4SKowalski, Kamil  */
993b5c07418SJames Feist nlohmann::json queryParameterValueTypeError(const std::string& arg1,
9941abe55efSEd Tanous                                             const std::string& arg2)
9951abe55efSEd Tanous {
996*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
997*b6cd31e1SEd Tanous     return getLog(
998*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::queryParameterValueTypeError,
999*b6cd31e1SEd Tanous         args);
1000b5c07418SJames Feist }
1001b5c07418SJames Feist 
1002b5c07418SJames Feist void queryParameterValueTypeError(crow::Response& res, const std::string& arg1,
1003b5c07418SJames Feist                                   const std::string& arg2)
1004b5c07418SJames Feist {
1005b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1006b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1007b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
1008f4c4dcf4SKowalski, Kamil }
1009f4c4dcf4SKowalski, Kamil 
1010f4c4dcf4SKowalski, Kamil /**
1011f4c4dcf4SKowalski, Kamil  * @internal
1012f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
1013f4c4dcf4SKowalski, Kamil  *
1014f4c4dcf4SKowalski, Kamil  * See header file for more information
1015f4c4dcf4SKowalski, Kamil  * @endinternal
1016f4c4dcf4SKowalski, Kamil  */
1017b5c07418SJames Feist nlohmann::json serviceShuttingDown(void)
10181abe55efSEd Tanous {
1019*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::serviceShuttingDown,
1020*b6cd31e1SEd Tanous                   {});
1021b5c07418SJames Feist }
1022b5c07418SJames Feist 
1023b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
1024b5c07418SJames Feist {
1025b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1026b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1027f4c4dcf4SKowalski, Kamil }
1028f4c4dcf4SKowalski, Kamil 
1029f4c4dcf4SKowalski, Kamil /**
1030f4c4dcf4SKowalski, Kamil  * @internal
1031f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
1032f4c4dcf4SKowalski, Kamil  *
1033f4c4dcf4SKowalski, Kamil  * See header file for more information
1034f4c4dcf4SKowalski, Kamil  * @endinternal
1035f4c4dcf4SKowalski, Kamil  */
1036b5c07418SJames Feist nlohmann::json actionParameterDuplicate(const std::string& arg1,
10371abe55efSEd Tanous                                         const std::string& arg2)
10381abe55efSEd Tanous {
1039*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
1040*b6cd31e1SEd Tanous     return getLog(
1041*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::actionParameterDuplicate,
1042*b6cd31e1SEd Tanous         args);
1043b5c07418SJames Feist }
1044b5c07418SJames Feist 
1045b5c07418SJames Feist void actionParameterDuplicate(crow::Response& res, const std::string& arg1,
1046b5c07418SJames Feist                               const std::string& arg2)
1047b5c07418SJames Feist {
1048b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1049b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1050f4c4dcf4SKowalski, Kamil }
1051f4c4dcf4SKowalski, Kamil 
1052f4c4dcf4SKowalski, Kamil /**
1053f4c4dcf4SKowalski, Kamil  * @internal
1054f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1055f4c4dcf4SKowalski, Kamil  *
1056f4c4dcf4SKowalski, Kamil  * See header file for more information
1057f4c4dcf4SKowalski, Kamil  * @endinternal
1058f4c4dcf4SKowalski, Kamil  */
1059b5c07418SJames Feist nlohmann::json actionParameterNotSupported(const std::string& arg1,
10601abe55efSEd Tanous                                            const std::string& arg2)
10611abe55efSEd Tanous {
1062*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
1063*b6cd31e1SEd Tanous     return getLog(
1064*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::actionParameterNotSupported,
1065*b6cd31e1SEd Tanous         args);
1066b5c07418SJames Feist }
1067b5c07418SJames Feist 
1068b5c07418SJames Feist void actionParameterNotSupported(crow::Response& res, const std::string& arg1,
1069b5c07418SJames Feist                                  const std::string& arg2)
1070b5c07418SJames Feist {
1071b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1072b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1073b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1074f4c4dcf4SKowalski, Kamil }
1075f4c4dcf4SKowalski, Kamil 
1076f4c4dcf4SKowalski, Kamil /**
1077f4c4dcf4SKowalski, Kamil  * @internal
1078f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1079f4c4dcf4SKowalski, Kamil  *
1080f4c4dcf4SKowalski, Kamil  * See header file for more information
1081f4c4dcf4SKowalski, Kamil  * @endinternal
1082f4c4dcf4SKowalski, Kamil  */
1083ace85d60SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1,
10841abe55efSEd Tanous                                             const std::string& arg2)
10851abe55efSEd Tanous {
1086*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{
1087*b6cd31e1SEd Tanous         std::string_view(arg1.data(), arg1.size()), arg2};
1088*b6cd31e1SEd Tanous     return getLog(
1089*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::sourceDoesNotSupportProtocol,
1090*b6cd31e1SEd Tanous         args);
1091b5c07418SJames Feist }
1092b5c07418SJames Feist 
1093ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res,
1094ace85d60SEd Tanous                                   const boost::urls::url_view& arg1,
1095b5c07418SJames Feist                                   const std::string& arg2)
1096b5c07418SJames Feist {
1097b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1098b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1099b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1100f4c4dcf4SKowalski, Kamil }
1101f4c4dcf4SKowalski, Kamil 
1102f4c4dcf4SKowalski, Kamil /**
1103f4c4dcf4SKowalski, Kamil  * @internal
1104f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1105f4c4dcf4SKowalski, Kamil  *
1106f4c4dcf4SKowalski, Kamil  * See header file for more information
1107f4c4dcf4SKowalski, Kamil  * @endinternal
1108f4c4dcf4SKowalski, Kamil  */
1109b5c07418SJames Feist nlohmann::json accountRemoved(void)
11101abe55efSEd Tanous {
1111*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::accountRemoved, {});
1112b5c07418SJames Feist }
1113b5c07418SJames Feist 
1114b5c07418SJames Feist void accountRemoved(crow::Response& res)
1115b5c07418SJames Feist {
1116b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1117b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1118f4c4dcf4SKowalski, Kamil }
1119f4c4dcf4SKowalski, Kamil 
1120f4c4dcf4SKowalski, Kamil /**
1121f4c4dcf4SKowalski, Kamil  * @internal
1122f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1123f4c4dcf4SKowalski, Kamil  *
1124f4c4dcf4SKowalski, Kamil  * See header file for more information
1125f4c4dcf4SKowalski, Kamil  * @endinternal
1126f4c4dcf4SKowalski, Kamil  */
1127ace85d60SEd Tanous nlohmann::json accessDenied(const boost::urls::url_view& arg1)
11281abe55efSEd Tanous {
1129*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
1130*b6cd31e1SEd Tanous         std::string_view(arg1.data(), arg1.size())};
1131*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::accessDenied, args);
1132b5c07418SJames Feist }
1133b5c07418SJames Feist 
1134ace85d60SEd Tanous void accessDenied(crow::Response& res, const boost::urls::url_view& arg1)
1135b5c07418SJames Feist {
1136b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1137b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1138f4c4dcf4SKowalski, Kamil }
1139f4c4dcf4SKowalski, Kamil 
1140f4c4dcf4SKowalski, Kamil /**
1141f4c4dcf4SKowalski, Kamil  * @internal
1142f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1143f4c4dcf4SKowalski, Kamil  *
1144f4c4dcf4SKowalski, Kamil  * See header file for more information
1145f4c4dcf4SKowalski, Kamil  * @endinternal
1146f4c4dcf4SKowalski, Kamil  */
1147b5c07418SJames Feist nlohmann::json queryNotSupported(void)
11481abe55efSEd Tanous {
1149*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::queryNotSupported,
1150*b6cd31e1SEd Tanous                   {});
1151b5c07418SJames Feist }
1152b5c07418SJames Feist 
1153b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1154b5c07418SJames Feist {
1155b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1156b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1157f4c4dcf4SKowalski, Kamil }
1158f4c4dcf4SKowalski, Kamil 
1159f4c4dcf4SKowalski, Kamil /**
1160f4c4dcf4SKowalski, Kamil  * @internal
1161f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1162f4c4dcf4SKowalski, Kamil  *
1163f4c4dcf4SKowalski, Kamil  * See header file for more information
1164f4c4dcf4SKowalski, Kamil  * @endinternal
1165f4c4dcf4SKowalski, Kamil  */
1166b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void)
11671abe55efSEd Tanous {
1168*b6cd31e1SEd Tanous     return getLog(
1169*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::createLimitReachedForResource,
1170*b6cd31e1SEd Tanous         {});
1171b5c07418SJames Feist }
1172b5c07418SJames Feist 
1173b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1174b5c07418SJames Feist {
1175b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1176b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1177f4c4dcf4SKowalski, Kamil }
1178f4c4dcf4SKowalski, Kamil 
1179f4c4dcf4SKowalski, Kamil /**
1180f4c4dcf4SKowalski, Kamil  * @internal
1181f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1182f4c4dcf4SKowalski, Kamil  *
1183f4c4dcf4SKowalski, Kamil  * See header file for more information
1184f4c4dcf4SKowalski, Kamil  * @endinternal
1185f4c4dcf4SKowalski, Kamil  */
1186b5c07418SJames Feist nlohmann::json generalError(void)
11871abe55efSEd Tanous {
1188*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::generalError, {});
1189b5c07418SJames Feist }
1190b5c07418SJames Feist 
1191b5c07418SJames Feist void generalError(crow::Response& res)
1192b5c07418SJames Feist {
1193b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1194b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1195f4c4dcf4SKowalski, Kamil }
1196f4c4dcf4SKowalski, Kamil 
1197f4c4dcf4SKowalski, Kamil /**
1198f4c4dcf4SKowalski, Kamil  * @internal
1199f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1200f4c4dcf4SKowalski, Kamil  *
1201f4c4dcf4SKowalski, Kamil  * See header file for more information
1202f4c4dcf4SKowalski, Kamil  * @endinternal
1203f4c4dcf4SKowalski, Kamil  */
1204b5c07418SJames Feist nlohmann::json success(void)
12051abe55efSEd Tanous {
1206*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::success, {});
1207b5c07418SJames Feist }
1208b5c07418SJames Feist 
1209b5c07418SJames Feist void success(crow::Response& res)
1210b5c07418SJames Feist {
1211b5c07418SJames Feist     // don't set res.result here because success is the default and any
1212b5c07418SJames Feist     // error should overwrite the default
1213b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1214f12894f8SJason M. Bills }
1215f12894f8SJason M. Bills 
1216f12894f8SJason M. Bills /**
1217f12894f8SJason M. Bills  * @internal
1218f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1219f4c4dcf4SKowalski, Kamil  *
1220f4c4dcf4SKowalski, Kamil  * See header file for more information
1221f4c4dcf4SKowalski, Kamil  * @endinternal
1222f4c4dcf4SKowalski, Kamil  */
1223b5c07418SJames Feist nlohmann::json created(void)
12241abe55efSEd Tanous {
1225*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::created, {});
1226b5c07418SJames Feist }
1227b5c07418SJames Feist 
1228b5c07418SJames Feist void created(crow::Response& res)
1229b5c07418SJames Feist {
1230b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1231b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1232f4c4dcf4SKowalski, Kamil }
1233f4c4dcf4SKowalski, Kamil 
1234f4c4dcf4SKowalski, Kamil /**
1235f4c4dcf4SKowalski, Kamil  * @internal
1236cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1237cc9139ecSJason M. Bills  *
1238cc9139ecSJason M. Bills  * See header file for more information
1239cc9139ecSJason M. Bills  * @endinternal
1240cc9139ecSJason M. Bills  */
1241b5c07418SJames Feist nlohmann::json noOperation(void)
1242cc9139ecSJason M. Bills {
1243*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::noOperation, {});
1244b5c07418SJames Feist }
1245b5c07418SJames Feist 
1246b5c07418SJames Feist void noOperation(crow::Response& res)
1247b5c07418SJames Feist {
1248b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1249b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1250cc9139ecSJason M. Bills }
1251cc9139ecSJason M. Bills 
1252cc9139ecSJason M. Bills /**
1253cc9139ecSJason M. Bills  * @internal
1254b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1255b5c07418SJames Feist  * property
1256f12894f8SJason M. Bills  *
1257f12894f8SJason M. Bills  * See header file for more information
1258f12894f8SJason M. Bills  * @endinternal
1259f12894f8SJason M. Bills  */
1260b5c07418SJames Feist nlohmann::json propertyUnknown(const std::string& arg1)
1261b5c07418SJames Feist {
1262*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1};
1263*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::propertyUnknown,
1264*b6cd31e1SEd Tanous                   args);
1265b5c07418SJames Feist }
1266b5c07418SJames Feist 
1267a08b46ccSJason M. Bills void propertyUnknown(crow::Response& res, const std::string& arg1)
1268f12894f8SJason M. Bills {
1269f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1270b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1);
1271f4c4dcf4SKowalski, Kamil }
1272f4c4dcf4SKowalski, Kamil 
1273f4c4dcf4SKowalski, Kamil /**
1274f4c4dcf4SKowalski, Kamil  * @internal
1275f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1276f4c4dcf4SKowalski, Kamil  *
1277f4c4dcf4SKowalski, Kamil  * See header file for more information
1278f4c4dcf4SKowalski, Kamil  * @endinternal
1279f4c4dcf4SKowalski, Kamil  */
1280b5c07418SJames Feist nlohmann::json noValidSession(void)
12811abe55efSEd Tanous {
1282*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::noValidSession, {});
1283b5c07418SJames Feist }
1284b5c07418SJames Feist 
1285b5c07418SJames Feist void noValidSession(crow::Response& res)
1286b5c07418SJames Feist {
1287b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1288b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1289f4c4dcf4SKowalski, Kamil }
1290f4c4dcf4SKowalski, Kamil 
1291f4c4dcf4SKowalski, Kamil /**
1292f4c4dcf4SKowalski, Kamil  * @internal
1293f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1294f4c4dcf4SKowalski, Kamil  *
1295f4c4dcf4SKowalski, Kamil  * See header file for more information
1296f4c4dcf4SKowalski, Kamil  * @endinternal
1297f4c4dcf4SKowalski, Kamil  */
1298ace85d60SEd Tanous nlohmann::json invalidObject(const boost::urls::url_view& arg1)
12991abe55efSEd Tanous {
1300*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
1301*b6cd31e1SEd Tanous         std::string_view(arg1.data(), arg1.size())};
1302*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::invalidObject,
1303*b6cd31e1SEd Tanous                   args);
1304b5c07418SJames Feist }
1305b5c07418SJames Feist 
1306ace85d60SEd Tanous void invalidObject(crow::Response& res, const boost::urls::url_view& arg1)
1307b5c07418SJames Feist {
1308b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1309b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1310f4c4dcf4SKowalski, Kamil }
1311f4c4dcf4SKowalski, Kamil 
1312f4c4dcf4SKowalski, Kamil /**
1313f4c4dcf4SKowalski, Kamil  * @internal
1314f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1315f4c4dcf4SKowalski, Kamil  *
1316f4c4dcf4SKowalski, Kamil  * See header file for more information
1317f4c4dcf4SKowalski, Kamil  * @endinternal
1318f4c4dcf4SKowalski, Kamil  */
1319b5c07418SJames Feist nlohmann::json resourceInStandby(void)
13201abe55efSEd Tanous {
1321*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resourceInStandby,
1322*b6cd31e1SEd Tanous                   {});
1323b5c07418SJames Feist }
1324b5c07418SJames Feist 
1325b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1326b5c07418SJames Feist {
1327b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1328b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1329f4c4dcf4SKowalski, Kamil }
1330f4c4dcf4SKowalski, Kamil 
1331f4c4dcf4SKowalski, Kamil /**
1332f4c4dcf4SKowalski, Kamil  * @internal
1333f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1334f4c4dcf4SKowalski, Kamil  *
1335f4c4dcf4SKowalski, Kamil  * See header file for more information
1336f4c4dcf4SKowalski, Kamil  * @endinternal
1337f4c4dcf4SKowalski, Kamil  */
1338b5c07418SJames Feist nlohmann::json actionParameterValueTypeError(const std::string& arg1,
1339f4c4dcf4SKowalski, Kamil                                              const std::string& arg2,
13401abe55efSEd Tanous                                              const std::string& arg3)
13411abe55efSEd Tanous {
1342*b6cd31e1SEd Tanous     std::array<std::string_view, 3> args{arg1, arg2, arg3};
1343*b6cd31e1SEd Tanous     return getLog(
1344*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::actionParameterValueTypeError,
1345*b6cd31e1SEd Tanous         args);
1346b5c07418SJames Feist }
1347b5c07418SJames Feist 
1348b5c07418SJames Feist void actionParameterValueTypeError(crow::Response& res, const std::string& arg1,
1349b5c07418SJames Feist                                    const std::string& arg2,
1350b5c07418SJames Feist                                    const std::string& arg3)
1351b5c07418SJames Feist {
1352b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1353b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1354b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1355f4c4dcf4SKowalski, Kamil }
1356f4c4dcf4SKowalski, Kamil 
1357f4c4dcf4SKowalski, Kamil /**
1358f4c4dcf4SKowalski, Kamil  * @internal
1359f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1360f4c4dcf4SKowalski, Kamil  *
1361f4c4dcf4SKowalski, Kamil  * See header file for more information
1362f4c4dcf4SKowalski, Kamil  * @endinternal
1363f4c4dcf4SKowalski, Kamil  */
1364b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void)
13651abe55efSEd Tanous {
1366*b6cd31e1SEd Tanous     return getLog(
1367*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::sessionLimitExceeded, {});
1368b5c07418SJames Feist }
1369b5c07418SJames Feist 
1370b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1371b5c07418SJames Feist {
1372b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1373b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1374f4c4dcf4SKowalski, Kamil }
1375f4c4dcf4SKowalski, Kamil 
1376f4c4dcf4SKowalski, Kamil /**
1377f4c4dcf4SKowalski, Kamil  * @internal
1378f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1379f4c4dcf4SKowalski, Kamil  *
1380f4c4dcf4SKowalski, Kamil  * See header file for more information
1381f4c4dcf4SKowalski, Kamil  * @endinternal
1382f4c4dcf4SKowalski, Kamil  */
1383b5c07418SJames Feist nlohmann::json actionNotSupported(const std::string& arg1)
13841abe55efSEd Tanous {
1385*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1};
1386*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::actionNotSupported,
1387*b6cd31e1SEd Tanous                   args);
1388b5c07418SJames Feist }
1389b5c07418SJames Feist 
1390b5c07418SJames Feist void actionNotSupported(crow::Response& res, const std::string& arg1)
1391b5c07418SJames Feist {
1392b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1393b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1394f4c4dcf4SKowalski, Kamil }
1395f4c4dcf4SKowalski, Kamil 
1396f4c4dcf4SKowalski, Kamil /**
1397f4c4dcf4SKowalski, Kamil  * @internal
1398f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1399f4c4dcf4SKowalski, Kamil  *
1400f4c4dcf4SKowalski, Kamil  * See header file for more information
1401f4c4dcf4SKowalski, Kamil  * @endinternal
1402f4c4dcf4SKowalski, Kamil  */
14035187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
14041abe55efSEd Tanous {
1405*b6cd31e1SEd Tanous     std::string arg1Str = std::to_string(arg1);
1406*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1Str};
1407*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::invalidIndex, args);
1408b5c07418SJames Feist }
1409b5c07418SJames Feist 
14105187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1411b5c07418SJames Feist {
1412b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1413b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1414f4c4dcf4SKowalski, Kamil }
1415f4c4dcf4SKowalski, Kamil 
1416f4c4dcf4SKowalski, Kamil /**
1417f4c4dcf4SKowalski, Kamil  * @internal
1418f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1419f4c4dcf4SKowalski, Kamil  *
1420f4c4dcf4SKowalski, Kamil  * See header file for more information
1421f4c4dcf4SKowalski, Kamil  * @endinternal
1422f4c4dcf4SKowalski, Kamil  */
1423b5c07418SJames Feist nlohmann::json emptyJSON(void)
14241abe55efSEd Tanous {
1425*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::emptyJSON, {});
1426b5c07418SJames Feist }
1427b5c07418SJames Feist 
1428b5c07418SJames Feist void emptyJSON(crow::Response& res)
1429b5c07418SJames Feist {
1430b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1431b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1432f4c4dcf4SKowalski, Kamil }
1433f4c4dcf4SKowalski, Kamil 
1434f4c4dcf4SKowalski, Kamil /**
1435f4c4dcf4SKowalski, Kamil  * @internal
1436f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1437f4c4dcf4SKowalski, Kamil  *
1438f4c4dcf4SKowalski, Kamil  * See header file for more information
1439f4c4dcf4SKowalski, Kamil  * @endinternal
1440f4c4dcf4SKowalski, Kamil  */
1441b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void)
14421abe55efSEd Tanous {
1443*b6cd31e1SEd Tanous     return getLog(
1444*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::queryNotSupportedOnResource,
1445*b6cd31e1SEd Tanous         {});
1446b5c07418SJames Feist }
1447b5c07418SJames Feist 
1448b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1449b5c07418SJames Feist {
1450b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1451b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1452f4c4dcf4SKowalski, Kamil }
1453f4c4dcf4SKowalski, Kamil 
1454f4c4dcf4SKowalski, Kamil /**
1455f4c4dcf4SKowalski, Kamil  * @internal
1456684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1457684bb4b8SJason M. Bills  *
1458684bb4b8SJason M. Bills  * See header file for more information
1459684bb4b8SJason M. Bills  * @endinternal
1460684bb4b8SJason M. Bills  */
1461684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void)
1462684bb4b8SJason M. Bills {
1463*b6cd31e1SEd Tanous     return getLog(
1464*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::queryNotSupportedOnOperation,
1465*b6cd31e1SEd Tanous         {});
1466684bb4b8SJason M. Bills }
1467684bb4b8SJason M. Bills 
1468684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1469684bb4b8SJason M. Bills {
1470684bb4b8SJason M. Bills     res.result(boost::beast::http::status::forbidden);
1471684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1472684bb4b8SJason M. Bills }
1473684bb4b8SJason M. Bills 
1474684bb4b8SJason M. Bills /**
1475684bb4b8SJason M. Bills  * @internal
1476684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1477684bb4b8SJason M. Bills  *
1478684bb4b8SJason M. Bills  * See header file for more information
1479684bb4b8SJason M. Bills  * @endinternal
1480684bb4b8SJason M. Bills  */
1481684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void)
1482684bb4b8SJason M. Bills {
1483*b6cd31e1SEd Tanous     return getLog(
1484*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::queryCombinationInvalid, {});
1485684bb4b8SJason M. Bills }
1486684bb4b8SJason M. Bills 
1487684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1488684bb4b8SJason M. Bills {
1489684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1490684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1491684bb4b8SJason M. Bills }
1492684bb4b8SJason M. Bills 
1493684bb4b8SJason M. Bills /**
1494684bb4b8SJason M. Bills  * @internal
1495f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1496f4c4dcf4SKowalski, Kamil  *
1497f4c4dcf4SKowalski, Kamil  * See header file for more information
1498f4c4dcf4SKowalski, Kamil  * @endinternal
1499f4c4dcf4SKowalski, Kamil  */
1500b5c07418SJames Feist nlohmann::json insufficientPrivilege(void)
15011abe55efSEd Tanous {
1502*b6cd31e1SEd Tanous     return getLog(
1503*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::insufficientPrivilege, {});
1504b5c07418SJames Feist }
1505b5c07418SJames Feist 
1506b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1507b5c07418SJames Feist {
1508b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1509b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1510f4c4dcf4SKowalski, Kamil }
1511f4c4dcf4SKowalski, Kamil 
1512f4c4dcf4SKowalski, Kamil /**
1513f4c4dcf4SKowalski, Kamil  * @internal
1514f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1515f4c4dcf4SKowalski, Kamil  *
1516f4c4dcf4SKowalski, Kamil  * See header file for more information
1517f4c4dcf4SKowalski, Kamil  * @endinternal
1518f4c4dcf4SKowalski, Kamil  */
1519b5c07418SJames Feist nlohmann::json propertyValueModified(const std::string& arg1,
1520b5c07418SJames Feist                                      const std::string& arg2)
1521b5c07418SJames Feist {
1522*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
1523*b6cd31e1SEd Tanous     return getLog(
1524*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::propertyValueModified, args);
1525b5c07418SJames Feist }
1526b5c07418SJames Feist 
1527f12894f8SJason M. Bills void propertyValueModified(crow::Response& res, const std::string& arg1,
1528a08b46ccSJason M. Bills                            const std::string& arg2)
15291abe55efSEd Tanous {
1530f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1531b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1532f4c4dcf4SKowalski, Kamil }
1533f4c4dcf4SKowalski, Kamil 
1534f4c4dcf4SKowalski, Kamil /**
1535f4c4dcf4SKowalski, Kamil  * @internal
1536f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1537f4c4dcf4SKowalski, Kamil  *
1538f4c4dcf4SKowalski, Kamil  * See header file for more information
1539f4c4dcf4SKowalski, Kamil  * @endinternal
1540f4c4dcf4SKowalski, Kamil  */
1541b5c07418SJames Feist nlohmann::json accountNotModified(void)
15421abe55efSEd Tanous {
1543*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::accountNotModified,
1544*b6cd31e1SEd Tanous                   {});
1545b5c07418SJames Feist }
1546b5c07418SJames Feist 
1547b5c07418SJames Feist void accountNotModified(crow::Response& res)
1548b5c07418SJames Feist {
1549b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1550b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1551f4c4dcf4SKowalski, Kamil }
1552f4c4dcf4SKowalski, Kamil 
1553f4c4dcf4SKowalski, Kamil /**
1554f4c4dcf4SKowalski, Kamil  * @internal
1555f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1556f4c4dcf4SKowalski, Kamil  *
1557f4c4dcf4SKowalski, Kamil  * See header file for more information
1558f4c4dcf4SKowalski, Kamil  * @endinternal
1559f4c4dcf4SKowalski, Kamil  */
1560b5c07418SJames Feist nlohmann::json queryParameterValueFormatError(const std::string& arg1,
15611abe55efSEd Tanous                                               const std::string& arg2)
15621abe55efSEd Tanous {
1563*b6cd31e1SEd Tanous     std::array<std::string_view, 2> args{arg1, arg2};
1564*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::
1565*b6cd31e1SEd Tanous                       queryParameterValueFormatError,
1566*b6cd31e1SEd Tanous                   args);
1567b5c07418SJames Feist }
1568b5c07418SJames Feist 
1569b5c07418SJames Feist void queryParameterValueFormatError(crow::Response& res,
1570b5c07418SJames Feist                                     const std::string& arg1,
1571b5c07418SJames Feist                                     const std::string& arg2)
1572b5c07418SJames Feist {
1573b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1574b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1575b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
1576f4c4dcf4SKowalski, Kamil }
1577f4c4dcf4SKowalski, Kamil 
1578f4c4dcf4SKowalski, Kamil /**
1579f4c4dcf4SKowalski, Kamil  * @internal
1580b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
1581b5c07418SJames Feist  * property
1582f12894f8SJason M. Bills  *
1583f12894f8SJason M. Bills  * See header file for more information
1584f12894f8SJason M. Bills  * @endinternal
1585f12894f8SJason M. Bills  */
1586b5c07418SJames Feist nlohmann::json propertyMissing(const std::string& arg1)
1587f12894f8SJason M. Bills {
1588*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1};
1589*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::propertyMissing,
1590*b6cd31e1SEd Tanous                   args);
1591b5c07418SJames Feist }
1592b5c07418SJames Feist 
1593b5c07418SJames Feist void propertyMissing(crow::Response& res, const std::string& arg1)
1594b5c07418SJames Feist {
1595b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1596b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1597f4c4dcf4SKowalski, Kamil }
1598f4c4dcf4SKowalski, Kamil 
1599f4c4dcf4SKowalski, Kamil /**
1600f4c4dcf4SKowalski, Kamil  * @internal
1601f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
1602f4c4dcf4SKowalski, Kamil  *
1603f4c4dcf4SKowalski, Kamil  * See header file for more information
1604f4c4dcf4SKowalski, Kamil  * @endinternal
1605f4c4dcf4SKowalski, Kamil  */
1606b5c07418SJames Feist nlohmann::json resourceExhaustion(const std::string& arg1)
16071abe55efSEd Tanous {
1608*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{arg1};
1609*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::resourceExhaustion,
1610*b6cd31e1SEd Tanous                   args);
1611b5c07418SJames Feist }
1612b5c07418SJames Feist 
1613b5c07418SJames Feist void resourceExhaustion(crow::Response& res, const std::string& arg1)
1614b5c07418SJames Feist {
1615b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1616b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1617f4c4dcf4SKowalski, Kamil }
1618f4c4dcf4SKowalski, Kamil 
1619f4c4dcf4SKowalski, Kamil /**
1620f4c4dcf4SKowalski, Kamil  * @internal
1621f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
1622f4c4dcf4SKowalski, Kamil  *
1623f4c4dcf4SKowalski, Kamil  * See header file for more information
1624f4c4dcf4SKowalski, Kamil  * @endinternal
1625f4c4dcf4SKowalski, Kamil  */
1626b5c07418SJames Feist nlohmann::json accountModified(void)
16271abe55efSEd Tanous {
1628*b6cd31e1SEd Tanous     return getLog(redfish::message_registries::base::Index::accountModified,
1629*b6cd31e1SEd Tanous                   {});
1630b5c07418SJames Feist }
1631b5c07418SJames Feist 
1632b5c07418SJames Feist void accountModified(crow::Response& res)
1633b5c07418SJames Feist {
1634b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1635b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
1636f4c4dcf4SKowalski, Kamil }
1637f4c4dcf4SKowalski, Kamil 
1638f4c4dcf4SKowalski, Kamil /**
1639f4c4dcf4SKowalski, Kamil  * @internal
1640f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
1641f4c4dcf4SKowalski, Kamil  *
1642f4c4dcf4SKowalski, Kamil  * See header file for more information
1643f4c4dcf4SKowalski, Kamil  * @endinternal
1644f4c4dcf4SKowalski, Kamil  */
1645b5c07418SJames Feist nlohmann::json queryParameterOutOfRange(const std::string& arg1,
1646b5c07418SJames Feist                                         const std::string& arg2,
1647b5c07418SJames Feist                                         const std::string& arg3)
16481abe55efSEd Tanous {
1649*b6cd31e1SEd Tanous     std::array<std::string_view, 3> args{arg1, arg2, arg3};
1650*b6cd31e1SEd Tanous     return getLog(
1651*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::queryParameterOutOfRange,
1652*b6cd31e1SEd Tanous         args);
1653b5c07418SJames Feist }
1654b5c07418SJames Feist 
1655b5c07418SJames Feist void queryParameterOutOfRange(crow::Response& res, const std::string& arg1,
1656b5c07418SJames Feist                               const std::string& arg2, const std::string& arg3)
1657b5c07418SJames Feist {
1658b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1659b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1660b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
1661f4c4dcf4SKowalski, Kamil }
1662f4c4dcf4SKowalski, Kamil 
1663*b6cd31e1SEd Tanous nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1)
1664*b6cd31e1SEd Tanous {
1665*b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
1666*b6cd31e1SEd Tanous         std::string_view(arg1.data(), arg1.size())};
1667*b6cd31e1SEd Tanous 
1668*b6cd31e1SEd Tanous     return getLog(
1669*b6cd31e1SEd Tanous         redfish::message_registries::base::Index::passwordChangeRequired, args);
1670*b6cd31e1SEd Tanous }
1671*b6cd31e1SEd Tanous 
16723bf4e632SJoseph Reynolds /**
16733bf4e632SJoseph Reynolds  * @internal
16743bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
16753bf4e632SJoseph Reynolds  *
16763bf4e632SJoseph Reynolds  * See header file for more information
16773bf4e632SJoseph Reynolds  * @endinternal
16783bf4e632SJoseph Reynolds  */
1679ace85d60SEd Tanous void passwordChangeRequired(crow::Response& res,
1680ace85d60SEd Tanous                             const boost::urls::url_view& arg1)
16813bf4e632SJoseph Reynolds {
1682*b6cd31e1SEd Tanous     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
16833bf4e632SJoseph Reynolds }
16843bf4e632SJoseph Reynolds 
16854cde5d90SJames Feist void invalidUpload(crow::Response& res, const std::string& arg1,
16864cde5d90SJames Feist                    const std::string& arg2)
16874cde5d90SJames Feist {
16884cde5d90SJames Feist     res.result(boost::beast::http::status::bad_request);
16894cde5d90SJames Feist     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
16904cde5d90SJames Feist }
16914cde5d90SJames Feist 
16924cde5d90SJames Feist /**
16934cde5d90SJames Feist  * @internal
16944cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
16954cde5d90SJames Feist  *
16964cde5d90SJames Feist  * See header file for more information
16974cde5d90SJames Feist  * @endinternal
16984cde5d90SJames Feist  */
16994cde5d90SJames Feist nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2)
17004cde5d90SJames Feist {
17014cde5d90SJames Feist     return nlohmann::json{
17023e082749SAsmitha Karunanithi         {"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"},
17034a0bf539SManojkiran Eda         {"MessageId", "OpenBMC.0.2.InvalidUpload"},
17044cde5d90SJames Feist         {"Message", "Invalid file uploaded to " + arg1 + ": " + arg2 + "."},
17054cde5d90SJames Feist         {"MessageArgs", {arg1, arg2}},
1706684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
17074cde5d90SJames Feist         {"Resolution", "None."}};
17084cde5d90SJames Feist }
1709f4c4dcf4SKowalski, Kamil } // namespace messages
1710f4c4dcf4SKowalski, Kamil 
1711d425c6f6SEd Tanous } // namespace redfish
1712