sonarr_api_rs/apis/
delay_profile_api.rs

1/*
2 * Sonarr
3 *
4 * Sonarr API docs - The v3 API docs apply to both v3 and v4 versions of Sonarr. Some functionality may only be available in v4 of the Sonarr application.
5 *
6 * The version of the OpenAPI document: 3.0.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`api_v3_delayprofile_get`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ApiV3DelayprofileGetError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`api_v3_delayprofile_id_delete`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ApiV3DelayprofileIdDeleteError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`api_v3_delayprofile_id_get`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ApiV3DelayprofileIdGetError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`api_v3_delayprofile_id_put`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ApiV3DelayprofileIdPutError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`api_v3_delayprofile_post`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ApiV3DelayprofilePostError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`api_v3_delayprofile_reorder_id_put`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ApiV3DelayprofileReorderIdPutError {
57    UnknownValue(serde_json::Value),
58}
59
60
61pub async fn api_v3_delayprofile_get(configuration: &configuration::Configuration, ) -> Result<Vec<models::DelayProfileResource>, Error<ApiV3DelayprofileGetError>> {
62    let local_var_configuration = configuration;
63
64    let local_var_client = &local_var_configuration.client;
65
66    let local_var_uri_str = format!("{}/api/v3/delayprofile", local_var_configuration.base_path);
67    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
68
69    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
70        let local_var_key = local_var_apikey.key.clone();
71        let local_var_value = match local_var_apikey.prefix {
72            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
73            None => local_var_key,
74        };
75        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
76    }
77    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
78        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
79    }
80    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
81        let local_var_key = local_var_apikey.key.clone();
82        let local_var_value = match local_var_apikey.prefix {
83            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
84            None => local_var_key,
85        };
86        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
87    };
88
89    let local_var_req = local_var_req_builder.build()?;
90    let local_var_resp = local_var_client.execute(local_var_req).await?;
91
92    let local_var_status = local_var_resp.status();
93    let local_var_content = local_var_resp.text().await?;
94
95    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
96        serde_json::from_str(&local_var_content).map_err(Error::from)
97    } else {
98        let local_var_entity: Option<ApiV3DelayprofileGetError> = serde_json::from_str(&local_var_content).ok();
99        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
100        Err(Error::ResponseError(local_var_error))
101    }
102}
103
104pub async fn api_v3_delayprofile_id_delete(configuration: &configuration::Configuration, id: i32) -> Result<(), Error<ApiV3DelayprofileIdDeleteError>> {
105    let local_var_configuration = configuration;
106
107    let local_var_client = &local_var_configuration.client;
108
109    let local_var_uri_str = format!("{}/api/v3/delayprofile/{id}", local_var_configuration.base_path, id=id);
110    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
111
112    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
113        let local_var_key = local_var_apikey.key.clone();
114        let local_var_value = match local_var_apikey.prefix {
115            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
116            None => local_var_key,
117        };
118        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
119    }
120    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
121        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
122    }
123    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
124        let local_var_key = local_var_apikey.key.clone();
125        let local_var_value = match local_var_apikey.prefix {
126            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
127            None => local_var_key,
128        };
129        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
130    };
131
132    let local_var_req = local_var_req_builder.build()?;
133    let local_var_resp = local_var_client.execute(local_var_req).await?;
134
135    let local_var_status = local_var_resp.status();
136    let local_var_content = local_var_resp.text().await?;
137
138    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
139        Ok(())
140    } else {
141        let local_var_entity: Option<ApiV3DelayprofileIdDeleteError> = serde_json::from_str(&local_var_content).ok();
142        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
143        Err(Error::ResponseError(local_var_error))
144    }
145}
146
147pub async fn api_v3_delayprofile_id_get(configuration: &configuration::Configuration, id: i32) -> Result<models::DelayProfileResource, Error<ApiV3DelayprofileIdGetError>> {
148    let local_var_configuration = configuration;
149
150    let local_var_client = &local_var_configuration.client;
151
152    let local_var_uri_str = format!("{}/api/v3/delayprofile/{id}", local_var_configuration.base_path, id=id);
153    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
154
155    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
156        let local_var_key = local_var_apikey.key.clone();
157        let local_var_value = match local_var_apikey.prefix {
158            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
159            None => local_var_key,
160        };
161        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
162    }
163    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
164        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
165    }
166    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
167        let local_var_key = local_var_apikey.key.clone();
168        let local_var_value = match local_var_apikey.prefix {
169            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
170            None => local_var_key,
171        };
172        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
173    };
174
175    let local_var_req = local_var_req_builder.build()?;
176    let local_var_resp = local_var_client.execute(local_var_req).await?;
177
178    let local_var_status = local_var_resp.status();
179    let local_var_content = local_var_resp.text().await?;
180
181    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
182        serde_json::from_str(&local_var_content).map_err(Error::from)
183    } else {
184        let local_var_entity: Option<ApiV3DelayprofileIdGetError> = serde_json::from_str(&local_var_content).ok();
185        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
186        Err(Error::ResponseError(local_var_error))
187    }
188}
189
190pub async fn api_v3_delayprofile_id_put(configuration: &configuration::Configuration, id: &str, delay_profile_resource: Option<models::DelayProfileResource>) -> Result<models::DelayProfileResource, Error<ApiV3DelayprofileIdPutError>> {
191    let local_var_configuration = configuration;
192
193    let local_var_client = &local_var_configuration.client;
194
195    let local_var_uri_str = format!("{}/api/v3/delayprofile/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
196    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
197
198    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
199        let local_var_key = local_var_apikey.key.clone();
200        let local_var_value = match local_var_apikey.prefix {
201            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
202            None => local_var_key,
203        };
204        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
205    }
206    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
207        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
208    }
209    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
210        let local_var_key = local_var_apikey.key.clone();
211        let local_var_value = match local_var_apikey.prefix {
212            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
213            None => local_var_key,
214        };
215        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
216    };
217    local_var_req_builder = local_var_req_builder.json(&delay_profile_resource);
218
219    let local_var_req = local_var_req_builder.build()?;
220    let local_var_resp = local_var_client.execute(local_var_req).await?;
221
222    let local_var_status = local_var_resp.status();
223    let local_var_content = local_var_resp.text().await?;
224
225    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
226        serde_json::from_str(&local_var_content).map_err(Error::from)
227    } else {
228        let local_var_entity: Option<ApiV3DelayprofileIdPutError> = serde_json::from_str(&local_var_content).ok();
229        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
230        Err(Error::ResponseError(local_var_error))
231    }
232}
233
234pub async fn api_v3_delayprofile_post(configuration: &configuration::Configuration, delay_profile_resource: Option<models::DelayProfileResource>) -> Result<models::DelayProfileResource, Error<ApiV3DelayprofilePostError>> {
235    let local_var_configuration = configuration;
236
237    let local_var_client = &local_var_configuration.client;
238
239    let local_var_uri_str = format!("{}/api/v3/delayprofile", local_var_configuration.base_path);
240    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
241
242    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
243        let local_var_key = local_var_apikey.key.clone();
244        let local_var_value = match local_var_apikey.prefix {
245            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
246            None => local_var_key,
247        };
248        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
249    }
250    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
251        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
252    }
253    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
254        let local_var_key = local_var_apikey.key.clone();
255        let local_var_value = match local_var_apikey.prefix {
256            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
257            None => local_var_key,
258        };
259        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
260    };
261    local_var_req_builder = local_var_req_builder.json(&delay_profile_resource);
262
263    let local_var_req = local_var_req_builder.build()?;
264    let local_var_resp = local_var_client.execute(local_var_req).await?;
265
266    let local_var_status = local_var_resp.status();
267    let local_var_content = local_var_resp.text().await?;
268
269    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
270        serde_json::from_str(&local_var_content).map_err(Error::from)
271    } else {
272        let local_var_entity: Option<ApiV3DelayprofilePostError> = serde_json::from_str(&local_var_content).ok();
273        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
274        Err(Error::ResponseError(local_var_error))
275    }
276}
277
278pub async fn api_v3_delayprofile_reorder_id_put(configuration: &configuration::Configuration, id: i32, after: Option<i32>) -> Result<Vec<models::DelayProfileResource>, Error<ApiV3DelayprofileReorderIdPutError>> {
279    let local_var_configuration = configuration;
280
281    let local_var_client = &local_var_configuration.client;
282
283    let local_var_uri_str = format!("{}/api/v3/delayprofile/reorder/{id}", local_var_configuration.base_path, id=id);
284    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
285
286    if let Some(ref local_var_str) = after {
287        local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]);
288    }
289    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
290        let local_var_key = local_var_apikey.key.clone();
291        let local_var_value = match local_var_apikey.prefix {
292            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
293            None => local_var_key,
294        };
295        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
296    }
297    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
298        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
299    }
300    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
301        let local_var_key = local_var_apikey.key.clone();
302        let local_var_value = match local_var_apikey.prefix {
303            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
304            None => local_var_key,
305        };
306        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
307    };
308
309    let local_var_req = local_var_req_builder.build()?;
310    let local_var_resp = local_var_client.execute(local_var_req).await?;
311
312    let local_var_status = local_var_resp.status();
313    let local_var_content = local_var_resp.text().await?;
314
315    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
316        serde_json::from_str(&local_var_content).map_err(Error::from)
317    } else {
318        let local_var_entity: Option<ApiV3DelayprofileReorderIdPutError> = serde_json::from_str(&local_var_content).ok();
319        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
320        Err(Error::ResponseError(local_var_error))
321    }
322}
323