1 /*
2 // Copyright (c) 2018 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 #pragma once
17 
18 #include "node.hpp"
19 
20 namespace redfish
21 {
22 
23 class AccountService : public Node
24 {
25   public:
26     AccountService(CrowApp& app) : Node(app, "/redfish/v1/AccountService/")
27     {
28         Node::json["@odata.id"] = "/redfish/v1/AccountService";
29         Node::json["@odata.type"] = "#AccountService.v1_1_0.AccountService";
30         Node::json["@odata.context"] =
31             "/redfish/v1/$metadata#AccountService.AccountService";
32         Node::json["Id"] = "AccountService";
33         Node::json["Description"] = "BMC User Accounts";
34         Node::json["Name"] = "Account Service";
35         Node::json["ServiceEnabled"] = true;
36         Node::json["MinPasswordLength"] = 1;
37         Node::json["MaxPasswordLength"] = 20;
38         Node::json["Accounts"]["@odata.id"] =
39             "/redfish/v1/AccountService/Accounts";
40         Node::json["Roles"]["@odata.id"] = "/redfish/v1/AccountService/Roles";
41 
42         entityPrivileges = {
43             {boost::beast::http::verb::get,
44              {{"ConfigureUsers"}, {"ConfigureManager"}}},
45             {boost::beast::http::verb::head, {{"Login"}}},
46             {boost::beast::http::verb::patch, {{"ConfigureUsers"}}},
47             {boost::beast::http::verb::put, {{"ConfigureUsers"}}},
48             {boost::beast::http::verb::delete_, {{"ConfigureUsers"}}},
49             {boost::beast::http::verb::post, {{"ConfigureUsers"}}}};
50     }
51 
52   private:
53     void doGet(crow::Response& res, const crow::Request& req,
54                const std::vector<std::string>& params) override
55     {
56         res.jsonValue = Node::json;
57         res.end();
58     }
59 };
60 
61 } // namespace redfish
62