radarr_api_rs/apis/
system_api.rs

1/*
2 * Radarr
3 *
4 * Radarr API docs
5 *
6 * The version of the OpenAPI document: 3.0.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`api_v3_system_restart_post`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ApiV3SystemRestartPostError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`api_v3_system_routes_duplicate_get`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ApiV3SystemRoutesDuplicateGetError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`api_v3_system_routes_get`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ApiV3SystemRoutesGetError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`api_v3_system_shutdown_post`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ApiV3SystemShutdownPostError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`api_v3_system_status_get`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ApiV3SystemStatusGetError {
50    UnknownValue(serde_json::Value),
51}
52
53
54pub async fn api_v3_system_restart_post(configuration: &configuration::Configuration, ) -> Result<(), Error<ApiV3SystemRestartPostError>> {
55    let local_var_configuration = configuration;
56
57    let local_var_client = &local_var_configuration.client;
58
59    let local_var_uri_str = format!("{}/api/v3/system/restart", local_var_configuration.base_path);
60    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
61
62    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
63        let local_var_key = local_var_apikey.key.clone();
64        let local_var_value = match local_var_apikey.prefix {
65            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
66            None => local_var_key,
67        };
68        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
69    }
70    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
71        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
72    }
73    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
74        let local_var_key = local_var_apikey.key.clone();
75        let local_var_value = match local_var_apikey.prefix {
76            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
77            None => local_var_key,
78        };
79        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
80    };
81
82    let local_var_req = local_var_req_builder.build()?;
83    let local_var_resp = local_var_client.execute(local_var_req).await?;
84
85    let local_var_status = local_var_resp.status();
86    let local_var_content = local_var_resp.text().await?;
87
88    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
89        Ok(())
90    } else {
91        let local_var_entity: Option<ApiV3SystemRestartPostError> = serde_json::from_str(&local_var_content).ok();
92        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
93        Err(Error::ResponseError(local_var_error))
94    }
95}
96
97pub async fn api_v3_system_routes_duplicate_get(configuration: &configuration::Configuration, ) -> Result<(), Error<ApiV3SystemRoutesDuplicateGetError>> {
98    let local_var_configuration = configuration;
99
100    let local_var_client = &local_var_configuration.client;
101
102    let local_var_uri_str = format!("{}/api/v3/system/routes/duplicate", local_var_configuration.base_path);
103    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
104
105    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
106        let local_var_key = local_var_apikey.key.clone();
107        let local_var_value = match local_var_apikey.prefix {
108            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
109            None => local_var_key,
110        };
111        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
112    }
113    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
114        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
115    }
116    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
117        let local_var_key = local_var_apikey.key.clone();
118        let local_var_value = match local_var_apikey.prefix {
119            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
120            None => local_var_key,
121        };
122        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
123    };
124
125    let local_var_req = local_var_req_builder.build()?;
126    let local_var_resp = local_var_client.execute(local_var_req).await?;
127
128    let local_var_status = local_var_resp.status();
129    let local_var_content = local_var_resp.text().await?;
130
131    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
132        Ok(())
133    } else {
134        let local_var_entity: Option<ApiV3SystemRoutesDuplicateGetError> = serde_json::from_str(&local_var_content).ok();
135        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
136        Err(Error::ResponseError(local_var_error))
137    }
138}
139
140pub async fn api_v3_system_routes_get(configuration: &configuration::Configuration, ) -> Result<(), Error<ApiV3SystemRoutesGetError>> {
141    let local_var_configuration = configuration;
142
143    let local_var_client = &local_var_configuration.client;
144
145    let local_var_uri_str = format!("{}/api/v3/system/routes", local_var_configuration.base_path);
146    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
147
148    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
149        let local_var_key = local_var_apikey.key.clone();
150        let local_var_value = match local_var_apikey.prefix {
151            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
152            None => local_var_key,
153        };
154        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
155    }
156    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
157        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
158    }
159    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
160        let local_var_key = local_var_apikey.key.clone();
161        let local_var_value = match local_var_apikey.prefix {
162            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
163            None => local_var_key,
164        };
165        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
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        Ok(())
176    } else {
177        let local_var_entity: Option<ApiV3SystemRoutesGetError> = 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 api_v3_system_shutdown_post(configuration: &configuration::Configuration, ) -> Result<(), Error<ApiV3SystemShutdownPostError>> {
184    let local_var_configuration = configuration;
185
186    let local_var_client = &local_var_configuration.client;
187
188    let local_var_uri_str = format!("{}/api/v3/system/shutdown", local_var_configuration.base_path);
189    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
190
191    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
192        let local_var_key = local_var_apikey.key.clone();
193        let local_var_value = match local_var_apikey.prefix {
194            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
195            None => local_var_key,
196        };
197        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
198    }
199    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
200        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
201    }
202    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
203        let local_var_key = local_var_apikey.key.clone();
204        let local_var_value = match local_var_apikey.prefix {
205            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
206            None => local_var_key,
207        };
208        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
209    };
210
211    let local_var_req = local_var_req_builder.build()?;
212    let local_var_resp = local_var_client.execute(local_var_req).await?;
213
214    let local_var_status = local_var_resp.status();
215    let local_var_content = local_var_resp.text().await?;
216
217    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
218        Ok(())
219    } else {
220        let local_var_entity: Option<ApiV3SystemShutdownPostError> = serde_json::from_str(&local_var_content).ok();
221        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
222        Err(Error::ResponseError(local_var_error))
223    }
224}
225
226pub async fn api_v3_system_status_get(configuration: &configuration::Configuration, ) -> Result<crate::models::SystemResource, Error<ApiV3SystemStatusGetError>> {
227    let local_var_configuration = configuration;
228
229    let local_var_client = &local_var_configuration.client;
230
231    let local_var_uri_str = format!("{}/api/v3/system/status", local_var_configuration.base_path);
232    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
233
234    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
235        let local_var_key = local_var_apikey.key.clone();
236        let local_var_value = match local_var_apikey.prefix {
237            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
238            None => local_var_key,
239        };
240        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
241    }
242    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
243        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
244    }
245    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
246        let local_var_key = local_var_apikey.key.clone();
247        let local_var_value = match local_var_apikey.prefix {
248            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
249            None => local_var_key,
250        };
251        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
252    };
253
254    let local_var_req = local_var_req_builder.build()?;
255    let local_var_resp = local_var_client.execute(local_var_req).await?;
256
257    let local_var_status = local_var_resp.status();
258    let local_var_content = local_var_resp.text().await?;
259
260    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
261        serde_json::from_str(&local_var_content).map_err(Error::from)
262    } else {
263        let local_var_entity: Option<ApiV3SystemStatusGetError> = serde_json::from_str(&local_var_content).ok();
264        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
265        Err(Error::ResponseError(local_var_error))
266    }
267}
268