blob: c302a685964489013baa1a9cecdad97756a1b082 [file] [log] [blame]
Ed Tanous3dac7492017-08-02 13:46:20 -07001#include <crow/app.h>
2namespace crow {
3namespace redfish {
4
5template <typename... Middlewares>
6void request_routes(Crow<Middlewares...>& app) {
7 CROW_ROUTE(app, "/redfish/").methods("GET"_method)([]() {
8 return nlohmann::json{{"v1", "/redfish/v1/"}};
9 });
10 CROW_ROUTE(app, "/redfish/v1/").methods("GET"_method)([]() {
11 return nlohmann::json{
12 {"@odata.context", "/redfish/v1/$metadata#ServiceRoot.ServiceRoot"},
13 {"@odata.id", "/redfish/v1/"},
14 {"@odata.type", "#ServiceRoot.v1_1_1.ServiceRoot"},
15 {"Id", "RootService"},
16 {"Name", "Root Service"},
17 {"RedfishVersion", "1.1.0"},
18 {"UUID", "bdfc5c6d-07a9-4e67-972f-bd2b30c6a0e8"},
19 //{"Systems", {{"@odata.id", "/redfish/v1/Systems"}}},
20 //{"Chassis", {{"@odata.id", "/redfish/v1/Chassis"}}},
21 //{"Managers", {{"@odata.id", "/redfish/v1/Managers"}}},
22 //{"SessionService", {{"@odata.id", "/redfish/v1/SessionService"}}},
23 {"AccountService", {{"@odata.id", "/redfish/v1/AccountService"}}},
24 //{"UpdateService", {{"@odata.id", "/redfish/v1/UpdateService"}}},
25 /*{"Links",
26 {{"Sessions",
27 {{"@odata.id", "/redfish/v1/SessionService/Sessions"}}}}}*/
28 };
29 });
30
31 CROW_ROUTE(app, "/redfish/v1/AccountService").methods("GET"_method)([]() {
32 return nlohmann::json{
33 {"@odata.context",
34 "/redfish/v1/$metadata#AccountService.AccountService"},
35 {"@odata.id", "/redfish/v1/AccountService"},
36 {"@odata.type", "#AccountService.v1_1_0.AccountService"},
37 {"Id", "AccountService"},
38 {"Name", "Account Service"},
39 {"Description", "BMC User Accounts"},
40 {"Status",
41 {{"State", "Enabled"}, {"Health", "OK"}, {"HealthRollup", "OK"}}},
42 {"ServiceEnabled", true},
43 {"MinPasswordLength", 1},
44 {"MaxPasswordLength", 20},
45 {"Accounts", {{"@odata.id", "/redfish/v1/AccountService/Accounts"}}},
46 //{"Roles", {{"@odata.id", "/redfish/v1/AccountService/Roles"}}}
47 };
48 });
49
50 CROW_ROUTE(app, "/redfish/v1/AccountService/Accounts/")
51 .methods("GET"_method)([]() {
52 return nlohmann::json{
53 {"@odata.context",
54 "/redfish/v1/"
55 "$metadata#ManagerAccountCollection.ManagerAccountCollection"},
56 {"@odata.id", "/redfish/v1/AccountService/Accounts"},
57 {"@odata.type",
58 "#ManagerAccountCollection.ManagerAccountCollection"},
59 {"Name", "Accounts Collection"},
60 {"Description", "BMC User Accounts"},
61 {"Members@odata.count", 3},
62 {"Members",
63 {{{"@odata.id", "/redfish/v1/AccountService/Accounts/1"}},
64 {{"@odata.id", "/redfish/v1/AccountService/Accounts/2"}},
65 {{"@odata.id", "/redfish/v1/AccountService/Accounts/3"}}}}};
66 });
67
68 CROW_ROUTE(app, "/redfish/v1/AccountService/Accounts/<int>/")
69 .methods("GET"_method)([](int account_index) {
70 return nlohmann::json{
71 {"@odata.context",
72 "/redfish/v1/$metadata#ManagerAccount.ManagerAccount"},
73 {"@odata.id", "/redfish/v1/AccountService/Accounts/1"},
74 {"@odata.type", "#ManagerAccount.v1_0_3.ManagerAccount"},
75 {"Id", "1"},
76 {"Name", "User Account"},
77 {"Description", "User Account"},
78 {"Enabled", false},
79 {"Password", nullptr},
80 {"UserName", "anonymous"},
81 {"RoleId", "NoAccess"},
82 {"Links",
83 {{"Role",
84 {{"@odata.id", "/redfish/v1/AccountService/Roles/NoAccess"}}}}}};
85 });
86}
87}
88}