1f4c4dcf4SKowalski, Kamil /* 2f4c4dcf4SKowalski, Kamil // Copyright (c) 2018 Intel Corporation 3f4c4dcf4SKowalski, Kamil // 4f4c4dcf4SKowalski, Kamil // Licensed under the Apache License, Version 2.0 (the "License"); 5f4c4dcf4SKowalski, Kamil // you may not use this file except in compliance with the License. 6f4c4dcf4SKowalski, Kamil // You may obtain a copy of the License at 7f4c4dcf4SKowalski, Kamil // 8f4c4dcf4SKowalski, Kamil // http://www.apache.org/licenses/LICENSE-2.0 9f4c4dcf4SKowalski, Kamil // 10f4c4dcf4SKowalski, Kamil // Unless required by applicable law or agreed to in writing, software 11f4c4dcf4SKowalski, Kamil // distributed under the License is distributed on an "AS IS" BASIS, 12f4c4dcf4SKowalski, Kamil // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f4c4dcf4SKowalski, Kamil // See the License for the specific language governing permissions and 14f4c4dcf4SKowalski, Kamil // limitations under the License. 15f4c4dcf4SKowalski, Kamil */ 16c94ad49bSEd Tanous #include <logging.h> 17f4c4dcf4SKowalski, Kamil 181abe55efSEd Tanous #include <error_messages.hpp> 19f4c4dcf4SKowalski, Kamil 201abe55efSEd Tanous namespace redfish 211abe55efSEd Tanous { 221abe55efSEd Tanous 231abe55efSEd Tanous namespace messages 241abe55efSEd Tanous { 25f4c4dcf4SKowalski, Kamil 26f12894f8SJason M. Bills static void addMessageToErrorJson(nlohmann::json& target, 271abe55efSEd Tanous const nlohmann::json& message) 281abe55efSEd Tanous { 29f4c4dcf4SKowalski, Kamil auto& error = target["error"]; 30f4c4dcf4SKowalski, Kamil 311abe55efSEd Tanous // If this is the first error message, fill in the information from the 321abe55efSEd Tanous // first error message to the top level struct 331abe55efSEd Tanous if (!error.is_object()) 341abe55efSEd Tanous { 35c074230bSJason M. Bills auto messageIdIterator = message.find("MessageId"); 36c074230bSJason M. Bills if (messageIdIterator == message.end()) 371abe55efSEd Tanous { 381abe55efSEd Tanous BMCWEB_LOG_CRITICAL 391abe55efSEd Tanous << "Attempt to add error message without MessageId"; 40f4c4dcf4SKowalski, Kamil return; 41f4c4dcf4SKowalski, Kamil } 42f4c4dcf4SKowalski, Kamil 43c074230bSJason M. Bills auto messageFieldIterator = message.find("Message"); 44c074230bSJason M. Bills if (messageFieldIterator == message.end()) 451abe55efSEd Tanous { 461abe55efSEd Tanous BMCWEB_LOG_CRITICAL 471abe55efSEd Tanous << "Attempt to add error message without Message"; 48f4c4dcf4SKowalski, Kamil return; 49f4c4dcf4SKowalski, Kamil } 50c21055aaSEd Tanous error = {{"code", *messageIdIterator}, 51c21055aaSEd Tanous {"message", *messageFieldIterator}}; 521abe55efSEd Tanous } 531abe55efSEd Tanous else 541abe55efSEd Tanous { 55f4c4dcf4SKowalski, Kamil // More than 1 error occurred, so the message has to be generic 5655c7b7a2SEd Tanous error["code"] = std::string(messageVersionPrefix) + "GeneralError"; 57cc9139ecSJason M. Bills error["message"] = "A general error has occurred. See Resolution for " 58cc9139ecSJason M. Bills "information on how to resolve the error."; 59f4c4dcf4SKowalski, Kamil } 60f4c4dcf4SKowalski, Kamil 61f4c4dcf4SKowalski, Kamil // This check could technically be done in in the default construction 62f4c4dcf4SKowalski, Kamil // branch above, but because we need the pointer to the extended info field 63f4c4dcf4SKowalski, Kamil // anyway, it's more efficient to do it here. 64c074230bSJason M. Bills auto& extendedInfo = error[messages::messageAnnotation]; 65c074230bSJason M. Bills if (!extendedInfo.is_array()) 661abe55efSEd Tanous { 67c074230bSJason M. Bills extendedInfo = nlohmann::json::array(); 68f4c4dcf4SKowalski, Kamil } 69f4c4dcf4SKowalski, Kamil 70c074230bSJason M. Bills extendedInfo.push_back(message); 71f4c4dcf4SKowalski, Kamil } 72f4c4dcf4SKowalski, Kamil 73f12894f8SJason M. Bills static void addMessageToJsonRoot(nlohmann::json& target, 74f12894f8SJason M. Bills const nlohmann::json& message) 751abe55efSEd Tanous { 761abe55efSEd Tanous if (!target[messages::messageAnnotation].is_array()) 771abe55efSEd Tanous { 78f4c4dcf4SKowalski, Kamil // Force object to be an array 7955c7b7a2SEd Tanous target[messages::messageAnnotation] = nlohmann::json::array(); 80f4c4dcf4SKowalski, Kamil } 81f4c4dcf4SKowalski, Kamil 8255c7b7a2SEd Tanous target[messages::messageAnnotation].push_back(message); 83f4c4dcf4SKowalski, Kamil } 84f4c4dcf4SKowalski, Kamil 85f12894f8SJason M. Bills static void addMessageToJson(nlohmann::json& target, 86f12894f8SJason M. Bills const nlohmann::json& message, 871abe55efSEd Tanous const std::string& fieldPath) 881abe55efSEd Tanous { 89a08b46ccSJason M. Bills std::string extendedInfo(fieldPath + messages::messageAnnotation); 90f4c4dcf4SKowalski, Kamil 911abe55efSEd Tanous if (!target[extendedInfo].is_array()) 921abe55efSEd Tanous { 93f4c4dcf4SKowalski, Kamil // Force object to be an array 94f4c4dcf4SKowalski, Kamil target[extendedInfo] = nlohmann::json::array(); 95f4c4dcf4SKowalski, Kamil } 96f4c4dcf4SKowalski, Kamil 97f4c4dcf4SKowalski, Kamil // Object exists and it is an array so we can just push in the message 98f4c4dcf4SKowalski, Kamil target[extendedInfo].push_back(message); 99f4c4dcf4SKowalski, Kamil } 100f4c4dcf4SKowalski, Kamil 101f4c4dcf4SKowalski, Kamil /** 102f4c4dcf4SKowalski, Kamil * @internal 103f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInUse message into JSON 104f4c4dcf4SKowalski, Kamil * 105f4c4dcf4SKowalski, Kamil * See header file for more information 106f4c4dcf4SKowalski, Kamil * @endinternal 107f4c4dcf4SKowalski, Kamil */ 108b5c07418SJames Feist nlohmann::json resourceInUse(void) 1091abe55efSEd Tanous { 110b5c07418SJames Feist return nlohmann::json{ 111b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 112cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceInUse"}, 11366ac2b8cSJason M. Bills {"Message", "The change to the requested resource failed because " 11466ac2b8cSJason M. Bills "the resource is in use or in transition."}, 11585659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 116f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 11766ac2b8cSJason M. Bills {"Resolution", "Remove the condition and resubmit the request if " 118b5c07418SJames Feist "the operation failed."}}; 119b5c07418SJames Feist } 120b5c07418SJames Feist 121b5c07418SJames Feist void resourceInUse(crow::Response& res) 122b5c07418SJames Feist { 123b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 124b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInUse()); 125f4c4dcf4SKowalski, Kamil } 126f4c4dcf4SKowalski, Kamil 127f4c4dcf4SKowalski, Kamil /** 128f4c4dcf4SKowalski, Kamil * @internal 129f4c4dcf4SKowalski, Kamil * @brief Formats MalformedJSON message into JSON 130f4c4dcf4SKowalski, Kamil * 131f4c4dcf4SKowalski, Kamil * See header file for more information 132f4c4dcf4SKowalski, Kamil * @endinternal 133f4c4dcf4SKowalski, Kamil */ 134b5c07418SJames Feist nlohmann::json malformedJSON(void) 1351abe55efSEd Tanous { 136b5c07418SJames Feist return nlohmann::json{ 137b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 138cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.MalformedJSON"}, 13966ac2b8cSJason M. Bills {"Message", "The request body submitted was malformed JSON and " 14066ac2b8cSJason M. Bills "could not be parsed by the receiving service."}, 14185659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 142f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1431abe55efSEd Tanous {"Resolution", "Ensure that the request body is valid JSON and " 144b5c07418SJames Feist "resubmit the request."}}; 145b5c07418SJames Feist } 146b5c07418SJames Feist 147b5c07418SJames Feist void malformedJSON(crow::Response& res) 148b5c07418SJames Feist { 149b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 150b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, malformedJSON()); 151f4c4dcf4SKowalski, Kamil } 152f4c4dcf4SKowalski, Kamil 153f4c4dcf4SKowalski, Kamil /** 154f4c4dcf4SKowalski, Kamil * @internal 155f4c4dcf4SKowalski, Kamil * @brief Formats ResourceMissingAtURI message into JSON 156f4c4dcf4SKowalski, Kamil * 157f4c4dcf4SKowalski, Kamil * See header file for more information 158f4c4dcf4SKowalski, Kamil * @endinternal 159f4c4dcf4SKowalski, Kamil */ 160b5c07418SJames Feist nlohmann::json resourceMissingAtURI(const std::string& arg1) 1611abe55efSEd Tanous { 162b5c07418SJames Feist return nlohmann::json{ 163b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 164cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceMissingAtURI"}, 165f4c4dcf4SKowalski, Kamil {"Message", "The resource at the URI " + arg1 + " was not found."}, 16685659adfSJason M. Bills {"MessageArgs", {arg1}}, 167f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 16866ac2b8cSJason M. Bills {"Resolution", "Place a valid resource at the URI or correct the " 169b5c07418SJames Feist "URI and resubmit the request."}}; 170b5c07418SJames Feist } 171b5c07418SJames Feist 172b5c07418SJames Feist void resourceMissingAtURI(crow::Response& res, const std::string& arg1) 173b5c07418SJames Feist { 174b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 175b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceMissingAtURI(arg1)); 176f4c4dcf4SKowalski, Kamil } 177f4c4dcf4SKowalski, Kamil 178f4c4dcf4SKowalski, Kamil /** 179f4c4dcf4SKowalski, Kamil * @internal 180f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueFormatError message into JSON 181f4c4dcf4SKowalski, Kamil * 182f4c4dcf4SKowalski, Kamil * See header file for more information 183f4c4dcf4SKowalski, Kamil * @endinternal 184f4c4dcf4SKowalski, Kamil */ 185b5c07418SJames Feist nlohmann::json actionParameterValueFormatError(const std::string& arg1, 186f4c4dcf4SKowalski, Kamil const std::string& arg2, 1871abe55efSEd Tanous const std::string& arg3) 1881abe55efSEd Tanous { 189b5c07418SJames Feist return nlohmann::json{ 190b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 191cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionParameterValueFormatError"}, 192f4c4dcf4SKowalski, Kamil {"Message", 1931abe55efSEd Tanous "The value " + arg1 + " for the parameter " + arg2 + 1941abe55efSEd Tanous " in the action " + arg3 + 1951abe55efSEd Tanous " is of a different format than the parameter can accept."}, 19685659adfSJason M. Bills {"MessageArgs", {arg1, arg2, arg3}}, 197f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 19866ac2b8cSJason M. Bills {"Resolution", 19966ac2b8cSJason M. Bills "Correct the value for the parameter in the request body and " 200b5c07418SJames Feist "resubmit the request if the operation failed."}}; 201b5c07418SJames Feist } 202b5c07418SJames Feist 203b5c07418SJames Feist void actionParameterValueFormatError(crow::Response& res, 204b5c07418SJames Feist const std::string& arg1, 205b5c07418SJames Feist const std::string& arg2, 206b5c07418SJames Feist const std::string& arg3) 207b5c07418SJames Feist { 208b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 209b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 210b5c07418SJames Feist actionParameterValueFormatError(arg1, arg2, arg3)); 211f4c4dcf4SKowalski, Kamil } 212f4c4dcf4SKowalski, Kamil 213f4c4dcf4SKowalski, Kamil /** 214f4c4dcf4SKowalski, Kamil * @internal 215f4c4dcf4SKowalski, Kamil * @brief Formats InternalError message into JSON 216f4c4dcf4SKowalski, Kamil * 217f4c4dcf4SKowalski, Kamil * See header file for more information 218f4c4dcf4SKowalski, Kamil * @endinternal 219f4c4dcf4SKowalski, Kamil */ 220b5c07418SJames Feist nlohmann::json internalError(void) 2211abe55efSEd Tanous { 222b5c07418SJames Feist return nlohmann::json{ 223b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 224cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.InternalError"}, 225f12894f8SJason M. Bills {"Message", "The request failed due to an internal service error. " 22666ac2b8cSJason M. Bills "The service is still operational."}, 22785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 228f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 2291abe55efSEd Tanous {"Resolution", "Resubmit the request. If the problem persists, " 230b5c07418SJames Feist "consider resetting the service."}}; 231b5c07418SJames Feist } 232b5c07418SJames Feist 233b5c07418SJames Feist void internalError(crow::Response& res) 234b5c07418SJames Feist { 235b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 236b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, internalError()); 237f12894f8SJason M. Bills } 238f12894f8SJason M. Bills 239f12894f8SJason M. Bills /** 240f12894f8SJason M. Bills * @internal 241f4c4dcf4SKowalski, Kamil * @brief Formats UnrecognizedRequestBody message into JSON 242f4c4dcf4SKowalski, Kamil * 243f4c4dcf4SKowalski, Kamil * See header file for more information 244f4c4dcf4SKowalski, Kamil * @endinternal 245f4c4dcf4SKowalski, Kamil */ 246b5c07418SJames Feist nlohmann::json unrecognizedRequestBody(void) 2471abe55efSEd Tanous { 248b5c07418SJames Feist return nlohmann::json{ 249b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 250cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.UnrecognizedRequestBody"}, 251f12894f8SJason M. Bills {"Message", "The service detected a malformed request body that it " 25266ac2b8cSJason M. Bills "was unable to interpret."}, 25385659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 254f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 255f12894f8SJason M. Bills {"Resolution", "Correct the request body and resubmit the request " 256b5c07418SJames Feist "if it failed."}}; 257b5c07418SJames Feist } 258b5c07418SJames Feist 259b5c07418SJames Feist void unrecognizedRequestBody(crow::Response& res) 260b5c07418SJames Feist { 261b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 262b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, unrecognizedRequestBody()); 263f4c4dcf4SKowalski, Kamil } 264f4c4dcf4SKowalski, Kamil 265f4c4dcf4SKowalski, Kamil /** 266f4c4dcf4SKowalski, Kamil * @internal 267f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriUnauthorized message into JSON 268f4c4dcf4SKowalski, Kamil * 269f4c4dcf4SKowalski, Kamil * See header file for more information 270f4c4dcf4SKowalski, Kamil * @endinternal 271f4c4dcf4SKowalski, Kamil */ 272b5c07418SJames Feist nlohmann::json resourceAtUriUnauthorized(const std::string& arg1, 2731abe55efSEd Tanous const std::string& arg2) 2741abe55efSEd Tanous { 275b5c07418SJames Feist return nlohmann::json{ 276b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 277cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceAtUriUnauthorized"}, 278f4c4dcf4SKowalski, Kamil {"Message", "While accessing the resource at " + arg1 + 2791abe55efSEd Tanous ", the service received an authorization error " + 2801abe55efSEd Tanous arg2 + "."}, 28185659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 282f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 283f12894f8SJason M. Bills {"Resolution", "Ensure that the appropriate access is provided for " 284b5c07418SJames Feist "the service in order for it to access the URI."}}; 285b5c07418SJames Feist } 286b5c07418SJames Feist 287b5c07418SJames Feist void resourceAtUriUnauthorized(crow::Response& res, const std::string& arg1, 288b5c07418SJames Feist const std::string& arg2) 289b5c07418SJames Feist { 290b5c07418SJames Feist res.result(boost::beast::http::status::unauthorized); 291b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriUnauthorized(arg1, arg2)); 292f4c4dcf4SKowalski, Kamil } 293f4c4dcf4SKowalski, Kamil 294f4c4dcf4SKowalski, Kamil /** 295f4c4dcf4SKowalski, Kamil * @internal 296f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterUnknown message into JSON 297f4c4dcf4SKowalski, Kamil * 298f4c4dcf4SKowalski, Kamil * See header file for more information 299f4c4dcf4SKowalski, Kamil * @endinternal 300f4c4dcf4SKowalski, Kamil */ 301b5c07418SJames Feist nlohmann::json actionParameterUnknown(const std::string& arg1, 302b5c07418SJames Feist const std::string& arg2) 303b5c07418SJames Feist { 304b5c07418SJames Feist return nlohmann::json{ 305b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 306b5c07418SJames Feist {"MessageId", "Base.1.4.0.ActionParameterUnknown"}, 307b5c07418SJames Feist {"Message", "The action " + arg1 + 308b5c07418SJames Feist " was submitted with the invalid parameter " + arg2 + 309b5c07418SJames Feist "."}, 310b5c07418SJames Feist {"MessageArgs", {arg1, arg2}}, 311b5c07418SJames Feist {"Severity", "Warning"}, 312b5c07418SJames Feist {"Resolution", "Correct the invalid parameter and resubmit the " 313b5c07418SJames Feist "request if the operation failed."}}; 314b5c07418SJames Feist } 315b5c07418SJames Feist 316f12894f8SJason M. Bills void actionParameterUnknown(crow::Response& res, const std::string& arg1, 3171abe55efSEd Tanous const std::string& arg2) 3181abe55efSEd Tanous { 319f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 320b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterUnknown(arg1, arg2)); 321f4c4dcf4SKowalski, Kamil } 322f4c4dcf4SKowalski, Kamil 323f4c4dcf4SKowalski, Kamil /** 324f4c4dcf4SKowalski, Kamil * @internal 325f4c4dcf4SKowalski, Kamil * @brief Formats ResourceCannotBeDeleted message into JSON 326f4c4dcf4SKowalski, Kamil * 327f4c4dcf4SKowalski, Kamil * See header file for more information 328f4c4dcf4SKowalski, Kamil * @endinternal 329f4c4dcf4SKowalski, Kamil */ 330b5c07418SJames Feist nlohmann::json resourceCannotBeDeleted(void) 3311abe55efSEd Tanous { 332b5c07418SJames Feist return nlohmann::json{ 333b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 334cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceCannotBeDeleted"}, 335f12894f8SJason M. Bills {"Message", "The delete request failed because the resource " 33666ac2b8cSJason M. Bills "requested cannot be deleted."}, 33785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 338f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 339b5c07418SJames Feist {"Resolution", "Do not attempt to delete a non-deletable resource."}}; 340b5c07418SJames Feist } 341b5c07418SJames Feist 342b5c07418SJames Feist void resourceCannotBeDeleted(crow::Response& res) 343b5c07418SJames Feist { 344b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 345b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceCannotBeDeleted()); 346f4c4dcf4SKowalski, Kamil } 347f4c4dcf4SKowalski, Kamil 348f4c4dcf4SKowalski, Kamil /** 349f4c4dcf4SKowalski, Kamil * @internal 350f4c4dcf4SKowalski, Kamil * @brief Formats PropertyDuplicate message into JSON 351f4c4dcf4SKowalski, Kamil * 352f4c4dcf4SKowalski, Kamil * See header file for more information 353f4c4dcf4SKowalski, Kamil * @endinternal 354f4c4dcf4SKowalski, Kamil */ 355b5c07418SJames Feist nlohmann::json propertyDuplicate(const std::string& arg1) 3561abe55efSEd Tanous { 357b5c07418SJames Feist return nlohmann::json{ 358b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 359cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyDuplicate"}, 360b5c07418SJames Feist {"Message", "The property " + arg1 + " was duplicated in the request."}, 36185659adfSJason M. Bills {"MessageArgs", {arg1}}, 362f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 36366ac2b8cSJason M. Bills {"Resolution", 36466ac2b8cSJason M. Bills "Remove the duplicate property from the request body and resubmit " 365b5c07418SJames Feist "the request if the operation failed."}}; 366b5c07418SJames Feist } 367b5c07418SJames Feist 368b5c07418SJames Feist void propertyDuplicate(crow::Response& res, const std::string& arg1) 369b5c07418SJames Feist { 370b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 371b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyDuplicate(arg1), arg1); 372f4c4dcf4SKowalski, Kamil } 373f4c4dcf4SKowalski, Kamil 374f4c4dcf4SKowalski, Kamil /** 375f4c4dcf4SKowalski, Kamil * @internal 376f4c4dcf4SKowalski, Kamil * @brief Formats ServiceTemporarilyUnavailable message into JSON 377f4c4dcf4SKowalski, Kamil * 378f4c4dcf4SKowalski, Kamil * See header file for more information 379f4c4dcf4SKowalski, Kamil * @endinternal 380f4c4dcf4SKowalski, Kamil */ 381b5c07418SJames Feist nlohmann::json serviceTemporarilyUnavailable(const std::string& arg1) 3821abe55efSEd Tanous { 383b5c07418SJames Feist return nlohmann::json{ 384b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 385cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ServiceTemporarilyUnavailable"}, 3861abe55efSEd Tanous {"Message", "The service is temporarily unavailable. Retry in " + 3871abe55efSEd Tanous arg1 + " seconds."}, 38885659adfSJason M. Bills {"MessageArgs", {arg1}}, 389f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 390f12894f8SJason M. Bills {"Resolution", "Wait for the indicated retry duration and retry " 391b5c07418SJames Feist "the operation."}}; 392b5c07418SJames Feist } 393b5c07418SJames Feist 394b5c07418SJames Feist void serviceTemporarilyUnavailable(crow::Response& res, const std::string& arg1) 395b5c07418SJames Feist { 396b5c07418SJames Feist res.addHeader("Retry-After", arg1); 397b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 398b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceTemporarilyUnavailable(arg1)); 399f4c4dcf4SKowalski, Kamil } 400f4c4dcf4SKowalski, Kamil 401f4c4dcf4SKowalski, Kamil /** 402f4c4dcf4SKowalski, Kamil * @internal 403f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAlreadyExists message into JSON 404f4c4dcf4SKowalski, Kamil * 405f4c4dcf4SKowalski, Kamil * See header file for more information 406f4c4dcf4SKowalski, Kamil * @endinternal 407f4c4dcf4SKowalski, Kamil */ 408b5c07418SJames Feist nlohmann::json resourceAlreadyExists(const std::string& arg1, 409b5c07418SJames Feist const std::string& arg2, 410b5c07418SJames Feist const std::string& arg3) 4111abe55efSEd Tanous { 412b5c07418SJames Feist return nlohmann::json{ 413b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 414cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceAlreadyExists"}, 415f4c4dcf4SKowalski, Kamil {"Message", "The requested resource of type " + arg1 + 4161abe55efSEd Tanous " with the property " + arg2 + " with the value " + 4171abe55efSEd Tanous arg3 + " already exists."}, 41885659adfSJason M. Bills {"MessageArgs", {arg1, arg2, arg3}}, 419f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 420f12894f8SJason M. Bills {"Resolution", "Do not repeat the create operation as the resource " 421b5c07418SJames Feist "has already been created."}}; 422b5c07418SJames Feist } 423b5c07418SJames Feist 424b5c07418SJames Feist void resourceAlreadyExists(crow::Response& res, const std::string& arg1, 425b5c07418SJames Feist const std::string& arg2, const std::string& arg3) 426b5c07418SJames Feist { 427b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 428b5c07418SJames Feist addMessageToJson(res.jsonValue, resourceAlreadyExists(arg1, arg2, arg3), 429a08b46ccSJason M. Bills arg2); 430f4c4dcf4SKowalski, Kamil } 431f4c4dcf4SKowalski, Kamil 432f4c4dcf4SKowalski, Kamil /** 433f4c4dcf4SKowalski, Kamil * @internal 434f4c4dcf4SKowalski, Kamil * @brief Formats AccountForSessionNoLongerExists message into JSON 435f4c4dcf4SKowalski, Kamil * 436f4c4dcf4SKowalski, Kamil * See header file for more information 437f4c4dcf4SKowalski, Kamil * @endinternal 438f4c4dcf4SKowalski, Kamil */ 439b5c07418SJames Feist nlohmann::json accountForSessionNoLongerExists(void) 4401abe55efSEd Tanous { 441b5c07418SJames Feist return nlohmann::json{ 442b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 443cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.AccountForSessionNoLongerExists"}, 4441abe55efSEd Tanous {"Message", "The account for the current session has been removed, " 44566ac2b8cSJason M. Bills "thus the current session has been removed as well."}, 44685659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 447f4c4dcf4SKowalski, Kamil {"Severity", "OK"}, 448b5c07418SJames Feist {"Resolution", "Attempt to connect with a valid account."}}; 449b5c07418SJames Feist } 450b5c07418SJames Feist 451b5c07418SJames Feist void accountForSessionNoLongerExists(crow::Response& res) 452b5c07418SJames Feist { 453b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 454b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountForSessionNoLongerExists()); 455f4c4dcf4SKowalski, Kamil } 456f4c4dcf4SKowalski, Kamil 457f4c4dcf4SKowalski, Kamil /** 458f4c4dcf4SKowalski, Kamil * @internal 459f4c4dcf4SKowalski, Kamil * @brief Formats CreateFailedMissingReqProperties message into JSON 460f4c4dcf4SKowalski, Kamil * 461f4c4dcf4SKowalski, Kamil * See header file for more information 462f4c4dcf4SKowalski, Kamil * @endinternal 463f4c4dcf4SKowalski, Kamil */ 464b5c07418SJames Feist nlohmann::json createFailedMissingReqProperties(const std::string& arg1) 4651abe55efSEd Tanous { 466b5c07418SJames Feist return nlohmann::json{ 467b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 468cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.CreateFailedMissingReqProperties"}, 4691abe55efSEd Tanous {"Message", 470b5c07418SJames Feist "The create operation failed because the required property " + arg1 + 471b5c07418SJames Feist " was missing from the request."}, 47285659adfSJason M. Bills {"MessageArgs", {arg1}}, 473f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 474f4c4dcf4SKowalski, Kamil {"Resolution", 475f12894f8SJason M. Bills "Correct the body to include the required property with a valid " 476b5c07418SJames Feist "value and resubmit the request if the operation failed."}}; 477b5c07418SJames Feist } 478b5c07418SJames Feist 479b5c07418SJames Feist void createFailedMissingReqProperties(crow::Response& res, 480b5c07418SJames Feist const std::string& arg1) 481b5c07418SJames Feist { 482b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 483b5c07418SJames Feist addMessageToJson(res.jsonValue, createFailedMissingReqProperties(arg1), 484a08b46ccSJason M. Bills arg1); 485f12894f8SJason M. Bills } 486f12894f8SJason M. Bills 487f12894f8SJason M. Bills /** 488f12894f8SJason M. Bills * @internal 489f12894f8SJason M. Bills * @brief Formats PropertyValueFormatError message into JSON for the specified 490f12894f8SJason M. Bills * property 491f12894f8SJason M. Bills * 492f12894f8SJason M. Bills * See header file for more information 493f12894f8SJason M. Bills * @endinternal 494f12894f8SJason M. Bills */ 495b5c07418SJames Feist nlohmann::json propertyValueFormatError(const std::string& arg1, 496a08b46ccSJason M. Bills const std::string& arg2) 497f12894f8SJason M. Bills { 498b5c07418SJames Feist return nlohmann::json{ 499b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 500cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyValueFormatError"}, 501f12894f8SJason M. Bills {"Message", 502f12894f8SJason M. Bills "The value " + arg1 + " for the property " + arg2 + 503f12894f8SJason M. Bills " is of a different format than the property can accept."}, 50485659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 505f12894f8SJason M. Bills {"Severity", "Warning"}, 50666ac2b8cSJason M. Bills {"Resolution", 50766ac2b8cSJason M. Bills "Correct the value for the property in the request body and " 508b5c07418SJames Feist "resubmit the request if the operation failed."}}; 509b5c07418SJames Feist } 510b5c07418SJames Feist 511b5c07418SJames Feist void propertyValueFormatError(crow::Response& res, const std::string& arg1, 512b5c07418SJames Feist const std::string& arg2) 513b5c07418SJames Feist { 514b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 515b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueFormatError(arg1, arg2), arg2); 516f12894f8SJason M. Bills } 517f12894f8SJason M. Bills 518f12894f8SJason M. Bills /** 519f12894f8SJason M. Bills * @internal 520f12894f8SJason M. Bills * @brief Formats PropertyValueNotInList message into JSON for the specified 521f12894f8SJason M. Bills * property 522f12894f8SJason M. Bills * 523f12894f8SJason M. Bills * See header file for more information 524f12894f8SJason M. Bills * @endinternal 525f12894f8SJason M. Bills */ 526b5c07418SJames Feist nlohmann::json propertyValueNotInList(const std::string& arg1, 527a08b46ccSJason M. Bills const std::string& arg2) 528f12894f8SJason M. Bills { 529b5c07418SJames Feist return nlohmann::json{ 530b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 531cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyValueNotInList"}, 532f12894f8SJason M. Bills {"Message", "The value " + arg1 + " for the property " + arg2 + 533f12894f8SJason M. Bills " is not in the list of acceptable values."}, 53485659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 535f12894f8SJason M. Bills {"Severity", "Warning"}, 536b5c07418SJames Feist {"Resolution", "Choose a value from the enumeration list that " 537b5c07418SJames Feist "the implementation " 538b5c07418SJames Feist "can support and resubmit the request if the " 539b5c07418SJames Feist "operation failed."}}; 540b5c07418SJames Feist } 541b5c07418SJames Feist 542b5c07418SJames Feist void propertyValueNotInList(crow::Response& res, const std::string& arg1, 543b5c07418SJames Feist const std::string& arg2) 544b5c07418SJames Feist { 545b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 546b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueNotInList(arg1, arg2), arg2); 547f4c4dcf4SKowalski, Kamil } 548f4c4dcf4SKowalski, Kamil 549f4c4dcf4SKowalski, Kamil /** 550f4c4dcf4SKowalski, Kamil * @internal 551f4c4dcf4SKowalski, Kamil * @brief Formats ResourceAtUriInUnknownFormat message into JSON 552f4c4dcf4SKowalski, Kamil * 553f4c4dcf4SKowalski, Kamil * See header file for more information 554f4c4dcf4SKowalski, Kamil * @endinternal 555f4c4dcf4SKowalski, Kamil */ 556b5c07418SJames Feist nlohmann::json resourceAtUriInUnknownFormat(const std::string& arg1) 5571abe55efSEd Tanous { 558b5c07418SJames Feist return nlohmann::json{ 559b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 560cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceAtUriInUnknownFormat"}, 561f4c4dcf4SKowalski, Kamil {"Message", "The resource at " + arg1 + 562f4c4dcf4SKowalski, Kamil " is in a format not recognized by the service."}, 56385659adfSJason M. Bills {"MessageArgs", {arg1}}, 564f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 565f12894f8SJason M. Bills {"Resolution", "Place an image or resource or file that is " 566b5c07418SJames Feist "recognized by the service at the URI."}}; 567b5c07418SJames Feist } 568b5c07418SJames Feist 569b5c07418SJames Feist void resourceAtUriInUnknownFormat(crow::Response& res, const std::string& arg1) 570b5c07418SJames Feist { 571b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 572b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceAtUriInUnknownFormat(arg1)); 573f4c4dcf4SKowalski, Kamil } 574f4c4dcf4SKowalski, Kamil 575f4c4dcf4SKowalski, Kamil /** 576f4c4dcf4SKowalski, Kamil * @internal 577f4c4dcf4SKowalski, Kamil * @brief Formats ServiceInUnknownState message into JSON 578f4c4dcf4SKowalski, Kamil * 579f4c4dcf4SKowalski, Kamil * See header file for more information 580f4c4dcf4SKowalski, Kamil * @endinternal 581f4c4dcf4SKowalski, Kamil */ 582b5c07418SJames Feist nlohmann::json serviceInUnknownState(void) 5831abe55efSEd Tanous { 584b5c07418SJames Feist return nlohmann::json{ 585b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 586cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ServiceInUnknownState"}, 58766ac2b8cSJason M. Bills {"Message", 58866ac2b8cSJason M. Bills "The operation failed because the service is in an unknown state " 58966ac2b8cSJason M. Bills "and can no longer take incoming requests."}, 59085659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 591f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 59266ac2b8cSJason M. Bills {"Resolution", "Restart the service and resubmit the request if " 593b5c07418SJames Feist "the operation failed."}}; 594b5c07418SJames Feist } 595b5c07418SJames Feist 596b5c07418SJames Feist void serviceInUnknownState(crow::Response& res) 597b5c07418SJames Feist { 598b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 599b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceInUnknownState()); 600f4c4dcf4SKowalski, Kamil } 601f4c4dcf4SKowalski, Kamil 602f4c4dcf4SKowalski, Kamil /** 603f4c4dcf4SKowalski, Kamil * @internal 604f4c4dcf4SKowalski, Kamil * @brief Formats EventSubscriptionLimitExceeded message into JSON 605f4c4dcf4SKowalski, Kamil * 606f4c4dcf4SKowalski, Kamil * See header file for more information 607f4c4dcf4SKowalski, Kamil * @endinternal 608f4c4dcf4SKowalski, Kamil */ 609b5c07418SJames Feist nlohmann::json eventSubscriptionLimitExceeded(void) 6101abe55efSEd Tanous { 611b5c07418SJames Feist return nlohmann::json{ 612b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 613cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.EventSubscriptionLimitExceeded"}, 614f4c4dcf4SKowalski, Kamil {"Message", 615f4c4dcf4SKowalski, Kamil "The event subscription failed due to the number of simultaneous " 616f4c4dcf4SKowalski, Kamil "subscriptions exceeding the limit of the implementation."}, 61785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 618f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 619f4c4dcf4SKowalski, Kamil {"Resolution", 620f12894f8SJason M. Bills "Reduce the number of other subscriptions before trying to " 62166ac2b8cSJason M. Bills "establish the event subscription or increase the limit of " 622b5c07418SJames Feist "simultaneous subscriptions (if supported)."}}; 623b5c07418SJames Feist } 624b5c07418SJames Feist 625b5c07418SJames Feist void eventSubscriptionLimitExceeded(crow::Response& res) 626b5c07418SJames Feist { 627b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 628b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, eventSubscriptionLimitExceeded()); 629f4c4dcf4SKowalski, Kamil } 630f4c4dcf4SKowalski, Kamil 631f4c4dcf4SKowalski, Kamil /** 632f4c4dcf4SKowalski, Kamil * @internal 633f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterMissing message into JSON 634f4c4dcf4SKowalski, Kamil * 635f4c4dcf4SKowalski, Kamil * See header file for more information 636f4c4dcf4SKowalski, Kamil * @endinternal 637f4c4dcf4SKowalski, Kamil */ 638b5c07418SJames Feist nlohmann::json actionParameterMissing(const std::string& arg1, 6391abe55efSEd Tanous const std::string& arg2) 6401abe55efSEd Tanous { 641b5c07418SJames Feist return nlohmann::json{ 642b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 643cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionParameterMissing"}, 644b5c07418SJames Feist {"Message", "The action " + arg1 + " requires the parameter " + arg2 + 645b5c07418SJames Feist " to be present in the request body."}, 64685659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 647f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 648f12894f8SJason M. Bills {"Resolution", 64966ac2b8cSJason M. Bills "Supply the action with the required parameter in the request " 650b5c07418SJames Feist "body when the request is resubmitted."}}; 651b5c07418SJames Feist } 652b5c07418SJames Feist 653b5c07418SJames Feist void actionParameterMissing(crow::Response& res, const std::string& arg1, 654b5c07418SJames Feist const std::string& arg2) 655b5c07418SJames Feist { 656b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 657b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterMissing(arg1, arg2)); 658f4c4dcf4SKowalski, Kamil } 659f4c4dcf4SKowalski, Kamil 660f4c4dcf4SKowalski, Kamil /** 661f4c4dcf4SKowalski, Kamil * @internal 662f4c4dcf4SKowalski, Kamil * @brief Formats StringValueTooLong message into JSON 663f4c4dcf4SKowalski, Kamil * 664f4c4dcf4SKowalski, Kamil * See header file for more information 665f4c4dcf4SKowalski, Kamil * @endinternal 666f4c4dcf4SKowalski, Kamil */ 667b5c07418SJames Feist nlohmann::json stringValueTooLong(const std::string& arg1, const int& arg2) 6681abe55efSEd Tanous { 669b5c07418SJames Feist return nlohmann::json{ 670b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 671cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.StringValueTooLong"}, 672f4c4dcf4SKowalski, Kamil {"Message", "The string " + arg1 + " exceeds the length limit " + 673f4c4dcf4SKowalski, Kamil std::to_string(arg2) + "."}, 67485659adfSJason M. Bills {"MessageArgs", {arg1, std::to_string(arg2)}}, 675f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 676f4c4dcf4SKowalski, Kamil {"Resolution", 677b5c07418SJames Feist "Resubmit the request with an appropriate string length."}}; 678b5c07418SJames Feist } 679b5c07418SJames Feist 680b5c07418SJames Feist void stringValueTooLong(crow::Response& res, const std::string& arg1, 681b5c07418SJames Feist const int& arg2) 682b5c07418SJames Feist { 683b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 684b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, stringValueTooLong(arg1, arg2)); 685f4c4dcf4SKowalski, Kamil } 686f4c4dcf4SKowalski, Kamil 687f4c4dcf4SKowalski, Kamil /** 688f4c4dcf4SKowalski, Kamil * @internal 689cc9139ecSJason M. Bills * @brief Formats SessionTerminated message into JSON 690cc9139ecSJason M. Bills * 691cc9139ecSJason M. Bills * See header file for more information 692cc9139ecSJason M. Bills * @endinternal 693cc9139ecSJason M. Bills */ 694b5c07418SJames Feist nlohmann::json sessionTerminated(void) 695cc9139ecSJason M. Bills { 696b5c07418SJames Feist return nlohmann::json{ 697b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 698cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.SessionTerminated"}, 699cc9139ecSJason M. Bills {"Message", "The session was successfully terminated."}, 70085659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 701cc9139ecSJason M. Bills {"Severity", "OK"}, 702b5c07418SJames Feist {"Resolution", "No resolution is required."}}; 703b5c07418SJames Feist } 704b5c07418SJames Feist 705b5c07418SJames Feist void sessionTerminated(crow::Response& res) 706b5c07418SJames Feist { 707b5c07418SJames Feist res.result(boost::beast::http::status::ok); 708b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, sessionTerminated()); 709cc9139ecSJason M. Bills } 710cc9139ecSJason M. Bills 711cc9139ecSJason M. Bills /** 712cc9139ecSJason M. Bills * @internal 713cc9139ecSJason M. Bills * @brief Formats ResourceTypeIncompatible message into JSON 714cc9139ecSJason M. Bills * 715cc9139ecSJason M. Bills * See header file for more information 716cc9139ecSJason M. Bills * @endinternal 717cc9139ecSJason M. Bills */ 718b5c07418SJames Feist nlohmann::json resourceTypeIncompatible(const std::string& arg1, 719cc9139ecSJason M. Bills const std::string& arg2) 720cc9139ecSJason M. Bills { 721b5c07418SJames Feist return nlohmann::json{ 722b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 723cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceTypeIncompatible"}, 724cc9139ecSJason M. Bills {"Message", "The @odata.type of the request body " + arg1 + 725cc9139ecSJason M. Bills " is incompatible with the @odata.type of the " 726cc9139ecSJason M. Bills "resource which is " + 727cc9139ecSJason M. Bills arg2 + "."}, 72885659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 729cc9139ecSJason M. Bills {"Severity", "Critical"}, 730cc9139ecSJason M. Bills {"Resolution", "Resubmit the request with a payload compatible " 731b5c07418SJames Feist "with the resource's schema."}}; 732b5c07418SJames Feist } 733b5c07418SJames Feist 734b5c07418SJames Feist void resourceTypeIncompatible(crow::Response& res, const std::string& arg1, 735b5c07418SJames Feist const std::string& arg2) 736b5c07418SJames Feist { 737b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 738b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceTypeIncompatible(arg1, arg2)); 739cc9139ecSJason M. Bills } 740cc9139ecSJason M. Bills 741cc9139ecSJason M. Bills /** 742cc9139ecSJason M. Bills * @internal 743f12894f8SJason M. Bills * @brief Formats PropertyValueTypeError message into JSON for the specified 744f12894f8SJason M. Bills * property 745f12894f8SJason M. Bills * 746f12894f8SJason M. Bills * See header file for more information 747f12894f8SJason M. Bills * @endinternal 748f12894f8SJason M. Bills */ 749b5c07418SJames Feist nlohmann::json propertyValueTypeError(const std::string& arg1, 750a08b46ccSJason M. Bills const std::string& arg2) 751f12894f8SJason M. Bills { 752b5c07418SJames Feist return nlohmann::json{ 753b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 754cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyValueTypeError"}, 755f12894f8SJason M. Bills {"Message", 756f12894f8SJason M. Bills "The value " + arg1 + " for the property " + arg2 + 757f12894f8SJason M. Bills " is of a different type than the property can accept."}, 75885659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 759f12894f8SJason M. Bills {"Severity", "Warning"}, 76066ac2b8cSJason M. Bills {"Resolution", 76166ac2b8cSJason M. Bills "Correct the value for the property in the request body and " 762b5c07418SJames Feist "resubmit the request if the operation failed."}}; 763b5c07418SJames Feist } 764b5c07418SJames Feist 765b5c07418SJames Feist void propertyValueTypeError(crow::Response& res, const std::string& arg1, 766b5c07418SJames Feist const std::string& arg2) 767b5c07418SJames Feist { 768b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 769b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueTypeError(arg1, arg2), arg2); 770f4c4dcf4SKowalski, Kamil } 771f4c4dcf4SKowalski, Kamil 772f4c4dcf4SKowalski, Kamil /** 773f4c4dcf4SKowalski, Kamil * @internal 774f4c4dcf4SKowalski, Kamil * @brief Formats ResourceNotFound message into JSON 775f4c4dcf4SKowalski, Kamil * 776f4c4dcf4SKowalski, Kamil * See header file for more information 777f4c4dcf4SKowalski, Kamil * @endinternal 778f4c4dcf4SKowalski, Kamil */ 779b5c07418SJames Feist nlohmann::json resourceNotFound(const std::string& arg1, 7801abe55efSEd Tanous const std::string& arg2) 7811abe55efSEd Tanous { 782b5c07418SJames Feist return nlohmann::json{ 783b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 784cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceNotFound"}, 7851abe55efSEd Tanous {"Message", "The requested resource of type " + arg1 + " named " + 7861abe55efSEd Tanous arg2 + " was not found."}, 78785659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 788f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 789f4c4dcf4SKowalski, Kamil {"Resolution", 790b5c07418SJames Feist "Provide a valid resource identifier and resubmit the request."}}; 791b5c07418SJames Feist } 792b5c07418SJames Feist 793b5c07418SJames Feist void resourceNotFound(crow::Response& res, const std::string& arg1, 794b5c07418SJames Feist const std::string& arg2) 795b5c07418SJames Feist { 796b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 797b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceNotFound(arg1, arg2)); 798f4c4dcf4SKowalski, Kamil } 799f4c4dcf4SKowalski, Kamil 800f4c4dcf4SKowalski, Kamil /** 801f4c4dcf4SKowalski, Kamil * @internal 802f4c4dcf4SKowalski, Kamil * @brief Formats CouldNotEstablishConnection message into JSON 803f4c4dcf4SKowalski, Kamil * 804f4c4dcf4SKowalski, Kamil * See header file for more information 805f4c4dcf4SKowalski, Kamil * @endinternal 806f4c4dcf4SKowalski, Kamil */ 807b5c07418SJames Feist nlohmann::json couldNotEstablishConnection(const std::string& arg1) 8081abe55efSEd Tanous { 809b5c07418SJames Feist return nlohmann::json{ 810b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 811cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.CouldNotEstablishConnection"}, 8121abe55efSEd Tanous {"Message", 813b5c07418SJames Feist "The service failed to establish a Connection with the URI " + arg1 + 814b5c07418SJames Feist "."}, 81585659adfSJason M. Bills {"MessageArgs", {arg1}}, 816f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 81766ac2b8cSJason M. Bills {"Resolution", 81866ac2b8cSJason M. Bills "Ensure that the URI contains a valid and reachable node name, " 819b5c07418SJames Feist "protocol information and other URI components."}}; 820b5c07418SJames Feist } 821b5c07418SJames Feist 822b5c07418SJames Feist void couldNotEstablishConnection(crow::Response& res, const std::string& arg1) 823b5c07418SJames Feist { 824b5c07418SJames Feist res.result(boost::beast::http::status::not_found); 825b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, couldNotEstablishConnection(arg1)); 826f4c4dcf4SKowalski, Kamil } 827f4c4dcf4SKowalski, Kamil 828f4c4dcf4SKowalski, Kamil /** 829f4c4dcf4SKowalski, Kamil * @internal 830f12894f8SJason M. Bills * @brief Formats PropertyNotWritable message into JSON for the specified 831f12894f8SJason M. Bills * property 832f12894f8SJason M. Bills * 833f12894f8SJason M. Bills * See header file for more information 834f12894f8SJason M. Bills * @endinternal 835f12894f8SJason M. Bills */ 836b5c07418SJames Feist nlohmann::json propertyNotWritable(const std::string& arg1) 837f12894f8SJason M. Bills { 838b5c07418SJames Feist return nlohmann::json{ 839b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 840cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyNotWritable"}, 841b5c07418SJames Feist {"Message", "The property " + arg1 + 842b5c07418SJames Feist " is a read only property and cannot be " 843b5c07418SJames Feist "assigned a value."}, 84485659adfSJason M. Bills {"MessageArgs", {arg1}}, 845f12894f8SJason M. Bills {"Severity", "Warning"}, 84666ac2b8cSJason M. Bills {"Resolution", "Remove the property from the request body and " 847b5c07418SJames Feist "resubmit the request if the operation failed."}}; 848b5c07418SJames Feist } 849b5c07418SJames Feist 850b5c07418SJames Feist void propertyNotWritable(crow::Response& res, const std::string& arg1) 851b5c07418SJames Feist { 852b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 853b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyNotWritable(arg1), arg1); 854f4c4dcf4SKowalski, Kamil } 855f4c4dcf4SKowalski, Kamil 856f4c4dcf4SKowalski, Kamil /** 857f4c4dcf4SKowalski, Kamil * @internal 858f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueTypeError message into JSON 859f4c4dcf4SKowalski, Kamil * 860f4c4dcf4SKowalski, Kamil * See header file for more information 861f4c4dcf4SKowalski, Kamil * @endinternal 862f4c4dcf4SKowalski, Kamil */ 863b5c07418SJames Feist nlohmann::json queryParameterValueTypeError(const std::string& arg1, 8641abe55efSEd Tanous const std::string& arg2) 8651abe55efSEd Tanous { 866b5c07418SJames Feist return nlohmann::json{ 867b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 868cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.QueryParameterValueTypeError"}, 8691abe55efSEd Tanous {"Message", 8701abe55efSEd Tanous "The value " + arg1 + " for the query parameter " + arg2 + 871f4c4dcf4SKowalski, Kamil " is of a different type than the parameter can accept."}, 87285659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 873f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 87466ac2b8cSJason M. Bills {"Resolution", 87566ac2b8cSJason M. Bills "Correct the value for the query parameter in the request and " 876b5c07418SJames Feist "resubmit the request if the operation failed."}}; 877b5c07418SJames Feist } 878b5c07418SJames Feist 879b5c07418SJames Feist void queryParameterValueTypeError(crow::Response& res, const std::string& arg1, 880b5c07418SJames Feist const std::string& arg2) 881b5c07418SJames Feist { 882b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 883b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 884b5c07418SJames Feist queryParameterValueTypeError(arg1, arg2)); 885f4c4dcf4SKowalski, Kamil } 886f4c4dcf4SKowalski, Kamil 887f4c4dcf4SKowalski, Kamil /** 888f4c4dcf4SKowalski, Kamil * @internal 889f4c4dcf4SKowalski, Kamil * @brief Formats ServiceShuttingDown message into JSON 890f4c4dcf4SKowalski, Kamil * 891f4c4dcf4SKowalski, Kamil * See header file for more information 892f4c4dcf4SKowalski, Kamil * @endinternal 893f4c4dcf4SKowalski, Kamil */ 894b5c07418SJames Feist nlohmann::json serviceShuttingDown(void) 8951abe55efSEd Tanous { 896b5c07418SJames Feist return nlohmann::json{ 897b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 898cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ServiceShuttingDown"}, 899f12894f8SJason M. Bills {"Message", "The operation failed because the service is shutting " 90066ac2b8cSJason M. Bills "down and can no longer take incoming requests."}, 90185659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 902f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 90366ac2b8cSJason M. Bills {"Resolution", "When the service becomes available, resubmit the " 904b5c07418SJames Feist "request if the operation failed."}}; 905b5c07418SJames Feist } 906b5c07418SJames Feist 907b5c07418SJames Feist void serviceShuttingDown(crow::Response& res) 908b5c07418SJames Feist { 909b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 910b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, serviceShuttingDown()); 911f4c4dcf4SKowalski, Kamil } 912f4c4dcf4SKowalski, Kamil 913f4c4dcf4SKowalski, Kamil /** 914f4c4dcf4SKowalski, Kamil * @internal 915f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterDuplicate message into JSON 916f4c4dcf4SKowalski, Kamil * 917f4c4dcf4SKowalski, Kamil * See header file for more information 918f4c4dcf4SKowalski, Kamil * @endinternal 919f4c4dcf4SKowalski, Kamil */ 920b5c07418SJames Feist nlohmann::json actionParameterDuplicate(const std::string& arg1, 9211abe55efSEd Tanous const std::string& arg2) 9221abe55efSEd Tanous { 923b5c07418SJames Feist return nlohmann::json{ 924b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 925cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionParameterDuplicate"}, 926f4c4dcf4SKowalski, Kamil {"Message", 927f4c4dcf4SKowalski, Kamil "The action " + arg1 + 9281abe55efSEd Tanous " was submitted with more than one value for the parameter " + 9291abe55efSEd Tanous arg2 + "."}, 93085659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 931f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 93266ac2b8cSJason M. Bills {"Resolution", 93366ac2b8cSJason M. Bills "Resubmit the action with only one instance of the parameter in " 934b5c07418SJames Feist "the request body if the operation failed."}}; 935b5c07418SJames Feist } 936b5c07418SJames Feist 937b5c07418SJames Feist void actionParameterDuplicate(crow::Response& res, const std::string& arg1, 938b5c07418SJames Feist const std::string& arg2) 939b5c07418SJames Feist { 940b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 941b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionParameterDuplicate(arg1, arg2)); 942f4c4dcf4SKowalski, Kamil } 943f4c4dcf4SKowalski, Kamil 944f4c4dcf4SKowalski, Kamil /** 945f4c4dcf4SKowalski, Kamil * @internal 946f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterNotSupported message into JSON 947f4c4dcf4SKowalski, Kamil * 948f4c4dcf4SKowalski, Kamil * See header file for more information 949f4c4dcf4SKowalski, Kamil * @endinternal 950f4c4dcf4SKowalski, Kamil */ 951b5c07418SJames Feist nlohmann::json actionParameterNotSupported(const std::string& arg1, 9521abe55efSEd Tanous const std::string& arg2) 9531abe55efSEd Tanous { 954b5c07418SJames Feist return nlohmann::json{ 955b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 956cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionParameterNotSupported"}, 957f4c4dcf4SKowalski, Kamil {"Message", "The parameter " + arg1 + " for the action " + arg2 + 958f4c4dcf4SKowalski, Kamil " is not supported on the target resource."}, 95985659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 960f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 96166ac2b8cSJason M. Bills {"Resolution", "Remove the parameter supplied and resubmit the " 962b5c07418SJames Feist "request if the operation failed."}}; 963b5c07418SJames Feist } 964b5c07418SJames Feist 965b5c07418SJames Feist void actionParameterNotSupported(crow::Response& res, const std::string& arg1, 966b5c07418SJames Feist const std::string& arg2) 967b5c07418SJames Feist { 968b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 969b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 970b5c07418SJames Feist actionParameterNotSupported(arg1, arg2)); 971f4c4dcf4SKowalski, Kamil } 972f4c4dcf4SKowalski, Kamil 973f4c4dcf4SKowalski, Kamil /** 974f4c4dcf4SKowalski, Kamil * @internal 975f4c4dcf4SKowalski, Kamil * @brief Formats SourceDoesNotSupportProtocol message into JSON 976f4c4dcf4SKowalski, Kamil * 977f4c4dcf4SKowalski, Kamil * See header file for more information 978f4c4dcf4SKowalski, Kamil * @endinternal 979f4c4dcf4SKowalski, Kamil */ 980b5c07418SJames Feist nlohmann::json sourceDoesNotSupportProtocol(const std::string& arg1, 9811abe55efSEd Tanous const std::string& arg2) 9821abe55efSEd Tanous { 983b5c07418SJames Feist return nlohmann::json{ 984b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 985cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.SourceDoesNotSupportProtocol"}, 98655c7b7a2SEd Tanous {"Message", "The other end of the Connection at " + arg1 + 9871abe55efSEd Tanous " does not support the specified protocol " + arg2 + 9881abe55efSEd Tanous "."}, 98985659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 990f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 991b5c07418SJames Feist {"Resolution", "Change protocols or URIs. "}}; 992b5c07418SJames Feist } 993b5c07418SJames Feist 994b5c07418SJames Feist void sourceDoesNotSupportProtocol(crow::Response& res, const std::string& arg1, 995b5c07418SJames Feist const std::string& arg2) 996b5c07418SJames Feist { 997b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 998b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 999b5c07418SJames Feist sourceDoesNotSupportProtocol(arg1, arg2)); 1000f4c4dcf4SKowalski, Kamil } 1001f4c4dcf4SKowalski, Kamil 1002f4c4dcf4SKowalski, Kamil /** 1003f4c4dcf4SKowalski, Kamil * @internal 1004f4c4dcf4SKowalski, Kamil * @brief Formats AccountRemoved message into JSON 1005f4c4dcf4SKowalski, Kamil * 1006f4c4dcf4SKowalski, Kamil * See header file for more information 1007f4c4dcf4SKowalski, Kamil * @endinternal 1008f4c4dcf4SKowalski, Kamil */ 1009b5c07418SJames Feist nlohmann::json accountRemoved(void) 10101abe55efSEd Tanous { 1011b7e069efSJames Feist return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, 1012cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.AccountRemoved"}, 1013f4c4dcf4SKowalski, Kamil {"Message", "The account was successfully removed."}, 101485659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1015f4c4dcf4SKowalski, Kamil {"Severity", "OK"}, 1016b5c07418SJames Feist {"Resolution", "No resolution is required."}}; 1017b5c07418SJames Feist } 1018b5c07418SJames Feist 1019b5c07418SJames Feist void accountRemoved(crow::Response& res) 1020b5c07418SJames Feist { 1021b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1022b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, accountRemoved()); 1023f4c4dcf4SKowalski, Kamil } 1024f4c4dcf4SKowalski, Kamil 1025f4c4dcf4SKowalski, Kamil /** 1026f4c4dcf4SKowalski, Kamil * @internal 1027f4c4dcf4SKowalski, Kamil * @brief Formats AccessDenied message into JSON 1028f4c4dcf4SKowalski, Kamil * 1029f4c4dcf4SKowalski, Kamil * See header file for more information 1030f4c4dcf4SKowalski, Kamil * @endinternal 1031f4c4dcf4SKowalski, Kamil */ 1032b5c07418SJames Feist nlohmann::json accessDenied(const std::string& arg1) 10331abe55efSEd Tanous { 1034b5c07418SJames Feist return nlohmann::json{ 1035b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1036cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.AccessDenied"}, 1037b5c07418SJames Feist {"Message", "While attempting to establish a Connection to " + arg1 + 1038b5c07418SJames Feist ", the service denied access."}, 103985659adfSJason M. Bills {"MessageArgs", {arg1}}, 1040f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 104166ac2b8cSJason M. Bills {"Resolution", "Attempt to ensure that the URI is correct and that " 1042b5c07418SJames Feist "the service has the appropriate credentials."}}; 1043b5c07418SJames Feist } 1044b5c07418SJames Feist 1045b5c07418SJames Feist void accessDenied(crow::Response& res, const std::string& arg1) 1046b5c07418SJames Feist { 1047b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1048b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accessDenied(arg1)); 1049f4c4dcf4SKowalski, Kamil } 1050f4c4dcf4SKowalski, Kamil 1051f4c4dcf4SKowalski, Kamil /** 1052f4c4dcf4SKowalski, Kamil * @internal 1053f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupported message into JSON 1054f4c4dcf4SKowalski, Kamil * 1055f4c4dcf4SKowalski, Kamil * See header file for more information 1056f4c4dcf4SKowalski, Kamil * @endinternal 1057f4c4dcf4SKowalski, Kamil */ 1058b5c07418SJames Feist nlohmann::json queryNotSupported(void) 10591abe55efSEd Tanous { 1060b5c07418SJames Feist return nlohmann::json{ 1061b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1062cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.QueryNotSupported"}, 1063f4c4dcf4SKowalski, Kamil {"Message", "Querying is not supported by the implementation."}, 106485659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1065f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 106666ac2b8cSJason M. Bills {"Resolution", "Remove the query parameters and resubmit the " 1067b5c07418SJames Feist "request if the operation failed."}}; 1068b5c07418SJames Feist } 1069b5c07418SJames Feist 1070b5c07418SJames Feist void queryNotSupported(crow::Response& res) 1071b5c07418SJames Feist { 1072b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1073b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupported()); 1074f4c4dcf4SKowalski, Kamil } 1075f4c4dcf4SKowalski, Kamil 1076f4c4dcf4SKowalski, Kamil /** 1077f4c4dcf4SKowalski, Kamil * @internal 1078f4c4dcf4SKowalski, Kamil * @brief Formats CreateLimitReachedForResource message into JSON 1079f4c4dcf4SKowalski, Kamil * 1080f4c4dcf4SKowalski, Kamil * See header file for more information 1081f4c4dcf4SKowalski, Kamil * @endinternal 1082f4c4dcf4SKowalski, Kamil */ 1083b5c07418SJames Feist nlohmann::json createLimitReachedForResource(void) 10841abe55efSEd Tanous { 1085b5c07418SJames Feist return nlohmann::json{ 1086b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1087cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.CreateLimitReachedForResource"}, 10881abe55efSEd Tanous {"Message", "The create operation failed because the resource has " 108966ac2b8cSJason M. Bills "reached the limit of possible resources."}, 109085659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1091f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 109266ac2b8cSJason M. Bills {"Resolution", 109366ac2b8cSJason M. Bills "Either delete resources and resubmit the request if the " 1094b5c07418SJames Feist "operation failed or do not resubmit the request."}}; 1095b5c07418SJames Feist } 1096b5c07418SJames Feist 1097b5c07418SJames Feist void createLimitReachedForResource(crow::Response& res) 1098b5c07418SJames Feist { 1099b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1100b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, createLimitReachedForResource()); 1101f4c4dcf4SKowalski, Kamil } 1102f4c4dcf4SKowalski, Kamil 1103f4c4dcf4SKowalski, Kamil /** 1104f4c4dcf4SKowalski, Kamil * @internal 1105f4c4dcf4SKowalski, Kamil * @brief Formats GeneralError message into JSON 1106f4c4dcf4SKowalski, Kamil * 1107f4c4dcf4SKowalski, Kamil * See header file for more information 1108f4c4dcf4SKowalski, Kamil * @endinternal 1109f4c4dcf4SKowalski, Kamil */ 1110b5c07418SJames Feist nlohmann::json generalError(void) 11111abe55efSEd Tanous { 1112b7e069efSJames Feist return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, 1113cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.GeneralError"}, 1114b7e069efSJames Feist {"Message", 1115b7e069efSJames Feist "A general error has occurred. See Resolution for " 1116cc9139ecSJason M. Bills "information on how to resolve the error."}, 111785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1118f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1119b5c07418SJames Feist {"Resolution", "None."}}; 1120b5c07418SJames Feist } 1121b5c07418SJames Feist 1122b5c07418SJames Feist void generalError(crow::Response& res) 1123b5c07418SJames Feist { 1124b5c07418SJames Feist res.result(boost::beast::http::status::internal_server_error); 1125b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, generalError()); 1126f4c4dcf4SKowalski, Kamil } 1127f4c4dcf4SKowalski, Kamil 1128f4c4dcf4SKowalski, Kamil /** 1129f4c4dcf4SKowalski, Kamil * @internal 1130f4c4dcf4SKowalski, Kamil * @brief Formats Success message into JSON 1131f4c4dcf4SKowalski, Kamil * 1132f4c4dcf4SKowalski, Kamil * See header file for more information 1133f4c4dcf4SKowalski, Kamil * @endinternal 1134f4c4dcf4SKowalski, Kamil */ 1135b5c07418SJames Feist nlohmann::json success(void) 11361abe55efSEd Tanous { 1137b7e069efSJames Feist return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, 1138cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.Success"}, 1139f4c4dcf4SKowalski, Kamil {"Message", "Successfully Completed Request"}, 114085659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1141f4c4dcf4SKowalski, Kamil {"Severity", "OK"}, 1142b5c07418SJames Feist {"Resolution", "None"}}; 1143b5c07418SJames Feist } 1144b5c07418SJames Feist 1145b5c07418SJames Feist void success(crow::Response& res) 1146b5c07418SJames Feist { 1147b5c07418SJames Feist // don't set res.result here because success is the default and any 1148b5c07418SJames Feist // error should overwrite the default 1149b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, success()); 1150f12894f8SJason M. Bills } 1151f12894f8SJason M. Bills 1152f12894f8SJason M. Bills /** 1153f12894f8SJason M. Bills * @internal 1154f4c4dcf4SKowalski, Kamil * @brief Formats Created message into JSON 1155f4c4dcf4SKowalski, Kamil * 1156f4c4dcf4SKowalski, Kamil * See header file for more information 1157f4c4dcf4SKowalski, Kamil * @endinternal 1158f4c4dcf4SKowalski, Kamil */ 1159b5c07418SJames Feist nlohmann::json created(void) 11601abe55efSEd Tanous { 1161b5c07418SJames Feist return nlohmann::json{ 1162b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1163cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.Created"}, 1164f4c4dcf4SKowalski, Kamil {"Message", "The resource has been created successfully"}, 116585659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1166f4c4dcf4SKowalski, Kamil {"Severity", "OK"}, 1167b5c07418SJames Feist {"Resolution", "None"}}; 1168b5c07418SJames Feist } 1169b5c07418SJames Feist 1170b5c07418SJames Feist void created(crow::Response& res) 1171b5c07418SJames Feist { 1172b5c07418SJames Feist res.result(boost::beast::http::status::created); 1173b5c07418SJames Feist addMessageToJsonRoot(res.jsonValue, created()); 1174f4c4dcf4SKowalski, Kamil } 1175f4c4dcf4SKowalski, Kamil 1176f4c4dcf4SKowalski, Kamil /** 1177f4c4dcf4SKowalski, Kamil * @internal 1178cc9139ecSJason M. Bills * @brief Formats NoOperation message into JSON 1179cc9139ecSJason M. Bills * 1180cc9139ecSJason M. Bills * See header file for more information 1181cc9139ecSJason M. Bills * @endinternal 1182cc9139ecSJason M. Bills */ 1183b5c07418SJames Feist nlohmann::json noOperation(void) 1184cc9139ecSJason M. Bills { 1185b5c07418SJames Feist return nlohmann::json{ 1186b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1187cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.NoOperation"}, 1188cc9139ecSJason M. Bills {"Message", "The request body submitted contain no data to act " 1189cc9139ecSJason M. Bills "upon and no changes to the resource took place."}, 119085659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1191cc9139ecSJason M. Bills {"Severity", "Warning"}, 1192cc9139ecSJason M. Bills {"Resolution", 1193b5c07418SJames Feist "Add properties in the JSON object and resubmit the request."}}; 1194b5c07418SJames Feist } 1195b5c07418SJames Feist 1196b5c07418SJames Feist void noOperation(crow::Response& res) 1197b5c07418SJames Feist { 1198b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1199b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noOperation()); 1200cc9139ecSJason M. Bills } 1201cc9139ecSJason M. Bills 1202cc9139ecSJason M. Bills /** 1203cc9139ecSJason M. Bills * @internal 1204b5c07418SJames Feist * @brief Formats PropertyUnknown message into JSON for the specified 1205b5c07418SJames Feist * property 1206f12894f8SJason M. Bills * 1207f12894f8SJason M. Bills * See header file for more information 1208f12894f8SJason M. Bills * @endinternal 1209f12894f8SJason M. Bills */ 1210b5c07418SJames Feist nlohmann::json propertyUnknown(const std::string& arg1) 1211b5c07418SJames Feist { 1212b5c07418SJames Feist return nlohmann::json{ 1213b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1214b5c07418SJames Feist {"MessageId", "Base.1.4.0.PropertyUnknown"}, 1215b5c07418SJames Feist {"Message", "The property " + arg1 + 1216b5c07418SJames Feist " is not in the list of valid properties for " 1217b5c07418SJames Feist "the resource."}, 1218b5c07418SJames Feist {"MessageArgs", {arg1}}, 1219b5c07418SJames Feist {"Severity", "Warning"}, 1220b5c07418SJames Feist {"Resolution", "Remove the unknown property from the request " 1221b5c07418SJames Feist "body and resubmit " 1222b5c07418SJames Feist "the request if the operation failed."}}; 1223b5c07418SJames Feist } 1224b5c07418SJames Feist 1225a08b46ccSJason M. Bills void propertyUnknown(crow::Response& res, const std::string& arg1) 1226f12894f8SJason M. Bills { 1227f12894f8SJason M. Bills res.result(boost::beast::http::status::bad_request); 1228b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyUnknown(arg1), arg1); 1229f4c4dcf4SKowalski, Kamil } 1230f4c4dcf4SKowalski, Kamil 1231f4c4dcf4SKowalski, Kamil /** 1232f4c4dcf4SKowalski, Kamil * @internal 1233f4c4dcf4SKowalski, Kamil * @brief Formats NoValidSession message into JSON 1234f4c4dcf4SKowalski, Kamil * 1235f4c4dcf4SKowalski, Kamil * See header file for more information 1236f4c4dcf4SKowalski, Kamil * @endinternal 1237f4c4dcf4SKowalski, Kamil */ 1238b5c07418SJames Feist nlohmann::json noValidSession(void) 12391abe55efSEd Tanous { 1240b5c07418SJames Feist return nlohmann::json{ 1241b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1242cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.NoValidSession"}, 1243f4c4dcf4SKowalski, Kamil {"Message", 1244f4c4dcf4SKowalski, Kamil "There is no valid session established with the implementation."}, 124585659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1246f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 12471abe55efSEd Tanous {"Resolution", 1248b5c07418SJames Feist "Establish as session before attempting any operations."}}; 1249b5c07418SJames Feist } 1250b5c07418SJames Feist 1251b5c07418SJames Feist void noValidSession(crow::Response& res) 1252b5c07418SJames Feist { 1253b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1254b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, noValidSession()); 1255f4c4dcf4SKowalski, Kamil } 1256f4c4dcf4SKowalski, Kamil 1257f4c4dcf4SKowalski, Kamil /** 1258f4c4dcf4SKowalski, Kamil * @internal 1259f4c4dcf4SKowalski, Kamil * @brief Formats InvalidObject message into JSON 1260f4c4dcf4SKowalski, Kamil * 1261f4c4dcf4SKowalski, Kamil * See header file for more information 1262f4c4dcf4SKowalski, Kamil * @endinternal 1263f4c4dcf4SKowalski, Kamil */ 1264b5c07418SJames Feist nlohmann::json invalidObject(const std::string& arg1) 12651abe55efSEd Tanous { 1266b5c07418SJames Feist return nlohmann::json{ 1267b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1268cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.InvalidObject"}, 1269f4c4dcf4SKowalski, Kamil {"Message", "The object at " + arg1 + " is invalid."}, 127085659adfSJason M. Bills {"MessageArgs", {arg1}}, 1271f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1272f12894f8SJason M. Bills {"Resolution", 127366ac2b8cSJason M. Bills "Either the object is malformed or the URI is not correct. " 1274b5c07418SJames Feist "Correct the condition and resubmit the request if it failed."}}; 1275b5c07418SJames Feist } 1276b5c07418SJames Feist 1277b5c07418SJames Feist void invalidObject(crow::Response& res, const std::string& arg1) 1278b5c07418SJames Feist { 1279b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1280b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidObject(arg1)); 1281f4c4dcf4SKowalski, Kamil } 1282f4c4dcf4SKowalski, Kamil 1283f4c4dcf4SKowalski, Kamil /** 1284f4c4dcf4SKowalski, Kamil * @internal 1285f4c4dcf4SKowalski, Kamil * @brief Formats ResourceInStandby message into JSON 1286f4c4dcf4SKowalski, Kamil * 1287f4c4dcf4SKowalski, Kamil * See header file for more information 1288f4c4dcf4SKowalski, Kamil * @endinternal 1289f4c4dcf4SKowalski, Kamil */ 1290b5c07418SJames Feist nlohmann::json resourceInStandby(void) 12911abe55efSEd Tanous { 1292b5c07418SJames Feist return nlohmann::json{ 1293b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1294cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceInStandby"}, 129566ac2b8cSJason M. Bills {"Message", "The request could not be performed because the " 129666ac2b8cSJason M. Bills "resource is in standby."}, 129785659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1298f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1299f12894f8SJason M. Bills {"Resolution", "Ensure that the resource is in the correct power " 1300b5c07418SJames Feist "state and resubmit the request."}}; 1301b5c07418SJames Feist } 1302b5c07418SJames Feist 1303b5c07418SJames Feist void resourceInStandby(crow::Response& res) 1304b5c07418SJames Feist { 1305b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1306b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceInStandby()); 1307f4c4dcf4SKowalski, Kamil } 1308f4c4dcf4SKowalski, Kamil 1309f4c4dcf4SKowalski, Kamil /** 1310f4c4dcf4SKowalski, Kamil * @internal 1311f4c4dcf4SKowalski, Kamil * @brief Formats ActionParameterValueTypeError message into JSON 1312f4c4dcf4SKowalski, Kamil * 1313f4c4dcf4SKowalski, Kamil * See header file for more information 1314f4c4dcf4SKowalski, Kamil * @endinternal 1315f4c4dcf4SKowalski, Kamil */ 1316b5c07418SJames Feist nlohmann::json actionParameterValueTypeError(const std::string& arg1, 1317f4c4dcf4SKowalski, Kamil const std::string& arg2, 13181abe55efSEd Tanous const std::string& arg3) 13191abe55efSEd Tanous { 1320b5c07418SJames Feist return nlohmann::json{ 1321b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1322cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionParameterValueTypeError"}, 13231abe55efSEd Tanous {"Message", 13241abe55efSEd Tanous "The value " + arg1 + " for the parameter " + arg2 + 1325f4c4dcf4SKowalski, Kamil " in the action " + arg3 + 1326f4c4dcf4SKowalski, Kamil " is of a different type than the parameter can accept."}, 132785659adfSJason M. Bills {"MessageArgs", {arg1, arg2, arg3}}, 1328f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 132966ac2b8cSJason M. Bills {"Resolution", 133066ac2b8cSJason M. Bills "Correct the value for the parameter in the request body and " 1331b5c07418SJames Feist "resubmit the request if the operation failed."}}; 1332b5c07418SJames Feist } 1333b5c07418SJames Feist 1334b5c07418SJames Feist void actionParameterValueTypeError(crow::Response& res, const std::string& arg1, 1335b5c07418SJames Feist const std::string& arg2, 1336b5c07418SJames Feist const std::string& arg3) 1337b5c07418SJames Feist { 1338b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1339b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1340b5c07418SJames Feist actionParameterValueTypeError(arg1, arg2, arg3)); 1341f4c4dcf4SKowalski, Kamil } 1342f4c4dcf4SKowalski, Kamil 1343f4c4dcf4SKowalski, Kamil /** 1344f4c4dcf4SKowalski, Kamil * @internal 1345f4c4dcf4SKowalski, Kamil * @brief Formats SessionLimitExceeded message into JSON 1346f4c4dcf4SKowalski, Kamil * 1347f4c4dcf4SKowalski, Kamil * See header file for more information 1348f4c4dcf4SKowalski, Kamil * @endinternal 1349f4c4dcf4SKowalski, Kamil */ 1350b5c07418SJames Feist nlohmann::json sessionLimitExceeded(void) 13511abe55efSEd Tanous { 1352b5c07418SJames Feist return nlohmann::json{ 1353b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1354cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.SessionLimitExceeded"}, 1355f12894f8SJason M. Bills {"Message", "The session establishment failed due to the number of " 135666ac2b8cSJason M. Bills "simultaneous sessions exceeding the limit of the " 135766ac2b8cSJason M. Bills "implementation."}, 135885659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1359f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 136066ac2b8cSJason M. Bills {"Resolution", "Reduce the number of other sessions before trying " 136166ac2b8cSJason M. Bills "to establish the session or increase the limit of " 1362b5c07418SJames Feist "simultaneous sessions (if supported)."}}; 1363b5c07418SJames Feist } 1364b5c07418SJames Feist 1365b5c07418SJames Feist void sessionLimitExceeded(crow::Response& res) 1366b5c07418SJames Feist { 1367b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1368b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, sessionLimitExceeded()); 1369f4c4dcf4SKowalski, Kamil } 1370f4c4dcf4SKowalski, Kamil 1371f4c4dcf4SKowalski, Kamil /** 1372f4c4dcf4SKowalski, Kamil * @internal 1373f4c4dcf4SKowalski, Kamil * @brief Formats ActionNotSupported message into JSON 1374f4c4dcf4SKowalski, Kamil * 1375f4c4dcf4SKowalski, Kamil * See header file for more information 1376f4c4dcf4SKowalski, Kamil * @endinternal 1377f4c4dcf4SKowalski, Kamil */ 1378b5c07418SJames Feist nlohmann::json actionNotSupported(const std::string& arg1) 13791abe55efSEd Tanous { 1380b5c07418SJames Feist return nlohmann::json{ 1381b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1382cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ActionNotSupported"}, 13831abe55efSEd Tanous {"Message", 13841abe55efSEd Tanous "The action " + arg1 + " is not supported by the resource."}, 138585659adfSJason M. Bills {"MessageArgs", {arg1}}, 1386f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1387f4c4dcf4SKowalski, Kamil {"Resolution", 1388f4c4dcf4SKowalski, Kamil "The action supplied cannot be resubmitted to the implementation. " 1389f12894f8SJason M. Bills " Perhaps the action was invalid, the wrong resource was the " 139066ac2b8cSJason M. Bills "target or the implementation documentation may be of " 1391b5c07418SJames Feist "assistance."}}; 1392b5c07418SJames Feist } 1393b5c07418SJames Feist 1394b5c07418SJames Feist void actionNotSupported(crow::Response& res, const std::string& arg1) 1395b5c07418SJames Feist { 1396b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1397b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, actionNotSupported(arg1)); 1398f4c4dcf4SKowalski, Kamil } 1399f4c4dcf4SKowalski, Kamil 1400f4c4dcf4SKowalski, Kamil /** 1401f4c4dcf4SKowalski, Kamil * @internal 1402f4c4dcf4SKowalski, Kamil * @brief Formats InvalidIndex message into JSON 1403f4c4dcf4SKowalski, Kamil * 1404f4c4dcf4SKowalski, Kamil * See header file for more information 1405f4c4dcf4SKowalski, Kamil * @endinternal 1406f4c4dcf4SKowalski, Kamil */ 1407b5c07418SJames Feist nlohmann::json invalidIndex(const int& arg1) 14081abe55efSEd Tanous { 1409b5c07418SJames Feist return nlohmann::json{ 1410b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1411cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.InvalidIndex"}, 141255c7b7a2SEd Tanous {"Message", "The index " + std::to_string(arg1) + 1413f4c4dcf4SKowalski, Kamil " is not a valid offset into the array."}, 141485659adfSJason M. Bills {"MessageArgs", {std::to_string(arg1)}}, 1415f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 1416f12894f8SJason M. Bills {"Resolution", "Verify the index value provided is within the " 1417b5c07418SJames Feist "bounds of the array."}}; 1418b5c07418SJames Feist } 1419b5c07418SJames Feist 1420b5c07418SJames Feist void invalidIndex(crow::Response& res, const int& arg1) 1421b5c07418SJames Feist { 1422b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1423b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, invalidIndex(arg1)); 1424f4c4dcf4SKowalski, Kamil } 1425f4c4dcf4SKowalski, Kamil 1426f4c4dcf4SKowalski, Kamil /** 1427f4c4dcf4SKowalski, Kamil * @internal 1428f4c4dcf4SKowalski, Kamil * @brief Formats EmptyJSON message into JSON 1429f4c4dcf4SKowalski, Kamil * 1430f4c4dcf4SKowalski, Kamil * See header file for more information 1431f4c4dcf4SKowalski, Kamil * @endinternal 1432f4c4dcf4SKowalski, Kamil */ 1433b5c07418SJames Feist nlohmann::json emptyJSON(void) 14341abe55efSEd Tanous { 1435b5c07418SJames Feist return nlohmann::json{ 1436b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1437cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.EmptyJSON"}, 1438f12894f8SJason M. Bills {"Message", "The request body submitted contained an empty JSON " 143966ac2b8cSJason M. Bills "object and the service is unable to process it."}, 144085659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1441f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 1442f4c4dcf4SKowalski, Kamil {"Resolution", 1443b5c07418SJames Feist "Add properties in the JSON object and resubmit the request."}}; 1444b5c07418SJames Feist } 1445b5c07418SJames Feist 1446b5c07418SJames Feist void emptyJSON(crow::Response& res) 1447b5c07418SJames Feist { 1448b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1449b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, emptyJSON()); 1450f4c4dcf4SKowalski, Kamil } 1451f4c4dcf4SKowalski, Kamil 1452f4c4dcf4SKowalski, Kamil /** 1453f4c4dcf4SKowalski, Kamil * @internal 1454f4c4dcf4SKowalski, Kamil * @brief Formats QueryNotSupportedOnResource message into JSON 1455f4c4dcf4SKowalski, Kamil * 1456f4c4dcf4SKowalski, Kamil * See header file for more information 1457f4c4dcf4SKowalski, Kamil * @endinternal 1458f4c4dcf4SKowalski, Kamil */ 1459b5c07418SJames Feist nlohmann::json queryNotSupportedOnResource(void) 14601abe55efSEd Tanous { 1461b5c07418SJames Feist return nlohmann::json{ 1462b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1463cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.QueryNotSupportedOnResource"}, 1464f4c4dcf4SKowalski, Kamil {"Message", "Querying is not supported on the requested resource."}, 146585659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1466f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 146766ac2b8cSJason M. Bills {"Resolution", "Remove the query parameters and resubmit the " 1468b5c07418SJames Feist "request if the operation failed."}}; 1469b5c07418SJames Feist } 1470b5c07418SJames Feist 1471b5c07418SJames Feist void queryNotSupportedOnResource(crow::Response& res) 1472b5c07418SJames Feist { 1473b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1474b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, queryNotSupportedOnResource()); 1475f4c4dcf4SKowalski, Kamil } 1476f4c4dcf4SKowalski, Kamil 1477f4c4dcf4SKowalski, Kamil /** 1478f4c4dcf4SKowalski, Kamil * @internal 1479f4c4dcf4SKowalski, Kamil * @brief Formats InsufficientPrivilege message into JSON 1480f4c4dcf4SKowalski, Kamil * 1481f4c4dcf4SKowalski, Kamil * See header file for more information 1482f4c4dcf4SKowalski, Kamil * @endinternal 1483f4c4dcf4SKowalski, Kamil */ 1484b5c07418SJames Feist nlohmann::json insufficientPrivilege(void) 14851abe55efSEd Tanous { 1486b5c07418SJames Feist return nlohmann::json{ 1487b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1488cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.InsufficientPrivilege"}, 148966ac2b8cSJason M. Bills {"Message", "There are insufficient privileges for the account or " 149066ac2b8cSJason M. Bills "credentials associated with the current session to " 149166ac2b8cSJason M. Bills "perform the requested operation."}, 149285659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1493f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1494f4c4dcf4SKowalski, Kamil {"Resolution", 1495f12894f8SJason M. Bills "Either abandon the operation or change the associated access " 1496b5c07418SJames Feist "rights and resubmit the request if the operation failed."}}; 1497b5c07418SJames Feist } 1498b5c07418SJames Feist 1499b5c07418SJames Feist void insufficientPrivilege(crow::Response& res) 1500b5c07418SJames Feist { 1501b5c07418SJames Feist res.result(boost::beast::http::status::forbidden); 1502b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, insufficientPrivilege()); 1503f4c4dcf4SKowalski, Kamil } 1504f4c4dcf4SKowalski, Kamil 1505f4c4dcf4SKowalski, Kamil /** 1506f4c4dcf4SKowalski, Kamil * @internal 1507f4c4dcf4SKowalski, Kamil * @brief Formats PropertyValueModified message into JSON 1508f4c4dcf4SKowalski, Kamil * 1509f4c4dcf4SKowalski, Kamil * See header file for more information 1510f4c4dcf4SKowalski, Kamil * @endinternal 1511f4c4dcf4SKowalski, Kamil */ 1512b5c07418SJames Feist nlohmann::json propertyValueModified(const std::string& arg1, 1513b5c07418SJames Feist const std::string& arg2) 1514b5c07418SJames Feist { 1515b5c07418SJames Feist return nlohmann::json{ 1516b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1517b5c07418SJames Feist {"MessageId", "Base.1.4.0.PropertyValueModified"}, 1518b5c07418SJames Feist {"Message", "The property " + arg1 + " was assigned the value " + arg2 + 1519b5c07418SJames Feist " due to modification by the service."}, 1520b5c07418SJames Feist {"MessageArgs", {arg1, arg2}}, 1521b5c07418SJames Feist {"Severity", "Warning"}, 1522b5c07418SJames Feist {"Resolution", "No resolution is required."}}; 1523b5c07418SJames Feist } 1524b5c07418SJames Feist 1525f12894f8SJason M. Bills void propertyValueModified(crow::Response& res, const std::string& arg1, 1526a08b46ccSJason M. Bills const std::string& arg2) 15271abe55efSEd Tanous { 1528f12894f8SJason M. Bills res.result(boost::beast::http::status::ok); 1529b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyValueModified(arg1, arg2), arg1); 1530f4c4dcf4SKowalski, Kamil } 1531f4c4dcf4SKowalski, Kamil 1532f4c4dcf4SKowalski, Kamil /** 1533f4c4dcf4SKowalski, Kamil * @internal 1534f4c4dcf4SKowalski, Kamil * @brief Formats AccountNotModified message into JSON 1535f4c4dcf4SKowalski, Kamil * 1536f4c4dcf4SKowalski, Kamil * See header file for more information 1537f4c4dcf4SKowalski, Kamil * @endinternal 1538f4c4dcf4SKowalski, Kamil */ 1539b5c07418SJames Feist nlohmann::json accountNotModified(void) 15401abe55efSEd Tanous { 1541b5c07418SJames Feist return nlohmann::json{ 1542b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1543cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.AccountNotModified"}, 1544f4c4dcf4SKowalski, Kamil {"Message", "The account modification request failed."}, 154585659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1546f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 1547f12894f8SJason M. Bills {"Resolution", "The modification may have failed due to permission " 1548b5c07418SJames Feist "issues or issues with the request body."}}; 1549b5c07418SJames Feist } 1550b5c07418SJames Feist 1551b5c07418SJames Feist void accountNotModified(crow::Response& res) 1552b5c07418SJames Feist { 1553b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1554b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountNotModified()); 1555f4c4dcf4SKowalski, Kamil } 1556f4c4dcf4SKowalski, Kamil 1557f4c4dcf4SKowalski, Kamil /** 1558f4c4dcf4SKowalski, Kamil * @internal 1559f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterValueFormatError message into JSON 1560f4c4dcf4SKowalski, Kamil * 1561f4c4dcf4SKowalski, Kamil * See header file for more information 1562f4c4dcf4SKowalski, Kamil * @endinternal 1563f4c4dcf4SKowalski, Kamil */ 1564b5c07418SJames Feist nlohmann::json queryParameterValueFormatError(const std::string& arg1, 15651abe55efSEd Tanous const std::string& arg2) 15661abe55efSEd Tanous { 1567b5c07418SJames Feist return nlohmann::json{ 1568b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1569cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.QueryParameterValueFormatError"}, 1570f4c4dcf4SKowalski, Kamil {"Message", 1571f4c4dcf4SKowalski, Kamil "The value " + arg1 + " for the parameter " + arg2 + 1572f4c4dcf4SKowalski, Kamil " is of a different format than the parameter can accept."}, 157385659adfSJason M. Bills {"MessageArgs", {arg1, arg2}}, 1574f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 157566ac2b8cSJason M. Bills {"Resolution", 157666ac2b8cSJason M. Bills "Correct the value for the query parameter in the request and " 1577b5c07418SJames Feist "resubmit the request if the operation failed."}}; 1578b5c07418SJames Feist } 1579b5c07418SJames Feist 1580b5c07418SJames Feist void queryParameterValueFormatError(crow::Response& res, 1581b5c07418SJames Feist const std::string& arg1, 1582b5c07418SJames Feist const std::string& arg2) 1583b5c07418SJames Feist { 1584b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1585b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1586b5c07418SJames Feist queryParameterValueFormatError(arg1, arg2)); 1587f4c4dcf4SKowalski, Kamil } 1588f4c4dcf4SKowalski, Kamil 1589f4c4dcf4SKowalski, Kamil /** 1590f4c4dcf4SKowalski, Kamil * @internal 1591b5c07418SJames Feist * @brief Formats PropertyMissing message into JSON for the specified 1592b5c07418SJames Feist * property 1593f12894f8SJason M. Bills * 1594f12894f8SJason M. Bills * See header file for more information 1595f12894f8SJason M. Bills * @endinternal 1596f12894f8SJason M. Bills */ 1597b5c07418SJames Feist nlohmann::json propertyMissing(const std::string& arg1) 1598f12894f8SJason M. Bills { 1599b5c07418SJames Feist return nlohmann::json{ 1600b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1601cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.PropertyMissing"}, 1602f12894f8SJason M. Bills {"Message", "The property " + arg1 + 1603f12894f8SJason M. Bills " is a required property and must be included in " 1604f12894f8SJason M. Bills "the request."}, 160585659adfSJason M. Bills {"MessageArgs", {arg1}}, 1606f12894f8SJason M. Bills {"Severity", "Warning"}, 1607f12894f8SJason M. Bills {"Resolution", 1608b5c07418SJames Feist "Ensure that the property is in the request body and has a " 1609b5c07418SJames Feist "valid " 1610b5c07418SJames Feist "value and resubmit the request if the operation failed."}}; 1611b5c07418SJames Feist } 1612b5c07418SJames Feist 1613b5c07418SJames Feist void propertyMissing(crow::Response& res, const std::string& arg1) 1614b5c07418SJames Feist { 1615b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1616b5c07418SJames Feist addMessageToJson(res.jsonValue, propertyMissing(arg1), arg1); 1617f4c4dcf4SKowalski, Kamil } 1618f4c4dcf4SKowalski, Kamil 1619f4c4dcf4SKowalski, Kamil /** 1620f4c4dcf4SKowalski, Kamil * @internal 1621f4c4dcf4SKowalski, Kamil * @brief Formats ResourceExhaustion message into JSON 1622f4c4dcf4SKowalski, Kamil * 1623f4c4dcf4SKowalski, Kamil * See header file for more information 1624f4c4dcf4SKowalski, Kamil * @endinternal 1625f4c4dcf4SKowalski, Kamil */ 1626b5c07418SJames Feist nlohmann::json resourceExhaustion(const std::string& arg1) 16271abe55efSEd Tanous { 1628b5c07418SJames Feist return nlohmann::json{ 1629b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1630cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.ResourceExhaustion"}, 1631d425c6f6SEd Tanous {"Message", "The resource " + arg1 + 163266ac2b8cSJason M. Bills " was unable to satisfy the request due to " 163366ac2b8cSJason M. Bills "unavailability of resources."}, 163485659adfSJason M. Bills {"MessageArgs", {arg1}}, 1635f4c4dcf4SKowalski, Kamil {"Severity", "Critical"}, 1636f12894f8SJason M. Bills {"Resolution", "Ensure that the resources are available and " 1637b5c07418SJames Feist "resubmit the request."}}; 1638b5c07418SJames Feist } 1639b5c07418SJames Feist 1640b5c07418SJames Feist void resourceExhaustion(crow::Response& res, const std::string& arg1) 1641b5c07418SJames Feist { 1642b5c07418SJames Feist res.result(boost::beast::http::status::service_unavailable); 1643b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, resourceExhaustion(arg1)); 1644f4c4dcf4SKowalski, Kamil } 1645f4c4dcf4SKowalski, Kamil 1646f4c4dcf4SKowalski, Kamil /** 1647f4c4dcf4SKowalski, Kamil * @internal 1648f4c4dcf4SKowalski, Kamil * @brief Formats AccountModified message into JSON 1649f4c4dcf4SKowalski, Kamil * 1650f4c4dcf4SKowalski, Kamil * See header file for more information 1651f4c4dcf4SKowalski, Kamil * @endinternal 1652f4c4dcf4SKowalski, Kamil */ 1653b5c07418SJames Feist nlohmann::json accountModified(void) 16541abe55efSEd Tanous { 1655b7e069efSJames Feist return nlohmann::json{{"@odata.type", "#Message.v1_0_0.Message"}, 1656cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.AccountModified"}, 1657f4c4dcf4SKowalski, Kamil {"Message", "The account was successfully modified."}, 165885659adfSJason M. Bills {"MessageArgs", nlohmann::json::array()}, 1659f4c4dcf4SKowalski, Kamil {"Severity", "OK"}, 1660b5c07418SJames Feist {"Resolution", "No resolution is required."}}; 1661b5c07418SJames Feist } 1662b5c07418SJames Feist 1663b5c07418SJames Feist void accountModified(crow::Response& res) 1664b5c07418SJames Feist { 1665b5c07418SJames Feist res.result(boost::beast::http::status::ok); 1666b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, accountModified()); 1667f4c4dcf4SKowalski, Kamil } 1668f4c4dcf4SKowalski, Kamil 1669f4c4dcf4SKowalski, Kamil /** 1670f4c4dcf4SKowalski, Kamil * @internal 1671f4c4dcf4SKowalski, Kamil * @brief Formats QueryParameterOutOfRange message into JSON 1672f4c4dcf4SKowalski, Kamil * 1673f4c4dcf4SKowalski, Kamil * See header file for more information 1674f4c4dcf4SKowalski, Kamil * @endinternal 1675f4c4dcf4SKowalski, Kamil */ 1676b5c07418SJames Feist nlohmann::json queryParameterOutOfRange(const std::string& arg1, 1677b5c07418SJames Feist const std::string& arg2, 1678b5c07418SJames Feist const std::string& arg3) 16791abe55efSEd Tanous { 1680b5c07418SJames Feist return nlohmann::json{ 1681b7e069efSJames Feist {"@odata.type", "#Message.v1_0_0.Message"}, 1682cc9139ecSJason M. Bills {"MessageId", "Base.1.4.0.QueryParameterOutOfRange"}, 1683b5c07418SJames Feist {"Message", "The value " + arg1 + " for the query parameter " + arg2 + 1684b5c07418SJames Feist " is out of range " + arg3 + "."}, 168585659adfSJason M. Bills {"MessageArgs", {arg1, arg2, arg3}}, 1686f4c4dcf4SKowalski, Kamil {"Severity", "Warning"}, 1687f4c4dcf4SKowalski, Kamil {"Resolution", 1688f12894f8SJason M. Bills "Reduce the value for the query parameter to a value that is " 168966ac2b8cSJason M. Bills "within range, such as a start or count value that is within " 169066ac2b8cSJason M. Bills "bounds of the number of resources in a collection or a page that " 1691b5c07418SJames Feist "is within the range of valid pages."}}; 1692b5c07418SJames Feist } 1693b5c07418SJames Feist 1694b5c07418SJames Feist void queryParameterOutOfRange(crow::Response& res, const std::string& arg1, 1695b5c07418SJames Feist const std::string& arg2, const std::string& arg3) 1696b5c07418SJames Feist { 1697b5c07418SJames Feist res.result(boost::beast::http::status::bad_request); 1698b5c07418SJames Feist addMessageToErrorJson(res.jsonValue, 1699b5c07418SJames Feist queryParameterOutOfRange(arg1, arg2, arg3)); 1700f4c4dcf4SKowalski, Kamil } 1701f4c4dcf4SKowalski, Kamil 17023bf4e632SJoseph Reynolds /** 17033bf4e632SJoseph Reynolds * @internal 17043bf4e632SJoseph Reynolds * @brief Formats PasswordChangeRequired message into JSON 17053bf4e632SJoseph Reynolds * 17063bf4e632SJoseph Reynolds * See header file for more information 17073bf4e632SJoseph Reynolds * @endinternal 17083bf4e632SJoseph Reynolds */ 17093bf4e632SJoseph Reynolds void passwordChangeRequired(crow::Response& res, const std::string& arg1) 17103bf4e632SJoseph Reynolds { 17113bf4e632SJoseph Reynolds messages::addMessageToJsonRoot( 17123bf4e632SJoseph Reynolds res.jsonValue, 17133bf4e632SJoseph Reynolds nlohmann::json{ 17143bf4e632SJoseph Reynolds {"@odata.type", "/redfish/v1/$metadata#Message.v1_5_0.Message"}, 17153bf4e632SJoseph Reynolds {"MessageId", "Base.1.5.0.PasswordChangeRequired"}, 17163bf4e632SJoseph Reynolds {"Message", "The password provided for this account must be " 17173bf4e632SJoseph Reynolds "changed before access is granted. PATCH the " 17183bf4e632SJoseph Reynolds "'Password' property for this account located at " 17193bf4e632SJoseph Reynolds "the target URI '" + 17203bf4e632SJoseph Reynolds arg1 + "' to complete this process."}, 17213bf4e632SJoseph Reynolds {"MessageArgs", {arg1}}, 17223bf4e632SJoseph Reynolds {"Severity", "Critical"}, 17233bf4e632SJoseph Reynolds {"Resolution", "Change the password for this account using " 17243bf4e632SJoseph Reynolds "a PATCH to the 'Password' property at the URI " 17253bf4e632SJoseph Reynolds "provided."}}); 17263bf4e632SJoseph Reynolds } 17273bf4e632SJoseph Reynolds 1728*4cde5d90SJames Feist void invalidUpload(crow::Response& res, const std::string& arg1, 1729*4cde5d90SJames Feist const std::string& arg2) 1730*4cde5d90SJames Feist { 1731*4cde5d90SJames Feist res.result(boost::beast::http::status::bad_request); 1732*4cde5d90SJames Feist addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2)); 1733*4cde5d90SJames Feist } 1734*4cde5d90SJames Feist 1735*4cde5d90SJames Feist /** 1736*4cde5d90SJames Feist * @internal 1737*4cde5d90SJames Feist * @brief Formats Invalid File message into JSON 1738*4cde5d90SJames Feist * 1739*4cde5d90SJames Feist * See header file for more information 1740*4cde5d90SJames Feist * @endinternal 1741*4cde5d90SJames Feist */ 1742*4cde5d90SJames Feist nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2) 1743*4cde5d90SJames Feist { 1744*4cde5d90SJames Feist return nlohmann::json{ 1745*4cde5d90SJames Feist {"@odata.type", "/redfish/v1/$metadata#Message.v1_0_0.Message"}, 1746*4cde5d90SJames Feist {"MessageId", "OpenBMC.0.1.0.InvalidUpload"}, 1747*4cde5d90SJames Feist {"Message", "Invalid file uploaded to " + arg1 + ": " + arg2 + "."}, 1748*4cde5d90SJames Feist {"MessageArgs", {arg1, arg2}}, 1749*4cde5d90SJames Feist {"Severity", "Warning"}, 1750*4cde5d90SJames Feist {"Resolution", "None."}}; 1751*4cde5d90SJames Feist } 1752*4cde5d90SJames Feist 1753f4c4dcf4SKowalski, Kamil } // namespace messages 1754f4c4dcf4SKowalski, Kamil 1755d425c6f6SEd Tanous } // namespace redfish 1756