xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision f7725d79fa9b5fcffcc368008fa029ea1a16c4b9)
1f4c4dcf4SKowalski, Kamil /*
2f4c4dcf4SKowalski, Kamil // Copyright (c) 2018 Intel Corporation
3f4c4dcf4SKowalski, Kamil //
4f4c4dcf4SKowalski, Kamil // Licensed under the Apache License, Version 2.0 (the "License");
5f4c4dcf4SKowalski, Kamil // you may not use this file except in compliance with the License.
6f4c4dcf4SKowalski, Kamil // You may obtain a copy of the License at
7f4c4dcf4SKowalski, Kamil //
8f4c4dcf4SKowalski, Kamil //      http://www.apache.org/licenses/LICENSE-2.0
9f4c4dcf4SKowalski, Kamil //
10f4c4dcf4SKowalski, Kamil // Unless required by applicable law or agreed to in writing, software
11f4c4dcf4SKowalski, Kamil // distributed under the License is distributed on an "AS IS" BASIS,
12f4c4dcf4SKowalski, Kamil // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13f4c4dcf4SKowalski, Kamil // See the License for the specific language governing permissions and
14f4c4dcf4SKowalski, Kamil // limitations under the License.
15f4c4dcf4SKowalski, Kamil */
169ea15c35SEd Tanous #include "http_response.hpp"
17b6cd31e1SEd Tanous #include "registries/base_message_registry.hpp"
189ea15c35SEd Tanous 
199ea15c35SEd Tanous #include <boost/beast/http/status.hpp>
20ace85d60SEd Tanous #include <boost/url/url.hpp>
211abe55efSEd Tanous #include <error_messages.hpp>
2204e438cbSEd Tanous #include <logging.hpp>
239ea15c35SEd Tanous #include <nlohmann/json.hpp>
24f4c4dcf4SKowalski, Kamil 
251668ce6dSEd Tanous #include <array>
261668ce6dSEd Tanous 
271abe55efSEd Tanous namespace redfish
281abe55efSEd Tanous {
291abe55efSEd Tanous 
301abe55efSEd Tanous namespace messages
311abe55efSEd Tanous {
32f4c4dcf4SKowalski, Kamil 
33f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target,
341abe55efSEd Tanous                                   const nlohmann::json& message)
351abe55efSEd Tanous {
36f4c4dcf4SKowalski, Kamil     auto& error = target["error"];
37f4c4dcf4SKowalski, Kamil 
381abe55efSEd Tanous     // If this is the first error message, fill in the information from the
391abe55efSEd Tanous     // first error message to the top level struct
401abe55efSEd Tanous     if (!error.is_object())
411abe55efSEd Tanous     {
42c074230bSJason M. Bills         auto messageIdIterator = message.find("MessageId");
43c074230bSJason M. Bills         if (messageIdIterator == message.end())
441abe55efSEd Tanous         {
451abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
461abe55efSEd Tanous                 << "Attempt to add error message without MessageId";
47f4c4dcf4SKowalski, Kamil             return;
48f4c4dcf4SKowalski, Kamil         }
49f4c4dcf4SKowalski, Kamil 
50c074230bSJason M. Bills         auto messageFieldIterator = message.find("Message");
51c074230bSJason M. Bills         if (messageFieldIterator == message.end())
521abe55efSEd Tanous         {
531abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
541abe55efSEd Tanous                 << "Attempt to add error message without Message";
55f4c4dcf4SKowalski, Kamil             return;
56f4c4dcf4SKowalski, Kamil         }
57c21055aaSEd Tanous         error = {{"code", *messageIdIterator},
58c21055aaSEd Tanous                  {"message", *messageFieldIterator}};
591abe55efSEd Tanous     }
601abe55efSEd Tanous     else
611abe55efSEd Tanous     {
62f4c4dcf4SKowalski, Kamil         // More than 1 error occurred, so the message has to be generic
6355c7b7a2SEd Tanous         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
64cc9139ecSJason M. Bills         error["message"] = "A general error has occurred. See Resolution for "
65cc9139ecSJason M. Bills                            "information on how to resolve the error.";
66f4c4dcf4SKowalski, Kamil     }
67f4c4dcf4SKowalski, Kamil 
68f4c4dcf4SKowalski, Kamil     // This check could technically be done in in the default construction
69f4c4dcf4SKowalski, Kamil     // branch above, but because we need the pointer to the extended info field
70f4c4dcf4SKowalski, Kamil     // anyway, it's more efficient to do it here.
71c074230bSJason M. Bills     auto& extendedInfo = error[messages::messageAnnotation];
72c074230bSJason M. Bills     if (!extendedInfo.is_array())
731abe55efSEd Tanous     {
74c074230bSJason M. Bills         extendedInfo = nlohmann::json::array();
75f4c4dcf4SKowalski, Kamil     }
76f4c4dcf4SKowalski, Kamil 
77c074230bSJason M. Bills     extendedInfo.push_back(message);
78f4c4dcf4SKowalski, Kamil }
79f4c4dcf4SKowalski, Kamil 
80f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target,
81f12894f8SJason M. Bills                                  const nlohmann::json& message)
821abe55efSEd Tanous {
831abe55efSEd Tanous     if (!target[messages::messageAnnotation].is_array())
841abe55efSEd Tanous     {
85f4c4dcf4SKowalski, Kamil         // Force object to be an array
8655c7b7a2SEd Tanous         target[messages::messageAnnotation] = nlohmann::json::array();
87f4c4dcf4SKowalski, Kamil     }
88f4c4dcf4SKowalski, Kamil 
8955c7b7a2SEd Tanous     target[messages::messageAnnotation].push_back(message);
90f4c4dcf4SKowalski, Kamil }
91f4c4dcf4SKowalski, Kamil 
92f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target,
93f12894f8SJason M. Bills                              const nlohmann::json& message,
941668ce6dSEd Tanous                              std::string_view fieldPath)
951abe55efSEd Tanous {
961668ce6dSEd Tanous     std::string extendedInfo(fieldPath);
971668ce6dSEd Tanous     extendedInfo += messages::messageAnnotation;
98f4c4dcf4SKowalski, Kamil 
991668ce6dSEd Tanous     nlohmann::json& field = target[extendedInfo];
1001668ce6dSEd Tanous     if (!field.is_array())
1011abe55efSEd Tanous     {
102f4c4dcf4SKowalski, Kamil         // Force object to be an array
1031668ce6dSEd Tanous         field = nlohmann::json::array();
104f4c4dcf4SKowalski, Kamil     }
105f4c4dcf4SKowalski, Kamil 
106f4c4dcf4SKowalski, Kamil     // Object exists and it is an array so we can just push in the message
1071668ce6dSEd Tanous     field.push_back(message);
108f4c4dcf4SKowalski, Kamil }
109f4c4dcf4SKowalski, Kamil 
110*f7725d79SEd Tanous static nlohmann::json getLog(redfish::registries::base::Index name,
111b6cd31e1SEd Tanous                              std::span<const std::string_view> args)
112b6cd31e1SEd Tanous {
113b6cd31e1SEd Tanous     size_t index = static_cast<size_t>(name);
114fffb8c1fSEd Tanous     if (index >= redfish::registries::base::registry.size())
115b6cd31e1SEd Tanous     {
116b6cd31e1SEd Tanous         return {};
117b6cd31e1SEd Tanous     }
118fffb8c1fSEd Tanous     const redfish::registries::MessageEntry& entry =
119fffb8c1fSEd Tanous         redfish::registries::base::registry[index];
120b6cd31e1SEd Tanous     // Intentionally make a copy of the string, so we can append in the
121b6cd31e1SEd Tanous     // parameters.
122b6cd31e1SEd Tanous     std::string msg = entry.second.message;
123fffb8c1fSEd Tanous     redfish::registries::fillMessageArgs(args, msg);
124b6cd31e1SEd Tanous     nlohmann::json jArgs = nlohmann::json::array();
125b6cd31e1SEd Tanous     for (const std::string_view arg : args)
126b6cd31e1SEd Tanous     {
127b6cd31e1SEd Tanous         jArgs.push_back(arg);
128b6cd31e1SEd Tanous     }
129fffb8c1fSEd Tanous     std::string msgId = redfish::registries::base::header.id;
130b6cd31e1SEd Tanous     msgId += ".";
131b6cd31e1SEd Tanous     msgId += entry.first;
132b6cd31e1SEd Tanous     return {{"@odata.type", "#Message.v1_1_1.Message"},
133b6cd31e1SEd Tanous             {"MessageId", std::move(msgId)},
134b6cd31e1SEd Tanous             {"Message", std::move(msg)},
135b6cd31e1SEd Tanous             {"MessageArgs", std::move(jArgs)},
1365f2b84eeSEd Tanous             {"MessageSeverity", entry.second.messageSeverity},
137b6cd31e1SEd Tanous             {"Resolution", entry.second.resolution}};
138b6cd31e1SEd Tanous }
139b6cd31e1SEd Tanous 
140f4c4dcf4SKowalski, Kamil /**
141f4c4dcf4SKowalski, Kamil  * @internal
142f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
143f4c4dcf4SKowalski, Kamil  *
144f4c4dcf4SKowalski, Kamil  * See header file for more information
145f4c4dcf4SKowalski, Kamil  * @endinternal
146f4c4dcf4SKowalski, Kamil  */
147b5c07418SJames Feist nlohmann::json resourceInUse(void)
1481abe55efSEd Tanous {
149fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInUse, {});
150b5c07418SJames Feist }
151b5c07418SJames Feist 
152b5c07418SJames Feist void resourceInUse(crow::Response& res)
153b5c07418SJames Feist {
154b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
155b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
156f4c4dcf4SKowalski, Kamil }
157f4c4dcf4SKowalski, Kamil 
158f4c4dcf4SKowalski, Kamil /**
159f4c4dcf4SKowalski, Kamil  * @internal
160f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
161f4c4dcf4SKowalski, Kamil  *
162f4c4dcf4SKowalski, Kamil  * See header file for more information
163f4c4dcf4SKowalski, Kamil  * @endinternal
164f4c4dcf4SKowalski, Kamil  */
165b5c07418SJames Feist nlohmann::json malformedJSON(void)
1661abe55efSEd Tanous {
167fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::malformedJSON, {});
168b5c07418SJames Feist }
169b5c07418SJames Feist 
170b5c07418SJames Feist void malformedJSON(crow::Response& res)
171b5c07418SJames Feist {
172b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
173b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
174f4c4dcf4SKowalski, Kamil }
175f4c4dcf4SKowalski, Kamil 
176f4c4dcf4SKowalski, Kamil /**
177f4c4dcf4SKowalski, Kamil  * @internal
178f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
179f4c4dcf4SKowalski, Kamil  *
180f4c4dcf4SKowalski, Kamil  * See header file for more information
181f4c4dcf4SKowalski, Kamil  * @endinternal
182f4c4dcf4SKowalski, Kamil  */
183ace85d60SEd Tanous nlohmann::json resourceMissingAtURI(const boost::urls::url_view& arg1)
1841abe55efSEd Tanous {
185b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
186b6cd31e1SEd Tanous         std::string_view{arg1.data(), arg1.size()}};
187fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceMissingAtURI, args);
188b5c07418SJames Feist }
189b5c07418SJames Feist 
190ace85d60SEd Tanous void resourceMissingAtURI(crow::Response& res,
191ace85d60SEd Tanous                           const boost::urls::url_view& arg1)
192b5c07418SJames Feist {
193b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
194b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
195f4c4dcf4SKowalski, Kamil }
196f4c4dcf4SKowalski, Kamil 
197f4c4dcf4SKowalski, Kamil /**
198f4c4dcf4SKowalski, Kamil  * @internal
199f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
200f4c4dcf4SKowalski, Kamil  *
201f4c4dcf4SKowalski, Kamil  * See header file for more information
202f4c4dcf4SKowalski, Kamil  * @endinternal
203f4c4dcf4SKowalski, Kamil  */
2041668ce6dSEd Tanous nlohmann::json actionParameterValueFormatError(std::string_view arg1,
2051668ce6dSEd Tanous                                                std::string_view arg2,
2061668ce6dSEd Tanous                                                std::string_view arg3)
2071abe55efSEd Tanous {
208fffb8c1fSEd Tanous     return getLog(
209fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueFormatError,
2101668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
211b5c07418SJames Feist }
212b5c07418SJames Feist 
2131668ce6dSEd Tanous void actionParameterValueFormatError(crow::Response& res, std::string_view arg1,
2141668ce6dSEd Tanous                                      std::string_view arg2,
2151668ce6dSEd Tanous                                      std::string_view arg3)
216b5c07418SJames Feist {
217b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
218b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
219b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
220f4c4dcf4SKowalski, Kamil }
221f4c4dcf4SKowalski, Kamil 
222f4c4dcf4SKowalski, Kamil /**
223f4c4dcf4SKowalski, Kamil  * @internal
224f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
225f4c4dcf4SKowalski, Kamil  *
226f4c4dcf4SKowalski, Kamil  * See header file for more information
227f4c4dcf4SKowalski, Kamil  * @endinternal
228f4c4dcf4SKowalski, Kamil  */
229b5c07418SJames Feist nlohmann::json internalError(void)
2301abe55efSEd Tanous {
231fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::internalError, {});
232b5c07418SJames Feist }
233b5c07418SJames Feist 
234df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location)
235b5c07418SJames Feist {
236df5415fcSEd Tanous     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
237df5415fcSEd Tanous                         << location.line() << ":" << location.column() << ") `"
238df5415fcSEd Tanous                         << location.function_name() << "`: ";
239b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
240b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
241f12894f8SJason M. Bills }
242f12894f8SJason M. Bills 
243f12894f8SJason M. Bills /**
244f12894f8SJason M. Bills  * @internal
245f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
246f4c4dcf4SKowalski, Kamil  *
247f4c4dcf4SKowalski, Kamil  * See header file for more information
248f4c4dcf4SKowalski, Kamil  * @endinternal
249f4c4dcf4SKowalski, Kamil  */
250b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void)
2511abe55efSEd Tanous {
252fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::unrecognizedRequestBody,
253fffb8c1fSEd Tanous                   {});
254b5c07418SJames Feist }
255b5c07418SJames Feist 
256b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
257b5c07418SJames Feist {
258b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
259b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
260f4c4dcf4SKowalski, Kamil }
261f4c4dcf4SKowalski, Kamil 
262f4c4dcf4SKowalski, Kamil /**
263f4c4dcf4SKowalski, Kamil  * @internal
264f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
265f4c4dcf4SKowalski, Kamil  *
266f4c4dcf4SKowalski, Kamil  * See header file for more information
267f4c4dcf4SKowalski, Kamil  * @endinternal
268f4c4dcf4SKowalski, Kamil  */
269ace85d60SEd Tanous nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1,
2701668ce6dSEd Tanous                                          std::string_view arg2)
2711abe55efSEd Tanous {
272b6cd31e1SEd Tanous     return getLog(
273fffb8c1fSEd Tanous         redfish::registries::base::Index::resourceAtUriUnauthorized,
2741668ce6dSEd Tanous         std::to_array({std::string_view{arg1.data(), arg1.size()}, arg2}));
275b5c07418SJames Feist }
276b5c07418SJames Feist 
277ace85d60SEd Tanous void resourceAtUriUnauthorized(crow::Response& res,
278ace85d60SEd Tanous                                const boost::urls::url_view& arg1,
2791668ce6dSEd Tanous                                std::string_view arg2)
280b5c07418SJames Feist {
281b5c07418SJames Feist     res.result(boost::beast::http::status::unauthorized);
282b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
283f4c4dcf4SKowalski, Kamil }
284f4c4dcf4SKowalski, Kamil 
285f4c4dcf4SKowalski, Kamil /**
286f4c4dcf4SKowalski, Kamil  * @internal
287f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterUnknown message into JSON
288f4c4dcf4SKowalski, Kamil  *
289f4c4dcf4SKowalski, Kamil  * See header file for more information
290f4c4dcf4SKowalski, Kamil  * @endinternal
291f4c4dcf4SKowalski, Kamil  */
2921668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1,
2931668ce6dSEd Tanous                                       std::string_view arg2)
294b5c07418SJames Feist {
295fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterUnknown,
2961668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
297b5c07418SJames Feist }
298b5c07418SJames Feist 
2991668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1,
3001668ce6dSEd Tanous                             std::string_view arg2)
3011abe55efSEd Tanous {
302f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
303b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
304f4c4dcf4SKowalski, Kamil }
305f4c4dcf4SKowalski, Kamil 
306f4c4dcf4SKowalski, Kamil /**
307f4c4dcf4SKowalski, Kamil  * @internal
308f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceCannotBeDeleted message into JSON
309f4c4dcf4SKowalski, Kamil  *
310f4c4dcf4SKowalski, Kamil  * See header file for more information
311f4c4dcf4SKowalski, Kamil  * @endinternal
312f4c4dcf4SKowalski, Kamil  */
313b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void)
3141abe55efSEd Tanous {
315fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCannotBeDeleted,
316fffb8c1fSEd Tanous                   {});
317b5c07418SJames Feist }
318b5c07418SJames Feist 
319b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res)
320b5c07418SJames Feist {
321b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
322b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
323f4c4dcf4SKowalski, Kamil }
324f4c4dcf4SKowalski, Kamil 
325f4c4dcf4SKowalski, Kamil /**
326f4c4dcf4SKowalski, Kamil  * @internal
327f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyDuplicate message into JSON
328f4c4dcf4SKowalski, Kamil  *
329f4c4dcf4SKowalski, Kamil  * See header file for more information
330f4c4dcf4SKowalski, Kamil  * @endinternal
331f4c4dcf4SKowalski, Kamil  */
3321668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1)
3331abe55efSEd Tanous {
334fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyDuplicate,
3351668ce6dSEd Tanous                   std::to_array({arg1}));
336b5c07418SJames Feist }
337b5c07418SJames Feist 
3381668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1)
339b5c07418SJames Feist {
340b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
341b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
342f4c4dcf4SKowalski, Kamil }
343f4c4dcf4SKowalski, Kamil 
344f4c4dcf4SKowalski, Kamil /**
345f4c4dcf4SKowalski, Kamil  * @internal
346f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
347f4c4dcf4SKowalski, Kamil  *
348f4c4dcf4SKowalski, Kamil  * See header file for more information
349f4c4dcf4SKowalski, Kamil  * @endinternal
350f4c4dcf4SKowalski, Kamil  */
3511668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
3521abe55efSEd Tanous {
353b6cd31e1SEd Tanous     return getLog(
354fffb8c1fSEd Tanous         redfish::registries::base::Index::serviceTemporarilyUnavailable,
3551668ce6dSEd Tanous         std::to_array({arg1}));
356b5c07418SJames Feist }
357b5c07418SJames Feist 
3581668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
359b5c07418SJames Feist {
360b5c07418SJames Feist     res.addHeader("Retry-After", arg1);
361b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
362b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
363f4c4dcf4SKowalski, Kamil }
364f4c4dcf4SKowalski, Kamil 
365f4c4dcf4SKowalski, Kamil /**
366f4c4dcf4SKowalski, Kamil  * @internal
367f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
368f4c4dcf4SKowalski, Kamil  *
369f4c4dcf4SKowalski, Kamil  * See header file for more information
370f4c4dcf4SKowalski, Kamil  * @endinternal
371f4c4dcf4SKowalski, Kamil  */
3721668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1,
3731668ce6dSEd Tanous                                      std::string_view arg2,
3741668ce6dSEd Tanous                                      std::string_view arg3)
3751abe55efSEd Tanous {
376fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceAlreadyExists,
3771668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
378b5c07418SJames Feist }
379b5c07418SJames Feist 
3801668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
3811668ce6dSEd Tanous                            std::string_view arg2, std::string_view arg3)
382b5c07418SJames Feist {
383b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
384b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
385a08b46ccSJason M. Bills                      arg2);
386f4c4dcf4SKowalski, Kamil }
387f4c4dcf4SKowalski, Kamil 
388f4c4dcf4SKowalski, Kamil /**
389f4c4dcf4SKowalski, Kamil  * @internal
390f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
391f4c4dcf4SKowalski, Kamil  *
392f4c4dcf4SKowalski, Kamil  * See header file for more information
393f4c4dcf4SKowalski, Kamil  * @endinternal
394f4c4dcf4SKowalski, Kamil  */
395b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void)
3961abe55efSEd Tanous {
397fffb8c1fSEd Tanous     return getLog(
398fffb8c1fSEd Tanous         redfish::registries::base::Index::accountForSessionNoLongerExists, {});
399b5c07418SJames Feist }
400b5c07418SJames Feist 
401b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
402b5c07418SJames Feist {
403b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
404b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
405f4c4dcf4SKowalski, Kamil }
406f4c4dcf4SKowalski, Kamil 
407f4c4dcf4SKowalski, Kamil /**
408f4c4dcf4SKowalski, Kamil  * @internal
409f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
410f4c4dcf4SKowalski, Kamil  *
411f4c4dcf4SKowalski, Kamil  * See header file for more information
412f4c4dcf4SKowalski, Kamil  * @endinternal
413f4c4dcf4SKowalski, Kamil  */
4141668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
4151abe55efSEd Tanous {
416fffb8c1fSEd Tanous     return getLog(
417fffb8c1fSEd Tanous         redfish::registries::base::Index::createFailedMissingReqProperties,
4181668ce6dSEd Tanous         std::to_array({arg1}));
419b5c07418SJames Feist }
420b5c07418SJames Feist 
421b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
4221668ce6dSEd Tanous                                       std::string_view arg1)
423b5c07418SJames Feist {
424b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
425b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
426a08b46ccSJason M. Bills                      arg1);
427f12894f8SJason M. Bills }
428f12894f8SJason M. Bills 
429f12894f8SJason M. Bills /**
430f12894f8SJason M. Bills  * @internal
431f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
432f12894f8SJason M. Bills  * property
433f12894f8SJason M. Bills  *
434f12894f8SJason M. Bills  * See header file for more information
435f12894f8SJason M. Bills  * @endinternal
436f12894f8SJason M. Bills  */
4371668ce6dSEd Tanous nlohmann::json propertyValueFormatError(std::string_view arg1,
4381668ce6dSEd Tanous                                         std::string_view arg2)
439f12894f8SJason M. Bills {
440fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueFormatError,
4411668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
442b5c07418SJames Feist }
443b5c07418SJames Feist 
4441668ce6dSEd Tanous void propertyValueFormatError(crow::Response& res, std::string_view arg1,
4451668ce6dSEd Tanous                               std::string_view arg2)
446b5c07418SJames Feist {
447b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
448b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
449f12894f8SJason M. Bills }
450f12894f8SJason M. Bills 
451f12894f8SJason M. Bills /**
452f12894f8SJason M. Bills  * @internal
453f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
454f12894f8SJason M. Bills  * property
455f12894f8SJason M. Bills  *
456f12894f8SJason M. Bills  * See header file for more information
457f12894f8SJason M. Bills  * @endinternal
458f12894f8SJason M. Bills  */
4591668ce6dSEd Tanous nlohmann::json propertyValueNotInList(std::string_view arg1,
4601668ce6dSEd Tanous                                       std::string_view arg2)
461f12894f8SJason M. Bills {
462fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueNotInList,
4631668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
464b5c07418SJames Feist }
465b5c07418SJames Feist 
4661668ce6dSEd Tanous void propertyValueNotInList(crow::Response& res, std::string_view arg1,
4671668ce6dSEd Tanous                             std::string_view arg2)
468b5c07418SJames Feist {
469b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
470b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
471f4c4dcf4SKowalski, Kamil }
472f4c4dcf4SKowalski, Kamil 
473f4c4dcf4SKowalski, Kamil /**
474f4c4dcf4SKowalski, Kamil  * @internal
475f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
476f4c4dcf4SKowalski, Kamil  *
477f4c4dcf4SKowalski, Kamil  * See header file for more information
478f4c4dcf4SKowalski, Kamil  * @endinternal
479f4c4dcf4SKowalski, Kamil  */
480ace85d60SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1)
4811abe55efSEd Tanous {
4821668ce6dSEd Tanous     std::string_view arg1str{arg1.data(), arg1.size()};
483b6cd31e1SEd Tanous     return getLog(
484fffb8c1fSEd Tanous         redfish::registries::base::Index::resourceAtUriInUnknownFormat,
4851668ce6dSEd Tanous         std::to_array({arg1str}));
486b5c07418SJames Feist }
487b5c07418SJames Feist 
488ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res,
489ace85d60SEd Tanous                                   const boost::urls::url_view& arg1)
490b5c07418SJames Feist {
491b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
492b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
493f4c4dcf4SKowalski, Kamil }
494f4c4dcf4SKowalski, Kamil 
495f4c4dcf4SKowalski, Kamil /**
496f4c4dcf4SKowalski, Kamil  * @internal
49781856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
49881856681SAsmitha Karunanithi  *
49981856681SAsmitha Karunanithi  * See header file for more information
50081856681SAsmitha Karunanithi  * @endinternal
50181856681SAsmitha Karunanithi  */
5021668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1)
50381856681SAsmitha Karunanithi {
504fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceDisabled,
5051668ce6dSEd Tanous                   std::to_array({arg1}));
50681856681SAsmitha Karunanithi }
50781856681SAsmitha Karunanithi 
5081668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1)
50981856681SAsmitha Karunanithi {
51081856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
51181856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
51281856681SAsmitha Karunanithi }
51381856681SAsmitha Karunanithi 
51481856681SAsmitha Karunanithi /**
51581856681SAsmitha Karunanithi  * @internal
516f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
517f4c4dcf4SKowalski, Kamil  *
518f4c4dcf4SKowalski, Kamil  * See header file for more information
519f4c4dcf4SKowalski, Kamil  * @endinternal
520f4c4dcf4SKowalski, Kamil  */
521b5c07418SJames Feist nlohmann::json serviceInUnknownState(void)
5221abe55efSEd Tanous {
523fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
524b5c07418SJames Feist }
525b5c07418SJames Feist 
526b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
527b5c07418SJames Feist {
528b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
529b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
530f4c4dcf4SKowalski, Kamil }
531f4c4dcf4SKowalski, Kamil 
532f4c4dcf4SKowalski, Kamil /**
533f4c4dcf4SKowalski, Kamil  * @internal
534f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
535f4c4dcf4SKowalski, Kamil  *
536f4c4dcf4SKowalski, Kamil  * See header file for more information
537f4c4dcf4SKowalski, Kamil  * @endinternal
538f4c4dcf4SKowalski, Kamil  */
539b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void)
5401abe55efSEd Tanous {
541fffb8c1fSEd Tanous     return getLog(
542fffb8c1fSEd Tanous         redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
543b5c07418SJames Feist }
544b5c07418SJames Feist 
545b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
546b5c07418SJames Feist {
547789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
548b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
549f4c4dcf4SKowalski, Kamil }
550f4c4dcf4SKowalski, Kamil 
551f4c4dcf4SKowalski, Kamil /**
552f4c4dcf4SKowalski, Kamil  * @internal
553f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
554f4c4dcf4SKowalski, Kamil  *
555f4c4dcf4SKowalski, Kamil  * See header file for more information
556f4c4dcf4SKowalski, Kamil  * @endinternal
557f4c4dcf4SKowalski, Kamil  */
5581668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1,
5591668ce6dSEd Tanous                                       std::string_view arg2)
5601abe55efSEd Tanous {
561fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterMissing,
5621668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
563b5c07418SJames Feist }
564b5c07418SJames Feist 
5651668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1,
5661668ce6dSEd Tanous                             std::string_view arg2)
567b5c07418SJames Feist {
568b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
569b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
570f4c4dcf4SKowalski, Kamil }
571f4c4dcf4SKowalski, Kamil 
572f4c4dcf4SKowalski, Kamil /**
573f4c4dcf4SKowalski, Kamil  * @internal
574f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
575f4c4dcf4SKowalski, Kamil  *
576f4c4dcf4SKowalski, Kamil  * See header file for more information
577f4c4dcf4SKowalski, Kamil  * @endinternal
578f4c4dcf4SKowalski, Kamil  */
5791668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
5801abe55efSEd Tanous {
581b6cd31e1SEd Tanous     std::string arg2String = std::to_string(arg2);
582fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::stringValueTooLong,
5831668ce6dSEd Tanous                   std::to_array({arg1, std::string_view(arg2String)}));
584b5c07418SJames Feist }
585b5c07418SJames Feist 
5861668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
587b5c07418SJames Feist {
588b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
589b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
590f4c4dcf4SKowalski, Kamil }
591f4c4dcf4SKowalski, Kamil 
592f4c4dcf4SKowalski, Kamil /**
593f4c4dcf4SKowalski, Kamil  * @internal
594cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
595cc9139ecSJason M. Bills  *
596cc9139ecSJason M. Bills  * See header file for more information
597cc9139ecSJason M. Bills  * @endinternal
598cc9139ecSJason M. Bills  */
599b5c07418SJames Feist nlohmann::json sessionTerminated(void)
600cc9139ecSJason M. Bills {
601fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionTerminated, {});
602b5c07418SJames Feist }
603b5c07418SJames Feist 
604b5c07418SJames Feist void sessionTerminated(crow::Response& res)
605b5c07418SJames Feist {
606b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
607b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
608cc9139ecSJason M. Bills }
609cc9139ecSJason M. Bills 
610cc9139ecSJason M. Bills /**
611cc9139ecSJason M. Bills  * @internal
612684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
613684bb4b8SJason M. Bills  *
614684bb4b8SJason M. Bills  * See header file for more information
615684bb4b8SJason M. Bills  * @endinternal
616684bb4b8SJason M. Bills  */
617684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void)
618684bb4b8SJason M. Bills {
619fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
620684bb4b8SJason M. Bills }
621684bb4b8SJason M. Bills 
622684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
623684bb4b8SJason M. Bills {
624684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
625684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
626684bb4b8SJason M. Bills }
627684bb4b8SJason M. Bills 
628684bb4b8SJason M. Bills /**
629684bb4b8SJason M. Bills  * @internal
630cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
631cc9139ecSJason M. Bills  *
632cc9139ecSJason M. Bills  * See header file for more information
633cc9139ecSJason M. Bills  * @endinternal
634cc9139ecSJason M. Bills  */
6351668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1,
6361668ce6dSEd Tanous                                         std::string_view arg2)
637cc9139ecSJason M. Bills {
638fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
6391668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
640b5c07418SJames Feist }
641b5c07418SJames Feist 
6421668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
6431668ce6dSEd Tanous                               std::string_view arg2)
644b5c07418SJames Feist {
645b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
646b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
647cc9139ecSJason M. Bills }
648cc9139ecSJason M. Bills 
649cc9139ecSJason M. Bills /**
650cc9139ecSJason M. Bills  * @internal
651684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
652684bb4b8SJason M. Bills  *
653684bb4b8SJason M. Bills  * See header file for more information
654684bb4b8SJason M. Bills  * @endinternal
655684bb4b8SJason M. Bills  */
656ace85d60SEd Tanous nlohmann::json resetRequired(const boost::urls::url_view& arg1,
6571668ce6dSEd Tanous                              std::string_view arg2)
658684bb4b8SJason M. Bills {
6591668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
660fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
6611668ce6dSEd Tanous                   std::to_array({arg1str, arg2}));
662684bb4b8SJason M. Bills }
663684bb4b8SJason M. Bills 
664ace85d60SEd Tanous void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
6651668ce6dSEd Tanous                    std::string_view arg2)
666684bb4b8SJason M. Bills {
667684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
668684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
669684bb4b8SJason M. Bills }
670684bb4b8SJason M. Bills 
671684bb4b8SJason M. Bills /**
672684bb4b8SJason M. Bills  * @internal
673684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
674684bb4b8SJason M. Bills  *
675684bb4b8SJason M. Bills  * See header file for more information
676684bb4b8SJason M. Bills  * @endinternal
677684bb4b8SJason M. Bills  */
6781668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
679684bb4b8SJason M. Bills {
680fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
6811668ce6dSEd Tanous                   std::to_array({arg1}));
682684bb4b8SJason M. Bills }
683684bb4b8SJason M. Bills 
6841668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
685684bb4b8SJason M. Bills {
686684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
687684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
688684bb4b8SJason M. Bills }
689684bb4b8SJason M. Bills 
690684bb4b8SJason M. Bills /**
691684bb4b8SJason M. Bills  * @internal
692684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
693684bb4b8SJason M. Bills  *
694684bb4b8SJason M. Bills  * See header file for more information
695684bb4b8SJason M. Bills  * @endinternal
696684bb4b8SJason M. Bills  */
6971668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
698684bb4b8SJason M. Bills {
699b6cd31e1SEd Tanous     return getLog(
700fffb8c1fSEd Tanous         redfish::registries::base::Index::chassisPowerStateOffRequired,
7011668ce6dSEd Tanous         std::to_array({arg1}));
702684bb4b8SJason M. Bills }
703684bb4b8SJason M. Bills 
7041668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1)
705684bb4b8SJason M. Bills {
706684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
707684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
708684bb4b8SJason M. Bills }
709684bb4b8SJason M. Bills 
710684bb4b8SJason M. Bills /**
711684bb4b8SJason M. Bills  * @internal
712684bb4b8SJason M. Bills  * @brief Formats PropertyValueConflict message into JSON
713684bb4b8SJason M. Bills  *
714684bb4b8SJason M. Bills  * See header file for more information
715684bb4b8SJason M. Bills  * @endinternal
716684bb4b8SJason M. Bills  */
7171668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1,
7181668ce6dSEd Tanous                                      std::string_view arg2)
719684bb4b8SJason M. Bills {
720fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueConflict,
7211668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
722684bb4b8SJason M. Bills }
723684bb4b8SJason M. Bills 
7241668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1,
7251668ce6dSEd Tanous                            std::string_view arg2)
726684bb4b8SJason M. Bills {
727684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
728684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
729684bb4b8SJason M. Bills }
730684bb4b8SJason M. Bills 
731684bb4b8SJason M. Bills /**
732684bb4b8SJason M. Bills  * @internal
733684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
734684bb4b8SJason M. Bills  *
735684bb4b8SJason M. Bills  * See header file for more information
736684bb4b8SJason M. Bills  * @endinternal
737684bb4b8SJason M. Bills  */
7381668ce6dSEd Tanous nlohmann::json propertyValueIncorrect(std::string_view arg1,
7391668ce6dSEd Tanous                                       std::string_view arg2)
740684bb4b8SJason M. Bills {
741fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueIncorrect,
7421668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
743684bb4b8SJason M. Bills }
744684bb4b8SJason M. Bills 
7451668ce6dSEd Tanous void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
7461668ce6dSEd Tanous                             std::string_view arg2)
747684bb4b8SJason M. Bills {
748684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
749684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
750684bb4b8SJason M. Bills }
751684bb4b8SJason M. Bills 
752684bb4b8SJason M. Bills /**
753684bb4b8SJason M. Bills  * @internal
754684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
755684bb4b8SJason M. Bills  *
756684bb4b8SJason M. Bills  * See header file for more information
757684bb4b8SJason M. Bills  * @endinternal
758684bb4b8SJason M. Bills  */
759ace85d60SEd Tanous nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1)
760684bb4b8SJason M. Bills {
7611668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
762fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCreationConflict,
7631668ce6dSEd Tanous                   std::to_array({arg1str}));
764684bb4b8SJason M. Bills }
765684bb4b8SJason M. Bills 
766ace85d60SEd Tanous void resourceCreationConflict(crow::Response& res,
767ace85d60SEd Tanous                               const boost::urls::url_view& arg1)
768684bb4b8SJason M. Bills {
769684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
770684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
771684bb4b8SJason M. Bills }
772684bb4b8SJason M. Bills 
773684bb4b8SJason M. Bills /**
774684bb4b8SJason M. Bills  * @internal
775684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded message into JSON
776684bb4b8SJason M. Bills  *
777684bb4b8SJason M. Bills  * See header file for more information
778684bb4b8SJason M. Bills  * @endinternal
779684bb4b8SJason M. Bills  */
780684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void)
781684bb4b8SJason M. Bills {
782fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
783684bb4b8SJason M. Bills }
784684bb4b8SJason M. Bills 
785684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
786684bb4b8SJason M. Bills {
787684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
788684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
789684bb4b8SJason M. Bills }
790684bb4b8SJason M. Bills 
791684bb4b8SJason M. Bills /**
792684bb4b8SJason M. Bills  * @internal
793684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
794684bb4b8SJason M. Bills  *
795684bb4b8SJason M. Bills  * See header file for more information
796684bb4b8SJason M. Bills  * @endinternal
797684bb4b8SJason M. Bills  */
798684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void)
799684bb4b8SJason M. Bills {
800fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionFailed, {});
801684bb4b8SJason M. Bills }
802684bb4b8SJason M. Bills 
803684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
804684bb4b8SJason M. Bills {
8054df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
806684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
807684bb4b8SJason M. Bills }
808684bb4b8SJason M. Bills 
809684bb4b8SJason M. Bills /**
810684bb4b8SJason M. Bills  * @internal
811684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
812684bb4b8SJason M. Bills  *
813684bb4b8SJason M. Bills  * See header file for more information
814684bb4b8SJason M. Bills  * @endinternal
815684bb4b8SJason M. Bills  */
816684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void)
817684bb4b8SJason M. Bills {
818fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionRequired, {});
819684bb4b8SJason M. Bills }
820684bb4b8SJason M. Bills 
821684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
822684bb4b8SJason M. Bills {
823684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
824684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
825684bb4b8SJason M. Bills }
826684bb4b8SJason M. Bills 
827684bb4b8SJason M. Bills /**
828684bb4b8SJason M. Bills  * @internal
829684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
830684bb4b8SJason M. Bills  *
831684bb4b8SJason M. Bills  * See header file for more information
832684bb4b8SJason M. Bills  * @endinternal
833684bb4b8SJason M. Bills  */
834684bb4b8SJason M. Bills nlohmann::json operationFailed(void)
835684bb4b8SJason M. Bills {
836fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationFailed, {});
837684bb4b8SJason M. Bills }
838684bb4b8SJason M. Bills 
839684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
840684bb4b8SJason M. Bills {
841684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
842684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
843684bb4b8SJason M. Bills }
844684bb4b8SJason M. Bills 
845684bb4b8SJason M. Bills /**
846684bb4b8SJason M. Bills  * @internal
847684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
848684bb4b8SJason M. Bills  *
849684bb4b8SJason M. Bills  * See header file for more information
850684bb4b8SJason M. Bills  * @endinternal
851684bb4b8SJason M. Bills  */
852684bb4b8SJason M. Bills nlohmann::json operationTimeout(void)
853684bb4b8SJason M. Bills {
854fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationTimeout, {});
855684bb4b8SJason M. Bills }
856684bb4b8SJason M. Bills 
857684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
858684bb4b8SJason M. Bills {
859684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
860684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
861684bb4b8SJason M. Bills }
862684bb4b8SJason M. Bills 
863684bb4b8SJason M. Bills /**
864684bb4b8SJason M. Bills  * @internal
865f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
866f12894f8SJason M. Bills  * property
867f12894f8SJason M. Bills  *
868f12894f8SJason M. Bills  * See header file for more information
869f12894f8SJason M. Bills  * @endinternal
870f12894f8SJason M. Bills  */
8711668ce6dSEd Tanous nlohmann::json propertyValueTypeError(std::string_view arg1,
8721668ce6dSEd Tanous                                       std::string_view arg2)
873f12894f8SJason M. Bills {
874fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueTypeError,
8751668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
876b5c07418SJames Feist }
877b5c07418SJames Feist 
8781668ce6dSEd Tanous void propertyValueTypeError(crow::Response& res, std::string_view arg1,
8791668ce6dSEd Tanous                             std::string_view arg2)
880b5c07418SJames Feist {
881b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
882b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
883f4c4dcf4SKowalski, Kamil }
884f4c4dcf4SKowalski, Kamil 
885f4c4dcf4SKowalski, Kamil /**
886f4c4dcf4SKowalski, Kamil  * @internal
887b6cd31e1SEd Tanous  * @brief Formats ResourceNotFound message into JSONd
888f4c4dcf4SKowalski, Kamil  *
889f4c4dcf4SKowalski, Kamil  * See header file for more information
890f4c4dcf4SKowalski, Kamil  * @endinternal
891f4c4dcf4SKowalski, Kamil  */
8921668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
8931abe55efSEd Tanous {
894fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceNotFound,
8951668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
896b5c07418SJames Feist }
897b5c07418SJames Feist 
8981668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1,
8991668ce6dSEd Tanous                       std::string_view arg2)
900b5c07418SJames Feist {
901b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
902b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
903f4c4dcf4SKowalski, Kamil }
904f4c4dcf4SKowalski, Kamil 
905f4c4dcf4SKowalski, Kamil /**
906f4c4dcf4SKowalski, Kamil  * @internal
907f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
908f4c4dcf4SKowalski, Kamil  *
909f4c4dcf4SKowalski, Kamil  * See header file for more information
910f4c4dcf4SKowalski, Kamil  * @endinternal
911f4c4dcf4SKowalski, Kamil  */
912ace85d60SEd Tanous nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1)
9131abe55efSEd Tanous {
9141668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
915fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
9161668ce6dSEd Tanous                   std::to_array({arg1str}));
917b5c07418SJames Feist }
918b5c07418SJames Feist 
919ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res,
920ace85d60SEd Tanous                                  const boost::urls::url_view& arg1)
921b5c07418SJames Feist {
922b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
923b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
924f4c4dcf4SKowalski, Kamil }
925f4c4dcf4SKowalski, Kamil 
926f4c4dcf4SKowalski, Kamil /**
927f4c4dcf4SKowalski, Kamil  * @internal
928f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
929f12894f8SJason M. Bills  * property
930f12894f8SJason M. Bills  *
931f12894f8SJason M. Bills  * See header file for more information
932f12894f8SJason M. Bills  * @endinternal
933f12894f8SJason M. Bills  */
9341668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1)
935f12894f8SJason M. Bills {
936fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyNotWritable,
9371668ce6dSEd Tanous                   std::to_array({arg1}));
938b5c07418SJames Feist }
939b5c07418SJames Feist 
9401668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1)
941b5c07418SJames Feist {
942b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
943b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
944f4c4dcf4SKowalski, Kamil }
945f4c4dcf4SKowalski, Kamil 
946f4c4dcf4SKowalski, Kamil /**
947f4c4dcf4SKowalski, Kamil  * @internal
948f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
949f4c4dcf4SKowalski, Kamil  *
950f4c4dcf4SKowalski, Kamil  * See header file for more information
951f4c4dcf4SKowalski, Kamil  * @endinternal
952f4c4dcf4SKowalski, Kamil  */
9531668ce6dSEd Tanous nlohmann::json queryParameterValueTypeError(std::string_view arg1,
9541668ce6dSEd Tanous                                             std::string_view arg2)
9551abe55efSEd Tanous {
956b6cd31e1SEd Tanous     return getLog(
957fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueTypeError,
9581668ce6dSEd Tanous         std::to_array({arg1, arg2}));
959b5c07418SJames Feist }
960b5c07418SJames Feist 
9611668ce6dSEd Tanous void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
9621668ce6dSEd Tanous                                   std::string_view arg2)
963b5c07418SJames Feist {
964b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
965b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
966b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
967f4c4dcf4SKowalski, Kamil }
968f4c4dcf4SKowalski, Kamil 
969f4c4dcf4SKowalski, Kamil /**
970f4c4dcf4SKowalski, Kamil  * @internal
971f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
972f4c4dcf4SKowalski, Kamil  *
973f4c4dcf4SKowalski, Kamil  * See header file for more information
974f4c4dcf4SKowalski, Kamil  * @endinternal
975f4c4dcf4SKowalski, Kamil  */
976b5c07418SJames Feist nlohmann::json serviceShuttingDown(void)
9771abe55efSEd Tanous {
978fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
979b5c07418SJames Feist }
980b5c07418SJames Feist 
981b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
982b5c07418SJames Feist {
983b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
984b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
985f4c4dcf4SKowalski, Kamil }
986f4c4dcf4SKowalski, Kamil 
987f4c4dcf4SKowalski, Kamil /**
988f4c4dcf4SKowalski, Kamil  * @internal
989f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
990f4c4dcf4SKowalski, Kamil  *
991f4c4dcf4SKowalski, Kamil  * See header file for more information
992f4c4dcf4SKowalski, Kamil  * @endinternal
993f4c4dcf4SKowalski, Kamil  */
9941668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1,
9951668ce6dSEd Tanous                                         std::string_view arg2)
9961abe55efSEd Tanous {
997fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
9981668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
999b5c07418SJames Feist }
1000b5c07418SJames Feist 
10011668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
10021668ce6dSEd Tanous                               std::string_view arg2)
1003b5c07418SJames Feist {
1004b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1005b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1006f4c4dcf4SKowalski, Kamil }
1007f4c4dcf4SKowalski, Kamil 
1008f4c4dcf4SKowalski, Kamil /**
1009f4c4dcf4SKowalski, Kamil  * @internal
1010f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1011f4c4dcf4SKowalski, Kamil  *
1012f4c4dcf4SKowalski, Kamil  * See header file for more information
1013f4c4dcf4SKowalski, Kamil  * @endinternal
1014f4c4dcf4SKowalski, Kamil  */
10151668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1,
10161668ce6dSEd Tanous                                            std::string_view arg2)
10171abe55efSEd Tanous {
1018fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
10191668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1020b5c07418SJames Feist }
1021b5c07418SJames Feist 
10221668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
10231668ce6dSEd Tanous                                  std::string_view arg2)
1024b5c07418SJames Feist {
1025b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1026b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1027b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1028f4c4dcf4SKowalski, Kamil }
1029f4c4dcf4SKowalski, Kamil 
1030f4c4dcf4SKowalski, Kamil /**
1031f4c4dcf4SKowalski, Kamil  * @internal
1032f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1033f4c4dcf4SKowalski, Kamil  *
1034f4c4dcf4SKowalski, Kamil  * See header file for more information
1035f4c4dcf4SKowalski, Kamil  * @endinternal
1036f4c4dcf4SKowalski, Kamil  */
1037ace85d60SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1,
10381668ce6dSEd Tanous                                             std::string_view arg2)
10391abe55efSEd Tanous {
10401668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1041b6cd31e1SEd Tanous     return getLog(
1042fffb8c1fSEd Tanous         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
10431668ce6dSEd Tanous         std::to_array({arg1str, arg2}));
1044b5c07418SJames Feist }
1045b5c07418SJames Feist 
1046ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res,
1047ace85d60SEd Tanous                                   const boost::urls::url_view& arg1,
10481668ce6dSEd Tanous                                   std::string_view arg2)
1049b5c07418SJames Feist {
1050b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1051b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1052b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1053f4c4dcf4SKowalski, Kamil }
1054f4c4dcf4SKowalski, Kamil 
1055f4c4dcf4SKowalski, Kamil /**
1056f4c4dcf4SKowalski, Kamil  * @internal
1057f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1058f4c4dcf4SKowalski, Kamil  *
1059f4c4dcf4SKowalski, Kamil  * See header file for more information
1060f4c4dcf4SKowalski, Kamil  * @endinternal
1061f4c4dcf4SKowalski, Kamil  */
1062b5c07418SJames Feist nlohmann::json accountRemoved(void)
10631abe55efSEd Tanous {
1064fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountRemoved, {});
1065b5c07418SJames Feist }
1066b5c07418SJames Feist 
1067b5c07418SJames Feist void accountRemoved(crow::Response& res)
1068b5c07418SJames Feist {
1069b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1070b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1071f4c4dcf4SKowalski, Kamil }
1072f4c4dcf4SKowalski, Kamil 
1073f4c4dcf4SKowalski, Kamil /**
1074f4c4dcf4SKowalski, Kamil  * @internal
1075f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1076f4c4dcf4SKowalski, Kamil  *
1077f4c4dcf4SKowalski, Kamil  * See header file for more information
1078f4c4dcf4SKowalski, Kamil  * @endinternal
1079f4c4dcf4SKowalski, Kamil  */
1080ace85d60SEd Tanous nlohmann::json accessDenied(const boost::urls::url_view& arg1)
10811abe55efSEd Tanous {
10821668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1083fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accessDenied,
10841668ce6dSEd Tanous                   std::to_array({arg1str}));
1085b5c07418SJames Feist }
1086b5c07418SJames Feist 
1087ace85d60SEd Tanous void accessDenied(crow::Response& res, const boost::urls::url_view& arg1)
1088b5c07418SJames Feist {
1089b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1090b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1091f4c4dcf4SKowalski, Kamil }
1092f4c4dcf4SKowalski, Kamil 
1093f4c4dcf4SKowalski, Kamil /**
1094f4c4dcf4SKowalski, Kamil  * @internal
1095f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1096f4c4dcf4SKowalski, Kamil  *
1097f4c4dcf4SKowalski, Kamil  * See header file for more information
1098f4c4dcf4SKowalski, Kamil  * @endinternal
1099f4c4dcf4SKowalski, Kamil  */
1100b5c07418SJames Feist nlohmann::json queryNotSupported(void)
11011abe55efSEd Tanous {
1102fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1103b5c07418SJames Feist }
1104b5c07418SJames Feist 
1105b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1106b5c07418SJames Feist {
1107b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1108b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1109f4c4dcf4SKowalski, Kamil }
1110f4c4dcf4SKowalski, Kamil 
1111f4c4dcf4SKowalski, Kamil /**
1112f4c4dcf4SKowalski, Kamil  * @internal
1113f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1114f4c4dcf4SKowalski, Kamil  *
1115f4c4dcf4SKowalski, Kamil  * See header file for more information
1116f4c4dcf4SKowalski, Kamil  * @endinternal
1117f4c4dcf4SKowalski, Kamil  */
1118b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void)
11191abe55efSEd Tanous {
1120b6cd31e1SEd Tanous     return getLog(
1121fffb8c1fSEd Tanous         redfish::registries::base::Index::createLimitReachedForResource, {});
1122b5c07418SJames Feist }
1123b5c07418SJames Feist 
1124b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1125b5c07418SJames Feist {
1126b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1127b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1128f4c4dcf4SKowalski, Kamil }
1129f4c4dcf4SKowalski, Kamil 
1130f4c4dcf4SKowalski, Kamil /**
1131f4c4dcf4SKowalski, Kamil  * @internal
1132f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1133f4c4dcf4SKowalski, Kamil  *
1134f4c4dcf4SKowalski, Kamil  * See header file for more information
1135f4c4dcf4SKowalski, Kamil  * @endinternal
1136f4c4dcf4SKowalski, Kamil  */
1137b5c07418SJames Feist nlohmann::json generalError(void)
11381abe55efSEd Tanous {
1139fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::generalError, {});
1140b5c07418SJames Feist }
1141b5c07418SJames Feist 
1142b5c07418SJames Feist void generalError(crow::Response& res)
1143b5c07418SJames Feist {
1144b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1145b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1146f4c4dcf4SKowalski, Kamil }
1147f4c4dcf4SKowalski, Kamil 
1148f4c4dcf4SKowalski, Kamil /**
1149f4c4dcf4SKowalski, Kamil  * @internal
1150f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1151f4c4dcf4SKowalski, Kamil  *
1152f4c4dcf4SKowalski, Kamil  * See header file for more information
1153f4c4dcf4SKowalski, Kamil  * @endinternal
1154f4c4dcf4SKowalski, Kamil  */
1155b5c07418SJames Feist nlohmann::json success(void)
11561abe55efSEd Tanous {
1157fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::success, {});
1158b5c07418SJames Feist }
1159b5c07418SJames Feist 
1160b5c07418SJames Feist void success(crow::Response& res)
1161b5c07418SJames Feist {
1162b5c07418SJames Feist     // don't set res.result here because success is the default and any
1163b5c07418SJames Feist     // error should overwrite the default
1164b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1165f12894f8SJason M. Bills }
1166f12894f8SJason M. Bills 
1167f12894f8SJason M. Bills /**
1168f12894f8SJason M. Bills  * @internal
1169f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1170f4c4dcf4SKowalski, Kamil  *
1171f4c4dcf4SKowalski, Kamil  * See header file for more information
1172f4c4dcf4SKowalski, Kamil  * @endinternal
1173f4c4dcf4SKowalski, Kamil  */
1174b5c07418SJames Feist nlohmann::json created(void)
11751abe55efSEd Tanous {
1176fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::created, {});
1177b5c07418SJames Feist }
1178b5c07418SJames Feist 
1179b5c07418SJames Feist void created(crow::Response& res)
1180b5c07418SJames Feist {
1181b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1182b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1183f4c4dcf4SKowalski, Kamil }
1184f4c4dcf4SKowalski, Kamil 
1185f4c4dcf4SKowalski, Kamil /**
1186f4c4dcf4SKowalski, Kamil  * @internal
1187cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1188cc9139ecSJason M. Bills  *
1189cc9139ecSJason M. Bills  * See header file for more information
1190cc9139ecSJason M. Bills  * @endinternal
1191cc9139ecSJason M. Bills  */
1192b5c07418SJames Feist nlohmann::json noOperation(void)
1193cc9139ecSJason M. Bills {
1194fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noOperation, {});
1195b5c07418SJames Feist }
1196b5c07418SJames Feist 
1197b5c07418SJames Feist void noOperation(crow::Response& res)
1198b5c07418SJames Feist {
1199b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1200b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1201cc9139ecSJason M. Bills }
1202cc9139ecSJason M. Bills 
1203cc9139ecSJason M. Bills /**
1204cc9139ecSJason M. Bills  * @internal
1205b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1206b5c07418SJames Feist  * property
1207f12894f8SJason M. Bills  *
1208f12894f8SJason M. Bills  * See header file for more information
1209f12894f8SJason M. Bills  * @endinternal
1210f12894f8SJason M. Bills  */
12111668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1)
1212b5c07418SJames Feist {
1213fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyUnknown,
12141668ce6dSEd Tanous                   std::to_array({arg1}));
1215b5c07418SJames Feist }
1216b5c07418SJames Feist 
12171668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1)
1218f12894f8SJason M. Bills {
1219f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1220b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1);
1221f4c4dcf4SKowalski, Kamil }
1222f4c4dcf4SKowalski, Kamil 
1223f4c4dcf4SKowalski, Kamil /**
1224f4c4dcf4SKowalski, Kamil  * @internal
1225f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1226f4c4dcf4SKowalski, Kamil  *
1227f4c4dcf4SKowalski, Kamil  * See header file for more information
1228f4c4dcf4SKowalski, Kamil  * @endinternal
1229f4c4dcf4SKowalski, Kamil  */
1230b5c07418SJames Feist nlohmann::json noValidSession(void)
12311abe55efSEd Tanous {
1232fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noValidSession, {});
1233b5c07418SJames Feist }
1234b5c07418SJames Feist 
1235b5c07418SJames Feist void noValidSession(crow::Response& res)
1236b5c07418SJames Feist {
1237b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1238b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1239f4c4dcf4SKowalski, Kamil }
1240f4c4dcf4SKowalski, Kamil 
1241f4c4dcf4SKowalski, Kamil /**
1242f4c4dcf4SKowalski, Kamil  * @internal
1243f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1244f4c4dcf4SKowalski, Kamil  *
1245f4c4dcf4SKowalski, Kamil  * See header file for more information
1246f4c4dcf4SKowalski, Kamil  * @endinternal
1247f4c4dcf4SKowalski, Kamil  */
1248ace85d60SEd Tanous nlohmann::json invalidObject(const boost::urls::url_view& arg1)
12491abe55efSEd Tanous {
12501668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1251fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidObject,
12521668ce6dSEd Tanous                   std::to_array({arg1str}));
1253b5c07418SJames Feist }
1254b5c07418SJames Feist 
1255ace85d60SEd Tanous void invalidObject(crow::Response& res, const boost::urls::url_view& arg1)
1256b5c07418SJames Feist {
1257b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1258b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1259f4c4dcf4SKowalski, Kamil }
1260f4c4dcf4SKowalski, Kamil 
1261f4c4dcf4SKowalski, Kamil /**
1262f4c4dcf4SKowalski, Kamil  * @internal
1263f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1264f4c4dcf4SKowalski, Kamil  *
1265f4c4dcf4SKowalski, Kamil  * See header file for more information
1266f4c4dcf4SKowalski, Kamil  * @endinternal
1267f4c4dcf4SKowalski, Kamil  */
1268b5c07418SJames Feist nlohmann::json resourceInStandby(void)
12691abe55efSEd Tanous {
1270fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1271b5c07418SJames Feist }
1272b5c07418SJames Feist 
1273b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1274b5c07418SJames Feist {
1275b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1276b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1277f4c4dcf4SKowalski, Kamil }
1278f4c4dcf4SKowalski, Kamil 
1279f4c4dcf4SKowalski, Kamil /**
1280f4c4dcf4SKowalski, Kamil  * @internal
1281f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1282f4c4dcf4SKowalski, Kamil  *
1283f4c4dcf4SKowalski, Kamil  * See header file for more information
1284f4c4dcf4SKowalski, Kamil  * @endinternal
1285f4c4dcf4SKowalski, Kamil  */
12861668ce6dSEd Tanous nlohmann::json actionParameterValueTypeError(std::string_view arg1,
12871668ce6dSEd Tanous                                              std::string_view arg2,
12881668ce6dSEd Tanous                                              std::string_view arg3)
12891abe55efSEd Tanous {
1290b6cd31e1SEd Tanous     return getLog(
1291fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueTypeError,
12921668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
1293b5c07418SJames Feist }
1294b5c07418SJames Feist 
12951668ce6dSEd Tanous void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
12961668ce6dSEd Tanous                                    std::string_view arg2, std::string_view arg3)
1297b5c07418SJames Feist {
1298b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1299b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1300b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1301f4c4dcf4SKowalski, Kamil }
1302f4c4dcf4SKowalski, Kamil 
1303f4c4dcf4SKowalski, Kamil /**
1304f4c4dcf4SKowalski, Kamil  * @internal
1305f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1306f4c4dcf4SKowalski, Kamil  *
1307f4c4dcf4SKowalski, Kamil  * See header file for more information
1308f4c4dcf4SKowalski, Kamil  * @endinternal
1309f4c4dcf4SKowalski, Kamil  */
1310b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void)
13111abe55efSEd Tanous {
1312fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1313b5c07418SJames Feist }
1314b5c07418SJames Feist 
1315b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1316b5c07418SJames Feist {
1317b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1318b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1319f4c4dcf4SKowalski, Kamil }
1320f4c4dcf4SKowalski, Kamil 
1321f4c4dcf4SKowalski, Kamil /**
1322f4c4dcf4SKowalski, Kamil  * @internal
1323f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1324f4c4dcf4SKowalski, Kamil  *
1325f4c4dcf4SKowalski, Kamil  * See header file for more information
1326f4c4dcf4SKowalski, Kamil  * @endinternal
1327f4c4dcf4SKowalski, Kamil  */
13281668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1)
13291abe55efSEd Tanous {
1330fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionNotSupported,
13311668ce6dSEd Tanous                   std::to_array({arg1}));
1332b5c07418SJames Feist }
1333b5c07418SJames Feist 
13341668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1)
1335b5c07418SJames Feist {
1336b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1337b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1338f4c4dcf4SKowalski, Kamil }
1339f4c4dcf4SKowalski, Kamil 
1340f4c4dcf4SKowalski, Kamil /**
1341f4c4dcf4SKowalski, Kamil  * @internal
1342f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1343f4c4dcf4SKowalski, Kamil  *
1344f4c4dcf4SKowalski, Kamil  * See header file for more information
1345f4c4dcf4SKowalski, Kamil  * @endinternal
1346f4c4dcf4SKowalski, Kamil  */
13475187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
13481abe55efSEd Tanous {
1349b6cd31e1SEd Tanous     std::string arg1Str = std::to_string(arg1);
1350fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidIndex,
13511668ce6dSEd Tanous                   std::to_array<std::string_view>({arg1Str}));
1352b5c07418SJames Feist }
1353b5c07418SJames Feist 
13545187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1355b5c07418SJames Feist {
1356b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1357b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1358f4c4dcf4SKowalski, Kamil }
1359f4c4dcf4SKowalski, Kamil 
1360f4c4dcf4SKowalski, Kamil /**
1361f4c4dcf4SKowalski, Kamil  * @internal
1362f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1363f4c4dcf4SKowalski, Kamil  *
1364f4c4dcf4SKowalski, Kamil  * See header file for more information
1365f4c4dcf4SKowalski, Kamil  * @endinternal
1366f4c4dcf4SKowalski, Kamil  */
1367b5c07418SJames Feist nlohmann::json emptyJSON(void)
13681abe55efSEd Tanous {
1369fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::emptyJSON, {});
1370b5c07418SJames Feist }
1371b5c07418SJames Feist 
1372b5c07418SJames Feist void emptyJSON(crow::Response& res)
1373b5c07418SJames Feist {
1374b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1375b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1376f4c4dcf4SKowalski, Kamil }
1377f4c4dcf4SKowalski, Kamil 
1378f4c4dcf4SKowalski, Kamil /**
1379f4c4dcf4SKowalski, Kamil  * @internal
1380f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1381f4c4dcf4SKowalski, Kamil  *
1382f4c4dcf4SKowalski, Kamil  * See header file for more information
1383f4c4dcf4SKowalski, Kamil  * @endinternal
1384f4c4dcf4SKowalski, Kamil  */
1385b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void)
13861abe55efSEd Tanous {
1387fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1388b6cd31e1SEd Tanous                   {});
1389b5c07418SJames Feist }
1390b5c07418SJames Feist 
1391b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1392b5c07418SJames Feist {
1393b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1394b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1395f4c4dcf4SKowalski, Kamil }
1396f4c4dcf4SKowalski, Kamil 
1397f4c4dcf4SKowalski, Kamil /**
1398f4c4dcf4SKowalski, Kamil  * @internal
1399684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1400684bb4b8SJason M. Bills  *
1401684bb4b8SJason M. Bills  * See header file for more information
1402684bb4b8SJason M. Bills  * @endinternal
1403684bb4b8SJason M. Bills  */
1404684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void)
1405684bb4b8SJason M. Bills {
1406b6cd31e1SEd Tanous     return getLog(
1407fffb8c1fSEd Tanous         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1408684bb4b8SJason M. Bills }
1409684bb4b8SJason M. Bills 
1410684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1411684bb4b8SJason M. Bills {
1412684bb4b8SJason M. Bills     res.result(boost::beast::http::status::forbidden);
1413684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1414684bb4b8SJason M. Bills }
1415684bb4b8SJason M. Bills 
1416684bb4b8SJason M. Bills /**
1417684bb4b8SJason M. Bills  * @internal
1418684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1419684bb4b8SJason M. Bills  *
1420684bb4b8SJason M. Bills  * See header file for more information
1421684bb4b8SJason M. Bills  * @endinternal
1422684bb4b8SJason M. Bills  */
1423684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void)
1424684bb4b8SJason M. Bills {
1425fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1426fffb8c1fSEd Tanous                   {});
1427684bb4b8SJason M. Bills }
1428684bb4b8SJason M. Bills 
1429684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1430684bb4b8SJason M. Bills {
1431684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1432684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1433684bb4b8SJason M. Bills }
1434684bb4b8SJason M. Bills 
1435684bb4b8SJason M. Bills /**
1436684bb4b8SJason M. Bills  * @internal
1437f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1438f4c4dcf4SKowalski, Kamil  *
1439f4c4dcf4SKowalski, Kamil  * See header file for more information
1440f4c4dcf4SKowalski, Kamil  * @endinternal
1441f4c4dcf4SKowalski, Kamil  */
1442b5c07418SJames Feist nlohmann::json insufficientPrivilege(void)
14431abe55efSEd Tanous {
1444fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1445b5c07418SJames Feist }
1446b5c07418SJames Feist 
1447b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1448b5c07418SJames Feist {
1449b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1450b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1451f4c4dcf4SKowalski, Kamil }
1452f4c4dcf4SKowalski, Kamil 
1453f4c4dcf4SKowalski, Kamil /**
1454f4c4dcf4SKowalski, Kamil  * @internal
1455f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1456f4c4dcf4SKowalski, Kamil  *
1457f4c4dcf4SKowalski, Kamil  * See header file for more information
1458f4c4dcf4SKowalski, Kamil  * @endinternal
1459f4c4dcf4SKowalski, Kamil  */
14601668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1,
14611668ce6dSEd Tanous                                      std::string_view arg2)
1462b5c07418SJames Feist {
1463fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueModified,
14641668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1465b5c07418SJames Feist }
1466b5c07418SJames Feist 
14671668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1,
14681668ce6dSEd Tanous                            std::string_view arg2)
14691abe55efSEd Tanous {
1470f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1471b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1472f4c4dcf4SKowalski, Kamil }
1473f4c4dcf4SKowalski, Kamil 
1474f4c4dcf4SKowalski, Kamil /**
1475f4c4dcf4SKowalski, Kamil  * @internal
1476f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1477f4c4dcf4SKowalski, Kamil  *
1478f4c4dcf4SKowalski, Kamil  * See header file for more information
1479f4c4dcf4SKowalski, Kamil  * @endinternal
1480f4c4dcf4SKowalski, Kamil  */
1481b5c07418SJames Feist nlohmann::json accountNotModified(void)
14821abe55efSEd Tanous {
1483fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountNotModified, {});
1484b5c07418SJames Feist }
1485b5c07418SJames Feist 
1486b5c07418SJames Feist void accountNotModified(crow::Response& res)
1487b5c07418SJames Feist {
1488b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1489b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1490f4c4dcf4SKowalski, Kamil }
1491f4c4dcf4SKowalski, Kamil 
1492f4c4dcf4SKowalski, Kamil /**
1493f4c4dcf4SKowalski, Kamil  * @internal
1494f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1495f4c4dcf4SKowalski, Kamil  *
1496f4c4dcf4SKowalski, Kamil  * See header file for more information
1497f4c4dcf4SKowalski, Kamil  * @endinternal
1498f4c4dcf4SKowalski, Kamil  */
14991668ce6dSEd Tanous nlohmann::json queryParameterValueFormatError(std::string_view arg1,
15001668ce6dSEd Tanous                                               std::string_view arg2)
15011abe55efSEd Tanous {
1502fffb8c1fSEd Tanous     return getLog(
1503fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueFormatError,
15041668ce6dSEd Tanous         std::to_array({arg1, arg2}));
1505b5c07418SJames Feist }
1506b5c07418SJames Feist 
15071668ce6dSEd Tanous void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
15081668ce6dSEd Tanous                                     std::string_view arg2)
1509b5c07418SJames Feist {
1510b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1511b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1512b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
1513f4c4dcf4SKowalski, Kamil }
1514f4c4dcf4SKowalski, Kamil 
1515f4c4dcf4SKowalski, Kamil /**
1516f4c4dcf4SKowalski, Kamil  * @internal
1517b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
1518b5c07418SJames Feist  * property
1519f12894f8SJason M. Bills  *
1520f12894f8SJason M. Bills  * See header file for more information
1521f12894f8SJason M. Bills  * @endinternal
1522f12894f8SJason M. Bills  */
15231668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1)
1524f12894f8SJason M. Bills {
1525fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyMissing,
15261668ce6dSEd Tanous                   std::to_array({arg1}));
1527b5c07418SJames Feist }
1528b5c07418SJames Feist 
15291668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1)
1530b5c07418SJames Feist {
1531b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1532b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1533f4c4dcf4SKowalski, Kamil }
1534f4c4dcf4SKowalski, Kamil 
1535f4c4dcf4SKowalski, Kamil /**
1536f4c4dcf4SKowalski, Kamil  * @internal
1537f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
1538f4c4dcf4SKowalski, Kamil  *
1539f4c4dcf4SKowalski, Kamil  * See header file for more information
1540f4c4dcf4SKowalski, Kamil  * @endinternal
1541f4c4dcf4SKowalski, Kamil  */
15421668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1)
15431abe55efSEd Tanous {
1544fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceExhaustion,
15451668ce6dSEd Tanous                   std::to_array({arg1}));
1546b5c07418SJames Feist }
1547b5c07418SJames Feist 
15481668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1)
1549b5c07418SJames Feist {
1550b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1551b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1552f4c4dcf4SKowalski, Kamil }
1553f4c4dcf4SKowalski, Kamil 
1554f4c4dcf4SKowalski, Kamil /**
1555f4c4dcf4SKowalski, Kamil  * @internal
1556f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
1557f4c4dcf4SKowalski, Kamil  *
1558f4c4dcf4SKowalski, Kamil  * See header file for more information
1559f4c4dcf4SKowalski, Kamil  * @endinternal
1560f4c4dcf4SKowalski, Kamil  */
1561b5c07418SJames Feist nlohmann::json accountModified(void)
15621abe55efSEd Tanous {
1563fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountModified, {});
1564b5c07418SJames Feist }
1565b5c07418SJames Feist 
1566b5c07418SJames Feist void accountModified(crow::Response& res)
1567b5c07418SJames Feist {
1568b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1569b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
1570f4c4dcf4SKowalski, Kamil }
1571f4c4dcf4SKowalski, Kamil 
1572f4c4dcf4SKowalski, Kamil /**
1573f4c4dcf4SKowalski, Kamil  * @internal
1574f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
1575f4c4dcf4SKowalski, Kamil  *
1576f4c4dcf4SKowalski, Kamil  * See header file for more information
1577f4c4dcf4SKowalski, Kamil  * @endinternal
1578f4c4dcf4SKowalski, Kamil  */
15791668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1,
15801668ce6dSEd Tanous                                         std::string_view arg2,
15811668ce6dSEd Tanous                                         std::string_view arg3)
15821abe55efSEd Tanous {
1583fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
15841668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
1585b5c07418SJames Feist }
1586b5c07418SJames Feist 
15871668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
15881668ce6dSEd Tanous                               std::string_view arg2, std::string_view arg3)
1589b5c07418SJames Feist {
1590b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1591b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1592b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
1593f4c4dcf4SKowalski, Kamil }
1594f4c4dcf4SKowalski, Kamil 
1595b6cd31e1SEd Tanous nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1)
1596b6cd31e1SEd Tanous {
15971668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1598fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::passwordChangeRequired,
15991668ce6dSEd Tanous                   std::to_array({arg1str}));
1600b6cd31e1SEd Tanous }
1601b6cd31e1SEd Tanous 
16023bf4e632SJoseph Reynolds /**
16033bf4e632SJoseph Reynolds  * @internal
16043bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
16053bf4e632SJoseph Reynolds  *
16063bf4e632SJoseph Reynolds  * See header file for more information
16073bf4e632SJoseph Reynolds  * @endinternal
16083bf4e632SJoseph Reynolds  */
1609ace85d60SEd Tanous void passwordChangeRequired(crow::Response& res,
1610ace85d60SEd Tanous                             const boost::urls::url_view& arg1)
16113bf4e632SJoseph Reynolds {
1612b6cd31e1SEd Tanous     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
16133bf4e632SJoseph Reynolds }
16143bf4e632SJoseph Reynolds 
16151668ce6dSEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1,
16161668ce6dSEd Tanous                    std::string_view arg2)
16174cde5d90SJames Feist {
16184cde5d90SJames Feist     res.result(boost::beast::http::status::bad_request);
16194cde5d90SJames Feist     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
16204cde5d90SJames Feist }
16214cde5d90SJames Feist 
16224cde5d90SJames Feist /**
16234cde5d90SJames Feist  * @internal
16244cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
16254cde5d90SJames Feist  *
16264cde5d90SJames Feist  * See header file for more information
16274cde5d90SJames Feist  * @endinternal
16284cde5d90SJames Feist  */
16291668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
16304cde5d90SJames Feist {
16311668ce6dSEd Tanous     std::string msg = "Invalid file uploaded to ";
16321668ce6dSEd Tanous     msg += arg1;
16331668ce6dSEd Tanous     msg += ": ";
16341668ce6dSEd Tanous     msg += arg2;
16351668ce6dSEd Tanous     msg += ".";
16364cde5d90SJames Feist     return nlohmann::json{
16373e082749SAsmitha Karunanithi         {"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"},
16384a0bf539SManojkiran Eda         {"MessageId", "OpenBMC.0.2.InvalidUpload"},
16391668ce6dSEd Tanous         {"Message", std::move(msg)},
16404cde5d90SJames Feist         {"MessageArgs", {arg1, arg2}},
1641684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
16424cde5d90SJames Feist         {"Resolution", "None."}};
16434cde5d90SJames Feist }
1644f4c4dcf4SKowalski, Kamil } // namespace messages
1645f4c4dcf4SKowalski, Kamil 
1646d425c6f6SEd Tanous } // namespace redfish
1647