blob: 5e711b172558dba747231f922e2df6c9d473fe02 [file] [log] [blame]
Lewanczyk, Dawid4e49bd42018-01-25 11:30:19 +01001/*
2// Copyright (c) 2018 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16#pragma once
17
Lewanczyk, Dawid4e49bd42018-01-25 11:30:19 +010018#include "node.hpp"
19
Ed Tanous1abe55e2018-09-05 08:30:59 -070020namespace redfish
21{
Lewanczyk, Dawid4e49bd42018-01-25 11:30:19 +010022
Ed Tanous1abe55e2018-09-05 08:30:59 -070023class Roles : public Node
24{
25 public:
26 Roles(CrowApp& app) :
27 Node(app, "/redfish/v1/AccountService/Roles/Administrator/")
28 {
Ed Tanous1abe55e2018-09-05 08:30:59 -070029 entityPrivileges = {
30 {boost::beast::http::verb::get, {{"Login"}}},
31 {boost::beast::http::verb::head, {{"Login"}}},
32 {boost::beast::http::verb::patch, {{"ConfigureManager"}}},
33 {boost::beast::http::verb::put, {{"ConfigureManager"}}},
34 {boost::beast::http::verb::delete_, {{"ConfigureManager"}}},
35 {boost::beast::http::verb::post, {{"ConfigureManager"}}}};
36 }
Lewanczyk, Dawid4e49bd42018-01-25 11:30:19 +010037
Ed Tanous1abe55e2018-09-05 08:30:59 -070038 private:
39 void doGet(crow::Response& res, const crow::Request& req,
40 const std::vector<std::string>& params) override
41 {
Ed Tanous0f74e642018-11-12 15:17:05 -080042 res.jsonValue["@odata.id"] =
43 "/redfish/v1/AccountService/Roles/Administrator";
44 res.jsonValue["@odata.type"] = "#Role.v1_0_2.Role";
45 res.jsonValue["@odata.context"] = "/redfish/v1/$metadata#Role.Role";
46 res.jsonValue["Id"] = "Administrator";
47 res.jsonValue["Name"] = "User Role";
48 res.jsonValue["Description"] = "Administrator User Role";
49 res.jsonValue["IsPredefined"] = true;
50 res.jsonValue["AssignedPrivileges"] = {
51 "Login", "ConfigureManager", "ConfigureUsers", "ConfigureSelf",
52 "ConfigureComponents"};
53 res.jsonValue["OemPrivileges"] = nlohmann::json::array();
Ed Tanous1abe55e2018-09-05 08:30:59 -070054 res.end();
55 }
Lewanczyk, Dawid4e49bd42018-01-25 11:30:19 +010056};
57
Ed Tanous1abe55e2018-09-05 08:30:59 -070058class RoleCollection : public Node
59{
60 public:
61 RoleCollection(CrowApp& app) :
62 Node(app, "/redfish/v1/AccountService/Roles/")
63 {
Ed Tanous1abe55e2018-09-05 08:30:59 -070064 entityPrivileges = {
65 {boost::beast::http::verb::get, {{"Login"}}},
66 {boost::beast::http::verb::head, {{"Login"}}},
67 {boost::beast::http::verb::patch, {{"ConfigureManager"}}},
68 {boost::beast::http::verb::put, {{"ConfigureManager"}}},
69 {boost::beast::http::verb::delete_, {{"ConfigureManager"}}},
70 {boost::beast::http::verb::post, {{"ConfigureManager"}}}};
71 }
Lewanczyk, Dawid4e49bd42018-01-25 11:30:19 +010072
Ed Tanous1abe55e2018-09-05 08:30:59 -070073 private:
74 void doGet(crow::Response& res, const crow::Request& req,
75 const std::vector<std::string>& params) override
76 {
Ed Tanous0f74e642018-11-12 15:17:05 -080077 res.jsonValue["@odata.id"] = "/redfish/v1/AccountService/Roles";
78 res.jsonValue["@odata.type"] = "#RoleCollection.RoleCollection";
79 res.jsonValue["@odata.context"] =
80 "/redfish/v1/$metadata#RoleCollection.RoleCollection";
81 res.jsonValue["Name"] = "Roles Collection";
82 res.jsonValue["Description"] = "BMC User Roles";
83 res.jsonValue["Members@odata.count"] = 1;
84 res.jsonValue["Members"] = {
85 {{"@odata.id", "/redfish/v1/AccountService/Roles/Administrator"}}};
Ed Tanous1abe55e2018-09-05 08:30:59 -070086 res.end();
87 }
Lewanczyk, Dawid4e49bd42018-01-25 11:30:19 +010088};
89
Ed Tanous1abe55e2018-09-05 08:30:59 -070090} // namespace redfish