xref: /openbmc/bmcweb/redfish-core/src/error_messages.cpp (revision 4859bdbafbb2b78ae414fb050ad197db2f2cb28b)
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 #include <error_messages.hpp>
17 #include <crow/logging.h>
18 
19 namespace redfish {
20 
21 namespace messages {
22 
23 void addMessageToErrorJson(nlohmann::json& target,
24                            const nlohmann::json& message) {
25   auto& error = target["error"];
26 
27   // If this is the first error message, fill in the information from the first
28   // error message to the top level struct
29   if (!error.is_object()) {
30     auto message_id_iterator = message.find("MessageId");
31     if (message_id_iterator == message.end()) {
32       BMCWEB_LOG_CRITICAL << "Attempt to add error message without MessageId";
33       return;
34     }
35 
36     auto message_field_iterator = message.find("Message");
37     if (message_field_iterator == message.end()) {
38       BMCWEB_LOG_CRITICAL << "Attempt to add error message without Message";
39       return;
40     }
41     // clang-format off
42     error = {
43         {"code", *message_id_iterator},
44         {"message", *message_field_iterator}
45     };
46     // clang-format on
47   } else {
48     // More than 1 error occurred, so the message has to be generic
49     error["code"] = std::string(messageVersionPrefix) + "GeneralError";
50     error["message"] =
51         "A general error has occurred. See ExtendedInfo for more"
52         "information.";
53   }
54 
55   // This check could technically be done in in the default construction
56   // branch above, but because we need the pointer to the extended info field
57   // anyway, it's more efficient to do it here.
58   auto& extended_info = error[messages::messageAnnotation];
59   if (!extended_info.is_array()) {
60     extended_info = nlohmann::json::array();
61   }
62 
63   extended_info.push_back(message);
64 }
65 
66 void addMessageToJsonRoot(nlohmann::json& target,
67                           const nlohmann::json& message) {
68   if (!target[messages::messageAnnotation].is_array()) {
69     // Force object to be an array
70     target[messages::messageAnnotation] = nlohmann::json::array();
71   }
72 
73   target[messages::messageAnnotation].push_back(message);
74 }
75 
76 void addMessageToJson(nlohmann::json& target, const nlohmann::json& message,
77                       const std::string& fieldPath) {
78   nlohmann::json_pointer<nlohmann::json> extendedInfo(
79       fieldPath + messages::messageAnnotation);
80 
81   if (!target[extendedInfo].is_array()) {
82     // Force object to be an array
83     target[extendedInfo] = nlohmann::json::array();
84   }
85 
86   // Object exists and it is an array so we can just push in the message
87   target[extendedInfo].push_back(message);
88 }
89 
90 /*********************************
91  * AUTOGENERATED FUNCTIONS START *
92  *********************************/
93 
94 /**
95  * @internal
96  * @brief Formats ResourceInUse message into JSON
97  *
98  * See header file for more information
99  * @endinternal
100  */
101 nlohmann::json resourceInUse() {
102   return nlohmann::json{
103       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
104       {"MessageId", "Base.1.2.0.ResourceInUse"},
105       {"Message",
106        "The change to the requested resource failed because the resource is in "
107        "use or in transition."},
108       {"Severity", "Warning"},
109       {"Resolution",
110        "Remove the condition and resubmit the request if the operation "
111        "failed."}};
112 }
113 
114 /**
115  * @internal
116  * @brief Formats MalformedJSON message into JSON
117  *
118  * See header file for more information
119  * @endinternal
120  */
121 nlohmann::json malformedJSON() {
122   return nlohmann::json{
123       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
124       {"MessageId", "Base.1.2.0.MalformedJSON"},
125       {"Message",
126        "The request body submitted was malformed JSON and could not be parsed "
127        "by the receiving service."},
128       {"Severity", "Critical"},
129       {"Resolution",
130        "Ensure that the request body is valid JSON and resubmit the request."}};
131 }
132 
133 /**
134  * @internal
135  * @brief Formats ResourceMissingAtURI message into JSON
136  *
137  * See header file for more information
138  * @endinternal
139  */
140 nlohmann::json resourceMissingAtURI(const std::string& arg1) {
141   return nlohmann::json{
142       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
143       {"MessageId", "Base.1.2.0.ResourceMissingAtURI"},
144       {"Message", "The resource at the URI " + arg1 + " was not found."},
145       {"Severity", "Critical"},
146       {"Resolution",
147        "Place a valid resource at the URI or correct the URI and resubmit the "
148        "request."}};
149 }
150 
151 /**
152  * @internal
153  * @brief Formats ActionParameterValueFormatError message into JSON
154  *
155  * See header file for more information
156  * @endinternal
157  */
158 nlohmann::json actionParameterValueFormatError(const std::string& arg1,
159                                                const std::string& arg2,
160                                                const std::string& arg3) {
161   return nlohmann::json{
162       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
163       {"MessageId", "Base.1.2.0.ActionParameterValueFormatError"},
164       {"Message",
165        "The value " + arg1 + " for the parameter " + arg2 + " in the action " +
166            arg3 + " is of a different format than the parameter can accept."},
167       {"Severity", "Warning"},
168       {"Resolution",
169        "Correct the value for the parameter in the request body and resubmit "
170        "the request if the operation failed."}};
171 }
172 
173 /**
174  * @internal
175  * @brief Formats InternalError message into JSON
176  *
177  * See header file for more information
178  * @endinternal
179  */
180 nlohmann::json internalError() {
181   return nlohmann::json{
182       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
183       {"MessageId", "Base.1.2.0.InternalError"},
184       {"Message",
185        "The request failed due to an internal service error.  The service is "
186        "still operational."},
187       {"Severity", "Critical"},
188       {"Resolution",
189        "Resubmit the request.  If the problem persists, consider resetting the "
190        "service."}};
191 }
192 
193 /**
194  * @internal
195  * @brief Formats UnrecognizedRequestBody message into JSON
196  *
197  * See header file for more information
198  * @endinternal
199  */
200 nlohmann::json unrecognizedRequestBody() {
201   return nlohmann::json{
202       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
203       {"MessageId", "Base.1.2.0.UnrecognizedRequestBody"},
204       {"Message",
205        "The service detected a malformed request body that it was unable to "
206        "interpret."},
207       {"Severity", "Warning"},
208       {"Resolution",
209        "Correct the request body and resubmit the request if it failed."}};
210 }
211 
212 /**
213  * @internal
214  * @brief Formats ResourceAtUriUnauthorized message into JSON
215  *
216  * See header file for more information
217  * @endinternal
218  */
219 nlohmann::json resourceAtUriUnauthorized(const std::string& arg1,
220                                          const std::string& arg2) {
221   return nlohmann::json{
222       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
223       {"MessageId", "Base.1.2.0.ResourceAtUriUnauthorized"},
224       {"Message", "While accessing the resource at " + arg1 +
225                       ", the service received an authorization error " + arg2 +
226                       "."},
227       {"Severity", "Critical"},
228       {"Resolution",
229        "Ensure that the appropriate access is provided for the service in "
230        "order for it to access the URI."}};
231 }
232 
233 /**
234  * @internal
235  * @brief Formats ActionParameterUnknown message into JSON
236  *
237  * See header file for more information
238  * @endinternal
239  */
240 nlohmann::json actionParameterUnknown(const std::string& arg1,
241                                       const std::string& arg2) {
242   return nlohmann::json{
243       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
244       {"MessageId", "Base.1.2.0.ActionParameterUnknown"},
245       {"Message", "The action " + arg1 +
246                       " was submitted with the invalid parameter " + arg2 +
247                       "."},
248       {"Severity", "Warning"},
249       {"Resolution",
250        "Correct the invalid parameter and resubmit the request if the "
251        "operation failed."}};
252 }
253 
254 /**
255  * @internal
256  * @brief Formats ResourceCannotBeDeleted message into JSON
257  *
258  * See header file for more information
259  * @endinternal
260  */
261 nlohmann::json resourceCannotBeDeleted() {
262   return nlohmann::json{
263       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
264       {"MessageId", "Base.1.2.0.ResourceCannotBeDeleted"},
265       {"Message",
266        "The delete request failed because the resource requested cannot be "
267        "deleted."},
268       {"Severity", "Critical"},
269       {"Resolution", "Do not attempt to delete a non-deletable resource."}};
270 }
271 
272 /**
273  * @internal
274  * @brief Formats PropertyDuplicate message into JSON
275  *
276  * See header file for more information
277  * @endinternal
278  */
279 nlohmann::json propertyDuplicate(const std::string& arg1) {
280   return nlohmann::json{
281       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
282       {"MessageId", "Base.1.2.0.PropertyDuplicate"},
283       {"Message", "The property " + arg1 + " was duplicated in the request."},
284       {"Severity", "Warning"},
285       {"Resolution",
286        "Remove the duplicate property from the request body and resubmit the "
287        "request if the operation failed."}};
288 }
289 
290 /**
291  * @internal
292  * @brief Formats ServiceTemporarilyUnavailable message into JSON
293  *
294  * See header file for more information
295  * @endinternal
296  */
297 nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1) {
298   return nlohmann::json{
299       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
300       {"MessageId", "Base.1.2.0.ServiceTemporarilyUnavailable"},
301       {"Message", "The service is temporarily unavailable.  Retry in " + arg1 +
302                       " seconds."},
303       {"Severity", "Critical"},
304       {"Resolution",
305        "Wait for the indicated retry duration and retry the operation."}};
306 }
307 
308 /**
309  * @internal
310  * @brief Formats ResourceAlreadyExists message into JSON
311  *
312  * See header file for more information
313  * @endinternal
314  */
315 nlohmann::json resourceAlreadyExists(const std::string& arg1,
316                                      const std::string& arg2,
317                                      const std::string& arg3) {
318   return nlohmann::json{
319       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
320       {"MessageId", "Base.1.2.0.ResourceAlreadyExists"},
321       {"Message", "The requested resource of type " + arg1 +
322                       " with the property " + arg2 + " with the value " + arg3 +
323                       " already exists."},
324       {"Severity", "Critical"},
325       {"Resolution",
326        "Do not repeat the create operation as the resource has already been "
327        "created."}};
328 }
329 
330 /**
331  * @internal
332  * @brief Formats AccountForSessionNoLongerExists message into JSON
333  *
334  * See header file for more information
335  * @endinternal
336  */
337 nlohmann::json accountForSessionNoLongerExists() {
338   return nlohmann::json{
339       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
340       {"MessageId", "Base.1.2.0.AccountForSessionNoLongerExists"},
341       {"Message",
342        "The account for the current session has been removed, thus the current "
343        "session has been removed as well."},
344       {"Severity", "OK"},
345       {"Resolution", "Attempt to connect with a valid account."}};
346 }
347 
348 /**
349  * @internal
350  * @brief Formats CreateFailedMissingReqProperties message into JSON
351  *
352  * See header file for more information
353  * @endinternal
354  */
355 nlohmann::json createFailedMissingReqProperties(const std::string& arg1) {
356   return nlohmann::json{
357       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
358       {"MessageId", "Base.1.2.0.CreateFailedMissingReqProperties"},
359       {"Message", "The create operation failed because the required property " +
360                       arg1 + " was missing from the request."},
361       {"Severity", "Critical"},
362       {"Resolution",
363        "Correct the body to include the required property with a valid value "
364        "and resubmit the request if the operation failed."}};
365 }
366 
367 /**
368  * @internal
369  * @brief Formats PropertyValueFormatError message into JSON
370  *
371  * See header file for more information
372  * @endinternal
373  */
374 nlohmann::json propertyValueFormatError(const std::string& arg1,
375                                         const std::string& arg2) {
376   return nlohmann::json{
377       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
378       {"MessageId", "Base.1.2.0.PropertyValueFormatError"},
379       {"Message",
380        "The value " + arg1 + " for the property " + arg2 +
381            " is of a different format than the property can accept."},
382       {"Severity", "Warning"},
383       {"Resolution",
384        "Correct the value for the property in the request body and resubmit "
385        "the request if the operation failed."}};
386 }
387 
388 /**
389  * @internal
390  * @brief Formats PropertyValueNotInList message into JSON
391  *
392  * See header file for more information
393  * @endinternal
394  */
395 nlohmann::json propertyValueNotInList(const std::string& arg1,
396                                       const std::string& arg2) {
397   return nlohmann::json{
398       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
399       {"MessageId", "Base.1.2.0.PropertyValueNotInList"},
400       {"Message", "The value " + arg1 + " for the property " + arg2 +
401                       " is not in the list of acceptable values."},
402       {"Severity", "Warning"},
403       {"Resolution",
404        "Choose a value from the enumeration list that the implementation can "
405        "support and resubmit the request if the operation failed."}};
406 }
407 
408 /**
409  * @internal
410  * @brief Formats ResourceAtUriInUnknownFormat message into JSON
411  *
412  * See header file for more information
413  * @endinternal
414  */
415 nlohmann::json resourceAtUriInUnknownFormat(const std::string& arg1) {
416   return nlohmann::json{
417       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
418       {"MessageId", "Base.1.2.0.ResourceAtUriInUnknownFormat"},
419       {"Message", "The resource at " + arg1 +
420                       " is in a format not recognized by the service."},
421       {"Severity", "Critical"},
422       {"Resolution",
423        "Place an image or resource or file that is recognized by the service "
424        "at the URI."}};
425 }
426 
427 /**
428  * @internal
429  * @brief Formats ServiceInUnknownState message into JSON
430  *
431  * See header file for more information
432  * @endinternal
433  */
434 nlohmann::json serviceInUnknownState() {
435   return nlohmann::json{
436       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
437       {"MessageId", "Base.1.2.0.ServiceInUnknownState"},
438       {"Message",
439        "The operation failed because the service is in an unknown state and "
440        "can no longer take incoming requests."},
441       {"Severity", "Critical"},
442       {"Resolution",
443        "Restart the service and resubmit the request if the operation "
444        "failed."}};
445 }
446 
447 /**
448  * @internal
449  * @brief Formats EventSubscriptionLimitExceeded message into JSON
450  *
451  * See header file for more information
452  * @endinternal
453  */
454 nlohmann::json eventSubscriptionLimitExceeded() {
455   return nlohmann::json{
456       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
457       {"MessageId", "Base.1.2.0.EventSubscriptionLimitExceeded"},
458       {"Message",
459        "The event subscription failed due to the number of simultaneous "
460        "subscriptions exceeding the limit of the implementation."},
461       {"Severity", "Critical"},
462       {"Resolution",
463        "Reduce the number of other subscriptions before trying to establish "
464        "the event subscription or increase the limit of simultaneous "
465        "subscriptions (if supported)."}};
466 }
467 
468 /**
469  * @internal
470  * @brief Formats ActionParameterMissing message into JSON
471  *
472  * See header file for more information
473  * @endinternal
474  */
475 nlohmann::json actionParameterMissing(const std::string& arg1,
476                                       const std::string& arg2) {
477   return nlohmann::json{
478       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
479       {"MessageId", "Base.1.2.0.ActionParameterMissing"},
480       {"Message", "The action " + arg1 + " requires the parameter " + arg2 +
481                       " to be present in the request body."},
482       {"Severity", "Critical"},
483       {"Resolution",
484        "Supply the action with the required parameter in the request body when "
485        "the request is resubmitted."}};
486 }
487 
488 /**
489  * @internal
490  * @brief Formats StringValueTooLong message into JSON
491  *
492  * See header file for more information
493  * @endinternal
494  */
495 nlohmann::json stringValueTooLong(const std::string& arg1, const int& arg2) {
496   return nlohmann::json{
497       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
498       {"MessageId", "Base.1.2.0.StringValueTooLong"},
499       {"Message", "The string " + arg1 + " exceeds the length limit " +
500                       std::to_string(arg2) + "."},
501       {"Severity", "Warning"},
502       {"Resolution",
503        "Resubmit the request with an appropriate string length."}};
504 }
505 
506 /**
507  * @internal
508  * @brief Formats PropertyValueTypeError message into JSON
509  *
510  * See header file for more information
511  * @endinternal
512  */
513 nlohmann::json propertyValueTypeError(const std::string& arg1,
514                                       const std::string& arg2) {
515   return nlohmann::json{
516       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
517       {"MessageId", "Base.1.2.0.PropertyValueTypeError"},
518       {"Message", "The value " + arg1 + " for the property " + arg2 +
519                       " is of a different type than the property can accept."},
520       {"Severity", "Warning"},
521       {"Resolution",
522        "Correct the value for the property in the request body and resubmit "
523        "the request if the operation failed."}};
524 }
525 
526 /**
527  * @internal
528  * @brief Formats ResourceNotFound message into JSON
529  *
530  * See header file for more information
531  * @endinternal
532  */
533 nlohmann::json resourceNotFound(const std::string& arg1,
534                                 const std::string& arg2) {
535   return nlohmann::json{
536       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
537       {"MessageId", "Base.1.2.0.ResourceNotFound"},
538       {"Message", "The requested resource of type " + arg1 + " named " + arg2 +
539                       " was not found."},
540       {"Severity", "Critical"},
541       {"Resolution",
542        "Provide a valid resource identifier and resubmit the request."}};
543 }
544 
545 /**
546  * @internal
547  * @brief Formats CouldNotEstablishConnection message into JSON
548  *
549  * See header file for more information
550  * @endinternal
551  */
552 nlohmann::json couldNotEstablishConnection(const std::string& arg1) {
553   return nlohmann::json{
554       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
555       {"MessageId", "Base.1.2.0.CouldNotEstablishConnection"},
556       {"Message", "The service failed to establish a Connection with the URI " +
557                       arg1 + "."},
558       {"Severity", "Critical"},
559       {"Resolution",
560        "Ensure that the URI contains a valid and reachable node name, protocol "
561        "information and other URI components."}};
562 }
563 
564 /**
565  * @internal
566  * @brief Formats PropertyNotWritable message into JSON
567  *
568  * See header file for more information
569  * @endinternal
570  */
571 nlohmann::json propertyNotWritable(const std::string& arg1) {
572   return nlohmann::json{
573       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
574       {"MessageId", "Base.1.2.0.PropertyNotWritable"},
575       {"Message",
576        "The property " + arg1 +
577            " is a read only property and cannot be assigned a value."},
578       {"Severity", "Warning"},
579       {"Resolution",
580        "Remove the property from the request body and resubmit the request if "
581        "the operation failed."}};
582 }
583 
584 /**
585  * @internal
586  * @brief Formats QueryParameterValueTypeError message into JSON
587  *
588  * See header file for more information
589  * @endinternal
590  */
591 nlohmann::json queryParameterValueTypeError(const std::string& arg1,
592                                             const std::string& arg2) {
593   return nlohmann::json{
594       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
595       {"MessageId", "Base.1.2.0.QueryParameterValueTypeError"},
596       {"Message", "The value " + arg1 + " for the query parameter " + arg2 +
597                       " is of a different type than the parameter can accept."},
598       {"Severity", "Warning"},
599       {"Resolution",
600        "Correct the value for the query parameter in the request and resubmit "
601        "the request if the operation failed."}};
602 }
603 
604 /**
605  * @internal
606  * @brief Formats ServiceShuttingDown message into JSON
607  *
608  * See header file for more information
609  * @endinternal
610  */
611 nlohmann::json serviceShuttingDown() {
612   return nlohmann::json{
613       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
614       {"MessageId", "Base.1.2.0.ServiceShuttingDown"},
615       {"Message",
616        "The operation failed because the service is shutting down and can no "
617        "longer take incoming requests."},
618       {"Severity", "Critical"},
619       {"Resolution",
620        "When the service becomes available, resubmit the request if the "
621        "operation failed."}};
622 }
623 
624 /**
625  * @internal
626  * @brief Formats ActionParameterDuplicate message into JSON
627  *
628  * See header file for more information
629  * @endinternal
630  */
631 nlohmann::json actionParameterDuplicate(const std::string& arg1,
632                                         const std::string& arg2) {
633   return nlohmann::json{
634       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
635       {"MessageId", "Base.1.2.0.ActionParameterDuplicate"},
636       {"Message",
637        "The action " + arg1 +
638            " was submitted with more than one value for the parameter " + arg2 +
639            "."},
640       {"Severity", "Warning"},
641       {"Resolution",
642        "Resubmit the action with only one instance of the parameter in the "
643        "request body if the operation failed."}};
644 }
645 
646 /**
647  * @internal
648  * @brief Formats ActionParameterNotSupported message into JSON
649  *
650  * See header file for more information
651  * @endinternal
652  */
653 nlohmann::json actionParameterNotSupported(const std::string& arg1,
654                                            const std::string& arg2) {
655   return nlohmann::json{
656       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
657       {"MessageId", "Base.1.2.0.ActionParameterNotSupported"},
658       {"Message", "The parameter " + arg1 + " for the action " + arg2 +
659                       " is not supported on the target resource."},
660       {"Severity", "Warning"},
661       {"Resolution",
662        "Remove the parameter supplied and resubmit the request if the "
663        "operation failed."}};
664 }
665 
666 /**
667  * @internal
668  * @brief Formats SourceDoesNotSupportProtocol message into JSON
669  *
670  * See header file for more information
671  * @endinternal
672  */
673 nlohmann::json sourceDoesNotSupportProtocol(const std::string& arg1,
674                                             const std::string& arg2) {
675   return nlohmann::json{
676       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
677       {"MessageId", "Base.1.2.0.SourceDoesNotSupportProtocol"},
678       {"Message", "The other end of the Connection at " + arg1 +
679                       " does not support the specified protocol " + arg2 + "."},
680       {"Severity", "Critical"},
681       {"Resolution", "Change protocols or URIs. "}};
682 }
683 
684 /**
685  * @internal
686  * @brief Formats AccountRemoved message into JSON
687  *
688  * See header file for more information
689  * @endinternal
690  */
691 nlohmann::json accountRemoved() {
692   return nlohmann::json{
693       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
694       {"MessageId", "Base.1.2.0.AccountRemoved"},
695       {"Message", "The account was successfully removed."},
696       {"Severity", "OK"},
697       {"Resolution", "No resolution is required."}};
698 }
699 
700 /**
701  * @internal
702  * @brief Formats AccessDenied message into JSON
703  *
704  * See header file for more information
705  * @endinternal
706  */
707 nlohmann::json accessDenied(const std::string& arg1) {
708   return nlohmann::json{
709       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
710       {"MessageId", "Base.1.2.0.AccessDenied"},
711       {"Message", "While attempting to establish a Connection to " + arg1 +
712                       ", the service denied access."},
713       {"Severity", "Critical"},
714       {"Resolution",
715        "Attempt to ensure that the URI is correct and that the service has the "
716        "appropriate credentials."}};
717 }
718 
719 /**
720  * @internal
721  * @brief Formats QueryNotSupported message into JSON
722  *
723  * See header file for more information
724  * @endinternal
725  */
726 nlohmann::json queryNotSupported() {
727   return nlohmann::json{
728       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
729       {"MessageId", "Base.1.2.0.QueryNotSupported"},
730       {"Message", "Querying is not supported by the implementation."},
731       {"Severity", "Warning"},
732       {"Resolution",
733        "Remove the query parameters and resubmit the request if the operation "
734        "failed."}};
735 }
736 
737 /**
738  * @internal
739  * @brief Formats CreateLimitReachedForResource message into JSON
740  *
741  * See header file for more information
742  * @endinternal
743  */
744 nlohmann::json createLimitReachedForResource() {
745   return nlohmann::json{
746       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
747       {"MessageId", "Base.1.2.0.CreateLimitReachedForResource"},
748       {"Message",
749        "The create operation failed because the resource has reached the limit "
750        "of possible resources."},
751       {"Severity", "Critical"},
752       {"Resolution",
753        "Either delete resources and resubmit the request if the operation "
754        "failed or do not resubmit the request."}};
755 }
756 
757 /**
758  * @internal
759  * @brief Formats GeneralError message into JSON
760  *
761  * See header file for more information
762  * @endinternal
763  */
764 nlohmann::json generalError() {
765   return nlohmann::json{
766       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
767       {"MessageId", "Base.1.2.0.GeneralError"},
768       {"Message",
769        "A general error has occurred. See ExtendedInfo for more information."},
770       {"Severity", "Critical"},
771       {"Resolution", "See ExtendedInfo for more information."}};
772 }
773 
774 /**
775  * @internal
776  * @brief Formats Success message into JSON
777  *
778  * See header file for more information
779  * @endinternal
780  */
781 nlohmann::json success() {
782   return nlohmann::json{
783       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
784       {"MessageId", "Base.1.2.0.Success"},
785       {"Message", "Successfully Completed Request"},
786       {"Severity", "OK"},
787       {"Resolution", "None"}};
788 }
789 
790 /**
791  * @internal
792  * @brief Formats Created message into JSON
793  *
794  * See header file for more information
795  * @endinternal
796  */
797 nlohmann::json created() {
798   return nlohmann::json{
799       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
800       {"MessageId", "Base.1.2.0.Created"},
801       {"Message", "The resource has been created successfully"},
802       {"Severity", "OK"},
803       {"Resolution", "None"}};
804 }
805 
806 /**
807  * @internal
808  * @brief Formats PropertyUnknown message into JSON
809  *
810  * See header file for more information
811  * @endinternal
812  */
813 nlohmann::json propertyUnknown(const std::string& arg1) {
814   return nlohmann::json{
815       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
816       {"MessageId", "Base.1.2.0.PropertyUnknown"},
817       {"Message",
818        "The property " + arg1 +
819            " is not in the list of valid properties for the resource."},
820       {"Severity", "Warning"},
821       {"Resolution",
822        "Remove the unknown property from the request body and resubmit the "
823        "request if the operation failed."}};
824 }
825 
826 /**
827  * @internal
828  * @brief Formats NoValidSession message into JSON
829  *
830  * See header file for more information
831  * @endinternal
832  */
833 nlohmann::json noValidSession() {
834   return nlohmann::json{
835       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
836       {"MessageId", "Base.1.2.0.NoValidSession"},
837       {"Message",
838        "There is no valid session established with the implementation."},
839       {"Severity", "Critical"},
840       {"Resolution", "Establish as session before attempting any operations."}};
841 }
842 
843 /**
844  * @internal
845  * @brief Formats InvalidObject message into JSON
846  *
847  * See header file for more information
848  * @endinternal
849  */
850 nlohmann::json invalidObject(const std::string& arg1) {
851   return nlohmann::json{
852       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
853       {"MessageId", "Base.1.2.0.InvalidObject"},
854       {"Message", "The object at " + arg1 + " is invalid."},
855       {"Severity", "Critical"},
856       {"Resolution",
857        "Either the object is malformed or the URI is not correct.  Correct the "
858        "condition and resubmit the request if it failed."}};
859 }
860 
861 /**
862  * @internal
863  * @brief Formats ResourceInStandby message into JSON
864  *
865  * See header file for more information
866  * @endinternal
867  */
868 nlohmann::json resourceInStandby() {
869   return nlohmann::json{
870       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
871       {"MessageId", "Base.1.2.0.ResourceInStandby"},
872       {"Message",
873        "The request could not be performed because the resource is in "
874        "standby."},
875       {"Severity", "Critical"},
876       {"Resolution",
877        "Ensure that the resource is in the correct power state and resubmit "
878        "the request."}};
879 }
880 
881 /**
882  * @internal
883  * @brief Formats ActionParameterValueTypeError message into JSON
884  *
885  * See header file for more information
886  * @endinternal
887  */
888 nlohmann::json actionParameterValueTypeError(const std::string& arg1,
889                                              const std::string& arg2,
890                                              const std::string& arg3) {
891   return nlohmann::json{
892       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
893       {"MessageId", "Base.1.2.0.ActionParameterValueTypeError"},
894       {"Message", "The value " + arg1 + " for the parameter " + arg2 +
895                       " in the action " + arg3 +
896                       " is of a different type than the parameter can accept."},
897       {"Severity", "Warning"},
898       {"Resolution",
899        "Correct the value for the parameter in the request body and resubmit "
900        "the request if the operation failed."}};
901 }
902 
903 /**
904  * @internal
905  * @brief Formats SessionLimitExceeded message into JSON
906  *
907  * See header file for more information
908  * @endinternal
909  */
910 nlohmann::json sessionLimitExceeded() {
911   return nlohmann::json{
912       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
913       {"MessageId", "Base.1.2.0.SessionLimitExceeded"},
914       {"Message",
915        "The session establishment failed due to the number of simultaneous "
916        "sessions exceeding the limit of the implementation."},
917       {"Severity", "Critical"},
918       {"Resolution",
919        "Reduce the number of other sessions before trying to establish the "
920        "session or increase the limit of simultaneous sessions (if "
921        "supported)."}};
922 }
923 
924 /**
925  * @internal
926  * @brief Formats ActionNotSupported message into JSON
927  *
928  * See header file for more information
929  * @endinternal
930  */
931 nlohmann::json actionNotSupported(const std::string& arg1) {
932   return nlohmann::json{
933       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
934       {"MessageId", "Base.1.2.0.ActionNotSupported"},
935       {"Message", "The action " + arg1 + " is not supported by the resource."},
936       {"Severity", "Critical"},
937       {"Resolution",
938        "The action supplied cannot be resubmitted to the implementation.  "
939        "Perhaps the action was invalid, the wrong resource was the target or "
940        "the implementation documentation may be of assistance."}};
941 }
942 
943 /**
944  * @internal
945  * @brief Formats InvalidIndex message into JSON
946  *
947  * See header file for more information
948  * @endinternal
949  */
950 nlohmann::json invalidIndex(const int& arg1) {
951   return nlohmann::json{
952       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
953       {"MessageId", "Base.1.2.0.InvalidIndex"},
954       {"Message", "The index " + std::to_string(arg1) +
955                       " is not a valid offset into the array."},
956       {"Severity", "Warning"},
957       {"Resolution",
958        "Verify the index value provided is within the bounds of the array."}};
959 }
960 
961 /**
962  * @internal
963  * @brief Formats EmptyJSON message into JSON
964  *
965  * See header file for more information
966  * @endinternal
967  */
968 nlohmann::json emptyJSON() {
969   return nlohmann::json{
970       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
971       {"MessageId", "Base.1.2.0.EmptyJSON"},
972       {"Message",
973        "The request body submitted contained an empty JSON object and the "
974        "service is unable to process it."},
975       {"Severity", "Warning"},
976       {"Resolution",
977        "Add properties in the JSON object and resubmit the request."}};
978 }
979 
980 /**
981  * @internal
982  * @brief Formats QueryNotSupportedOnResource message into JSON
983  *
984  * See header file for more information
985  * @endinternal
986  */
987 nlohmann::json queryNotSupportedOnResource() {
988   return nlohmann::json{
989       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
990       {"MessageId", "Base.1.2.0.QueryNotSupportedOnResource"},
991       {"Message", "Querying is not supported on the requested resource."},
992       {"Severity", "Warning"},
993       {"Resolution",
994        "Remove the query parameters and resubmit the request if the operation "
995        "failed."}};
996 }
997 
998 /**
999  * @internal
1000  * @brief Formats InsufficientPrivilege message into JSON
1001  *
1002  * See header file for more information
1003  * @endinternal
1004  */
1005 nlohmann::json insufficientPrivilege() {
1006   return nlohmann::json{
1007       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1008       {"MessageId", "Base.1.2.0.InsufficientPrivilege"},
1009       {"Message",
1010        "There are insufficient privileges for the account or credentials "
1011        "associated with the current session to perform the requested "
1012        "operation."},
1013       {"Severity", "Critical"},
1014       {"Resolution",
1015        "Either abandon the operation or change the associated access rights "
1016        "and resubmit the request if the operation failed."}};
1017 }
1018 
1019 /**
1020  * @internal
1021  * @brief Formats PropertyValueModified message into JSON
1022  *
1023  * See header file for more information
1024  * @endinternal
1025  */
1026 nlohmann::json propertyValueModified(const std::string& arg1,
1027                                      const std::string& arg2) {
1028   return nlohmann::json{
1029       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1030       {"MessageId", "Base.1.2.0.PropertyValueModified"},
1031       {"Message", "The property " + arg1 + " was assigned the value " + arg2 +
1032                       " due to modification by the service."},
1033       {"Severity", "Warning"},
1034       {"Resolution", "No resolution is required."}};
1035 }
1036 
1037 /**
1038  * @internal
1039  * @brief Formats AccountNotModified message into JSON
1040  *
1041  * See header file for more information
1042  * @endinternal
1043  */
1044 nlohmann::json accountNotModified() {
1045   return nlohmann::json{
1046       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1047       {"MessageId", "Base.1.2.0.AccountNotModified"},
1048       {"Message", "The account modification request failed."},
1049       {"Severity", "Warning"},
1050       {"Resolution",
1051        "The modification may have failed due to permission issues or issues "
1052        "with the request body."}};
1053 }
1054 
1055 /**
1056  * @internal
1057  * @brief Formats QueryParameterValueFormatError message into JSON
1058  *
1059  * See header file for more information
1060  * @endinternal
1061  */
1062 nlohmann::json queryParameterValueFormatError(const std::string& arg1,
1063                                               const std::string& arg2) {
1064   return nlohmann::json{
1065       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1066       {"MessageId", "Base.1.2.0.QueryParameterValueFormatError"},
1067       {"Message",
1068        "The value " + arg1 + " for the parameter " + arg2 +
1069            " is of a different format than the parameter can accept."},
1070       {"Severity", "Warning"},
1071       {"Resolution",
1072        "Correct the value for the query parameter in the request and resubmit "
1073        "the request if the operation failed."}};
1074 }
1075 
1076 /**
1077  * @internal
1078  * @brief Formats PropertyMissing message into JSON
1079  *
1080  * See header file for more information
1081  * @endinternal
1082  */
1083 nlohmann::json propertyMissing(const std::string& arg1) {
1084   return nlohmann::json{
1085       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1086       {"MessageId", "Base.1.2.0.PropertyMissing"},
1087       {"Message",
1088        "The property " + arg1 +
1089            " is a required property and must be included in the request."},
1090       {"Severity", "Warning"},
1091       {"Resolution",
1092        "Ensure that the property is in the request body and has a valid value "
1093        "and resubmit the request if the operation failed."}};
1094 }
1095 
1096 /**
1097  * @internal
1098  * @brief Formats ResourceExhaustion message into JSON
1099  *
1100  * See header file for more information
1101  * @endinternal
1102  */
1103 nlohmann::json resourceExhaustion(const std::string& arg1) {
1104   return nlohmann::json{
1105       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1106       {"MessageId", "Base.1.2.0.ResourceExhaustion"},
1107       {"Message", "The resource " + arg1 +
1108                       " was unable to satisfy the request "
1109                       "due to unavailability of "
1110                       "resources."},
1111       {"Severity", "Critical"},
1112       {"Resolution",
1113        "Ensure that the resources are available and resubmit the request."}};
1114 }
1115 
1116 /**
1117  * @internal
1118  * @brief Formats AccountModified message into JSON
1119  *
1120  * See header file for more information
1121  * @endinternal
1122  */
1123 nlohmann::json accountModified() {
1124   return nlohmann::json{
1125       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1126       {"MessageId", "Base.1.2.0.AccountModified"},
1127       {"Message", "The account was successfully modified."},
1128       {"Severity", "OK"},
1129       {"Resolution", "No resolution is required."}};
1130 }
1131 
1132 /**
1133  * @internal
1134  * @brief Formats QueryParameterOutOfRange message into JSON
1135  *
1136  * See header file for more information
1137  * @endinternal
1138  */
1139 nlohmann::json queryParameterOutOfRange(const std::string& arg1,
1140                                         const std::string& arg2,
1141                                         const std::string& arg3) {
1142   return nlohmann::json{
1143       {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"},
1144       {"MessageId", "Base.1.2.0.QueryParameterOutOfRange"},
1145       {"Message", "The value " + arg1 + " for the query parameter " + arg2 +
1146                       " is out of range " + arg3 + "."},
1147       {"Severity", "Warning"},
1148       {"Resolution",
1149        "Reduce the value for the query parameter to a value that is within "
1150        "range, such as a start or count value that is within bounds of the "
1151        "number of resources in a collection or a page that is within the range "
1152        "of valid pages."}};
1153 }
1154 
1155 /*********************************
1156  * AUTOGENERATED FUNCTIONS END *
1157  *********************************/
1158 
1159 }  // namespace messages
1160 
1161 }  // namespace redfish
1162