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