casdoor_sdk/apis/
system_api.rs

1
2
3use reqwest;
4
5use crate::{apis::ResponseContent, models};
6use super::{Error, configuration};
7
8
9/// struct for typed errors of method [`get_dashboard`]
10#[derive(Debug, Clone, Serialize, Deserialize)]
11#[serde(untagged)]
12pub enum ApiControllerGetDashboardError {
13    UnknownValue(serde_json::Value),
14}
15
16/// struct for typed errors of method [`get_prometheus_info`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ApiControllerGetPrometheusInfoError {
20    UnknownValue(serde_json::Value),
21}
22
23/// struct for typed errors of method [`get_system_info`]
24#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum ApiControllerGetSystemInfoError {
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`get_version_info`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum ApiControllerGetVersionInfoError {
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`get_webhook_event_type`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum ApiControllerGetWebhookEventTypeError {
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`handle_official_account_event`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum ApiControllerHandleOfficialAccountEventError {
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`health`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum ApiControllerHealthError {
55    UnknownValue(serde_json::Value),
56}
57
58
59/// get information of dashboard
60pub async fn get_dashboard(configuration: &configuration::Configuration) -> Result<models::ControllersResponse, Error<ApiControllerGetDashboardError>> {
61    let local_var_configuration = configuration;
62
63    // unbox the parameters
64
65
66    let local_var_client = &local_var_configuration.client;
67
68    let local_var_uri_str = format!("{}/api/get-dashboard", local_var_configuration.base_path);
69    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
70
71    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
72        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
73    }
74
75    let local_var_req = local_var_req_builder.build()?;
76    let local_var_resp = local_var_client.execute(local_var_req).await?;
77
78    let local_var_status = local_var_resp.status();
79    let local_var_content = local_var_resp.text().await?;
80
81    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
82        serde_json::from_str(&local_var_content).map_err(Error::from)
83    } else {
84        let local_var_entity: Option<ApiControllerGetDashboardError> = serde_json::from_str(&local_var_content).ok();
85        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
86        Err(Error::ResponseError(local_var_error))
87    }
88}
89
90/// get Prometheus Info
91pub async fn get_prometheus_info(configuration: &configuration::Configuration) -> Result<models::PrometheusInfo, Error<ApiControllerGetPrometheusInfoError>> {
92    let local_var_configuration = configuration;
93
94    // unbox the parameters
95
96
97    let local_var_client = &local_var_configuration.client;
98
99    let local_var_uri_str = format!("{}/api/get-prometheus-info", local_var_configuration.base_path);
100    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
101
102    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
103        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
104    }
105
106    let local_var_req = local_var_req_builder.build()?;
107    let local_var_resp = local_var_client.execute(local_var_req).await?;
108
109    let local_var_status = local_var_resp.status();
110    let local_var_content = local_var_resp.text().await?;
111
112    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
113        serde_json::from_str(&local_var_content).map_err(Error::from)
114    } else {
115        let local_var_entity: Option<ApiControllerGetPrometheusInfoError> = serde_json::from_str(&local_var_content).ok();
116        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
117        Err(Error::ResponseError(local_var_error))
118    }
119}
120
121/// get system info like CPU and memory usage
122pub async fn get_system_info(configuration: &configuration::Configuration) -> Result<models::UtilPeriodSystemInfo, Error<ApiControllerGetSystemInfoError>> {
123    let local_var_configuration = configuration;
124
125    // unbox the parameters
126
127
128    let local_var_client = &local_var_configuration.client;
129
130    let local_var_uri_str = format!("{}/api/get-system-info", local_var_configuration.base_path);
131    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
132
133    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
134        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
135    }
136
137    let local_var_req = local_var_req_builder.build()?;
138    let local_var_resp = local_var_client.execute(local_var_req).await?;
139
140    let local_var_status = local_var_resp.status();
141    let local_var_content = local_var_resp.text().await?;
142
143    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
144        serde_json::from_str(&local_var_content).map_err(Error::from)
145    } else {
146        let local_var_entity: Option<ApiControllerGetSystemInfoError> = serde_json::from_str(&local_var_content).ok();
147        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
148        Err(Error::ResponseError(local_var_error))
149    }
150}
151
152/// get version info like Casdoor release version and commit ID
153pub async fn get_version_info(configuration: &configuration::Configuration) -> Result<models::UtilPeriodVersionInfo, Error<ApiControllerGetVersionInfoError>> {
154    let local_var_configuration = configuration;
155
156    // unbox the parameters
157
158
159    let local_var_client = &local_var_configuration.client;
160
161    let local_var_uri_str = format!("{}/api/get-version-info", local_var_configuration.base_path);
162    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
163
164    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
165        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
166    }
167
168    let local_var_req = local_var_req_builder.build()?;
169    let local_var_resp = local_var_client.execute(local_var_req).await?;
170
171    let local_var_status = local_var_resp.status();
172    let local_var_content = local_var_resp.text().await?;
173
174    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
175        serde_json::from_str(&local_var_content).map_err(Error::from)
176    } else {
177        let local_var_entity: Option<ApiControllerGetVersionInfoError> = serde_json::from_str(&local_var_content).ok();
178        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
179        Err(Error::ResponseError(local_var_error))
180    }
181}
182
183pub async fn get_webhook_event_type(configuration: &configuration::Configuration) -> Result<models::Userinfo, Error<ApiControllerGetWebhookEventTypeError>> {
184    let local_var_configuration = configuration;
185
186    // unbox the parameters
187
188
189    let local_var_client = &local_var_configuration.client;
190
191    let local_var_uri_str = format!("{}/api/get-webhook-event", local_var_configuration.base_path);
192    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
193
194    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
195        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
196    }
197
198    let local_var_req = local_var_req_builder.build()?;
199    let local_var_resp = local_var_client.execute(local_var_req).await?;
200
201    let local_var_status = local_var_resp.status();
202    let local_var_content = local_var_resp.text().await?;
203
204    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
205        serde_json::from_str(&local_var_content).map_err(Error::from)
206    } else {
207        let local_var_entity: Option<ApiControllerGetWebhookEventTypeError> = serde_json::from_str(&local_var_content).ok();
208        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
209        Err(Error::ResponseError(local_var_error))
210    }
211}
212
213pub async fn handle_official_account_event(configuration: &configuration::Configuration) -> Result<models::Userinfo, Error<ApiControllerHandleOfficialAccountEventError>> {
214    let local_var_configuration = configuration;
215
216    // unbox the parameters
217
218
219    let local_var_client = &local_var_configuration.client;
220
221    let local_var_uri_str = format!("{}/api/webhook", local_var_configuration.base_path);
222    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
223
224    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
225        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
226    }
227
228    let local_var_req = local_var_req_builder.build()?;
229    let local_var_resp = local_var_client.execute(local_var_req).await?;
230
231    let local_var_status = local_var_resp.status();
232    let local_var_content = local_var_resp.text().await?;
233
234    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
235        serde_json::from_str(&local_var_content).map_err(Error::from)
236    } else {
237        let local_var_entity: Option<ApiControllerHandleOfficialAccountEventError> = serde_json::from_str(&local_var_content).ok();
238        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
239        Err(Error::ResponseError(local_var_error))
240    }
241}
242
243/// check if the system is live
244pub async fn health(configuration: &configuration::Configuration) -> Result<models::ControllersResponse, Error<ApiControllerHealthError>> {
245    let local_var_configuration = configuration;
246
247    // unbox the parameters
248
249
250    let local_var_client = &local_var_configuration.client;
251
252    let local_var_uri_str = format!("{}/api/health", local_var_configuration.base_path);
253    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
254
255    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
256        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
257    }
258
259    let local_var_req = local_var_req_builder.build()?;
260    let local_var_resp = local_var_client.execute(local_var_req).await?;
261
262    let local_var_status = local_var_resp.status();
263    let local_var_content = local_var_resp.text().await?;
264
265    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
266        serde_json::from_str(&local_var_content).map_err(Error::from)
267    } else {
268        let local_var_entity: Option<ApiControllerHealthError> = serde_json::from_str(&local_var_content).ok();
269        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
270        Err(Error::ResponseError(local_var_error))
271    }
272}
273