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