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