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         }
571476687dSEd Tanous         error["code"] = *messageIdIterator;
581476687dSEd Tanous         error["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 
110f7725d79SEd 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;
1321476687dSEd Tanous     nlohmann::json::object_t response;
1331476687dSEd Tanous     response["@odata.type"] = "#Message.v1_1_1.Message";
1341476687dSEd Tanous     response["MessageId"] = std::move(msgId);
1351476687dSEd Tanous     response["Message"] = std::move(msg);
1361476687dSEd Tanous     response["MessageArgs"] = std::move(jArgs);
1371476687dSEd Tanous     response["MessageSeverity"] = entry.second.messageSeverity;
1381476687dSEd Tanous     response["Resolution"] = entry.second.resolution;
1391476687dSEd Tanous     return response;
140b6cd31e1SEd Tanous }
141b6cd31e1SEd Tanous 
142f4c4dcf4SKowalski, Kamil /**
143f4c4dcf4SKowalski, Kamil  * @internal
144f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
145f4c4dcf4SKowalski, Kamil  *
146f4c4dcf4SKowalski, Kamil  * See header file for more information
147f4c4dcf4SKowalski, Kamil  * @endinternal
148f4c4dcf4SKowalski, Kamil  */
149b5c07418SJames Feist nlohmann::json resourceInUse(void)
1501abe55efSEd Tanous {
151fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInUse, {});
152b5c07418SJames Feist }
153b5c07418SJames Feist 
154b5c07418SJames Feist void resourceInUse(crow::Response& res)
155b5c07418SJames Feist {
156b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
157b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
158f4c4dcf4SKowalski, Kamil }
159f4c4dcf4SKowalski, Kamil 
160f4c4dcf4SKowalski, Kamil /**
161f4c4dcf4SKowalski, Kamil  * @internal
162f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
163f4c4dcf4SKowalski, Kamil  *
164f4c4dcf4SKowalski, Kamil  * See header file for more information
165f4c4dcf4SKowalski, Kamil  * @endinternal
166f4c4dcf4SKowalski, Kamil  */
167b5c07418SJames Feist nlohmann::json malformedJSON(void)
1681abe55efSEd Tanous {
169fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::malformedJSON, {});
170b5c07418SJames Feist }
171b5c07418SJames Feist 
172b5c07418SJames Feist void malformedJSON(crow::Response& res)
173b5c07418SJames Feist {
174b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
175b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
176f4c4dcf4SKowalski, Kamil }
177f4c4dcf4SKowalski, Kamil 
178f4c4dcf4SKowalski, Kamil /**
179f4c4dcf4SKowalski, Kamil  * @internal
180f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
181f4c4dcf4SKowalski, Kamil  *
182f4c4dcf4SKowalski, Kamil  * See header file for more information
183f4c4dcf4SKowalski, Kamil  * @endinternal
184f4c4dcf4SKowalski, Kamil  */
185ace85d60SEd Tanous nlohmann::json resourceMissingAtURI(const boost::urls::url_view& arg1)
1861abe55efSEd Tanous {
187b6cd31e1SEd Tanous     std::array<std::string_view, 1> args{
188b6cd31e1SEd Tanous         std::string_view{arg1.data(), arg1.size()}};
189fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceMissingAtURI, args);
190b5c07418SJames Feist }
191b5c07418SJames Feist 
192ace85d60SEd Tanous void resourceMissingAtURI(crow::Response& res,
193ace85d60SEd Tanous                           const boost::urls::url_view& arg1)
194b5c07418SJames Feist {
195b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
196b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
197f4c4dcf4SKowalski, Kamil }
198f4c4dcf4SKowalski, Kamil 
199f4c4dcf4SKowalski, Kamil /**
200f4c4dcf4SKowalski, Kamil  * @internal
201f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
202f4c4dcf4SKowalski, Kamil  *
203f4c4dcf4SKowalski, Kamil  * See header file for more information
204f4c4dcf4SKowalski, Kamil  * @endinternal
205f4c4dcf4SKowalski, Kamil  */
2061668ce6dSEd Tanous nlohmann::json actionParameterValueFormatError(std::string_view arg1,
2071668ce6dSEd Tanous                                                std::string_view arg2,
2081668ce6dSEd Tanous                                                std::string_view arg3)
2091abe55efSEd Tanous {
210fffb8c1fSEd Tanous     return getLog(
211fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueFormatError,
2121668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
213b5c07418SJames Feist }
214b5c07418SJames Feist 
2151668ce6dSEd Tanous void actionParameterValueFormatError(crow::Response& res, std::string_view arg1,
2161668ce6dSEd Tanous                                      std::string_view arg2,
2171668ce6dSEd Tanous                                      std::string_view arg3)
218b5c07418SJames Feist {
219b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
220b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
221b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
222f4c4dcf4SKowalski, Kamil }
223f4c4dcf4SKowalski, Kamil 
224f4c4dcf4SKowalski, Kamil /**
225f4c4dcf4SKowalski, Kamil  * @internal
226f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
227f4c4dcf4SKowalski, Kamil  *
228f4c4dcf4SKowalski, Kamil  * See header file for more information
229f4c4dcf4SKowalski, Kamil  * @endinternal
230f4c4dcf4SKowalski, Kamil  */
231b5c07418SJames Feist nlohmann::json internalError(void)
2321abe55efSEd Tanous {
233fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::internalError, {});
234b5c07418SJames Feist }
235b5c07418SJames Feist 
236df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location)
237b5c07418SJames Feist {
238df5415fcSEd Tanous     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
239df5415fcSEd Tanous                         << location.line() << ":" << location.column() << ") `"
240df5415fcSEd Tanous                         << location.function_name() << "`: ";
241b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
242b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
243f12894f8SJason M. Bills }
244f12894f8SJason M. Bills 
245f12894f8SJason M. Bills /**
246f12894f8SJason M. Bills  * @internal
247f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
248f4c4dcf4SKowalski, Kamil  *
249f4c4dcf4SKowalski, Kamil  * See header file for more information
250f4c4dcf4SKowalski, Kamil  * @endinternal
251f4c4dcf4SKowalski, Kamil  */
252b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void)
2531abe55efSEd Tanous {
254fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::unrecognizedRequestBody,
255fffb8c1fSEd Tanous                   {});
256b5c07418SJames Feist }
257b5c07418SJames Feist 
258b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
259b5c07418SJames Feist {
260b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
261b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
262f4c4dcf4SKowalski, Kamil }
263f4c4dcf4SKowalski, Kamil 
264f4c4dcf4SKowalski, Kamil /**
265f4c4dcf4SKowalski, Kamil  * @internal
266f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
267f4c4dcf4SKowalski, Kamil  *
268f4c4dcf4SKowalski, Kamil  * See header file for more information
269f4c4dcf4SKowalski, Kamil  * @endinternal
270f4c4dcf4SKowalski, Kamil  */
271ace85d60SEd Tanous nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1,
2721668ce6dSEd Tanous                                          std::string_view arg2)
2731abe55efSEd Tanous {
274b6cd31e1SEd Tanous     return getLog(
275fffb8c1fSEd Tanous         redfish::registries::base::Index::resourceAtUriUnauthorized,
2761668ce6dSEd Tanous         std::to_array({std::string_view{arg1.data(), arg1.size()}, arg2}));
277b5c07418SJames Feist }
278b5c07418SJames Feist 
279ace85d60SEd Tanous void resourceAtUriUnauthorized(crow::Response& res,
280ace85d60SEd Tanous                                const boost::urls::url_view& arg1,
2811668ce6dSEd Tanous                                std::string_view arg2)
282b5c07418SJames Feist {
283b5c07418SJames Feist     res.result(boost::beast::http::status::unauthorized);
284b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
285f4c4dcf4SKowalski, Kamil }
286f4c4dcf4SKowalski, Kamil 
287f4c4dcf4SKowalski, Kamil /**
288f4c4dcf4SKowalski, Kamil  * @internal
289f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterUnknown message into JSON
290f4c4dcf4SKowalski, Kamil  *
291f4c4dcf4SKowalski, Kamil  * See header file for more information
292f4c4dcf4SKowalski, Kamil  * @endinternal
293f4c4dcf4SKowalski, Kamil  */
2941668ce6dSEd Tanous nlohmann::json actionParameterUnknown(std::string_view arg1,
2951668ce6dSEd Tanous                                       std::string_view arg2)
296b5c07418SJames Feist {
297fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterUnknown,
2981668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
299b5c07418SJames Feist }
300b5c07418SJames Feist 
3011668ce6dSEd Tanous void actionParameterUnknown(crow::Response& res, std::string_view arg1,
3021668ce6dSEd Tanous                             std::string_view arg2)
3031abe55efSEd Tanous {
304f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
305b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
306f4c4dcf4SKowalski, Kamil }
307f4c4dcf4SKowalski, Kamil 
308f4c4dcf4SKowalski, Kamil /**
309f4c4dcf4SKowalski, Kamil  * @internal
310f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceCannotBeDeleted message into JSON
311f4c4dcf4SKowalski, Kamil  *
312f4c4dcf4SKowalski, Kamil  * See header file for more information
313f4c4dcf4SKowalski, Kamil  * @endinternal
314f4c4dcf4SKowalski, Kamil  */
315b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void)
3161abe55efSEd Tanous {
317fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCannotBeDeleted,
318fffb8c1fSEd Tanous                   {});
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  */
3341668ce6dSEd Tanous nlohmann::json propertyDuplicate(std::string_view arg1)
3351abe55efSEd Tanous {
336fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyDuplicate,
3371668ce6dSEd Tanous                   std::to_array({arg1}));
338b5c07418SJames Feist }
339b5c07418SJames Feist 
3401668ce6dSEd Tanous void propertyDuplicate(crow::Response& res, std::string_view arg1)
341b5c07418SJames Feist {
342b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
343b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
344f4c4dcf4SKowalski, Kamil }
345f4c4dcf4SKowalski, Kamil 
346f4c4dcf4SKowalski, Kamil /**
347f4c4dcf4SKowalski, Kamil  * @internal
348f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
349f4c4dcf4SKowalski, Kamil  *
350f4c4dcf4SKowalski, Kamil  * See header file for more information
351f4c4dcf4SKowalski, Kamil  * @endinternal
352f4c4dcf4SKowalski, Kamil  */
3531668ce6dSEd Tanous nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1)
3541abe55efSEd Tanous {
355b6cd31e1SEd Tanous     return getLog(
356fffb8c1fSEd Tanous         redfish::registries::base::Index::serviceTemporarilyUnavailable,
3571668ce6dSEd Tanous         std::to_array({arg1}));
358b5c07418SJames Feist }
359b5c07418SJames Feist 
3601668ce6dSEd Tanous void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1)
361b5c07418SJames Feist {
362b5c07418SJames Feist     res.addHeader("Retry-After", arg1);
363b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
364b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
365f4c4dcf4SKowalski, Kamil }
366f4c4dcf4SKowalski, Kamil 
367f4c4dcf4SKowalski, Kamil /**
368f4c4dcf4SKowalski, Kamil  * @internal
369f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
370f4c4dcf4SKowalski, Kamil  *
371f4c4dcf4SKowalski, Kamil  * See header file for more information
372f4c4dcf4SKowalski, Kamil  * @endinternal
373f4c4dcf4SKowalski, Kamil  */
3741668ce6dSEd Tanous nlohmann::json resourceAlreadyExists(std::string_view arg1,
3751668ce6dSEd Tanous                                      std::string_view arg2,
3761668ce6dSEd Tanous                                      std::string_view arg3)
3771abe55efSEd Tanous {
378fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceAlreadyExists,
3791668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
380b5c07418SJames Feist }
381b5c07418SJames Feist 
3821668ce6dSEd Tanous void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
3831668ce6dSEd Tanous                            std::string_view arg2, std::string_view arg3)
384b5c07418SJames Feist {
385b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
386b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
387a08b46ccSJason M. Bills                      arg2);
388f4c4dcf4SKowalski, Kamil }
389f4c4dcf4SKowalski, Kamil 
390f4c4dcf4SKowalski, Kamil /**
391f4c4dcf4SKowalski, Kamil  * @internal
392f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
393f4c4dcf4SKowalski, Kamil  *
394f4c4dcf4SKowalski, Kamil  * See header file for more information
395f4c4dcf4SKowalski, Kamil  * @endinternal
396f4c4dcf4SKowalski, Kamil  */
397b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void)
3981abe55efSEd Tanous {
399fffb8c1fSEd Tanous     return getLog(
400fffb8c1fSEd Tanous         redfish::registries::base::Index::accountForSessionNoLongerExists, {});
401b5c07418SJames Feist }
402b5c07418SJames Feist 
403b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
404b5c07418SJames Feist {
405b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
406b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
407f4c4dcf4SKowalski, Kamil }
408f4c4dcf4SKowalski, Kamil 
409f4c4dcf4SKowalski, Kamil /**
410f4c4dcf4SKowalski, Kamil  * @internal
411f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
412f4c4dcf4SKowalski, Kamil  *
413f4c4dcf4SKowalski, Kamil  * See header file for more information
414f4c4dcf4SKowalski, Kamil  * @endinternal
415f4c4dcf4SKowalski, Kamil  */
4161668ce6dSEd Tanous nlohmann::json createFailedMissingReqProperties(std::string_view arg1)
4171abe55efSEd Tanous {
418fffb8c1fSEd Tanous     return getLog(
419fffb8c1fSEd Tanous         redfish::registries::base::Index::createFailedMissingReqProperties,
4201668ce6dSEd Tanous         std::to_array({arg1}));
421b5c07418SJames Feist }
422b5c07418SJames Feist 
423b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
4241668ce6dSEd Tanous                                       std::string_view arg1)
425b5c07418SJames Feist {
426b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
427b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
428a08b46ccSJason M. Bills                      arg1);
429f12894f8SJason M. Bills }
430f12894f8SJason M. Bills 
431f12894f8SJason M. Bills /**
432f12894f8SJason M. Bills  * @internal
433f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
434f12894f8SJason M. Bills  * property
435f12894f8SJason M. Bills  *
436f12894f8SJason M. Bills  * See header file for more information
437f12894f8SJason M. Bills  * @endinternal
438f12894f8SJason M. Bills  */
4391668ce6dSEd Tanous nlohmann::json propertyValueFormatError(std::string_view arg1,
4401668ce6dSEd Tanous                                         std::string_view arg2)
441f12894f8SJason M. Bills {
442fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueFormatError,
4431668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
444b5c07418SJames Feist }
445b5c07418SJames Feist 
4461668ce6dSEd Tanous void propertyValueFormatError(crow::Response& res, std::string_view arg1,
4471668ce6dSEd Tanous                               std::string_view arg2)
448b5c07418SJames Feist {
449b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
450b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
451f12894f8SJason M. Bills }
452f12894f8SJason M. Bills 
453f12894f8SJason M. Bills /**
454f12894f8SJason M. Bills  * @internal
455f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
456f12894f8SJason M. Bills  * property
457f12894f8SJason M. Bills  *
458f12894f8SJason M. Bills  * See header file for more information
459f12894f8SJason M. Bills  * @endinternal
460f12894f8SJason M. Bills  */
4611668ce6dSEd Tanous nlohmann::json propertyValueNotInList(std::string_view arg1,
4621668ce6dSEd Tanous                                       std::string_view arg2)
463f12894f8SJason M. Bills {
464fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueNotInList,
4651668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
466b5c07418SJames Feist }
467b5c07418SJames Feist 
4681668ce6dSEd Tanous void propertyValueNotInList(crow::Response& res, std::string_view arg1,
4691668ce6dSEd Tanous                             std::string_view arg2)
470b5c07418SJames Feist {
471b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
472b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
473f4c4dcf4SKowalski, Kamil }
474f4c4dcf4SKowalski, Kamil 
475f4c4dcf4SKowalski, Kamil /**
476f4c4dcf4SKowalski, Kamil  * @internal
477*227a2b0aSJiaqing Zhao  * @brief Formats PropertyValueOutOfRange message into JSON
478*227a2b0aSJiaqing Zhao  *
479*227a2b0aSJiaqing Zhao  * See header file for more information
480*227a2b0aSJiaqing Zhao  * @endinternal
481*227a2b0aSJiaqing Zhao  */
482*227a2b0aSJiaqing Zhao nlohmann::json propertyValueOutOfRange(std::string_view arg1,
483*227a2b0aSJiaqing Zhao                                        std::string_view arg2)
484*227a2b0aSJiaqing Zhao {
485*227a2b0aSJiaqing Zhao     return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
486*227a2b0aSJiaqing Zhao                   std::to_array({arg1, arg2}));
487*227a2b0aSJiaqing Zhao }
488*227a2b0aSJiaqing Zhao 
489*227a2b0aSJiaqing Zhao void propertyValueOutOfRange(crow::Response& res, std::string_view arg1,
490*227a2b0aSJiaqing Zhao                              std::string_view arg2)
491*227a2b0aSJiaqing Zhao {
492*227a2b0aSJiaqing Zhao     res.result(boost::beast::http::status::bad_request);
493*227a2b0aSJiaqing Zhao     addMessageToErrorJson(res.jsonValue, propertyValueOutOfRange(arg1, arg2));
494*227a2b0aSJiaqing Zhao }
495*227a2b0aSJiaqing Zhao 
496*227a2b0aSJiaqing Zhao /**
497*227a2b0aSJiaqing Zhao  * @internal
498f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
499f4c4dcf4SKowalski, Kamil  *
500f4c4dcf4SKowalski, Kamil  * See header file for more information
501f4c4dcf4SKowalski, Kamil  * @endinternal
502f4c4dcf4SKowalski, Kamil  */
503ace85d60SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1)
5041abe55efSEd Tanous {
5051668ce6dSEd Tanous     std::string_view arg1str{arg1.data(), arg1.size()};
506b6cd31e1SEd Tanous     return getLog(
507fffb8c1fSEd Tanous         redfish::registries::base::Index::resourceAtUriInUnknownFormat,
5081668ce6dSEd Tanous         std::to_array({arg1str}));
509b5c07418SJames Feist }
510b5c07418SJames Feist 
511ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res,
512ace85d60SEd Tanous                                   const boost::urls::url_view& arg1)
513b5c07418SJames Feist {
514b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
515b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
516f4c4dcf4SKowalski, Kamil }
517f4c4dcf4SKowalski, Kamil 
518f4c4dcf4SKowalski, Kamil /**
519f4c4dcf4SKowalski, Kamil  * @internal
52081856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
52181856681SAsmitha Karunanithi  *
52281856681SAsmitha Karunanithi  * See header file for more information
52381856681SAsmitha Karunanithi  * @endinternal
52481856681SAsmitha Karunanithi  */
5251668ce6dSEd Tanous nlohmann::json serviceDisabled(std::string_view arg1)
52681856681SAsmitha Karunanithi {
527fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceDisabled,
5281668ce6dSEd Tanous                   std::to_array({arg1}));
52981856681SAsmitha Karunanithi }
53081856681SAsmitha Karunanithi 
5311668ce6dSEd Tanous void serviceDisabled(crow::Response& res, std::string_view arg1)
53281856681SAsmitha Karunanithi {
53381856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
53481856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
53581856681SAsmitha Karunanithi }
53681856681SAsmitha Karunanithi 
53781856681SAsmitha Karunanithi /**
53881856681SAsmitha Karunanithi  * @internal
539f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
540f4c4dcf4SKowalski, Kamil  *
541f4c4dcf4SKowalski, Kamil  * See header file for more information
542f4c4dcf4SKowalski, Kamil  * @endinternal
543f4c4dcf4SKowalski, Kamil  */
544b5c07418SJames Feist nlohmann::json serviceInUnknownState(void)
5451abe55efSEd Tanous {
546fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceInUnknownState, {});
547b5c07418SJames Feist }
548b5c07418SJames Feist 
549b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
550b5c07418SJames Feist {
551b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
552b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
553f4c4dcf4SKowalski, Kamil }
554f4c4dcf4SKowalski, Kamil 
555f4c4dcf4SKowalski, Kamil /**
556f4c4dcf4SKowalski, Kamil  * @internal
557f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
558f4c4dcf4SKowalski, Kamil  *
559f4c4dcf4SKowalski, Kamil  * See header file for more information
560f4c4dcf4SKowalski, Kamil  * @endinternal
561f4c4dcf4SKowalski, Kamil  */
562b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void)
5631abe55efSEd Tanous {
564fffb8c1fSEd Tanous     return getLog(
565fffb8c1fSEd Tanous         redfish::registries::base::Index::eventSubscriptionLimitExceeded, {});
566b5c07418SJames Feist }
567b5c07418SJames Feist 
568b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
569b5c07418SJames Feist {
570789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
571b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
572f4c4dcf4SKowalski, Kamil }
573f4c4dcf4SKowalski, Kamil 
574f4c4dcf4SKowalski, Kamil /**
575f4c4dcf4SKowalski, Kamil  * @internal
576f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
577f4c4dcf4SKowalski, Kamil  *
578f4c4dcf4SKowalski, Kamil  * See header file for more information
579f4c4dcf4SKowalski, Kamil  * @endinternal
580f4c4dcf4SKowalski, Kamil  */
5811668ce6dSEd Tanous nlohmann::json actionParameterMissing(std::string_view arg1,
5821668ce6dSEd Tanous                                       std::string_view arg2)
5831abe55efSEd Tanous {
584fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterMissing,
5851668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
586b5c07418SJames Feist }
587b5c07418SJames Feist 
5881668ce6dSEd Tanous void actionParameterMissing(crow::Response& res, std::string_view arg1,
5891668ce6dSEd Tanous                             std::string_view arg2)
590b5c07418SJames Feist {
591b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
592b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
593f4c4dcf4SKowalski, Kamil }
594f4c4dcf4SKowalski, Kamil 
595f4c4dcf4SKowalski, Kamil /**
596f4c4dcf4SKowalski, Kamil  * @internal
597f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
598f4c4dcf4SKowalski, Kamil  *
599f4c4dcf4SKowalski, Kamil  * See header file for more information
600f4c4dcf4SKowalski, Kamil  * @endinternal
601f4c4dcf4SKowalski, Kamil  */
6021668ce6dSEd Tanous nlohmann::json stringValueTooLong(std::string_view arg1, int arg2)
6031abe55efSEd Tanous {
604b6cd31e1SEd Tanous     std::string arg2String = std::to_string(arg2);
605fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::stringValueTooLong,
6061668ce6dSEd Tanous                   std::to_array({arg1, std::string_view(arg2String)}));
607b5c07418SJames Feist }
608b5c07418SJames Feist 
6091668ce6dSEd Tanous void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2)
610b5c07418SJames Feist {
611b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
612b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
613f4c4dcf4SKowalski, Kamil }
614f4c4dcf4SKowalski, Kamil 
615f4c4dcf4SKowalski, Kamil /**
616f4c4dcf4SKowalski, Kamil  * @internal
617cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
618cc9139ecSJason M. Bills  *
619cc9139ecSJason M. Bills  * See header file for more information
620cc9139ecSJason M. Bills  * @endinternal
621cc9139ecSJason M. Bills  */
622b5c07418SJames Feist nlohmann::json sessionTerminated(void)
623cc9139ecSJason M. Bills {
624fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionTerminated, {});
625b5c07418SJames Feist }
626b5c07418SJames Feist 
627b5c07418SJames Feist void sessionTerminated(crow::Response& res)
628b5c07418SJames Feist {
629b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
630b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
631cc9139ecSJason M. Bills }
632cc9139ecSJason M. Bills 
633cc9139ecSJason M. Bills /**
634cc9139ecSJason M. Bills  * @internal
635684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
636684bb4b8SJason M. Bills  *
637684bb4b8SJason M. Bills  * See header file for more information
638684bb4b8SJason M. Bills  * @endinternal
639684bb4b8SJason M. Bills  */
640684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void)
641684bb4b8SJason M. Bills {
642fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::subscriptionTerminated, {});
643684bb4b8SJason M. Bills }
644684bb4b8SJason M. Bills 
645684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
646684bb4b8SJason M. Bills {
647684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
648684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
649684bb4b8SJason M. Bills }
650684bb4b8SJason M. Bills 
651684bb4b8SJason M. Bills /**
652684bb4b8SJason M. Bills  * @internal
653cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
654cc9139ecSJason M. Bills  *
655cc9139ecSJason M. Bills  * See header file for more information
656cc9139ecSJason M. Bills  * @endinternal
657cc9139ecSJason M. Bills  */
6581668ce6dSEd Tanous nlohmann::json resourceTypeIncompatible(std::string_view arg1,
6591668ce6dSEd Tanous                                         std::string_view arg2)
660cc9139ecSJason M. Bills {
661fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceTypeIncompatible,
6621668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
663b5c07418SJames Feist }
664b5c07418SJames Feist 
6651668ce6dSEd Tanous void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
6661668ce6dSEd Tanous                               std::string_view arg2)
667b5c07418SJames Feist {
668b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
669b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
670cc9139ecSJason M. Bills }
671cc9139ecSJason M. Bills 
672cc9139ecSJason M. Bills /**
673cc9139ecSJason M. Bills  * @internal
674684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
675684bb4b8SJason M. Bills  *
676684bb4b8SJason M. Bills  * See header file for more information
677684bb4b8SJason M. Bills  * @endinternal
678684bb4b8SJason M. Bills  */
679ace85d60SEd Tanous nlohmann::json resetRequired(const boost::urls::url_view& arg1,
6801668ce6dSEd Tanous                              std::string_view arg2)
681684bb4b8SJason M. Bills {
6821668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
683fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
6841668ce6dSEd Tanous                   std::to_array({arg1str, arg2}));
685684bb4b8SJason M. Bills }
686684bb4b8SJason M. Bills 
687ace85d60SEd Tanous void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
6881668ce6dSEd Tanous                    std::string_view arg2)
689684bb4b8SJason M. Bills {
690684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
691684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
692684bb4b8SJason M. Bills }
693684bb4b8SJason M. Bills 
694684bb4b8SJason M. Bills /**
695684bb4b8SJason M. Bills  * @internal
696684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
697684bb4b8SJason M. Bills  *
698684bb4b8SJason M. Bills  * See header file for more information
699684bb4b8SJason M. Bills  * @endinternal
700684bb4b8SJason M. Bills  */
7011668ce6dSEd Tanous nlohmann::json chassisPowerStateOnRequired(std::string_view arg1)
702684bb4b8SJason M. Bills {
703fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resetRequired,
7041668ce6dSEd Tanous                   std::to_array({arg1}));
705684bb4b8SJason M. Bills }
706684bb4b8SJason M. Bills 
7071668ce6dSEd Tanous void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1)
708684bb4b8SJason M. Bills {
709684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
710684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
711684bb4b8SJason M. Bills }
712684bb4b8SJason M. Bills 
713684bb4b8SJason M. Bills /**
714684bb4b8SJason M. Bills  * @internal
715684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
716684bb4b8SJason M. Bills  *
717684bb4b8SJason M. Bills  * See header file for more information
718684bb4b8SJason M. Bills  * @endinternal
719684bb4b8SJason M. Bills  */
7201668ce6dSEd Tanous nlohmann::json chassisPowerStateOffRequired(std::string_view arg1)
721684bb4b8SJason M. Bills {
722b6cd31e1SEd Tanous     return getLog(
723fffb8c1fSEd Tanous         redfish::registries::base::Index::chassisPowerStateOffRequired,
7241668ce6dSEd Tanous         std::to_array({arg1}));
725684bb4b8SJason M. Bills }
726684bb4b8SJason M. Bills 
7271668ce6dSEd Tanous void chassisPowerStateOffRequired(crow::Response& res, std::string_view 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  */
7401668ce6dSEd Tanous nlohmann::json propertyValueConflict(std::string_view arg1,
7411668ce6dSEd Tanous                                      std::string_view arg2)
742684bb4b8SJason M. Bills {
743fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueConflict,
7441668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
745684bb4b8SJason M. Bills }
746684bb4b8SJason M. Bills 
7471668ce6dSEd Tanous void propertyValueConflict(crow::Response& res, std::string_view arg1,
7481668ce6dSEd Tanous                            std::string_view arg2)
749684bb4b8SJason M. Bills {
750684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
751684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
752684bb4b8SJason M. Bills }
753684bb4b8SJason M. Bills 
754684bb4b8SJason M. Bills /**
755684bb4b8SJason M. Bills  * @internal
7562a6af81cSRamesh Iyyar  * @brief Formats PropertyValueResourceConflict message into JSON
7572a6af81cSRamesh Iyyar  *
7582a6af81cSRamesh Iyyar  * See header file for more information
7592a6af81cSRamesh Iyyar  * @endinternal
7602a6af81cSRamesh Iyyar  */
7612a6af81cSRamesh Iyyar nlohmann::json propertyValueResourceConflict(std::string_view arg1,
7622a6af81cSRamesh Iyyar                                              std::string_view arg2,
7632a6af81cSRamesh Iyyar                                              const boost::urls::url_view& arg3)
7642a6af81cSRamesh Iyyar {
7652a6af81cSRamesh Iyyar     return getLog(
7662a6af81cSRamesh Iyyar         redfish::registries::base::Index::propertyValueResourceConflict,
7672a6af81cSRamesh Iyyar         std::to_array(
7682a6af81cSRamesh Iyyar             {arg1, arg2, std::string_view{arg3.data(), arg3.size()}}));
7692a6af81cSRamesh Iyyar }
7702a6af81cSRamesh Iyyar 
7712a6af81cSRamesh Iyyar void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
7722a6af81cSRamesh Iyyar                                    std::string_view arg2,
7732a6af81cSRamesh Iyyar                                    const boost::urls::url_view& arg3)
7742a6af81cSRamesh Iyyar {
7752a6af81cSRamesh Iyyar     res.result(boost::beast::http::status::conflict);
7762a6af81cSRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
7772a6af81cSRamesh Iyyar                           propertyValueResourceConflict(arg1, arg2, arg3));
7782a6af81cSRamesh Iyyar }
7792a6af81cSRamesh Iyyar 
7802a6af81cSRamesh Iyyar /**
7812a6af81cSRamesh Iyyar  * @internal
78224861a28SRamesh Iyyar  * @brief Formats PropertyValueExternalConflict message into JSON
78324861a28SRamesh Iyyar  *
78424861a28SRamesh Iyyar  * See header file for more information
78524861a28SRamesh Iyyar  * @endinternal
78624861a28SRamesh Iyyar  */
78724861a28SRamesh Iyyar nlohmann::json propertyValueExternalConflict(std::string_view arg1,
78824861a28SRamesh Iyyar                                              std::string_view arg2)
78924861a28SRamesh Iyyar {
79024861a28SRamesh Iyyar     return getLog(
79124861a28SRamesh Iyyar         redfish::registries::base::Index::propertyValueExternalConflict,
79224861a28SRamesh Iyyar         std::to_array({arg1, arg2}));
79324861a28SRamesh Iyyar }
79424861a28SRamesh Iyyar 
79524861a28SRamesh Iyyar void propertyValueExternalConflict(crow::Response& res, std::string_view arg1,
79624861a28SRamesh Iyyar                                    std::string_view arg2)
79724861a28SRamesh Iyyar {
79824861a28SRamesh Iyyar     res.result(boost::beast::http::status::conflict);
79924861a28SRamesh Iyyar     addMessageToErrorJson(res.jsonValue,
80024861a28SRamesh Iyyar                           propertyValueExternalConflict(arg1, arg2));
80124861a28SRamesh Iyyar }
80224861a28SRamesh Iyyar 
80324861a28SRamesh Iyyar /**
80424861a28SRamesh Iyyar  * @internal
805684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
806684bb4b8SJason M. Bills  *
807684bb4b8SJason M. Bills  * See header file for more information
808684bb4b8SJason M. Bills  * @endinternal
809684bb4b8SJason M. Bills  */
8101668ce6dSEd Tanous nlohmann::json propertyValueIncorrect(std::string_view arg1,
8111668ce6dSEd Tanous                                       std::string_view arg2)
812684bb4b8SJason M. Bills {
813fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueIncorrect,
8141668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
815684bb4b8SJason M. Bills }
816684bb4b8SJason M. Bills 
8171668ce6dSEd Tanous void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
8181668ce6dSEd Tanous                             std::string_view arg2)
819684bb4b8SJason M. Bills {
820684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
821684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
822684bb4b8SJason M. Bills }
823684bb4b8SJason M. Bills 
824684bb4b8SJason M. Bills /**
825684bb4b8SJason M. Bills  * @internal
826684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
827684bb4b8SJason M. Bills  *
828684bb4b8SJason M. Bills  * See header file for more information
829684bb4b8SJason M. Bills  * @endinternal
830684bb4b8SJason M. Bills  */
831ace85d60SEd Tanous nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1)
832684bb4b8SJason M. Bills {
8331668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
834fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceCreationConflict,
8351668ce6dSEd Tanous                   std::to_array({arg1str}));
836684bb4b8SJason M. Bills }
837684bb4b8SJason M. Bills 
838ace85d60SEd Tanous void resourceCreationConflict(crow::Response& res,
839ace85d60SEd Tanous                               const boost::urls::url_view& arg1)
840684bb4b8SJason M. Bills {
841684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
842684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
843684bb4b8SJason M. Bills }
844684bb4b8SJason M. Bills 
845684bb4b8SJason M. Bills /**
846684bb4b8SJason M. Bills  * @internal
847684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded 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 maximumErrorsExceeded(void)
853684bb4b8SJason M. Bills {
854fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::maximumErrorsExceeded, {});
855684bb4b8SJason M. Bills }
856684bb4b8SJason M. Bills 
857684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
858684bb4b8SJason M. Bills {
859684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
860684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
861684bb4b8SJason M. Bills }
862684bb4b8SJason M. Bills 
863684bb4b8SJason M. Bills /**
864684bb4b8SJason M. Bills  * @internal
865684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
866684bb4b8SJason M. Bills  *
867684bb4b8SJason M. Bills  * See header file for more information
868684bb4b8SJason M. Bills  * @endinternal
869684bb4b8SJason M. Bills  */
870684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void)
871684bb4b8SJason M. Bills {
872fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionFailed, {});
873684bb4b8SJason M. Bills }
874684bb4b8SJason M. Bills 
875684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
876684bb4b8SJason M. Bills {
8774df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
878684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
879684bb4b8SJason M. Bills }
880684bb4b8SJason M. Bills 
881684bb4b8SJason M. Bills /**
882684bb4b8SJason M. Bills  * @internal
883684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
884684bb4b8SJason M. Bills  *
885684bb4b8SJason M. Bills  * See header file for more information
886684bb4b8SJason M. Bills  * @endinternal
887684bb4b8SJason M. Bills  */
888684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void)
889684bb4b8SJason M. Bills {
890fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::preconditionRequired, {});
891684bb4b8SJason M. Bills }
892684bb4b8SJason M. Bills 
893684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
894684bb4b8SJason M. Bills {
895684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
896684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
897684bb4b8SJason M. Bills }
898684bb4b8SJason M. Bills 
899684bb4b8SJason M. Bills /**
900684bb4b8SJason M. Bills  * @internal
901684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
902684bb4b8SJason M. Bills  *
903684bb4b8SJason M. Bills  * See header file for more information
904684bb4b8SJason M. Bills  * @endinternal
905684bb4b8SJason M. Bills  */
906684bb4b8SJason M. Bills nlohmann::json operationFailed(void)
907684bb4b8SJason M. Bills {
908fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationFailed, {});
909684bb4b8SJason M. Bills }
910684bb4b8SJason M. Bills 
911684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
912684bb4b8SJason M. Bills {
9138868776eSEd Tanous     res.result(boost::beast::http::status::bad_gateway);
914684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
915684bb4b8SJason M. Bills }
916684bb4b8SJason M. Bills 
917684bb4b8SJason M. Bills /**
918684bb4b8SJason M. Bills  * @internal
919684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
920684bb4b8SJason M. Bills  *
921684bb4b8SJason M. Bills  * See header file for more information
922684bb4b8SJason M. Bills  * @endinternal
923684bb4b8SJason M. Bills  */
924684bb4b8SJason M. Bills nlohmann::json operationTimeout(void)
925684bb4b8SJason M. Bills {
926fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::operationTimeout, {});
927684bb4b8SJason M. Bills }
928684bb4b8SJason M. Bills 
929684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
930684bb4b8SJason M. Bills {
931684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
932684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
933684bb4b8SJason M. Bills }
934684bb4b8SJason M. Bills 
935684bb4b8SJason M. Bills /**
936684bb4b8SJason M. Bills  * @internal
937f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
938f12894f8SJason M. Bills  * property
939f12894f8SJason M. Bills  *
940f12894f8SJason M. Bills  * See header file for more information
941f12894f8SJason M. Bills  * @endinternal
942f12894f8SJason M. Bills  */
9431668ce6dSEd Tanous nlohmann::json propertyValueTypeError(std::string_view arg1,
9441668ce6dSEd Tanous                                       std::string_view arg2)
945f12894f8SJason M. Bills {
946fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueTypeError,
9471668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
948b5c07418SJames Feist }
949b5c07418SJames Feist 
9501668ce6dSEd Tanous void propertyValueTypeError(crow::Response& res, std::string_view arg1,
9511668ce6dSEd Tanous                             std::string_view arg2)
952b5c07418SJames Feist {
953b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
954b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
955f4c4dcf4SKowalski, Kamil }
956f4c4dcf4SKowalski, Kamil 
957f4c4dcf4SKowalski, Kamil /**
958f4c4dcf4SKowalski, Kamil  * @internal
959b6cd31e1SEd Tanous  * @brief Formats ResourceNotFound message into JSONd
960f4c4dcf4SKowalski, Kamil  *
961f4c4dcf4SKowalski, Kamil  * See header file for more information
962f4c4dcf4SKowalski, Kamil  * @endinternal
963f4c4dcf4SKowalski, Kamil  */
9641668ce6dSEd Tanous nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2)
9651abe55efSEd Tanous {
966fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceNotFound,
9671668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
968b5c07418SJames Feist }
969b5c07418SJames Feist 
9701668ce6dSEd Tanous void resourceNotFound(crow::Response& res, std::string_view arg1,
9711668ce6dSEd Tanous                       std::string_view arg2)
972b5c07418SJames Feist {
973b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
974b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
975f4c4dcf4SKowalski, Kamil }
976f4c4dcf4SKowalski, Kamil 
977f4c4dcf4SKowalski, Kamil /**
978f4c4dcf4SKowalski, Kamil  * @internal
979f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
980f4c4dcf4SKowalski, Kamil  *
981f4c4dcf4SKowalski, Kamil  * See header file for more information
982f4c4dcf4SKowalski, Kamil  * @endinternal
983f4c4dcf4SKowalski, Kamil  */
984ace85d60SEd Tanous nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1)
9851abe55efSEd Tanous {
9861668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
987fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::couldNotEstablishConnection,
9881668ce6dSEd Tanous                   std::to_array({arg1str}));
989b5c07418SJames Feist }
990b5c07418SJames Feist 
991ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res,
992ace85d60SEd Tanous                                  const boost::urls::url_view& arg1)
993b5c07418SJames Feist {
994b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
995b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
996f4c4dcf4SKowalski, Kamil }
997f4c4dcf4SKowalski, Kamil 
998f4c4dcf4SKowalski, Kamil /**
999f4c4dcf4SKowalski, Kamil  * @internal
1000f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
1001f12894f8SJason M. Bills  * property
1002f12894f8SJason M. Bills  *
1003f12894f8SJason M. Bills  * See header file for more information
1004f12894f8SJason M. Bills  * @endinternal
1005f12894f8SJason M. Bills  */
10061668ce6dSEd Tanous nlohmann::json propertyNotWritable(std::string_view arg1)
1007f12894f8SJason M. Bills {
1008fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyNotWritable,
10091668ce6dSEd Tanous                   std::to_array({arg1}));
1010b5c07418SJames Feist }
1011b5c07418SJames Feist 
10121668ce6dSEd Tanous void propertyNotWritable(crow::Response& res, std::string_view arg1)
1013b5c07418SJames Feist {
1014b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1015b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1016f4c4dcf4SKowalski, Kamil }
1017f4c4dcf4SKowalski, Kamil 
1018f4c4dcf4SKowalski, Kamil /**
1019f4c4dcf4SKowalski, Kamil  * @internal
1020f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
1021f4c4dcf4SKowalski, Kamil  *
1022f4c4dcf4SKowalski, Kamil  * See header file for more information
1023f4c4dcf4SKowalski, Kamil  * @endinternal
1024f4c4dcf4SKowalski, Kamil  */
10251668ce6dSEd Tanous nlohmann::json queryParameterValueTypeError(std::string_view arg1,
10261668ce6dSEd Tanous                                             std::string_view arg2)
10271abe55efSEd Tanous {
1028b6cd31e1SEd Tanous     return getLog(
1029fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueTypeError,
10301668ce6dSEd Tanous         std::to_array({arg1, arg2}));
1031b5c07418SJames Feist }
1032b5c07418SJames Feist 
10331668ce6dSEd Tanous void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
10341668ce6dSEd Tanous                                   std::string_view arg2)
1035b5c07418SJames Feist {
1036b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1037b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1038b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
1039f4c4dcf4SKowalski, Kamil }
1040f4c4dcf4SKowalski, Kamil 
1041f4c4dcf4SKowalski, Kamil /**
1042f4c4dcf4SKowalski, Kamil  * @internal
1043f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
1044f4c4dcf4SKowalski, Kamil  *
1045f4c4dcf4SKowalski, Kamil  * See header file for more information
1046f4c4dcf4SKowalski, Kamil  * @endinternal
1047f4c4dcf4SKowalski, Kamil  */
1048b5c07418SJames Feist nlohmann::json serviceShuttingDown(void)
10491abe55efSEd Tanous {
1050fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::serviceShuttingDown, {});
1051b5c07418SJames Feist }
1052b5c07418SJames Feist 
1053b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
1054b5c07418SJames Feist {
1055b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1056b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1057f4c4dcf4SKowalski, Kamil }
1058f4c4dcf4SKowalski, Kamil 
1059f4c4dcf4SKowalski, Kamil /**
1060f4c4dcf4SKowalski, Kamil  * @internal
1061f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
1062f4c4dcf4SKowalski, Kamil  *
1063f4c4dcf4SKowalski, Kamil  * See header file for more information
1064f4c4dcf4SKowalski, Kamil  * @endinternal
1065f4c4dcf4SKowalski, Kamil  */
10661668ce6dSEd Tanous nlohmann::json actionParameterDuplicate(std::string_view arg1,
10671668ce6dSEd Tanous                                         std::string_view arg2)
10681abe55efSEd Tanous {
1069fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterDuplicate,
10701668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1071b5c07418SJames Feist }
1072b5c07418SJames Feist 
10731668ce6dSEd Tanous void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
10741668ce6dSEd Tanous                               std::string_view arg2)
1075b5c07418SJames Feist {
1076b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1077b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1078f4c4dcf4SKowalski, Kamil }
1079f4c4dcf4SKowalski, Kamil 
1080f4c4dcf4SKowalski, Kamil /**
1081f4c4dcf4SKowalski, Kamil  * @internal
1082f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1083f4c4dcf4SKowalski, Kamil  *
1084f4c4dcf4SKowalski, Kamil  * See header file for more information
1085f4c4dcf4SKowalski, Kamil  * @endinternal
1086f4c4dcf4SKowalski, Kamil  */
10871668ce6dSEd Tanous nlohmann::json actionParameterNotSupported(std::string_view arg1,
10881668ce6dSEd Tanous                                            std::string_view arg2)
10891abe55efSEd Tanous {
1090fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionParameterNotSupported,
10911668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1092b5c07418SJames Feist }
1093b5c07418SJames Feist 
10941668ce6dSEd Tanous void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
10951668ce6dSEd Tanous                                  std::string_view arg2)
1096b5c07418SJames Feist {
1097b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1098b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1099b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1100f4c4dcf4SKowalski, Kamil }
1101f4c4dcf4SKowalski, Kamil 
1102f4c4dcf4SKowalski, Kamil /**
1103f4c4dcf4SKowalski, Kamil  * @internal
1104f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1105f4c4dcf4SKowalski, Kamil  *
1106f4c4dcf4SKowalski, Kamil  * See header file for more information
1107f4c4dcf4SKowalski, Kamil  * @endinternal
1108f4c4dcf4SKowalski, Kamil  */
1109ace85d60SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1,
11101668ce6dSEd Tanous                                             std::string_view arg2)
11111abe55efSEd Tanous {
11121668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1113b6cd31e1SEd Tanous     return getLog(
1114fffb8c1fSEd Tanous         redfish::registries::base::Index::sourceDoesNotSupportProtocol,
11151668ce6dSEd Tanous         std::to_array({arg1str, arg2}));
1116b5c07418SJames Feist }
1117b5c07418SJames Feist 
1118ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res,
1119ace85d60SEd Tanous                                   const boost::urls::url_view& arg1,
11201668ce6dSEd Tanous                                   std::string_view arg2)
1121b5c07418SJames Feist {
1122b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1123b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1124b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1125f4c4dcf4SKowalski, Kamil }
1126f4c4dcf4SKowalski, Kamil 
1127f4c4dcf4SKowalski, Kamil /**
1128f4c4dcf4SKowalski, Kamil  * @internal
1129f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1130f4c4dcf4SKowalski, Kamil  *
1131f4c4dcf4SKowalski, Kamil  * See header file for more information
1132f4c4dcf4SKowalski, Kamil  * @endinternal
1133f4c4dcf4SKowalski, Kamil  */
1134b5c07418SJames Feist nlohmann::json accountRemoved(void)
11351abe55efSEd Tanous {
1136fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountRemoved, {});
1137b5c07418SJames Feist }
1138b5c07418SJames Feist 
1139b5c07418SJames Feist void accountRemoved(crow::Response& res)
1140b5c07418SJames Feist {
1141b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1142b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1143f4c4dcf4SKowalski, Kamil }
1144f4c4dcf4SKowalski, Kamil 
1145f4c4dcf4SKowalski, Kamil /**
1146f4c4dcf4SKowalski, Kamil  * @internal
1147f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1148f4c4dcf4SKowalski, Kamil  *
1149f4c4dcf4SKowalski, Kamil  * See header file for more information
1150f4c4dcf4SKowalski, Kamil  * @endinternal
1151f4c4dcf4SKowalski, Kamil  */
1152ace85d60SEd Tanous nlohmann::json accessDenied(const boost::urls::url_view& arg1)
11531abe55efSEd Tanous {
11541668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1155fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accessDenied,
11561668ce6dSEd Tanous                   std::to_array({arg1str}));
1157b5c07418SJames Feist }
1158b5c07418SJames Feist 
1159ace85d60SEd Tanous void accessDenied(crow::Response& res, const boost::urls::url_view& arg1)
1160b5c07418SJames Feist {
1161b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1162b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1163f4c4dcf4SKowalski, Kamil }
1164f4c4dcf4SKowalski, Kamil 
1165f4c4dcf4SKowalski, Kamil /**
1166f4c4dcf4SKowalski, Kamil  * @internal
1167f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1168f4c4dcf4SKowalski, Kamil  *
1169f4c4dcf4SKowalski, Kamil  * See header file for more information
1170f4c4dcf4SKowalski, Kamil  * @endinternal
1171f4c4dcf4SKowalski, Kamil  */
1172b5c07418SJames Feist nlohmann::json queryNotSupported(void)
11731abe55efSEd Tanous {
1174fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupported, {});
1175b5c07418SJames Feist }
1176b5c07418SJames Feist 
1177b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1178b5c07418SJames Feist {
1179b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1180b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1181f4c4dcf4SKowalski, Kamil }
1182f4c4dcf4SKowalski, Kamil 
1183f4c4dcf4SKowalski, Kamil /**
1184f4c4dcf4SKowalski, Kamil  * @internal
1185f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1186f4c4dcf4SKowalski, Kamil  *
1187f4c4dcf4SKowalski, Kamil  * See header file for more information
1188f4c4dcf4SKowalski, Kamil  * @endinternal
1189f4c4dcf4SKowalski, Kamil  */
1190b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void)
11911abe55efSEd Tanous {
1192b6cd31e1SEd Tanous     return getLog(
1193fffb8c1fSEd Tanous         redfish::registries::base::Index::createLimitReachedForResource, {});
1194b5c07418SJames Feist }
1195b5c07418SJames Feist 
1196b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1197b5c07418SJames Feist {
1198b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1199b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1200f4c4dcf4SKowalski, Kamil }
1201f4c4dcf4SKowalski, Kamil 
1202f4c4dcf4SKowalski, Kamil /**
1203f4c4dcf4SKowalski, Kamil  * @internal
1204f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1205f4c4dcf4SKowalski, Kamil  *
1206f4c4dcf4SKowalski, Kamil  * See header file for more information
1207f4c4dcf4SKowalski, Kamil  * @endinternal
1208f4c4dcf4SKowalski, Kamil  */
1209b5c07418SJames Feist nlohmann::json generalError(void)
12101abe55efSEd Tanous {
1211fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::generalError, {});
1212b5c07418SJames Feist }
1213b5c07418SJames Feist 
1214b5c07418SJames Feist void generalError(crow::Response& res)
1215b5c07418SJames Feist {
1216b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1217b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1218f4c4dcf4SKowalski, Kamil }
1219f4c4dcf4SKowalski, Kamil 
1220f4c4dcf4SKowalski, Kamil /**
1221f4c4dcf4SKowalski, Kamil  * @internal
1222f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1223f4c4dcf4SKowalski, Kamil  *
1224f4c4dcf4SKowalski, Kamil  * See header file for more information
1225f4c4dcf4SKowalski, Kamil  * @endinternal
1226f4c4dcf4SKowalski, Kamil  */
1227b5c07418SJames Feist nlohmann::json success(void)
12281abe55efSEd Tanous {
1229fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::success, {});
1230b5c07418SJames Feist }
1231b5c07418SJames Feist 
1232b5c07418SJames Feist void success(crow::Response& res)
1233b5c07418SJames Feist {
1234b5c07418SJames Feist     // don't set res.result here because success is the default and any
1235b5c07418SJames Feist     // error should overwrite the default
1236b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1237f12894f8SJason M. Bills }
1238f12894f8SJason M. Bills 
1239f12894f8SJason M. Bills /**
1240f12894f8SJason M. Bills  * @internal
1241f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1242f4c4dcf4SKowalski, Kamil  *
1243f4c4dcf4SKowalski, Kamil  * See header file for more information
1244f4c4dcf4SKowalski, Kamil  * @endinternal
1245f4c4dcf4SKowalski, Kamil  */
1246b5c07418SJames Feist nlohmann::json created(void)
12471abe55efSEd Tanous {
1248fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::created, {});
1249b5c07418SJames Feist }
1250b5c07418SJames Feist 
1251b5c07418SJames Feist void created(crow::Response& res)
1252b5c07418SJames Feist {
1253b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1254b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1255f4c4dcf4SKowalski, Kamil }
1256f4c4dcf4SKowalski, Kamil 
1257f4c4dcf4SKowalski, Kamil /**
1258f4c4dcf4SKowalski, Kamil  * @internal
1259cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1260cc9139ecSJason M. Bills  *
1261cc9139ecSJason M. Bills  * See header file for more information
1262cc9139ecSJason M. Bills  * @endinternal
1263cc9139ecSJason M. Bills  */
1264b5c07418SJames Feist nlohmann::json noOperation(void)
1265cc9139ecSJason M. Bills {
1266fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noOperation, {});
1267b5c07418SJames Feist }
1268b5c07418SJames Feist 
1269b5c07418SJames Feist void noOperation(crow::Response& res)
1270b5c07418SJames Feist {
1271b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1272b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1273cc9139ecSJason M. Bills }
1274cc9139ecSJason M. Bills 
1275cc9139ecSJason M. Bills /**
1276cc9139ecSJason M. Bills  * @internal
1277b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1278b5c07418SJames Feist  * property
1279f12894f8SJason M. Bills  *
1280f12894f8SJason M. Bills  * See header file for more information
1281f12894f8SJason M. Bills  * @endinternal
1282f12894f8SJason M. Bills  */
12831668ce6dSEd Tanous nlohmann::json propertyUnknown(std::string_view arg1)
1284b5c07418SJames Feist {
1285fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyUnknown,
12861668ce6dSEd Tanous                   std::to_array({arg1}));
1287b5c07418SJames Feist }
1288b5c07418SJames Feist 
12891668ce6dSEd Tanous void propertyUnknown(crow::Response& res, std::string_view arg1)
1290f12894f8SJason M. Bills {
1291f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1292b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1);
1293f4c4dcf4SKowalski, Kamil }
1294f4c4dcf4SKowalski, Kamil 
1295f4c4dcf4SKowalski, Kamil /**
1296f4c4dcf4SKowalski, Kamil  * @internal
1297f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1298f4c4dcf4SKowalski, Kamil  *
1299f4c4dcf4SKowalski, Kamil  * See header file for more information
1300f4c4dcf4SKowalski, Kamil  * @endinternal
1301f4c4dcf4SKowalski, Kamil  */
1302b5c07418SJames Feist nlohmann::json noValidSession(void)
13031abe55efSEd Tanous {
1304fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::noValidSession, {});
1305b5c07418SJames Feist }
1306b5c07418SJames Feist 
1307b5c07418SJames Feist void noValidSession(crow::Response& res)
1308b5c07418SJames Feist {
1309b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1310b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1311f4c4dcf4SKowalski, Kamil }
1312f4c4dcf4SKowalski, Kamil 
1313f4c4dcf4SKowalski, Kamil /**
1314f4c4dcf4SKowalski, Kamil  * @internal
1315f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1316f4c4dcf4SKowalski, Kamil  *
1317f4c4dcf4SKowalski, Kamil  * See header file for more information
1318f4c4dcf4SKowalski, Kamil  * @endinternal
1319f4c4dcf4SKowalski, Kamil  */
1320ace85d60SEd Tanous nlohmann::json invalidObject(const boost::urls::url_view& arg1)
13211abe55efSEd Tanous {
13221668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1323fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidObject,
13241668ce6dSEd Tanous                   std::to_array({arg1str}));
1325b5c07418SJames Feist }
1326b5c07418SJames Feist 
1327ace85d60SEd Tanous void invalidObject(crow::Response& res, const boost::urls::url_view& arg1)
1328b5c07418SJames Feist {
1329b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1330b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1331f4c4dcf4SKowalski, Kamil }
1332f4c4dcf4SKowalski, Kamil 
1333f4c4dcf4SKowalski, Kamil /**
1334f4c4dcf4SKowalski, Kamil  * @internal
1335f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1336f4c4dcf4SKowalski, Kamil  *
1337f4c4dcf4SKowalski, Kamil  * See header file for more information
1338f4c4dcf4SKowalski, Kamil  * @endinternal
1339f4c4dcf4SKowalski, Kamil  */
1340b5c07418SJames Feist nlohmann::json resourceInStandby(void)
13411abe55efSEd Tanous {
1342fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceInStandby, {});
1343b5c07418SJames Feist }
1344b5c07418SJames Feist 
1345b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1346b5c07418SJames Feist {
1347b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1348b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1349f4c4dcf4SKowalski, Kamil }
1350f4c4dcf4SKowalski, Kamil 
1351f4c4dcf4SKowalski, Kamil /**
1352f4c4dcf4SKowalski, Kamil  * @internal
1353f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1354f4c4dcf4SKowalski, Kamil  *
1355f4c4dcf4SKowalski, Kamil  * See header file for more information
1356f4c4dcf4SKowalski, Kamil  * @endinternal
1357f4c4dcf4SKowalski, Kamil  */
13581668ce6dSEd Tanous nlohmann::json actionParameterValueTypeError(std::string_view arg1,
13591668ce6dSEd Tanous                                              std::string_view arg2,
13601668ce6dSEd Tanous                                              std::string_view arg3)
13611abe55efSEd Tanous {
1362b6cd31e1SEd Tanous     return getLog(
1363fffb8c1fSEd Tanous         redfish::registries::base::Index::actionParameterValueTypeError,
13641668ce6dSEd Tanous         std::to_array({arg1, arg2, arg3}));
1365b5c07418SJames Feist }
1366b5c07418SJames Feist 
13671668ce6dSEd Tanous void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
13681668ce6dSEd Tanous                                    std::string_view arg2, std::string_view arg3)
1369b5c07418SJames Feist {
1370b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1371b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1372b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1373f4c4dcf4SKowalski, Kamil }
1374f4c4dcf4SKowalski, Kamil 
1375f4c4dcf4SKowalski, Kamil /**
1376f4c4dcf4SKowalski, Kamil  * @internal
1377f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1378f4c4dcf4SKowalski, Kamil  *
1379f4c4dcf4SKowalski, Kamil  * See header file for more information
1380f4c4dcf4SKowalski, Kamil  * @endinternal
1381f4c4dcf4SKowalski, Kamil  */
1382b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void)
13831abe55efSEd Tanous {
1384fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::sessionLimitExceeded, {});
1385b5c07418SJames Feist }
1386b5c07418SJames Feist 
1387b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1388b5c07418SJames Feist {
1389b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1390b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1391f4c4dcf4SKowalski, Kamil }
1392f4c4dcf4SKowalski, Kamil 
1393f4c4dcf4SKowalski, Kamil /**
1394f4c4dcf4SKowalski, Kamil  * @internal
1395f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1396f4c4dcf4SKowalski, Kamil  *
1397f4c4dcf4SKowalski, Kamil  * See header file for more information
1398f4c4dcf4SKowalski, Kamil  * @endinternal
1399f4c4dcf4SKowalski, Kamil  */
14001668ce6dSEd Tanous nlohmann::json actionNotSupported(std::string_view arg1)
14011abe55efSEd Tanous {
1402fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::actionNotSupported,
14031668ce6dSEd Tanous                   std::to_array({arg1}));
1404b5c07418SJames Feist }
1405b5c07418SJames Feist 
14061668ce6dSEd Tanous void actionNotSupported(crow::Response& res, std::string_view arg1)
1407b5c07418SJames Feist {
1408b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1409b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1410f4c4dcf4SKowalski, Kamil }
1411f4c4dcf4SKowalski, Kamil 
1412f4c4dcf4SKowalski, Kamil /**
1413f4c4dcf4SKowalski, Kamil  * @internal
1414f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1415f4c4dcf4SKowalski, Kamil  *
1416f4c4dcf4SKowalski, Kamil  * See header file for more information
1417f4c4dcf4SKowalski, Kamil  * @endinternal
1418f4c4dcf4SKowalski, Kamil  */
14195187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
14201abe55efSEd Tanous {
1421b6cd31e1SEd Tanous     std::string arg1Str = std::to_string(arg1);
1422fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::invalidIndex,
14231668ce6dSEd Tanous                   std::to_array<std::string_view>({arg1Str}));
1424b5c07418SJames Feist }
1425b5c07418SJames Feist 
14265187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1427b5c07418SJames Feist {
1428b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1429b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1430f4c4dcf4SKowalski, Kamil }
1431f4c4dcf4SKowalski, Kamil 
1432f4c4dcf4SKowalski, Kamil /**
1433f4c4dcf4SKowalski, Kamil  * @internal
1434f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1435f4c4dcf4SKowalski, Kamil  *
1436f4c4dcf4SKowalski, Kamil  * See header file for more information
1437f4c4dcf4SKowalski, Kamil  * @endinternal
1438f4c4dcf4SKowalski, Kamil  */
1439b5c07418SJames Feist nlohmann::json emptyJSON(void)
14401abe55efSEd Tanous {
1441fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::emptyJSON, {});
1442b5c07418SJames Feist }
1443b5c07418SJames Feist 
1444b5c07418SJames Feist void emptyJSON(crow::Response& res)
1445b5c07418SJames Feist {
1446b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1447b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1448f4c4dcf4SKowalski, Kamil }
1449f4c4dcf4SKowalski, Kamil 
1450f4c4dcf4SKowalski, Kamil /**
1451f4c4dcf4SKowalski, Kamil  * @internal
1452f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1453f4c4dcf4SKowalski, Kamil  *
1454f4c4dcf4SKowalski, Kamil  * See header file for more information
1455f4c4dcf4SKowalski, Kamil  * @endinternal
1456f4c4dcf4SKowalski, Kamil  */
1457b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void)
14581abe55efSEd Tanous {
1459fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryNotSupportedOnResource,
1460b6cd31e1SEd Tanous                   {});
1461b5c07418SJames Feist }
1462b5c07418SJames Feist 
1463b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1464b5c07418SJames Feist {
14656a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1466b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1467f4c4dcf4SKowalski, Kamil }
1468f4c4dcf4SKowalski, Kamil 
1469f4c4dcf4SKowalski, Kamil /**
1470f4c4dcf4SKowalski, Kamil  * @internal
1471684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1472684bb4b8SJason M. Bills  *
1473684bb4b8SJason M. Bills  * See header file for more information
1474684bb4b8SJason M. Bills  * @endinternal
1475684bb4b8SJason M. Bills  */
1476684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void)
1477684bb4b8SJason M. Bills {
1478b6cd31e1SEd Tanous     return getLog(
1479fffb8c1fSEd Tanous         redfish::registries::base::Index::queryNotSupportedOnOperation, {});
1480684bb4b8SJason M. Bills }
1481684bb4b8SJason M. Bills 
1482684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1483684bb4b8SJason M. Bills {
14846a409c12SEd Tanous     res.result(boost::beast::http::status::bad_request);
1485684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1486684bb4b8SJason M. Bills }
1487684bb4b8SJason M. Bills 
1488684bb4b8SJason M. Bills /**
1489684bb4b8SJason M. Bills  * @internal
1490684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1491684bb4b8SJason M. Bills  *
1492684bb4b8SJason M. Bills  * See header file for more information
1493684bb4b8SJason M. Bills  * @endinternal
1494684bb4b8SJason M. Bills  */
1495684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void)
1496684bb4b8SJason M. Bills {
1497fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryCombinationInvalid,
1498fffb8c1fSEd Tanous                   {});
1499684bb4b8SJason M. Bills }
1500684bb4b8SJason M. Bills 
1501684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1502684bb4b8SJason M. Bills {
1503684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1504684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1505684bb4b8SJason M. Bills }
1506684bb4b8SJason M. Bills 
1507684bb4b8SJason M. Bills /**
1508684bb4b8SJason M. Bills  * @internal
1509f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1510f4c4dcf4SKowalski, Kamil  *
1511f4c4dcf4SKowalski, Kamil  * See header file for more information
1512f4c4dcf4SKowalski, Kamil  * @endinternal
1513f4c4dcf4SKowalski, Kamil  */
1514b5c07418SJames Feist nlohmann::json insufficientPrivilege(void)
15151abe55efSEd Tanous {
1516fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::insufficientPrivilege, {});
1517b5c07418SJames Feist }
1518b5c07418SJames Feist 
1519b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1520b5c07418SJames Feist {
1521b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1522b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1523f4c4dcf4SKowalski, Kamil }
1524f4c4dcf4SKowalski, Kamil 
1525f4c4dcf4SKowalski, Kamil /**
1526f4c4dcf4SKowalski, Kamil  * @internal
1527f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1528f4c4dcf4SKowalski, Kamil  *
1529f4c4dcf4SKowalski, Kamil  * See header file for more information
1530f4c4dcf4SKowalski, Kamil  * @endinternal
1531f4c4dcf4SKowalski, Kamil  */
15321668ce6dSEd Tanous nlohmann::json propertyValueModified(std::string_view arg1,
15331668ce6dSEd Tanous                                      std::string_view arg2)
1534b5c07418SJames Feist {
1535fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyValueModified,
15361668ce6dSEd Tanous                   std::to_array({arg1, arg2}));
1537b5c07418SJames Feist }
1538b5c07418SJames Feist 
15391668ce6dSEd Tanous void propertyValueModified(crow::Response& res, std::string_view arg1,
15401668ce6dSEd Tanous                            std::string_view arg2)
15411abe55efSEd Tanous {
1542f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1543b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1544f4c4dcf4SKowalski, Kamil }
1545f4c4dcf4SKowalski, Kamil 
1546f4c4dcf4SKowalski, Kamil /**
1547f4c4dcf4SKowalski, Kamil  * @internal
1548f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1549f4c4dcf4SKowalski, Kamil  *
1550f4c4dcf4SKowalski, Kamil  * See header file for more information
1551f4c4dcf4SKowalski, Kamil  * @endinternal
1552f4c4dcf4SKowalski, Kamil  */
1553b5c07418SJames Feist nlohmann::json accountNotModified(void)
15541abe55efSEd Tanous {
1555fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountNotModified, {});
1556b5c07418SJames Feist }
1557b5c07418SJames Feist 
1558b5c07418SJames Feist void accountNotModified(crow::Response& res)
1559b5c07418SJames Feist {
1560b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1561b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1562f4c4dcf4SKowalski, Kamil }
1563f4c4dcf4SKowalski, Kamil 
1564f4c4dcf4SKowalski, Kamil /**
1565f4c4dcf4SKowalski, Kamil  * @internal
1566f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1567f4c4dcf4SKowalski, Kamil  *
1568f4c4dcf4SKowalski, Kamil  * See header file for more information
1569f4c4dcf4SKowalski, Kamil  * @endinternal
1570f4c4dcf4SKowalski, Kamil  */
15711668ce6dSEd Tanous nlohmann::json queryParameterValueFormatError(std::string_view arg1,
15721668ce6dSEd Tanous                                               std::string_view arg2)
15731abe55efSEd Tanous {
1574fffb8c1fSEd Tanous     return getLog(
1575fffb8c1fSEd Tanous         redfish::registries::base::Index::queryParameterValueFormatError,
15761668ce6dSEd Tanous         std::to_array({arg1, arg2}));
1577b5c07418SJames Feist }
1578b5c07418SJames Feist 
15791668ce6dSEd Tanous void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
15801668ce6dSEd Tanous                                     std::string_view arg2)
1581b5c07418SJames Feist {
1582b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1583b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1584b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
1585f4c4dcf4SKowalski, Kamil }
1586f4c4dcf4SKowalski, Kamil 
1587f4c4dcf4SKowalski, Kamil /**
1588f4c4dcf4SKowalski, Kamil  * @internal
1589b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
1590b5c07418SJames Feist  * property
1591f12894f8SJason M. Bills  *
1592f12894f8SJason M. Bills  * See header file for more information
1593f12894f8SJason M. Bills  * @endinternal
1594f12894f8SJason M. Bills  */
15951668ce6dSEd Tanous nlohmann::json propertyMissing(std::string_view arg1)
1596f12894f8SJason M. Bills {
1597fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::propertyMissing,
15981668ce6dSEd Tanous                   std::to_array({arg1}));
1599b5c07418SJames Feist }
1600b5c07418SJames Feist 
16011668ce6dSEd Tanous void propertyMissing(crow::Response& res, std::string_view arg1)
1602b5c07418SJames Feist {
1603b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1604b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
1605f4c4dcf4SKowalski, Kamil }
1606f4c4dcf4SKowalski, Kamil 
1607f4c4dcf4SKowalski, Kamil /**
1608f4c4dcf4SKowalski, Kamil  * @internal
1609f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
1610f4c4dcf4SKowalski, Kamil  *
1611f4c4dcf4SKowalski, Kamil  * See header file for more information
1612f4c4dcf4SKowalski, Kamil  * @endinternal
1613f4c4dcf4SKowalski, Kamil  */
16141668ce6dSEd Tanous nlohmann::json resourceExhaustion(std::string_view arg1)
16151abe55efSEd Tanous {
1616fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::resourceExhaustion,
16171668ce6dSEd Tanous                   std::to_array({arg1}));
1618b5c07418SJames Feist }
1619b5c07418SJames Feist 
16201668ce6dSEd Tanous void resourceExhaustion(crow::Response& res, std::string_view arg1)
1621b5c07418SJames Feist {
1622b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1623b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
1624f4c4dcf4SKowalski, Kamil }
1625f4c4dcf4SKowalski, Kamil 
1626f4c4dcf4SKowalski, Kamil /**
1627f4c4dcf4SKowalski, Kamil  * @internal
1628f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
1629f4c4dcf4SKowalski, Kamil  *
1630f4c4dcf4SKowalski, Kamil  * See header file for more information
1631f4c4dcf4SKowalski, Kamil  * @endinternal
1632f4c4dcf4SKowalski, Kamil  */
1633b5c07418SJames Feist nlohmann::json accountModified(void)
16341abe55efSEd Tanous {
1635fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::accountModified, {});
1636b5c07418SJames Feist }
1637b5c07418SJames Feist 
1638b5c07418SJames Feist void accountModified(crow::Response& res)
1639b5c07418SJames Feist {
1640b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1641b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
1642f4c4dcf4SKowalski, Kamil }
1643f4c4dcf4SKowalski, Kamil 
1644f4c4dcf4SKowalski, Kamil /**
1645f4c4dcf4SKowalski, Kamil  * @internal
1646f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
1647f4c4dcf4SKowalski, Kamil  *
1648f4c4dcf4SKowalski, Kamil  * See header file for more information
1649f4c4dcf4SKowalski, Kamil  * @endinternal
1650f4c4dcf4SKowalski, Kamil  */
16511668ce6dSEd Tanous nlohmann::json queryParameterOutOfRange(std::string_view arg1,
16521668ce6dSEd Tanous                                         std::string_view arg2,
16531668ce6dSEd Tanous                                         std::string_view arg3)
16541abe55efSEd Tanous {
1655fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
16561668ce6dSEd Tanous                   std::to_array({arg1, arg2, arg3}));
1657b5c07418SJames Feist }
1658b5c07418SJames Feist 
16591668ce6dSEd Tanous void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
16601668ce6dSEd Tanous                               std::string_view arg2, std::string_view arg3)
1661b5c07418SJames Feist {
1662b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1663b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1664b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
1665f4c4dcf4SKowalski, Kamil }
1666f4c4dcf4SKowalski, Kamil 
1667b6cd31e1SEd Tanous nlohmann::json passwordChangeRequired(const boost::urls::url_view& arg1)
1668b6cd31e1SEd Tanous {
16691668ce6dSEd Tanous     std::string_view arg1str(arg1.data(), arg1.size());
1670fffb8c1fSEd Tanous     return getLog(redfish::registries::base::Index::passwordChangeRequired,
16711668ce6dSEd Tanous                   std::to_array({arg1str}));
1672b6cd31e1SEd Tanous }
1673b6cd31e1SEd Tanous 
16743bf4e632SJoseph Reynolds /**
16753bf4e632SJoseph Reynolds  * @internal
16763bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
16773bf4e632SJoseph Reynolds  *
16783bf4e632SJoseph Reynolds  * See header file for more information
16793bf4e632SJoseph Reynolds  * @endinternal
16803bf4e632SJoseph Reynolds  */
1681ace85d60SEd Tanous void passwordChangeRequired(crow::Response& res,
1682ace85d60SEd Tanous                             const boost::urls::url_view& arg1)
16833bf4e632SJoseph Reynolds {
1684b6cd31e1SEd Tanous     messages::addMessageToJsonRoot(res.jsonValue, passwordChangeRequired(arg1));
16853bf4e632SJoseph Reynolds }
16863bf4e632SJoseph Reynolds 
16871668ce6dSEd Tanous void invalidUpload(crow::Response& res, std::string_view arg1,
16881668ce6dSEd Tanous                    std::string_view arg2)
16894cde5d90SJames Feist {
16904cde5d90SJames Feist     res.result(boost::beast::http::status::bad_request);
16914cde5d90SJames Feist     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
16924cde5d90SJames Feist }
16934cde5d90SJames Feist 
16944cde5d90SJames Feist /**
16954cde5d90SJames Feist  * @internal
16964cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
16974cde5d90SJames Feist  *
16984cde5d90SJames Feist  * See header file for more information
16994cde5d90SJames Feist  * @endinternal
17004cde5d90SJames Feist  */
17011668ce6dSEd Tanous nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
17024cde5d90SJames Feist {
17031668ce6dSEd Tanous     std::string msg = "Invalid file uploaded to ";
17041668ce6dSEd Tanous     msg += arg1;
17051668ce6dSEd Tanous     msg += ": ";
17061668ce6dSEd Tanous     msg += arg2;
17071668ce6dSEd Tanous     msg += ".";
17084cde5d90SJames Feist     return nlohmann::json{
17093e082749SAsmitha Karunanithi         {"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"},
17104a0bf539SManojkiran Eda         {"MessageId", "OpenBMC.0.2.InvalidUpload"},
17111668ce6dSEd Tanous         {"Message", std::move(msg)},
17124cde5d90SJames Feist         {"MessageArgs", {arg1, arg2}},
1713684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
17144cde5d90SJames Feist         {"Resolution", "None."}};
17154cde5d90SJames Feist }
1716f4c4dcf4SKowalski, Kamil } // namespace messages
1717f4c4dcf4SKowalski, Kamil 
1718d425c6f6SEd Tanous } // namespace redfish
1719