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 
20 #include <boost/url/url_view_base.hpp>
21 #include <nlohmann/json.hpp>
22 
23 #include <cstdint>
24 #include <source_location>
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(const boost::urls::url_view_base& arg1);
75 
76 void resourceMissingAtURI(crow::Response& res,
77                           const boost::urls::url_view_base& arg1);
78 
79 /**
80  * @brief Formats ActionParameterValueFormatError message into JSON
81  * Message body: "The value <arg1> for the parameter <arg2> in the action <arg3>
82  * is of a different format than the parameter can accept."
83  *
84  * @param[in] arg1 Parameter of message that will replace %1 in its body.
85  * @param[in] arg2 Parameter of message that will replace %2 in its body.
86  * @param[in] arg3 Parameter of message that will replace %3 in its body.
87  *
88  * @returns Message ActionParameterValueFormatError formatted to JSON */
89 nlohmann::json actionParameterValueFormatError(
90     const nlohmann::json& arg1, std::string_view arg2, std::string_view arg3);
91 
92 void actionParameterValueFormatError(
93     crow::Response& res, const nlohmann::json& arg1, 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(
107     std::string_view arg1, std::string_view arg2, std::string_view arg3);
108 
109 void actionParameterValueNotInList(crow::Response& res, std::string_view arg1,
110                                    std::string_view arg2,
111                                    std::string_view arg3);
112 
113 /**
114  * @brief Formats InternalError message into JSON
115  * Message body: "The request failed due to an internal service error.  The
116  * service is still operational."
117  *
118  *
119  * @returns Message InternalError formatted to JSON */
120 nlohmann::json internalError();
121 
122 void internalError(crow::Response& res, std::source_location location =
123                                             std::source_location::current());
124 
125 /**
126  * @brief Formats UnrecognizedRequestBody message into JSON
127  * Message body: "The service detected a malformed request body that it was
128  * unable to interpret."
129  *
130  *
131  * @returns Message UnrecognizedRequestBody formatted to JSON */
132 nlohmann::json unrecognizedRequestBody();
133 
134 void unrecognizedRequestBody(crow::Response& res);
135 
136 /**
137  * @brief Formats ResourceAtUriUnauthorized message into JSON
138  * Message body: "While accessing the resource at <arg1>, the service received
139  * an authorization error <arg2>."
140  *
141  * @param[in] arg1 Parameter of message that will replace %1 in its body.
142  * @param[in] arg2 Parameter of message that will replace %2 in its body.
143  *
144  * @returns Message ResourceAtUriUnauthorized formatted to JSON */
145 nlohmann::json resourceAtUriUnauthorized(const boost::urls::url_view_base& arg1,
146                                          std::string_view arg2);
147 
148 void resourceAtUriUnauthorized(crow::Response& res,
149                                const boost::urls::url_view_base& 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(
212     std::string_view arg1, std::string_view arg2, std::string_view arg3);
213 
214 void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
215                            std::string_view arg2, std::string_view arg3);
216 
217 /**
218  * @brief Formats AccountForSessionNoLongerExists message into JSON
219  * Message body: "The account for the current session has been removed, thus the
220  * current session has been removed as well."
221  *
222  *
223  * @returns Message AccountForSessionNoLongerExists formatted to JSON */
224 nlohmann::json accountForSessionNoLongerExists();
225 
226 void accountForSessionNoLongerExists(crow::Response& res);
227 
228 /**
229  * @brief Formats CreateFailedMissingReqProperties message into JSON
230  * Message body: "The create operation failed because the required property
231  * <arg1> was missing from the request."
232  *
233  * @param[in] arg1 Parameter of message that will replace %1 in its body.
234  *
235  * @returns Message CreateFailedMissingReqProperties formatted to JSON */
236 nlohmann::json createFailedMissingReqProperties(std::string_view arg1);
237 
238 void createFailedMissingReqProperties(crow::Response& res,
239                                       std::string_view arg1);
240 
241 /**
242  * @brief Formats PropertyValueFormatError message into JSON
243  * Message body: "The value <arg1> for the property <arg2> is of a different
244  * format than the property can accept."
245  *
246  * @param[in] arg1 Parameter of message that will replace %1 in its body.
247  * @param[in] arg2 Parameter of message that will replace %2 in its body.
248  *
249  * @returns Message PropertyValueFormatError formatted to JSON */
250 nlohmann::json propertyValueFormatError(const nlohmann::json& arg1,
251                                         std::string_view arg2);
252 
253 void propertyValueFormatError(crow::Response& res, const nlohmann::json& arg1,
254                               std::string_view arg2);
255 
256 /**
257  * @brief Formats PropertyValueNotInList message into JSON
258  * Message body: "The value <arg1> for the property <arg2> is not in the list of
259  * acceptable values."
260  *
261  * @param[in] arg1 Parameter of message that will replace %1 in its body.
262  * @param[in] arg2 Parameter of message that will replace %2 in its body.
263  *
264  * @returns Message PropertyValueNotInList formatted to JSON */
265 nlohmann::json propertyValueNotInList(const nlohmann::json& arg1,
266                                       std::string_view arg2);
267 
268 void propertyValueNotInList(crow::Response& res, const nlohmann::json& arg1,
269                             std::string_view arg2);
270 /**
271  * @brief Formats PropertyValueOutOfRange message into JSON
272  * Message body: "The value '%1' for the property %2 is not in the supported
273  * range of acceptable values."
274  *
275  * @param[in] arg1 Parameter of message that will replace %1 in its body.
276  * @param[in] arg2 Parameter of message that will replace %2 in its body.
277  *
278  * @returns Message PropertyValueExternalConflict formatted to JSON */
279 nlohmann::json propertyValueOutOfRange(const nlohmann::json& arg1,
280                                        std::string_view arg2);
281 
282 void propertyValueOutOfRange(crow::Response& res, const nlohmann::json& arg1,
283                              std::string_view arg2);
284 
285 /**
286  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
287  * Message body: "The resource at <arg1> is in a format not recognized by the
288  * service."
289  *
290  * @param[in] arg1 Parameter of message that will replace %1 in its body.
291  *
292  * @returns Message ResourceAtUriInUnknownFormat formatted to JSON */
293 nlohmann::json
294     resourceAtUriInUnknownFormat(const boost::urls::url_view_base& arg1);
295 
296 void resourceAtUriInUnknownFormat(crow::Response& res,
297                                   const boost::urls::url_view_base& 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(const boost::urls::url_view_base& arg1,
405                              std::string_view arg2);
406 
407 void resetRequired(crow::Response& res, const boost::urls::url_view_base& arg1,
408                    std::string_view arg2);
409 
410 /**
411  * @brief Formats ChassisPowerStateOnRequired message into JSON
412  * Message body: "The Chassis with Id '<arg1>' requires to be powered on to
413  * perform this request."
414  *
415  * @param[in] arg1 Parameter of message that will replace %1 in its body.
416  *
417  * @returns Message ChassisPowerStateOnRequired formatted to JSON */
418 nlohmann::json chassisPowerStateOnRequired(std::string_view arg1);
419 
420 void chassisPowerStateOnRequired(crow::Response& res, std::string_view arg1);
421 
422 /**
423  * @brief Formats ChassisPowerStateOffRequired message into JSON
424  * Message body: "The Chassis with Id '<arg1>' requires to be powered off to
425  * perform this request."
426  *
427  * @param[in] arg1 Parameter of message that will replace %1 in its body.
428  *
429  * @returns Message ChassisPowerStateOffRequired formatted to JSON */
430 nlohmann::json chassisPowerStateOffRequired(std::string_view arg1);
431 
432 void chassisPowerStateOffRequired(crow::Response& res, std::string_view arg1);
433 
434 /**
435  * @brief Formats PropertyValueConflict message into JSON
436  * Message body: "The property '<arg1>' could not be written because its value
437  * would conflict with the value of the '<arg2>' property."
438  *
439  * @param[in] arg1 Parameter of message that will replace %1 in its body.
440  * @param[in] arg2 Parameter of message that will replace %2 in its body.
441  *
442  * @returns Message PropertyValueConflict formatted to JSON */
443 nlohmann::json propertyValueConflict(std::string_view arg1,
444                                      std::string_view arg2);
445 
446 void propertyValueConflict(crow::Response& res, std::string_view arg1,
447                            std::string_view arg2);
448 
449 /**
450  * @brief Formats PropertyValueResourceConflict message into JSON
451  * Message body: "The property '%1' with the requested value of '%2' could
452  * not be written because the value conflicts with the state or configuration
453  * of the resource at '%3'."
454  *
455  * @param[in] arg1 Parameter of message that will replace %1 in its body.
456  * @param[in] arg2 Parameter of message that will replace %2 in its body.
457  * @param[in] arg3 Parameter of message that will replace %3 in its body.
458  *
459  * @returns Message PropertyValueResourceConflict to JSON */
460 nlohmann::json propertyValueResourceConflict(
461     std::string_view arg1, const nlohmann::json& arg2,
462     const boost::urls::url_view_base& arg3);
463 
464 void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
465                                    const nlohmann::json& arg2,
466                                    const boost::urls::url_view_base& arg3);
467 
468 /**
469  * @brief Formats PropertyValueExternalConflict message into JSON
470  * Message body: "The property '%1' with the requested value of '%2' could not
471  * be written because the value is not available due to a configuration
472  * conflict."
473  *
474  * @param[in] arg1 Parameter of message that will replace %1 in its body.
475  * @param[in] arg2 Parameter of message that will replace %2 in its body.
476  *
477  * @returns Message PropertyValueExternalConflict formatted to JSON */
478 nlohmann::json propertyValueExternalConflict(std::string_view arg1,
479                                              const nlohmann::json& arg2);
480 
481 void propertyValueExternalConflict(crow::Response& res, std::string_view arg1,
482                                    const nlohmann::json& arg2);
483 
484 /**
485  * @brief Formats PropertyValueIncorrect message into JSON
486  * Message body: "The property '<arg1>' with the requested value of '<arg2>'
487  * could not be written because the value does not meet the constraints of the
488  * implementation."
489  *
490  * @param[in] arg1 Parameter of message that will replace %1 in its body.
491  * @param[in] arg2 Parameter of message that will replace %2 in its body.
492  *
493  * @returns Message PropertyValueIncorrect formatted to JSON */
494 nlohmann::json propertyValueIncorrect(std::string_view arg1,
495                                       const nlohmann::json& arg2);
496 
497 void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
498                             const nlohmann::json& arg2);
499 
500 /**
501  * @brief Formats ResourceCreationConflict message into JSON
502  * Message body: "The resource could not be created.  The service has a resource
503  * at URI '<arg1>' that conflicts with the creation request."
504  *
505  * @param[in] arg1 Parameter of message that will replace %1 in its body.
506  *
507  * @returns Message ResourceCreationConflict formatted to JSON */
508 nlohmann::json resourceCreationConflict(const boost::urls::url_view_base& arg1);
509 
510 void resourceCreationConflict(crow::Response& res,
511                               const boost::urls::url_view_base& arg1);
512 
513 /**
514  * @brief Formats MaximumErrorsExceeded message into JSON
515  * Message body: "Too many errors have occurred to report them all."
516  *
517  *
518  * @returns Message MaximumErrorsExceeded formatted to JSON */
519 nlohmann::json maximumErrorsExceeded();
520 
521 void maximumErrorsExceeded(crow::Response& res);
522 
523 /**
524  * @brief Formats PreconditionFailed message into JSON
525  * Message body: "The ETag supplied did not match the ETag required to change
526  * this resource."
527  *
528  *
529  * @returns Message PreconditionFailed formatted to JSON */
530 nlohmann::json preconditionFailed();
531 
532 void preconditionFailed(crow::Response& res);
533 
534 /**
535  * @brief Formats PreconditionRequired message into JSON
536  * Message body: "A precondition header or annotation is required to change this
537  * resource."
538  *
539  *
540  * @returns Message PreconditionRequired formatted to JSON */
541 nlohmann::json preconditionRequired();
542 
543 void preconditionRequired(crow::Response& res);
544 
545 /**
546  * @brief Formats OperationFailed message into JSON
547  * Message body: "An error occurred internal to the service as part of the
548  * overall request.  Partial results may have been returned."
549  *
550  *
551  * @returns Message OperationFailed formatted to JSON */
552 nlohmann::json operationFailed();
553 
554 void operationFailed(crow::Response& res);
555 
556 /**
557  * @brief Formats OperationTimeout message into JSON
558  * Message body: "A timeout internal to the service occurred as part of the
559  * request.  Partial results may have been returned."
560  *
561  *
562  * @returns Message OperationTimeout formatted to JSON */
563 nlohmann::json operationTimeout();
564 
565 void operationTimeout(crow::Response& res);
566 
567 /**
568  * @brief Formats PropertyValueTypeError message into JSON
569  * Message body: "The value <arg1> for the property <arg2> is of a different
570  * type than the property can accept."
571  *
572  * @param[in] arg1 Parameter of message that will replace %1 in its body.
573  * @param[in] arg2 Parameter of message that will replace %2 in its body.
574  *
575  * @returns Message PropertyValueTypeError formatted to JSON */
576 nlohmann::json propertyValueTypeError(const nlohmann::json& arg1,
577                                       std::string_view arg2);
578 
579 void propertyValueTypeError(crow::Response& res, const nlohmann::json& arg1,
580                             std::string_view arg2);
581 
582 /**
583  * @brief Formats PropertyValueError message into JSON
584  * Message body: "The value provided for the property <arg1> is not valid."
585  *
586  * @param[in] arg1 Parameter of message that will replace %1 in its body.
587  *
588  * @returns Message PropertyValueTypeError formatted to JSON */
589 nlohmann::json propertyValueError(std::string_view arg1);
590 
591 void propertyValueError(crow::Response& res, std::string_view arg1);
592 
593 /**
594  * @brief Formats ResourceNotFound message into JSON
595  * Message body: "The requested resource of type <arg1> named <arg2> was not
596  * found."
597  *
598  * @param[in] arg1 Parameter of message that will replace %1 in its body.
599  * @param[in] arg2 Parameter of message that will replace %2 in its body.
600  *
601  * @returns Message ResourceNotFound formatted to JSON */
602 nlohmann::json resourceNotFound(std::string_view arg1, std::string_view arg2);
603 
604 void resourceNotFound(crow::Response& res, std::string_view arg1,
605                       std::string_view arg2);
606 
607 /**
608  * @brief Formats CouldNotEstablishConnection message into JSON
609  * Message body: "The service failed to establish a Connection with the URI
610  * <arg1>."
611  *
612  * @param[in] arg1 Parameter of message that will replace %1 in its body.
613  *
614  * @returns Message CouldNotEstablishConnection formatted to JSON */
615 nlohmann::json
616     couldNotEstablishConnection(const boost::urls::url_view_base& arg1);
617 
618 void couldNotEstablishConnection(crow::Response& res,
619                                  const boost::urls::url_view_base& arg1);
620 
621 /**
622  * @brief Formats PropertyNotWritable message into JSON
623  * Message body: "The property <arg1> is a read only property and cannot be
624  * assigned a value."
625  *
626  * @param[in] arg1 Parameter of message that will replace %1 in its body.
627  *
628  * @returns Message PropertyNotWritable formatted to JSON */
629 nlohmann::json propertyNotWritable(std::string_view arg1);
630 
631 void propertyNotWritable(crow::Response& res, std::string_view arg1);
632 
633 /**
634  * @brief Formats QueryParameterValueTypeError message into JSON
635  * Message body: "The value <arg1> for the query parameter <arg2> is of a
636  * different type than the parameter can accept."
637  *
638  * @param[in] arg1 Parameter of message that will replace %1 in its body.
639  * @param[in] arg2 Parameter of message that will replace %2 in its body.
640  *
641  * @returns Message QueryParameterValueTypeError formatted to JSON */
642 nlohmann::json queryParameterValueTypeError(const nlohmann::json& arg1,
643                                             std::string_view arg2);
644 
645 void queryParameterValueTypeError(
646     crow::Response& res, const nlohmann::json& arg1, std::string_view arg2);
647 
648 /**
649  * @brief Formats ServiceShuttingDown message into JSON
650  * Message body: "The operation failed because the service is shutting down and
651  * can no longer take incoming requests."
652  *
653  *
654  * @returns Message ServiceShuttingDown formatted to JSON */
655 nlohmann::json serviceShuttingDown();
656 
657 void serviceShuttingDown(crow::Response& res);
658 
659 /**
660  * @brief Formats ActionParameterDuplicate message into JSON
661  * Message body: "The action <arg1> was submitted with more than one value for
662  * the parameter <arg2>."
663  *
664  * @param[in] arg1 Parameter of message that will replace %1 in its body.
665  * @param[in] arg2 Parameter of message that will replace %2 in its body.
666  *
667  * @returns Message ActionParameterDuplicate formatted to JSON */
668 nlohmann::json actionParameterDuplicate(std::string_view arg1,
669                                         std::string_view arg2);
670 
671 void actionParameterDuplicate(crow::Response& res, std::string_view arg1,
672                               std::string_view arg2);
673 
674 /**
675  * @brief Formats ActionParameterNotSupported message into JSON
676  * Message body: "The parameter <arg1> for the action <arg2> is not supported on
677  * the target resource."
678  *
679  * @param[in] arg1 Parameter of message that will replace %1 in its body.
680  * @param[in] arg2 Parameter of message that will replace %2 in its body.
681  *
682  * @returns Message ActionParameterNotSupported formatted to JSON */
683 nlohmann::json actionParameterNotSupported(std::string_view arg1,
684                                            std::string_view arg2);
685 
686 void actionParameterNotSupported(crow::Response& res, std::string_view arg1,
687                                  std::string_view arg2);
688 
689 /**
690  * @brief Formats SourceDoesNotSupportProtocol message into JSON
691  * Message body: "The other end of the Connection at <arg1> does not support the
692  * specified protocol <arg2>."
693  *
694  * @param[in] arg1 Parameter of message that will replace %1 in its body.
695  * @param[in] arg2 Parameter of message that will replace %2 in its body.
696  *
697  * @returns Message SourceDoesNotSupportProtocol formatted to JSON */
698 nlohmann::json sourceDoesNotSupportProtocol(
699     const boost::urls::url_view_base& arg1, std::string_view arg2);
700 
701 void sourceDoesNotSupportProtocol(crow::Response& res,
702                                   const boost::urls::url_view_base& arg1,
703                                   std::string_view arg2);
704 
705 /**
706  * @brief Formats StrictAccountTypes message into JSON
707  * Message body: Indicates the request failed because a set of `AccountTypes` or
708  * `OEMAccountTypes` was not accepted while `StrictAccountTypes` is set to `true
709  * @param[in] arg1 Parameter of message that will replace %1 in its body.
710  *
711  * @returns Message StrictAccountTypes formatted to JSON */
712 nlohmann::json strictAccountTypes(std::string_view arg1);
713 
714 void strictAccountTypes(crow::Response& res, std::string_view arg1);
715 
716 /**
717  * @brief Formats AccountRemoved message into JSON
718  * Message body: "The account was successfully removed."
719  *
720  *
721  * @returns Message AccountRemoved formatted to JSON */
722 nlohmann::json accountRemoved();
723 
724 void accountRemoved(crow::Response& res);
725 
726 /**
727  * @brief Formats AccessDenied message into JSON
728  * Message body: "While attempting to establish a Connection to <arg1>, the
729  * service denied access."
730  *
731  * @param[in] arg1 Parameter of message that will replace %1 in its body.
732  *
733  * @returns Message AccessDenied formatted to JSON */
734 nlohmann::json accessDenied(const boost::urls::url_view_base& arg1);
735 
736 void accessDenied(crow::Response& res, const boost::urls::url_view_base& arg1);
737 
738 /**
739  * @brief Formats QueryNotSupported message into JSON
740  * Message body: "Querying is not supported by the implementation."
741  *
742  *
743  * @returns Message QueryNotSupported formatted to JSON */
744 nlohmann::json queryNotSupported();
745 
746 void queryNotSupported(crow::Response& res);
747 
748 /**
749  * @brief Formats CreateLimitReachedForResource message into JSON
750  * Message body: "The create operation failed because the resource has reached
751  * the limit of possible resources."
752  *
753  *
754  * @returns Message CreateLimitReachedForResource formatted to JSON */
755 nlohmann::json createLimitReachedForResource();
756 
757 void createLimitReachedForResource(crow::Response& res);
758 
759 /**
760  * @brief Formats GeneralError message into JSON
761  * Message body: "A general error has occurred. See ExtendedInfo for more
762  * information."
763  *
764  *
765  * @returns Message GeneralError formatted to JSON */
766 nlohmann::json generalError();
767 
768 void generalError(crow::Response& res);
769 
770 /**
771  * @brief Formats Success message into JSON
772  * Message body: "Successfully Completed Request"
773  *
774  *
775  * @returns Message Success formatted to JSON */
776 nlohmann::json success();
777 
778 void success(crow::Response& res);
779 
780 /**
781  * @brief Formats Created message into JSON
782  * Message body: "The resource has been created successfully"
783  *
784  *
785  * @returns Message Created formatted to JSON */
786 nlohmann::json created();
787 
788 void created(crow::Response& res);
789 
790 /**
791  * @brief Formats NoOperation message into JSON
792  * Message body: "The request body submitted contain no data to act upon and
793  * no changes to the resource took place."
794  *
795  *
796  * @returns Message NoOperation formatted to JSON */
797 nlohmann::json noOperation();
798 
799 void noOperation(crow::Response& res);
800 
801 /**
802  * @brief Formats PropertyUnknown message into JSON
803  * Message body: "The property <arg1> is not in the list of valid properties for
804  * the resource."
805  *
806  * @param[in] arg1 Parameter of message that will replace %1 in its body.
807  *
808  * @returns Message PropertyUnknown formatted to JSON */
809 nlohmann::json propertyUnknown(std::string_view arg1);
810 
811 void propertyUnknown(crow::Response& res, std::string_view arg1);
812 
813 /**
814  * @brief Formats NoValidSession message into JSON
815  * Message body: "There is no valid session established with the
816  * implementation."
817  *
818  *
819  * @returns Message NoValidSession formatted to JSON */
820 nlohmann::json noValidSession();
821 
822 void noValidSession(crow::Response& res);
823 
824 /**
825  * @brief Formats InvalidObject message into JSON
826  * Message body: "The object at <arg1> is invalid."
827  *
828  * @param[in] arg1 Parameter of message that will replace %1 in its body.
829  *
830  * @returns Message InvalidObject formatted to JSON */
831 nlohmann::json invalidObject(const boost::urls::url_view_base& arg1);
832 
833 void invalidObject(crow::Response& res, const boost::urls::url_view_base& arg1);
834 
835 /**
836  * @brief Formats ResourceInStandby message into JSON
837  * Message body: "The request could not be performed because the resource is in
838  * standby."
839  *
840  *
841  * @returns Message ResourceInStandby formatted to JSON */
842 nlohmann::json resourceInStandby();
843 
844 void resourceInStandby(crow::Response& res);
845 
846 /**
847  * @brief Formats ActionParameterValueTypeError message into JSON
848  * Message body: "The value <arg1> for the parameter <arg2> in the action <arg3>
849  * is of a different type than the parameter can accept."
850  *
851  * @param[in] arg1 Parameter of message that will replace %1 in its body.
852  * @param[in] arg2 Parameter of message that will replace %2 in its body.
853  * @param[in] arg3 Parameter of message that will replace %3 in its body.
854  *
855  * @returns Message ActionParameterValueTypeError formatted to JSON */
856 nlohmann::json actionParameterValueTypeError(
857     const nlohmann::json& arg1, std::string_view arg2, std::string_view arg3);
858 
859 void actionParameterValueTypeError(
860     crow::Response& res, const nlohmann::json& arg1, std::string_view arg2,
861     std::string_view arg3);
862 
863 /**
864  * @brief Formats ActionParameterValueError message into JSON
865  * Message body: "Indicates that a parameter was given an invalid value."
866  *  The value for the parameter %1 in the action %2 is invalid.
867  *
868  * @param[in] arg1 Parameter of message that will replace %1 in its body.
869  * @param[in] arg2 Parameter of message that will replace %2 in its body.
870  *
871  * @returns Message ActionParameterValueError formatted to JSON */
872 nlohmann::json actionParameterValueError(const nlohmann::json& arg1,
873                                          std::string_view arg2);
874 
875 void actionParameterValueError(crow::Response& res, const nlohmann::json& arg1,
876                                std::string_view arg2);
877 
878 /**
879  * @brief Formats SessionLimitExceeded message into JSON
880  * Message body: "The session establishment failed due to the number of
881  * simultaneous sessions exceeding the limit of the implementation."
882  *
883  *
884  * @returns Message SessionLimitExceeded formatted to JSON */
885 nlohmann::json sessionLimitExceeded();
886 
887 void sessionLimitExceeded(crow::Response& res);
888 
889 /**
890  * @brief Formats ActionNotSupported message into JSON
891  * Message body: "The action <arg1> is not supported by the resource."
892  *
893  * @param[in] arg1 Parameter of message that will replace %1 in its body.
894  *
895  * @returns Message ActionNotSupported formatted to JSON */
896 nlohmann::json actionNotSupported(std::string_view arg1);
897 
898 void actionNotSupported(crow::Response& res, std::string_view arg1);
899 
900 /**
901  * @brief Formats InvalidIndex message into JSON
902  * Message body: "The index <arg1> is not a valid offset into the array."
903  *
904  * @param[in] arg1 Parameter of message that will replace %1 in its body.
905  *
906  * @returns Message InvalidIndex formatted to JSON */
907 nlohmann::json invalidIndex(int64_t arg1);
908 
909 void invalidIndex(crow::Response& res, int64_t arg1);
910 
911 /**
912  * @brief Formats EmptyJSON message into JSON
913  * Message body: "The request body submitted contained an empty JSON object and
914  * the service is unable to process it."
915  *
916  *
917  * @returns Message EmptyJSON formatted to JSON */
918 nlohmann::json emptyJSON();
919 
920 void emptyJSON(crow::Response& res);
921 
922 /**
923  * @brief Formats QueryNotSupportedOnResource message into JSON
924  * Message body: "Querying is not supported on the requested resource."
925  *
926  *
927  * @returns Message QueryNotSupportedOnResource formatted to JSON */
928 nlohmann::json queryNotSupportedOnResource();
929 
930 void queryNotSupportedOnResource(crow::Response& res);
931 
932 /**
933  * @brief Formats QueryNotSupportedOnOperation message into JSON
934  * Message body: "Querying is not supported with the requested operation."
935  *
936  *
937  * @returns Message QueryNotSupportedOnOperation formatted to JSON */
938 nlohmann::json queryNotSupportedOnOperation();
939 
940 void queryNotSupportedOnOperation(crow::Response& res);
941 
942 /**
943  * @brief Formats QueryCombinationInvalid message into JSON
944  * Message body: "Two or more query parameters in the request cannot be used
945  * together."
946  *
947  *
948  * @returns Message QueryCombinationInvalid formatted to JSON */
949 nlohmann::json queryCombinationInvalid();
950 
951 void queryCombinationInvalid(crow::Response& res);
952 
953 /**
954  * @brief Formats EventBufferExceeded message into JSON
955  * Message body: "Indicates undelivered events may have been lost due to a lack
956  * of buffer space in the service."
957  *
958  *
959  * @returns Message QueryCombinationInvalid formatted to JSON */
960 nlohmann::json eventBufferExceeded();
961 
962 void eventBufferExceeded(crow::Response& res);
963 
964 /**
965  * @brief Formats InsufficientPrivilege message into JSON
966  * Message body: "There are insufficient privileges for the account or
967  * credentials associated with the current session to perform the requested
968  * operation."
969  *
970  *
971  * @returns Message InsufficientPrivilege formatted to JSON */
972 nlohmann::json insufficientPrivilege();
973 
974 void insufficientPrivilege(crow::Response& res);
975 
976 /**
977  * @brief Formats PropertyValueModified message into JSON
978  * Message body: "The property <arg1> was assigned the value <arg2> due to
979  * modification by the service."
980  *
981  * @param[in] arg1 Parameter of message that will replace %1 in its body.
982  * @param[in] arg2 Parameter of message that will replace %2 in its body.
983  *
984  * @returns Message PropertyValueModified formatted to JSON */
985 nlohmann::json propertyValueModified(std::string_view arg1,
986                                      const nlohmann::json& arg2);
987 
988 void propertyValueModified(crow::Response& res, std::string_view arg1,
989                            const nlohmann::json& arg2);
990 
991 /**
992  * @brief Formats AccountNotModified message into JSON
993  * Message body: "The account modification request failed."
994  *
995  *
996  * @returns Message AccountNotModified formatted to JSON */
997 nlohmann::json accountNotModified();
998 
999 void accountNotModified(crow::Response& res);
1000 
1001 /**
1002  * @brief Formats QueryParameterValueFormatError message into JSON
1003  * Message body: "The value <arg1> for the parameter <arg2> is of a different
1004  * format than the parameter can accept."
1005  *
1006  * @param[in] arg1 Parameter of message that will replace %1 in its body.
1007  * @param[in] arg2 Parameter of message that will replace %2 in its body.
1008  *
1009  * @returns Message QueryParameterValueFormatError formatted to JSON */
1010 
1011 nlohmann::json queryParameterValueFormatError(const nlohmann::json& arg1,
1012                                               std::string_view arg2);
1013 
1014 void queryParameterValueFormatError(
1015     crow::Response& res, const nlohmann::json& arg1, std::string_view arg2);
1016 
1017 /**
1018  * @brief Formats PropertyMissing message into JSON
1019  * Message body: "The property <arg1> is a required property and must be
1020  * included in the request."
1021  *
1022  * @param[in] arg1 Parameter of message that will replace %1 in its body.
1023  *
1024  * @returns Message PropertyMissing formatted to JSON */
1025 nlohmann::json propertyMissing(std::string_view arg1);
1026 
1027 void propertyMissing(crow::Response& res, std::string_view arg1);
1028 
1029 /**
1030  * @brief Formats ResourceExhaustion message into JSON
1031  * Message body: "The resource <arg1> was unable to satisfy the request due to
1032  * unavailability of resources."
1033  *
1034  * @param[in] arg1 Parameter of message that will replace %1 in its body.
1035  *
1036  * @returns Message ResourceExhaustion formatted to JSON */
1037 nlohmann::json resourceExhaustion(std::string_view arg1);
1038 
1039 void resourceExhaustion(crow::Response& res, std::string_view arg1);
1040 
1041 /**
1042  * @brief Formats AccountModified message into JSON
1043  * Message body: "The account was successfully modified."
1044  *
1045  *
1046  * @returns Message AccountModified formatted to JSON */
1047 nlohmann::json accountModified();
1048 
1049 void accountModified(crow::Response& res);
1050 
1051 /**
1052  * @brief Formats QueryParameterOutOfRange message into JSON
1053  * Message body: "The value <arg1> for the query parameter <arg2> is out of
1054  * range <arg3>."
1055  *
1056  * @param[in] arg1 Parameter of message that will replace %1 in its body.
1057  * @param[in] arg2 Parameter of message that will replace %2 in its body.
1058  * @param[in] arg3 Parameter of message that will replace %3 in its body.
1059  *
1060  * @returns Message QueryParameterOutOfRange formatted to JSON */
1061 nlohmann::json queryParameterOutOfRange(
1062     std::string_view arg1, std::string_view arg2, std::string_view arg3);
1063 
1064 void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
1065                               std::string_view arg2, std::string_view arg3);
1066 
1067 /**
1068  * @brief Formats PasswordChangeRequired message into JSON
1069  * Message body: The password provided for this account must be changed
1070  * before access is granted.  PATCH the 'Password' property for this
1071  * account located at the target URI '%1' to complete this process.
1072  *
1073  * @param[in] arg1 Parameter of message that will replace %1 in its body.
1074  *
1075  * @returns Message PasswordChangeRequired formatted to JSON */
1076 
1077 nlohmann::json passwordChangeRequired(const boost::urls::url_view_base& arg1);
1078 
1079 void passwordChangeRequired(crow::Response& res,
1080                             const boost::urls::url_view_base& arg1);
1081 
1082 /**
1083  * @brief Formats InvalidUpload message into JSON
1084  * Message body: Invalid file uploaded to %1: %2.*
1085  * @param[in] arg1 Parameter of message that will replace %1 in its body.
1086  * @param[in] arg2 Parameter of message that will replace %2 in its body.
1087  *
1088  * @returns Message InvalidUpload formatted to JSON */
1089 nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2);
1090 
1091 void invalidUpload(crow::Response& res, std::string_view arg1,
1092                    std::string_view arg2);
1093 
1094 /**
1095  * @brief Formats InsufficientStorage message into JSON
1096  * Message body: "Insufficient storage or memory available to complete the
1097  *  request."
1098  * @returns Message InsufficientStorage formatted to JSON */
1099 nlohmann::json insufficientStorage();
1100 
1101 void insufficientStorage(crow::Response& res);
1102 
1103 /**
1104  * @brief Formats OperationNotAllowed message into JSON
1105  * Message body: "he HTTP method is not allowed on this resource."
1106  * @returns Message OperationNotAllowed formatted to JSON */
1107 nlohmann::json operationNotAllowed();
1108 
1109 void operationNotAllowed(crow::Response& res);
1110 
1111 /**
1112  * @brief Formats ArraySizeTooLong message into JSON
1113  * Message body: "Indicates that a string value passed to the given resource
1114  * exceeded its length limit."
1115  * @returns Message ArraySizeTooLong formatted to JSON */
1116 nlohmann::json arraySizeTooLong(std::string_view property, uint64_t length);
1117 
1118 void arraySizeTooLong(crow::Response& res, std::string_view property,
1119                       uint64_t length);
1120 
1121 } // namespace messages
1122 
1123 } // namespace redfish
1124