14e49bd4bSLewanczyk, Dawid /* 24e49bd4bSLewanczyk, Dawid // Copyright (c) 2018 Intel Corporation 34e49bd4bSLewanczyk, Dawid // 44e49bd4bSLewanczyk, Dawid // Licensed under the Apache License, Version 2.0 (the "License"); 54e49bd4bSLewanczyk, Dawid // you may not use this file except in compliance with the License. 64e49bd4bSLewanczyk, Dawid // You may obtain a copy of the License at 74e49bd4bSLewanczyk, Dawid // 84e49bd4bSLewanczyk, Dawid // http://www.apache.org/licenses/LICENSE-2.0 94e49bd4bSLewanczyk, Dawid // 104e49bd4bSLewanczyk, Dawid // Unless required by applicable law or agreed to in writing, software 114e49bd4bSLewanczyk, Dawid // distributed under the License is distributed on an "AS IS" BASIS, 124e49bd4bSLewanczyk, Dawid // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134e49bd4bSLewanczyk, Dawid // See the License for the specific language governing permissions and 144e49bd4bSLewanczyk, Dawid // limitations under the License. 154e49bd4bSLewanczyk, Dawid */ 164e49bd4bSLewanczyk, Dawid #pragma once 174e49bd4bSLewanczyk, Dawid 184e49bd4bSLewanczyk, Dawid #include "node.hpp" 194e49bd4bSLewanczyk, Dawid 204e49bd4bSLewanczyk, Dawid namespace redfish { 214e49bd4bSLewanczyk, Dawid 224e49bd4bSLewanczyk, Dawid class Roles : public Node { 234e49bd4bSLewanczyk, Dawid public: 2443a095abSBorawski.Lukasz Roles(CrowApp& app) 253ebd75f7SEd Tanous : Node(app, "/redfish/v1/AccountService/Roles/Administrator/") { 26c1a46bd2SBorawski.Lukasz Node::json["@odata.id"] = "/redfish/v1/AccountService/Roles/Administrator"; 27c1a46bd2SBorawski.Lukasz Node::json["@odata.type"] = "#Role.v1_0_2.Role"; 28c1a46bd2SBorawski.Lukasz Node::json["@odata.context"] = "/redfish/v1/$metadata#Role.Role"; 29c1a46bd2SBorawski.Lukasz Node::json["Id"] = "Administrator"; 30c1a46bd2SBorawski.Lukasz Node::json["Name"] = "User Role"; 31c1a46bd2SBorawski.Lukasz Node::json["Description"] = "Administrator User Role"; 32c1a46bd2SBorawski.Lukasz Node::json["IsPredefined"] = true; 33c1a46bd2SBorawski.Lukasz Node::json["AssignedPrivileges"] = {"Login", "ConfigureManager", 344e49bd4bSLewanczyk, Dawid "ConfigureUsers", "ConfigureSelf", 354e49bd4bSLewanczyk, Dawid "ConfigureComponents"}; 36c1a46bd2SBorawski.Lukasz Node::json["OemPrivileges"] = nlohmann::json::array(); 37*e0d918bcSEd Tanous entityPrivileges = {{boost::beast::http::verb::get, {{"Login"}}}, 38*e0d918bcSEd Tanous {boost::beast::http::verb::head, {{"Login"}}}, 39*e0d918bcSEd Tanous {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, 40*e0d918bcSEd Tanous {boost::beast::http::verb::put, {{"ConfigureManager"}}}, 41*e0d918bcSEd Tanous {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, 42*e0d918bcSEd Tanous {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; 434e49bd4bSLewanczyk, Dawid } 444e49bd4bSLewanczyk, Dawid 454e49bd4bSLewanczyk, Dawid private: 464e49bd4bSLewanczyk, Dawid void doGet(crow::response& res, const crow::request& req, 474e49bd4bSLewanczyk, Dawid const std::vector<std::string>& params) override { 48c1a46bd2SBorawski.Lukasz res.json_value = Node::json; 494e49bd4bSLewanczyk, Dawid res.end(); 504e49bd4bSLewanczyk, Dawid } 514e49bd4bSLewanczyk, Dawid }; 524e49bd4bSLewanczyk, Dawid 534e49bd4bSLewanczyk, Dawid class RoleCollection : public Node { 544e49bd4bSLewanczyk, Dawid public: 5543a095abSBorawski.Lukasz RoleCollection(CrowApp& app) 563ebd75f7SEd Tanous : Node(app, "/redfish/v1/AccountService/Roles/") { 57c1a46bd2SBorawski.Lukasz Node::json["@odata.id"] = "/redfish/v1/AccountService/Roles"; 58c1a46bd2SBorawski.Lukasz Node::json["@odata.type"] = "#RoleCollection.RoleCollection"; 59c1a46bd2SBorawski.Lukasz Node::json["@odata.context"] = 604e49bd4bSLewanczyk, Dawid "/redfish/v1/$metadata#RoleCollection.RoleCollection"; 61c1a46bd2SBorawski.Lukasz Node::json["Name"] = "Roles Collection"; 62c1a46bd2SBorawski.Lukasz Node::json["Description"] = "BMC User Roles"; 63c1a46bd2SBorawski.Lukasz Node::json["Members@odata.count"] = 1; 64c1a46bd2SBorawski.Lukasz Node::json["Members"] = { 656c233015SEd Tanous {{"@odata.id", "/redfish/v1/AccountService/Roles/Administrator"}}}; 663ebd75f7SEd Tanous 67*e0d918bcSEd Tanous entityPrivileges = {{boost::beast::http::verb::get, {{"Login"}}}, 68*e0d918bcSEd Tanous {boost::beast::http::verb::head, {{"Login"}}}, 69*e0d918bcSEd Tanous {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, 70*e0d918bcSEd Tanous {boost::beast::http::verb::put, {{"ConfigureManager"}}}, 71*e0d918bcSEd Tanous {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, 72*e0d918bcSEd Tanous {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; 734e49bd4bSLewanczyk, Dawid } 744e49bd4bSLewanczyk, Dawid 754e49bd4bSLewanczyk, Dawid private: 764e49bd4bSLewanczyk, Dawid void doGet(crow::response& res, const crow::request& req, 774e49bd4bSLewanczyk, Dawid const std::vector<std::string>& params) override { 78c1a46bd2SBorawski.Lukasz res.json_value = Node::json; 796c233015SEd Tanous // This is a short term solution to work around a bug. GetSubroutes 806c233015SEd Tanous // accidentally recognizes the Roles/Administrator route as a subroute 816c233015SEd Tanous // (because it's hardcoded to a single entity). Remove this line when that 826c233015SEd Tanous // is resolved 836c233015SEd Tanous res.json_value.erase("Administrator"); 844e49bd4bSLewanczyk, Dawid res.end(); 854e49bd4bSLewanczyk, Dawid } 864e49bd4bSLewanczyk, Dawid }; 874e49bd4bSLewanczyk, Dawid 884e49bd4bSLewanczyk, Dawid } // namespace redfish 89