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"
179ea15c35SEd Tanous 
189ea15c35SEd Tanous #include <boost/beast/http/status.hpp>
19*ace85d60SEd Tanous #include <boost/url/url.hpp>
201abe55efSEd Tanous #include <error_messages.hpp>
2104e438cbSEd Tanous #include <logging.hpp>
229ea15c35SEd Tanous #include <nlohmann/json.hpp>
23f4c4dcf4SKowalski, Kamil 
241abe55efSEd Tanous namespace redfish
251abe55efSEd Tanous {
261abe55efSEd Tanous 
271abe55efSEd Tanous namespace messages
281abe55efSEd Tanous {
29f4c4dcf4SKowalski, Kamil 
30f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target,
311abe55efSEd Tanous                                   const nlohmann::json& message)
321abe55efSEd Tanous {
33f4c4dcf4SKowalski, Kamil     auto& error = target["error"];
34f4c4dcf4SKowalski, Kamil 
351abe55efSEd Tanous     // If this is the first error message, fill in the information from the
361abe55efSEd Tanous     // first error message to the top level struct
371abe55efSEd Tanous     if (!error.is_object())
381abe55efSEd Tanous     {
39c074230bSJason M. Bills         auto messageIdIterator = message.find("MessageId");
40c074230bSJason M. Bills         if (messageIdIterator == message.end())
411abe55efSEd Tanous         {
421abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
431abe55efSEd Tanous                 << "Attempt to add error message without MessageId";
44f4c4dcf4SKowalski, Kamil             return;
45f4c4dcf4SKowalski, Kamil         }
46f4c4dcf4SKowalski, Kamil 
47c074230bSJason M. Bills         auto messageFieldIterator = message.find("Message");
48c074230bSJason M. Bills         if (messageFieldIterator == message.end())
491abe55efSEd Tanous         {
501abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
511abe55efSEd Tanous                 << "Attempt to add error message without Message";
52f4c4dcf4SKowalski, Kamil             return;
53f4c4dcf4SKowalski, Kamil         }
54c21055aaSEd Tanous         error = {{"code", *messageIdIterator},
55c21055aaSEd Tanous                  {"message", *messageFieldIterator}};
561abe55efSEd Tanous     }
571abe55efSEd Tanous     else
581abe55efSEd Tanous     {
59f4c4dcf4SKowalski, Kamil         // More than 1 error occurred, so the message has to be generic
6055c7b7a2SEd Tanous         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
61cc9139ecSJason M. Bills         error["message"] = "A general error has occurred. See Resolution for "
62cc9139ecSJason M. Bills                            "information on how to resolve the error.";
63f4c4dcf4SKowalski, Kamil     }
64f4c4dcf4SKowalski, Kamil 
65f4c4dcf4SKowalski, Kamil     // This check could technically be done in in the default construction
66f4c4dcf4SKowalski, Kamil     // branch above, but because we need the pointer to the extended info field
67f4c4dcf4SKowalski, Kamil     // anyway, it's more efficient to do it here.
68c074230bSJason M. Bills     auto& extendedInfo = error[messages::messageAnnotation];
69c074230bSJason M. Bills     if (!extendedInfo.is_array())
701abe55efSEd Tanous     {
71c074230bSJason M. Bills         extendedInfo = nlohmann::json::array();
72f4c4dcf4SKowalski, Kamil     }
73f4c4dcf4SKowalski, Kamil 
74c074230bSJason M. Bills     extendedInfo.push_back(message);
75f4c4dcf4SKowalski, Kamil }
76f4c4dcf4SKowalski, Kamil 
77f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target,
78f12894f8SJason M. Bills                                  const nlohmann::json& message)
791abe55efSEd Tanous {
801abe55efSEd Tanous     if (!target[messages::messageAnnotation].is_array())
811abe55efSEd Tanous     {
82f4c4dcf4SKowalski, Kamil         // Force object to be an array
8355c7b7a2SEd Tanous         target[messages::messageAnnotation] = nlohmann::json::array();
84f4c4dcf4SKowalski, Kamil     }
85f4c4dcf4SKowalski, Kamil 
8655c7b7a2SEd Tanous     target[messages::messageAnnotation].push_back(message);
87f4c4dcf4SKowalski, Kamil }
88f4c4dcf4SKowalski, Kamil 
89f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target,
90f12894f8SJason M. Bills                              const nlohmann::json& message,
911abe55efSEd Tanous                              const std::string& fieldPath)
921abe55efSEd Tanous {
93a08b46ccSJason M. Bills     std::string extendedInfo(fieldPath + messages::messageAnnotation);
94f4c4dcf4SKowalski, Kamil 
951abe55efSEd Tanous     if (!target[extendedInfo].is_array())
961abe55efSEd Tanous     {
97f4c4dcf4SKowalski, Kamil         // Force object to be an array
98f4c4dcf4SKowalski, Kamil         target[extendedInfo] = nlohmann::json::array();
99f4c4dcf4SKowalski, Kamil     }
100f4c4dcf4SKowalski, Kamil 
101f4c4dcf4SKowalski, Kamil     // Object exists and it is an array so we can just push in the message
102f4c4dcf4SKowalski, Kamil     target[extendedInfo].push_back(message);
103f4c4dcf4SKowalski, Kamil }
104f4c4dcf4SKowalski, Kamil 
105f4c4dcf4SKowalski, Kamil /**
106f4c4dcf4SKowalski, Kamil  * @internal
107f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
108f4c4dcf4SKowalski, Kamil  *
109f4c4dcf4SKowalski, Kamil  * See header file for more information
110f4c4dcf4SKowalski, Kamil  * @endinternal
111f4c4dcf4SKowalski, Kamil  */
112b5c07418SJames Feist nlohmann::json resourceInUse(void)
1131abe55efSEd Tanous {
114b5c07418SJames Feist     return nlohmann::json{
1153e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
116684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceInUse"},
11766ac2b8cSJason M. Bills         {"Message", "The change to the requested resource failed because "
11866ac2b8cSJason M. Bills                     "the resource is in use or in transition."},
11985659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
120684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
12166ac2b8cSJason M. Bills         {"Resolution", "Remove the condition and resubmit the request if "
122b5c07418SJames Feist                        "the operation failed."}};
123b5c07418SJames Feist }
124b5c07418SJames Feist 
125b5c07418SJames Feist void resourceInUse(crow::Response& res)
126b5c07418SJames Feist {
127b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
128b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
129f4c4dcf4SKowalski, Kamil }
130f4c4dcf4SKowalski, Kamil 
131f4c4dcf4SKowalski, Kamil /**
132f4c4dcf4SKowalski, Kamil  * @internal
133f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
134f4c4dcf4SKowalski, Kamil  *
135f4c4dcf4SKowalski, Kamil  * See header file for more information
136f4c4dcf4SKowalski, Kamil  * @endinternal
137f4c4dcf4SKowalski, Kamil  */
138b5c07418SJames Feist nlohmann::json malformedJSON(void)
1391abe55efSEd Tanous {
140b5c07418SJames Feist     return nlohmann::json{
1413e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
142684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.MalformedJSON"},
14366ac2b8cSJason M. Bills         {"Message", "The request body submitted was malformed JSON and "
14466ac2b8cSJason M. Bills                     "could not be parsed by the receiving service."},
14585659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
146684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1471abe55efSEd Tanous         {"Resolution", "Ensure that the request body is valid JSON and "
148b5c07418SJames Feist                        "resubmit the request."}};
149b5c07418SJames Feist }
150b5c07418SJames Feist 
151b5c07418SJames Feist void malformedJSON(crow::Response& res)
152b5c07418SJames Feist {
153b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
154b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
155f4c4dcf4SKowalski, Kamil }
156f4c4dcf4SKowalski, Kamil 
157f4c4dcf4SKowalski, Kamil /**
158f4c4dcf4SKowalski, Kamil  * @internal
159f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
160f4c4dcf4SKowalski, Kamil  *
161f4c4dcf4SKowalski, Kamil  * See header file for more information
162f4c4dcf4SKowalski, Kamil  * @endinternal
163f4c4dcf4SKowalski, Kamil  */
164*ace85d60SEd Tanous nlohmann::json resourceMissingAtURI(const boost::urls::url_view& arg1)
1651abe55efSEd Tanous {
166*ace85d60SEd Tanous     std::string url(arg1.data(), arg1.size());
167b5c07418SJames Feist     return nlohmann::json{
1683e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
169684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceMissingAtURI"},
170*ace85d60SEd Tanous         {"Message", "The resource at the URI " + url + " was not found."},
171*ace85d60SEd Tanous         {"MessageArgs", {url}},
172684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
17366ac2b8cSJason M. Bills         {"Resolution", "Place a valid resource at the URI or correct the "
174b5c07418SJames Feist                        "URI and resubmit the request."}};
175b5c07418SJames Feist }
176b5c07418SJames Feist 
177*ace85d60SEd Tanous void resourceMissingAtURI(crow::Response& res,
178*ace85d60SEd Tanous                           const boost::urls::url_view& arg1)
179b5c07418SJames Feist {
180b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
181b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
182f4c4dcf4SKowalski, Kamil }
183f4c4dcf4SKowalski, Kamil 
184f4c4dcf4SKowalski, Kamil /**
185f4c4dcf4SKowalski, Kamil  * @internal
186f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
187f4c4dcf4SKowalski, Kamil  *
188f4c4dcf4SKowalski, Kamil  * See header file for more information
189f4c4dcf4SKowalski, Kamil  * @endinternal
190f4c4dcf4SKowalski, Kamil  */
191b5c07418SJames Feist nlohmann::json actionParameterValueFormatError(const std::string& arg1,
192f4c4dcf4SKowalski, Kamil                                                const std::string& arg2,
1931abe55efSEd Tanous                                                const std::string& arg3)
1941abe55efSEd Tanous {
195b5c07418SJames Feist     return nlohmann::json{
1963e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
197684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterValueFormatError"},
198f4c4dcf4SKowalski, Kamil         {"Message",
1991abe55efSEd Tanous          "The value " + arg1 + " for the parameter " + arg2 +
2001abe55efSEd Tanous              " in the action " + arg3 +
2011abe55efSEd Tanous              " is of a different format than the parameter can accept."},
20285659adfSJason M. Bills         {"MessageArgs", {arg1, arg2, arg3}},
203684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
20466ac2b8cSJason M. Bills         {"Resolution",
20566ac2b8cSJason M. Bills          "Correct the value for the parameter in the request body and "
206b5c07418SJames Feist          "resubmit the request if the operation failed."}};
207b5c07418SJames Feist }
208b5c07418SJames Feist 
209b5c07418SJames Feist void actionParameterValueFormatError(crow::Response& res,
210b5c07418SJames Feist                                      const std::string& arg1,
211b5c07418SJames Feist                                      const std::string& arg2,
212b5c07418SJames Feist                                      const std::string& arg3)
213b5c07418SJames Feist {
214b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
215b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
216b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
217f4c4dcf4SKowalski, Kamil }
218f4c4dcf4SKowalski, Kamil 
219f4c4dcf4SKowalski, Kamil /**
220f4c4dcf4SKowalski, Kamil  * @internal
221f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
222f4c4dcf4SKowalski, Kamil  *
223f4c4dcf4SKowalski, Kamil  * See header file for more information
224f4c4dcf4SKowalski, Kamil  * @endinternal
225f4c4dcf4SKowalski, Kamil  */
226b5c07418SJames Feist nlohmann::json internalError(void)
2271abe55efSEd Tanous {
228b5c07418SJames Feist     return nlohmann::json{
2293e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
230684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.InternalError"},
231f12894f8SJason M. Bills         {"Message", "The request failed due to an internal service error.  "
23266ac2b8cSJason M. Bills                     "The service is still operational."},
23385659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
234684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
2351abe55efSEd Tanous         {"Resolution", "Resubmit the request.  If the problem persists, "
236b5c07418SJames Feist                        "consider resetting the service."}};
237b5c07418SJames Feist }
238b5c07418SJames Feist 
239df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location)
240b5c07418SJames Feist {
241df5415fcSEd Tanous     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
242df5415fcSEd Tanous                         << location.line() << ":" << location.column() << ") `"
243df5415fcSEd Tanous                         << location.function_name() << "`: ";
244b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
245b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
246f12894f8SJason M. Bills }
247f12894f8SJason M. Bills 
248f12894f8SJason M. Bills /**
249f12894f8SJason M. Bills  * @internal
250f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
251f4c4dcf4SKowalski, Kamil  *
252f4c4dcf4SKowalski, Kamil  * See header file for more information
253f4c4dcf4SKowalski, Kamil  * @endinternal
254f4c4dcf4SKowalski, Kamil  */
255b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void)
2561abe55efSEd Tanous {
257b5c07418SJames Feist     return nlohmann::json{
2583e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
259684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.UnrecognizedRequestBody"},
260f12894f8SJason M. Bills         {"Message", "The service detected a malformed request body that it "
26166ac2b8cSJason M. Bills                     "was unable to interpret."},
26285659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
263684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
264f12894f8SJason M. Bills         {"Resolution", "Correct the request body and resubmit the request "
265b5c07418SJames Feist                        "if it failed."}};
266b5c07418SJames Feist }
267b5c07418SJames Feist 
268b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
269b5c07418SJames Feist {
270b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
271b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
272f4c4dcf4SKowalski, Kamil }
273f4c4dcf4SKowalski, Kamil 
274f4c4dcf4SKowalski, Kamil /**
275f4c4dcf4SKowalski, Kamil  * @internal
276f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
277f4c4dcf4SKowalski, Kamil  *
278f4c4dcf4SKowalski, Kamil  * See header file for more information
279f4c4dcf4SKowalski, Kamil  * @endinternal
280f4c4dcf4SKowalski, Kamil  */
281*ace85d60SEd Tanous nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view& arg1,
2821abe55efSEd Tanous                                          const std::string& arg2)
2831abe55efSEd Tanous {
284*ace85d60SEd Tanous     std::string url(arg1.data(), arg1.size());
285b5c07418SJames Feist     return nlohmann::json{
2863e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
287684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceAtUriUnauthorized"},
288*ace85d60SEd Tanous         {"Message", "While accessing the resource at " + url +
2891abe55efSEd Tanous                         ", the service received an authorization error " +
2901abe55efSEd Tanous                         arg2 + "."},
291*ace85d60SEd Tanous         {"MessageArgs", {url, arg2}},
292684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
293f12894f8SJason M. Bills         {"Resolution", "Ensure that the appropriate access is provided for "
294b5c07418SJames Feist                        "the service in order for it to access the URI."}};
295b5c07418SJames Feist }
296b5c07418SJames Feist 
297*ace85d60SEd Tanous void resourceAtUriUnauthorized(crow::Response& res,
298*ace85d60SEd Tanous                                const boost::urls::url_view& arg1,
299b5c07418SJames Feist                                const std::string& arg2)
300b5c07418SJames Feist {
301b5c07418SJames Feist     res.result(boost::beast::http::status::unauthorized);
302b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
303f4c4dcf4SKowalski, Kamil }
304f4c4dcf4SKowalski, Kamil 
305f4c4dcf4SKowalski, Kamil /**
306f4c4dcf4SKowalski, Kamil  * @internal
307f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterUnknown message into JSON
308f4c4dcf4SKowalski, Kamil  *
309f4c4dcf4SKowalski, Kamil  * See header file for more information
310f4c4dcf4SKowalski, Kamil  * @endinternal
311f4c4dcf4SKowalski, Kamil  */
312b5c07418SJames Feist nlohmann::json actionParameterUnknown(const std::string& arg1,
313b5c07418SJames Feist                                       const std::string& arg2)
314b5c07418SJames Feist {
315b5c07418SJames Feist     return nlohmann::json{
3163e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
317684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterUnknown"},
318b5c07418SJames Feist         {"Message", "The action " + arg1 +
319b5c07418SJames Feist                         " was submitted with the invalid parameter " + arg2 +
320b5c07418SJames Feist                         "."},
321b5c07418SJames Feist         {"MessageArgs", {arg1, arg2}},
322684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
323b5c07418SJames Feist         {"Resolution", "Correct the invalid parameter and resubmit the "
324b5c07418SJames Feist                        "request if the operation failed."}};
325b5c07418SJames Feist }
326b5c07418SJames Feist 
327f12894f8SJason M. Bills void actionParameterUnknown(crow::Response& res, const std::string& arg1,
3281abe55efSEd Tanous                             const std::string& arg2)
3291abe55efSEd Tanous {
330f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
331b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
332f4c4dcf4SKowalski, Kamil }
333f4c4dcf4SKowalski, Kamil 
334f4c4dcf4SKowalski, Kamil /**
335f4c4dcf4SKowalski, Kamil  * @internal
336f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceCannotBeDeleted message into JSON
337f4c4dcf4SKowalski, Kamil  *
338f4c4dcf4SKowalski, Kamil  * See header file for more information
339f4c4dcf4SKowalski, Kamil  * @endinternal
340f4c4dcf4SKowalski, Kamil  */
341b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void)
3421abe55efSEd Tanous {
343b5c07418SJames Feist     return nlohmann::json{
3443e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
345684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceCannotBeDeleted"},
346f12894f8SJason M. Bills         {"Message", "The delete request failed because the resource "
34766ac2b8cSJason M. Bills                     "requested cannot be deleted."},
34885659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
349684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
350b5c07418SJames Feist         {"Resolution", "Do not attempt to delete a non-deletable resource."}};
351b5c07418SJames Feist }
352b5c07418SJames Feist 
353b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res)
354b5c07418SJames Feist {
355b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
356b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
357f4c4dcf4SKowalski, Kamil }
358f4c4dcf4SKowalski, Kamil 
359f4c4dcf4SKowalski, Kamil /**
360f4c4dcf4SKowalski, Kamil  * @internal
361f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyDuplicate message into JSON
362f4c4dcf4SKowalski, Kamil  *
363f4c4dcf4SKowalski, Kamil  * See header file for more information
364f4c4dcf4SKowalski, Kamil  * @endinternal
365f4c4dcf4SKowalski, Kamil  */
366b5c07418SJames Feist nlohmann::json propertyDuplicate(const std::string& arg1)
3671abe55efSEd Tanous {
368b5c07418SJames Feist     return nlohmann::json{
3693e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
370684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyDuplicate"},
371b5c07418SJames Feist         {"Message", "The property " + arg1 + " was duplicated in the request."},
37285659adfSJason M. Bills         {"MessageArgs", {arg1}},
373684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
37466ac2b8cSJason M. Bills         {"Resolution",
37566ac2b8cSJason M. Bills          "Remove the duplicate property from the request body and resubmit "
376b5c07418SJames Feist          "the request if the operation failed."}};
377b5c07418SJames Feist }
378b5c07418SJames Feist 
379b5c07418SJames Feist void propertyDuplicate(crow::Response& res, const std::string& arg1)
380b5c07418SJames Feist {
381b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
382b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
383f4c4dcf4SKowalski, Kamil }
384f4c4dcf4SKowalski, Kamil 
385f4c4dcf4SKowalski, Kamil /**
386f4c4dcf4SKowalski, Kamil  * @internal
387f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
388f4c4dcf4SKowalski, Kamil  *
389f4c4dcf4SKowalski, Kamil  * See header file for more information
390f4c4dcf4SKowalski, Kamil  * @endinternal
391f4c4dcf4SKowalski, Kamil  */
392b5c07418SJames Feist nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1)
3931abe55efSEd Tanous {
394b5c07418SJames Feist     return nlohmann::json{
3953e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
396684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ServiceTemporarilyUnavailable"},
3971abe55efSEd Tanous         {"Message", "The service is temporarily unavailable.  Retry in " +
3981abe55efSEd Tanous                         arg1 + " seconds."},
39985659adfSJason M. Bills         {"MessageArgs", {arg1}},
400684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
401f12894f8SJason M. Bills         {"Resolution", "Wait for the indicated retry duration and retry "
402b5c07418SJames Feist                        "the operation."}};
403b5c07418SJames Feist }
404b5c07418SJames Feist 
405b5c07418SJames Feist void serviceTemporarilyUnavailable(crow::Response& res, const std::string& arg1)
406b5c07418SJames Feist {
407b5c07418SJames Feist     res.addHeader("Retry-After", arg1);
408b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
409b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
410f4c4dcf4SKowalski, Kamil }
411f4c4dcf4SKowalski, Kamil 
412f4c4dcf4SKowalski, Kamil /**
413f4c4dcf4SKowalski, Kamil  * @internal
414f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
415f4c4dcf4SKowalski, Kamil  *
416f4c4dcf4SKowalski, Kamil  * See header file for more information
417f4c4dcf4SKowalski, Kamil  * @endinternal
418f4c4dcf4SKowalski, Kamil  */
419b5c07418SJames Feist nlohmann::json resourceAlreadyExists(const std::string& arg1,
420b5c07418SJames Feist                                      const std::string& arg2,
421b5c07418SJames Feist                                      const std::string& arg3)
4221abe55efSEd Tanous {
423b5c07418SJames Feist     return nlohmann::json{
4243e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
425684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceAlreadyExists"},
426f4c4dcf4SKowalski, Kamil         {"Message", "The requested resource of type " + arg1 +
4271abe55efSEd Tanous                         " with the property " + arg2 + " with the value " +
4281abe55efSEd Tanous                         arg3 + " already exists."},
42985659adfSJason M. Bills         {"MessageArgs", {arg1, arg2, arg3}},
430684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
431f12894f8SJason M. Bills         {"Resolution", "Do not repeat the create operation as the resource "
432b5c07418SJames Feist                        "has already been created."}};
433b5c07418SJames Feist }
434b5c07418SJames Feist 
435b5c07418SJames Feist void resourceAlreadyExists(crow::Response& res, const std::string& arg1,
436b5c07418SJames Feist                            const std::string& arg2, const std::string& arg3)
437b5c07418SJames Feist {
438b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
439b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
440a08b46ccSJason M. Bills                      arg2);
441f4c4dcf4SKowalski, Kamil }
442f4c4dcf4SKowalski, Kamil 
443f4c4dcf4SKowalski, Kamil /**
444f4c4dcf4SKowalski, Kamil  * @internal
445f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
446f4c4dcf4SKowalski, Kamil  *
447f4c4dcf4SKowalski, Kamil  * See header file for more information
448f4c4dcf4SKowalski, Kamil  * @endinternal
449f4c4dcf4SKowalski, Kamil  */
450b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void)
4511abe55efSEd Tanous {
452b5c07418SJames Feist     return nlohmann::json{
4533e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
454684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.AccountForSessionNoLongerExists"},
4551abe55efSEd Tanous         {"Message", "The account for the current session has been removed, "
45666ac2b8cSJason M. Bills                     "thus the current session has been removed as well."},
45785659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
458684bb4b8SJason M. Bills         {"MessageSeverity", "OK"},
459b5c07418SJames Feist         {"Resolution", "Attempt to connect with a valid account."}};
460b5c07418SJames Feist }
461b5c07418SJames Feist 
462b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
463b5c07418SJames Feist {
464b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
465b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
466f4c4dcf4SKowalski, Kamil }
467f4c4dcf4SKowalski, Kamil 
468f4c4dcf4SKowalski, Kamil /**
469f4c4dcf4SKowalski, Kamil  * @internal
470f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
471f4c4dcf4SKowalski, Kamil  *
472f4c4dcf4SKowalski, Kamil  * See header file for more information
473f4c4dcf4SKowalski, Kamil  * @endinternal
474f4c4dcf4SKowalski, Kamil  */
475b5c07418SJames Feist nlohmann::json createFailedMissingReqProperties(const std::string& arg1)
4761abe55efSEd Tanous {
477b5c07418SJames Feist     return nlohmann::json{
4783e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
479684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.CreateFailedMissingReqProperties"},
4801abe55efSEd Tanous         {"Message",
481b5c07418SJames Feist          "The create operation failed because the required property " + arg1 +
482b5c07418SJames Feist              " was missing from the request."},
48385659adfSJason M. Bills         {"MessageArgs", {arg1}},
484684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
485f4c4dcf4SKowalski, Kamil         {"Resolution",
486f12894f8SJason M. Bills          "Correct the body to include the required property with a valid "
487b5c07418SJames Feist          "value and resubmit the request if the operation failed."}};
488b5c07418SJames Feist }
489b5c07418SJames Feist 
490b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
491b5c07418SJames Feist                                       const std::string& arg1)
492b5c07418SJames Feist {
493b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
494b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
495a08b46ccSJason M. Bills                      arg1);
496f12894f8SJason M. Bills }
497f12894f8SJason M. Bills 
498f12894f8SJason M. Bills /**
499f12894f8SJason M. Bills  * @internal
500f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
501f12894f8SJason M. Bills  * property
502f12894f8SJason M. Bills  *
503f12894f8SJason M. Bills  * See header file for more information
504f12894f8SJason M. Bills  * @endinternal
505f12894f8SJason M. Bills  */
506b5c07418SJames Feist nlohmann::json propertyValueFormatError(const std::string& arg1,
507a08b46ccSJason M. Bills                                         const std::string& arg2)
508f12894f8SJason M. Bills {
509b5c07418SJames Feist     return nlohmann::json{
5103e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
511684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueFormatError"},
512f12894f8SJason M. Bills         {"Message",
513f12894f8SJason M. Bills          "The value " + arg1 + " for the property " + arg2 +
514f12894f8SJason M. Bills              " is of a different format than the property can accept."},
51585659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
516684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
51766ac2b8cSJason M. Bills         {"Resolution",
51866ac2b8cSJason M. Bills          "Correct the value for the property in the request body and "
519b5c07418SJames Feist          "resubmit the request if the operation failed."}};
520b5c07418SJames Feist }
521b5c07418SJames Feist 
522b5c07418SJames Feist void propertyValueFormatError(crow::Response& res, const std::string& arg1,
523b5c07418SJames Feist                               const std::string& arg2)
524b5c07418SJames Feist {
525b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
526b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
527f12894f8SJason M. Bills }
528f12894f8SJason M. Bills 
529f12894f8SJason M. Bills /**
530f12894f8SJason M. Bills  * @internal
531f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
532f12894f8SJason M. Bills  * property
533f12894f8SJason M. Bills  *
534f12894f8SJason M. Bills  * See header file for more information
535f12894f8SJason M. Bills  * @endinternal
536f12894f8SJason M. Bills  */
537b5c07418SJames Feist nlohmann::json propertyValueNotInList(const std::string& arg1,
538a08b46ccSJason M. Bills                                       const std::string& arg2)
539f12894f8SJason M. Bills {
540b5c07418SJames Feist     return nlohmann::json{
5413e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
542684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueNotInList"},
543f12894f8SJason M. Bills         {"Message", "The value " + arg1 + " for the property " + arg2 +
544f12894f8SJason M. Bills                         " is not in the list of acceptable values."},
54585659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
546684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
547b5c07418SJames Feist         {"Resolution", "Choose a value from the enumeration list that "
548b5c07418SJames Feist                        "the implementation "
549b5c07418SJames Feist                        "can support and resubmit the request if the "
550b5c07418SJames Feist                        "operation failed."}};
551b5c07418SJames Feist }
552b5c07418SJames Feist 
553b5c07418SJames Feist void propertyValueNotInList(crow::Response& res, const std::string& arg1,
554b5c07418SJames Feist                             const std::string& arg2)
555b5c07418SJames Feist {
556b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
557b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
558f4c4dcf4SKowalski, Kamil }
559f4c4dcf4SKowalski, Kamil 
560f4c4dcf4SKowalski, Kamil /**
561f4c4dcf4SKowalski, Kamil  * @internal
562f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
563f4c4dcf4SKowalski, Kamil  *
564f4c4dcf4SKowalski, Kamil  * See header file for more information
565f4c4dcf4SKowalski, Kamil  * @endinternal
566f4c4dcf4SKowalski, Kamil  */
567*ace85d60SEd Tanous nlohmann::json resourceAtUriInUnknownFormat(const boost::urls::url_view& arg1)
5681abe55efSEd Tanous {
569*ace85d60SEd Tanous     std::string url(arg1.data(), arg1.size());
570b5c07418SJames Feist     return nlohmann::json{
5713e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
572684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceAtUriInUnknownFormat"},
573*ace85d60SEd Tanous         {"Message", "The resource at " + url +
574f4c4dcf4SKowalski, Kamil                         " is in a format not recognized by the service."},
575*ace85d60SEd Tanous         {"MessageArgs", {url}},
576684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
577f12894f8SJason M. Bills         {"Resolution", "Place an image or resource or file that is "
578b5c07418SJames Feist                        "recognized by the service at the URI."}};
579b5c07418SJames Feist }
580b5c07418SJames Feist 
581*ace85d60SEd Tanous void resourceAtUriInUnknownFormat(crow::Response& res,
582*ace85d60SEd Tanous                                   const boost::urls::url_view& arg1)
583b5c07418SJames Feist {
584b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
585b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
586f4c4dcf4SKowalski, Kamil }
587f4c4dcf4SKowalski, Kamil 
588f4c4dcf4SKowalski, Kamil /**
589f4c4dcf4SKowalski, Kamil  * @internal
59081856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
59181856681SAsmitha Karunanithi  *
59281856681SAsmitha Karunanithi  * See header file for more information
59381856681SAsmitha Karunanithi  * @endinternal
59481856681SAsmitha Karunanithi  */
59581856681SAsmitha Karunanithi nlohmann::json serviceDisabled(const std::string& arg1)
59681856681SAsmitha Karunanithi {
59781856681SAsmitha Karunanithi     return nlohmann::json{
59881856681SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
59981856681SAsmitha Karunanithi         {"MessageId", "Base.1.11.0.ServiceDisabled"},
60081856681SAsmitha Karunanithi         {"Message", "The operation failed because the service at " + arg1 +
60181856681SAsmitha Karunanithi                         " is disabled and cannot accept requests."},
60281856681SAsmitha Karunanithi         {"MessageArgs", {arg1}},
60381856681SAsmitha Karunanithi         {"MessageSeverity", "Warning"},
60481856681SAsmitha Karunanithi         {"Resolution", "Enable the service and resubmit the request if the "
60581856681SAsmitha Karunanithi                        "operation failed."}};
60681856681SAsmitha Karunanithi }
60781856681SAsmitha Karunanithi 
60881856681SAsmitha Karunanithi void serviceDisabled(crow::Response& res, const std::string& arg1)
60981856681SAsmitha Karunanithi {
61081856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
61181856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
61281856681SAsmitha Karunanithi }
61381856681SAsmitha Karunanithi 
61481856681SAsmitha Karunanithi /**
61581856681SAsmitha Karunanithi  * @internal
616f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
617f4c4dcf4SKowalski, Kamil  *
618f4c4dcf4SKowalski, Kamil  * See header file for more information
619f4c4dcf4SKowalski, Kamil  * @endinternal
620f4c4dcf4SKowalski, Kamil  */
621b5c07418SJames Feist nlohmann::json serviceInUnknownState(void)
6221abe55efSEd Tanous {
623b5c07418SJames Feist     return nlohmann::json{
6243e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
625684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ServiceInUnknownState"},
62666ac2b8cSJason M. Bills         {"Message",
62766ac2b8cSJason M. Bills          "The operation failed because the service is in an unknown state "
62866ac2b8cSJason M. Bills          "and can no longer take incoming requests."},
62985659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
630684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
63166ac2b8cSJason M. Bills         {"Resolution", "Restart the service and resubmit the request if "
632b5c07418SJames Feist                        "the operation failed."}};
633b5c07418SJames Feist }
634b5c07418SJames Feist 
635b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
636b5c07418SJames Feist {
637b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
638b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
639f4c4dcf4SKowalski, Kamil }
640f4c4dcf4SKowalski, Kamil 
641f4c4dcf4SKowalski, Kamil /**
642f4c4dcf4SKowalski, Kamil  * @internal
643f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
644f4c4dcf4SKowalski, Kamil  *
645f4c4dcf4SKowalski, Kamil  * See header file for more information
646f4c4dcf4SKowalski, Kamil  * @endinternal
647f4c4dcf4SKowalski, Kamil  */
648b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void)
6491abe55efSEd Tanous {
650b5c07418SJames Feist     return nlohmann::json{
6513e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
652684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.EventSubscriptionLimitExceeded"},
653f4c4dcf4SKowalski, Kamil         {"Message",
654f4c4dcf4SKowalski, Kamil          "The event subscription failed due to the number of simultaneous "
655f4c4dcf4SKowalski, Kamil          "subscriptions exceeding the limit of the implementation."},
65685659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
657684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
658f4c4dcf4SKowalski, Kamil         {"Resolution",
659f12894f8SJason M. Bills          "Reduce the number of other subscriptions before trying to "
66066ac2b8cSJason M. Bills          "establish the event subscription or increase the limit of "
661b5c07418SJames Feist          "simultaneous subscriptions (if supported)."}};
662b5c07418SJames Feist }
663b5c07418SJames Feist 
664b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
665b5c07418SJames Feist {
666789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
667b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
668f4c4dcf4SKowalski, Kamil }
669f4c4dcf4SKowalski, Kamil 
670f4c4dcf4SKowalski, Kamil /**
671f4c4dcf4SKowalski, Kamil  * @internal
672f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
673f4c4dcf4SKowalski, Kamil  *
674f4c4dcf4SKowalski, Kamil  * See header file for more information
675f4c4dcf4SKowalski, Kamil  * @endinternal
676f4c4dcf4SKowalski, Kamil  */
677b5c07418SJames Feist nlohmann::json actionParameterMissing(const std::string& arg1,
6781abe55efSEd Tanous                                       const std::string& arg2)
6791abe55efSEd Tanous {
680b5c07418SJames Feist     return nlohmann::json{
6813e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
682684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterMissing"},
683b5c07418SJames Feist         {"Message", "The action " + arg1 + " requires the parameter " + arg2 +
684b5c07418SJames Feist                         " to be present in the request body."},
68585659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
686684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
687f12894f8SJason M. Bills         {"Resolution",
68866ac2b8cSJason M. Bills          "Supply the action with the required parameter in the request "
689b5c07418SJames Feist          "body when the request is resubmitted."}};
690b5c07418SJames Feist }
691b5c07418SJames Feist 
692b5c07418SJames Feist void actionParameterMissing(crow::Response& res, const std::string& arg1,
693b5c07418SJames Feist                             const std::string& arg2)
694b5c07418SJames Feist {
695b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
696b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
697f4c4dcf4SKowalski, Kamil }
698f4c4dcf4SKowalski, Kamil 
699f4c4dcf4SKowalski, Kamil /**
700f4c4dcf4SKowalski, Kamil  * @internal
701f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
702f4c4dcf4SKowalski, Kamil  *
703f4c4dcf4SKowalski, Kamil  * See header file for more information
704f4c4dcf4SKowalski, Kamil  * @endinternal
705f4c4dcf4SKowalski, Kamil  */
706331b2017SEd Tanous nlohmann::json stringValueTooLong(const std::string& arg1, int arg2)
7071abe55efSEd Tanous {
708b5c07418SJames Feist     return nlohmann::json{
7093e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
710684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.StringValueTooLong"},
711f4c4dcf4SKowalski, Kamil         {"Message", "The string " + arg1 + " exceeds the length limit " +
712f4c4dcf4SKowalski, Kamil                         std::to_string(arg2) + "."},
71385659adfSJason M. Bills         {"MessageArgs", {arg1, std::to_string(arg2)}},
714684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
715f4c4dcf4SKowalski, Kamil         {"Resolution",
716b5c07418SJames Feist          "Resubmit the request with an appropriate string length."}};
717b5c07418SJames Feist }
718b5c07418SJames Feist 
719331b2017SEd Tanous void stringValueTooLong(crow::Response& res, const std::string& arg1, int arg2)
720b5c07418SJames Feist {
721b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
722b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
723f4c4dcf4SKowalski, Kamil }
724f4c4dcf4SKowalski, Kamil 
725f4c4dcf4SKowalski, Kamil /**
726f4c4dcf4SKowalski, Kamil  * @internal
727cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
728cc9139ecSJason M. Bills  *
729cc9139ecSJason M. Bills  * See header file for more information
730cc9139ecSJason M. Bills  * @endinternal
731cc9139ecSJason M. Bills  */
732b5c07418SJames Feist nlohmann::json sessionTerminated(void)
733cc9139ecSJason M. Bills {
734b5c07418SJames Feist     return nlohmann::json{
7353e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
736684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.SessionTerminated"},
737cc9139ecSJason M. Bills         {"Message", "The session was successfully terminated."},
73885659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
739684bb4b8SJason M. Bills         {"MessageSeverity", "OK"},
740b5c07418SJames Feist         {"Resolution", "No resolution is required."}};
741b5c07418SJames Feist }
742b5c07418SJames Feist 
743b5c07418SJames Feist void sessionTerminated(crow::Response& res)
744b5c07418SJames Feist {
745b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
746b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
747cc9139ecSJason M. Bills }
748cc9139ecSJason M. Bills 
749cc9139ecSJason M. Bills /**
750cc9139ecSJason M. Bills  * @internal
751684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
752684bb4b8SJason M. Bills  *
753684bb4b8SJason M. Bills  * See header file for more information
754684bb4b8SJason M. Bills  * @endinternal
755684bb4b8SJason M. Bills  */
756684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void)
757684bb4b8SJason M. Bills {
758684bb4b8SJason M. Bills     return nlohmann::json{
7593e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
760684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.SubscriptionTerminated"},
761684bb4b8SJason M. Bills         {"Message", "The event subscription has been terminated."},
762684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
763684bb4b8SJason M. Bills         {"MessageSeverity", "OK"},
764684bb4b8SJason M. Bills         {"Resolution", "No resolution is required."}};
765684bb4b8SJason M. Bills }
766684bb4b8SJason M. Bills 
767684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
768684bb4b8SJason M. Bills {
769684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
770684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
771684bb4b8SJason M. Bills }
772684bb4b8SJason M. Bills 
773684bb4b8SJason M. Bills /**
774684bb4b8SJason M. Bills  * @internal
775cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
776cc9139ecSJason M. Bills  *
777cc9139ecSJason M. Bills  * See header file for more information
778cc9139ecSJason M. Bills  * @endinternal
779cc9139ecSJason M. Bills  */
780b5c07418SJames Feist nlohmann::json resourceTypeIncompatible(const std::string& arg1,
781cc9139ecSJason M. Bills                                         const std::string& arg2)
782cc9139ecSJason M. Bills {
783b5c07418SJames Feist     return nlohmann::json{
7843e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
785684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceTypeIncompatible"},
786cc9139ecSJason M. Bills         {"Message", "The @odata.type of the request body " + arg1 +
787cc9139ecSJason M. Bills                         " is incompatible with the @odata.type of the "
788cc9139ecSJason M. Bills                         "resource which is " +
789cc9139ecSJason M. Bills                         arg2 + "."},
79085659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
791684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
792cc9139ecSJason M. Bills         {"Resolution", "Resubmit the request with a payload compatible "
793b5c07418SJames Feist                        "with the resource's schema."}};
794b5c07418SJames Feist }
795b5c07418SJames Feist 
796b5c07418SJames Feist void resourceTypeIncompatible(crow::Response& res, const std::string& arg1,
797b5c07418SJames Feist                               const std::string& arg2)
798b5c07418SJames Feist {
799b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
800b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
801cc9139ecSJason M. Bills }
802cc9139ecSJason M. Bills 
803cc9139ecSJason M. Bills /**
804cc9139ecSJason M. Bills  * @internal
805684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
806684bb4b8SJason M. Bills  *
807684bb4b8SJason M. Bills  * See header file for more information
808684bb4b8SJason M. Bills  * @endinternal
809684bb4b8SJason M. Bills  */
810*ace85d60SEd Tanous nlohmann::json resetRequired(const boost::urls::url_view& arg1,
811*ace85d60SEd Tanous                              const std::string& arg2)
812684bb4b8SJason M. Bills {
813*ace85d60SEd Tanous     std::string url(arg1.data(), arg1.size());
814684bb4b8SJason M. Bills     return nlohmann::json{
8153e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
816684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResetRequired"},
817684bb4b8SJason M. Bills         {"Message", "In order to complete the operation, a component reset is "
818684bb4b8SJason M. Bills                     "required with the Reset action URI '" +
819*ace85d60SEd Tanous                         url + "' and ResetType '" + arg2 + "'."},
820*ace85d60SEd Tanous         {"MessageArgs", {url, arg2}},
821684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
822684bb4b8SJason M. Bills         {"Resolution",
823684bb4b8SJason M. Bills          "Perform the required Reset action on the specified component."}};
824684bb4b8SJason M. Bills }
825684bb4b8SJason M. Bills 
826*ace85d60SEd Tanous void resetRequired(crow::Response& res, const boost::urls::url_view& arg1,
827684bb4b8SJason M. Bills                    const std::string& arg2)
828684bb4b8SJason M. Bills {
829684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
830684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
831684bb4b8SJason M. Bills }
832684bb4b8SJason M. Bills 
833684bb4b8SJason M. Bills /**
834684bb4b8SJason M. Bills  * @internal
835684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
836684bb4b8SJason M. Bills  *
837684bb4b8SJason M. Bills  * See header file for more information
838684bb4b8SJason M. Bills  * @endinternal
839684bb4b8SJason M. Bills  */
840684bb4b8SJason M. Bills nlohmann::json chassisPowerStateOnRequired(const std::string& arg1)
841684bb4b8SJason M. Bills {
842684bb4b8SJason M. Bills     return nlohmann::json{
8433e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
844684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ChassisPowerStateOnRequired"},
845684bb4b8SJason M. Bills         {"Message", "The Chassis with Id '" + arg1 +
846684bb4b8SJason M. Bills                         "' requires to be powered on to perform this request."},
847684bb4b8SJason M. Bills         {"MessageArgs", {arg1}},
848684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
849684bb4b8SJason M. Bills         {"Resolution",
850684bb4b8SJason M. Bills          "Power on the specified Chassis and resubmit the request."}};
851684bb4b8SJason M. Bills }
852684bb4b8SJason M. Bills 
853684bb4b8SJason M. Bills void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1)
854684bb4b8SJason M. Bills {
855684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
856684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
857684bb4b8SJason M. Bills }
858684bb4b8SJason M. Bills 
859684bb4b8SJason M. Bills /**
860684bb4b8SJason M. Bills  * @internal
861684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
862684bb4b8SJason M. Bills  *
863684bb4b8SJason M. Bills  * See header file for more information
864684bb4b8SJason M. Bills  * @endinternal
865684bb4b8SJason M. Bills  */
866684bb4b8SJason M. Bills nlohmann::json chassisPowerStateOffRequired(const std::string& arg1)
867684bb4b8SJason M. Bills {
868684bb4b8SJason M. Bills     return nlohmann::json{
8693e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
870684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ChassisPowerStateOffRequired"},
871684bb4b8SJason M. Bills         {"Message",
872684bb4b8SJason M. Bills          "The Chassis with Id '" + arg1 +
873684bb4b8SJason M. Bills              "' requires to be powered off to perform this request."},
874684bb4b8SJason M. Bills         {"MessageArgs", {arg1}},
875684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
876684bb4b8SJason M. Bills         {"Resolution",
877684bb4b8SJason M. Bills          "Power off the specified Chassis and resubmit the request."}};
878684bb4b8SJason M. Bills }
879684bb4b8SJason M. Bills 
880684bb4b8SJason M. Bills void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1)
881684bb4b8SJason M. Bills {
882684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
883684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
884684bb4b8SJason M. Bills }
885684bb4b8SJason M. Bills 
886684bb4b8SJason M. Bills /**
887684bb4b8SJason M. Bills  * @internal
888684bb4b8SJason M. Bills  * @brief Formats PropertyValueConflict message into JSON
889684bb4b8SJason M. Bills  *
890684bb4b8SJason M. Bills  * See header file for more information
891684bb4b8SJason M. Bills  * @endinternal
892684bb4b8SJason M. Bills  */
893684bb4b8SJason M. Bills nlohmann::json propertyValueConflict(const std::string& arg1,
894684bb4b8SJason M. Bills                                      const std::string& arg2)
895684bb4b8SJason M. Bills {
896684bb4b8SJason M. Bills     return nlohmann::json{
8973e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
898684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueConflict"},
899684bb4b8SJason M. Bills         {"Message", "The property '" + arg1 +
900684bb4b8SJason M. Bills                         "' could not be written because its value would "
901684bb4b8SJason M. Bills                         "conflict with the value of the '" +
902684bb4b8SJason M. Bills                         arg2 + "' property."},
903684bb4b8SJason M. Bills         {"MessageArgs", {arg1, arg2}},
904684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
905684bb4b8SJason M. Bills         {"Resolution", "No resolution is required."}};
906684bb4b8SJason M. Bills }
907684bb4b8SJason M. Bills 
908684bb4b8SJason M. Bills void propertyValueConflict(crow::Response& res, const std::string& arg1,
909684bb4b8SJason M. Bills                            const std::string& arg2)
910684bb4b8SJason M. Bills {
911684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
912684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
913684bb4b8SJason M. Bills }
914684bb4b8SJason M. Bills 
915684bb4b8SJason M. Bills /**
916684bb4b8SJason M. Bills  * @internal
917684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
918684bb4b8SJason M. Bills  *
919684bb4b8SJason M. Bills  * See header file for more information
920684bb4b8SJason M. Bills  * @endinternal
921684bb4b8SJason M. Bills  */
922684bb4b8SJason M. Bills nlohmann::json propertyValueIncorrect(const std::string& arg1,
923684bb4b8SJason M. Bills                                       const std::string& arg2)
924684bb4b8SJason M. Bills {
925684bb4b8SJason M. Bills     return nlohmann::json{
9263e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
927684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueIncorrect"},
928684bb4b8SJason M. Bills         {"Message", "The property '" + arg1 +
929684bb4b8SJason M. Bills                         "' with the requested value of '" + arg2 +
930684bb4b8SJason M. Bills                         "' could not be written because the value does not "
931684bb4b8SJason M. Bills                         "meet the constraints of the implementation."},
932684bb4b8SJason M. Bills         {"MessageArgs", {arg1, arg2}},
933684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
934684bb4b8SJason M. Bills         {"Resolution", "No resolution is required."}};
935684bb4b8SJason M. Bills }
936684bb4b8SJason M. Bills 
937684bb4b8SJason M. Bills void propertyValueIncorrect(crow::Response& res, const std::string& arg1,
938684bb4b8SJason M. Bills                             const std::string& arg2)
939684bb4b8SJason M. Bills {
940684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
941684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
942684bb4b8SJason M. Bills }
943684bb4b8SJason M. Bills 
944684bb4b8SJason M. Bills /**
945684bb4b8SJason M. Bills  * @internal
946684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
947684bb4b8SJason M. Bills  *
948684bb4b8SJason M. Bills  * See header file for more information
949684bb4b8SJason M. Bills  * @endinternal
950684bb4b8SJason M. Bills  */
951*ace85d60SEd Tanous nlohmann::json resourceCreationConflict(const boost::urls::url_view& arg1)
952684bb4b8SJason M. Bills {
953*ace85d60SEd Tanous     std::string url(arg1.data(), arg1.size());
954684bb4b8SJason M. Bills     return nlohmann::json{
9553e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
956684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceCreationConflict"},
957684bb4b8SJason M. Bills         {"Message", "The resource could not be created.  The service has a "
958684bb4b8SJason M. Bills                     "resource at URI '" +
959*ace85d60SEd Tanous                         url + "' that conflicts with the creation request."},
960*ace85d60SEd Tanous         {"MessageArgs", {url}},
961684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
962684bb4b8SJason M. Bills         {"Resolution", "No resolution is required."}};
963684bb4b8SJason M. Bills }
964684bb4b8SJason M. Bills 
965*ace85d60SEd Tanous void resourceCreationConflict(crow::Response& res,
966*ace85d60SEd Tanous                               const boost::urls::url_view& arg1)
967684bb4b8SJason M. Bills {
968684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
969684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
970684bb4b8SJason M. Bills }
971684bb4b8SJason M. Bills 
972684bb4b8SJason M. Bills /**
973684bb4b8SJason M. Bills  * @internal
974684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded message into JSON
975684bb4b8SJason M. Bills  *
976684bb4b8SJason M. Bills  * See header file for more information
977684bb4b8SJason M. Bills  * @endinternal
978684bb4b8SJason M. Bills  */
979684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void)
980684bb4b8SJason M. Bills {
981684bb4b8SJason M. Bills     return nlohmann::json{
9823e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
983684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.MaximumErrorsExceeded"},
984684bb4b8SJason M. Bills         {"Message", "Too many errors have occurred to report them all."},
985684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
986684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
987684bb4b8SJason M. Bills         {"Resolution",
988684bb4b8SJason M. Bills          "Resolve other reported errors and retry the current operation."}};
989684bb4b8SJason M. Bills }
990684bb4b8SJason M. Bills 
991684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
992684bb4b8SJason M. Bills {
993684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
994684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
995684bb4b8SJason M. Bills }
996684bb4b8SJason M. Bills 
997684bb4b8SJason M. Bills /**
998684bb4b8SJason M. Bills  * @internal
999684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
1000684bb4b8SJason M. Bills  *
1001684bb4b8SJason M. Bills  * See header file for more information
1002684bb4b8SJason M. Bills  * @endinternal
1003684bb4b8SJason M. Bills  */
1004684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void)
1005684bb4b8SJason M. Bills {
1006684bb4b8SJason M. Bills     return nlohmann::json{
10073e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1008684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PreconditionFailed"},
1009684bb4b8SJason M. Bills         {"Message", "The ETag supplied did not match the ETag required to "
1010684bb4b8SJason M. Bills                     "change this resource."},
1011684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1012684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1013684bb4b8SJason M. Bills         {"Resolution", "Try the operation again using the appropriate ETag."}};
1014684bb4b8SJason M. Bills }
1015684bb4b8SJason M. Bills 
1016684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
1017684bb4b8SJason M. Bills {
10184df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
1019684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
1020684bb4b8SJason M. Bills }
1021684bb4b8SJason M. Bills 
1022684bb4b8SJason M. Bills /**
1023684bb4b8SJason M. Bills  * @internal
1024684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
1025684bb4b8SJason M. Bills  *
1026684bb4b8SJason M. Bills  * See header file for more information
1027684bb4b8SJason M. Bills  * @endinternal
1028684bb4b8SJason M. Bills  */
1029684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void)
1030684bb4b8SJason M. Bills {
1031684bb4b8SJason M. Bills     return nlohmann::json{
10323e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1033684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PreconditionRequired"},
1034684bb4b8SJason M. Bills         {"Message", "A precondition header or annotation is required to change "
1035684bb4b8SJason M. Bills                     "this resource."},
1036684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1037684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1038684bb4b8SJason M. Bills         {"Resolution", "Try the operation again using an If-Match or "
1039684bb4b8SJason M. Bills                        "If-None-Match header and appropriate ETag."}};
1040684bb4b8SJason M. Bills }
1041684bb4b8SJason M. Bills 
1042684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
1043684bb4b8SJason M. Bills {
1044684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1045684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
1046684bb4b8SJason M. Bills }
1047684bb4b8SJason M. Bills 
1048684bb4b8SJason M. Bills /**
1049684bb4b8SJason M. Bills  * @internal
1050684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
1051684bb4b8SJason M. Bills  *
1052684bb4b8SJason M. Bills  * See header file for more information
1053684bb4b8SJason M. Bills  * @endinternal
1054684bb4b8SJason M. Bills  */
1055684bb4b8SJason M. Bills nlohmann::json operationFailed(void)
1056684bb4b8SJason M. Bills {
1057684bb4b8SJason M. Bills     return nlohmann::json{
10583e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1059684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.OperationFailed"},
1060684bb4b8SJason M. Bills         {"Message",
1061684bb4b8SJason M. Bills          "An error occurred internal to the service as part of the overall "
1062684bb4b8SJason M. Bills          "request.  Partial results may have been returned."},
1063684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1064684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1065684bb4b8SJason M. Bills         {"Resolution", "Resubmit the request.  If the problem persists, "
1066684bb4b8SJason M. Bills                        "consider resetting the service or provider."}};
1067684bb4b8SJason M. Bills }
1068684bb4b8SJason M. Bills 
1069684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
1070684bb4b8SJason M. Bills {
1071684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
1072684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
1073684bb4b8SJason M. Bills }
1074684bb4b8SJason M. Bills 
1075684bb4b8SJason M. Bills /**
1076684bb4b8SJason M. Bills  * @internal
1077684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
1078684bb4b8SJason M. Bills  *
1079684bb4b8SJason M. Bills  * See header file for more information
1080684bb4b8SJason M. Bills  * @endinternal
1081684bb4b8SJason M. Bills  */
1082684bb4b8SJason M. Bills nlohmann::json operationTimeout(void)
1083684bb4b8SJason M. Bills {
1084684bb4b8SJason M. Bills     return nlohmann::json{
10853e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1086684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.OperationTimeout"},
1087684bb4b8SJason M. Bills         {"Message", "A timeout internal to the service occured as part of the "
1088684bb4b8SJason M. Bills                     "request.  Partial results may have been returned."},
1089684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1090684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1091684bb4b8SJason M. Bills         {"Resolution", "Resubmit the request.  If the problem persists, "
1092684bb4b8SJason M. Bills                        "consider resetting the service or provider."}};
1093684bb4b8SJason M. Bills }
1094684bb4b8SJason M. Bills 
1095684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
1096684bb4b8SJason M. Bills {
1097684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
1098684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
1099684bb4b8SJason M. Bills }
1100684bb4b8SJason M. Bills 
1101684bb4b8SJason M. Bills /**
1102684bb4b8SJason M. Bills  * @internal
1103f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
1104f12894f8SJason M. Bills  * property
1105f12894f8SJason M. Bills  *
1106f12894f8SJason M. Bills  * See header file for more information
1107f12894f8SJason M. Bills  * @endinternal
1108f12894f8SJason M. Bills  */
1109b5c07418SJames Feist nlohmann::json propertyValueTypeError(const std::string& arg1,
1110a08b46ccSJason M. Bills                                       const std::string& arg2)
1111f12894f8SJason M. Bills {
1112b5c07418SJames Feist     return nlohmann::json{
11133e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1114684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueTypeError"},
1115f12894f8SJason M. Bills         {"Message",
1116f12894f8SJason M. Bills          "The value " + arg1 + " for the property " + arg2 +
1117f12894f8SJason M. Bills              " is of a different type than the property can accept."},
111885659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1119684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
112066ac2b8cSJason M. Bills         {"Resolution",
112166ac2b8cSJason M. Bills          "Correct the value for the property in the request body and "
1122b5c07418SJames Feist          "resubmit the request if the operation failed."}};
1123b5c07418SJames Feist }
1124b5c07418SJames Feist 
1125b5c07418SJames Feist void propertyValueTypeError(crow::Response& res, const std::string& arg1,
1126b5c07418SJames Feist                             const std::string& arg2)
1127b5c07418SJames Feist {
1128b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1129b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
1130f4c4dcf4SKowalski, Kamil }
1131f4c4dcf4SKowalski, Kamil 
1132f4c4dcf4SKowalski, Kamil /**
1133f4c4dcf4SKowalski, Kamil  * @internal
1134f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceNotFound message into JSON
1135f4c4dcf4SKowalski, Kamil  *
1136f4c4dcf4SKowalski, Kamil  * See header file for more information
1137f4c4dcf4SKowalski, Kamil  * @endinternal
1138f4c4dcf4SKowalski, Kamil  */
1139b5c07418SJames Feist nlohmann::json resourceNotFound(const std::string& arg1,
11401abe55efSEd Tanous                                 const std::string& arg2)
11411abe55efSEd Tanous {
1142b5c07418SJames Feist     return nlohmann::json{
11433e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1144684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceNotFound"},
11451abe55efSEd Tanous         {"Message", "The requested resource of type " + arg1 + " named " +
11461abe55efSEd Tanous                         arg2 + " was not found."},
114785659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1148684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1149f4c4dcf4SKowalski, Kamil         {"Resolution",
1150b5c07418SJames Feist          "Provide a valid resource identifier and resubmit the request."}};
1151b5c07418SJames Feist }
1152b5c07418SJames Feist 
1153b5c07418SJames Feist void resourceNotFound(crow::Response& res, const std::string& arg1,
1154b5c07418SJames Feist                       const std::string& arg2)
1155b5c07418SJames Feist {
1156b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1157b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
1158f4c4dcf4SKowalski, Kamil }
1159f4c4dcf4SKowalski, Kamil 
1160f4c4dcf4SKowalski, Kamil /**
1161f4c4dcf4SKowalski, Kamil  * @internal
1162f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
1163f4c4dcf4SKowalski, Kamil  *
1164f4c4dcf4SKowalski, Kamil  * See header file for more information
1165f4c4dcf4SKowalski, Kamil  * @endinternal
1166f4c4dcf4SKowalski, Kamil  */
1167*ace85d60SEd Tanous nlohmann::json couldNotEstablishConnection(const boost::urls::url_view& arg1)
11681abe55efSEd Tanous {
1169*ace85d60SEd Tanous     std::string url(arg1.data(), arg1.size());
1170b5c07418SJames Feist     return nlohmann::json{
11713e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1172684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.CouldNotEstablishConnection"},
11731abe55efSEd Tanous         {"Message",
1174*ace85d60SEd Tanous          "The service failed to establish a connection with the URI " + url +
1175b5c07418SJames Feist              "."},
1176*ace85d60SEd Tanous         {"MessageArgs", {url}},
1177684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
117866ac2b8cSJason M. Bills         {"Resolution",
117966ac2b8cSJason M. Bills          "Ensure that the URI contains a valid and reachable node name, "
1180b5c07418SJames Feist          "protocol information and other URI components."}};
1181b5c07418SJames Feist }
1182b5c07418SJames Feist 
1183*ace85d60SEd Tanous void couldNotEstablishConnection(crow::Response& res,
1184*ace85d60SEd Tanous                                  const boost::urls::url_view& arg1)
1185b5c07418SJames Feist {
1186b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1187b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
1188f4c4dcf4SKowalski, Kamil }
1189f4c4dcf4SKowalski, Kamil 
1190f4c4dcf4SKowalski, Kamil /**
1191f4c4dcf4SKowalski, Kamil  * @internal
1192f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
1193f12894f8SJason M. Bills  * property
1194f12894f8SJason M. Bills  *
1195f12894f8SJason M. Bills  * See header file for more information
1196f12894f8SJason M. Bills  * @endinternal
1197f12894f8SJason M. Bills  */
1198b5c07418SJames Feist nlohmann::json propertyNotWritable(const std::string& arg1)
1199f12894f8SJason M. Bills {
1200b5c07418SJames Feist     return nlohmann::json{
12013e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1202684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyNotWritable"},
1203b5c07418SJames Feist         {"Message", "The property " + arg1 +
1204b5c07418SJames Feist                         " is a read only property and cannot be "
1205b5c07418SJames Feist                         "assigned a value."},
120685659adfSJason M. Bills         {"MessageArgs", {arg1}},
1207684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
120866ac2b8cSJason M. Bills         {"Resolution", "Remove the property from the request body and "
1209b5c07418SJames Feist                        "resubmit the request if the operation failed."}};
1210b5c07418SJames Feist }
1211b5c07418SJames Feist 
1212b5c07418SJames Feist void propertyNotWritable(crow::Response& res, const std::string& arg1)
1213b5c07418SJames Feist {
1214b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1215b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1216f4c4dcf4SKowalski, Kamil }
1217f4c4dcf4SKowalski, Kamil 
1218f4c4dcf4SKowalski, Kamil /**
1219f4c4dcf4SKowalski, Kamil  * @internal
1220f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
1221f4c4dcf4SKowalski, Kamil  *
1222f4c4dcf4SKowalski, Kamil  * See header file for more information
1223f4c4dcf4SKowalski, Kamil  * @endinternal
1224f4c4dcf4SKowalski, Kamil  */
1225b5c07418SJames Feist nlohmann::json queryParameterValueTypeError(const std::string& arg1,
12261abe55efSEd Tanous                                             const std::string& arg2)
12271abe55efSEd Tanous {
1228b5c07418SJames Feist     return nlohmann::json{
12293e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1230684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryParameterValueTypeError"},
12311abe55efSEd Tanous         {"Message",
12321abe55efSEd Tanous          "The value " + arg1 + " for the query parameter " + arg2 +
1233f4c4dcf4SKowalski, Kamil              " is of a different type than the parameter can accept."},
123485659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1235684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
123666ac2b8cSJason M. Bills         {"Resolution",
123766ac2b8cSJason M. Bills          "Correct the value for the query parameter in the request and "
1238b5c07418SJames Feist          "resubmit the request if the operation failed."}};
1239b5c07418SJames Feist }
1240b5c07418SJames Feist 
1241b5c07418SJames Feist void queryParameterValueTypeError(crow::Response& res, const std::string& arg1,
1242b5c07418SJames Feist                                   const std::string& arg2)
1243b5c07418SJames Feist {
1244b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1245b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1246b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
1247f4c4dcf4SKowalski, Kamil }
1248f4c4dcf4SKowalski, Kamil 
1249f4c4dcf4SKowalski, Kamil /**
1250f4c4dcf4SKowalski, Kamil  * @internal
1251f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
1252f4c4dcf4SKowalski, Kamil  *
1253f4c4dcf4SKowalski, Kamil  * See header file for more information
1254f4c4dcf4SKowalski, Kamil  * @endinternal
1255f4c4dcf4SKowalski, Kamil  */
1256b5c07418SJames Feist nlohmann::json serviceShuttingDown(void)
12571abe55efSEd Tanous {
1258b5c07418SJames Feist     return nlohmann::json{
12593e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1260684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ServiceShuttingDown"},
1261f12894f8SJason M. Bills         {"Message", "The operation failed because the service is shutting "
126266ac2b8cSJason M. Bills                     "down and can no longer take incoming requests."},
126385659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1264684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
126566ac2b8cSJason M. Bills         {"Resolution", "When the service becomes available, resubmit the "
1266b5c07418SJames Feist                        "request if the operation failed."}};
1267b5c07418SJames Feist }
1268b5c07418SJames Feist 
1269b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
1270b5c07418SJames Feist {
1271b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1272b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1273f4c4dcf4SKowalski, Kamil }
1274f4c4dcf4SKowalski, Kamil 
1275f4c4dcf4SKowalski, Kamil /**
1276f4c4dcf4SKowalski, Kamil  * @internal
1277f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
1278f4c4dcf4SKowalski, Kamil  *
1279f4c4dcf4SKowalski, Kamil  * See header file for more information
1280f4c4dcf4SKowalski, Kamil  * @endinternal
1281f4c4dcf4SKowalski, Kamil  */
1282b5c07418SJames Feist nlohmann::json actionParameterDuplicate(const std::string& arg1,
12831abe55efSEd Tanous                                         const std::string& arg2)
12841abe55efSEd Tanous {
1285b5c07418SJames Feist     return nlohmann::json{
12863e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1287684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterDuplicate"},
1288f4c4dcf4SKowalski, Kamil         {"Message",
1289f4c4dcf4SKowalski, Kamil          "The action " + arg1 +
12901abe55efSEd Tanous              " was submitted with more than one value for the parameter " +
12911abe55efSEd Tanous              arg2 + "."},
129285659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1293684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
129466ac2b8cSJason M. Bills         {"Resolution",
129566ac2b8cSJason M. Bills          "Resubmit the action with only one instance of the parameter in "
1296b5c07418SJames Feist          "the request body if the operation failed."}};
1297b5c07418SJames Feist }
1298b5c07418SJames Feist 
1299b5c07418SJames Feist void actionParameterDuplicate(crow::Response& res, const std::string& arg1,
1300b5c07418SJames Feist                               const std::string& arg2)
1301b5c07418SJames Feist {
1302b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1303b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1304f4c4dcf4SKowalski, Kamil }
1305f4c4dcf4SKowalski, Kamil 
1306f4c4dcf4SKowalski, Kamil /**
1307f4c4dcf4SKowalski, Kamil  * @internal
1308f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1309f4c4dcf4SKowalski, Kamil  *
1310f4c4dcf4SKowalski, Kamil  * See header file for more information
1311f4c4dcf4SKowalski, Kamil  * @endinternal
1312f4c4dcf4SKowalski, Kamil  */
1313b5c07418SJames Feist nlohmann::json actionParameterNotSupported(const std::string& arg1,
13141abe55efSEd Tanous                                            const std::string& arg2)
13151abe55efSEd Tanous {
1316b5c07418SJames Feist     return nlohmann::json{
13173e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1318684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterNotSupported"},
1319f4c4dcf4SKowalski, Kamil         {"Message", "The parameter " + arg1 + " for the action " + arg2 +
1320f4c4dcf4SKowalski, Kamil                         " is not supported on the target resource."},
132185659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1322684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
132366ac2b8cSJason M. Bills         {"Resolution", "Remove the parameter supplied and resubmit the "
1324b5c07418SJames Feist                        "request if the operation failed."}};
1325b5c07418SJames Feist }
1326b5c07418SJames Feist 
1327b5c07418SJames Feist void actionParameterNotSupported(crow::Response& res, const std::string& arg1,
1328b5c07418SJames Feist                                  const std::string& arg2)
1329b5c07418SJames Feist {
1330b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1331b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1332b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1333f4c4dcf4SKowalski, Kamil }
1334f4c4dcf4SKowalski, Kamil 
1335f4c4dcf4SKowalski, Kamil /**
1336f4c4dcf4SKowalski, Kamil  * @internal
1337f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1338f4c4dcf4SKowalski, Kamil  *
1339f4c4dcf4SKowalski, Kamil  * See header file for more information
1340f4c4dcf4SKowalski, Kamil  * @endinternal
1341f4c4dcf4SKowalski, Kamil  */
1342*ace85d60SEd Tanous nlohmann::json sourceDoesNotSupportProtocol(const boost::urls::url_view& arg1,
13431abe55efSEd Tanous                                             const std::string& arg2)
13441abe55efSEd Tanous {
1345*ace85d60SEd Tanous     std::string url(arg1.data(), arg1.size());
1346b5c07418SJames Feist     return nlohmann::json{
13473e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1348684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.SourceDoesNotSupportProtocol"},
1349*ace85d60SEd Tanous         {"Message", "The other end of the connection at " + url +
13501abe55efSEd Tanous                         " does not support the specified protocol " + arg2 +
13511abe55efSEd Tanous                         "."},
1352*ace85d60SEd Tanous         {"MessageArgs", {url, arg2}},
1353684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1354b5c07418SJames Feist         {"Resolution", "Change protocols or URIs. "}};
1355b5c07418SJames Feist }
1356b5c07418SJames Feist 
1357*ace85d60SEd Tanous void sourceDoesNotSupportProtocol(crow::Response& res,
1358*ace85d60SEd Tanous                                   const boost::urls::url_view& arg1,
1359b5c07418SJames Feist                                   const std::string& arg2)
1360b5c07418SJames Feist {
1361b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1362b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1363b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1364f4c4dcf4SKowalski, Kamil }
1365f4c4dcf4SKowalski, Kamil 
1366f4c4dcf4SKowalski, Kamil /**
1367f4c4dcf4SKowalski, Kamil  * @internal
1368f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1369f4c4dcf4SKowalski, Kamil  *
1370f4c4dcf4SKowalski, Kamil  * See header file for more information
1371f4c4dcf4SKowalski, Kamil  * @endinternal
1372f4c4dcf4SKowalski, Kamil  */
1373b5c07418SJames Feist nlohmann::json accountRemoved(void)
13741abe55efSEd Tanous {
13753e082749SAsmitha Karunanithi     return nlohmann::json{{"@odata.type", "#Message.v1_1_1.Message"},
1376684bb4b8SJason M. Bills                           {"MessageId", "Base.1.8.1.AccountRemoved"},
1377f4c4dcf4SKowalski, Kamil                           {"Message", "The account was successfully removed."},
137885659adfSJason M. Bills                           {"MessageArgs", nlohmann::json::array()},
1379684bb4b8SJason M. Bills                           {"MessageSeverity", "OK"},
1380b5c07418SJames Feist                           {"Resolution", "No resolution is required."}};
1381b5c07418SJames Feist }
1382b5c07418SJames Feist 
1383b5c07418SJames Feist void accountRemoved(crow::Response& res)
1384b5c07418SJames Feist {
1385b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1386b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1387f4c4dcf4SKowalski, Kamil }
1388f4c4dcf4SKowalski, Kamil 
1389f4c4dcf4SKowalski, Kamil /**
1390f4c4dcf4SKowalski, Kamil  * @internal
1391f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1392f4c4dcf4SKowalski, Kamil  *
1393f4c4dcf4SKowalski, Kamil  * See header file for more information
1394f4c4dcf4SKowalski, Kamil  * @endinternal
1395f4c4dcf4SKowalski, Kamil  */
1396*ace85d60SEd Tanous nlohmann::json accessDenied(const boost::urls::url_view& arg1)
13971abe55efSEd Tanous {
1398*ace85d60SEd Tanous     std::string url(arg1.data(), arg1.size());
1399b5c07418SJames Feist     return nlohmann::json{
14003e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1401684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.AccessDenied"},
1402*ace85d60SEd Tanous         {"Message", "While attempting to establish a connection to " + url +
1403b5c07418SJames Feist                         ", the service denied access."},
1404*ace85d60SEd Tanous         {"MessageArgs", {url}},
1405684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
140666ac2b8cSJason M. Bills         {"Resolution", "Attempt to ensure that the URI is correct and that "
1407b5c07418SJames Feist                        "the service has the appropriate credentials."}};
1408b5c07418SJames Feist }
1409b5c07418SJames Feist 
1410*ace85d60SEd Tanous void accessDenied(crow::Response& res, const boost::urls::url_view& arg1)
1411b5c07418SJames Feist {
1412b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1413b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1414f4c4dcf4SKowalski, Kamil }
1415f4c4dcf4SKowalski, Kamil 
1416f4c4dcf4SKowalski, Kamil /**
1417f4c4dcf4SKowalski, Kamil  * @internal
1418f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1419f4c4dcf4SKowalski, Kamil  *
1420f4c4dcf4SKowalski, Kamil  * See header file for more information
1421f4c4dcf4SKowalski, Kamil  * @endinternal
1422f4c4dcf4SKowalski, Kamil  */
1423b5c07418SJames Feist nlohmann::json queryNotSupported(void)
14241abe55efSEd Tanous {
1425b5c07418SJames Feist     return nlohmann::json{
14263e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1427684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryNotSupported"},
1428f4c4dcf4SKowalski, Kamil         {"Message", "Querying is not supported by the implementation."},
142985659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1430684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
143166ac2b8cSJason M. Bills         {"Resolution", "Remove the query parameters and resubmit the "
1432b5c07418SJames Feist                        "request if the operation failed."}};
1433b5c07418SJames Feist }
1434b5c07418SJames Feist 
1435b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1436b5c07418SJames Feist {
1437b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1438b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1439f4c4dcf4SKowalski, Kamil }
1440f4c4dcf4SKowalski, Kamil 
1441f4c4dcf4SKowalski, Kamil /**
1442f4c4dcf4SKowalski, Kamil  * @internal
1443f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1444f4c4dcf4SKowalski, Kamil  *
1445f4c4dcf4SKowalski, Kamil  * See header file for more information
1446f4c4dcf4SKowalski, Kamil  * @endinternal
1447f4c4dcf4SKowalski, Kamil  */
1448b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void)
14491abe55efSEd Tanous {
1450b5c07418SJames Feist     return nlohmann::json{
14513e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1452684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.CreateLimitReachedForResource"},
14531abe55efSEd Tanous         {"Message", "The create operation failed because the resource has "
145466ac2b8cSJason M. Bills                     "reached the limit of possible resources."},
145585659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1456684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
145766ac2b8cSJason M. Bills         {"Resolution",
145866ac2b8cSJason M. Bills          "Either delete resources and resubmit the request if the "
1459b5c07418SJames Feist          "operation failed or do not resubmit the request."}};
1460b5c07418SJames Feist }
1461b5c07418SJames Feist 
1462b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1463b5c07418SJames Feist {
1464b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1465b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1466f4c4dcf4SKowalski, Kamil }
1467f4c4dcf4SKowalski, Kamil 
1468f4c4dcf4SKowalski, Kamil /**
1469f4c4dcf4SKowalski, Kamil  * @internal
1470f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1471f4c4dcf4SKowalski, Kamil  *
1472f4c4dcf4SKowalski, Kamil  * See header file for more information
1473f4c4dcf4SKowalski, Kamil  * @endinternal
1474f4c4dcf4SKowalski, Kamil  */
1475b5c07418SJames Feist nlohmann::json generalError(void)
14761abe55efSEd Tanous {
14773e082749SAsmitha Karunanithi     return nlohmann::json{{"@odata.type", "#Message.v1_1_1.Message"},
1478684bb4b8SJason M. Bills                           {"MessageId", "Base.1.8.1.GeneralError"},
1479b7e069efSJames Feist                           {"Message",
1480b7e069efSJames Feist                            "A general error has occurred. See Resolution for "
1481cc9139ecSJason M. Bills                            "information on how to resolve the error."},
148285659adfSJason M. Bills                           {"MessageArgs", nlohmann::json::array()},
1483684bb4b8SJason M. Bills                           {"MessageSeverity", "Critical"},
1484b5c07418SJames Feist                           {"Resolution", "None."}};
1485b5c07418SJames Feist }
1486b5c07418SJames Feist 
1487b5c07418SJames Feist void generalError(crow::Response& res)
1488b5c07418SJames Feist {
1489b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1490b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1491f4c4dcf4SKowalski, Kamil }
1492f4c4dcf4SKowalski, Kamil 
1493f4c4dcf4SKowalski, Kamil /**
1494f4c4dcf4SKowalski, Kamil  * @internal
1495f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1496f4c4dcf4SKowalski, Kamil  *
1497f4c4dcf4SKowalski, Kamil  * See header file for more information
1498f4c4dcf4SKowalski, Kamil  * @endinternal
1499f4c4dcf4SKowalski, Kamil  */
1500b5c07418SJames Feist nlohmann::json success(void)
15011abe55efSEd Tanous {
15023e082749SAsmitha Karunanithi     return nlohmann::json{{"@odata.type", "#Message.v1_1_1.Message"},
1503684bb4b8SJason M. Bills                           {"MessageId", "Base.1.8.1.Success"},
1504f4c4dcf4SKowalski, Kamil                           {"Message", "Successfully Completed Request"},
150585659adfSJason M. Bills                           {"MessageArgs", nlohmann::json::array()},
1506684bb4b8SJason M. Bills                           {"MessageSeverity", "OK"},
1507b5c07418SJames Feist                           {"Resolution", "None"}};
1508b5c07418SJames Feist }
1509b5c07418SJames Feist 
1510b5c07418SJames Feist void success(crow::Response& res)
1511b5c07418SJames Feist {
1512b5c07418SJames Feist     // don't set res.result here because success is the default and any
1513b5c07418SJames Feist     // error should overwrite the default
1514b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1515f12894f8SJason M. Bills }
1516f12894f8SJason M. Bills 
1517f12894f8SJason M. Bills /**
1518f12894f8SJason M. Bills  * @internal
1519f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1520f4c4dcf4SKowalski, Kamil  *
1521f4c4dcf4SKowalski, Kamil  * See header file for more information
1522f4c4dcf4SKowalski, Kamil  * @endinternal
1523f4c4dcf4SKowalski, Kamil  */
1524b5c07418SJames Feist nlohmann::json created(void)
15251abe55efSEd Tanous {
1526b5c07418SJames Feist     return nlohmann::json{
15273e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1528684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.Created"},
1529f4c4dcf4SKowalski, Kamil         {"Message", "The resource has been created successfully"},
153085659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1531684bb4b8SJason M. Bills         {"MessageSeverity", "OK"},
1532b5c07418SJames Feist         {"Resolution", "None"}};
1533b5c07418SJames Feist }
1534b5c07418SJames Feist 
1535b5c07418SJames Feist void created(crow::Response& res)
1536b5c07418SJames Feist {
1537b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1538b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1539f4c4dcf4SKowalski, Kamil }
1540f4c4dcf4SKowalski, Kamil 
1541f4c4dcf4SKowalski, Kamil /**
1542f4c4dcf4SKowalski, Kamil  * @internal
1543cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1544cc9139ecSJason M. Bills  *
1545cc9139ecSJason M. Bills  * See header file for more information
1546cc9139ecSJason M. Bills  * @endinternal
1547cc9139ecSJason M. Bills  */
1548b5c07418SJames Feist nlohmann::json noOperation(void)
1549cc9139ecSJason M. Bills {
1550b5c07418SJames Feist     return nlohmann::json{
15513e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1552684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.NoOperation"},
1553cc9139ecSJason M. Bills         {"Message", "The request body submitted contain no data to act "
1554cc9139ecSJason M. Bills                     "upon and no changes to the resource took place."},
155585659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1556684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1557cc9139ecSJason M. Bills         {"Resolution",
1558b5c07418SJames Feist          "Add properties in the JSON object and resubmit the request."}};
1559b5c07418SJames Feist }
1560b5c07418SJames Feist 
1561b5c07418SJames Feist void noOperation(crow::Response& res)
1562b5c07418SJames Feist {
1563b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1564b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1565cc9139ecSJason M. Bills }
1566cc9139ecSJason M. Bills 
1567cc9139ecSJason M. Bills /**
1568cc9139ecSJason M. Bills  * @internal
1569b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1570b5c07418SJames Feist  * property
1571f12894f8SJason M. Bills  *
1572f12894f8SJason M. Bills  * See header file for more information
1573f12894f8SJason M. Bills  * @endinternal
1574f12894f8SJason M. Bills  */
1575b5c07418SJames Feist nlohmann::json propertyUnknown(const std::string& arg1)
1576b5c07418SJames Feist {
1577b5c07418SJames Feist     return nlohmann::json{
15783e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1579684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyUnknown"},
1580b5c07418SJames Feist         {"Message", "The property " + arg1 +
1581b5c07418SJames Feist                         " is not in the list of valid properties for "
1582b5c07418SJames Feist                         "the resource."},
1583b5c07418SJames Feist         {"MessageArgs", {arg1}},
1584684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1585b5c07418SJames Feist         {"Resolution", "Remove the unknown property from the request "
1586b5c07418SJames Feist                        "body and resubmit "
1587b5c07418SJames Feist                        "the request if the operation failed."}};
1588b5c07418SJames Feist }
1589b5c07418SJames Feist 
1590a08b46ccSJason M. Bills void propertyUnknown(crow::Response& res, const std::string& arg1)
1591f12894f8SJason M. Bills {
1592f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1593b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1);
1594f4c4dcf4SKowalski, Kamil }
1595f4c4dcf4SKowalski, Kamil 
1596f4c4dcf4SKowalski, Kamil /**
1597f4c4dcf4SKowalski, Kamil  * @internal
1598f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1599f4c4dcf4SKowalski, Kamil  *
1600f4c4dcf4SKowalski, Kamil  * See header file for more information
1601f4c4dcf4SKowalski, Kamil  * @endinternal
1602f4c4dcf4SKowalski, Kamil  */
1603b5c07418SJames Feist nlohmann::json noValidSession(void)
16041abe55efSEd Tanous {
1605b5c07418SJames Feist     return nlohmann::json{
16063e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1607684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.NoValidSession"},
1608f4c4dcf4SKowalski, Kamil         {"Message",
1609f4c4dcf4SKowalski, Kamil          "There is no valid session established with the implementation."},
161085659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1611684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
16121abe55efSEd Tanous         {"Resolution",
1613684bb4b8SJason M. Bills          "Establish a session before attempting any operations."}};
1614b5c07418SJames Feist }
1615b5c07418SJames Feist 
1616b5c07418SJames Feist void noValidSession(crow::Response& res)
1617b5c07418SJames Feist {
1618b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1619b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1620f4c4dcf4SKowalski, Kamil }
1621f4c4dcf4SKowalski, Kamil 
1622f4c4dcf4SKowalski, Kamil /**
1623f4c4dcf4SKowalski, Kamil  * @internal
1624f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1625f4c4dcf4SKowalski, Kamil  *
1626f4c4dcf4SKowalski, Kamil  * See header file for more information
1627f4c4dcf4SKowalski, Kamil  * @endinternal
1628f4c4dcf4SKowalski, Kamil  */
1629*ace85d60SEd Tanous nlohmann::json invalidObject(const boost::urls::url_view& arg1)
16301abe55efSEd Tanous {
1631*ace85d60SEd Tanous     std::string url(arg1.data(), arg1.size());
1632b5c07418SJames Feist     return nlohmann::json{
16333e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1634684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.InvalidObject"},
1635*ace85d60SEd Tanous         {"Message", "The object at " + url + " is invalid."},
1636*ace85d60SEd Tanous         {"MessageArgs", {url}},
1637684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1638f12894f8SJason M. Bills         {"Resolution",
163966ac2b8cSJason M. Bills          "Either the object is malformed or the URI is not correct.  "
1640b5c07418SJames Feist          "Correct the condition and resubmit the request if it failed."}};
1641b5c07418SJames Feist }
1642b5c07418SJames Feist 
1643*ace85d60SEd Tanous void invalidObject(crow::Response& res, const boost::urls::url_view& arg1)
1644b5c07418SJames Feist {
1645b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1646b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1647f4c4dcf4SKowalski, Kamil }
1648f4c4dcf4SKowalski, Kamil 
1649f4c4dcf4SKowalski, Kamil /**
1650f4c4dcf4SKowalski, Kamil  * @internal
1651f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1652f4c4dcf4SKowalski, Kamil  *
1653f4c4dcf4SKowalski, Kamil  * See header file for more information
1654f4c4dcf4SKowalski, Kamil  * @endinternal
1655f4c4dcf4SKowalski, Kamil  */
1656b5c07418SJames Feist nlohmann::json resourceInStandby(void)
16571abe55efSEd Tanous {
1658b5c07418SJames Feist     return nlohmann::json{
16593e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1660684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceInStandby"},
166166ac2b8cSJason M. Bills         {"Message", "The request could not be performed because the "
166266ac2b8cSJason M. Bills                     "resource is in standby."},
166385659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1664684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1665f12894f8SJason M. Bills         {"Resolution", "Ensure that the resource is in the correct power "
1666b5c07418SJames Feist                        "state and resubmit the request."}};
1667b5c07418SJames Feist }
1668b5c07418SJames Feist 
1669b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1670b5c07418SJames Feist {
1671b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1672b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1673f4c4dcf4SKowalski, Kamil }
1674f4c4dcf4SKowalski, Kamil 
1675f4c4dcf4SKowalski, Kamil /**
1676f4c4dcf4SKowalski, Kamil  * @internal
1677f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1678f4c4dcf4SKowalski, Kamil  *
1679f4c4dcf4SKowalski, Kamil  * See header file for more information
1680f4c4dcf4SKowalski, Kamil  * @endinternal
1681f4c4dcf4SKowalski, Kamil  */
1682b5c07418SJames Feist nlohmann::json actionParameterValueTypeError(const std::string& arg1,
1683f4c4dcf4SKowalski, Kamil                                              const std::string& arg2,
16841abe55efSEd Tanous                                              const std::string& arg3)
16851abe55efSEd Tanous {
1686b5c07418SJames Feist     return nlohmann::json{
16873e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1688684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterValueTypeError"},
16891abe55efSEd Tanous         {"Message",
16901abe55efSEd Tanous          "The value " + arg1 + " for the parameter " + arg2 +
1691f4c4dcf4SKowalski, Kamil              " in the action " + arg3 +
1692f4c4dcf4SKowalski, Kamil              " is of a different type than the parameter can accept."},
169385659adfSJason M. Bills         {"MessageArgs", {arg1, arg2, arg3}},
1694684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
169566ac2b8cSJason M. Bills         {"Resolution",
169666ac2b8cSJason M. Bills          "Correct the value for the parameter in the request body and "
1697b5c07418SJames Feist          "resubmit the request if the operation failed."}};
1698b5c07418SJames Feist }
1699b5c07418SJames Feist 
1700b5c07418SJames Feist void actionParameterValueTypeError(crow::Response& res, const std::string& arg1,
1701b5c07418SJames Feist                                    const std::string& arg2,
1702b5c07418SJames Feist                                    const std::string& arg3)
1703b5c07418SJames Feist {
1704b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1705b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1706b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1707f4c4dcf4SKowalski, Kamil }
1708f4c4dcf4SKowalski, Kamil 
1709f4c4dcf4SKowalski, Kamil /**
1710f4c4dcf4SKowalski, Kamil  * @internal
1711f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1712f4c4dcf4SKowalski, Kamil  *
1713f4c4dcf4SKowalski, Kamil  * See header file for more information
1714f4c4dcf4SKowalski, Kamil  * @endinternal
1715f4c4dcf4SKowalski, Kamil  */
1716b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void)
17171abe55efSEd Tanous {
1718b5c07418SJames Feist     return nlohmann::json{
17193e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1720684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.SessionLimitExceeded"},
1721f12894f8SJason M. Bills         {"Message", "The session establishment failed due to the number of "
172266ac2b8cSJason M. Bills                     "simultaneous sessions exceeding the limit of the "
172366ac2b8cSJason M. Bills                     "implementation."},
172485659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1725684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
172666ac2b8cSJason M. Bills         {"Resolution", "Reduce the number of other sessions before trying "
172766ac2b8cSJason M. Bills                        "to establish the session or increase the limit of "
1728b5c07418SJames Feist                        "simultaneous sessions (if supported)."}};
1729b5c07418SJames Feist }
1730b5c07418SJames Feist 
1731b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1732b5c07418SJames Feist {
1733b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1734b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1735f4c4dcf4SKowalski, Kamil }
1736f4c4dcf4SKowalski, Kamil 
1737f4c4dcf4SKowalski, Kamil /**
1738f4c4dcf4SKowalski, Kamil  * @internal
1739f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1740f4c4dcf4SKowalski, Kamil  *
1741f4c4dcf4SKowalski, Kamil  * See header file for more information
1742f4c4dcf4SKowalski, Kamil  * @endinternal
1743f4c4dcf4SKowalski, Kamil  */
1744b5c07418SJames Feist nlohmann::json actionNotSupported(const std::string& arg1)
17451abe55efSEd Tanous {
1746b5c07418SJames Feist     return nlohmann::json{
17473e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1748684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionNotSupported"},
17491abe55efSEd Tanous         {"Message",
17501abe55efSEd Tanous          "The action " + arg1 + " is not supported by the resource."},
175185659adfSJason M. Bills         {"MessageArgs", {arg1}},
1752684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1753f4c4dcf4SKowalski, Kamil         {"Resolution",
1754f4c4dcf4SKowalski, Kamil          "The action supplied cannot be resubmitted to the implementation. "
1755f12894f8SJason M. Bills          " Perhaps the action was invalid, the wrong resource was the "
175666ac2b8cSJason M. Bills          "target or the implementation documentation may be of "
1757b5c07418SJames Feist          "assistance."}};
1758b5c07418SJames Feist }
1759b5c07418SJames Feist 
1760b5c07418SJames Feist void actionNotSupported(crow::Response& res, const std::string& arg1)
1761b5c07418SJames Feist {
1762b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1763b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1764f4c4dcf4SKowalski, Kamil }
1765f4c4dcf4SKowalski, Kamil 
1766f4c4dcf4SKowalski, Kamil /**
1767f4c4dcf4SKowalski, Kamil  * @internal
1768f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1769f4c4dcf4SKowalski, Kamil  *
1770f4c4dcf4SKowalski, Kamil  * See header file for more information
1771f4c4dcf4SKowalski, Kamil  * @endinternal
1772f4c4dcf4SKowalski, Kamil  */
17735187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
17741abe55efSEd Tanous {
1775b5c07418SJames Feist     return nlohmann::json{
17763e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1777684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.InvalidIndex"},
1778684bb4b8SJason M. Bills         {"Message", "The Index " + std::to_string(arg1) +
1779f4c4dcf4SKowalski, Kamil                         " is not a valid offset into the array."},
178085659adfSJason M. Bills         {"MessageArgs", {std::to_string(arg1)}},
1781684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1782f12894f8SJason M. Bills         {"Resolution", "Verify the index value provided is within the "
1783b5c07418SJames Feist                        "bounds of the array."}};
1784b5c07418SJames Feist }
1785b5c07418SJames Feist 
17865187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1787b5c07418SJames Feist {
1788b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1789b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1790f4c4dcf4SKowalski, Kamil }
1791f4c4dcf4SKowalski, Kamil 
1792f4c4dcf4SKowalski, Kamil /**
1793f4c4dcf4SKowalski, Kamil  * @internal
1794f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1795f4c4dcf4SKowalski, Kamil  *
1796f4c4dcf4SKowalski, Kamil  * See header file for more information
1797f4c4dcf4SKowalski, Kamil  * @endinternal
1798f4c4dcf4SKowalski, Kamil  */
1799b5c07418SJames Feist nlohmann::json emptyJSON(void)
18001abe55efSEd Tanous {
1801b5c07418SJames Feist     return nlohmann::json{
18023e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1803684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.EmptyJSON"},
1804f12894f8SJason M. Bills         {"Message", "The request body submitted contained an empty JSON "
180566ac2b8cSJason M. Bills                     "object and the service is unable to process it."},
180685659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1807684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1808f4c4dcf4SKowalski, Kamil         {"Resolution",
1809b5c07418SJames Feist          "Add properties in the JSON object and resubmit the request."}};
1810b5c07418SJames Feist }
1811b5c07418SJames Feist 
1812b5c07418SJames Feist void emptyJSON(crow::Response& res)
1813b5c07418SJames Feist {
1814b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1815b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1816f4c4dcf4SKowalski, Kamil }
1817f4c4dcf4SKowalski, Kamil 
1818f4c4dcf4SKowalski, Kamil /**
1819f4c4dcf4SKowalski, Kamil  * @internal
1820f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1821f4c4dcf4SKowalski, Kamil  *
1822f4c4dcf4SKowalski, Kamil  * See header file for more information
1823f4c4dcf4SKowalski, Kamil  * @endinternal
1824f4c4dcf4SKowalski, Kamil  */
1825b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void)
18261abe55efSEd Tanous {
1827b5c07418SJames Feist     return nlohmann::json{
18283e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1829684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryNotSupportedOnResource"},
1830f4c4dcf4SKowalski, Kamil         {"Message", "Querying is not supported on the requested resource."},
183185659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1832684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
183366ac2b8cSJason M. Bills         {"Resolution", "Remove the query parameters and resubmit the "
1834b5c07418SJames Feist                        "request if the operation failed."}};
1835b5c07418SJames Feist }
1836b5c07418SJames Feist 
1837b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1838b5c07418SJames Feist {
1839b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1840b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1841f4c4dcf4SKowalski, Kamil }
1842f4c4dcf4SKowalski, Kamil 
1843f4c4dcf4SKowalski, Kamil /**
1844f4c4dcf4SKowalski, Kamil  * @internal
1845684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1846684bb4b8SJason M. Bills  *
1847684bb4b8SJason M. Bills  * See header file for more information
1848684bb4b8SJason M. Bills  * @endinternal
1849684bb4b8SJason M. Bills  */
1850684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void)
1851684bb4b8SJason M. Bills {
1852684bb4b8SJason M. Bills     return nlohmann::json{
18533e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1854684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryNotSupportedOnOperation"},
1855684bb4b8SJason M. Bills         {"Message", "Querying is not supported with the requested operation."},
1856684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1857684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1858684bb4b8SJason M. Bills         {"Resolution", "Remove the query parameters and resubmit the request "
1859684bb4b8SJason M. Bills                        "if the operation failed."}};
1860684bb4b8SJason M. Bills }
1861684bb4b8SJason M. Bills 
1862684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1863684bb4b8SJason M. Bills {
1864684bb4b8SJason M. Bills     res.result(boost::beast::http::status::forbidden);
1865684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1866684bb4b8SJason M. Bills }
1867684bb4b8SJason M. Bills 
1868684bb4b8SJason M. Bills /**
1869684bb4b8SJason M. Bills  * @internal
1870684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1871684bb4b8SJason M. Bills  *
1872684bb4b8SJason M. Bills  * See header file for more information
1873684bb4b8SJason M. Bills  * @endinternal
1874684bb4b8SJason M. Bills  */
1875684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void)
1876684bb4b8SJason M. Bills {
1877684bb4b8SJason M. Bills     return nlohmann::json{
18783e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1879684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryCombinationInvalid"},
1880684bb4b8SJason M. Bills         {"Message", "Two or more query parameters in the request cannot be "
1881684bb4b8SJason M. Bills                     "used together."},
1882684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1883684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1884684bb4b8SJason M. Bills         {"Resolution", "Remove one or more of the query parameters and "
1885684bb4b8SJason M. Bills                        "resubmit the request if the operation failed."}};
1886684bb4b8SJason M. Bills }
1887684bb4b8SJason M. Bills 
1888684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1889684bb4b8SJason M. Bills {
1890684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1891684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1892684bb4b8SJason M. Bills }
1893684bb4b8SJason M. Bills 
1894684bb4b8SJason M. Bills /**
1895684bb4b8SJason M. Bills  * @internal
1896f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1897f4c4dcf4SKowalski, Kamil  *
1898f4c4dcf4SKowalski, Kamil  * See header file for more information
1899f4c4dcf4SKowalski, Kamil  * @endinternal
1900f4c4dcf4SKowalski, Kamil  */
1901b5c07418SJames Feist nlohmann::json insufficientPrivilege(void)
19021abe55efSEd Tanous {
1903b5c07418SJames Feist     return nlohmann::json{
19043e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1905684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.InsufficientPrivilege"},
190666ac2b8cSJason M. Bills         {"Message", "There are insufficient privileges for the account or "
190766ac2b8cSJason M. Bills                     "credentials associated with the current session to "
190866ac2b8cSJason M. Bills                     "perform the requested operation."},
190985659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1910684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1911f4c4dcf4SKowalski, Kamil         {"Resolution",
1912f12894f8SJason M. Bills          "Either abandon the operation or change the associated access "
1913b5c07418SJames Feist          "rights and resubmit the request if the operation failed."}};
1914b5c07418SJames Feist }
1915b5c07418SJames Feist 
1916b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1917b5c07418SJames Feist {
1918b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1919b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1920f4c4dcf4SKowalski, Kamil }
1921f4c4dcf4SKowalski, Kamil 
1922f4c4dcf4SKowalski, Kamil /**
1923f4c4dcf4SKowalski, Kamil  * @internal
1924f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1925f4c4dcf4SKowalski, Kamil  *
1926f4c4dcf4SKowalski, Kamil  * See header file for more information
1927f4c4dcf4SKowalski, Kamil  * @endinternal
1928f4c4dcf4SKowalski, Kamil  */
1929b5c07418SJames Feist nlohmann::json propertyValueModified(const std::string& arg1,
1930b5c07418SJames Feist                                      const std::string& arg2)
1931b5c07418SJames Feist {
1932b5c07418SJames Feist     return nlohmann::json{
19333e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1934684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueModified"},
1935b5c07418SJames Feist         {"Message", "The property " + arg1 + " was assigned the value " + arg2 +
1936b5c07418SJames Feist                         " due to modification by the service."},
1937b5c07418SJames Feist         {"MessageArgs", {arg1, arg2}},
1938684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1939b5c07418SJames Feist         {"Resolution", "No resolution is required."}};
1940b5c07418SJames Feist }
1941b5c07418SJames Feist 
1942f12894f8SJason M. Bills void propertyValueModified(crow::Response& res, const std::string& arg1,
1943a08b46ccSJason M. Bills                            const std::string& arg2)
19441abe55efSEd Tanous {
1945f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1946b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1947f4c4dcf4SKowalski, Kamil }
1948f4c4dcf4SKowalski, Kamil 
1949f4c4dcf4SKowalski, Kamil /**
1950f4c4dcf4SKowalski, Kamil  * @internal
1951f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1952f4c4dcf4SKowalski, Kamil  *
1953f4c4dcf4SKowalski, Kamil  * See header file for more information
1954f4c4dcf4SKowalski, Kamil  * @endinternal
1955f4c4dcf4SKowalski, Kamil  */
1956b5c07418SJames Feist nlohmann::json accountNotModified(void)
19571abe55efSEd Tanous {
1958b5c07418SJames Feist     return nlohmann::json{
19593e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1960684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.AccountNotModified"},
1961f4c4dcf4SKowalski, Kamil         {"Message", "The account modification request failed."},
196285659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1963684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1964f12894f8SJason M. Bills         {"Resolution", "The modification may have failed due to permission "
1965b5c07418SJames Feist                        "issues or issues with the request body."}};
1966b5c07418SJames Feist }
1967b5c07418SJames Feist 
1968b5c07418SJames Feist void accountNotModified(crow::Response& res)
1969b5c07418SJames Feist {
1970b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1971b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1972f4c4dcf4SKowalski, Kamil }
1973f4c4dcf4SKowalski, Kamil 
1974f4c4dcf4SKowalski, Kamil /**
1975f4c4dcf4SKowalski, Kamil  * @internal
1976f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1977f4c4dcf4SKowalski, Kamil  *
1978f4c4dcf4SKowalski, Kamil  * See header file for more information
1979f4c4dcf4SKowalski, Kamil  * @endinternal
1980f4c4dcf4SKowalski, Kamil  */
1981b5c07418SJames Feist nlohmann::json queryParameterValueFormatError(const std::string& arg1,
19821abe55efSEd Tanous                                               const std::string& arg2)
19831abe55efSEd Tanous {
1984b5c07418SJames Feist     return nlohmann::json{
19853e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1986684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryParameterValueFormatError"},
1987f4c4dcf4SKowalski, Kamil         {"Message",
1988f4c4dcf4SKowalski, Kamil          "The value " + arg1 + " for the parameter " + arg2 +
1989f4c4dcf4SKowalski, Kamil              " is of a different format than the parameter can accept."},
199085659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1991684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
199266ac2b8cSJason M. Bills         {"Resolution",
199366ac2b8cSJason M. Bills          "Correct the value for the query parameter in the request and "
1994b5c07418SJames Feist          "resubmit the request if the operation failed."}};
1995b5c07418SJames Feist }
1996b5c07418SJames Feist 
1997b5c07418SJames Feist void queryParameterValueFormatError(crow::Response& res,
1998b5c07418SJames Feist                                     const std::string& arg1,
1999b5c07418SJames Feist                                     const std::string& arg2)
2000b5c07418SJames Feist {
2001b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
2002b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
2003b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
2004f4c4dcf4SKowalski, Kamil }
2005f4c4dcf4SKowalski, Kamil 
2006f4c4dcf4SKowalski, Kamil /**
2007f4c4dcf4SKowalski, Kamil  * @internal
2008b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
2009b5c07418SJames Feist  * property
2010f12894f8SJason M. Bills  *
2011f12894f8SJason M. Bills  * See header file for more information
2012f12894f8SJason M. Bills  * @endinternal
2013f12894f8SJason M. Bills  */
2014b5c07418SJames Feist nlohmann::json propertyMissing(const std::string& arg1)
2015f12894f8SJason M. Bills {
2016b5c07418SJames Feist     return nlohmann::json{
20173e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
2018684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyMissing"},
2019f12894f8SJason M. Bills         {"Message", "The property " + arg1 +
2020f12894f8SJason M. Bills                         " is a required property and must be included in "
2021f12894f8SJason M. Bills                         "the request."},
202285659adfSJason M. Bills         {"MessageArgs", {arg1}},
2023684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
2024f12894f8SJason M. Bills         {"Resolution",
2025b5c07418SJames Feist          "Ensure that the property is in the request body and has a "
2026b5c07418SJames Feist          "valid "
2027b5c07418SJames Feist          "value and resubmit the request if the operation failed."}};
2028b5c07418SJames Feist }
2029b5c07418SJames Feist 
2030b5c07418SJames Feist void propertyMissing(crow::Response& res, const std::string& arg1)
2031b5c07418SJames Feist {
2032b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
2033b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
2034f4c4dcf4SKowalski, Kamil }
2035f4c4dcf4SKowalski, Kamil 
2036f4c4dcf4SKowalski, Kamil /**
2037f4c4dcf4SKowalski, Kamil  * @internal
2038f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
2039f4c4dcf4SKowalski, Kamil  *
2040f4c4dcf4SKowalski, Kamil  * See header file for more information
2041f4c4dcf4SKowalski, Kamil  * @endinternal
2042f4c4dcf4SKowalski, Kamil  */
2043b5c07418SJames Feist nlohmann::json resourceExhaustion(const std::string& arg1)
20441abe55efSEd Tanous {
2045b5c07418SJames Feist     return nlohmann::json{
20463e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
2047684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceExhaustion"},
2048d425c6f6SEd Tanous         {"Message", "The resource " + arg1 +
204966ac2b8cSJason M. Bills                         " was unable to satisfy the request due to "
205066ac2b8cSJason M. Bills                         "unavailability of resources."},
205185659adfSJason M. Bills         {"MessageArgs", {arg1}},
2052684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
2053f12894f8SJason M. Bills         {"Resolution", "Ensure that the resources are available and "
2054b5c07418SJames Feist                        "resubmit the request."}};
2055b5c07418SJames Feist }
2056b5c07418SJames Feist 
2057b5c07418SJames Feist void resourceExhaustion(crow::Response& res, const std::string& arg1)
2058b5c07418SJames Feist {
2059b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
2060b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
2061f4c4dcf4SKowalski, Kamil }
2062f4c4dcf4SKowalski, Kamil 
2063f4c4dcf4SKowalski, Kamil /**
2064f4c4dcf4SKowalski, Kamil  * @internal
2065f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
2066f4c4dcf4SKowalski, Kamil  *
2067f4c4dcf4SKowalski, Kamil  * See header file for more information
2068f4c4dcf4SKowalski, Kamil  * @endinternal
2069f4c4dcf4SKowalski, Kamil  */
2070b5c07418SJames Feist nlohmann::json accountModified(void)
20711abe55efSEd Tanous {
20723e082749SAsmitha Karunanithi     return nlohmann::json{{"@odata.type", "#Message.v1_1_1.Message"},
2073684bb4b8SJason M. Bills                           {"MessageId", "Base.1.8.1.AccountModified"},
2074f4c4dcf4SKowalski, Kamil                           {"Message", "The account was successfully modified."},
207585659adfSJason M. Bills                           {"MessageArgs", nlohmann::json::array()},
2076684bb4b8SJason M. Bills                           {"MessageSeverity", "OK"},
2077b5c07418SJames Feist                           {"Resolution", "No resolution is required."}};
2078b5c07418SJames Feist }
2079b5c07418SJames Feist 
2080b5c07418SJames Feist void accountModified(crow::Response& res)
2081b5c07418SJames Feist {
2082b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
2083b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
2084f4c4dcf4SKowalski, Kamil }
2085f4c4dcf4SKowalski, Kamil 
2086f4c4dcf4SKowalski, Kamil /**
2087f4c4dcf4SKowalski, Kamil  * @internal
2088f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
2089f4c4dcf4SKowalski, Kamil  *
2090f4c4dcf4SKowalski, Kamil  * See header file for more information
2091f4c4dcf4SKowalski, Kamil  * @endinternal
2092f4c4dcf4SKowalski, Kamil  */
2093b5c07418SJames Feist nlohmann::json queryParameterOutOfRange(const std::string& arg1,
2094b5c07418SJames Feist                                         const std::string& arg2,
2095b5c07418SJames Feist                                         const std::string& arg3)
20961abe55efSEd Tanous {
2097b5c07418SJames Feist     return nlohmann::json{
20983e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
2099684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryParameterOutOfRange"},
2100b5c07418SJames Feist         {"Message", "The value " + arg1 + " for the query parameter " + arg2 +
2101b5c07418SJames Feist                         " is out of range " + arg3 + "."},
210285659adfSJason M. Bills         {"MessageArgs", {arg1, arg2, arg3}},
2103684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
2104f4c4dcf4SKowalski, Kamil         {"Resolution",
2105f12894f8SJason M. Bills          "Reduce the value for the query parameter to a value that is "
210666ac2b8cSJason M. Bills          "within range, such as a start or count value that is within "
210766ac2b8cSJason M. Bills          "bounds of the number of resources in a collection or a page that "
2108b5c07418SJames Feist          "is within the range of valid pages."}};
2109b5c07418SJames Feist }
2110b5c07418SJames Feist 
2111b5c07418SJames Feist void queryParameterOutOfRange(crow::Response& res, const std::string& arg1,
2112b5c07418SJames Feist                               const std::string& arg2, const std::string& arg3)
2113b5c07418SJames Feist {
2114b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
2115b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
2116b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
2117f4c4dcf4SKowalski, Kamil }
2118f4c4dcf4SKowalski, Kamil 
21193bf4e632SJoseph Reynolds /**
21203bf4e632SJoseph Reynolds  * @internal
21213bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
21223bf4e632SJoseph Reynolds  *
21233bf4e632SJoseph Reynolds  * See header file for more information
21243bf4e632SJoseph Reynolds  * @endinternal
21253bf4e632SJoseph Reynolds  */
2126*ace85d60SEd Tanous void passwordChangeRequired(crow::Response& res,
2127*ace85d60SEd Tanous                             const boost::urls::url_view& arg1)
21283bf4e632SJoseph Reynolds {
2129*ace85d60SEd Tanous     std::string url(arg1.data(), arg1.size());
21303bf4e632SJoseph Reynolds     messages::addMessageToJsonRoot(
21313bf4e632SJoseph Reynolds         res.jsonValue,
21323bf4e632SJoseph Reynolds         nlohmann::json{
21333bf4e632SJoseph Reynolds             {"@odata.type", "/redfish/v1/$metadata#Message.v1_5_0.Message"},
2134684bb4b8SJason M. Bills             {"MessageId", "Base.1.8.1.PasswordChangeRequired"},
21353bf4e632SJoseph Reynolds             {"Message", "The password provided for this account must be "
21363bf4e632SJoseph Reynolds                         "changed before access is granted.  PATCH the "
21373bf4e632SJoseph Reynolds                         "'Password' property for this account located at "
21383bf4e632SJoseph Reynolds                         "the target URI '" +
2139*ace85d60SEd Tanous                             url + "' to complete this process."},
2140*ace85d60SEd Tanous             {"MessageArgs", {url}},
2141684bb4b8SJason M. Bills             {"MessageSeverity", "Critical"},
21423bf4e632SJoseph Reynolds             {"Resolution", "Change the password for this account using "
21433bf4e632SJoseph Reynolds                            "a PATCH to the 'Password' property at the URI "
21443bf4e632SJoseph Reynolds                            "provided."}});
21453bf4e632SJoseph Reynolds }
21463bf4e632SJoseph Reynolds 
21474cde5d90SJames Feist void invalidUpload(crow::Response& res, const std::string& arg1,
21484cde5d90SJames Feist                    const std::string& arg2)
21494cde5d90SJames Feist {
21504cde5d90SJames Feist     res.result(boost::beast::http::status::bad_request);
21514cde5d90SJames Feist     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
21524cde5d90SJames Feist }
21534cde5d90SJames Feist 
21544cde5d90SJames Feist /**
21554cde5d90SJames Feist  * @internal
21564cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
21574cde5d90SJames Feist  *
21584cde5d90SJames Feist  * See header file for more information
21594cde5d90SJames Feist  * @endinternal
21604cde5d90SJames Feist  */
21614cde5d90SJames Feist nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2)
21624cde5d90SJames Feist {
21634cde5d90SJames Feist     return nlohmann::json{
21643e082749SAsmitha Karunanithi         {"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"},
21654a0bf539SManojkiran Eda         {"MessageId", "OpenBMC.0.2.InvalidUpload"},
21664cde5d90SJames Feist         {"Message", "Invalid file uploaded to " + arg1 + ": " + arg2 + "."},
21674cde5d90SJames Feist         {"MessageArgs", {arg1, arg2}},
2168684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
21694cde5d90SJames Feist         {"Resolution", "None."}};
21704cde5d90SJames Feist }
21714cde5d90SJames Feist 
2172f4c4dcf4SKowalski, Kamil } // namespace messages
2173f4c4dcf4SKowalski, Kamil 
2174d425c6f6SEd Tanous } // namespace redfish
2175