diff options
author | Jason M. Bills <jason.m.bills@linux.intel.com> | 2020-09-11 23:19:43 +0300 |
---|---|---|
committer | Jason Bills <jason.m.bills@linux.intel.com> | 2020-09-21 22:37:45 +0300 |
commit | 684bb4b89f88b394b00b140d71c161143393f80b (patch) | |
tree | 6e3168b94b59cb79e3562b68990eaa350c584cf5 | |
parent | 1eb779d10a6ac0f77ded4067b7f2b4514f1e2bce (diff) | |
download | bmcweb-684bb4b89f88b394b00b140d71c161143393f80b.tar.xz |
Update error_messages to Base 1.8.1
The Base message registry has updated to 1.8.1. This updates our
error_messages files to match.
This changes from the deprecated 'Severity' to the new
'MessageSeverity' property.
It also adds a script to compare our error_messages.cpp messages
against the Base message registry and flag any differences.
Tested:
Ran the Redfish Validator and confirmed that this change does
not introduce any new failures.
Change-Id: I2e5101a5b4d0c0963569493451f99521e42b0f4d
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
-rw-r--r-- | redfish-core/include/error_messages.hpp | 176 | ||||
-rw-r--r-- | redfish-core/src/error_messages.cpp | 619 | ||||
-rw-r--r-- | scripts/check_base_registry.py | 61 |
3 files changed, 722 insertions, 134 deletions
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp index 9a2d1ca481..7255b8eb4e 100644 --- a/redfish-core/include/error_messages.hpp +++ b/redfish-core/include/error_messages.hpp @@ -13,14 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. */ -/**************************************************************** - * This is an auto-generated header which contains definitions - * to use Redfish DMTF defined messages. - * - * This header contains preprocessor defines which wrap - * preparation functions for message with given id. The message - * ids can be retrieved from Base.__ver__.json file. - ***************************************************************/ #pragma once #include "http_response.h" @@ -32,7 +24,7 @@ namespace redfish namespace messages { -constexpr const char* messageVersionPrefix = "Base.1.2.0."; +constexpr const char* messageVersionPrefix = "Base.1.8.1."; constexpr const char* messageAnnotation = "@Message.ExtendedInfo"; /** @@ -318,6 +310,16 @@ nlohmann::json sessionTerminated(void); void sessionTerminated(crow::Response& res); /** + * @brief Formats SubscriptionTerminated message into JSON + * Message body: "The event subscription has been terminated." + * + * + * @returns Message SubscriptionTerminated formatted to JSON */ +nlohmann::json subscriptionTerminated(void); + +void subscriptionTerminated(crow::Response& res); + +/** * @brief Formats ResourceTypeIncompatible message into JSON * Message body: "The @odata.type of the request body <arg1> is incompatible * with the @odata.type of the resource which is <arg2>." @@ -333,6 +335,141 @@ void resourceTypeIncompatible(crow::Response& res, const std::string& arg1, const std::string& arg2); /** + * @brief Formats ResetRequired message into JSON + * Message body: "In order to complete the operation, a component reset is + * required with the Reset action URI '<arg1>' and ResetType '<arg2>'." + * + * @param[in] arg1 Parameter of message that will replace %1 in its body. + * @param[in] arg2 Parameter of message that will replace %2 in its body. + * + * @returns Message ResetRequired formatted to JSON */ +nlohmann::json resetRequired(const std::string& arg1, const std::string& arg2); + +void resetRequired(crow::Response& res, const std::string& arg1, + const std::string& arg2); + +/** + * @brief Formats ChassisPowerStateOnRequired message into JSON + * Message body: "The Chassis with Id '<arg1>' requires to be powered on to + * perform this request." + * + * @param[in] arg1 Parameter of message that will replace %1 in its body. + * + * @returns Message ChassisPowerStateOnRequired formatted to JSON */ +nlohmann::json chassisPowerStateOnRequired(const std::string& arg1); + +void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1); + +/** + * @brief Formats ChassisPowerStateOffRequired message into JSON + * Message body: "The Chassis with Id '<arg1>' requires to be powered off to + * perform this request." + * + * @param[in] arg1 Parameter of message that will replace %1 in its body. + * + * @returns Message ChassisPowerStateOffRequired formatted to JSON */ +nlohmann::json chassisPowerStateOffRequired(const std::string& arg1); + +void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1); + +/** + * @brief Formats PropertyValueConflict message into JSON + * Message body: "The property '<arg1>' could not be written because its value + * would conflict with the value of the '<arg2>' property." + * + * @param[in] arg1 Parameter of message that will replace %1 in its body. + * @param[in] arg2 Parameter of message that will replace %2 in its body. + * + * @returns Message PropertyValueConflict formatted to JSON */ +nlohmann::json propertyValueConflict(const std::string& arg1, + const std::string& arg2); + +void propertyValueConflict(crow::Response& res, const std::string& arg1, + const std::string& arg2); + +/** + * @brief Formats PropertyValueIncorrect message into JSON + * Message body: "The property '<arg1>' with the requested value of '<arg2>' + * could not be written because the value does not meet the constraints of the + * implementation." + * + * @param[in] arg1 Parameter of message that will replace %1 in its body. + * @param[in] arg2 Parameter of message that will replace %2 in its body. + * + * @returns Message PropertyValueIncorrect formatted to JSON */ +nlohmann::json propertyValueIncorrect(const std::string& arg1, + const std::string& arg2); + +void propertyValueIncorrect(crow::Response& res, const std::string& arg1, + const std::string& arg2); + +/** + * @brief Formats ResourceCreationConflict message into JSON + * Message body: "The resource could not be created. The service has a resource + * at URI '<arg1>' that conflicts with the creation request." + * + * @param[in] arg1 Parameter of message that will replace %1 in its body. + * + * @returns Message ResourceCreationConflict formatted to JSON */ +nlohmann::json resourceCreationConflict(const std::string& arg1); + +void resourceCreationConflict(crow::Response& res, const std::string& arg1); + +/** + * @brief Formats MaximumErrorsExceeded message into JSON + * Message body: "Too many errors have occurred to report them all." + * + * + * @returns Message MaximumErrorsExceeded formatted to JSON */ +nlohmann::json maximumErrorsExceeded(void); + +void maximumErrorsExceeded(crow::Response& res); + +/** + * @brief Formats PreconditionFailed message into JSON + * Message body: "The ETag supplied did not match the ETag required to change + * this resource." + * + * + * @returns Message PreconditionFailed formatted to JSON */ +nlohmann::json preconditionFailed(void); + +void preconditionFailed(crow::Response& res); + +/** + * @brief Formats PreconditionRequired message into JSON + * Message body: "A precondition header or annotation is required to change this + * resource." + * + * + * @returns Message PreconditionRequired formatted to JSON */ +nlohmann::json preconditionRequired(void); + +void preconditionRequired(crow::Response& res); + +/** + * @brief Formats OperationFailed message into JSON + * Message body: "An error occurred internal to the service as part of the + * overall request. Partial results may have been returned." + * + * + * @returns Message OperationFailed formatted to JSON */ +nlohmann::json operationFailed(void); + +void operationFailed(crow::Response& res); + +/** + * @brief Formats OperationTimeout message into JSON + * Message body: "A timeout internal to the service occured as part of the + * request. Partial results may have been returned." + * + * + * @returns Message OperationTimeout formatted to JSON */ +nlohmann::json operationTimeout(void); + +void operationTimeout(crow::Response& res); + +/** * @brief Formats PropertyValueTypeError message into JSON * Message body: "The value <arg1> for the property <arg2> is of a different * type than the property can accept." @@ -660,6 +797,27 @@ nlohmann::json queryNotSupportedOnResource(void); void queryNotSupportedOnResource(crow::Response& res); /** + * @brief Formats QueryNotSupportedOnOperation message into JSON + * Message body: "Querying is not supported with the requested operation." + * + * + * @returns Message QueryNotSupportedOnOperation formatted to JSON */ +nlohmann::json queryNotSupportedOnOperation(void); + +void queryNotSupportedOnOperation(crow::Response& res); + +/** + * @brief Formats QueryCombinationInvalid message into JSON + * Message body: "Two or more query parameters in the request cannot be used + * together." + * + * + * @returns Message QueryCombinationInvalid formatted to JSON */ +nlohmann::json queryCombinationInvalid(void); + +void queryCombinationInvalid(crow::Response& res); + +/** * @brief Formats InsufficientPrivilege message into JSON * Message body: "There are insufficient privileges for the account or * credentials associated with the current session to perform the requested diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp index c6938ba336..efd2c37fc8 100644 --- a/redfish-core/src/error_messages.cpp +++ b/redfish-core/src/error_messages.cpp @@ -109,11 +109,11 @@ nlohmann::json resourceInUse(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ResourceInUse"}, + {"MessageId", "Base.1.8.1.ResourceInUse"}, {"Message", "The change to the requested resource failed because " "the resource is in use or in transition."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Remove the condition and resubmit the request if " "the operation failed."}}; } @@ -135,11 +135,11 @@ nlohmann::json malformedJSON(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.MalformedJSON"}, + {"MessageId", "Base.1.8.1.MalformedJSON"}, {"Message", "The request body submitted was malformed JSON and " "could not be parsed by the receiving service."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Ensure that the request body is valid JSON and " "resubmit the request."}}; } @@ -161,10 +161,10 @@ nlohmann::json resourceMissingAtURI(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ResourceMissingAtURI"}, + {"MessageId", "Base.1.8.1.ResourceMissingAtURI"}, {"Message", "The resource at the URI " + arg1 + " was not found."}, {"MessageArgs", {arg1}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Place a valid resource at the URI or correct the " "URI and resubmit the request."}}; } @@ -188,13 +188,13 @@ nlohmann::json actionParameterValueFormatError(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ActionParameterValueFormatError"}, + {"MessageId", "Base.1.8.1.ActionParameterValueFormatError"}, {"Message", "The value " + arg1 + " for the parameter " + arg2 + " in the action " + arg3 + " is of a different format than the parameter can accept."}, {"MessageArgs", {arg1, arg2, arg3}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Correct the value for the parameter in the request body and " "resubmit the request if the operation failed."}}; @@ -221,11 +221,11 @@ nlohmann::json internalError(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.InternalError"}, + {"MessageId", "Base.1.8.1.InternalError"}, {"Message", "The request failed due to an internal service error. " "The service is still operational."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Resubmit the request. If the problem persists, " "consider resetting the service."}}; } @@ -247,11 +247,11 @@ nlohmann::json unrecognizedRequestBody(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.UnrecognizedRequestBody"}, + {"MessageId", "Base.1.8.1.UnrecognizedRequestBody"}, {"Message", "The service detected a malformed request body that it " "was unable to interpret."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Correct the request body and resubmit the request " "if it failed."}}; } @@ -274,12 +274,12 @@ nlohmann::json resourceAtUriUnauthorized(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ResourceAtUriUnauthorized"}, + {"MessageId", "Base.1.8.1.ResourceAtUriUnauthorized"}, {"Message", "While accessing the resource at " + arg1 + ", the service received an authorization error " + arg2 + "."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Ensure that the appropriate access is provided for " "the service in order for it to access the URI."}}; } @@ -303,12 +303,12 @@ nlohmann::json actionParameterUnknown(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ActionParameterUnknown"}, + {"MessageId", "Base.1.8.1.ActionParameterUnknown"}, {"Message", "The action " + arg1 + " was submitted with the invalid parameter " + arg2 + "."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Correct the invalid parameter and resubmit the " "request if the operation failed."}}; } @@ -331,11 +331,11 @@ nlohmann::json resourceCannotBeDeleted(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ResourceCannotBeDeleted"}, + {"MessageId", "Base.1.8.1.ResourceCannotBeDeleted"}, {"Message", "The delete request failed because the resource " "requested cannot be deleted."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Do not attempt to delete a non-deletable resource."}}; } @@ -356,10 +356,10 @@ nlohmann::json propertyDuplicate(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.PropertyDuplicate"}, + {"MessageId", "Base.1.8.1.PropertyDuplicate"}, {"Message", "The property " + arg1 + " was duplicated in the request."}, {"MessageArgs", {arg1}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Remove the duplicate property from the request body and resubmit " "the request if the operation failed."}}; @@ -382,11 +382,11 @@ nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ServiceTemporarilyUnavailable"}, + {"MessageId", "Base.1.8.1.ServiceTemporarilyUnavailable"}, {"Message", "The service is temporarily unavailable. Retry in " + arg1 + " seconds."}, {"MessageArgs", {arg1}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Wait for the indicated retry duration and retry " "the operation."}}; } @@ -411,12 +411,12 @@ nlohmann::json resourceAlreadyExists(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ResourceAlreadyExists"}, + {"MessageId", "Base.1.8.1.ResourceAlreadyExists"}, {"Message", "The requested resource of type " + arg1 + " with the property " + arg2 + " with the value " + arg3 + " already exists."}, {"MessageArgs", {arg1, arg2, arg3}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Do not repeat the create operation as the resource " "has already been created."}}; } @@ -440,11 +440,11 @@ nlohmann::json accountForSessionNoLongerExists(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.AccountForSessionNoLongerExists"}, + {"MessageId", "Base.1.8.1.AccountForSessionNoLongerExists"}, {"Message", "The account for the current session has been removed, " "thus the current session has been removed as well."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "OK"}, + {"MessageSeverity", "OK"}, {"Resolution", "Attempt to connect with a valid account."}}; } @@ -465,12 +465,12 @@ nlohmann::json createFailedMissingReqProperties(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.CreateFailedMissingReqProperties"}, + {"MessageId", "Base.1.8.1.CreateFailedMissingReqProperties"}, {"Message", "The create operation failed because the required property " + arg1 + " was missing from the request."}, {"MessageArgs", {arg1}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Correct the body to include the required property with a valid " "value and resubmit the request if the operation failed."}}; @@ -497,12 +497,12 @@ nlohmann::json propertyValueFormatError(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.PropertyValueFormatError"}, + {"MessageId", "Base.1.8.1.PropertyValueFormatError"}, {"Message", "The value " + arg1 + " for the property " + arg2 + " is of a different format than the property can accept."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Correct the value for the property in the request body and " "resubmit the request if the operation failed."}}; @@ -528,11 +528,11 @@ nlohmann::json propertyValueNotInList(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.PropertyValueNotInList"}, + {"MessageId", "Base.1.8.1.PropertyValueNotInList"}, {"Message", "The value " + arg1 + " for the property " + arg2 + " is not in the list of acceptable values."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Choose a value from the enumeration list that " "the implementation " "can support and resubmit the request if the " @@ -557,11 +557,11 @@ nlohmann::json resourceAtUriInUnknownFormat(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ResourceAtUriInUnknownFormat"}, + {"MessageId", "Base.1.8.1.ResourceAtUriInUnknownFormat"}, {"Message", "The resource at " + arg1 + " is in a format not recognized by the service."}, {"MessageArgs", {arg1}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Place an image or resource or file that is " "recognized by the service at the URI."}}; } @@ -583,12 +583,12 @@ nlohmann::json serviceInUnknownState(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ServiceInUnknownState"}, + {"MessageId", "Base.1.8.1.ServiceInUnknownState"}, {"Message", "The operation failed because the service is in an unknown state " "and can no longer take incoming requests."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Restart the service and resubmit the request if " "the operation failed."}}; } @@ -610,12 +610,12 @@ nlohmann::json eventSubscriptionLimitExceeded(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.EventSubscriptionLimitExceeded"}, + {"MessageId", "Base.1.8.1.EventSubscriptionLimitExceeded"}, {"Message", "The event subscription failed due to the number of simultaneous " "subscriptions exceeding the limit of the implementation."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Reduce the number of other subscriptions before trying to " "establish the event subscription or increase the limit of " @@ -640,11 +640,11 @@ nlohmann::json actionParameterMissing(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ActionParameterMissing"}, + {"MessageId", "Base.1.8.1.ActionParameterMissing"}, {"Message", "The action " + arg1 + " requires the parameter " + arg2 + " to be present in the request body."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Supply the action with the required parameter in the request " "body when the request is resubmitted."}}; @@ -668,11 +668,11 @@ nlohmann::json stringValueTooLong(const std::string& arg1, const int& arg2) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.StringValueTooLong"}, + {"MessageId", "Base.1.8.1.StringValueTooLong"}, {"Message", "The string " + arg1 + " exceeds the length limit " + std::to_string(arg2) + "."}, {"MessageArgs", {arg1, std::to_string(arg2)}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Resubmit the request with an appropriate string length."}}; } @@ -695,10 +695,10 @@ nlohmann::json sessionTerminated(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.SessionTerminated"}, + {"MessageId", "Base.1.8.1.SessionTerminated"}, {"Message", "The session was successfully terminated."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "OK"}, + {"MessageSeverity", "OK"}, {"Resolution", "No resolution is required."}}; } @@ -710,6 +710,30 @@ void sessionTerminated(crow::Response& res) /** * @internal + * @brief Formats SubscriptionTerminated message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json subscriptionTerminated(void) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.SubscriptionTerminated"}, + {"Message", "The event subscription has been terminated."}, + {"MessageArgs", nlohmann::json::array()}, + {"MessageSeverity", "OK"}, + {"Resolution", "No resolution is required."}}; +} + +void subscriptionTerminated(crow::Response& res) +{ + res.result(boost::beast::http::status::ok); + addMessageToJsonRoot(res.jsonValue, subscriptionTerminated()); +} + +/** + * @internal * @brief Formats ResourceTypeIncompatible message into JSON * * See header file for more information @@ -720,13 +744,13 @@ nlohmann::json resourceTypeIncompatible(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ResourceTypeIncompatible"}, + {"MessageId", "Base.1.8.1.ResourceTypeIncompatible"}, {"Message", "The @odata.type of the request body " + arg1 + " is incompatible with the @odata.type of the " "resource which is " + arg2 + "."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Resubmit the request with a payload compatible " "with the resource's schema."}}; } @@ -740,6 +764,300 @@ void resourceTypeIncompatible(crow::Response& res, const std::string& arg1, /** * @internal + * @brief Formats ResetRequired message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json resetRequired(const std::string& arg1, const std::string& arg2) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.ResetRequired"}, + {"Message", "In order to complete the operation, a component reset is " + "required with the Reset action URI '" + + arg1 + "' and ResetType '" + arg2 + "'."}, + {"MessageArgs", {arg1, arg2}}, + {"MessageSeverity", "Warning"}, + {"Resolution", + "Perform the required Reset action on the specified component."}}; +} + +void resetRequired(crow::Response& res, const std::string& arg1, + const std::string& arg2) +{ + res.result(boost::beast::http::status::bad_request); + addMessageToErrorJson(res.jsonValue, resetRequired(arg1, arg2)); +} + +/** + * @internal + * @brief Formats ChassisPowerStateOnRequired message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json chassisPowerStateOnRequired(const std::string& arg1) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.ChassisPowerStateOnRequired"}, + {"Message", "The Chassis with Id '" + arg1 + + "' requires to be powered on to perform this request."}, + {"MessageArgs", {arg1}}, + {"MessageSeverity", "Warning"}, + {"Resolution", + "Power on the specified Chassis and resubmit the request."}}; +} + +void chassisPowerStateOnRequired(crow::Response& res, const std::string& arg1) +{ + res.result(boost::beast::http::status::bad_request); + addMessageToErrorJson(res.jsonValue, chassisPowerStateOnRequired(arg1)); +} + +/** + * @internal + * @brief Formats ChassisPowerStateOffRequired message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json chassisPowerStateOffRequired(const std::string& arg1) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.ChassisPowerStateOffRequired"}, + {"Message", + "The Chassis with Id '" + arg1 + + "' requires to be powered off to perform this request."}, + {"MessageArgs", {arg1}}, + {"MessageSeverity", "Warning"}, + {"Resolution", + "Power off the specified Chassis and resubmit the request."}}; +} + +void chassisPowerStateOffRequired(crow::Response& res, const std::string& arg1) +{ + res.result(boost::beast::http::status::bad_request); + addMessageToErrorJson(res.jsonValue, chassisPowerStateOffRequired(arg1)); +} + +/** + * @internal + * @brief Formats PropertyValueConflict message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json propertyValueConflict(const std::string& arg1, + const std::string& arg2) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.PropertyValueConflict"}, + {"Message", "The property '" + arg1 + + "' could not be written because its value would " + "conflict with the value of the '" + + arg2 + "' property."}, + {"MessageArgs", {arg1, arg2}}, + {"MessageSeverity", "Warning"}, + {"Resolution", "No resolution is required."}}; +} + +void propertyValueConflict(crow::Response& res, const std::string& arg1, + const std::string& arg2) +{ + res.result(boost::beast::http::status::bad_request); + addMessageToErrorJson(res.jsonValue, propertyValueConflict(arg1, arg2)); +} + +/** + * @internal + * @brief Formats PropertyValueIncorrect message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json propertyValueIncorrect(const std::string& arg1, + const std::string& arg2) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.PropertyValueIncorrect"}, + {"Message", "The property '" + arg1 + + "' with the requested value of '" + arg2 + + "' could not be written because the value does not " + "meet the constraints of the implementation."}, + {"MessageArgs", {arg1, arg2}}, + {"MessageSeverity", "Warning"}, + {"Resolution", "No resolution is required."}}; +} + +void propertyValueIncorrect(crow::Response& res, const std::string& arg1, + const std::string& arg2) +{ + res.result(boost::beast::http::status::bad_request); + addMessageToErrorJson(res.jsonValue, propertyValueIncorrect(arg1, arg2)); +} + +/** + * @internal + * @brief Formats ResourceCreationConflict message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json resourceCreationConflict(const std::string& arg1) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.ResourceCreationConflict"}, + {"Message", "The resource could not be created. The service has a " + "resource at URI '" + + arg1 + "' that conflicts with the creation request."}, + {"MessageArgs", {arg1}}, + {"MessageSeverity", "Warning"}, + {"Resolution", "No resolution is required."}}; +} + +void resourceCreationConflict(crow::Response& res, const std::string& arg1) +{ + res.result(boost::beast::http::status::bad_request); + addMessageToErrorJson(res.jsonValue, resourceCreationConflict(arg1)); +} + +/** + * @internal + * @brief Formats MaximumErrorsExceeded message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json maximumErrorsExceeded(void) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.MaximumErrorsExceeded"}, + {"Message", "Too many errors have occurred to report them all."}, + {"MessageArgs", nlohmann::json::array()}, + {"MessageSeverity", "Critical"}, + {"Resolution", + "Resolve other reported errors and retry the current operation."}}; +} + +void maximumErrorsExceeded(crow::Response& res) +{ + res.result(boost::beast::http::status::internal_server_error); + addMessageToErrorJson(res.jsonValue, maximumErrorsExceeded()); +} + +/** + * @internal + * @brief Formats PreconditionFailed message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json preconditionFailed(void) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.PreconditionFailed"}, + {"Message", "The ETag supplied did not match the ETag required to " + "change this resource."}, + {"MessageArgs", nlohmann::json::array()}, + {"MessageSeverity", "Critical"}, + {"Resolution", "Try the operation again using the appropriate ETag."}}; +} + +void preconditionFailed(crow::Response& res) +{ + res.result(boost::beast::http::status::bad_request); + addMessageToErrorJson(res.jsonValue, preconditionFailed()); +} + +/** + * @internal + * @brief Formats PreconditionRequired message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json preconditionRequired(void) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.PreconditionRequired"}, + {"Message", "A precondition header or annotation is required to change " + "this resource."}, + {"MessageArgs", nlohmann::json::array()}, + {"MessageSeverity", "Critical"}, + {"Resolution", "Try the operation again using an If-Match or " + "If-None-Match header and appropriate ETag."}}; +} + +void preconditionRequired(crow::Response& res) +{ + res.result(boost::beast::http::status::bad_request); + addMessageToErrorJson(res.jsonValue, preconditionRequired()); +} + +/** + * @internal + * @brief Formats OperationFailed message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json operationFailed(void) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.OperationFailed"}, + {"Message", + "An error occurred internal to the service as part of the overall " + "request. Partial results may have been returned."}, + {"MessageArgs", nlohmann::json::array()}, + {"MessageSeverity", "Warning"}, + {"Resolution", "Resubmit the request. If the problem persists, " + "consider resetting the service or provider."}}; +} + +void operationFailed(crow::Response& res) +{ + res.result(boost::beast::http::status::internal_server_error); + addMessageToErrorJson(res.jsonValue, operationFailed()); +} + +/** + * @internal + * @brief Formats OperationTimeout message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json operationTimeout(void) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.OperationTimeout"}, + {"Message", "A timeout internal to the service occured as part of the " + "request. Partial results may have been returned."}, + {"MessageArgs", nlohmann::json::array()}, + {"MessageSeverity", "Warning"}, + {"Resolution", "Resubmit the request. If the problem persists, " + "consider resetting the service or provider."}}; +} + +void operationTimeout(crow::Response& res) +{ + res.result(boost::beast::http::status::internal_server_error); + addMessageToErrorJson(res.jsonValue, operationTimeout()); +} + +/** + * @internal * @brief Formats PropertyValueTypeError message into JSON for the specified * property * @@ -751,12 +1069,12 @@ nlohmann::json propertyValueTypeError(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.PropertyValueTypeError"}, + {"MessageId", "Base.1.8.1.PropertyValueTypeError"}, {"Message", "The value " + arg1 + " for the property " + arg2 + " is of a different type than the property can accept."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Correct the value for the property in the request body and " "resubmit the request if the operation failed."}}; @@ -781,11 +1099,11 @@ nlohmann::json resourceNotFound(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ResourceNotFound"}, + {"MessageId", "Base.1.8.1.ResourceNotFound"}, {"Message", "The requested resource of type " + arg1 + " named " + arg2 + " was not found."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Provide a valid resource identifier and resubmit the request."}}; } @@ -808,12 +1126,12 @@ nlohmann::json couldNotEstablishConnection(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.CouldNotEstablishConnection"}, + {"MessageId", "Base.1.8.1.CouldNotEstablishConnection"}, {"Message", - "The service failed to establish a Connection with the URI " + arg1 + + "The service failed to establish a connection with the URI " + arg1 + "."}, {"MessageArgs", {arg1}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Ensure that the URI contains a valid and reachable node name, " "protocol information and other URI components."}}; @@ -837,12 +1155,12 @@ nlohmann::json propertyNotWritable(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.PropertyNotWritable"}, + {"MessageId", "Base.1.8.1.PropertyNotWritable"}, {"Message", "The property " + arg1 + " is a read only property and cannot be " "assigned a value."}, {"MessageArgs", {arg1}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Remove the property from the request body and " "resubmit the request if the operation failed."}}; } @@ -865,12 +1183,12 @@ nlohmann::json queryParameterValueTypeError(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.QueryParameterValueTypeError"}, + {"MessageId", "Base.1.8.1.QueryParameterValueTypeError"}, {"Message", "The value " + arg1 + " for the query parameter " + arg2 + " is of a different type than the parameter can accept."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Correct the value for the query parameter in the request and " "resubmit the request if the operation failed."}}; @@ -895,11 +1213,11 @@ nlohmann::json serviceShuttingDown(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ServiceShuttingDown"}, + {"MessageId", "Base.1.8.1.ServiceShuttingDown"}, {"Message", "The operation failed because the service is shutting " "down and can no longer take incoming requests."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "When the service becomes available, resubmit the " "request if the operation failed."}}; } @@ -922,13 +1240,13 @@ nlohmann::json actionParameterDuplicate(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ActionParameterDuplicate"}, + {"MessageId", "Base.1.8.1.ActionParameterDuplicate"}, {"Message", "The action " + arg1 + " was submitted with more than one value for the parameter " + arg2 + "."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Resubmit the action with only one instance of the parameter in " "the request body if the operation failed."}}; @@ -953,11 +1271,11 @@ nlohmann::json actionParameterNotSupported(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ActionParameterNotSupported"}, + {"MessageId", "Base.1.8.1.ActionParameterNotSupported"}, {"Message", "The parameter " + arg1 + " for the action " + arg2 + " is not supported on the target resource."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Remove the parameter supplied and resubmit the " "request if the operation failed."}}; } @@ -982,12 +1300,12 @@ nlohmann::json sourceDoesNotSupportProtocol(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.SourceDoesNotSupportProtocol"}, - {"Message", "The other end of the Connection at " + arg1 + + {"MessageId", "Base.1.8.1.SourceDoesNotSupportProtocol"}, + {"Message", "The other end of the connection at " + arg1 + " does not support the specified protocol " + arg2 + "."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Change protocols or URIs. "}}; } @@ -1009,10 +1327,10 @@ void sourceDoesNotSupportProtocol(crow::Response& res, const std::string& arg1, nlohmann::json accountRemoved(void) { return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.AccountRemoved"}, + {"MessageId", "Base.1.8.1.AccountRemoved"}, {"Message", "The account was successfully removed."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "OK"}, + {"MessageSeverity", "OK"}, {"Resolution", "No resolution is required."}}; } @@ -1033,11 +1351,11 @@ nlohmann::json accessDenied(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.AccessDenied"}, - {"Message", "While attempting to establish a Connection to " + arg1 + + {"MessageId", "Base.1.8.1.AccessDenied"}, + {"Message", "While attempting to establish a connection to " + arg1 + ", the service denied access."}, {"MessageArgs", {arg1}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Attempt to ensure that the URI is correct and that " "the service has the appropriate credentials."}}; } @@ -1059,10 +1377,10 @@ nlohmann::json queryNotSupported(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.QueryNotSupported"}, + {"MessageId", "Base.1.8.1.QueryNotSupported"}, {"Message", "Querying is not supported by the implementation."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Remove the query parameters and resubmit the " "request if the operation failed."}}; } @@ -1084,11 +1402,11 @@ nlohmann::json createLimitReachedForResource(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.CreateLimitReachedForResource"}, + {"MessageId", "Base.1.8.1.CreateLimitReachedForResource"}, {"Message", "The create operation failed because the resource has " "reached the limit of possible resources."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Either delete resources and resubmit the request if the " "operation failed or do not resubmit the request."}}; @@ -1110,12 +1428,12 @@ void createLimitReachedForResource(crow::Response& res) nlohmann::json generalError(void) { return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.GeneralError"}, + {"MessageId", "Base.1.8.1.GeneralError"}, {"Message", "A general error has occurred. See Resolution for " "information on how to resolve the error."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "None."}}; } @@ -1135,10 +1453,10 @@ void generalError(crow::Response& res) nlohmann::json success(void) { return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.Success"}, + {"MessageId", "Base.1.8.1.Success"}, {"Message", "Successfully Completed Request"}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "OK"}, + {"MessageSeverity", "OK"}, {"Resolution", "None"}}; } @@ -1160,10 +1478,10 @@ nlohmann::json created(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.Created"}, + {"MessageId", "Base.1.8.1.Created"}, {"Message", "The resource has been created successfully"}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "OK"}, + {"MessageSeverity", "OK"}, {"Resolution", "None"}}; } @@ -1184,11 +1502,11 @@ nlohmann::json noOperation(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.NoOperation"}, + {"MessageId", "Base.1.8.1.NoOperation"}, {"Message", "The request body submitted contain no data to act " "upon and no changes to the resource took place."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Add properties in the JSON object and resubmit the request."}}; } @@ -1211,12 +1529,12 @@ nlohmann::json propertyUnknown(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.PropertyUnknown"}, + {"MessageId", "Base.1.8.1.PropertyUnknown"}, {"Message", "The property " + arg1 + " is not in the list of valid properties for " "the resource."}, {"MessageArgs", {arg1}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Remove the unknown property from the request " "body and resubmit " "the request if the operation failed."}}; @@ -1239,13 +1557,13 @@ nlohmann::json noValidSession(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.NoValidSession"}, + {"MessageId", "Base.1.8.1.NoValidSession"}, {"Message", "There is no valid session established with the implementation."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", - "Establish as session before attempting any operations."}}; + "Establish a session before attempting any operations."}}; } void noValidSession(crow::Response& res) @@ -1265,10 +1583,10 @@ nlohmann::json invalidObject(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.InvalidObject"}, + {"MessageId", "Base.1.8.1.InvalidObject"}, {"Message", "The object at " + arg1 + " is invalid."}, {"MessageArgs", {arg1}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Either the object is malformed or the URI is not correct. " "Correct the condition and resubmit the request if it failed."}}; @@ -1291,11 +1609,11 @@ nlohmann::json resourceInStandby(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ResourceInStandby"}, + {"MessageId", "Base.1.8.1.ResourceInStandby"}, {"Message", "The request could not be performed because the " "resource is in standby."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Ensure that the resource is in the correct power " "state and resubmit the request."}}; } @@ -1319,13 +1637,13 @@ nlohmann::json actionParameterValueTypeError(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ActionParameterValueTypeError"}, + {"MessageId", "Base.1.8.1.ActionParameterValueTypeError"}, {"Message", "The value " + arg1 + " for the parameter " + arg2 + " in the action " + arg3 + " is of a different type than the parameter can accept."}, {"MessageArgs", {arg1, arg2, arg3}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Correct the value for the parameter in the request body and " "resubmit the request if the operation failed."}}; @@ -1351,12 +1669,12 @@ nlohmann::json sessionLimitExceeded(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.SessionLimitExceeded"}, + {"MessageId", "Base.1.8.1.SessionLimitExceeded"}, {"Message", "The session establishment failed due to the number of " "simultaneous sessions exceeding the limit of the " "implementation."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Reduce the number of other sessions before trying " "to establish the session or increase the limit of " "simultaneous sessions (if supported)."}}; @@ -1379,11 +1697,11 @@ nlohmann::json actionNotSupported(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ActionNotSupported"}, + {"MessageId", "Base.1.8.1.ActionNotSupported"}, {"Message", "The action " + arg1 + " is not supported by the resource."}, {"MessageArgs", {arg1}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "The action supplied cannot be resubmitted to the implementation. " " Perhaps the action was invalid, the wrong resource was the " @@ -1408,11 +1726,11 @@ nlohmann::json invalidIndex(const int& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.InvalidIndex"}, - {"Message", "The index " + std::to_string(arg1) + + {"MessageId", "Base.1.8.1.InvalidIndex"}, + {"Message", "The Index " + std::to_string(arg1) + " is not a valid offset into the array."}, {"MessageArgs", {std::to_string(arg1)}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Verify the index value provided is within the " "bounds of the array."}}; } @@ -1434,11 +1752,11 @@ nlohmann::json emptyJSON(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.EmptyJSON"}, + {"MessageId", "Base.1.8.1.EmptyJSON"}, {"Message", "The request body submitted contained an empty JSON " "object and the service is unable to process it."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Add properties in the JSON object and resubmit the request."}}; } @@ -1460,10 +1778,10 @@ nlohmann::json queryNotSupportedOnResource(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.QueryNotSupportedOnResource"}, + {"MessageId", "Base.1.8.1.QueryNotSupportedOnResource"}, {"Message", "Querying is not supported on the requested resource."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Remove the query parameters and resubmit the " "request if the operation failed."}}; } @@ -1476,6 +1794,57 @@ void queryNotSupportedOnResource(crow::Response& res) /** * @internal + * @brief Formats QueryNotSupportedOnOperation message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json queryNotSupportedOnOperation(void) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.QueryNotSupportedOnOperation"}, + {"Message", "Querying is not supported with the requested operation."}, + {"MessageArgs", nlohmann::json::array()}, + {"MessageSeverity", "Warning"}, + {"Resolution", "Remove the query parameters and resubmit the request " + "if the operation failed."}}; +} + +void queryNotSupportedOnOperation(crow::Response& res) +{ + res.result(boost::beast::http::status::forbidden); + addMessageToErrorJson(res.jsonValue, queryNotSupportedOnOperation()); +} + +/** + * @internal + * @brief Formats QueryCombinationInvalid message into JSON + * + * See header file for more information + * @endinternal + */ +nlohmann::json queryCombinationInvalid(void) +{ + return nlohmann::json{ + {"@odata.type", "#Message.v1_0_0.Message"}, + {"MessageId", "Base.1.8.1.QueryCombinationInvalid"}, + {"Message", "Two or more query parameters in the request cannot be " + "used together."}, + {"MessageArgs", nlohmann::json::array()}, + {"MessageSeverity", "Warning"}, + {"Resolution", "Remove one or more of the query parameters and " + "resubmit the request if the operation failed."}}; +} + +void queryCombinationInvalid(crow::Response& res) +{ + res.result(boost::beast::http::status::bad_request); + addMessageToErrorJson(res.jsonValue, queryCombinationInvalid()); +} + +/** + * @internal * @brief Formats InsufficientPrivilege message into JSON * * See header file for more information @@ -1485,12 +1854,12 @@ nlohmann::json insufficientPrivilege(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.InsufficientPrivilege"}, + {"MessageId", "Base.1.8.1.InsufficientPrivilege"}, {"Message", "There are insufficient privileges for the account or " "credentials associated with the current session to " "perform the requested operation."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Either abandon the operation or change the associated access " "rights and resubmit the request if the operation failed."}}; @@ -1514,11 +1883,11 @@ nlohmann::json propertyValueModified(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.PropertyValueModified"}, + {"MessageId", "Base.1.8.1.PropertyValueModified"}, {"Message", "The property " + arg1 + " was assigned the value " + arg2 + " due to modification by the service."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "No resolution is required."}}; } @@ -1540,10 +1909,10 @@ nlohmann::json accountNotModified(void) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.AccountNotModified"}, + {"MessageId", "Base.1.8.1.AccountNotModified"}, {"Message", "The account modification request failed."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "The modification may have failed due to permission " "issues or issues with the request body."}}; } @@ -1566,12 +1935,12 @@ nlohmann::json queryParameterValueFormatError(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.QueryParameterValueFormatError"}, + {"MessageId", "Base.1.8.1.QueryParameterValueFormatError"}, {"Message", "The value " + arg1 + " for the parameter " + arg2 + " is of a different format than the parameter can accept."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Correct the value for the query parameter in the request and " "resubmit the request if the operation failed."}}; @@ -1598,12 +1967,12 @@ nlohmann::json propertyMissing(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.PropertyMissing"}, + {"MessageId", "Base.1.8.1.PropertyMissing"}, {"Message", "The property " + arg1 + " is a required property and must be included in " "the request."}, {"MessageArgs", {arg1}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Ensure that the property is in the request body and has a " "valid " @@ -1627,12 +1996,12 @@ nlohmann::json resourceExhaustion(const std::string& arg1) { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.ResourceExhaustion"}, + {"MessageId", "Base.1.8.1.ResourceExhaustion"}, {"Message", "The resource " + arg1 + " was unable to satisfy the request due to " "unavailability of resources."}, {"MessageArgs", {arg1}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Ensure that the resources are available and " "resubmit the request."}}; } @@ -1653,10 +2022,10 @@ void resourceExhaustion(crow::Response& res, const std::string& arg1) nlohmann::json accountModified(void) { return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.AccountModified"}, + {"MessageId", "Base.1.8.1.AccountModified"}, {"Message", "The account was successfully modified."}, {"MessageArgs", nlohmann::json::array()}, - {"Severity", "OK"}, + {"MessageSeverity", "OK"}, {"Resolution", "No resolution is required."}}; } @@ -1679,11 +2048,11 @@ nlohmann::json queryParameterOutOfRange(const std::string& arg1, { return nlohmann::json{ {"@odata.type", "#Message.v1_0_0.Message"}, - {"MessageId", "Base.1.4.0.QueryParameterOutOfRange"}, + {"MessageId", "Base.1.8.1.QueryParameterOutOfRange"}, {"Message", "The value " + arg1 + " for the query parameter " + arg2 + " is out of range " + arg3 + "."}, {"MessageArgs", {arg1, arg2, arg3}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Reduce the value for the query parameter to a value that is " "within range, such as a start or count value that is within " @@ -1712,14 +2081,14 @@ void passwordChangeRequired(crow::Response& res, const std::string& arg1) res.jsonValue, nlohmann::json{ {"@odata.type", "/redfish/v1/$metadata#Message.v1_5_0.Message"}, - {"MessageId", "Base.1.5.0.PasswordChangeRequired"}, + {"MessageId", "Base.1.8.1.PasswordChangeRequired"}, {"Message", "The password provided for this account must be " "changed before access is granted. PATCH the " "'Password' property for this account located at " "the target URI '" + arg1 + "' to complete this process."}, {"MessageArgs", {arg1}}, - {"Severity", "Critical"}, + {"MessageSeverity", "Critical"}, {"Resolution", "Change the password for this account using " "a PATCH to the 'Password' property at the URI " "provided."}}); @@ -1746,7 +2115,7 @@ nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2) {"MessageId", "OpenBMC.0.1.0.InvalidUpload"}, {"Message", "Invalid file uploaded to " + arg1 + ": " + arg2 + "."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "None."}}; } @@ -1766,7 +2135,7 @@ nlohmann::json mutualExclusiveProperties(const std::string& arg1, {"Message", "The properties " + arg1 + " and " + arg2 + " are mutually exclusive."}, {"MessageArgs", {arg1, arg2}}, - {"Severity", "Warning"}, + {"MessageSeverity", "Warning"}, {"Resolution", "Ensure that the request body doesn't contain mutually exclusive " "properties and resubmit the request."}}; diff --git a/scripts/check_base_registry.py b/scripts/check_base_registry.py new file mode 100644 index 0000000000..667f167026 --- /dev/null +++ b/scripts/check_base_registry.py @@ -0,0 +1,61 @@ +#!/usr/bin/python3 + +import argparse +import json +import re + + +parser = argparse.ArgumentParser() +parser.add_argument('-b', '--base', default=None, required=True) +parser.add_argument('-f', '--file', default=None, required=True) +args = parser.parse_args() + +with open(args.file) as error_file: + error_data = error_file.readlines() + + with open(args.base) as base_file: + base_json = json.load(base_file) + for message_name, message_data in base_json['Messages'].items(): + message_id = base_json['RegistryPrefix'] + '.' + \ + base_json['RegistryVersion'] + '.' + message_name + message_found = False + index = 0 + for i, error in enumerate(error_data): + if message_id in error: + message_found = True + index = i + break + if not message_found: + print("{} not found".format(message_id)) + continue + + error_info = error_data[index:index + 15] + error_str = " ".join(error_info) + error_str = re.sub( + 'std::to_string\(arg(\d+)\)', + 'arg\\1', + error_str) + error_str = re.sub('"\n\s*"', '', error_str, re.MULTILINE) + error_str = re.sub( + '"\s*\+\s*arg(\d+)\s*\+\n?\s*"', + '%\\1', + error_str, + re.MULTILINE) + if message_data['Message'] not in error_str: + print( + "{}: error in Message: {}".format( + message_id, + message_data['Message'])) + print(error_str) + + if message_data['MessageSeverity'] not in error_str: + print("{}: error in MessageSeverity: {}".format( + message_id, message_data['MessageSeverity'])) + print(error_str) + + if message_data['Resolution'] not in error_str: + print( + "{}: error in Resolution: {}".format( + message_id, + message_data['Resolution'])) + print(error_str) |