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