Lewanczyk, Dawid | 88d16c9 | 2018-02-02 14:51:09 +0100 | [diff] [blame] | 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 | |
Borawski.Lukasz | 43a095a | 2018-02-19 15:39:01 +0100 | [diff] [blame] | 22 | static OperationMap accountServiceOpMap = { |
| 23 | {crow::HTTPMethod::GET, {{"ConfigureUsers"}, {"ConfigureManager"}}}, |
| 24 | {crow::HTTPMethod::HEAD, {{"Login"}}}, |
| 25 | {crow::HTTPMethod::PATCH, {{"ConfigureUsers"}}}, |
| 26 | {crow::HTTPMethod::PUT, {{"ConfigureUsers"}}}, |
| 27 | {crow::HTTPMethod::DELETE, {{"ConfigureUsers"}}}, |
| 28 | {crow::HTTPMethod::POST, {{"ConfigureUsers"}}}}; |
| 29 | |
Lewanczyk, Dawid | 88d16c9 | 2018-02-02 14:51:09 +0100 | [diff] [blame] | 30 | class AccountService : public Node { |
| 31 | public: |
Borawski.Lukasz | 43a095a | 2018-02-19 15:39:01 +0100 | [diff] [blame] | 32 | template <typename CrowApp> |
| 33 | AccountService(CrowApp& app) |
| 34 | : Node(app, EntityPrivileges(std::move(accountServiceOpMap)), |
Lewanczyk, Dawid | 88d16c9 | 2018-02-02 14:51:09 +0100 | [diff] [blame] | 35 | "/redfish/v1/AccountService/") { |
Borawski.Lukasz | c1a46bd | 2018-02-08 13:31:59 +0100 | [diff] [blame^] | 36 | Node::json["@odata.id"] = "/redfish/v1/AccountService"; |
| 37 | Node::json["@odata.type"] = "#AccountService.v1_1_0.AccountService"; |
| 38 | Node::json["@odata.context"] = |
Lewanczyk, Dawid | 88d16c9 | 2018-02-02 14:51:09 +0100 | [diff] [blame] | 39 | "/redfish/v1/$metadata#AccountService.AccountService"; |
Borawski.Lukasz | c1a46bd | 2018-02-08 13:31:59 +0100 | [diff] [blame^] | 40 | Node::json["Id"] = "AccountService"; |
| 41 | Node::json["Description"] = "BMC User Accounts"; |
| 42 | Node::json["Name"] = "Account Service"; |
| 43 | Node::json["Status"]["State"] = "Enabled"; |
| 44 | Node::json["Status"]["Health"] = "OK"; |
| 45 | Node::json["Status"]["HealthRollup"] = "OK"; |
| 46 | Node::json["ServiceEnabled"] = true; |
| 47 | Node::json["MinPasswordLength"] = 1; |
| 48 | Node::json["MaxPasswordLength"] = 20; |
| 49 | Node::json["Accounts"]["@odata.id"] = "/redfish/v1/AccountService/Accounts"; |
| 50 | Node::json["Roles"]["@odata.id"] = "/redfish/v1/AccountService/Roles"; |
Lewanczyk, Dawid | 88d16c9 | 2018-02-02 14:51:09 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | private: |
| 54 | void doGet(crow::response& res, const crow::request& req, |
| 55 | const std::vector<std::string>& params) override { |
Borawski.Lukasz | c1a46bd | 2018-02-08 13:31:59 +0100 | [diff] [blame^] | 56 | res.json_value = Node::json; |
Lewanczyk, Dawid | 88d16c9 | 2018-02-02 14:51:09 +0100 | [diff] [blame] | 57 | res.end(); |
| 58 | } |
Lewanczyk, Dawid | 88d16c9 | 2018-02-02 14:51:09 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } // namespace redfish |