radarr_api_rs/apis/
custom_format_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_customformat_get`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ApiV3CustomformatGetError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`api_v3_customformat_id_delete`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ApiV3CustomformatIdDeleteError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`api_v3_customformat_id_get`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ApiV3CustomformatIdGetError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`api_v3_customformat_id_put`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ApiV3CustomformatIdPutError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`api_v3_customformat_post`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ApiV3CustomformatPostError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`api_v3_customformat_schema_get`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ApiV3CustomformatSchemaGetError {
57    UnknownValue(serde_json::Value),
58}
59
60
61pub async fn api_v3_customformat_get(configuration: &configuration::Configuration, ) -> Result<Vec<crate::models::CustomFormatResource>, Error<ApiV3CustomformatGetError>> {
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/customformat", 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<ApiV3CustomformatGetError> = 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_customformat_id_delete(configuration: &configuration::Configuration, id: i32) -> Result<(), Error<ApiV3CustomformatIdDeleteError>> {
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/customformat/{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<ApiV3CustomformatIdDeleteError> = 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_customformat_id_get(configuration: &configuration::Configuration, id: i32) -> Result<crate::models::CustomFormatResource, Error<ApiV3CustomformatIdGetError>> {
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/customformat/{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<ApiV3CustomformatIdGetError> = 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_customformat_id_put(configuration: &configuration::Configuration, id: &str, custom_format_resource: Option<crate::models::CustomFormatResource>) -> Result<crate::models::CustomFormatResource, Error<ApiV3CustomformatIdPutError>> {
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/customformat/{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(&custom_format_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<ApiV3CustomformatIdPutError> = 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_customformat_post(configuration: &configuration::Configuration, custom_format_resource: Option<crate::models::CustomFormatResource>) -> Result<crate::models::CustomFormatResource, Error<ApiV3CustomformatPostError>> {
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/customformat", 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(&custom_format_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<ApiV3CustomformatPostError> = 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_customformat_schema_get(configuration: &configuration::Configuration, ) -> Result<(), Error<ApiV3CustomformatSchemaGetError>> {
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/customformat/schema", local_var_configuration.base_path);
284    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
285
286    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
287        let local_var_key = local_var_apikey.key.clone();
288        let local_var_value = match local_var_apikey.prefix {
289            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
290            None => local_var_key,
291        };
292        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
293    }
294    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
295        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
296    }
297    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
298        let local_var_key = local_var_apikey.key.clone();
299        let local_var_value = match local_var_apikey.prefix {
300            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
301            None => local_var_key,
302        };
303        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
304    };
305
306    let local_var_req = local_var_req_builder.build()?;
307    let local_var_resp = local_var_client.execute(local_var_req).await?;
308
309    let local_var_status = local_var_resp.status();
310    let local_var_content = local_var_resp.text().await?;
311
312    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
313        Ok(())
314    } else {
315        let local_var_entity: Option<ApiV3CustomformatSchemaGetError> = serde_json::from_str(&local_var_content).ok();
316        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
317        Err(Error::ResponseError(local_var_error))
318    }
319}
320