redfish_axum/
odata.rs

1// Generated by redfish-codegen. Do not modify.
2
3
4use axum::{
5    extract::State,
6    routing::{self, MethodRouter},
7    Json,
8};
9use redfish_codegen::models::odata_v4::{Context, Service, ServiceDocument};
10
11/// This endpoint implements the OData Service Document.
12#[derive(Clone, Default)]
13pub struct OData(ServiceDocument);
14
15impl OData {
16    pub fn new() -> Self {
17        Self(ServiceDocument {
18            odata_context: Context("/redfish/v1/$metadata".to_string()),
19            value: vec![Service {
20                name: "Service".to_string(),
21                url: "/redfish/v1/".to_string(),
22                ..Default::default()
23            }],
24        })
25    }
26
27    pub fn enable_systems(mut self) -> Self {
28        self.0.value.push(Service {
29            name: "Systems".to_string(),
30            url: "/redfish/v1/Systems".to_string(),
31            ..Default::default()
32        });
33        self
34    }
35
36    pub fn enable_chassis(mut self) -> Self {
37        self.0.value.push(Service {
38            name: "Chassis".to_string(),
39            url: "/redfish/v1/Chassis".to_string(),
40            ..Default::default()
41        });
42        self
43    }
44
45    pub fn enable_managers(mut self) -> Self {
46        self.0.value.push(Service {
47            name: "Managers".to_string(),
48            url: "/redfish/v1/Managers".to_string(),
49            ..Default::default()
50        });
51        self
52    }
53
54    pub fn enable_task_service(mut self) -> Self {
55        self.0.value.push(Service {
56            name: "TaskService".to_string(),
57            url: "/redfish/v1/TaskService".to_string(),
58            ..Default::default()
59        });
60        self
61    }
62
63    pub fn enable_account_service(mut self) -> Self {
64        self.0.value.push(Service {
65            name: "AccountService".to_string(),
66            url: "/redfish/v1/AccountService".to_string(),
67            ..Default::default()
68        });
69        self
70    }
71
72    pub fn enable_session_service(mut self) -> Self {
73        self.0.value.push(Service {
74            name: "SessionService".to_string(),
75            url: "/redfish/v1/SessionService".to_string(),
76            ..Default::default()
77        });
78        self
79    }
80
81    pub fn enable_event_service(mut self) -> Self {
82        self.0.value.push(Service {
83            name: "EventService".to_string(),
84            url: "/redfish/v1/EventService".to_string(),
85            ..Default::default()
86        });
87        self
88    }
89
90    pub fn enable_registries(mut self) -> Self {
91        self.0.value.push(Service {
92            name: "Registries".to_string(),
93            url: "/redfish/v1/Registries".to_string(),
94            ..Default::default()
95        });
96        self
97    }
98
99    pub fn enable_json_schemas(mut self) -> Self {
100        self.0.value.push(Service {
101            name: "JsonSchemas".to_string(),
102            url: "/redfish/v1/JsonSchemas".to_string(),
103            ..Default::default()
104        });
105        self
106    }
107
108    pub fn enable_certificate_service(mut self) -> Self {
109        self.0.value.push(Service {
110            name: "CertificateService".to_string(),
111            url: "/redfish/v1/CertificateService".to_string(),
112            ..Default::default()
113        });
114        self
115    }
116
117    pub fn enable_key_service(mut self) -> Self {
118        self.0.value.push(Service {
119            name: "KeyService".to_string(),
120            url: "/redfish/v1/KeyService".to_string(),
121            ..Default::default()
122        });
123        self
124    }
125
126    pub fn enable_update_service(mut self) -> Self {
127        self.0.value.push(Service {
128            name: "UpdateService".to_string(),
129            url: "/redfish/v1/UpdateService".to_string(),
130            ..Default::default()
131        });
132        self
133    }
134
135    pub fn enable_sessions(mut self) -> Self {
136        self.0.value.push(Service {
137            name: "Sessions".to_string(),
138            url: "/redfish/v1/SessionService/Sessions".to_string(),
139            ..Default::default()
140        });
141        self
142    }
143
144}
145
146impl From<OData> for MethodRouter {
147    fn from(val: OData) -> Self {
148        routing::get(|State(odata): State<OData>| async move { Json(odata.0) }).with_state(val)
149    }
150}