radarr_api_rs/apis/
naming_config_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 crate::models::ColonReplacementFormat;
16use super::{Error, configuration};
17
18
19/// struct for typed errors of method [`api_v3_config_naming_examples_get`]
20#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(untagged)]
22pub enum ApiV3ConfigNamingExamplesGetError {
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`api_v3_config_naming_get`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum ApiV3ConfigNamingGetError {
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method [`api_v3_config_naming_id_get`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum ApiV3ConfigNamingIdGetError {
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`api_v3_config_naming_id_put`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum ApiV3ConfigNamingIdPutError {
44    UnknownValue(serde_json::Value),
45}
46
47
48pub async fn api_v3_config_naming_examples_get(configuration: &configuration::Configuration, rename_movies: Option<bool>, replace_illegal_characters: Option<bool>, colon_replacement_format: Option<ColonReplacementFormat>, standard_movie_format: Option<&str>, movie_folder_format: Option<&str>, include_quality: Option<bool>, replace_spaces: Option<bool>, separator: Option<&str>, number_style: Option<&str>, id: Option<i32>, resource_name: Option<&str>) -> Result<(), Error<ApiV3ConfigNamingExamplesGetError>> {
49    let local_var_configuration = configuration;
50
51    let local_var_client = &local_var_configuration.client;
52
53    let local_var_uri_str = format!("{}/api/v3/config/naming/examples", local_var_configuration.base_path);
54    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
55
56    if let Some(ref local_var_str) = rename_movies {
57        local_var_req_builder = local_var_req_builder.query(&[("renameMovies", &local_var_str.to_string())]);
58    }
59    if let Some(ref local_var_str) = replace_illegal_characters {
60        local_var_req_builder = local_var_req_builder.query(&[("replaceIllegalCharacters", &local_var_str.to_string())]);
61    }
62    if let Some(ref local_var_str) = colon_replacement_format {
63        local_var_req_builder = local_var_req_builder.query(&[("colonReplacementFormat", &local_var_str.to_string())]);
64    }
65    if let Some(ref local_var_str) = standard_movie_format {
66        local_var_req_builder = local_var_req_builder.query(&[("standardMovieFormat", &local_var_str.to_string())]);
67    }
68    if let Some(ref local_var_str) = movie_folder_format {
69        local_var_req_builder = local_var_req_builder.query(&[("movieFolderFormat", &local_var_str.to_string())]);
70    }
71    if let Some(ref local_var_str) = include_quality {
72        local_var_req_builder = local_var_req_builder.query(&[("includeQuality", &local_var_str.to_string())]);
73    }
74    if let Some(ref local_var_str) = replace_spaces {
75        local_var_req_builder = local_var_req_builder.query(&[("replaceSpaces", &local_var_str.to_string())]);
76    }
77    if let Some(ref local_var_str) = separator {
78        local_var_req_builder = local_var_req_builder.query(&[("separator", &local_var_str.to_string())]);
79    }
80    if let Some(ref local_var_str) = number_style {
81        local_var_req_builder = local_var_req_builder.query(&[("numberStyle", &local_var_str.to_string())]);
82    }
83    if let Some(ref local_var_str) = id {
84        local_var_req_builder = local_var_req_builder.query(&[("id", &local_var_str.to_string())]);
85    }
86    if let Some(ref local_var_str) = resource_name {
87        local_var_req_builder = local_var_req_builder.query(&[("resourceName", &local_var_str.to_string())]);
88    }
89    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
90        let local_var_key = local_var_apikey.key.clone();
91        let local_var_value = match local_var_apikey.prefix {
92            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
93            None => local_var_key,
94        };
95        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
96    }
97    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
98        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
99    }
100    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
101        let local_var_key = local_var_apikey.key.clone();
102        let local_var_value = match local_var_apikey.prefix {
103            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
104            None => local_var_key,
105        };
106        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
107    };
108
109    let local_var_req = local_var_req_builder.build()?;
110    let local_var_resp = local_var_client.execute(local_var_req).await?;
111
112    let local_var_status = local_var_resp.status();
113    let local_var_content = local_var_resp.text().await?;
114
115    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
116        Ok(())
117    } else {
118        let local_var_entity: Option<ApiV3ConfigNamingExamplesGetError> = serde_json::from_str(&local_var_content).ok();
119        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
120        Err(Error::ResponseError(local_var_error))
121    }
122}
123
124pub async fn api_v3_config_naming_get(configuration: &configuration::Configuration, ) -> Result<crate::models::NamingConfigResource, Error<ApiV3ConfigNamingGetError>> {
125    let local_var_configuration = configuration;
126
127    let local_var_client = &local_var_configuration.client;
128
129    let local_var_uri_str = format!("{}/api/v3/config/naming", local_var_configuration.base_path);
130    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
131
132    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
133        let local_var_key = local_var_apikey.key.clone();
134        let local_var_value = match local_var_apikey.prefix {
135            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
136            None => local_var_key,
137        };
138        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
139    }
140    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
141        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
142    }
143    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
144        let local_var_key = local_var_apikey.key.clone();
145        let local_var_value = match local_var_apikey.prefix {
146            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
147            None => local_var_key,
148        };
149        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
150    };
151
152    let local_var_req = local_var_req_builder.build()?;
153    let local_var_resp = local_var_client.execute(local_var_req).await?;
154
155    let local_var_status = local_var_resp.status();
156    let local_var_content = local_var_resp.text().await?;
157
158    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
159        serde_json::from_str(&local_var_content).map_err(Error::from)
160    } else {
161        let local_var_entity: Option<ApiV3ConfigNamingGetError> = serde_json::from_str(&local_var_content).ok();
162        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
163        Err(Error::ResponseError(local_var_error))
164    }
165}
166
167pub async fn api_v3_config_naming_id_get(configuration: &configuration::Configuration, id: i32) -> Result<crate::models::NamingConfigResource, Error<ApiV3ConfigNamingIdGetError>> {
168    let local_var_configuration = configuration;
169
170    let local_var_client = &local_var_configuration.client;
171
172    let local_var_uri_str = format!("{}/api/v3/config/naming/{id}", local_var_configuration.base_path, id=id);
173    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
174
175    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
176        let local_var_key = local_var_apikey.key.clone();
177        let local_var_value = match local_var_apikey.prefix {
178            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
179            None => local_var_key,
180        };
181        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
182    }
183    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
184        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
185    }
186    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
187        let local_var_key = local_var_apikey.key.clone();
188        let local_var_value = match local_var_apikey.prefix {
189            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
190            None => local_var_key,
191        };
192        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
193    };
194
195    let local_var_req = local_var_req_builder.build()?;
196    let local_var_resp = local_var_client.execute(local_var_req).await?;
197
198    let local_var_status = local_var_resp.status();
199    let local_var_content = local_var_resp.text().await?;
200
201    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
202        serde_json::from_str(&local_var_content).map_err(Error::from)
203    } else {
204        let local_var_entity: Option<ApiV3ConfigNamingIdGetError> = serde_json::from_str(&local_var_content).ok();
205        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
206        Err(Error::ResponseError(local_var_error))
207    }
208}
209
210pub async fn api_v3_config_naming_id_put(configuration: &configuration::Configuration, id: &str, naming_config_resource: Option<crate::models::NamingConfigResource>) -> Result<crate::models::NamingConfigResource, Error<ApiV3ConfigNamingIdPutError>> {
211    let local_var_configuration = configuration;
212
213    let local_var_client = &local_var_configuration.client;
214
215    let local_var_uri_str = format!("{}/api/v3/config/naming/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
216    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
217
218    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
219        let local_var_key = local_var_apikey.key.clone();
220        let local_var_value = match local_var_apikey.prefix {
221            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
222            None => local_var_key,
223        };
224        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
225    }
226    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
227        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
228    }
229    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
230        let local_var_key = local_var_apikey.key.clone();
231        let local_var_value = match local_var_apikey.prefix {
232            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
233            None => local_var_key,
234        };
235        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
236    };
237    local_var_req_builder = local_var_req_builder.json(&naming_config_resource);
238
239    let local_var_req = local_var_req_builder.build()?;
240    let local_var_resp = local_var_client.execute(local_var_req).await?;
241
242    let local_var_status = local_var_resp.status();
243    let local_var_content = local_var_resp.text().await?;
244
245    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
246        serde_json::from_str(&local_var_content).map_err(Error::from)
247    } else {
248        let local_var_entity: Option<ApiV3ConfigNamingIdPutError> = serde_json::from_str(&local_var_content).ok();
249        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
250        Err(Error::ResponseError(local_var_error))
251    }
252}
253