sonarr_api_rs/apis/
file_system_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_filesystem_get`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ApiV3FilesystemGetError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`api_v3_filesystem_mediafiles_get`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ApiV3FilesystemMediafilesGetError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`api_v3_filesystem_type_get`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ApiV3FilesystemTypeGetError {
36    UnknownValue(serde_json::Value),
37}
38
39
40pub async fn api_v3_filesystem_get(configuration: &configuration::Configuration, path: Option<&str>, include_files: Option<bool>, allow_folders_without_trailing_slashes: Option<bool>) -> Result<(), Error<ApiV3FilesystemGetError>> {
41    let local_var_configuration = configuration;
42
43    let local_var_client = &local_var_configuration.client;
44
45    let local_var_uri_str = format!("{}/api/v3/filesystem", local_var_configuration.base_path);
46    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
47
48    if let Some(ref local_var_str) = path {
49        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
50    }
51    if let Some(ref local_var_str) = include_files {
52        local_var_req_builder = local_var_req_builder.query(&[("includeFiles", &local_var_str.to_string())]);
53    }
54    if let Some(ref local_var_str) = allow_folders_without_trailing_slashes {
55        local_var_req_builder = local_var_req_builder.query(&[("allowFoldersWithoutTrailingSlashes", &local_var_str.to_string())]);
56    }
57    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
58        let local_var_key = local_var_apikey.key.clone();
59        let local_var_value = match local_var_apikey.prefix {
60            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
61            None => local_var_key,
62        };
63        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
64    }
65    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
66        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
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.header("X-Api-Key", local_var_value);
75    };
76
77    let local_var_req = local_var_req_builder.build()?;
78    let local_var_resp = local_var_client.execute(local_var_req).await?;
79
80    let local_var_status = local_var_resp.status();
81    let local_var_content = local_var_resp.text().await?;
82
83    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
84        Ok(())
85    } else {
86        let local_var_entity: Option<ApiV3FilesystemGetError> = serde_json::from_str(&local_var_content).ok();
87        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
88        Err(Error::ResponseError(local_var_error))
89    }
90}
91
92pub async fn api_v3_filesystem_mediafiles_get(configuration: &configuration::Configuration, path: Option<&str>) -> Result<(), Error<ApiV3FilesystemMediafilesGetError>> {
93    let local_var_configuration = configuration;
94
95    let local_var_client = &local_var_configuration.client;
96
97    let local_var_uri_str = format!("{}/api/v3/filesystem/mediafiles", local_var_configuration.base_path);
98    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
99
100    if let Some(ref local_var_str) = path {
101        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
102    }
103    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
104        let local_var_key = local_var_apikey.key.clone();
105        let local_var_value = match local_var_apikey.prefix {
106            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
107            None => local_var_key,
108        };
109        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
110    }
111    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
112        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
113    }
114    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
115        let local_var_key = local_var_apikey.key.clone();
116        let local_var_value = match local_var_apikey.prefix {
117            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
118            None => local_var_key,
119        };
120        local_var_req_builder = local_var_req_builder.header("X-Api-Key", local_var_value);
121    };
122
123    let local_var_req = local_var_req_builder.build()?;
124    let local_var_resp = local_var_client.execute(local_var_req).await?;
125
126    let local_var_status = local_var_resp.status();
127    let local_var_content = local_var_resp.text().await?;
128
129    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
130        Ok(())
131    } else {
132        let local_var_entity: Option<ApiV3FilesystemMediafilesGetError> = serde_json::from_str(&local_var_content).ok();
133        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
134        Err(Error::ResponseError(local_var_error))
135    }
136}
137
138pub async fn api_v3_filesystem_type_get(configuration: &configuration::Configuration, path: Option<&str>) -> Result<(), Error<ApiV3FilesystemTypeGetError>> {
139    let local_var_configuration = configuration;
140
141    let local_var_client = &local_var_configuration.client;
142
143    let local_var_uri_str = format!("{}/api/v3/filesystem/type", local_var_configuration.base_path);
144    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
145
146    if let Some(ref local_var_str) = path {
147        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
148    }
149    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
150        let local_var_key = local_var_apikey.key.clone();
151        let local_var_value = match local_var_apikey.prefix {
152            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
153            None => local_var_key,
154        };
155        local_var_req_builder = local_var_req_builder.query(&[("apikey", local_var_value)]);
156    }
157    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
158        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
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.header("X-Api-Key", local_var_value);
167    };
168
169    let local_var_req = local_var_req_builder.build()?;
170    let local_var_resp = local_var_client.execute(local_var_req).await?;
171
172    let local_var_status = local_var_resp.status();
173    let local_var_content = local_var_resp.text().await?;
174
175    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
176        Ok(())
177    } else {
178        let local_var_entity: Option<ApiV3FilesystemTypeGetError> = serde_json::from_str(&local_var_content).ok();
179        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
180        Err(Error::ResponseError(local_var_error))
181    }
182}
183