xref: /openbmc/bmcweb/features/redfish/src/error_messages.cpp (revision 5187e09b891b9d0f12c76736caaa062120fd19f7)
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 */
161abe55efSEd Tanous #include <error_messages.hpp>
1704e438cbSEd Tanous #include <logging.hpp>
18f4c4dcf4SKowalski, Kamil 
191abe55efSEd Tanous namespace redfish
201abe55efSEd Tanous {
211abe55efSEd Tanous 
221abe55efSEd Tanous namespace messages
231abe55efSEd Tanous {
24f4c4dcf4SKowalski, Kamil 
25f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target,
261abe55efSEd Tanous                                   const nlohmann::json& message)
271abe55efSEd Tanous {
28f4c4dcf4SKowalski, Kamil     auto& error = target["error"];
29f4c4dcf4SKowalski, Kamil 
301abe55efSEd Tanous     // If this is the first error message, fill in the information from the
311abe55efSEd Tanous     // first error message to the top level struct
321abe55efSEd Tanous     if (!error.is_object())
331abe55efSEd Tanous     {
34c074230bSJason M. Bills         auto messageIdIterator = message.find("MessageId");
35c074230bSJason M. Bills         if (messageIdIterator == message.end())
361abe55efSEd Tanous         {
371abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
381abe55efSEd Tanous                 << "Attempt to add error message without MessageId";
39f4c4dcf4SKowalski, Kamil             return;
40f4c4dcf4SKowalski, Kamil         }
41f4c4dcf4SKowalski, Kamil 
42c074230bSJason M. Bills         auto messageFieldIterator = message.find("Message");
43c074230bSJason M. Bills         if (messageFieldIterator == message.end())
441abe55efSEd Tanous         {
451abe55efSEd Tanous             BMCWEB_LOG_CRITICAL
461abe55efSEd Tanous                 << "Attempt to add error message without Message";
47f4c4dcf4SKowalski, Kamil             return;
48f4c4dcf4SKowalski, Kamil         }
49c21055aaSEd Tanous         error = {{"code", *messageIdIterator},
50c21055aaSEd Tanous                  {"message", *messageFieldIterator}};
511abe55efSEd Tanous     }
521abe55efSEd Tanous     else
531abe55efSEd Tanous     {
54f4c4dcf4SKowalski, Kamil         // More than 1 error occurred, so the message has to be generic
5555c7b7a2SEd Tanous         error["code"] = std::string(messageVersionPrefix) + "GeneralError";
56cc9139ecSJason M. Bills         error["message"] = "A general error has occurred. See Resolution for "
57cc9139ecSJason M. Bills                            "information on how to resolve the error.";
58f4c4dcf4SKowalski, Kamil     }
59f4c4dcf4SKowalski, Kamil 
60f4c4dcf4SKowalski, Kamil     // This check could technically be done in in the default construction
61f4c4dcf4SKowalski, Kamil     // branch above, but because we need the pointer to the extended info field
62f4c4dcf4SKowalski, Kamil     // anyway, it's more efficient to do it here.
63c074230bSJason M. Bills     auto& extendedInfo = error[messages::messageAnnotation];
64c074230bSJason M. Bills     if (!extendedInfo.is_array())
651abe55efSEd Tanous     {
66c074230bSJason M. Bills         extendedInfo = nlohmann::json::array();
67f4c4dcf4SKowalski, Kamil     }
68f4c4dcf4SKowalski, Kamil 
69c074230bSJason M. Bills     extendedInfo.push_back(message);
70f4c4dcf4SKowalski, Kamil }
71f4c4dcf4SKowalski, Kamil 
72f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target,
73f12894f8SJason M. Bills                                  const nlohmann::json& message)
741abe55efSEd Tanous {
751abe55efSEd Tanous     if (!target[messages::messageAnnotation].is_array())
761abe55efSEd Tanous     {
77f4c4dcf4SKowalski, Kamil         // Force object to be an array
7855c7b7a2SEd Tanous         target[messages::messageAnnotation] = nlohmann::json::array();
79f4c4dcf4SKowalski, Kamil     }
80f4c4dcf4SKowalski, Kamil 
8155c7b7a2SEd Tanous     target[messages::messageAnnotation].push_back(message);
82f4c4dcf4SKowalski, Kamil }
83f4c4dcf4SKowalski, Kamil 
84f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target,
85f12894f8SJason M. Bills                              const nlohmann::json& message,
861abe55efSEd Tanous                              const std::string& fieldPath)
871abe55efSEd Tanous {
88a08b46ccSJason M. Bills     std::string extendedInfo(fieldPath + messages::messageAnnotation);
89f4c4dcf4SKowalski, Kamil 
901abe55efSEd Tanous     if (!target[extendedInfo].is_array())
911abe55efSEd Tanous     {
92f4c4dcf4SKowalski, Kamil         // Force object to be an array
93f4c4dcf4SKowalski, Kamil         target[extendedInfo] = nlohmann::json::array();
94f4c4dcf4SKowalski, Kamil     }
95f4c4dcf4SKowalski, Kamil 
96f4c4dcf4SKowalski, Kamil     // Object exists and it is an array so we can just push in the message
97f4c4dcf4SKowalski, Kamil     target[extendedInfo].push_back(message);
98f4c4dcf4SKowalski, Kamil }
99f4c4dcf4SKowalski, Kamil 
100f4c4dcf4SKowalski, Kamil /**
101f4c4dcf4SKowalski, Kamil  * @internal
102f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInUse message into JSON
103f4c4dcf4SKowalski, Kamil  *
104f4c4dcf4SKowalski, Kamil  * See header file for more information
105f4c4dcf4SKowalski, Kamil  * @endinternal
106f4c4dcf4SKowalski, Kamil  */
107b5c07418SJames Feist nlohmann::json resourceInUse(void)
1081abe55efSEd Tanous {
109b5c07418SJames Feist     return nlohmann::json{
1103e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
111684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceInUse"},
11266ac2b8cSJason M. Bills         {"Message", "The change to the requested resource failed because "
11366ac2b8cSJason M. Bills                     "the resource is in use or in transition."},
11485659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
115684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
11666ac2b8cSJason M. Bills         {"Resolution", "Remove the condition and resubmit the request if "
117b5c07418SJames Feist                        "the operation failed."}};
118b5c07418SJames Feist }
119b5c07418SJames Feist 
120b5c07418SJames Feist void resourceInUse(crow::Response& res)
121b5c07418SJames Feist {
122b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
123b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInUse());
124f4c4dcf4SKowalski, Kamil }
125f4c4dcf4SKowalski, Kamil 
126f4c4dcf4SKowalski, Kamil /**
127f4c4dcf4SKowalski, Kamil  * @internal
128f4c4dcf4SKowalski, Kamil  * @brief Formats MalformedJSON message into JSON
129f4c4dcf4SKowalski, Kamil  *
130f4c4dcf4SKowalski, Kamil  * See header file for more information
131f4c4dcf4SKowalski, Kamil  * @endinternal
132f4c4dcf4SKowalski, Kamil  */
133b5c07418SJames Feist nlohmann::json malformedJSON(void)
1341abe55efSEd Tanous {
135b5c07418SJames Feist     return nlohmann::json{
1363e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
137684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.MalformedJSON"},
13866ac2b8cSJason M. Bills         {"Message", "The request body submitted was malformed JSON and "
13966ac2b8cSJason M. Bills                     "could not be parsed by the receiving service."},
14085659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
141684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1421abe55efSEd Tanous         {"Resolution", "Ensure that the request body is valid JSON and "
143b5c07418SJames Feist                        "resubmit the request."}};
144b5c07418SJames Feist }
145b5c07418SJames Feist 
146b5c07418SJames Feist void malformedJSON(crow::Response& res)
147b5c07418SJames Feist {
148b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
149b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, malformedJSON());
150f4c4dcf4SKowalski, Kamil }
151f4c4dcf4SKowalski, Kamil 
152f4c4dcf4SKowalski, Kamil /**
153f4c4dcf4SKowalski, Kamil  * @internal
154f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceMissingAtURI message into JSON
155f4c4dcf4SKowalski, Kamil  *
156f4c4dcf4SKowalski, Kamil  * See header file for more information
157f4c4dcf4SKowalski, Kamil  * @endinternal
158f4c4dcf4SKowalski, Kamil  */
159b5c07418SJames Feist nlohmann::json resourceMissingAtURI(const std::string& arg1)
1601abe55efSEd Tanous {
161b5c07418SJames Feist     return nlohmann::json{
1623e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
163684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceMissingAtURI"},
164f4c4dcf4SKowalski, Kamil         {"Message", "The resource at the URI " + arg1 + " was not found."},
16585659adfSJason M. Bills         {"MessageArgs", {arg1}},
166684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
16766ac2b8cSJason M. Bills         {"Resolution", "Place a valid resource at the URI or correct the "
168b5c07418SJames Feist                        "URI and resubmit the request."}};
169b5c07418SJames Feist }
170b5c07418SJames Feist 
171b5c07418SJames Feist void resourceMissingAtURI(crow::Response& res, const std::string& arg1)
172b5c07418SJames Feist {
173b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
174b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1));
175f4c4dcf4SKowalski, Kamil }
176f4c4dcf4SKowalski, Kamil 
177f4c4dcf4SKowalski, Kamil /**
178f4c4dcf4SKowalski, Kamil  * @internal
179f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueFormatError message into JSON
180f4c4dcf4SKowalski, Kamil  *
181f4c4dcf4SKowalski, Kamil  * See header file for more information
182f4c4dcf4SKowalski, Kamil  * @endinternal
183f4c4dcf4SKowalski, Kamil  */
184b5c07418SJames Feist nlohmann::json actionParameterValueFormatError(const std::string& arg1,
185f4c4dcf4SKowalski, Kamil                                                const std::string& arg2,
1861abe55efSEd Tanous                                                const std::string& arg3)
1871abe55efSEd Tanous {
188b5c07418SJames Feist     return nlohmann::json{
1893e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
190684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterValueFormatError"},
191f4c4dcf4SKowalski, Kamil         {"Message",
1921abe55efSEd Tanous          "The value " + arg1 + " for the parameter " + arg2 +
1931abe55efSEd Tanous              " in the action " + arg3 +
1941abe55efSEd Tanous              " is of a different format than the parameter can accept."},
19585659adfSJason M. Bills         {"MessageArgs", {arg1, arg2, arg3}},
196684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
19766ac2b8cSJason M. Bills         {"Resolution",
19866ac2b8cSJason M. Bills          "Correct the value for the parameter in the request body and "
199b5c07418SJames Feist          "resubmit the request if the operation failed."}};
200b5c07418SJames Feist }
201b5c07418SJames Feist 
202b5c07418SJames Feist void actionParameterValueFormatError(crow::Response& res,
203b5c07418SJames Feist                                      const std::string& arg1,
204b5c07418SJames Feist                                      const std::string& arg2,
205b5c07418SJames Feist                                      const std::string& arg3)
206b5c07418SJames Feist {
207b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
208b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
209b5c07418SJames Feist                           actionParameterValueFormatError(arg1, arg2, arg3));
210f4c4dcf4SKowalski, Kamil }
211f4c4dcf4SKowalski, Kamil 
212f4c4dcf4SKowalski, Kamil /**
213f4c4dcf4SKowalski, Kamil  * @internal
214f4c4dcf4SKowalski, Kamil  * @brief Formats InternalError message into JSON
215f4c4dcf4SKowalski, Kamil  *
216f4c4dcf4SKowalski, Kamil  * See header file for more information
217f4c4dcf4SKowalski, Kamil  * @endinternal
218f4c4dcf4SKowalski, Kamil  */
219b5c07418SJames Feist nlohmann::json internalError(void)
2201abe55efSEd Tanous {
221b5c07418SJames Feist     return nlohmann::json{
2223e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
223684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.InternalError"},
224f12894f8SJason M. Bills         {"Message", "The request failed due to an internal service error.  "
22566ac2b8cSJason M. Bills                     "The service is still operational."},
22685659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
227684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
2281abe55efSEd Tanous         {"Resolution", "Resubmit the request.  If the problem persists, "
229b5c07418SJames Feist                        "consider resetting the service."}};
230b5c07418SJames Feist }
231b5c07418SJames Feist 
232df5415fcSEd Tanous void internalError(crow::Response& res, const bmcweb::source_location location)
233b5c07418SJames Feist {
234df5415fcSEd Tanous     BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "("
235df5415fcSEd Tanous                         << location.line() << ":" << location.column() << ") `"
236df5415fcSEd Tanous                         << location.function_name() << "`: ";
237b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
238b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, internalError());
239f12894f8SJason M. Bills }
240f12894f8SJason M. Bills 
241f12894f8SJason M. Bills /**
242f12894f8SJason M. Bills  * @internal
243f4c4dcf4SKowalski, Kamil  * @brief Formats UnrecognizedRequestBody message into JSON
244f4c4dcf4SKowalski, Kamil  *
245f4c4dcf4SKowalski, Kamil  * See header file for more information
246f4c4dcf4SKowalski, Kamil  * @endinternal
247f4c4dcf4SKowalski, Kamil  */
248b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void)
2491abe55efSEd Tanous {
250b5c07418SJames Feist     return nlohmann::json{
2513e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
252684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.UnrecognizedRequestBody"},
253f12894f8SJason M. Bills         {"Message", "The service detected a malformed request body that it "
25466ac2b8cSJason M. Bills                     "was unable to interpret."},
25585659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
256684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
257f12894f8SJason M. Bills         {"Resolution", "Correct the request body and resubmit the request "
258b5c07418SJames Feist                        "if it failed."}};
259b5c07418SJames Feist }
260b5c07418SJames Feist 
261b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res)
262b5c07418SJames Feist {
263b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
264b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody());
265f4c4dcf4SKowalski, Kamil }
266f4c4dcf4SKowalski, Kamil 
267f4c4dcf4SKowalski, Kamil /**
268f4c4dcf4SKowalski, Kamil  * @internal
269f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriUnauthorized message into JSON
270f4c4dcf4SKowalski, Kamil  *
271f4c4dcf4SKowalski, Kamil  * See header file for more information
272f4c4dcf4SKowalski, Kamil  * @endinternal
273f4c4dcf4SKowalski, Kamil  */
274b5c07418SJames Feist nlohmann::json resourceAtUriUnauthorized(const std::string& arg1,
2751abe55efSEd Tanous                                          const std::string& arg2)
2761abe55efSEd Tanous {
277b5c07418SJames Feist     return nlohmann::json{
2783e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
279684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceAtUriUnauthorized"},
280f4c4dcf4SKowalski, Kamil         {"Message", "While accessing the resource at " + arg1 +
2811abe55efSEd Tanous                         ", the service received an authorization error " +
2821abe55efSEd Tanous                         arg2 + "."},
28385659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
284684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
285f12894f8SJason M. Bills         {"Resolution", "Ensure that the appropriate access is provided for "
286b5c07418SJames Feist                        "the service in order for it to access the URI."}};
287b5c07418SJames Feist }
288b5c07418SJames Feist 
289b5c07418SJames Feist void resourceAtUriUnauthorized(crow::Response& res, const std::string& arg1,
290b5c07418SJames Feist                                const std::string& arg2)
291b5c07418SJames Feist {
292b5c07418SJames Feist     res.result(boost::beast::http::status::unauthorized);
293b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2));
294f4c4dcf4SKowalski, Kamil }
295f4c4dcf4SKowalski, Kamil 
296f4c4dcf4SKowalski, Kamil /**
297f4c4dcf4SKowalski, Kamil  * @internal
298f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterUnknown message into JSON
299f4c4dcf4SKowalski, Kamil  *
300f4c4dcf4SKowalski, Kamil  * See header file for more information
301f4c4dcf4SKowalski, Kamil  * @endinternal
302f4c4dcf4SKowalski, Kamil  */
303b5c07418SJames Feist nlohmann::json actionParameterUnknown(const std::string& arg1,
304b5c07418SJames Feist                                       const std::string& arg2)
305b5c07418SJames Feist {
306b5c07418SJames Feist     return nlohmann::json{
3073e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
308684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterUnknown"},
309b5c07418SJames Feist         {"Message", "The action " + arg1 +
310b5c07418SJames Feist                         " was submitted with the invalid parameter " + arg2 +
311b5c07418SJames Feist                         "."},
312b5c07418SJames Feist         {"MessageArgs", {arg1, arg2}},
313684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
314b5c07418SJames Feist         {"Resolution", "Correct the invalid parameter and resubmit the "
315b5c07418SJames Feist                        "request if the operation failed."}};
316b5c07418SJames Feist }
317b5c07418SJames Feist 
318f12894f8SJason M. Bills void actionParameterUnknown(crow::Response& res, const std::string& arg1,
3191abe55efSEd Tanous                             const std::string& arg2)
3201abe55efSEd Tanous {
321f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
322b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2));
323f4c4dcf4SKowalski, Kamil }
324f4c4dcf4SKowalski, Kamil 
325f4c4dcf4SKowalski, Kamil /**
326f4c4dcf4SKowalski, Kamil  * @internal
327f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceCannotBeDeleted message into JSON
328f4c4dcf4SKowalski, Kamil  *
329f4c4dcf4SKowalski, Kamil  * See header file for more information
330f4c4dcf4SKowalski, Kamil  * @endinternal
331f4c4dcf4SKowalski, Kamil  */
332b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void)
3331abe55efSEd Tanous {
334b5c07418SJames Feist     return nlohmann::json{
3353e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
336684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceCannotBeDeleted"},
337f12894f8SJason M. Bills         {"Message", "The delete request failed because the resource "
33866ac2b8cSJason M. Bills                     "requested cannot be deleted."},
33985659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
340684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
341b5c07418SJames Feist         {"Resolution", "Do not attempt to delete a non-deletable resource."}};
342b5c07418SJames Feist }
343b5c07418SJames Feist 
344b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res)
345b5c07418SJames Feist {
346b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
347b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted());
348f4c4dcf4SKowalski, Kamil }
349f4c4dcf4SKowalski, Kamil 
350f4c4dcf4SKowalski, Kamil /**
351f4c4dcf4SKowalski, Kamil  * @internal
352f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyDuplicate message into JSON
353f4c4dcf4SKowalski, Kamil  *
354f4c4dcf4SKowalski, Kamil  * See header file for more information
355f4c4dcf4SKowalski, Kamil  * @endinternal
356f4c4dcf4SKowalski, Kamil  */
357b5c07418SJames Feist nlohmann::json propertyDuplicate(const std::string& arg1)
3581abe55efSEd Tanous {
359b5c07418SJames Feist     return nlohmann::json{
3603e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
361684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyDuplicate"},
362b5c07418SJames Feist         {"Message", "The property " + arg1 + " was duplicated in the request."},
36385659adfSJason M. Bills         {"MessageArgs", {arg1}},
364684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
36566ac2b8cSJason M. Bills         {"Resolution",
36666ac2b8cSJason M. Bills          "Remove the duplicate property from the request body and resubmit "
367b5c07418SJames Feist          "the request if the operation failed."}};
368b5c07418SJames Feist }
369b5c07418SJames Feist 
370b5c07418SJames Feist void propertyDuplicate(crow::Response& res, const std::string& arg1)
371b5c07418SJames Feist {
372b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
373b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1);
374f4c4dcf4SKowalski, Kamil }
375f4c4dcf4SKowalski, Kamil 
376f4c4dcf4SKowalski, Kamil /**
377f4c4dcf4SKowalski, Kamil  * @internal
378f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceTemporarilyUnavailable message into JSON
379f4c4dcf4SKowalski, Kamil  *
380f4c4dcf4SKowalski, Kamil  * See header file for more information
381f4c4dcf4SKowalski, Kamil  * @endinternal
382f4c4dcf4SKowalski, Kamil  */
383b5c07418SJames Feist nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1)
3841abe55efSEd Tanous {
385b5c07418SJames Feist     return nlohmann::json{
3863e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
387684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ServiceTemporarilyUnavailable"},
3881abe55efSEd Tanous         {"Message", "The service is temporarily unavailable.  Retry in " +
3891abe55efSEd Tanous                         arg1 + " seconds."},
39085659adfSJason M. Bills         {"MessageArgs", {arg1}},
391684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
392f12894f8SJason M. Bills         {"Resolution", "Wait for the indicated retry duration and retry "
393b5c07418SJames Feist                        "the operation."}};
394b5c07418SJames Feist }
395b5c07418SJames Feist 
396b5c07418SJames Feist void serviceTemporarilyUnavailable(crow::Response& res, const std::string& arg1)
397b5c07418SJames Feist {
398b5c07418SJames Feist     res.addHeader("Retry-After", arg1);
399b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
400b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1));
401f4c4dcf4SKowalski, Kamil }
402f4c4dcf4SKowalski, Kamil 
403f4c4dcf4SKowalski, Kamil /**
404f4c4dcf4SKowalski, Kamil  * @internal
405f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAlreadyExists message into JSON
406f4c4dcf4SKowalski, Kamil  *
407f4c4dcf4SKowalski, Kamil  * See header file for more information
408f4c4dcf4SKowalski, Kamil  * @endinternal
409f4c4dcf4SKowalski, Kamil  */
410b5c07418SJames Feist nlohmann::json resourceAlreadyExists(const std::string& arg1,
411b5c07418SJames Feist                                      const std::string& arg2,
412b5c07418SJames Feist                                      const std::string& arg3)
4131abe55efSEd Tanous {
414b5c07418SJames Feist     return nlohmann::json{
4153e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
416684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceAlreadyExists"},
417f4c4dcf4SKowalski, Kamil         {"Message", "The requested resource of type " + arg1 +
4181abe55efSEd Tanous                         " with the property " + arg2 + " with the value " +
4191abe55efSEd Tanous                         arg3 + " already exists."},
42085659adfSJason M. Bills         {"MessageArgs", {arg1, arg2, arg3}},
421684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
422f12894f8SJason M. Bills         {"Resolution", "Do not repeat the create operation as the resource "
423b5c07418SJames Feist                        "has already been created."}};
424b5c07418SJames Feist }
425b5c07418SJames Feist 
426b5c07418SJames Feist void resourceAlreadyExists(crow::Response& res, const std::string& arg1,
427b5c07418SJames Feist                            const std::string& arg2, const std::string& arg3)
428b5c07418SJames Feist {
429b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
430b5c07418SJames Feist     addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3),
431a08b46ccSJason M. Bills                      arg2);
432f4c4dcf4SKowalski, Kamil }
433f4c4dcf4SKowalski, Kamil 
434f4c4dcf4SKowalski, Kamil /**
435f4c4dcf4SKowalski, Kamil  * @internal
436f4c4dcf4SKowalski, Kamil  * @brief Formats AccountForSessionNoLongerExists message into JSON
437f4c4dcf4SKowalski, Kamil  *
438f4c4dcf4SKowalski, Kamil  * See header file for more information
439f4c4dcf4SKowalski, Kamil  * @endinternal
440f4c4dcf4SKowalski, Kamil  */
441b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void)
4421abe55efSEd Tanous {
443b5c07418SJames Feist     return nlohmann::json{
4443e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
445684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.AccountForSessionNoLongerExists"},
4461abe55efSEd Tanous         {"Message", "The account for the current session has been removed, "
44766ac2b8cSJason M. Bills                     "thus the current session has been removed as well."},
44885659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
449684bb4b8SJason M. Bills         {"MessageSeverity", "OK"},
450b5c07418SJames Feist         {"Resolution", "Attempt to connect with a valid account."}};
451b5c07418SJames Feist }
452b5c07418SJames Feist 
453b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res)
454b5c07418SJames Feist {
455b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
456b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists());
457f4c4dcf4SKowalski, Kamil }
458f4c4dcf4SKowalski, Kamil 
459f4c4dcf4SKowalski, Kamil /**
460f4c4dcf4SKowalski, Kamil  * @internal
461f4c4dcf4SKowalski, Kamil  * @brief Formats CreateFailedMissingReqProperties message into JSON
462f4c4dcf4SKowalski, Kamil  *
463f4c4dcf4SKowalski, Kamil  * See header file for more information
464f4c4dcf4SKowalski, Kamil  * @endinternal
465f4c4dcf4SKowalski, Kamil  */
466b5c07418SJames Feist nlohmann::json createFailedMissingReqProperties(const std::string& arg1)
4671abe55efSEd Tanous {
468b5c07418SJames Feist     return nlohmann::json{
4693e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
470684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.CreateFailedMissingReqProperties"},
4711abe55efSEd Tanous         {"Message",
472b5c07418SJames Feist          "The create operation failed because the required property " + arg1 +
473b5c07418SJames Feist              " was missing from the request."},
47485659adfSJason M. Bills         {"MessageArgs", {arg1}},
475684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
476f4c4dcf4SKowalski, Kamil         {"Resolution",
477f12894f8SJason M. Bills          "Correct the body to include the required property with a valid "
478b5c07418SJames Feist          "value and resubmit the request if the operation failed."}};
479b5c07418SJames Feist }
480b5c07418SJames Feist 
481b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res,
482b5c07418SJames Feist                                       const std::string& arg1)
483b5c07418SJames Feist {
484b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
485b5c07418SJames Feist     addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1),
486a08b46ccSJason M. Bills                      arg1);
487f12894f8SJason M. Bills }
488f12894f8SJason M. Bills 
489f12894f8SJason M. Bills /**
490f12894f8SJason M. Bills  * @internal
491f12894f8SJason M. Bills  * @brief Formats PropertyValueFormatError message into JSON for the specified
492f12894f8SJason M. Bills  * property
493f12894f8SJason M. Bills  *
494f12894f8SJason M. Bills  * See header file for more information
495f12894f8SJason M. Bills  * @endinternal
496f12894f8SJason M. Bills  */
497b5c07418SJames Feist nlohmann::json propertyValueFormatError(const std::string& arg1,
498a08b46ccSJason M. Bills                                         const std::string& arg2)
499f12894f8SJason M. Bills {
500b5c07418SJames Feist     return nlohmann::json{
5013e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
502684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueFormatError"},
503f12894f8SJason M. Bills         {"Message",
504f12894f8SJason M. Bills          "The value " + arg1 + " for the property " + arg2 +
505f12894f8SJason M. Bills              " is of a different format than the property can accept."},
50685659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
507684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
50866ac2b8cSJason M. Bills         {"Resolution",
50966ac2b8cSJason M. Bills          "Correct the value for the property in the request body and "
510b5c07418SJames Feist          "resubmit the request if the operation failed."}};
511b5c07418SJames Feist }
512b5c07418SJames Feist 
513b5c07418SJames Feist void propertyValueFormatError(crow::Response& res, const std::string& arg1,
514b5c07418SJames Feist                               const std::string& arg2)
515b5c07418SJames Feist {
516b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
517b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2);
518f12894f8SJason M. Bills }
519f12894f8SJason M. Bills 
520f12894f8SJason M. Bills /**
521f12894f8SJason M. Bills  * @internal
522f12894f8SJason M. Bills  * @brief Formats PropertyValueNotInList message into JSON for the specified
523f12894f8SJason M. Bills  * property
524f12894f8SJason M. Bills  *
525f12894f8SJason M. Bills  * See header file for more information
526f12894f8SJason M. Bills  * @endinternal
527f12894f8SJason M. Bills  */
528b5c07418SJames Feist nlohmann::json propertyValueNotInList(const std::string& arg1,
529a08b46ccSJason M. Bills                                       const std::string& arg2)
530f12894f8SJason M. Bills {
531b5c07418SJames Feist     return nlohmann::json{
5323e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
533684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueNotInList"},
534f12894f8SJason M. Bills         {"Message", "The value " + arg1 + " for the property " + arg2 +
535f12894f8SJason M. Bills                         " is not in the list of acceptable values."},
53685659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
537684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
538b5c07418SJames Feist         {"Resolution", "Choose a value from the enumeration list that "
539b5c07418SJames Feist                        "the implementation "
540b5c07418SJames Feist                        "can support and resubmit the request if the "
541b5c07418SJames Feist                        "operation failed."}};
542b5c07418SJames Feist }
543b5c07418SJames Feist 
544b5c07418SJames Feist void propertyValueNotInList(crow::Response& res, const std::string& arg1,
545b5c07418SJames Feist                             const std::string& arg2)
546b5c07418SJames Feist {
547b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
548b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2);
549f4c4dcf4SKowalski, Kamil }
550f4c4dcf4SKowalski, Kamil 
551f4c4dcf4SKowalski, Kamil /**
552f4c4dcf4SKowalski, Kamil  * @internal
553f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
554f4c4dcf4SKowalski, Kamil  *
555f4c4dcf4SKowalski, Kamil  * See header file for more information
556f4c4dcf4SKowalski, Kamil  * @endinternal
557f4c4dcf4SKowalski, Kamil  */
558b5c07418SJames Feist nlohmann::json resourceAtUriInUnknownFormat(const std::string& arg1)
5591abe55efSEd Tanous {
560b5c07418SJames Feist     return nlohmann::json{
5613e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
562684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceAtUriInUnknownFormat"},
563f4c4dcf4SKowalski, Kamil         {"Message", "The resource at " + arg1 +
564f4c4dcf4SKowalski, Kamil                         " is in a format not recognized by the service."},
56585659adfSJason M. Bills         {"MessageArgs", {arg1}},
566684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
567f12894f8SJason M. Bills         {"Resolution", "Place an image or resource or file that is "
568b5c07418SJames Feist                        "recognized by the service at the URI."}};
569b5c07418SJames Feist }
570b5c07418SJames Feist 
571b5c07418SJames Feist void resourceAtUriInUnknownFormat(crow::Response& res, const std::string& arg1)
572b5c07418SJames Feist {
573b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
574b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1));
575f4c4dcf4SKowalski, Kamil }
576f4c4dcf4SKowalski, Kamil 
577f4c4dcf4SKowalski, Kamil /**
578f4c4dcf4SKowalski, Kamil  * @internal
57981856681SAsmitha Karunanithi  * @brief Formats ServiceDisabled message into JSON
58081856681SAsmitha Karunanithi  *
58181856681SAsmitha Karunanithi  * See header file for more information
58281856681SAsmitha Karunanithi  * @endinternal
58381856681SAsmitha Karunanithi  */
58481856681SAsmitha Karunanithi nlohmann::json serviceDisabled(const std::string& arg1)
58581856681SAsmitha Karunanithi {
58681856681SAsmitha Karunanithi     return nlohmann::json{
58781856681SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
58881856681SAsmitha Karunanithi         {"MessageId", "Base.1.11.0.ServiceDisabled"},
58981856681SAsmitha Karunanithi         {"Message", "The operation failed because the service at " + arg1 +
59081856681SAsmitha Karunanithi                         " is disabled and cannot accept requests."},
59181856681SAsmitha Karunanithi         {"MessageArgs", {arg1}},
59281856681SAsmitha Karunanithi         {"MessageSeverity", "Warning"},
59381856681SAsmitha Karunanithi         {"Resolution", "Enable the service and resubmit the request if the "
59481856681SAsmitha Karunanithi                        "operation failed."}};
59581856681SAsmitha Karunanithi }
59681856681SAsmitha Karunanithi 
59781856681SAsmitha Karunanithi void serviceDisabled(crow::Response& res, const std::string& arg1)
59881856681SAsmitha Karunanithi {
59981856681SAsmitha Karunanithi     res.result(boost::beast::http::status::service_unavailable);
60081856681SAsmitha Karunanithi     addMessageToErrorJson(res.jsonValue, serviceDisabled(arg1));
60181856681SAsmitha Karunanithi }
60281856681SAsmitha Karunanithi 
60381856681SAsmitha Karunanithi /**
60481856681SAsmitha Karunanithi  * @internal
605f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceInUnknownState message into JSON
606f4c4dcf4SKowalski, Kamil  *
607f4c4dcf4SKowalski, Kamil  * See header file for more information
608f4c4dcf4SKowalski, Kamil  * @endinternal
609f4c4dcf4SKowalski, Kamil  */
610b5c07418SJames Feist nlohmann::json serviceInUnknownState(void)
6111abe55efSEd Tanous {
612b5c07418SJames Feist     return nlohmann::json{
6133e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
614684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ServiceInUnknownState"},
61566ac2b8cSJason M. Bills         {"Message",
61666ac2b8cSJason M. Bills          "The operation failed because the service is in an unknown state "
61766ac2b8cSJason M. Bills          "and can no longer take incoming requests."},
61885659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
619684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
62066ac2b8cSJason M. Bills         {"Resolution", "Restart the service and resubmit the request if "
621b5c07418SJames Feist                        "the operation failed."}};
622b5c07418SJames Feist }
623b5c07418SJames Feist 
624b5c07418SJames Feist void serviceInUnknownState(crow::Response& res)
625b5c07418SJames Feist {
626b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
627b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceInUnknownState());
628f4c4dcf4SKowalski, Kamil }
629f4c4dcf4SKowalski, Kamil 
630f4c4dcf4SKowalski, Kamil /**
631f4c4dcf4SKowalski, Kamil  * @internal
632f4c4dcf4SKowalski, Kamil  * @brief Formats EventSubscriptionLimitExceeded message into JSON
633f4c4dcf4SKowalski, Kamil  *
634f4c4dcf4SKowalski, Kamil  * See header file for more information
635f4c4dcf4SKowalski, Kamil  * @endinternal
636f4c4dcf4SKowalski, Kamil  */
637b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void)
6381abe55efSEd Tanous {
639b5c07418SJames Feist     return nlohmann::json{
6403e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
641684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.EventSubscriptionLimitExceeded"},
642f4c4dcf4SKowalski, Kamil         {"Message",
643f4c4dcf4SKowalski, Kamil          "The event subscription failed due to the number of simultaneous "
644f4c4dcf4SKowalski, Kamil          "subscriptions exceeding the limit of the implementation."},
64585659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
646684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
647f4c4dcf4SKowalski, Kamil         {"Resolution",
648f12894f8SJason M. Bills          "Reduce the number of other subscriptions before trying to "
64966ac2b8cSJason M. Bills          "establish the event subscription or increase the limit of "
650b5c07418SJames Feist          "simultaneous subscriptions (if supported)."}};
651b5c07418SJames Feist }
652b5c07418SJames Feist 
653b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res)
654b5c07418SJames Feist {
655789fdab3SEd Tanous     res.result(boost::beast::http::status::service_unavailable);
656b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded());
657f4c4dcf4SKowalski, Kamil }
658f4c4dcf4SKowalski, Kamil 
659f4c4dcf4SKowalski, Kamil /**
660f4c4dcf4SKowalski, Kamil  * @internal
661f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterMissing message into JSON
662f4c4dcf4SKowalski, Kamil  *
663f4c4dcf4SKowalski, Kamil  * See header file for more information
664f4c4dcf4SKowalski, Kamil  * @endinternal
665f4c4dcf4SKowalski, Kamil  */
666b5c07418SJames Feist nlohmann::json actionParameterMissing(const std::string& arg1,
6671abe55efSEd Tanous                                       const std::string& arg2)
6681abe55efSEd Tanous {
669b5c07418SJames Feist     return nlohmann::json{
6703e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
671684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterMissing"},
672b5c07418SJames Feist         {"Message", "The action " + arg1 + " requires the parameter " + arg2 +
673b5c07418SJames Feist                         " to be present in the request body."},
67485659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
675684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
676f12894f8SJason M. Bills         {"Resolution",
67766ac2b8cSJason M. Bills          "Supply the action with the required parameter in the request "
678b5c07418SJames Feist          "body when the request is resubmitted."}};
679b5c07418SJames Feist }
680b5c07418SJames Feist 
681b5c07418SJames Feist void actionParameterMissing(crow::Response& res, const std::string& arg1,
682b5c07418SJames Feist                             const std::string& arg2)
683b5c07418SJames Feist {
684b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
685b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2));
686f4c4dcf4SKowalski, Kamil }
687f4c4dcf4SKowalski, Kamil 
688f4c4dcf4SKowalski, Kamil /**
689f4c4dcf4SKowalski, Kamil  * @internal
690f4c4dcf4SKowalski, Kamil  * @brief Formats StringValueTooLong message into JSON
691f4c4dcf4SKowalski, Kamil  *
692f4c4dcf4SKowalski, Kamil  * See header file for more information
693f4c4dcf4SKowalski, Kamil  * @endinternal
694f4c4dcf4SKowalski, Kamil  */
695b5c07418SJames Feist nlohmann::json stringValueTooLong(const std::string& arg1, const int& arg2)
6961abe55efSEd Tanous {
697b5c07418SJames Feist     return nlohmann::json{
6983e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
699684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.StringValueTooLong"},
700f4c4dcf4SKowalski, Kamil         {"Message", "The string " + arg1 + " exceeds the length limit " +
701f4c4dcf4SKowalski, Kamil                         std::to_string(arg2) + "."},
70285659adfSJason M. Bills         {"MessageArgs", {arg1, std::to_string(arg2)}},
703684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
704f4c4dcf4SKowalski, Kamil         {"Resolution",
705b5c07418SJames Feist          "Resubmit the request with an appropriate string length."}};
706b5c07418SJames Feist }
707b5c07418SJames Feist 
708b5c07418SJames Feist void stringValueTooLong(crow::Response& res, const std::string& arg1,
709b5c07418SJames Feist                         const int& arg2)
710b5c07418SJames Feist {
711b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
712b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2));
713f4c4dcf4SKowalski, Kamil }
714f4c4dcf4SKowalski, Kamil 
715f4c4dcf4SKowalski, Kamil /**
716f4c4dcf4SKowalski, Kamil  * @internal
717cc9139ecSJason M. Bills  * @brief Formats SessionTerminated message into JSON
718cc9139ecSJason M. Bills  *
719cc9139ecSJason M. Bills  * See header file for more information
720cc9139ecSJason M. Bills  * @endinternal
721cc9139ecSJason M. Bills  */
722b5c07418SJames Feist nlohmann::json sessionTerminated(void)
723cc9139ecSJason M. Bills {
724b5c07418SJames Feist     return nlohmann::json{
7253e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
726684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.SessionTerminated"},
727cc9139ecSJason M. Bills         {"Message", "The session was successfully terminated."},
72885659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
729684bb4b8SJason M. Bills         {"MessageSeverity", "OK"},
730b5c07418SJames Feist         {"Resolution", "No resolution is required."}};
731b5c07418SJames Feist }
732b5c07418SJames Feist 
733b5c07418SJames Feist void sessionTerminated(crow::Response& res)
734b5c07418SJames Feist {
735b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
736b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, sessionTerminated());
737cc9139ecSJason M. Bills }
738cc9139ecSJason M. Bills 
739cc9139ecSJason M. Bills /**
740cc9139ecSJason M. Bills  * @internal
741684bb4b8SJason M. Bills  * @brief Formats SubscriptionTerminated message into JSON
742684bb4b8SJason M. Bills  *
743684bb4b8SJason M. Bills  * See header file for more information
744684bb4b8SJason M. Bills  * @endinternal
745684bb4b8SJason M. Bills  */
746684bb4b8SJason M. Bills nlohmann::json subscriptionTerminated(void)
747684bb4b8SJason M. Bills {
748684bb4b8SJason M. Bills     return nlohmann::json{
7493e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
750684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.SubscriptionTerminated"},
751684bb4b8SJason M. Bills         {"Message", "The event subscription has been terminated."},
752684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
753684bb4b8SJason M. Bills         {"MessageSeverity", "OK"},
754684bb4b8SJason M. Bills         {"Resolution", "No resolution is required."}};
755684bb4b8SJason M. Bills }
756684bb4b8SJason M. Bills 
757684bb4b8SJason M. Bills void subscriptionTerminated(crow::Response& res)
758684bb4b8SJason M. Bills {
759684bb4b8SJason M. Bills     res.result(boost::beast::http::status::ok);
760684bb4b8SJason M. Bills     addMessageToJsonRoot(res.jsonValue, subscriptionTerminated());
761684bb4b8SJason M. Bills }
762684bb4b8SJason M. Bills 
763684bb4b8SJason M. Bills /**
764684bb4b8SJason M. Bills  * @internal
765cc9139ecSJason M. Bills  * @brief Formats ResourceTypeIncompatible message into JSON
766cc9139ecSJason M. Bills  *
767cc9139ecSJason M. Bills  * See header file for more information
768cc9139ecSJason M. Bills  * @endinternal
769cc9139ecSJason M. Bills  */
770b5c07418SJames Feist nlohmann::json resourceTypeIncompatible(const std::string& arg1,
771cc9139ecSJason M. Bills                                         const std::string& arg2)
772cc9139ecSJason M. Bills {
773b5c07418SJames Feist     return nlohmann::json{
7743e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
775684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceTypeIncompatible"},
776cc9139ecSJason M. Bills         {"Message", "The @odata.type of the request body " + arg1 +
777cc9139ecSJason M. Bills                         " is incompatible with the @odata.type of the "
778cc9139ecSJason M. Bills                         "resource which is " +
779cc9139ecSJason M. Bills                         arg2 + "."},
78085659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
781684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
782cc9139ecSJason M. Bills         {"Resolution", "Resubmit the request with a payload compatible "
783b5c07418SJames Feist                        "with the resource's schema."}};
784b5c07418SJames Feist }
785b5c07418SJames Feist 
786b5c07418SJames Feist void resourceTypeIncompatible(crow::Response& res, const std::string& arg1,
787b5c07418SJames Feist                               const std::string& arg2)
788b5c07418SJames Feist {
789b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
790b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2));
791cc9139ecSJason M. Bills }
792cc9139ecSJason M. Bills 
793cc9139ecSJason M. Bills /**
794cc9139ecSJason M. Bills  * @internal
795684bb4b8SJason M. Bills  * @brief Formats ResetRequired message into JSON
796684bb4b8SJason M. Bills  *
797684bb4b8SJason M. Bills  * See header file for more information
798684bb4b8SJason M. Bills  * @endinternal
799684bb4b8SJason M. Bills  */
800684bb4b8SJason M. Bills nlohmann::json resetRequired(const std::string& arg1, const std::string& arg2)
801684bb4b8SJason M. Bills {
802684bb4b8SJason M. Bills     return nlohmann::json{
8033e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
804684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResetRequired"},
805684bb4b8SJason M. Bills         {"Message", "In order to complete the operation, a component reset is "
806684bb4b8SJason M. Bills                     "required with the Reset action URI '" +
807684bb4b8SJason M. Bills                         arg1 + "' and ResetType '" + arg2 + "'."},
808684bb4b8SJason M. Bills         {"MessageArgs", {arg1, arg2}},
809684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
810684bb4b8SJason M. Bills         {"Resolution",
811684bb4b8SJason M. Bills          "Perform the required Reset action on the specified component."}};
812684bb4b8SJason M. Bills }
813684bb4b8SJason M. Bills 
814684bb4b8SJason M. Bills void resetRequired(crow::Response& res, const std::string& arg1,
815684bb4b8SJason M. Bills                    const std::string& arg2)
816684bb4b8SJason M. Bills {
817684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
818684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2));
819684bb4b8SJason M. Bills }
820684bb4b8SJason M. Bills 
821684bb4b8SJason M. Bills /**
822684bb4b8SJason M. Bills  * @internal
823684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOnRequired message into JSON
824684bb4b8SJason M. Bills  *
825684bb4b8SJason M. Bills  * See header file for more information
826684bb4b8SJason M. Bills  * @endinternal
827684bb4b8SJason M. Bills  */
828684bb4b8SJason M. Bills nlohmann::json chassisPowerStateOnRequired(const std::string& arg1)
829684bb4b8SJason M. Bills {
830684bb4b8SJason M. Bills     return nlohmann::json{
8313e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
832684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ChassisPowerStateOnRequired"},
833684bb4b8SJason M. Bills         {"Message", "The Chassis with Id '" + arg1 +
834684bb4b8SJason M. Bills                         "' requires to be powered on to perform this request."},
835684bb4b8SJason M. Bills         {"MessageArgs", {arg1}},
836684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
837684bb4b8SJason M. Bills         {"Resolution",
838684bb4b8SJason M. Bills          "Power on the specified Chassis and resubmit the request."}};
839684bb4b8SJason M. Bills }
840684bb4b8SJason M. Bills 
841684bb4b8SJason M. Bills void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1)
842684bb4b8SJason M. Bills {
843684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
844684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1));
845684bb4b8SJason M. Bills }
846684bb4b8SJason M. Bills 
847684bb4b8SJason M. Bills /**
848684bb4b8SJason M. Bills  * @internal
849684bb4b8SJason M. Bills  * @brief Formats ChassisPowerStateOffRequired message into JSON
850684bb4b8SJason M. Bills  *
851684bb4b8SJason M. Bills  * See header file for more information
852684bb4b8SJason M. Bills  * @endinternal
853684bb4b8SJason M. Bills  */
854684bb4b8SJason M. Bills nlohmann::json chassisPowerStateOffRequired(const std::string& arg1)
855684bb4b8SJason M. Bills {
856684bb4b8SJason M. Bills     return nlohmann::json{
8573e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
858684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ChassisPowerStateOffRequired"},
859684bb4b8SJason M. Bills         {"Message",
860684bb4b8SJason M. Bills          "The Chassis with Id '" + arg1 +
861684bb4b8SJason M. Bills              "' requires to be powered off to perform this request."},
862684bb4b8SJason M. Bills         {"MessageArgs", {arg1}},
863684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
864684bb4b8SJason M. Bills         {"Resolution",
865684bb4b8SJason M. Bills          "Power off the specified Chassis and resubmit the request."}};
866684bb4b8SJason M. Bills }
867684bb4b8SJason M. Bills 
868684bb4b8SJason M. Bills void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1)
869684bb4b8SJason M. Bills {
870684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
871684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1));
872684bb4b8SJason M. Bills }
873684bb4b8SJason M. Bills 
874684bb4b8SJason M. Bills /**
875684bb4b8SJason M. Bills  * @internal
876684bb4b8SJason M. Bills  * @brief Formats PropertyValueConflict message into JSON
877684bb4b8SJason M. Bills  *
878684bb4b8SJason M. Bills  * See header file for more information
879684bb4b8SJason M. Bills  * @endinternal
880684bb4b8SJason M. Bills  */
881684bb4b8SJason M. Bills nlohmann::json propertyValueConflict(const std::string& arg1,
882684bb4b8SJason M. Bills                                      const std::string& arg2)
883684bb4b8SJason M. Bills {
884684bb4b8SJason M. Bills     return nlohmann::json{
8853e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
886684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueConflict"},
887684bb4b8SJason M. Bills         {"Message", "The property '" + arg1 +
888684bb4b8SJason M. Bills                         "' could not be written because its value would "
889684bb4b8SJason M. Bills                         "conflict with the value of the '" +
890684bb4b8SJason M. Bills                         arg2 + "' property."},
891684bb4b8SJason M. Bills         {"MessageArgs", {arg1, arg2}},
892684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
893684bb4b8SJason M. Bills         {"Resolution", "No resolution is required."}};
894684bb4b8SJason M. Bills }
895684bb4b8SJason M. Bills 
896684bb4b8SJason M. Bills void propertyValueConflict(crow::Response& res, const std::string& arg1,
897684bb4b8SJason M. Bills                            const std::string& arg2)
898684bb4b8SJason M. Bills {
899684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
900684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2));
901684bb4b8SJason M. Bills }
902684bb4b8SJason M. Bills 
903684bb4b8SJason M. Bills /**
904684bb4b8SJason M. Bills  * @internal
905684bb4b8SJason M. Bills  * @brief Formats PropertyValueIncorrect message into JSON
906684bb4b8SJason M. Bills  *
907684bb4b8SJason M. Bills  * See header file for more information
908684bb4b8SJason M. Bills  * @endinternal
909684bb4b8SJason M. Bills  */
910684bb4b8SJason M. Bills nlohmann::json propertyValueIncorrect(const std::string& arg1,
911684bb4b8SJason M. Bills                                       const std::string& arg2)
912684bb4b8SJason M. Bills {
913684bb4b8SJason M. Bills     return nlohmann::json{
9143e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
915684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueIncorrect"},
916684bb4b8SJason M. Bills         {"Message", "The property '" + arg1 +
917684bb4b8SJason M. Bills                         "' with the requested value of '" + arg2 +
918684bb4b8SJason M. Bills                         "' could not be written because the value does not "
919684bb4b8SJason M. Bills                         "meet the constraints of the implementation."},
920684bb4b8SJason M. Bills         {"MessageArgs", {arg1, arg2}},
921684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
922684bb4b8SJason M. Bills         {"Resolution", "No resolution is required."}};
923684bb4b8SJason M. Bills }
924684bb4b8SJason M. Bills 
925684bb4b8SJason M. Bills void propertyValueIncorrect(crow::Response& res, const std::string& arg1,
926684bb4b8SJason M. Bills                             const std::string& arg2)
927684bb4b8SJason M. Bills {
928684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
929684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2));
930684bb4b8SJason M. Bills }
931684bb4b8SJason M. Bills 
932684bb4b8SJason M. Bills /**
933684bb4b8SJason M. Bills  * @internal
934684bb4b8SJason M. Bills  * @brief Formats ResourceCreationConflict message into JSON
935684bb4b8SJason M. Bills  *
936684bb4b8SJason M. Bills  * See header file for more information
937684bb4b8SJason M. Bills  * @endinternal
938684bb4b8SJason M. Bills  */
939684bb4b8SJason M. Bills nlohmann::json resourceCreationConflict(const std::string& arg1)
940684bb4b8SJason M. Bills {
941684bb4b8SJason M. Bills     return nlohmann::json{
9423e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
943684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceCreationConflict"},
944684bb4b8SJason M. Bills         {"Message", "The resource could not be created.  The service has a "
945684bb4b8SJason M. Bills                     "resource at URI '" +
946684bb4b8SJason M. Bills                         arg1 + "' that conflicts with the creation request."},
947684bb4b8SJason M. Bills         {"MessageArgs", {arg1}},
948684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
949684bb4b8SJason M. Bills         {"Resolution", "No resolution is required."}};
950684bb4b8SJason M. Bills }
951684bb4b8SJason M. Bills 
952684bb4b8SJason M. Bills void resourceCreationConflict(crow::Response& res, const std::string& arg1)
953684bb4b8SJason M. Bills {
954684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
955684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1));
956684bb4b8SJason M. Bills }
957684bb4b8SJason M. Bills 
958684bb4b8SJason M. Bills /**
959684bb4b8SJason M. Bills  * @internal
960684bb4b8SJason M. Bills  * @brief Formats MaximumErrorsExceeded message into JSON
961684bb4b8SJason M. Bills  *
962684bb4b8SJason M. Bills  * See header file for more information
963684bb4b8SJason M. Bills  * @endinternal
964684bb4b8SJason M. Bills  */
965684bb4b8SJason M. Bills nlohmann::json maximumErrorsExceeded(void)
966684bb4b8SJason M. Bills {
967684bb4b8SJason M. Bills     return nlohmann::json{
9683e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
969684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.MaximumErrorsExceeded"},
970684bb4b8SJason M. Bills         {"Message", "Too many errors have occurred to report them all."},
971684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
972684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
973684bb4b8SJason M. Bills         {"Resolution",
974684bb4b8SJason M. Bills          "Resolve other reported errors and retry the current operation."}};
975684bb4b8SJason M. Bills }
976684bb4b8SJason M. Bills 
977684bb4b8SJason M. Bills void maximumErrorsExceeded(crow::Response& res)
978684bb4b8SJason M. Bills {
979684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
980684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded());
981684bb4b8SJason M. Bills }
982684bb4b8SJason M. Bills 
983684bb4b8SJason M. Bills /**
984684bb4b8SJason M. Bills  * @internal
985684bb4b8SJason M. Bills  * @brief Formats PreconditionFailed message into JSON
986684bb4b8SJason M. Bills  *
987684bb4b8SJason M. Bills  * See header file for more information
988684bb4b8SJason M. Bills  * @endinternal
989684bb4b8SJason M. Bills  */
990684bb4b8SJason M. Bills nlohmann::json preconditionFailed(void)
991684bb4b8SJason M. Bills {
992684bb4b8SJason M. Bills     return nlohmann::json{
9933e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
994684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PreconditionFailed"},
995684bb4b8SJason M. Bills         {"Message", "The ETag supplied did not match the ETag required to "
996684bb4b8SJason M. Bills                     "change this resource."},
997684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
998684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
999684bb4b8SJason M. Bills         {"Resolution", "Try the operation again using the appropriate ETag."}};
1000684bb4b8SJason M. Bills }
1001684bb4b8SJason M. Bills 
1002684bb4b8SJason M. Bills void preconditionFailed(crow::Response& res)
1003684bb4b8SJason M. Bills {
10044df1bee0SEd Tanous     res.result(boost::beast::http::status::precondition_failed);
1005684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionFailed());
1006684bb4b8SJason M. Bills }
1007684bb4b8SJason M. Bills 
1008684bb4b8SJason M. Bills /**
1009684bb4b8SJason M. Bills  * @internal
1010684bb4b8SJason M. Bills  * @brief Formats PreconditionRequired message into JSON
1011684bb4b8SJason M. Bills  *
1012684bb4b8SJason M. Bills  * See header file for more information
1013684bb4b8SJason M. Bills  * @endinternal
1014684bb4b8SJason M. Bills  */
1015684bb4b8SJason M. Bills nlohmann::json preconditionRequired(void)
1016684bb4b8SJason M. Bills {
1017684bb4b8SJason M. Bills     return nlohmann::json{
10183e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1019684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PreconditionRequired"},
1020684bb4b8SJason M. Bills         {"Message", "A precondition header or annotation is required to change "
1021684bb4b8SJason M. Bills                     "this resource."},
1022684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1023684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1024684bb4b8SJason M. Bills         {"Resolution", "Try the operation again using an If-Match or "
1025684bb4b8SJason M. Bills                        "If-None-Match header and appropriate ETag."}};
1026684bb4b8SJason M. Bills }
1027684bb4b8SJason M. Bills 
1028684bb4b8SJason M. Bills void preconditionRequired(crow::Response& res)
1029684bb4b8SJason M. Bills {
1030684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1031684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, preconditionRequired());
1032684bb4b8SJason M. Bills }
1033684bb4b8SJason M. Bills 
1034684bb4b8SJason M. Bills /**
1035684bb4b8SJason M. Bills  * @internal
1036684bb4b8SJason M. Bills  * @brief Formats OperationFailed message into JSON
1037684bb4b8SJason M. Bills  *
1038684bb4b8SJason M. Bills  * See header file for more information
1039684bb4b8SJason M. Bills  * @endinternal
1040684bb4b8SJason M. Bills  */
1041684bb4b8SJason M. Bills nlohmann::json operationFailed(void)
1042684bb4b8SJason M. Bills {
1043684bb4b8SJason M. Bills     return nlohmann::json{
10443e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1045684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.OperationFailed"},
1046684bb4b8SJason M. Bills         {"Message",
1047684bb4b8SJason M. Bills          "An error occurred internal to the service as part of the overall "
1048684bb4b8SJason M. Bills          "request.  Partial results may have been returned."},
1049684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1050684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1051684bb4b8SJason M. Bills         {"Resolution", "Resubmit the request.  If the problem persists, "
1052684bb4b8SJason M. Bills                        "consider resetting the service or provider."}};
1053684bb4b8SJason M. Bills }
1054684bb4b8SJason M. Bills 
1055684bb4b8SJason M. Bills void operationFailed(crow::Response& res)
1056684bb4b8SJason M. Bills {
1057684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
1058684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationFailed());
1059684bb4b8SJason M. Bills }
1060684bb4b8SJason M. Bills 
1061684bb4b8SJason M. Bills /**
1062684bb4b8SJason M. Bills  * @internal
1063684bb4b8SJason M. Bills  * @brief Formats OperationTimeout message into JSON
1064684bb4b8SJason M. Bills  *
1065684bb4b8SJason M. Bills  * See header file for more information
1066684bb4b8SJason M. Bills  * @endinternal
1067684bb4b8SJason M. Bills  */
1068684bb4b8SJason M. Bills nlohmann::json operationTimeout(void)
1069684bb4b8SJason M. Bills {
1070684bb4b8SJason M. Bills     return nlohmann::json{
10713e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1072684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.OperationTimeout"},
1073684bb4b8SJason M. Bills         {"Message", "A timeout internal to the service occured as part of the "
1074684bb4b8SJason M. Bills                     "request.  Partial results may have been returned."},
1075684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1076684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1077684bb4b8SJason M. Bills         {"Resolution", "Resubmit the request.  If the problem persists, "
1078684bb4b8SJason M. Bills                        "consider resetting the service or provider."}};
1079684bb4b8SJason M. Bills }
1080684bb4b8SJason M. Bills 
1081684bb4b8SJason M. Bills void operationTimeout(crow::Response& res)
1082684bb4b8SJason M. Bills {
1083684bb4b8SJason M. Bills     res.result(boost::beast::http::status::internal_server_error);
1084684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, operationTimeout());
1085684bb4b8SJason M. Bills }
1086684bb4b8SJason M. Bills 
1087684bb4b8SJason M. Bills /**
1088684bb4b8SJason M. Bills  * @internal
1089f12894f8SJason M. Bills  * @brief Formats PropertyValueTypeError message into JSON for the specified
1090f12894f8SJason M. Bills  * property
1091f12894f8SJason M. Bills  *
1092f12894f8SJason M. Bills  * See header file for more information
1093f12894f8SJason M. Bills  * @endinternal
1094f12894f8SJason M. Bills  */
1095b5c07418SJames Feist nlohmann::json propertyValueTypeError(const std::string& arg1,
1096a08b46ccSJason M. Bills                                       const std::string& arg2)
1097f12894f8SJason M. Bills {
1098b5c07418SJames Feist     return nlohmann::json{
10993e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1100684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueTypeError"},
1101f12894f8SJason M. Bills         {"Message",
1102f12894f8SJason M. Bills          "The value " + arg1 + " for the property " + arg2 +
1103f12894f8SJason M. Bills              " is of a different type than the property can accept."},
110485659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1105684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
110666ac2b8cSJason M. Bills         {"Resolution",
110766ac2b8cSJason M. Bills          "Correct the value for the property in the request body and "
1108b5c07418SJames Feist          "resubmit the request if the operation failed."}};
1109b5c07418SJames Feist }
1110b5c07418SJames Feist 
1111b5c07418SJames Feist void propertyValueTypeError(crow::Response& res, const std::string& arg1,
1112b5c07418SJames Feist                             const std::string& arg2)
1113b5c07418SJames Feist {
1114b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1115b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2);
1116f4c4dcf4SKowalski, Kamil }
1117f4c4dcf4SKowalski, Kamil 
1118f4c4dcf4SKowalski, Kamil /**
1119f4c4dcf4SKowalski, Kamil  * @internal
1120f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceNotFound message into JSON
1121f4c4dcf4SKowalski, Kamil  *
1122f4c4dcf4SKowalski, Kamil  * See header file for more information
1123f4c4dcf4SKowalski, Kamil  * @endinternal
1124f4c4dcf4SKowalski, Kamil  */
1125b5c07418SJames Feist nlohmann::json resourceNotFound(const std::string& arg1,
11261abe55efSEd Tanous                                 const std::string& arg2)
11271abe55efSEd Tanous {
1128b5c07418SJames Feist     return nlohmann::json{
11293e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1130684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceNotFound"},
11311abe55efSEd Tanous         {"Message", "The requested resource of type " + arg1 + " named " +
11321abe55efSEd Tanous                         arg2 + " was not found."},
113385659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1134684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1135f4c4dcf4SKowalski, Kamil         {"Resolution",
1136b5c07418SJames Feist          "Provide a valid resource identifier and resubmit the request."}};
1137b5c07418SJames Feist }
1138b5c07418SJames Feist 
1139b5c07418SJames Feist void resourceNotFound(crow::Response& res, const std::string& arg1,
1140b5c07418SJames Feist                       const std::string& arg2)
1141b5c07418SJames Feist {
1142b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1143b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2));
1144f4c4dcf4SKowalski, Kamil }
1145f4c4dcf4SKowalski, Kamil 
1146f4c4dcf4SKowalski, Kamil /**
1147f4c4dcf4SKowalski, Kamil  * @internal
1148f4c4dcf4SKowalski, Kamil  * @brief Formats CouldNotEstablishConnection message into JSON
1149f4c4dcf4SKowalski, Kamil  *
1150f4c4dcf4SKowalski, Kamil  * See header file for more information
1151f4c4dcf4SKowalski, Kamil  * @endinternal
1152f4c4dcf4SKowalski, Kamil  */
1153b5c07418SJames Feist nlohmann::json couldNotEstablishConnection(const std::string& arg1)
11541abe55efSEd Tanous {
1155b5c07418SJames Feist     return nlohmann::json{
11563e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1157684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.CouldNotEstablishConnection"},
11581abe55efSEd Tanous         {"Message",
1159684bb4b8SJason M. Bills          "The service failed to establish a connection with the URI " + arg1 +
1160b5c07418SJames Feist              "."},
116185659adfSJason M. Bills         {"MessageArgs", {arg1}},
1162684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
116366ac2b8cSJason M. Bills         {"Resolution",
116466ac2b8cSJason M. Bills          "Ensure that the URI contains a valid and reachable node name, "
1165b5c07418SJames Feist          "protocol information and other URI components."}};
1166b5c07418SJames Feist }
1167b5c07418SJames Feist 
1168b5c07418SJames Feist void couldNotEstablishConnection(crow::Response& res, const std::string& arg1)
1169b5c07418SJames Feist {
1170b5c07418SJames Feist     res.result(boost::beast::http::status::not_found);
1171b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1));
1172f4c4dcf4SKowalski, Kamil }
1173f4c4dcf4SKowalski, Kamil 
1174f4c4dcf4SKowalski, Kamil /**
1175f4c4dcf4SKowalski, Kamil  * @internal
1176f12894f8SJason M. Bills  * @brief Formats PropertyNotWritable message into JSON for the specified
1177f12894f8SJason M. Bills  * property
1178f12894f8SJason M. Bills  *
1179f12894f8SJason M. Bills  * See header file for more information
1180f12894f8SJason M. Bills  * @endinternal
1181f12894f8SJason M. Bills  */
1182b5c07418SJames Feist nlohmann::json propertyNotWritable(const std::string& arg1)
1183f12894f8SJason M. Bills {
1184b5c07418SJames Feist     return nlohmann::json{
11853e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1186684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyNotWritable"},
1187b5c07418SJames Feist         {"Message", "The property " + arg1 +
1188b5c07418SJames Feist                         " is a read only property and cannot be "
1189b5c07418SJames Feist                         "assigned a value."},
119085659adfSJason M. Bills         {"MessageArgs", {arg1}},
1191684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
119266ac2b8cSJason M. Bills         {"Resolution", "Remove the property from the request body and "
1193b5c07418SJames Feist                        "resubmit the request if the operation failed."}};
1194b5c07418SJames Feist }
1195b5c07418SJames Feist 
1196b5c07418SJames Feist void propertyNotWritable(crow::Response& res, const std::string& arg1)
1197b5c07418SJames Feist {
1198b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1199b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1);
1200f4c4dcf4SKowalski, Kamil }
1201f4c4dcf4SKowalski, Kamil 
1202f4c4dcf4SKowalski, Kamil /**
1203f4c4dcf4SKowalski, Kamil  * @internal
1204f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueTypeError message into JSON
1205f4c4dcf4SKowalski, Kamil  *
1206f4c4dcf4SKowalski, Kamil  * See header file for more information
1207f4c4dcf4SKowalski, Kamil  * @endinternal
1208f4c4dcf4SKowalski, Kamil  */
1209b5c07418SJames Feist nlohmann::json queryParameterValueTypeError(const std::string& arg1,
12101abe55efSEd Tanous                                             const std::string& arg2)
12111abe55efSEd Tanous {
1212b5c07418SJames Feist     return nlohmann::json{
12133e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1214684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryParameterValueTypeError"},
12151abe55efSEd Tanous         {"Message",
12161abe55efSEd Tanous          "The value " + arg1 + " for the query parameter " + arg2 +
1217f4c4dcf4SKowalski, Kamil              " is of a different type than the parameter can accept."},
121885659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1219684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
122066ac2b8cSJason M. Bills         {"Resolution",
122166ac2b8cSJason M. Bills          "Correct the value for the query parameter in the request and "
1222b5c07418SJames Feist          "resubmit the request if the operation failed."}};
1223b5c07418SJames Feist }
1224b5c07418SJames Feist 
1225b5c07418SJames Feist void queryParameterValueTypeError(crow::Response& res, const std::string& arg1,
1226b5c07418SJames Feist                                   const std::string& arg2)
1227b5c07418SJames Feist {
1228b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1229b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1230b5c07418SJames Feist                           queryParameterValueTypeError(arg1, arg2));
1231f4c4dcf4SKowalski, Kamil }
1232f4c4dcf4SKowalski, Kamil 
1233f4c4dcf4SKowalski, Kamil /**
1234f4c4dcf4SKowalski, Kamil  * @internal
1235f4c4dcf4SKowalski, Kamil  * @brief Formats ServiceShuttingDown message into JSON
1236f4c4dcf4SKowalski, Kamil  *
1237f4c4dcf4SKowalski, Kamil  * See header file for more information
1238f4c4dcf4SKowalski, Kamil  * @endinternal
1239f4c4dcf4SKowalski, Kamil  */
1240b5c07418SJames Feist nlohmann::json serviceShuttingDown(void)
12411abe55efSEd Tanous {
1242b5c07418SJames Feist     return nlohmann::json{
12433e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1244684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ServiceShuttingDown"},
1245f12894f8SJason M. Bills         {"Message", "The operation failed because the service is shutting "
124666ac2b8cSJason M. Bills                     "down and can no longer take incoming requests."},
124785659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1248684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
124966ac2b8cSJason M. Bills         {"Resolution", "When the service becomes available, resubmit the "
1250b5c07418SJames Feist                        "request if the operation failed."}};
1251b5c07418SJames Feist }
1252b5c07418SJames Feist 
1253b5c07418SJames Feist void serviceShuttingDown(crow::Response& res)
1254b5c07418SJames Feist {
1255b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1256b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, serviceShuttingDown());
1257f4c4dcf4SKowalski, Kamil }
1258f4c4dcf4SKowalski, Kamil 
1259f4c4dcf4SKowalski, Kamil /**
1260f4c4dcf4SKowalski, Kamil  * @internal
1261f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterDuplicate message into JSON
1262f4c4dcf4SKowalski, Kamil  *
1263f4c4dcf4SKowalski, Kamil  * See header file for more information
1264f4c4dcf4SKowalski, Kamil  * @endinternal
1265f4c4dcf4SKowalski, Kamil  */
1266b5c07418SJames Feist nlohmann::json actionParameterDuplicate(const std::string& arg1,
12671abe55efSEd Tanous                                         const std::string& arg2)
12681abe55efSEd Tanous {
1269b5c07418SJames Feist     return nlohmann::json{
12703e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1271684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterDuplicate"},
1272f4c4dcf4SKowalski, Kamil         {"Message",
1273f4c4dcf4SKowalski, Kamil          "The action " + arg1 +
12741abe55efSEd Tanous              " was submitted with more than one value for the parameter " +
12751abe55efSEd Tanous              arg2 + "."},
127685659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1277684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
127866ac2b8cSJason M. Bills         {"Resolution",
127966ac2b8cSJason M. Bills          "Resubmit the action with only one instance of the parameter in "
1280b5c07418SJames Feist          "the request body if the operation failed."}};
1281b5c07418SJames Feist }
1282b5c07418SJames Feist 
1283b5c07418SJames Feist void actionParameterDuplicate(crow::Response& res, const std::string& arg1,
1284b5c07418SJames Feist                               const std::string& arg2)
1285b5c07418SJames Feist {
1286b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1287b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2));
1288f4c4dcf4SKowalski, Kamil }
1289f4c4dcf4SKowalski, Kamil 
1290f4c4dcf4SKowalski, Kamil /**
1291f4c4dcf4SKowalski, Kamil  * @internal
1292f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterNotSupported message into JSON
1293f4c4dcf4SKowalski, Kamil  *
1294f4c4dcf4SKowalski, Kamil  * See header file for more information
1295f4c4dcf4SKowalski, Kamil  * @endinternal
1296f4c4dcf4SKowalski, Kamil  */
1297b5c07418SJames Feist nlohmann::json actionParameterNotSupported(const std::string& arg1,
12981abe55efSEd Tanous                                            const std::string& arg2)
12991abe55efSEd Tanous {
1300b5c07418SJames Feist     return nlohmann::json{
13013e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1302684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterNotSupported"},
1303f4c4dcf4SKowalski, Kamil         {"Message", "The parameter " + arg1 + " for the action " + arg2 +
1304f4c4dcf4SKowalski, Kamil                         " is not supported on the target resource."},
130585659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1306684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
130766ac2b8cSJason M. Bills         {"Resolution", "Remove the parameter supplied and resubmit the "
1308b5c07418SJames Feist                        "request if the operation failed."}};
1309b5c07418SJames Feist }
1310b5c07418SJames Feist 
1311b5c07418SJames Feist void actionParameterNotSupported(crow::Response& res, const std::string& arg1,
1312b5c07418SJames Feist                                  const std::string& arg2)
1313b5c07418SJames Feist {
1314b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1315b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1316b5c07418SJames Feist                           actionParameterNotSupported(arg1, arg2));
1317f4c4dcf4SKowalski, Kamil }
1318f4c4dcf4SKowalski, Kamil 
1319f4c4dcf4SKowalski, Kamil /**
1320f4c4dcf4SKowalski, Kamil  * @internal
1321f4c4dcf4SKowalski, Kamil  * @brief Formats SourceDoesNotSupportProtocol message into JSON
1322f4c4dcf4SKowalski, Kamil  *
1323f4c4dcf4SKowalski, Kamil  * See header file for more information
1324f4c4dcf4SKowalski, Kamil  * @endinternal
1325f4c4dcf4SKowalski, Kamil  */
1326b5c07418SJames Feist nlohmann::json sourceDoesNotSupportProtocol(const std::string& arg1,
13271abe55efSEd Tanous                                             const std::string& arg2)
13281abe55efSEd Tanous {
1329b5c07418SJames Feist     return nlohmann::json{
13303e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1331684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.SourceDoesNotSupportProtocol"},
1332684bb4b8SJason M. Bills         {"Message", "The other end of the connection at " + arg1 +
13331abe55efSEd Tanous                         " does not support the specified protocol " + arg2 +
13341abe55efSEd Tanous                         "."},
133585659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1336684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1337b5c07418SJames Feist         {"Resolution", "Change protocols or URIs. "}};
1338b5c07418SJames Feist }
1339b5c07418SJames Feist 
1340b5c07418SJames Feist void sourceDoesNotSupportProtocol(crow::Response& res, const std::string& arg1,
1341b5c07418SJames Feist                                   const std::string& arg2)
1342b5c07418SJames Feist {
1343b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1344b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1345b5c07418SJames Feist                           sourceDoesNotSupportProtocol(arg1, arg2));
1346f4c4dcf4SKowalski, Kamil }
1347f4c4dcf4SKowalski, Kamil 
1348f4c4dcf4SKowalski, Kamil /**
1349f4c4dcf4SKowalski, Kamil  * @internal
1350f4c4dcf4SKowalski, Kamil  * @brief Formats AccountRemoved message into JSON
1351f4c4dcf4SKowalski, Kamil  *
1352f4c4dcf4SKowalski, Kamil  * See header file for more information
1353f4c4dcf4SKowalski, Kamil  * @endinternal
1354f4c4dcf4SKowalski, Kamil  */
1355b5c07418SJames Feist nlohmann::json accountRemoved(void)
13561abe55efSEd Tanous {
13573e082749SAsmitha Karunanithi     return nlohmann::json{{"@odata.type", "#Message.v1_1_1.Message"},
1358684bb4b8SJason M. Bills                           {"MessageId", "Base.1.8.1.AccountRemoved"},
1359f4c4dcf4SKowalski, Kamil                           {"Message", "The account was successfully removed."},
136085659adfSJason M. Bills                           {"MessageArgs", nlohmann::json::array()},
1361684bb4b8SJason M. Bills                           {"MessageSeverity", "OK"},
1362b5c07418SJames Feist                           {"Resolution", "No resolution is required."}};
1363b5c07418SJames Feist }
1364b5c07418SJames Feist 
1365b5c07418SJames Feist void accountRemoved(crow::Response& res)
1366b5c07418SJames Feist {
1367b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
1368b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, accountRemoved());
1369f4c4dcf4SKowalski, Kamil }
1370f4c4dcf4SKowalski, Kamil 
1371f4c4dcf4SKowalski, Kamil /**
1372f4c4dcf4SKowalski, Kamil  * @internal
1373f4c4dcf4SKowalski, Kamil  * @brief Formats AccessDenied message into JSON
1374f4c4dcf4SKowalski, Kamil  *
1375f4c4dcf4SKowalski, Kamil  * See header file for more information
1376f4c4dcf4SKowalski, Kamil  * @endinternal
1377f4c4dcf4SKowalski, Kamil  */
1378b5c07418SJames Feist nlohmann::json accessDenied(const std::string& arg1)
13791abe55efSEd Tanous {
1380b5c07418SJames Feist     return nlohmann::json{
13813e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1382684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.AccessDenied"},
1383684bb4b8SJason M. Bills         {"Message", "While attempting to establish a connection to " + arg1 +
1384b5c07418SJames Feist                         ", the service denied access."},
138585659adfSJason M. Bills         {"MessageArgs", {arg1}},
1386684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
138766ac2b8cSJason M. Bills         {"Resolution", "Attempt to ensure that the URI is correct and that "
1388b5c07418SJames Feist                        "the service has the appropriate credentials."}};
1389b5c07418SJames Feist }
1390b5c07418SJames Feist 
1391b5c07418SJames Feist void accessDenied(crow::Response& res, const std::string& arg1)
1392b5c07418SJames Feist {
1393b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1394b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accessDenied(arg1));
1395f4c4dcf4SKowalski, Kamil }
1396f4c4dcf4SKowalski, Kamil 
1397f4c4dcf4SKowalski, Kamil /**
1398f4c4dcf4SKowalski, Kamil  * @internal
1399f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupported message into JSON
1400f4c4dcf4SKowalski, Kamil  *
1401f4c4dcf4SKowalski, Kamil  * See header file for more information
1402f4c4dcf4SKowalski, Kamil  * @endinternal
1403f4c4dcf4SKowalski, Kamil  */
1404b5c07418SJames Feist nlohmann::json queryNotSupported(void)
14051abe55efSEd Tanous {
1406b5c07418SJames Feist     return nlohmann::json{
14073e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1408684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryNotSupported"},
1409f4c4dcf4SKowalski, Kamil         {"Message", "Querying is not supported by the implementation."},
141085659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1411684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
141266ac2b8cSJason M. Bills         {"Resolution", "Remove the query parameters and resubmit the "
1413b5c07418SJames Feist                        "request if the operation failed."}};
1414b5c07418SJames Feist }
1415b5c07418SJames Feist 
1416b5c07418SJames Feist void queryNotSupported(crow::Response& res)
1417b5c07418SJames Feist {
1418b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1419b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupported());
1420f4c4dcf4SKowalski, Kamil }
1421f4c4dcf4SKowalski, Kamil 
1422f4c4dcf4SKowalski, Kamil /**
1423f4c4dcf4SKowalski, Kamil  * @internal
1424f4c4dcf4SKowalski, Kamil  * @brief Formats CreateLimitReachedForResource message into JSON
1425f4c4dcf4SKowalski, Kamil  *
1426f4c4dcf4SKowalski, Kamil  * See header file for more information
1427f4c4dcf4SKowalski, Kamil  * @endinternal
1428f4c4dcf4SKowalski, Kamil  */
1429b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void)
14301abe55efSEd Tanous {
1431b5c07418SJames Feist     return nlohmann::json{
14323e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1433684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.CreateLimitReachedForResource"},
14341abe55efSEd Tanous         {"Message", "The create operation failed because the resource has "
143566ac2b8cSJason M. Bills                     "reached the limit of possible resources."},
143685659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1437684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
143866ac2b8cSJason M. Bills         {"Resolution",
143966ac2b8cSJason M. Bills          "Either delete resources and resubmit the request if the "
1440b5c07418SJames Feist          "operation failed or do not resubmit the request."}};
1441b5c07418SJames Feist }
1442b5c07418SJames Feist 
1443b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res)
1444b5c07418SJames Feist {
1445b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1446b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, createLimitReachedForResource());
1447f4c4dcf4SKowalski, Kamil }
1448f4c4dcf4SKowalski, Kamil 
1449f4c4dcf4SKowalski, Kamil /**
1450f4c4dcf4SKowalski, Kamil  * @internal
1451f4c4dcf4SKowalski, Kamil  * @brief Formats GeneralError message into JSON
1452f4c4dcf4SKowalski, Kamil  *
1453f4c4dcf4SKowalski, Kamil  * See header file for more information
1454f4c4dcf4SKowalski, Kamil  * @endinternal
1455f4c4dcf4SKowalski, Kamil  */
1456b5c07418SJames Feist nlohmann::json generalError(void)
14571abe55efSEd Tanous {
14583e082749SAsmitha Karunanithi     return nlohmann::json{{"@odata.type", "#Message.v1_1_1.Message"},
1459684bb4b8SJason M. Bills                           {"MessageId", "Base.1.8.1.GeneralError"},
1460b7e069efSJames Feist                           {"Message",
1461b7e069efSJames Feist                            "A general error has occurred. See Resolution for "
1462cc9139ecSJason M. Bills                            "information on how to resolve the error."},
146385659adfSJason M. Bills                           {"MessageArgs", nlohmann::json::array()},
1464684bb4b8SJason M. Bills                           {"MessageSeverity", "Critical"},
1465b5c07418SJames Feist                           {"Resolution", "None."}};
1466b5c07418SJames Feist }
1467b5c07418SJames Feist 
1468b5c07418SJames Feist void generalError(crow::Response& res)
1469b5c07418SJames Feist {
1470b5c07418SJames Feist     res.result(boost::beast::http::status::internal_server_error);
1471b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, generalError());
1472f4c4dcf4SKowalski, Kamil }
1473f4c4dcf4SKowalski, Kamil 
1474f4c4dcf4SKowalski, Kamil /**
1475f4c4dcf4SKowalski, Kamil  * @internal
1476f4c4dcf4SKowalski, Kamil  * @brief Formats Success message into JSON
1477f4c4dcf4SKowalski, Kamil  *
1478f4c4dcf4SKowalski, Kamil  * See header file for more information
1479f4c4dcf4SKowalski, Kamil  * @endinternal
1480f4c4dcf4SKowalski, Kamil  */
1481b5c07418SJames Feist nlohmann::json success(void)
14821abe55efSEd Tanous {
14833e082749SAsmitha Karunanithi     return nlohmann::json{{"@odata.type", "#Message.v1_1_1.Message"},
1484684bb4b8SJason M. Bills                           {"MessageId", "Base.1.8.1.Success"},
1485f4c4dcf4SKowalski, Kamil                           {"Message", "Successfully Completed Request"},
148685659adfSJason M. Bills                           {"MessageArgs", nlohmann::json::array()},
1487684bb4b8SJason M. Bills                           {"MessageSeverity", "OK"},
1488b5c07418SJames Feist                           {"Resolution", "None"}};
1489b5c07418SJames Feist }
1490b5c07418SJames Feist 
1491b5c07418SJames Feist void success(crow::Response& res)
1492b5c07418SJames Feist {
1493b5c07418SJames Feist     // don't set res.result here because success is the default and any
1494b5c07418SJames Feist     // error should overwrite the default
1495b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, success());
1496f12894f8SJason M. Bills }
1497f12894f8SJason M. Bills 
1498f12894f8SJason M. Bills /**
1499f12894f8SJason M. Bills  * @internal
1500f4c4dcf4SKowalski, Kamil  * @brief Formats Created message into JSON
1501f4c4dcf4SKowalski, Kamil  *
1502f4c4dcf4SKowalski, Kamil  * See header file for more information
1503f4c4dcf4SKowalski, Kamil  * @endinternal
1504f4c4dcf4SKowalski, Kamil  */
1505b5c07418SJames Feist nlohmann::json created(void)
15061abe55efSEd Tanous {
1507b5c07418SJames Feist     return nlohmann::json{
15083e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1509684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.Created"},
1510f4c4dcf4SKowalski, Kamil         {"Message", "The resource has been created successfully"},
151185659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1512684bb4b8SJason M. Bills         {"MessageSeverity", "OK"},
1513b5c07418SJames Feist         {"Resolution", "None"}};
1514b5c07418SJames Feist }
1515b5c07418SJames Feist 
1516b5c07418SJames Feist void created(crow::Response& res)
1517b5c07418SJames Feist {
1518b5c07418SJames Feist     res.result(boost::beast::http::status::created);
1519b5c07418SJames Feist     addMessageToJsonRoot(res.jsonValue, created());
1520f4c4dcf4SKowalski, Kamil }
1521f4c4dcf4SKowalski, Kamil 
1522f4c4dcf4SKowalski, Kamil /**
1523f4c4dcf4SKowalski, Kamil  * @internal
1524cc9139ecSJason M. Bills  * @brief Formats NoOperation message into JSON
1525cc9139ecSJason M. Bills  *
1526cc9139ecSJason M. Bills  * See header file for more information
1527cc9139ecSJason M. Bills  * @endinternal
1528cc9139ecSJason M. Bills  */
1529b5c07418SJames Feist nlohmann::json noOperation(void)
1530cc9139ecSJason M. Bills {
1531b5c07418SJames Feist     return nlohmann::json{
15323e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1533684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.NoOperation"},
1534cc9139ecSJason M. Bills         {"Message", "The request body submitted contain no data to act "
1535cc9139ecSJason M. Bills                     "upon and no changes to the resource took place."},
153685659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1537684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1538cc9139ecSJason M. Bills         {"Resolution",
1539b5c07418SJames Feist          "Add properties in the JSON object and resubmit the request."}};
1540b5c07418SJames Feist }
1541b5c07418SJames Feist 
1542b5c07418SJames Feist void noOperation(crow::Response& res)
1543b5c07418SJames Feist {
1544b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1545b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noOperation());
1546cc9139ecSJason M. Bills }
1547cc9139ecSJason M. Bills 
1548cc9139ecSJason M. Bills /**
1549cc9139ecSJason M. Bills  * @internal
1550b5c07418SJames Feist  * @brief Formats PropertyUnknown message into JSON for the specified
1551b5c07418SJames Feist  * property
1552f12894f8SJason M. Bills  *
1553f12894f8SJason M. Bills  * See header file for more information
1554f12894f8SJason M. Bills  * @endinternal
1555f12894f8SJason M. Bills  */
1556b5c07418SJames Feist nlohmann::json propertyUnknown(const std::string& arg1)
1557b5c07418SJames Feist {
1558b5c07418SJames Feist     return nlohmann::json{
15593e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1560684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyUnknown"},
1561b5c07418SJames Feist         {"Message", "The property " + arg1 +
1562b5c07418SJames Feist                         " is not in the list of valid properties for "
1563b5c07418SJames Feist                         "the resource."},
1564b5c07418SJames Feist         {"MessageArgs", {arg1}},
1565684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1566b5c07418SJames Feist         {"Resolution", "Remove the unknown property from the request "
1567b5c07418SJames Feist                        "body and resubmit "
1568b5c07418SJames Feist                        "the request if the operation failed."}};
1569b5c07418SJames Feist }
1570b5c07418SJames Feist 
1571a08b46ccSJason M. Bills void propertyUnknown(crow::Response& res, const std::string& arg1)
1572f12894f8SJason M. Bills {
1573f12894f8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1574b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1);
1575f4c4dcf4SKowalski, Kamil }
1576f4c4dcf4SKowalski, Kamil 
1577f4c4dcf4SKowalski, Kamil /**
1578f4c4dcf4SKowalski, Kamil  * @internal
1579f4c4dcf4SKowalski, Kamil  * @brief Formats NoValidSession message into JSON
1580f4c4dcf4SKowalski, Kamil  *
1581f4c4dcf4SKowalski, Kamil  * See header file for more information
1582f4c4dcf4SKowalski, Kamil  * @endinternal
1583f4c4dcf4SKowalski, Kamil  */
1584b5c07418SJames Feist nlohmann::json noValidSession(void)
15851abe55efSEd Tanous {
1586b5c07418SJames Feist     return nlohmann::json{
15873e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1588684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.NoValidSession"},
1589f4c4dcf4SKowalski, Kamil         {"Message",
1590f4c4dcf4SKowalski, Kamil          "There is no valid session established with the implementation."},
159185659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1592684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
15931abe55efSEd Tanous         {"Resolution",
1594684bb4b8SJason M. Bills          "Establish a session before attempting any operations."}};
1595b5c07418SJames Feist }
1596b5c07418SJames Feist 
1597b5c07418SJames Feist void noValidSession(crow::Response& res)
1598b5c07418SJames Feist {
1599b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1600b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, noValidSession());
1601f4c4dcf4SKowalski, Kamil }
1602f4c4dcf4SKowalski, Kamil 
1603f4c4dcf4SKowalski, Kamil /**
1604f4c4dcf4SKowalski, Kamil  * @internal
1605f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidObject message into JSON
1606f4c4dcf4SKowalski, Kamil  *
1607f4c4dcf4SKowalski, Kamil  * See header file for more information
1608f4c4dcf4SKowalski, Kamil  * @endinternal
1609f4c4dcf4SKowalski, Kamil  */
1610b5c07418SJames Feist nlohmann::json invalidObject(const std::string& arg1)
16111abe55efSEd Tanous {
1612b5c07418SJames Feist     return nlohmann::json{
16133e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1614684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.InvalidObject"},
1615f4c4dcf4SKowalski, Kamil         {"Message", "The object at " + arg1 + " is invalid."},
161685659adfSJason M. Bills         {"MessageArgs", {arg1}},
1617684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1618f12894f8SJason M. Bills         {"Resolution",
161966ac2b8cSJason M. Bills          "Either the object is malformed or the URI is not correct.  "
1620b5c07418SJames Feist          "Correct the condition and resubmit the request if it failed."}};
1621b5c07418SJames Feist }
1622b5c07418SJames Feist 
1623b5c07418SJames Feist void invalidObject(crow::Response& res, const std::string& arg1)
1624b5c07418SJames Feist {
1625b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1626b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidObject(arg1));
1627f4c4dcf4SKowalski, Kamil }
1628f4c4dcf4SKowalski, Kamil 
1629f4c4dcf4SKowalski, Kamil /**
1630f4c4dcf4SKowalski, Kamil  * @internal
1631f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceInStandby message into JSON
1632f4c4dcf4SKowalski, Kamil  *
1633f4c4dcf4SKowalski, Kamil  * See header file for more information
1634f4c4dcf4SKowalski, Kamil  * @endinternal
1635f4c4dcf4SKowalski, Kamil  */
1636b5c07418SJames Feist nlohmann::json resourceInStandby(void)
16371abe55efSEd Tanous {
1638b5c07418SJames Feist     return nlohmann::json{
16393e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1640684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceInStandby"},
164166ac2b8cSJason M. Bills         {"Message", "The request could not be performed because the "
164266ac2b8cSJason M. Bills                     "resource is in standby."},
164385659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1644684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1645f12894f8SJason M. Bills         {"Resolution", "Ensure that the resource is in the correct power "
1646b5c07418SJames Feist                        "state and resubmit the request."}};
1647b5c07418SJames Feist }
1648b5c07418SJames Feist 
1649b5c07418SJames Feist void resourceInStandby(crow::Response& res)
1650b5c07418SJames Feist {
1651b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1652b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceInStandby());
1653f4c4dcf4SKowalski, Kamil }
1654f4c4dcf4SKowalski, Kamil 
1655f4c4dcf4SKowalski, Kamil /**
1656f4c4dcf4SKowalski, Kamil  * @internal
1657f4c4dcf4SKowalski, Kamil  * @brief Formats ActionParameterValueTypeError message into JSON
1658f4c4dcf4SKowalski, Kamil  *
1659f4c4dcf4SKowalski, Kamil  * See header file for more information
1660f4c4dcf4SKowalski, Kamil  * @endinternal
1661f4c4dcf4SKowalski, Kamil  */
1662b5c07418SJames Feist nlohmann::json actionParameterValueTypeError(const std::string& arg1,
1663f4c4dcf4SKowalski, Kamil                                              const std::string& arg2,
16641abe55efSEd Tanous                                              const std::string& arg3)
16651abe55efSEd Tanous {
1666b5c07418SJames Feist     return nlohmann::json{
16673e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1668684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionParameterValueTypeError"},
16691abe55efSEd Tanous         {"Message",
16701abe55efSEd Tanous          "The value " + arg1 + " for the parameter " + arg2 +
1671f4c4dcf4SKowalski, Kamil              " in the action " + arg3 +
1672f4c4dcf4SKowalski, Kamil              " is of a different type than the parameter can accept."},
167385659adfSJason M. Bills         {"MessageArgs", {arg1, arg2, arg3}},
1674684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
167566ac2b8cSJason M. Bills         {"Resolution",
167666ac2b8cSJason M. Bills          "Correct the value for the parameter in the request body and "
1677b5c07418SJames Feist          "resubmit the request if the operation failed."}};
1678b5c07418SJames Feist }
1679b5c07418SJames Feist 
1680b5c07418SJames Feist void actionParameterValueTypeError(crow::Response& res, const std::string& arg1,
1681b5c07418SJames Feist                                    const std::string& arg2,
1682b5c07418SJames Feist                                    const std::string& arg3)
1683b5c07418SJames Feist {
1684b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1685b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1686b5c07418SJames Feist                           actionParameterValueTypeError(arg1, arg2, arg3));
1687f4c4dcf4SKowalski, Kamil }
1688f4c4dcf4SKowalski, Kamil 
1689f4c4dcf4SKowalski, Kamil /**
1690f4c4dcf4SKowalski, Kamil  * @internal
1691f4c4dcf4SKowalski, Kamil  * @brief Formats SessionLimitExceeded message into JSON
1692f4c4dcf4SKowalski, Kamil  *
1693f4c4dcf4SKowalski, Kamil  * See header file for more information
1694f4c4dcf4SKowalski, Kamil  * @endinternal
1695f4c4dcf4SKowalski, Kamil  */
1696b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void)
16971abe55efSEd Tanous {
1698b5c07418SJames Feist     return nlohmann::json{
16993e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1700684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.SessionLimitExceeded"},
1701f12894f8SJason M. Bills         {"Message", "The session establishment failed due to the number of "
170266ac2b8cSJason M. Bills                     "simultaneous sessions exceeding the limit of the "
170366ac2b8cSJason M. Bills                     "implementation."},
170485659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1705684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
170666ac2b8cSJason M. Bills         {"Resolution", "Reduce the number of other sessions before trying "
170766ac2b8cSJason M. Bills                        "to establish the session or increase the limit of "
1708b5c07418SJames Feist                        "simultaneous sessions (if supported)."}};
1709b5c07418SJames Feist }
1710b5c07418SJames Feist 
1711b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res)
1712b5c07418SJames Feist {
1713b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
1714b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, sessionLimitExceeded());
1715f4c4dcf4SKowalski, Kamil }
1716f4c4dcf4SKowalski, Kamil 
1717f4c4dcf4SKowalski, Kamil /**
1718f4c4dcf4SKowalski, Kamil  * @internal
1719f4c4dcf4SKowalski, Kamil  * @brief Formats ActionNotSupported message into JSON
1720f4c4dcf4SKowalski, Kamil  *
1721f4c4dcf4SKowalski, Kamil  * See header file for more information
1722f4c4dcf4SKowalski, Kamil  * @endinternal
1723f4c4dcf4SKowalski, Kamil  */
1724b5c07418SJames Feist nlohmann::json actionNotSupported(const std::string& arg1)
17251abe55efSEd Tanous {
1726b5c07418SJames Feist     return nlohmann::json{
17273e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1728684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ActionNotSupported"},
17291abe55efSEd Tanous         {"Message",
17301abe55efSEd Tanous          "The action " + arg1 + " is not supported by the resource."},
173185659adfSJason M. Bills         {"MessageArgs", {arg1}},
1732684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1733f4c4dcf4SKowalski, Kamil         {"Resolution",
1734f4c4dcf4SKowalski, Kamil          "The action supplied cannot be resubmitted to the implementation. "
1735f12894f8SJason M. Bills          " Perhaps the action was invalid, the wrong resource was the "
173666ac2b8cSJason M. Bills          "target or the implementation documentation may be of "
1737b5c07418SJames Feist          "assistance."}};
1738b5c07418SJames Feist }
1739b5c07418SJames Feist 
1740b5c07418SJames Feist void actionNotSupported(crow::Response& res, const std::string& arg1)
1741b5c07418SJames Feist {
1742b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1743b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1));
1744f4c4dcf4SKowalski, Kamil }
1745f4c4dcf4SKowalski, Kamil 
1746f4c4dcf4SKowalski, Kamil /**
1747f4c4dcf4SKowalski, Kamil  * @internal
1748f4c4dcf4SKowalski, Kamil  * @brief Formats InvalidIndex message into JSON
1749f4c4dcf4SKowalski, Kamil  *
1750f4c4dcf4SKowalski, Kamil  * See header file for more information
1751f4c4dcf4SKowalski, Kamil  * @endinternal
1752f4c4dcf4SKowalski, Kamil  */
1753*5187e09bSJosh Lehan nlohmann::json invalidIndex(int64_t arg1)
17541abe55efSEd Tanous {
1755b5c07418SJames Feist     return nlohmann::json{
17563e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1757684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.InvalidIndex"},
1758684bb4b8SJason M. Bills         {"Message", "The Index " + std::to_string(arg1) +
1759f4c4dcf4SKowalski, Kamil                         " is not a valid offset into the array."},
176085659adfSJason M. Bills         {"MessageArgs", {std::to_string(arg1)}},
1761684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1762f12894f8SJason M. Bills         {"Resolution", "Verify the index value provided is within the "
1763b5c07418SJames Feist                        "bounds of the array."}};
1764b5c07418SJames Feist }
1765b5c07418SJames Feist 
1766*5187e09bSJosh Lehan void invalidIndex(crow::Response& res, int64_t arg1)
1767b5c07418SJames Feist {
1768b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1769b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, invalidIndex(arg1));
1770f4c4dcf4SKowalski, Kamil }
1771f4c4dcf4SKowalski, Kamil 
1772f4c4dcf4SKowalski, Kamil /**
1773f4c4dcf4SKowalski, Kamil  * @internal
1774f4c4dcf4SKowalski, Kamil  * @brief Formats EmptyJSON message into JSON
1775f4c4dcf4SKowalski, Kamil  *
1776f4c4dcf4SKowalski, Kamil  * See header file for more information
1777f4c4dcf4SKowalski, Kamil  * @endinternal
1778f4c4dcf4SKowalski, Kamil  */
1779b5c07418SJames Feist nlohmann::json emptyJSON(void)
17801abe55efSEd Tanous {
1781b5c07418SJames Feist     return nlohmann::json{
17823e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1783684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.EmptyJSON"},
1784f12894f8SJason M. Bills         {"Message", "The request body submitted contained an empty JSON "
178566ac2b8cSJason M. Bills                     "object and the service is unable to process it."},
178685659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1787684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1788f4c4dcf4SKowalski, Kamil         {"Resolution",
1789b5c07418SJames Feist          "Add properties in the JSON object and resubmit the request."}};
1790b5c07418SJames Feist }
1791b5c07418SJames Feist 
1792b5c07418SJames Feist void emptyJSON(crow::Response& res)
1793b5c07418SJames Feist {
1794b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1795b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, emptyJSON());
1796f4c4dcf4SKowalski, Kamil }
1797f4c4dcf4SKowalski, Kamil 
1798f4c4dcf4SKowalski, Kamil /**
1799f4c4dcf4SKowalski, Kamil  * @internal
1800f4c4dcf4SKowalski, Kamil  * @brief Formats QueryNotSupportedOnResource message into JSON
1801f4c4dcf4SKowalski, Kamil  *
1802f4c4dcf4SKowalski, Kamil  * See header file for more information
1803f4c4dcf4SKowalski, Kamil  * @endinternal
1804f4c4dcf4SKowalski, Kamil  */
1805b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void)
18061abe55efSEd Tanous {
1807b5c07418SJames Feist     return nlohmann::json{
18083e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1809684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryNotSupportedOnResource"},
1810f4c4dcf4SKowalski, Kamil         {"Message", "Querying is not supported on the requested resource."},
181185659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1812684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
181366ac2b8cSJason M. Bills         {"Resolution", "Remove the query parameters and resubmit the "
1814b5c07418SJames Feist                        "request if the operation failed."}};
1815b5c07418SJames Feist }
1816b5c07418SJames Feist 
1817b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res)
1818b5c07418SJames Feist {
1819b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1820b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource());
1821f4c4dcf4SKowalski, Kamil }
1822f4c4dcf4SKowalski, Kamil 
1823f4c4dcf4SKowalski, Kamil /**
1824f4c4dcf4SKowalski, Kamil  * @internal
1825684bb4b8SJason M. Bills  * @brief Formats QueryNotSupportedOnOperation message into JSON
1826684bb4b8SJason M. Bills  *
1827684bb4b8SJason M. Bills  * See header file for more information
1828684bb4b8SJason M. Bills  * @endinternal
1829684bb4b8SJason M. Bills  */
1830684bb4b8SJason M. Bills nlohmann::json queryNotSupportedOnOperation(void)
1831684bb4b8SJason M. Bills {
1832684bb4b8SJason M. Bills     return nlohmann::json{
18333e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1834684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryNotSupportedOnOperation"},
1835684bb4b8SJason M. Bills         {"Message", "Querying is not supported with the requested operation."},
1836684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1837684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1838684bb4b8SJason M. Bills         {"Resolution", "Remove the query parameters and resubmit the request "
1839684bb4b8SJason M. Bills                        "if the operation failed."}};
1840684bb4b8SJason M. Bills }
1841684bb4b8SJason M. Bills 
1842684bb4b8SJason M. Bills void queryNotSupportedOnOperation(crow::Response& res)
1843684bb4b8SJason M. Bills {
1844684bb4b8SJason M. Bills     res.result(boost::beast::http::status::forbidden);
1845684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation());
1846684bb4b8SJason M. Bills }
1847684bb4b8SJason M. Bills 
1848684bb4b8SJason M. Bills /**
1849684bb4b8SJason M. Bills  * @internal
1850684bb4b8SJason M. Bills  * @brief Formats QueryCombinationInvalid message into JSON
1851684bb4b8SJason M. Bills  *
1852684bb4b8SJason M. Bills  * See header file for more information
1853684bb4b8SJason M. Bills  * @endinternal
1854684bb4b8SJason M. Bills  */
1855684bb4b8SJason M. Bills nlohmann::json queryCombinationInvalid(void)
1856684bb4b8SJason M. Bills {
1857684bb4b8SJason M. Bills     return nlohmann::json{
18583e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1859684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryCombinationInvalid"},
1860684bb4b8SJason M. Bills         {"Message", "Two or more query parameters in the request cannot be "
1861684bb4b8SJason M. Bills                     "used together."},
1862684bb4b8SJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1863684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1864684bb4b8SJason M. Bills         {"Resolution", "Remove one or more of the query parameters and "
1865684bb4b8SJason M. Bills                        "resubmit the request if the operation failed."}};
1866684bb4b8SJason M. Bills }
1867684bb4b8SJason M. Bills 
1868684bb4b8SJason M. Bills void queryCombinationInvalid(crow::Response& res)
1869684bb4b8SJason M. Bills {
1870684bb4b8SJason M. Bills     res.result(boost::beast::http::status::bad_request);
1871684bb4b8SJason M. Bills     addMessageToErrorJson(res.jsonValue, queryCombinationInvalid());
1872684bb4b8SJason M. Bills }
1873684bb4b8SJason M. Bills 
1874684bb4b8SJason M. Bills /**
1875684bb4b8SJason M. Bills  * @internal
1876f4c4dcf4SKowalski, Kamil  * @brief Formats InsufficientPrivilege message into JSON
1877f4c4dcf4SKowalski, Kamil  *
1878f4c4dcf4SKowalski, Kamil  * See header file for more information
1879f4c4dcf4SKowalski, Kamil  * @endinternal
1880f4c4dcf4SKowalski, Kamil  */
1881b5c07418SJames Feist nlohmann::json insufficientPrivilege(void)
18821abe55efSEd Tanous {
1883b5c07418SJames Feist     return nlohmann::json{
18843e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1885684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.InsufficientPrivilege"},
188666ac2b8cSJason M. Bills         {"Message", "There are insufficient privileges for the account or "
188766ac2b8cSJason M. Bills                     "credentials associated with the current session to "
188866ac2b8cSJason M. Bills                     "perform the requested operation."},
188985659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1890684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
1891f4c4dcf4SKowalski, Kamil         {"Resolution",
1892f12894f8SJason M. Bills          "Either abandon the operation or change the associated access "
1893b5c07418SJames Feist          "rights and resubmit the request if the operation failed."}};
1894b5c07418SJames Feist }
1895b5c07418SJames Feist 
1896b5c07418SJames Feist void insufficientPrivilege(crow::Response& res)
1897b5c07418SJames Feist {
1898b5c07418SJames Feist     res.result(boost::beast::http::status::forbidden);
1899b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, insufficientPrivilege());
1900f4c4dcf4SKowalski, Kamil }
1901f4c4dcf4SKowalski, Kamil 
1902f4c4dcf4SKowalski, Kamil /**
1903f4c4dcf4SKowalski, Kamil  * @internal
1904f4c4dcf4SKowalski, Kamil  * @brief Formats PropertyValueModified message into JSON
1905f4c4dcf4SKowalski, Kamil  *
1906f4c4dcf4SKowalski, Kamil  * See header file for more information
1907f4c4dcf4SKowalski, Kamil  * @endinternal
1908f4c4dcf4SKowalski, Kamil  */
1909b5c07418SJames Feist nlohmann::json propertyValueModified(const std::string& arg1,
1910b5c07418SJames Feist                                      const std::string& arg2)
1911b5c07418SJames Feist {
1912b5c07418SJames Feist     return nlohmann::json{
19133e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1914684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyValueModified"},
1915b5c07418SJames Feist         {"Message", "The property " + arg1 + " was assigned the value " + arg2 +
1916b5c07418SJames Feist                         " due to modification by the service."},
1917b5c07418SJames Feist         {"MessageArgs", {arg1, arg2}},
1918684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1919b5c07418SJames Feist         {"Resolution", "No resolution is required."}};
1920b5c07418SJames Feist }
1921b5c07418SJames Feist 
1922f12894f8SJason M. Bills void propertyValueModified(crow::Response& res, const std::string& arg1,
1923a08b46ccSJason M. Bills                            const std::string& arg2)
19241abe55efSEd Tanous {
1925f12894f8SJason M. Bills     res.result(boost::beast::http::status::ok);
1926b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1);
1927f4c4dcf4SKowalski, Kamil }
1928f4c4dcf4SKowalski, Kamil 
1929f4c4dcf4SKowalski, Kamil /**
1930f4c4dcf4SKowalski, Kamil  * @internal
1931f4c4dcf4SKowalski, Kamil  * @brief Formats AccountNotModified message into JSON
1932f4c4dcf4SKowalski, Kamil  *
1933f4c4dcf4SKowalski, Kamil  * See header file for more information
1934f4c4dcf4SKowalski, Kamil  * @endinternal
1935f4c4dcf4SKowalski, Kamil  */
1936b5c07418SJames Feist nlohmann::json accountNotModified(void)
19371abe55efSEd Tanous {
1938b5c07418SJames Feist     return nlohmann::json{
19393e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1940684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.AccountNotModified"},
1941f4c4dcf4SKowalski, Kamil         {"Message", "The account modification request failed."},
194285659adfSJason M. Bills         {"MessageArgs", nlohmann::json::array()},
1943684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
1944f12894f8SJason M. Bills         {"Resolution", "The modification may have failed due to permission "
1945b5c07418SJames Feist                        "issues or issues with the request body."}};
1946b5c07418SJames Feist }
1947b5c07418SJames Feist 
1948b5c07418SJames Feist void accountNotModified(crow::Response& res)
1949b5c07418SJames Feist {
1950b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1951b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountNotModified());
1952f4c4dcf4SKowalski, Kamil }
1953f4c4dcf4SKowalski, Kamil 
1954f4c4dcf4SKowalski, Kamil /**
1955f4c4dcf4SKowalski, Kamil  * @internal
1956f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterValueFormatError message into JSON
1957f4c4dcf4SKowalski, Kamil  *
1958f4c4dcf4SKowalski, Kamil  * See header file for more information
1959f4c4dcf4SKowalski, Kamil  * @endinternal
1960f4c4dcf4SKowalski, Kamil  */
1961b5c07418SJames Feist nlohmann::json queryParameterValueFormatError(const std::string& arg1,
19621abe55efSEd Tanous                                               const std::string& arg2)
19631abe55efSEd Tanous {
1964b5c07418SJames Feist     return nlohmann::json{
19653e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1966684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryParameterValueFormatError"},
1967f4c4dcf4SKowalski, Kamil         {"Message",
1968f4c4dcf4SKowalski, Kamil          "The value " + arg1 + " for the parameter " + arg2 +
1969f4c4dcf4SKowalski, Kamil              " is of a different format than the parameter can accept."},
197085659adfSJason M. Bills         {"MessageArgs", {arg1, arg2}},
1971684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
197266ac2b8cSJason M. Bills         {"Resolution",
197366ac2b8cSJason M. Bills          "Correct the value for the query parameter in the request and "
1974b5c07418SJames Feist          "resubmit the request if the operation failed."}};
1975b5c07418SJames Feist }
1976b5c07418SJames Feist 
1977b5c07418SJames Feist void queryParameterValueFormatError(crow::Response& res,
1978b5c07418SJames Feist                                     const std::string& arg1,
1979b5c07418SJames Feist                                     const std::string& arg2)
1980b5c07418SJames Feist {
1981b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
1982b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
1983b5c07418SJames Feist                           queryParameterValueFormatError(arg1, arg2));
1984f4c4dcf4SKowalski, Kamil }
1985f4c4dcf4SKowalski, Kamil 
1986f4c4dcf4SKowalski, Kamil /**
1987f4c4dcf4SKowalski, Kamil  * @internal
1988b5c07418SJames Feist  * @brief Formats PropertyMissing message into JSON for the specified
1989b5c07418SJames Feist  * property
1990f12894f8SJason M. Bills  *
1991f12894f8SJason M. Bills  * See header file for more information
1992f12894f8SJason M. Bills  * @endinternal
1993f12894f8SJason M. Bills  */
1994b5c07418SJames Feist nlohmann::json propertyMissing(const std::string& arg1)
1995f12894f8SJason M. Bills {
1996b5c07418SJames Feist     return nlohmann::json{
19973e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
1998684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.PropertyMissing"},
1999f12894f8SJason M. Bills         {"Message", "The property " + arg1 +
2000f12894f8SJason M. Bills                         " is a required property and must be included in "
2001f12894f8SJason M. Bills                         "the request."},
200285659adfSJason M. Bills         {"MessageArgs", {arg1}},
2003684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
2004f12894f8SJason M. Bills         {"Resolution",
2005b5c07418SJames Feist          "Ensure that the property is in the request body and has a "
2006b5c07418SJames Feist          "valid "
2007b5c07418SJames Feist          "value and resubmit the request if the operation failed."}};
2008b5c07418SJames Feist }
2009b5c07418SJames Feist 
2010b5c07418SJames Feist void propertyMissing(crow::Response& res, const std::string& arg1)
2011b5c07418SJames Feist {
2012b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
2013b5c07418SJames Feist     addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1);
2014f4c4dcf4SKowalski, Kamil }
2015f4c4dcf4SKowalski, Kamil 
2016f4c4dcf4SKowalski, Kamil /**
2017f4c4dcf4SKowalski, Kamil  * @internal
2018f4c4dcf4SKowalski, Kamil  * @brief Formats ResourceExhaustion message into JSON
2019f4c4dcf4SKowalski, Kamil  *
2020f4c4dcf4SKowalski, Kamil  * See header file for more information
2021f4c4dcf4SKowalski, Kamil  * @endinternal
2022f4c4dcf4SKowalski, Kamil  */
2023b5c07418SJames Feist nlohmann::json resourceExhaustion(const std::string& arg1)
20241abe55efSEd Tanous {
2025b5c07418SJames Feist     return nlohmann::json{
20263e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
2027684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.ResourceExhaustion"},
2028d425c6f6SEd Tanous         {"Message", "The resource " + arg1 +
202966ac2b8cSJason M. Bills                         " was unable to satisfy the request due to "
203066ac2b8cSJason M. Bills                         "unavailability of resources."},
203185659adfSJason M. Bills         {"MessageArgs", {arg1}},
2032684bb4b8SJason M. Bills         {"MessageSeverity", "Critical"},
2033f12894f8SJason M. Bills         {"Resolution", "Ensure that the resources are available and "
2034b5c07418SJames Feist                        "resubmit the request."}};
2035b5c07418SJames Feist }
2036b5c07418SJames Feist 
2037b5c07418SJames Feist void resourceExhaustion(crow::Response& res, const std::string& arg1)
2038b5c07418SJames Feist {
2039b5c07418SJames Feist     res.result(boost::beast::http::status::service_unavailable);
2040b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1));
2041f4c4dcf4SKowalski, Kamil }
2042f4c4dcf4SKowalski, Kamil 
2043f4c4dcf4SKowalski, Kamil /**
2044f4c4dcf4SKowalski, Kamil  * @internal
2045f4c4dcf4SKowalski, Kamil  * @brief Formats AccountModified message into JSON
2046f4c4dcf4SKowalski, Kamil  *
2047f4c4dcf4SKowalski, Kamil  * See header file for more information
2048f4c4dcf4SKowalski, Kamil  * @endinternal
2049f4c4dcf4SKowalski, Kamil  */
2050b5c07418SJames Feist nlohmann::json accountModified(void)
20511abe55efSEd Tanous {
20523e082749SAsmitha Karunanithi     return nlohmann::json{{"@odata.type", "#Message.v1_1_1.Message"},
2053684bb4b8SJason M. Bills                           {"MessageId", "Base.1.8.1.AccountModified"},
2054f4c4dcf4SKowalski, Kamil                           {"Message", "The account was successfully modified."},
205585659adfSJason M. Bills                           {"MessageArgs", nlohmann::json::array()},
2056684bb4b8SJason M. Bills                           {"MessageSeverity", "OK"},
2057b5c07418SJames Feist                           {"Resolution", "No resolution is required."}};
2058b5c07418SJames Feist }
2059b5c07418SJames Feist 
2060b5c07418SJames Feist void accountModified(crow::Response& res)
2061b5c07418SJames Feist {
2062b5c07418SJames Feist     res.result(boost::beast::http::status::ok);
2063b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue, accountModified());
2064f4c4dcf4SKowalski, Kamil }
2065f4c4dcf4SKowalski, Kamil 
2066f4c4dcf4SKowalski, Kamil /**
2067f4c4dcf4SKowalski, Kamil  * @internal
2068f4c4dcf4SKowalski, Kamil  * @brief Formats QueryParameterOutOfRange message into JSON
2069f4c4dcf4SKowalski, Kamil  *
2070f4c4dcf4SKowalski, Kamil  * See header file for more information
2071f4c4dcf4SKowalski, Kamil  * @endinternal
2072f4c4dcf4SKowalski, Kamil  */
2073b5c07418SJames Feist nlohmann::json queryParameterOutOfRange(const std::string& arg1,
2074b5c07418SJames Feist                                         const std::string& arg2,
2075b5c07418SJames Feist                                         const std::string& arg3)
20761abe55efSEd Tanous {
2077b5c07418SJames Feist     return nlohmann::json{
20783e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
2079684bb4b8SJason M. Bills         {"MessageId", "Base.1.8.1.QueryParameterOutOfRange"},
2080b5c07418SJames Feist         {"Message", "The value " + arg1 + " for the query parameter " + arg2 +
2081b5c07418SJames Feist                         " is out of range " + arg3 + "."},
208285659adfSJason M. Bills         {"MessageArgs", {arg1, arg2, arg3}},
2083684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
2084f4c4dcf4SKowalski, Kamil         {"Resolution",
2085f12894f8SJason M. Bills          "Reduce the value for the query parameter to a value that is "
208666ac2b8cSJason M. Bills          "within range, such as a start or count value that is within "
208766ac2b8cSJason M. Bills          "bounds of the number of resources in a collection or a page that "
2088b5c07418SJames Feist          "is within the range of valid pages."}};
2089b5c07418SJames Feist }
2090b5c07418SJames Feist 
2091b5c07418SJames Feist void queryParameterOutOfRange(crow::Response& res, const std::string& arg1,
2092b5c07418SJames Feist                               const std::string& arg2, const std::string& arg3)
2093b5c07418SJames Feist {
2094b5c07418SJames Feist     res.result(boost::beast::http::status::bad_request);
2095b5c07418SJames Feist     addMessageToErrorJson(res.jsonValue,
2096b5c07418SJames Feist                           queryParameterOutOfRange(arg1, arg2, arg3));
2097f4c4dcf4SKowalski, Kamil }
2098f4c4dcf4SKowalski, Kamil 
20993bf4e632SJoseph Reynolds /**
21003bf4e632SJoseph Reynolds  * @internal
21013bf4e632SJoseph Reynolds  * @brief Formats PasswordChangeRequired message into JSON
21023bf4e632SJoseph Reynolds  *
21033bf4e632SJoseph Reynolds  * See header file for more information
21043bf4e632SJoseph Reynolds  * @endinternal
21053bf4e632SJoseph Reynolds  */
21063bf4e632SJoseph Reynolds void passwordChangeRequired(crow::Response& res, const std::string& arg1)
21073bf4e632SJoseph Reynolds {
21083bf4e632SJoseph Reynolds     messages::addMessageToJsonRoot(
21093bf4e632SJoseph Reynolds         res.jsonValue,
21103bf4e632SJoseph Reynolds         nlohmann::json{
21113bf4e632SJoseph Reynolds             {"@odata.type", "/redfish/v1/$metadata#Message.v1_5_0.Message"},
2112684bb4b8SJason M. Bills             {"MessageId", "Base.1.8.1.PasswordChangeRequired"},
21133bf4e632SJoseph Reynolds             {"Message", "The password provided for this account must be "
21143bf4e632SJoseph Reynolds                         "changed before access is granted.  PATCH the "
21153bf4e632SJoseph Reynolds                         "'Password' property for this account located at "
21163bf4e632SJoseph Reynolds                         "the target URI '" +
21173bf4e632SJoseph Reynolds                             arg1 + "' to complete this process."},
21183bf4e632SJoseph Reynolds             {"MessageArgs", {arg1}},
2119684bb4b8SJason M. Bills             {"MessageSeverity", "Critical"},
21203bf4e632SJoseph Reynolds             {"Resolution", "Change the password for this account using "
21213bf4e632SJoseph Reynolds                            "a PATCH to the 'Password' property at the URI "
21223bf4e632SJoseph Reynolds                            "provided."}});
21233bf4e632SJoseph Reynolds }
21243bf4e632SJoseph Reynolds 
21254cde5d90SJames Feist void invalidUpload(crow::Response& res, const std::string& arg1,
21264cde5d90SJames Feist                    const std::string& arg2)
21274cde5d90SJames Feist {
21284cde5d90SJames Feist     res.result(boost::beast::http::status::bad_request);
21294cde5d90SJames Feist     addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
21304cde5d90SJames Feist }
21314cde5d90SJames Feist 
21324cde5d90SJames Feist /**
21334cde5d90SJames Feist  * @internal
21344cde5d90SJames Feist  * @brief Formats Invalid File message into JSON
21354cde5d90SJames Feist  *
21364cde5d90SJames Feist  * See header file for more information
21374cde5d90SJames Feist  * @endinternal
21384cde5d90SJames Feist  */
21394cde5d90SJames Feist nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2)
21404cde5d90SJames Feist {
21414cde5d90SJames Feist     return nlohmann::json{
21423e082749SAsmitha Karunanithi         {"@odata.type", "/redfish/v1/$metadata#Message.v1_1_1.Message"},
21434a0bf539SManojkiran Eda         {"MessageId", "OpenBMC.0.2.InvalidUpload"},
21444cde5d90SJames Feist         {"Message", "Invalid file uploaded to " + arg1 + ": " + arg2 + "."},
21454cde5d90SJames Feist         {"MessageArgs", {arg1, arg2}},
2146684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
21474cde5d90SJames Feist         {"Resolution", "None."}};
21484cde5d90SJames Feist }
21494cde5d90SJames Feist 
2150dd28ba82SAppaRao Puli /**
2151dd28ba82SAppaRao Puli  * @internal
2152dd28ba82SAppaRao Puli  * @brief Formats MutualExclusiveProperties into JSON
2153dd28ba82SAppaRao Puli  *
2154dd28ba82SAppaRao Puli  * See header file for more information
2155dd28ba82SAppaRao Puli  * @endinternal
2156dd28ba82SAppaRao Puli  */
2157dd28ba82SAppaRao Puli nlohmann::json mutualExclusiveProperties(const std::string& arg1,
2158dd28ba82SAppaRao Puli                                          const std::string& arg2)
2159dd28ba82SAppaRao Puli {
2160dd28ba82SAppaRao Puli     return nlohmann::json{
21613e082749SAsmitha Karunanithi         {"@odata.type", "#Message.v1_1_1.Message"},
2162dd28ba82SAppaRao Puli         {"MessageId", "Base.1.5.0.MutualExclusiveProperties"},
2163dd28ba82SAppaRao Puli         {"Message", "The properties " + arg1 + " and " + arg2 +
2164dd28ba82SAppaRao Puli                         " are mutually exclusive."},
2165dd28ba82SAppaRao Puli         {"MessageArgs", {arg1, arg2}},
2166684bb4b8SJason M. Bills         {"MessageSeverity", "Warning"},
2167dd28ba82SAppaRao Puli         {"Resolution",
2168dd28ba82SAppaRao Puli          "Ensure that the request body doesn't contain mutually exclusive "
2169dd28ba82SAppaRao Puli          "properties and resubmit the request."}};
2170dd28ba82SAppaRao Puli }
2171dd28ba82SAppaRao Puli 
2172dd28ba82SAppaRao Puli void mutualExclusiveProperties(crow::Response& res, const std::string& arg1,
2173dd28ba82SAppaRao Puli                                const std::string& arg2)
2174dd28ba82SAppaRao Puli {
2175dd28ba82SAppaRao Puli     res.result(boost::beast::http::status::bad_request);
2176dd28ba82SAppaRao Puli     addMessageToErrorJson(res.jsonValue, mutualExclusiveProperties(arg1, arg2));
2177dd28ba82SAppaRao Puli }
2178dd28ba82SAppaRao Puli 
2179f4c4dcf4SKowalski, Kamil } // namespace messages
2180f4c4dcf4SKowalski, Kamil 
2181d425c6f6SEd Tanous } // namespace redfish
2182