radarr_api_rs/apis/
import_exclusions_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_exclusions_bulk_post`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ApiV3ExclusionsBulkPostError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`api_v3_exclusions_get`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ApiV3ExclusionsGetError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`api_v3_exclusions_id_delete`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ApiV3ExclusionsIdDeleteError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`api_v3_exclusions_id_get`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ApiV3ExclusionsIdGetError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`api_v3_exclusions_id_put`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ApiV3ExclusionsIdPutError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`api_v3_exclusions_post`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ApiV3ExclusionsPostError {
57    UnknownValue(serde_json::Value),
58}
59
60
61pub async fn api_v3_exclusions_bulk_post(configuration: &configuration::Configuration, import_exclusions_resource: Option<Vec<crate::models::ImportExclusionsResource>>) -> Result<(), Error<ApiV3ExclusionsBulkPostError>> {
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/exclusions/bulk", local_var_configuration.base_path);
67    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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    local_var_req_builder = local_var_req_builder.json(&import_exclusions_resource);
89
90    let local_var_req = local_var_req_builder.build()?;
91    let local_var_resp = local_var_client.execute(local_var_req).await?;
92
93    let local_var_status = local_var_resp.status();
94    let local_var_content = local_var_resp.text().await?;
95
96    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
97        Ok(())
98    } else {
99        let local_var_entity: Option<ApiV3ExclusionsBulkPostError> = serde_json::from_str(&local_var_content).ok();
100        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
101        Err(Error::ResponseError(local_var_error))
102    }
103}
104
105pub async fn api_v3_exclusions_get(configuration: &configuration::Configuration, ) -> Result<Vec<crate::models::ImportExclusionsResource>, Error<ApiV3ExclusionsGetError>> {
106    let local_var_configuration = configuration;
107
108    let local_var_client = &local_var_configuration.client;
109
110    let local_var_uri_str = format!("{}/api/v3/exclusions", local_var_configuration.base_path);
111    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
112
113    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
114        let local_var_key = local_var_apikey.key.clone();
115        let local_var_value = match local_var_apikey.prefix {
116            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
117            None => local_var_key,
118        };
119        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
120    }
121    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
122        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
123    }
124    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
125        let local_var_key = local_var_apikey.key.clone();
126        let local_var_value = match local_var_apikey.prefix {
127            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
128            None => local_var_key,
129        };
130        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
131    };
132
133    let local_var_req = local_var_req_builder.build()?;
134    let local_var_resp = local_var_client.execute(local_var_req).await?;
135
136    let local_var_status = local_var_resp.status();
137    let local_var_content = local_var_resp.text().await?;
138
139    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
140        serde_json::from_str(&local_var_content).map_err(Error::from)
141    } else {
142        let local_var_entity: Option<ApiV3ExclusionsGetError> = serde_json::from_str(&local_var_content).ok();
143        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
144        Err(Error::ResponseError(local_var_error))
145    }
146}
147
148pub async fn api_v3_exclusions_id_delete(configuration: &configuration::Configuration, id: i32) -> Result<(), Error<ApiV3ExclusionsIdDeleteError>> {
149    let local_var_configuration = configuration;
150
151    let local_var_client = &local_var_configuration.client;
152
153    let local_var_uri_str = format!("{}/api/v3/exclusions/{id}", local_var_configuration.base_path, id=id);
154    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
155
156    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
157        let local_var_key = local_var_apikey.key.clone();
158        let local_var_value = match local_var_apikey.prefix {
159            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
160            None => local_var_key,
161        };
162        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
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    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
168        let local_var_key = local_var_apikey.key.clone();
169        let local_var_value = match local_var_apikey.prefix {
170            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
171            None => local_var_key,
172        };
173        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
174    };
175
176    let local_var_req = local_var_req_builder.build()?;
177    let local_var_resp = local_var_client.execute(local_var_req).await?;
178
179    let local_var_status = local_var_resp.status();
180    let local_var_content = local_var_resp.text().await?;
181
182    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
183        Ok(())
184    } else {
185        let local_var_entity: Option<ApiV3ExclusionsIdDeleteError> = serde_json::from_str(&local_var_content).ok();
186        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
187        Err(Error::ResponseError(local_var_error))
188    }
189}
190
191pub async fn api_v3_exclusions_id_get(configuration: &configuration::Configuration, id: i32) -> Result<crate::models::ImportExclusionsResource, Error<ApiV3ExclusionsIdGetError>> {
192    let local_var_configuration = configuration;
193
194    let local_var_client = &local_var_configuration.client;
195
196    let local_var_uri_str = format!("{}/api/v3/exclusions/{id}", local_var_configuration.base_path, id=id);
197    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
198
199    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
200        let local_var_key = local_var_apikey.key.clone();
201        let local_var_value = match local_var_apikey.prefix {
202            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
203            None => local_var_key,
204        };
205        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
206    }
207    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
208        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
209    }
210    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
211        let local_var_key = local_var_apikey.key.clone();
212        let local_var_value = match local_var_apikey.prefix {
213            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
214            None => local_var_key,
215        };
216        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
217    };
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<ApiV3ExclusionsIdGetError> = 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_exclusions_id_put(configuration: &configuration::Configuration, id: &str, import_exclusions_resource: Option<crate::models::ImportExclusionsResource>) -> Result<crate::models::ImportExclusionsResource, Error<ApiV3ExclusionsIdPutError>> {
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/exclusions/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
240    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, 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(&import_exclusions_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<ApiV3ExclusionsIdPutError> = 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_exclusions_post(configuration: &configuration::Configuration, import_exclusions_resource: Option<crate::models::ImportExclusionsResource>) -> Result<crate::models::ImportExclusionsResource, Error<ApiV3ExclusionsPostError>> {
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/exclusions", local_var_configuration.base_path);
284    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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    local_var_req_builder = local_var_req_builder.json(&import_exclusions_resource);
306
307    let local_var_req = local_var_req_builder.build()?;
308    let local_var_resp = local_var_client.execute(local_var_req).await?;
309
310    let local_var_status = local_var_resp.status();
311    let local_var_content = local_var_resp.text().await?;
312
313    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
314        serde_json::from_str(&local_var_content).map_err(Error::from)
315    } else {
316        let local_var_entity: Option<ApiV3ExclusionsPostError> = serde_json::from_str(&local_var_content).ok();
317        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
318        Err(Error::ResponseError(local_var_error))
319    }
320}
321