radarr_api_rs/apis/
movie_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_movie_get`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ApiV3MovieGetError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`api_v3_movie_id_delete`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ApiV3MovieIdDeleteError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`api_v3_movie_id_get`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ApiV3MovieIdGetError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`api_v3_movie_id_put`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ApiV3MovieIdPutError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`api_v3_movie_post`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ApiV3MoviePostError {
50    UnknownValue(serde_json::Value),
51}
52
53
54pub async fn api_v3_movie_get(configuration: &configuration::Configuration, tmdb_id: Option<i32>, exclude_local_covers: Option<bool>) -> Result<Vec<crate::models::MovieResource>, Error<ApiV3MovieGetError>> {
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/movie", local_var_configuration.base_path);
60    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
61
62    if let Some(ref local_var_str) = tmdb_id {
63        local_var_req_builder = local_var_req_builder.query(&[("tmdbId", &local_var_str.to_string())]);
64    }
65    if let Some(ref local_var_str) = exclude_local_covers {
66        local_var_req_builder = local_var_req_builder.query(&[("excludeLocalCovers", &local_var_str.to_string())]);
67    }
68    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
69        let local_var_key = local_var_apikey.key.clone();
70        let local_var_value = match local_var_apikey.prefix {
71            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
72            None => local_var_key,
73        };
74        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
75    }
76    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
77        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
78    }
79    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
80        let local_var_key = local_var_apikey.key.clone();
81        let local_var_value = match local_var_apikey.prefix {
82            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
83            None => local_var_key,
84        };
85        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
86    };
87
88    let local_var_req = local_var_req_builder.build()?;
89    let local_var_resp = local_var_client.execute(local_var_req).await?;
90
91    let local_var_status = local_var_resp.status();
92    let local_var_content = local_var_resp.text().await?;
93
94    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
95        serde_json::from_str(&local_var_content).map_err(Error::from)
96    } else {
97        let local_var_entity: Option<ApiV3MovieGetError> = serde_json::from_str(&local_var_content).ok();
98        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
99        Err(Error::ResponseError(local_var_error))
100    }
101}
102
103pub async fn api_v3_movie_id_delete(configuration: &configuration::Configuration, id: i32, delete_files: Option<bool>, add_import_exclusion: Option<bool>) -> Result<(), Error<ApiV3MovieIdDeleteError>> {
104    let local_var_configuration = configuration;
105
106    let local_var_client = &local_var_configuration.client;
107
108    let local_var_uri_str = format!("{}/api/v3/movie/{id}", local_var_configuration.base_path, id=id);
109    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
110
111    if let Some(ref local_var_str) = delete_files {
112        local_var_req_builder = local_var_req_builder.query(&[("deleteFiles", &local_var_str.to_string())]);
113    }
114    if let Some(ref local_var_str) = add_import_exclusion {
115        local_var_req_builder = local_var_req_builder.query(&[("addImportExclusion", &local_var_str.to_string())]);
116    }
117    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
118        let local_var_key = local_var_apikey.key.clone();
119        let local_var_value = match local_var_apikey.prefix {
120            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
121            None => local_var_key,
122        };
123        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
124    }
125    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
126        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
127    }
128    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
129        let local_var_key = local_var_apikey.key.clone();
130        let local_var_value = match local_var_apikey.prefix {
131            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
132            None => local_var_key,
133        };
134        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
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        Ok(())
145    } else {
146        let local_var_entity: Option<ApiV3MovieIdDeleteError> = 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
152pub async fn api_v3_movie_id_get(configuration: &configuration::Configuration, id: i32) -> Result<crate::models::MovieResource, Error<ApiV3MovieIdGetError>> {
153    let local_var_configuration = configuration;
154
155    let local_var_client = &local_var_configuration.client;
156
157    let local_var_uri_str = format!("{}/api/v3/movie/{id}", local_var_configuration.base_path, id=id);
158    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
159
160    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
161        let local_var_key = local_var_apikey.key.clone();
162        let local_var_value = match local_var_apikey.prefix {
163            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
164            None => local_var_key,
165        };
166        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
167    }
168    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
169        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
170    }
171    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
172        let local_var_key = local_var_apikey.key.clone();
173        let local_var_value = match local_var_apikey.prefix {
174            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
175            None => local_var_key,
176        };
177        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
178    };
179
180    let local_var_req = local_var_req_builder.build()?;
181    let local_var_resp = local_var_client.execute(local_var_req).await?;
182
183    let local_var_status = local_var_resp.status();
184    let local_var_content = local_var_resp.text().await?;
185
186    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
187        serde_json::from_str(&local_var_content).map_err(Error::from)
188    } else {
189        let local_var_entity: Option<ApiV3MovieIdGetError> = serde_json::from_str(&local_var_content).ok();
190        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
191        Err(Error::ResponseError(local_var_error))
192    }
193}
194
195pub async fn api_v3_movie_id_put(configuration: &configuration::Configuration, id: &str, move_files: Option<bool>, movie_resource: Option<crate::models::MovieResource>) -> Result<crate::models::MovieResource, Error<ApiV3MovieIdPutError>> {
196    let local_var_configuration = configuration;
197
198    let local_var_client = &local_var_configuration.client;
199
200    let local_var_uri_str = format!("{}/api/v3/movie/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
201    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
202
203    if let Some(ref local_var_str) = move_files {
204        local_var_req_builder = local_var_req_builder.query(&[("moveFiles", &local_var_str.to_string())]);
205    }
206    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
207        let local_var_key = local_var_apikey.key.clone();
208        let local_var_value = match local_var_apikey.prefix {
209            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
210            None => local_var_key,
211        };
212        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
213    }
214    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
215        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
216    }
217    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
218        let local_var_key = local_var_apikey.key.clone();
219        let local_var_value = match local_var_apikey.prefix {
220            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
221            None => local_var_key,
222        };
223        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
224    };
225    local_var_req_builder = local_var_req_builder.json(&movie_resource);
226
227    let local_var_req = local_var_req_builder.build()?;
228    let local_var_resp = local_var_client.execute(local_var_req).await?;
229
230    let local_var_status = local_var_resp.status();
231    let local_var_content = local_var_resp.text().await?;
232
233    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
234        serde_json::from_str(&local_var_content).map_err(Error::from)
235    } else {
236        let local_var_entity: Option<ApiV3MovieIdPutError> = serde_json::from_str(&local_var_content).ok();
237        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
238        Err(Error::ResponseError(local_var_error))
239    }
240}
241
242pub async fn api_v3_movie_post(configuration: &configuration::Configuration, movie_resource: Option<crate::models::MovieResource>) -> Result<crate::models::MovieResource, Error<ApiV3MoviePostError>> {
243    let local_var_configuration = configuration;
244
245    let local_var_client = &local_var_configuration.client;
246
247    let local_var_uri_str = format!("{}/api/v3/movie", local_var_configuration.base_path);
248    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
249
250    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
251        let local_var_key = local_var_apikey.key.clone();
252        let local_var_value = match local_var_apikey.prefix {
253            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
254            None => local_var_key,
255        };
256        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
257    }
258    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
259        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
260    }
261    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
262        let local_var_key = local_var_apikey.key.clone();
263        let local_var_value = match local_var_apikey.prefix {
264            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
265            None => local_var_key,
266        };
267        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
268    };
269    local_var_req_builder = local_var_req_builder.json(&movie_resource);
270
271    let local_var_req = local_var_req_builder.build()?;
272    let local_var_resp = local_var_client.execute(local_var_req).await?;
273
274    let local_var_status = local_var_resp.status();
275    let local_var_content = local_var_resp.text().await?;
276
277    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
278        serde_json::from_str(&local_var_content).map_err(Error::from)
279    } else {
280        let local_var_entity: Option<ApiV3MoviePostError> = serde_json::from_str(&local_var_content).ok();
281        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
282        Err(Error::ResponseError(local_var_error))
283    }
284}
285