xref: /openbmc/bmcweb/redfish-core/include/error_messages.hpp (revision 7d95f5f6db1df37fe6438aa0e87479275c82807a)
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 /****************************************************************
17  * This is an auto-generated header which contains definitions
18  * to use Redfish DMTF defined messages.
19  *
20  * This header contains preprocessor defines which wrap
21  * preparation functions for message with given id. The message
22  * ids can be retrieved from Base.__ver__.json file.
23  ***************************************************************/
24 #pragma once
25 #include <nlohmann/json.hpp>
26 
27 namespace redfish {
28 
29 namespace messages {
30 
31 constexpr const char* MESSAGE_VERSION_PREFIX = "Base.1.2.0.";
32 constexpr const char* MESSAGE_ANNOTATION = "@Message.ExtendedInfo";
33 
34 /**
35  * @brief Adds Message JSON object to error object
36  *
37  * @param[out] target   Target JSON to which message will be added
38  * @param[in]  message  Message JSON that should be added to target
39  *
40  * @return None
41  */
42 void addMessageToErrorJson(nlohmann::json& target,
43                            const nlohmann::json& message);
44 
45 /**
46  * @brief Adds Message JSON object to target JSON
47  *
48  * @internal
49  * This function has similar implementation to addMessageToJson(...), but
50  * does not use nlohmann::json_pointer to avoid costly construction
51  * @endinternal
52  *
53  * @param[out] target   Target JSON to which message will be added
54  * @param[in]  message  Message JSON that should be added to target
55  *
56  * @return None
57  */
58 void addMessageToJsonRoot(nlohmann::json& target,
59                           const nlohmann::json& message);
60 
61 /**
62  * @brief Adds Message JSON object connected with specific field to target JSON
63  *
64  * @param[out] target      Target JSON to which message will be added
65  * @param[in]  message     Message JSON that should be added to target
66  * @param[in]  fieldPath   Path of related field
67  *
68  * @return None
69  */
70 void addMessageToJson(nlohmann::json& target, const nlohmann::json& message,
71                       const std::string& fieldPath);
72 
73 /*********************************
74  * AUTOGENERATED FUNCTIONS START *
75  *********************************/
76 
77 /**
78  * @brief Formats ResourceInUse message into JSON
79  * Message body: "The change to the requested resource failed because the
80  * resource is in use or in transition."
81  *
82  *
83  * @returns Message ResourceInUse formatted to JSON */
84 nlohmann::json resourceInUse();
85 
86 /**
87  * @brief Formats MalformedJSON message into JSON
88  * Message body: "The request body submitted was malformed JSON and could not be
89  * parsed by the receiving service."
90  *
91  *
92  * @returns Message MalformedJSON formatted to JSON */
93 nlohmann::json malformedJSON();
94 
95 /**
96  * @brief Formats ResourceMissingAtURI message into JSON
97  * Message body: "The resource at the URI <arg0> was not found."
98  *
99  * @param[in] arg1 Parameter of message that will replace %1 in its body.
100  *
101  * @returns Message ResourceMissingAtURI formatted to JSON */
102 nlohmann::json resourceMissingAtURI(const std::string& arg1);
103 
104 /**
105  * @brief Formats ActionParameterValueFormatError message into JSON
106  * Message body: "The value <arg0> for the parameter <arg1> in the action <arg2>
107  * is of a different format than the parameter can accept."
108  *
109  * @param[in] arg1 Parameter of message that will replace %1 in its body.
110  * @param[in] arg2 Parameter of message that will replace %2 in its body.
111  * @param[in] arg3 Parameter of message that will replace %3 in its body.
112  *
113  * @returns Message ActionParameterValueFormatError formatted to JSON */
114 nlohmann::json actionParameterValueFormatError(const std::string& arg1,
115                                                const std::string& arg2,
116                                                const std::string& arg3);
117 
118 /**
119  * @brief Formats InternalError message into JSON
120  * Message body: "The request failed due to an internal service error.  The
121  * service is still operational."
122  *
123  *
124  * @returns Message InternalError formatted to JSON */
125 nlohmann::json internalError();
126 
127 /**
128  * @brief Formats UnrecognizedRequestBody message into JSON
129  * Message body: "The service detected a malformed request body that it was
130  * unable to interpret."
131  *
132  *
133  * @returns Message UnrecognizedRequestBody formatted to JSON */
134 nlohmann::json unrecognizedRequestBody();
135 
136 /**
137  * @brief Formats ResourceAtUriUnauthorized message into JSON
138  * Message body: "While accessing the resource at <arg0>, the service received
139  * an authorization error <arg1>."
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 std::string& arg1,
146                                          const std::string& arg2);
147 
148 /**
149  * @brief Formats ActionParameterUnknown message into JSON
150  * Message body: "The action <arg0> was submitted with the invalid parameter
151  * <arg1>."
152  *
153  * @param[in] arg1 Parameter of message that will replace %1 in its body.
154  * @param[in] arg2 Parameter of message that will replace %2 in its body.
155  *
156  * @returns Message ActionParameterUnknown formatted to JSON */
157 nlohmann::json actionParameterUnknown(const std::string& arg1,
158                                       const std::string& arg2);
159 
160 /**
161  * @brief Formats ResourceCannotBeDeleted message into JSON
162  * Message body: "The delete request failed because the resource requested
163  * cannot be deleted."
164  *
165  *
166  * @returns Message ResourceCannotBeDeleted formatted to JSON */
167 nlohmann::json resourceCannotBeDeleted();
168 
169 /**
170  * @brief Formats PropertyDuplicate message into JSON
171  * Message body: "The property <arg0> was duplicated in the request."
172  *
173  * @param[in] arg1 Parameter of message that will replace %1 in its body.
174  *
175  * @returns Message PropertyDuplicate formatted to JSON */
176 nlohmann::json propertyDuplicate(const std::string& arg1);
177 
178 /**
179  * @brief Formats ServiceTemporarilyUnavailable message into JSON
180  * Message body: "The service is temporarily unavailable.  Retry in <arg0>
181  * seconds."
182  *
183  * @param[in] arg1 Parameter of message that will replace %1 in its body.
184  *
185  * @returns Message ServiceTemporarilyUnavailable formatted to JSON */
186 nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1);
187 
188 /**
189  * @brief Formats ResourceAlreadyExists message into JSON
190  * Message body: "The requested resource of type <arg0> with the property <arg1>
191  * with the value <arg2> already exists."
192  *
193  * @param[in] arg1 Parameter of message that will replace %1 in its body.
194  * @param[in] arg2 Parameter of message that will replace %2 in its body.
195  * @param[in] arg3 Parameter of message that will replace %3 in its body.
196  *
197  * @returns Message ResourceAlreadyExists formatted to JSON */
198 nlohmann::json resourceAlreadyExists(const std::string& arg1,
199                                      const std::string& arg2,
200                                      const std::string& 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 /**
212  * @brief Formats CreateFailedMissingReqProperties message into JSON
213  * Message body: "The create operation failed because the required property
214  * <arg0> was missing from the request."
215  *
216  * @param[in] arg1 Parameter of message that will replace %1 in its body.
217  *
218  * @returns Message CreateFailedMissingReqProperties formatted to JSON */
219 nlohmann::json createFailedMissingReqProperties(const std::string& arg1);
220 
221 /**
222  * @brief Formats PropertyValueFormatError message into JSON
223  * Message body: "The value <arg0> for the property <arg1> is of a different
224  * format than the property can accept."
225  *
226  * @param[in] arg1 Parameter of message that will replace %1 in its body.
227  * @param[in] arg2 Parameter of message that will replace %2 in its body.
228  *
229  * @returns Message PropertyValueFormatError formatted to JSON */
230 nlohmann::json propertyValueFormatError(const std::string& arg1,
231                                         const std::string& arg2);
232 
233 /**
234  * @brief Formats PropertyValueNotInList message into JSON
235  * Message body: "The value <arg0> for the property <arg1> is not in the list of
236  * acceptable values."
237  *
238  * @param[in] arg1 Parameter of message that will replace %1 in its body.
239  * @param[in] arg2 Parameter of message that will replace %2 in its body.
240  *
241  * @returns Message PropertyValueNotInList formatted to JSON */
242 nlohmann::json propertyValueNotInList(const std::string& arg1,
243                                       const std::string& arg2);
244 
245 /**
246  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
247  * Message body: "The resource at <arg0> is in a format not recognized by the
248  * service."
249  *
250  * @param[in] arg1 Parameter of message that will replace %1 in its body.
251  *
252  * @returns Message ResourceAtUriInUnknownFormat formatted to JSON */
253 nlohmann::json resourceAtUriInUnknownFormat(const std::string& arg1);
254 
255 /**
256  * @brief Formats ServiceInUnknownState message into JSON
257  * Message body: "The operation failed because the service is in an unknown
258  * state and can no longer take incoming requests."
259  *
260  *
261  * @returns Message ServiceInUnknownState formatted to JSON */
262 nlohmann::json serviceInUnknownState();
263 
264 /**
265  * @brief Formats EventSubscriptionLimitExceeded message into JSON
266  * Message body: "The event subscription failed due to the number of
267  * simultaneous subscriptions exceeding the limit of the implementation."
268  *
269  *
270  * @returns Message EventSubscriptionLimitExceeded formatted to JSON */
271 nlohmann::json eventSubscriptionLimitExceeded();
272 
273 /**
274  * @brief Formats ActionParameterMissing message into JSON
275  * Message body: "The action <arg0> requires the parameter <arg1> to be present
276  * in the request body."
277  *
278  * @param[in] arg1 Parameter of message that will replace %1 in its body.
279  * @param[in] arg2 Parameter of message that will replace %2 in its body.
280  *
281  * @returns Message ActionParameterMissing formatted to JSON */
282 nlohmann::json actionParameterMissing(const std::string& arg1,
283                                       const std::string& arg2);
284 
285 /**
286  * @brief Formats StringValueTooLong message into JSON
287  * Message body: "The string <arg0> exceeds the length limit <arg1>."
288  *
289  * @param[in] arg1 Parameter of message that will replace %1 in its body.
290  * @param[in] arg2 Parameter of message that will replace %2 in its body.
291  *
292  * @returns Message StringValueTooLong formatted to JSON */
293 nlohmann::json stringValueTooLong(const std::string& arg1, const int& arg2);
294 
295 /**
296  * @brief Formats PropertyValueTypeError message into JSON
297  * Message body: "The value <arg0> for the property <arg1> is of a different
298  * type than the property can accept."
299  *
300  * @param[in] arg1 Parameter of message that will replace %1 in its body.
301  * @param[in] arg2 Parameter of message that will replace %2 in its body.
302  *
303  * @returns Message PropertyValueTypeError formatted to JSON */
304 nlohmann::json propertyValueTypeError(const std::string& arg1,
305                                       const std::string& arg2);
306 
307 /**
308  * @brief Formats ResourceNotFound message into JSON
309  * Message body: "The requested resource of type <arg0> named <arg1> was not
310  * found."
311  *
312  * @param[in] arg1 Parameter of message that will replace %1 in its body.
313  * @param[in] arg2 Parameter of message that will replace %2 in its body.
314  *
315  * @returns Message ResourceNotFound formatted to JSON */
316 nlohmann::json resourceNotFound(const std::string& arg1,
317                                 const std::string& arg2);
318 
319 /**
320  * @brief Formats CouldNotEstablishConnection message into JSON
321  * Message body: "The service failed to establish a connection with the URI
322  * <arg0>."
323  *
324  * @param[in] arg1 Parameter of message that will replace %1 in its body.
325  *
326  * @returns Message CouldNotEstablishConnection formatted to JSON */
327 nlohmann::json couldNotEstablishConnection(const std::string& arg1);
328 
329 /**
330  * @brief Formats PropertyNotWritable message into JSON
331  * Message body: "The property <arg0> is a read only property and cannot be
332  * assigned a value."
333  *
334  * @param[in] arg1 Parameter of message that will replace %1 in its body.
335  *
336  * @returns Message PropertyNotWritable formatted to JSON */
337 nlohmann::json propertyNotWritable(const std::string& arg1);
338 
339 /**
340  * @brief Formats QueryParameterValueTypeError message into JSON
341  * Message body: "The value <arg0> for the query parameter <arg1> is of a
342  * different type than the parameter can accept."
343  *
344  * @param[in] arg1 Parameter of message that will replace %1 in its body.
345  * @param[in] arg2 Parameter of message that will replace %2 in its body.
346  *
347  * @returns Message QueryParameterValueTypeError formatted to JSON */
348 nlohmann::json queryParameterValueTypeError(const std::string& arg1,
349                                             const std::string& arg2);
350 
351 /**
352  * @brief Formats ServiceShuttingDown message into JSON
353  * Message body: "The operation failed because the service is shutting down and
354  * can no longer take incoming requests."
355  *
356  *
357  * @returns Message ServiceShuttingDown formatted to JSON */
358 nlohmann::json serviceShuttingDown();
359 
360 /**
361  * @brief Formats ActionParameterDuplicate message into JSON
362  * Message body: "The action <arg0> was submitted with more than one value for
363  * the parameter <arg1>."
364  *
365  * @param[in] arg1 Parameter of message that will replace %1 in its body.
366  * @param[in] arg2 Parameter of message that will replace %2 in its body.
367  *
368  * @returns Message ActionParameterDuplicate formatted to JSON */
369 nlohmann::json actionParameterDuplicate(const std::string& arg1,
370                                         const std::string& arg2);
371 
372 /**
373  * @brief Formats ActionParameterNotSupported message into JSON
374  * Message body: "The parameter <arg0> for the action <arg1> is not supported on
375  * the target resource."
376  *
377  * @param[in] arg1 Parameter of message that will replace %1 in its body.
378  * @param[in] arg2 Parameter of message that will replace %2 in its body.
379  *
380  * @returns Message ActionParameterNotSupported formatted to JSON */
381 nlohmann::json actionParameterNotSupported(const std::string& arg1,
382                                            const std::string& arg2);
383 
384 /**
385  * @brief Formats SourceDoesNotSupportProtocol message into JSON
386  * Message body: "The other end of the connection at <arg0> does not support the
387  * specified protocol <arg1>."
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 SourceDoesNotSupportProtocol formatted to JSON */
393 nlohmann::json sourceDoesNotSupportProtocol(const std::string& arg1,
394                                             const std::string& arg2);
395 
396 /**
397  * @brief Formats AccountRemoved message into JSON
398  * Message body: "The account was successfully removed."
399  *
400  *
401  * @returns Message AccountRemoved formatted to JSON */
402 nlohmann::json accountRemoved();
403 
404 /**
405  * @brief Formats AccessDenied message into JSON
406  * Message body: "While attempting to establish a connection to <arg0>, the
407  * service denied access."
408  *
409  * @param[in] arg1 Parameter of message that will replace %1 in its body.
410  *
411  * @returns Message AccessDenied formatted to JSON */
412 nlohmann::json accessDenied(const std::string& arg1);
413 
414 /**
415  * @brief Formats QueryNotSupported message into JSON
416  * Message body: "Querying is not supported by the implementation."
417  *
418  *
419  * @returns Message QueryNotSupported formatted to JSON */
420 nlohmann::json queryNotSupported();
421 
422 /**
423  * @brief Formats CreateLimitReachedForResource message into JSON
424  * Message body: "The create operation failed because the resource has reached
425  * the limit of possible resources."
426  *
427  *
428  * @returns Message CreateLimitReachedForResource formatted to JSON */
429 nlohmann::json createLimitReachedForResource();
430 
431 /**
432  * @brief Formats GeneralError message into JSON
433  * Message body: "A general error has occurred. See ExtendedInfo for more
434  * information."
435  *
436  *
437  * @returns Message GeneralError formatted to JSON */
438 nlohmann::json generalError();
439 
440 /**
441  * @brief Formats Success message into JSON
442  * Message body: "Successfully Completed Request"
443  *
444  *
445  * @returns Message Success formatted to JSON */
446 nlohmann::json success();
447 
448 /**
449  * @brief Formats Created message into JSON
450  * Message body: "The resource has been created successfully"
451  *
452  *
453  * @returns Message Created formatted to JSON */
454 nlohmann::json created();
455 
456 /**
457  * @brief Formats PropertyUnknown message into JSON
458  * Message body: "The property <arg0> is not in the list of valid properties for
459  * the resource."
460  *
461  * @param[in] arg1 Parameter of message that will replace %1 in its body.
462  *
463  * @returns Message PropertyUnknown formatted to JSON */
464 nlohmann::json propertyUnknown(const std::string& arg1);
465 
466 /**
467  * @brief Formats NoValidSession message into JSON
468  * Message body: "There is no valid session established with the
469  * implementation."
470  *
471  *
472  * @returns Message NoValidSession formatted to JSON */
473 nlohmann::json noValidSession();
474 
475 /**
476  * @brief Formats InvalidObject message into JSON
477  * Message body: "The object at <arg0> is invalid."
478  *
479  * @param[in] arg1 Parameter of message that will replace %1 in its body.
480  *
481  * @returns Message InvalidObject formatted to JSON */
482 nlohmann::json invalidObject(const std::string& arg1);
483 
484 /**
485  * @brief Formats ResourceInStandby message into JSON
486  * Message body: "The request could not be performed because the resource is in
487  * standby."
488  *
489  *
490  * @returns Message ResourceInStandby formatted to JSON */
491 nlohmann::json resourceInStandby();
492 
493 /**
494  * @brief Formats ActionParameterValueTypeError message into JSON
495  * Message body: "The value <arg0> for the parameter <arg1> in the action <arg2>
496  * is of a different type than the parameter can accept."
497  *
498  * @param[in] arg1 Parameter of message that will replace %1 in its body.
499  * @param[in] arg2 Parameter of message that will replace %2 in its body.
500  * @param[in] arg3 Parameter of message that will replace %3 in its body.
501  *
502  * @returns Message ActionParameterValueTypeError formatted to JSON */
503 nlohmann::json actionParameterValueTypeError(const std::string& arg1,
504                                              const std::string& arg2,
505                                              const std::string& arg3);
506 
507 /**
508  * @brief Formats SessionLimitExceeded message into JSON
509  * Message body: "The session establishment failed due to the number of
510  * simultaneous sessions exceeding the limit of the implementation."
511  *
512  *
513  * @returns Message SessionLimitExceeded formatted to JSON */
514 nlohmann::json sessionLimitExceeded();
515 
516 /**
517  * @brief Formats ActionNotSupported message into JSON
518  * Message body: "The action <arg0> is not supported by the resource."
519  *
520  * @param[in] arg1 Parameter of message that will replace %1 in its body.
521  *
522  * @returns Message ActionNotSupported formatted to JSON */
523 nlohmann::json actionNotSupported(const std::string& arg1);
524 
525 /**
526  * @brief Formats InvalidIndex message into JSON
527  * Message body: "The Index <arg0> is not a valid offset into the array."
528  *
529  * @param[in] arg1 Parameter of message that will replace %1 in its body.
530  *
531  * @returns Message InvalidIndex formatted to JSON */
532 nlohmann::json invalidIndex(const int& arg1);
533 
534 /**
535  * @brief Formats EmptyJSON message into JSON
536  * Message body: "The request body submitted contained an empty JSON object and
537  * the service is unable to process it."
538  *
539  *
540  * @returns Message EmptyJSON formatted to JSON */
541 nlohmann::json emptyJSON();
542 
543 /**
544  * @brief Formats QueryNotSupportedOnResource message into JSON
545  * Message body: "Querying is not supported on the requested resource."
546  *
547  *
548  * @returns Message QueryNotSupportedOnResource formatted to JSON */
549 nlohmann::json queryNotSupportedOnResource();
550 
551 /**
552  * @brief Formats InsufficientPrivilege message into JSON
553  * Message body: "There are insufficient privileges for the account or
554  * credentials associated with the current session to perform the requested
555  * operation."
556  *
557  *
558  * @returns Message InsufficientPrivilege formatted to JSON */
559 nlohmann::json insufficientPrivilege();
560 
561 /**
562  * @brief Formats PropertyValueModified message into JSON
563  * Message body: "The property <arg0> was assigned the value <arg1> due to
564  * modification by the service."
565  *
566  * @param[in] arg1 Parameter of message that will replace %1 in its body.
567  * @param[in] arg2 Parameter of message that will replace %2 in its body.
568  *
569  * @returns Message PropertyValueModified formatted to JSON */
570 nlohmann::json propertyValueModified(const std::string& arg1,
571                                      const std::string& arg2);
572 
573 /**
574  * @brief Formats AccountNotModified message into JSON
575  * Message body: "The account modification request failed."
576  *
577  *
578  * @returns Message AccountNotModified formatted to JSON */
579 nlohmann::json accountNotModified();
580 
581 /**
582  * @brief Formats QueryParameterValueFormatError message into JSON
583  * Message body: "The value <arg0> for the parameter <arg1> is of a different
584  * format than the parameter can accept."
585  *
586  * @param[in] arg1 Parameter of message that will replace %1 in its body.
587  * @param[in] arg2 Parameter of message that will replace %2 in its body.
588  *
589  * @returns Message QueryParameterValueFormatError formatted to JSON */
590 nlohmann::json queryParameterValueFormatError(const std::string& arg1,
591                                               const std::string& arg2);
592 
593 /**
594  * @brief Formats PropertyMissing message into JSON
595  * Message body: "The property <arg0> is a required property and must be
596  * included in the request."
597  *
598  * @param[in] arg1 Parameter of message that will replace %1 in its body.
599  *
600  * @returns Message PropertyMissing formatted to JSON */
601 nlohmann::json propertyMissing(const std::string& arg1);
602 
603 /**
604  * @brief Formats ResourceExhaustion message into JSON
605  * Message body: "The resource <arg0> was unable to satisfy the request due to
606  * unavailability of resources."
607  *
608  * @param[in] arg1 Parameter of message that will replace %1 in its body.
609  *
610  * @returns Message ResourceExhaustion formatted to JSON */
611 nlohmann::json resourceExhaustion(const std::string& arg1);
612 
613 /**
614  * @brief Formats AccountModified message into JSON
615  * Message body: "The account was successfully modified."
616  *
617  *
618  * @returns Message AccountModified formatted to JSON */
619 nlohmann::json accountModified();
620 
621 /**
622  * @brief Formats QueryParameterOutOfRange message into JSON
623  * Message body: "The value <arg0> for the query parameter <arg1> is out of
624  * range <arg2>."
625  *
626  * @param[in] arg1 Parameter of message that will replace %1 in its body.
627  * @param[in] arg2 Parameter of message that will replace %2 in its body.
628  * @param[in] arg3 Parameter of message that will replace %3 in its body.
629  *
630  * @returns Message QueryParameterOutOfRange formatted to JSON */
631 nlohmann::json queryParameterOutOfRange(const std::string& arg1,
632                                         const std::string& arg2,
633                                         const std::string& arg3);
634 
635 /*********************************
636  * AUTOGENERATED FUNCTIONS END *
637  *********************************/
638 
639 }  // namespace messages
640 
641 }  // namespace redfish
642