xref: /openbmc/bmcweb/features/redfish/include/error_messages.hpp (revision 14fbced62e8e6e7e2d9c948f287fbde30721489a)
1 /*
2 // Copyright (c) 2018 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 #pragma once
17 
18 #include "http_response.hpp"
19 #include "source_location.hpp"
20 
21 #include <boost/url/url_view.hpp>
22 #include <nlohmann/json.hpp>
23 
24 #include <cstdint>
25 #include <string>
26 #include <string_view>
27 
28 // IWYU pragma: no_include <cstdint.h>
29 // IWYU pragma: no_forward_declare crow::Response
30 
31 namespace redfish
32 {
33 
34 namespace messages
35 {
36 
37 constexpr const char* messageVersionPrefix = "Base.1.11.0.";
38 constexpr const char* messageAnnotation = "@Message.ExtendedInfo";
39 
40 /**
41  * @brief Moves all error messages from the |source| JSON to |target|
42  */
43 void moveErrorsToErrorJson(nlohmann::json& target, nlohmann::json& source);
44 
45 /**
46  * @brief Formats ResourceInUse message into JSON
47  * Message body: "The change to the requested resource failed because the
48  * resource is in use or in transition."
49  *
50  *
51  * @returns Message ResourceInUse formatted to JSON */
52 nlohmann::json resourceInUse();
53 
54 void resourceInUse(crow::Response& res);
55 
56 /**
57  * @brief Formats MalformedJSON message into JSON
58  * Message body: "The request body submitted was malformed JSON and could not be
59  * parsed by the receiving service."
60  *
61  *
62  * @returns Message MalformedJSON formatted to JSON */
63 nlohmann::json malformedJSON();
64 
65 void malformedJSON(crow::Response& res);
66 
67 /**
68  * @brief Formats ResourceMissingAtURI message into JSON
69  * Message body: "The resource at the URI <arg1> was not found."
70  *
71  * @param[in] arg1 Parameter of message that will replace %1 in its body.
72  *
73  * @returns Message ResourceMissingAtURI formatted to JSON */
74 nlohmann::json resourceMissingAtURI(boost::urls::url_view arg1);
75 
76 void resourceMissingAtURI(crow::Response& res, boost::urls::url_view arg1);
77 
78 /**
79  * @brief Formats ActionParameterValueFormatError message into JSON
80  * Message body: "The value <arg1> for the parameter <arg2> in the action <arg3>
81  * is of a different format than the parameter can accept."
82  *
83  * @param[in] arg1 Parameter of message that will replace %1 in its body.
84  * @param[in] arg2 Parameter of message that will replace %2 in its body.
85  * @param[in] arg3 Parameter of message that will replace %3 in its body.
86  *
87  * @returns Message ActionParameterValueFormatError formatted to JSON */
88 nlohmann::json actionParameterValueFormatError(std::string_view arg1,
89                                                std::string_view arg2,
90                                                std::string_view arg3);
91 
92 void actionParameterValueFormatError(crow::Response& res, std::string_view arg1,
93                                      std::string_view arg2,
94                                      std::string_view arg3);
95 
96 /**
97  * @brief Formats ActionParameterValueNotInList message into JSON
98  * Message body: "The value <arg1> for the parameter <arg2> in the action <arg3>
99  * is not in the list of acceptable values."
100  *
101  * @param[in] arg1 Parameter of message that will replace %1 in its body.
102  * @param[in] arg2 Parameter of message that will replace %2 in its body.
103  * @param[in] arg3 Parameter of message that will replace %3 in its body.
104  *
105  * @returns Message ActionParameterValueFormatError formatted to JSON */
106 nlohmann::json actionParameterValueNotInList(std::string_view arg1,
107                                              std::string_view arg2,
108                                              std::string_view arg3);
109 
110 void actionParameterValueNotInList(crow::Response& res, std::string_view arg1,
111                                    std::string_view arg2,
112                                    std::string_view arg3);
113 
114 /**
115  * @brief Formats InternalError message into JSON
116  * Message body: "The request failed due to an internal service error.  The
117  * service is still operational."
118  *
119  *
120  * @returns Message InternalError formatted to JSON */
121 nlohmann::json internalError();
122 
123 void internalError(crow::Response& res, bmcweb::source_location location =
124                                             bmcweb::source_location::current());
125 
126 /**
127  * @brief Formats UnrecognizedRequestBody message into JSON
128  * Message body: "The service detected a malformed request body that it was
129  * unable to interpret."
130  *
131  *
132  * @returns Message UnrecognizedRequestBody formatted to JSON */
133 nlohmann::json unrecognizedRequestBody();
134 
135 void unrecognizedRequestBody(crow::Response& res);
136 
137 /**
138  * @brief Formats ResourceAtUriUnauthorized message into JSON
139  * Message body: "While accessing the resource at <arg1>, the service received
140  * an authorization error <arg2>."
141  *
142  * @param[in] arg1 Parameter of message that will replace %1 in its body.
143  * @param[in] arg2 Parameter of message that will replace %2 in its body.
144  *
145  * @returns Message ResourceAtUriUnauthorized formatted to JSON */
146 nlohmann::json resourceAtUriUnauthorized(boost::urls::url_view arg1,
147                                          std::string_view arg2);
148 
149 void resourceAtUriUnauthorized(crow::Response& res, boost::urls::url_view arg1,
150                                std::string_view arg2);
151 
152 /**
153  * @brief Formats ActionParameterUnknown message into JSON
154  * Message body: "The action <arg1> was submitted with the invalid parameter
155  * <arg2>."
156  *
157  * @param[in] arg1 Parameter of message that will replace %1 in its body.
158  * @param[in] arg2 Parameter of message that will replace %2 in its body.
159  *
160  * @returns Message ActionParameterUnknown formatted to JSON */
161 nlohmann::json actionParameterUnknown(std::string_view arg1,
162                                       std::string_view arg2);
163 
164 void actionParameterUnknown(crow::Response& res, std::string_view arg1,
165                             std::string_view arg2);
166 
167 /**
168  * @brief Formats ResourceCannotBeDeleted message into JSON
169  * Message body: "The delete request failed because the resource requested
170  * cannot be deleted."
171  *
172  *
173  * @returns Message ResourceCannotBeDeleted formatted to JSON */
174 nlohmann::json resourceCannotBeDeleted();
175 
176 void resourceCannotBeDeleted(crow::Response& res);
177 
178 /**
179  * @brief Formats PropertyDuplicate message into JSON
180  * Message body: "The property <arg1> was duplicated in the request."
181  *
182  * @param[in] arg1 Parameter of message that will replace %1 in its body.
183  *
184  * @returns Message PropertyDuplicate formatted to JSON */
185 nlohmann::json propertyDuplicate(std::string_view arg1);
186 
187 void propertyDuplicate(crow::Response& res, std::string_view arg1);
188 
189 /**
190  * @brief Formats ServiceTemporarilyUnavailable message into JSON
191  * Message body: "The service is temporarily unavailable.  Retry in <arg1>
192  * seconds."
193  *
194  * @param[in] arg1 Parameter of message that will replace %1 in its body.
195  *
196  * @returns Message ServiceTemporarilyUnavailable formatted to JSON */
197 nlohmann::json serviceTemporarilyUnavailable(std::string_view arg1);
198 
199 void serviceTemporarilyUnavailable(crow::Response& res, std::string_view arg1);
200 
201 /**
202  * @brief Formats ResourceAlreadyExists message into JSON
203  * Message body: "The requested resource of type <arg1> with the property <arg2>
204  * with the value <arg3> already exists."
205  *
206  * @param[in] arg1 Parameter of message that will replace %1 in its body.
207  * @param[in] arg2 Parameter of message that will replace %2 in its body.
208  * @param[in] arg3 Parameter of message that will replace %3 in its body.
209  *
210  * @returns Message ResourceAlreadyExists formatted to JSON */
211 nlohmann::json resourceAlreadyExists(std::string_view arg1,
212                                      std::string_view arg2,
213                                      std::string_view arg3);
214 
215 void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
216                            std::string_view arg2, std::string_view arg3);
217 
218 /**
219  * @brief Formats AccountForSessionNoLongerExists message into JSON
220  * Message body: "The account for the current session has been removed, thus the
221  * current session has been removed as well."
222  *
223  *
224  * @returns Message AccountForSessionNoLongerExists formatted to JSON */
225 nlohmann::json accountForSessionNoLongerExists();
226 
227 void accountForSessionNoLongerExists(crow::Response& res);
228 
229 /**
230  * @brief Formats CreateFailedMissingReqProperties message into JSON
231  * Message body: "The create operation failed because the required property
232  * <arg1> was missing from the request."
233  *
234  * @param[in] arg1 Parameter of message that will replace %1 in its body.
235  *
236  * @returns Message CreateFailedMissingReqProperties formatted to JSON */
237 nlohmann::json createFailedMissingReqProperties(std::string_view arg1);
238 
239 void createFailedMissingReqProperties(crow::Response& res,
240                                       std::string_view arg1);
241 
242 /**
243  * @brief Formats PropertyValueFormatError message into JSON
244  * Message body: "The value <arg1> for the property <arg2> is of a different
245  * format than the property can accept."
246  *
247  * @param[in] arg1 Parameter of message that will replace %1 in its body.
248  * @param[in] arg2 Parameter of message that will replace %2 in its body.
249  *
250  * @returns Message PropertyValueFormatError formatted to JSON */
251 nlohmann::json propertyValueFormatError(const nlohmann::json& arg1,
252                                         std::string_view arg2);
253 
254 void propertyValueFormatError(crow::Response& res, const nlohmann::json& arg1,
255                               std::string_view arg2);
256 
257 /**
258  * @brief Formats PropertyValueNotInList message into JSON
259  * Message body: "The value <arg1> for the property <arg2> is not in the list of
260  * acceptable values."
261  *
262  * @param[in] arg1 Parameter of message that will replace %1 in its body.
263  * @param[in] arg2 Parameter of message that will replace %2 in its body.
264  *
265  * @returns Message PropertyValueNotInList formatted to JSON */
266 nlohmann::json propertyValueNotInList(const nlohmann::json& arg1,
267                                       std::string_view arg2);
268 
269 void propertyValueNotInList(crow::Response& res, const nlohmann::json& arg1,
270                             std::string_view arg2);
271 /**
272  * @brief Formats PropertyValueOutOfRange message into JSON
273  * Message body: "The value '%1' for the property %2 is not in the supported
274  * range of acceptable values."
275  *
276  * @param[in] arg1 Parameter of message that will replace %1 in its body.
277  * @param[in] arg2 Parameter of message that will replace %2 in its body.
278  *
279  * @returns Message PropertyValueExternalConflict formatted to JSON */
280 nlohmann::json propertyValueOutOfRange(std::string_view arg1,
281                                        std::string_view arg2);
282 
283 void propertyValueOutOfRange(crow::Response& res, std::string_view arg1,
284                              std::string_view arg2);
285 
286 /**
287  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
288  * Message body: "The resource at <arg1> is in a format not recognized by the
289  * service."
290  *
291  * @param[in] arg1 Parameter of message that will replace %1 in its body.
292  *
293  * @returns Message ResourceAtUriInUnknownFormat formatted to JSON */
294 nlohmann::json resourceAtUriInUnknownFormat(boost::urls::url_view arg1);
295 
296 void resourceAtUriInUnknownFormat(crow::Response& res,
297                                   boost::urls::url_view arg1);
298 
299 /**
300  * @brief Formats ServiceDisabled message into JSON
301  * Message body: "The operation failed because the service at <arg1> is disabled
302  * and " cannot accept requests."
303  *
304  * @param[in] arg1 Parameter of message that will replace %1 in its body.
305  *
306  * @returns Message ServiceDisabled formatted to JSON */
307 nlohmann::json serviceDisabled(std::string_view arg1);
308 
309 void serviceDisabled(crow::Response& res, std::string_view arg1);
310 
311 /**
312  * @brief Formats ServiceInUnknownState message into JSON
313  * Message body: "The operation failed because the service is in an unknown
314  * state and can no longer take incoming requests."
315  *
316  *
317  * @returns Message ServiceInUnknownState formatted to JSON */
318 nlohmann::json serviceInUnknownState();
319 
320 void serviceInUnknownState(crow::Response& res);
321 
322 /**
323  * @brief Formats EventSubscriptionLimitExceeded message into JSON
324  * Message body: "The event subscription failed due to the number of
325  * simultaneous subscriptions exceeding the limit of the implementation."
326  *
327  *
328  * @returns Message EventSubscriptionLimitExceeded formatted to JSON */
329 nlohmann::json eventSubscriptionLimitExceeded();
330 
331 void eventSubscriptionLimitExceeded(crow::Response& res);
332 
333 /**
334  * @brief Formats ActionParameterMissing message into JSON
335  * Message body: "The action <arg1> requires the parameter <arg2> to be present
336  * in the request body."
337  *
338  * @param[in] arg1 Parameter of message that will replace %1 in its body.
339  * @param[in] arg2 Parameter of message that will replace %2 in its body.
340  *
341  * @returns Message ActionParameterMissing formatted to JSON */
342 nlohmann::json actionParameterMissing(std::string_view arg1,
343                                       std::string_view arg2);
344 
345 void actionParameterMissing(crow::Response& res, std::string_view arg1,
346                             std::string_view arg2);
347 
348 /**
349  * @brief Formats StringValueTooLong message into JSON
350  * Message body: "The string <arg1> exceeds the length limit <arg2>."
351  *
352  * @param[in] arg1 Parameter of message that will replace %1 in its body.
353  * @param[in] arg2 Parameter of message that will replace %2 in its body.
354  *
355  * @returns Message StringValueTooLong formatted to JSON */
356 nlohmann::json stringValueTooLong(std::string_view arg1, int arg2);
357 
358 void stringValueTooLong(crow::Response& res, std::string_view arg1, int arg2);
359 
360 /**
361  * @brief Formats SessionTerminated message into JSON
362  * Message body: "The session was successfully terminated."
363  *
364  *
365  * @returns Message SessionTerminated formatted to JSON */
366 nlohmann::json sessionTerminated();
367 
368 void sessionTerminated(crow::Response& res);
369 
370 /**
371  * @brief Formats SubscriptionTerminated message into JSON
372  * Message body: "The event subscription has been terminated."
373  *
374  *
375  * @returns Message SubscriptionTerminated formatted to JSON */
376 nlohmann::json subscriptionTerminated();
377 
378 void subscriptionTerminated(crow::Response& res);
379 
380 /**
381  * @brief Formats ResourceTypeIncompatible message into JSON
382  * Message body: "The @odata.type of the request body <arg1> is incompatible
383  * with the @odata.type of the resource which is <arg2>."
384  *
385  * @param[in] arg1 Parameter of message that will replace %1 in its body.
386  * @param[in] arg2 Parameter of message that will replace %2 in its body.
387  *
388  * @returns Message ResourceTypeIncompatible formatted to JSON */
389 nlohmann::json resourceTypeIncompatible(std::string_view arg1,
390                                         std::string_view arg2);
391 
392 void resourceTypeIncompatible(crow::Response& res, std::string_view arg1,
393                               std::string_view arg2);
394 
395 /**
396  * @brief Formats ResetRequired message into JSON
397  * Message body: "In order to complete the operation, a component reset is
398  * required with the Reset action URI '<arg1>' and ResetType '<arg2>'."
399  *
400  * @param[in] arg1 Parameter of message that will replace %1 in its body.
401  * @param[in] arg2 Parameter of message that will replace %2 in its body.
402  *
403  * @returns Message ResetRequired formatted to JSON */
404 nlohmann::json resetRequired(boost::urls::url_view arg1, std::string_view arg2);
405 
406 void resetRequired(crow::Response& res, boost::urls::url_view arg1,
407                    std::string_view arg2);
408 
409 /**
410  * @brief Formats ChassisPowerStateOnRequired message into JSON
411  * Message body: "The Chassis with Id '<arg1>' requires to be powered on to
412  * perform this request."
413  *
414  * @param[in] arg1 Parameter of message that will replace %1 in its body.
415  *
416  * @returns Message ChassisPowerStateOnRequired formatted to JSON */
417 nlohmann::json chassisPowerStateOnRequired(std::string_view arg1);
418 
419 void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1);
420 
421 /**
422  * @brief Formats ChassisPowerStateOffRequired message into JSON
423  * Message body: "The Chassis with Id '<arg1>' requires to be powered off to
424  * perform this request."
425  *
426  * @param[in] arg1 Parameter of message that will replace %1 in its body.
427  *
428  * @returns Message ChassisPowerStateOffRequired formatted to JSON */
429 nlohmann::json chassisPowerStateOffRequired(std::string_view arg1);
430 
431 void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1);
432 
433 /**
434  * @brief Formats PropertyValueConflict message into JSON
435  * Message body: "The property '<arg1>' could not be written because its value
436  * would conflict with the value of the '<arg2>' property."
437  *
438  * @param[in] arg1 Parameter of message that will replace %1 in its body.
439  * @param[in] arg2 Parameter of message that will replace %2 in its body.
440  *
441  * @returns Message PropertyValueConflict formatted to JSON */
442 nlohmann::json propertyValueConflict(std::string_view arg1,
443                                      std::string_view arg2);
444 
445 void propertyValueConflict(crow::Response& res, std::string_view arg1,
446                            std::string_view arg2);
447 
448 /**
449  * @brief Formats PropertyValueResourceConflict message into JSON
450  * Message body: "The property '%1' with the requested value of '%2' could
451  * not be written because the value conflicts with the state or configuration
452  * of the resource at '%3'."
453  *
454  * @param[in] arg1 Parameter of message that will replace %1 in its body.
455  * @param[in] arg2 Parameter of message that will replace %2 in its body.
456  * @param[in] arg3 Parameter of message that will replace %3 in its body.
457  *
458  * @returns Message PropertyValueResourceConflict to JSON */
459 nlohmann::json propertyValueResourceConflict(std::string_view arg1,
460                                              std::string_view arg2,
461                                              boost::urls::url_view arg3);
462 
463 void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
464                                    std::string_view arg2,
465                                    boost::urls::url_view arg3);
466 
467 /**
468  * @brief Formats PropertyValueExternalConflict message into JSON
469  * Message body: "The property '%1' with the requested value of '%2' could not
470  * be written because the value is not available due to a configuration
471  * conflict."
472  *
473  * @param[in] arg1 Parameter of message that will replace %1 in its body.
474  * @param[in] arg2 Parameter of message that will replace %2 in its body.
475  *
476  * @returns Message PropertyValueExternalConflict formatted to JSON */
477 nlohmann::json propertyValueExternalConflict(std::string_view arg1,
478                                              std::string_view arg2);
479 
480 void propertyValueExternalConflict(crow::Response& res, std::string_view arg1,
481                                    std::string_view arg2);
482 
483 /**
484  * @brief Formats PropertyValueIncorrect message into JSON
485  * Message body: "The property '<arg1>' with the requested value of '<arg2>'
486  * could not be written because the value does not meet the constraints of the
487  * implementation."
488  *
489  * @param[in] arg1 Parameter of message that will replace %1 in its body.
490  * @param[in] arg2 Parameter of message that will replace %2 in its body.
491  *
492  * @returns Message PropertyValueIncorrect formatted to JSON */
493 nlohmann::json propertyValueIncorrect(const nlohmann::json& arg1,
494                                       std::string_view arg2);
495 
496 void propertyValueIncorrect(crow::Response& res, const nlohmann::json& arg1,
497                             std::string_view arg2);
498 
499 /**
500  * @brief Formats ResourceCreationConflict message into JSON
501  * Message body: "The resource could not be created.  The service has a resource
502  * at URI '<arg1>' that conflicts with the creation request."
503  *
504  * @param[in] arg1 Parameter of message that will replace %1 in its body.
505  *
506  * @returns Message ResourceCreationConflict formatted to JSON */
507 nlohmann::json resourceCreationConflict(boost::urls::url_view arg1);
508 
509 void resourceCreationConflict(crow::Response& res, boost::urls::url_view arg1);
510 
511 /**
512  * @brief Formats MaximumErrorsExceeded message into JSON
513  * Message body: "Too many errors have occurred to report them all."
514  *
515  *
516  * @returns Message MaximumErrorsExceeded formatted to JSON */
517 nlohmann::json maximumErrorsExceeded();
518 
519 void maximumErrorsExceeded(crow::Response& res);
520 
521 /**
522  * @brief Formats PreconditionFailed message into JSON
523  * Message body: "The ETag supplied did not match the ETag required to change
524  * this resource."
525  *
526  *
527  * @returns Message PreconditionFailed formatted to JSON */
528 nlohmann::json preconditionFailed();
529 
530 void preconditionFailed(crow::Response& res);
531 
532 /**
533  * @brief Formats PreconditionRequired message into JSON
534  * Message body: "A precondition header or annotation is required to change this
535  * resource."
536  *
537  *
538  * @returns Message PreconditionRequired formatted to JSON */
539 nlohmann::json preconditionRequired();
540 
541 void preconditionRequired(crow::Response& res);
542 
543 /**
544  * @brief Formats OperationFailed message into JSON
545  * Message body: "An error occurred internal to the service as part of the
546  * overall request.  Partial results may have been returned."
547  *
548  *
549  * @returns Message OperationFailed formatted to JSON */
550 nlohmann::json operationFailed();
551 
552 void operationFailed(crow::Response& res);
553 
554 /**
555  * @brief Formats OperationTimeout message into JSON
556  * Message body: "A timeout internal to the service occured as part of the
557  * request.  Partial results may have been returned."
558  *
559  *
560  * @returns Message OperationTimeout formatted to JSON */
561 nlohmann::json operationTimeout();
562 
563 void operationTimeout(crow::Response& res);
564 
565 /**
566  * @brief Formats PropertyValueTypeError message into JSON
567  * Message body: "The value <arg1> for the property <arg2> is of a different
568  * type than the property can accept."
569  *
570  * @param[in] arg1 Parameter of message that will replace %1 in its body.
571  * @param[in] arg2 Parameter of message that will replace %2 in its body.
572  *
573  * @returns Message PropertyValueTypeError formatted to JSON */
574 nlohmann::json propertyValueTypeError(const nlohmann::json& arg1,
575                                       std::string_view arg2);
576 
577 void propertyValueTypeError(crow::Response& res, const nlohmann::json& arg1,
578                             std::string_view arg2);
579 
580 /**
581  * @brief Formats ResourceNotFound message into JSON
582  * Message body: "The requested resource of type <arg1> named <arg2> was not
583  * found."
584  *
585  * @param[in] arg1 Parameter of message that will replace %1 in its body.
586  * @param[in] arg2 Parameter of message that will replace %2 in its body.
587  *
588  * @returns Message ResourceNotFound formatted to JSON */
589 nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2);
590 
591 void resourceNotFound(crow::Response& res, std::string_view arg1,
592                       std::string_view arg2);
593 
594 /**
595  * @brief Formats CouldNotEstablishConnection message into JSON
596  * Message body: "The service failed to establish a Connection with the URI
597  * <arg1>."
598  *
599  * @param[in] arg1 Parameter of message that will replace %1 in its body.
600  *
601  * @returns Message CouldNotEstablishConnection formatted to JSON */
602 nlohmann::json couldNotEstablishConnection(boost::urls::url_view arg1);
603 
604 void couldNotEstablishConnection(crow::Response& res,
605                                  boost::urls::url_view arg1);
606 
607 /**
608  * @brief Formats PropertyNotWritable message into JSON
609  * Message body: "The property <arg1> is a read only property and cannot be
610  * assigned a value."
611  *
612  * @param[in] arg1 Parameter of message that will replace %1 in its body.
613  *
614  * @returns Message PropertyNotWritable formatted to JSON */
615 nlohmann::json propertyNotWritable(std::string_view arg1);
616 
617 void propertyNotWritable(crow::Response& res, std::string_view arg1);
618 
619 /**
620  * @brief Formats QueryParameterValueTypeError message into JSON
621  * Message body: "The value <arg1> for the query parameter <arg2> is of a
622  * different type than the parameter can accept."
623  *
624  * @param[in] arg1 Parameter of message that will replace %1 in its body.
625  * @param[in] arg2 Parameter of message that will replace %2 in its body.
626  *
627  * @returns Message QueryParameterValueTypeError formatted to JSON */
628 nlohmann::json queryParameterValueTypeError(std::string_view arg1,
629                                             std::string_view arg2);
630 
631 void queryParameterValueTypeError(crow::Response& res, std::string_view arg1,
632                                   std::string_view arg2);
633 
634 /**
635  * @brief Formats ServiceShuttingDown message into JSON
636  * Message body: "The operation failed because the service is shutting down and
637  * can no longer take incoming requests."
638  *
639  *
640  * @returns Message ServiceShuttingDown formatted to JSON */
641 nlohmann::json serviceShuttingDown();
642 
643 void serviceShuttingDown(crow::Response& res);
644 
645 /**
646  * @brief Formats ActionParameterDuplicate message into JSON
647  * Message body: "The action <arg1> was submitted with more than one value for
648  * the parameter <arg2>."
649  *
650  * @param[in] arg1 Parameter of message that will replace %1 in its body.
651  * @param[in] arg2 Parameter of message that will replace %2 in its body.
652  *
653  * @returns Message ActionParameterDuplicate formatted to JSON */
654 nlohmann::json actionParameterDuplicate(std::string_view arg1,
655                                         std::string_view arg2);
656 
657 void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
658                               std::string_view arg2);
659 
660 /**
661  * @brief Formats ActionParameterNotSupported message into JSON
662  * Message body: "The parameter <arg1> for the action <arg2> is not supported on
663  * the target resource."
664  *
665  * @param[in] arg1 Parameter of message that will replace %1 in its body.
666  * @param[in] arg2 Parameter of message that will replace %2 in its body.
667  *
668  * @returns Message ActionParameterNotSupported formatted to JSON */
669 nlohmann::json actionParameterNotSupported(std::string_view arg1,
670                                            std::string_view arg2);
671 
672 void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
673                                  std::string_view arg2);
674 
675 /**
676  * @brief Formats SourceDoesNotSupportProtocol message into JSON
677  * Message body: "The other end of the Connection at <arg1> does not support the
678  * specified protocol <arg2>."
679  *
680  * @param[in] arg1 Parameter of message that will replace %1 in its body.
681  * @param[in] arg2 Parameter of message that will replace %2 in its body.
682  *
683  * @returns Message SourceDoesNotSupportProtocol formatted to JSON */
684 nlohmann::json sourceDoesNotSupportProtocol(boost::urls::url_view arg1,
685                                             std::string_view arg2);
686 
687 void sourceDoesNotSupportProtocol(crow::Response& res,
688                                   boost::urls::url_view arg1,
689                                   std::string_view arg2);
690 
691 /**
692  * @brief Formats StrictAccountTypes message into JSON
693  * Message body: Indicates the request failed because a set of `AccountTypes` or
694  * `OEMAccountTypes` was not accepted while `StrictAccountTypes` is set to `true
695  * @param[in] arg1 Parameter of message that will replace %1 in its body.
696  *
697  * @returns Message StrictAccountTypes formatted to JSON */
698 nlohmann::json strictAccountTypes(std::string_view arg1);
699 
700 void strictAccountTypes(crow::Response& res, std::string_view arg1);
701 
702 /**
703  * @brief Formats AccountRemoved message into JSON
704  * Message body: "The account was successfully removed."
705  *
706  *
707  * @returns Message AccountRemoved formatted to JSON */
708 nlohmann::json accountRemoved();
709 
710 void accountRemoved(crow::Response& res);
711 
712 /**
713  * @brief Formats AccessDenied message into JSON
714  * Message body: "While attempting to establish a Connection to <arg1>, the
715  * service denied access."
716  *
717  * @param[in] arg1 Parameter of message that will replace %1 in its body.
718  *
719  * @returns Message AccessDenied formatted to JSON */
720 nlohmann::json accessDenied(boost::urls::url_view arg1);
721 
722 void accessDenied(crow::Response& res, boost::urls::url_view arg1);
723 
724 /**
725  * @brief Formats QueryNotSupported message into JSON
726  * Message body: "Querying is not supported by the implementation."
727  *
728  *
729  * @returns Message QueryNotSupported formatted to JSON */
730 nlohmann::json queryNotSupported();
731 
732 void queryNotSupported(crow::Response& res);
733 
734 /**
735  * @brief Formats CreateLimitReachedForResource message into JSON
736  * Message body: "The create operation failed because the resource has reached
737  * the limit of possible resources."
738  *
739  *
740  * @returns Message CreateLimitReachedForResource formatted to JSON */
741 nlohmann::json createLimitReachedForResource();
742 
743 void createLimitReachedForResource(crow::Response& res);
744 
745 /**
746  * @brief Formats GeneralError message into JSON
747  * Message body: "A general error has occurred. See ExtendedInfo for more
748  * information."
749  *
750  *
751  * @returns Message GeneralError formatted to JSON */
752 nlohmann::json generalError();
753 
754 void generalError(crow::Response& res);
755 
756 /**
757  * @brief Formats Success message into JSON
758  * Message body: "Successfully Completed Request"
759  *
760  *
761  * @returns Message Success formatted to JSON */
762 nlohmann::json success();
763 
764 void success(crow::Response& res);
765 
766 /**
767  * @brief Formats Created message into JSON
768  * Message body: "The resource has been created successfully"
769  *
770  *
771  * @returns Message Created formatted to JSON */
772 nlohmann::json created();
773 
774 void created(crow::Response& res);
775 
776 /**
777  * @brief Formats NoOperation message into JSON
778  * Message body: "The request body submitted contain no data to act upon and
779  * no changes to the resource took place."
780  *
781  *
782  * @returns Message NoOperation formatted to JSON */
783 nlohmann::json noOperation();
784 
785 void noOperation(crow::Response& res);
786 
787 /**
788  * @brief Formats PropertyUnknown message into JSON
789  * Message body: "The property <arg1> is not in the list of valid properties for
790  * the resource."
791  *
792  * @param[in] arg1 Parameter of message that will replace %1 in its body.
793  *
794  * @returns Message PropertyUnknown formatted to JSON */
795 nlohmann::json propertyUnknown(std::string_view arg1);
796 
797 void propertyUnknown(crow::Response& res, std::string_view arg1);
798 
799 /**
800  * @brief Formats NoValidSession message into JSON
801  * Message body: "There is no valid session established with the
802  * implementation."
803  *
804  *
805  * @returns Message NoValidSession formatted to JSON */
806 nlohmann::json noValidSession();
807 
808 void noValidSession(crow::Response& res);
809 
810 /**
811  * @brief Formats InvalidObject message into JSON
812  * Message body: "The object at <arg1> is invalid."
813  *
814  * @param[in] arg1 Parameter of message that will replace %1 in its body.
815  *
816  * @returns Message InvalidObject formatted to JSON */
817 nlohmann::json invalidObject(boost::urls::url_view arg1);
818 
819 void invalidObject(crow::Response& res, boost::urls::url_view arg1);
820 
821 /**
822  * @brief Formats ResourceInStandby message into JSON
823  * Message body: "The request could not be performed because the resource is in
824  * standby."
825  *
826  *
827  * @returns Message ResourceInStandby formatted to JSON */
828 nlohmann::json resourceInStandby();
829 
830 void resourceInStandby(crow::Response& res);
831 
832 /**
833  * @brief Formats ActionParameterValueTypeError message into JSON
834  * Message body: "The value <arg1> for the parameter <arg2> in the action <arg3>
835  * is of a different type than the parameter can accept."
836  *
837  * @param[in] arg1 Parameter of message that will replace %1 in its body.
838  * @param[in] arg2 Parameter of message that will replace %2 in its body.
839  * @param[in] arg3 Parameter of message that will replace %3 in its body.
840  *
841  * @returns Message ActionParameterValueTypeError formatted to JSON */
842 nlohmann::json actionParameterValueTypeError(std::string_view arg1,
843                                              std::string_view arg2,
844                                              std::string_view arg3);
845 
846 void actionParameterValueTypeError(crow::Response& res, std::string_view arg1,
847                                    std::string_view arg2,
848                                    std::string_view arg3);
849 
850 /**
851  * @brief Formats SessionLimitExceeded message into JSON
852  * Message body: "The session establishment failed due to the number of
853  * simultaneous sessions exceeding the limit of the implementation."
854  *
855  *
856  * @returns Message SessionLimitExceeded formatted to JSON */
857 nlohmann::json sessionLimitExceeded();
858 
859 void sessionLimitExceeded(crow::Response& res);
860 
861 /**
862  * @brief Formats ActionNotSupported message into JSON
863  * Message body: "The action <arg1> is not supported by the resource."
864  *
865  * @param[in] arg1 Parameter of message that will replace %1 in its body.
866  *
867  * @returns Message ActionNotSupported formatted to JSON */
868 nlohmann::json actionNotSupported(std::string_view arg1);
869 
870 void actionNotSupported(crow::Response& res, std::string_view arg1);
871 
872 /**
873  * @brief Formats InvalidIndex message into JSON
874  * Message body: "The index <arg1> is not a valid offset into the array."
875  *
876  * @param[in] arg1 Parameter of message that will replace %1 in its body.
877  *
878  * @returns Message InvalidIndex formatted to JSON */
879 nlohmann::json invalidIndex(int64_t arg1);
880 
881 void invalidIndex(crow::Response& res, int64_t arg1);
882 
883 /**
884  * @brief Formats EmptyJSON message into JSON
885  * Message body: "The request body submitted contained an empty JSON object and
886  * the service is unable to process it."
887  *
888  *
889  * @returns Message EmptyJSON formatted to JSON */
890 nlohmann::json emptyJSON();
891 
892 void emptyJSON(crow::Response& res);
893 
894 /**
895  * @brief Formats QueryNotSupportedOnResource message into JSON
896  * Message body: "Querying is not supported on the requested resource."
897  *
898  *
899  * @returns Message QueryNotSupportedOnResource formatted to JSON */
900 nlohmann::json queryNotSupportedOnResource();
901 
902 void queryNotSupportedOnResource(crow::Response& res);
903 
904 /**
905  * @brief Formats QueryNotSupportedOnOperation message into JSON
906  * Message body: "Querying is not supported with the requested operation."
907  *
908  *
909  * @returns Message QueryNotSupportedOnOperation formatted to JSON */
910 nlohmann::json queryNotSupportedOnOperation();
911 
912 void queryNotSupportedOnOperation(crow::Response& res);
913 
914 /**
915  * @brief Formats QueryCombinationInvalid message into JSON
916  * Message body: "Two or more query parameters in the request cannot be used
917  * together."
918  *
919  *
920  * @returns Message QueryCombinationInvalid formatted to JSON */
921 nlohmann::json queryCombinationInvalid();
922 
923 void queryCombinationInvalid(crow::Response& res);
924 
925 /**
926  * @brief Formats InsufficientPrivilege message into JSON
927  * Message body: "There are insufficient privileges for the account or
928  * credentials associated with the current session to perform the requested
929  * operation."
930  *
931  *
932  * @returns Message InsufficientPrivilege formatted to JSON */
933 nlohmann::json insufficientPrivilege();
934 
935 void insufficientPrivilege(crow::Response& res);
936 
937 /**
938  * @brief Formats PropertyValueModified message into JSON
939  * Message body: "The property <arg1> was assigned the value <arg2> due to
940  * modification by the service."
941  *
942  * @param[in] arg1 Parameter of message that will replace %1 in its body.
943  * @param[in] arg2 Parameter of message that will replace %2 in its body.
944  *
945  * @returns Message PropertyValueModified formatted to JSON */
946 nlohmann::json propertyValueModified(std::string_view arg1,
947                                      std::string_view arg2);
948 
949 void propertyValueModified(crow::Response& res, std::string_view arg1,
950                            std::string_view arg2);
951 
952 /**
953  * @brief Formats AccountNotModified message into JSON
954  * Message body: "The account modification request failed."
955  *
956  *
957  * @returns Message AccountNotModified formatted to JSON */
958 nlohmann::json accountNotModified();
959 
960 void accountNotModified(crow::Response& res);
961 
962 /**
963  * @brief Formats QueryParameterValueFormatError message into JSON
964  * Message body: "The value <arg1> for the parameter <arg2> is of a different
965  * format than the parameter can accept."
966  *
967  * @param[in] arg1 Parameter of message that will replace %1 in its body.
968  * @param[in] arg2 Parameter of message that will replace %2 in its body.
969  *
970  * @returns Message QueryParameterValueFormatError formatted to JSON */
971 
972 nlohmann::json queryParameterValueFormatError(std::string_view arg1,
973                                               std::string_view arg2);
974 
975 void queryParameterValueFormatError(crow::Response& res, std::string_view arg1,
976                                     std::string_view arg2);
977 
978 /**
979  * @brief Formats PropertyMissing message into JSON
980  * Message body: "The property <arg1> is a required property and must be
981  * included in the request."
982  *
983  * @param[in] arg1 Parameter of message that will replace %1 in its body.
984  *
985  * @returns Message PropertyMissing formatted to JSON */
986 nlohmann::json propertyMissing(std::string_view arg1);
987 
988 void propertyMissing(crow::Response& res, std::string_view arg1);
989 
990 /**
991  * @brief Formats ResourceExhaustion message into JSON
992  * Message body: "The resource <arg1> was unable to satisfy the request due to
993  * unavailability of resources."
994  *
995  * @param[in] arg1 Parameter of message that will replace %1 in its body.
996  *
997  * @returns Message ResourceExhaustion formatted to JSON */
998 nlohmann::json resourceExhaustion(std::string_view arg1);
999 
1000 void resourceExhaustion(crow::Response& res, std::string_view arg1);
1001 
1002 /**
1003  * @brief Formats AccountModified message into JSON
1004  * Message body: "The account was successfully modified."
1005  *
1006  *
1007  * @returns Message AccountModified formatted to JSON */
1008 nlohmann::json accountModified();
1009 
1010 void accountModified(crow::Response& res);
1011 
1012 /**
1013  * @brief Formats QueryParameterOutOfRange message into JSON
1014  * Message body: "The value <arg1> for the query parameter <arg2> is out of
1015  * range <arg3>."
1016  *
1017  * @param[in] arg1 Parameter of message that will replace %1 in its body.
1018  * @param[in] arg2 Parameter of message that will replace %2 in its body.
1019  * @param[in] arg3 Parameter of message that will replace %3 in its body.
1020  *
1021  * @returns Message QueryParameterOutOfRange formatted to JSON */
1022 nlohmann::json queryParameterOutOfRange(std::string_view arg1,
1023                                         std::string_view arg2,
1024                                         std::string_view arg3);
1025 
1026 void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
1027                               std::string_view arg2, std::string_view arg3);
1028 
1029 /**
1030  * @brief Formats PasswordChangeRequired message into JSON
1031  * Message body: The password provided for this account must be changed
1032  * before access is granted.  PATCH the 'Password' property for this
1033  * account located at the target URI '%1' to complete this process.
1034  *
1035  * @param[in] arg1 Parameter of message that will replace %1 in its body.
1036  *
1037  * @returns Message PasswordChangeRequired formatted to JSON */
1038 
1039 nlohmann::json passwordChangeRequired(boost::urls::url_view arg1);
1040 
1041 void passwordChangeRequired(crow::Response& res, boost::urls::url_view arg1);
1042 
1043 /**
1044  * @brief Formats InvalidUpload message into JSON
1045  * Message body: Invalid file uploaded to %1: %2.*
1046  * @param[in] arg1 Parameter of message that will replace %1 in its body.
1047  * @param[in] arg2 Parameter of message that will replace %2 in its body.
1048  *
1049  * @returns Message InvalidUpload formatted to JSON */
1050 nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2);
1051 
1052 void invalidUpload(crow::Response& res, std::string_view arg1,
1053                    std::string_view arg2);
1054 
1055 /**
1056  * @brief Formats InsufficientStorage message into JSON
1057  * Message body: "Insufficent storage or memory available to complete the
1058  *  request."
1059  * @returns Message InsufficientStorage formatted to JSON */
1060 nlohmann::json insufficientStorage();
1061 
1062 void insufficientStorage(crow::Response& res);
1063 
1064 /**
1065  * @brief Formats OperationNotAllowed message into JSON
1066  * Message body: "he HTTP method is not allowed on this resource."
1067  * @returns Message OperationNotAllowed formatted to JSON */
1068 nlohmann::json operationNotAllowed();
1069 
1070 void operationNotAllowed(crow::Response& res);
1071 
1072 /**
1073  * @brief Formats ArraySizeTooLong message into JSON
1074  * Message body: "Indicates that a string value passed to the given resource
1075  * exceeded its length limit."
1076  * @returns Message ArraySizeTooLong formatted to JSON */
1077 nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length);
1078 
1079 void arraySizeTooLong(crow::Response& res, std::string_view property,
1080                       uint64_t length);
1081 
1082 } // namespace messages
1083 
1084 } // namespace redfish
1085