windmill_api/apis/
folder_api.rs

1/*
2 * Windmill API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.505.0
7 * Contact: contact@windmill.dev
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 [`add_owner_to_folder`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddOwnerToFolderError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`create_folder`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateFolderError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`delete_folder`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteFolderError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`exists_folder`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ExistsFolderError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_folder`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetFolderError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_folder_usage`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetFolderUsageError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`list_folder_names`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListFolderNamesError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`list_folders`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListFoldersError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`remove_owner_to_folder`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum RemoveOwnerToFolderError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`update_folder`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum UpdateFolderError {
85    UnknownValue(serde_json::Value),
86}
87
88
89pub async fn add_owner_to_folder(configuration: &configuration::Configuration, workspace: &str, name: &str, add_owner_to_folder_request: models::AddOwnerToFolderRequest) -> Result<String, Error<AddOwnerToFolderError>> {
90    let local_var_configuration = configuration;
91
92    let local_var_client = &local_var_configuration.client;
93
94    let local_var_uri_str = format!("{}/w/{workspace}/folders/addowner/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
95    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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_token) = local_var_configuration.bearer_access_token {
101        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
102    };
103    local_var_req_builder = local_var_req_builder.json(&add_owner_to_folder_request);
104
105    let local_var_req = local_var_req_builder.build()?;
106    let local_var_resp = local_var_client.execute(local_var_req).await?;
107
108    let local_var_status = local_var_resp.status();
109    let local_var_content = local_var_resp.text().await?;
110
111    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
112        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
113    } else {
114        let local_var_entity: Option<AddOwnerToFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
115        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
116        Err(Error::ResponseError(local_var_error))
117    }
118}
119
120pub async fn create_folder(configuration: &configuration::Configuration, workspace: &str, create_folder_request: models::CreateFolderRequest) -> Result<String, Error<CreateFolderError>> {
121    let local_var_configuration = configuration;
122
123    let local_var_client = &local_var_configuration.client;
124
125    let local_var_uri_str = format!("{}/w/{workspace}/folders/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
126    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
127
128    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
129        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
130    }
131    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
132        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
133    };
134    local_var_req_builder = local_var_req_builder.json(&create_folder_request);
135
136    let local_var_req = local_var_req_builder.build()?;
137    let local_var_resp = local_var_client.execute(local_var_req).await?;
138
139    let local_var_status = local_var_resp.status();
140    let local_var_content = local_var_resp.text().await?;
141
142    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
143        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
144    } else {
145        let local_var_entity: Option<CreateFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
146        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
147        Err(Error::ResponseError(local_var_error))
148    }
149}
150
151pub async fn delete_folder(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<String, Error<DeleteFolderError>> {
152    let local_var_configuration = configuration;
153
154    let local_var_client = &local_var_configuration.client;
155
156    let local_var_uri_str = format!("{}/w/{workspace}/folders/delete/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
157    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
158
159    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
160        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
161    }
162    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
163        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
164    };
165
166    let local_var_req = local_var_req_builder.build()?;
167    let local_var_resp = local_var_client.execute(local_var_req).await?;
168
169    let local_var_status = local_var_resp.status();
170    let local_var_content = local_var_resp.text().await?;
171
172    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
173        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
174    } else {
175        let local_var_entity: Option<DeleteFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
176        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
177        Err(Error::ResponseError(local_var_error))
178    }
179}
180
181pub async fn exists_folder(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<bool, Error<ExistsFolderError>> {
182    let local_var_configuration = configuration;
183
184    let local_var_client = &local_var_configuration.client;
185
186    let local_var_uri_str = format!("{}/w/{workspace}/folders/exists/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
187    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
188
189    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
190        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
191    }
192    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
193        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
194    };
195
196    let local_var_req = local_var_req_builder.build()?;
197    let local_var_resp = local_var_client.execute(local_var_req).await?;
198
199    let local_var_status = local_var_resp.status();
200    let local_var_content = local_var_resp.text().await?;
201
202    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
203        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
204    } else {
205        let local_var_entity: Option<ExistsFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
206        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
207        Err(Error::ResponseError(local_var_error))
208    }
209}
210
211pub async fn get_folder(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<models::Folder, Error<GetFolderError>> {
212    let local_var_configuration = configuration;
213
214    let local_var_client = &local_var_configuration.client;
215
216    let local_var_uri_str = format!("{}/w/{workspace}/folders/get/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
217    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
218
219    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
220        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
221    }
222    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
223        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
224    };
225
226    let local_var_req = local_var_req_builder.build()?;
227    let local_var_resp = local_var_client.execute(local_var_req).await?;
228
229    let local_var_status = local_var_resp.status();
230    let local_var_content = local_var_resp.text().await?;
231
232    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
233        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
234    } else {
235        let local_var_entity: Option<GetFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
236        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
237        Err(Error::ResponseError(local_var_error))
238    }
239}
240
241pub async fn get_folder_usage(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<models::GetFolderUsage200Response, Error<GetFolderUsageError>> {
242    let local_var_configuration = configuration;
243
244    let local_var_client = &local_var_configuration.client;
245
246    let local_var_uri_str = format!("{}/w/{workspace}/folders/getusage/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
247    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
248
249    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
250        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
251    }
252    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
253        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
254    };
255
256    let local_var_req = local_var_req_builder.build()?;
257    let local_var_resp = local_var_client.execute(local_var_req).await?;
258
259    let local_var_status = local_var_resp.status();
260    let local_var_content = local_var_resp.text().await?;
261
262    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
263        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
264    } else {
265        let local_var_entity: Option<GetFolderUsageError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
266        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
267        Err(Error::ResponseError(local_var_error))
268    }
269}
270
271pub async fn list_folder_names(configuration: &configuration::Configuration, workspace: &str, only_member_of: Option<bool>) -> Result<Vec<String>, Error<ListFolderNamesError>> {
272    let local_var_configuration = configuration;
273
274    let local_var_client = &local_var_configuration.client;
275
276    let local_var_uri_str = format!("{}/w/{workspace}/folders/listnames", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
277    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
278
279    if let Some(ref local_var_str) = only_member_of {
280        local_var_req_builder = local_var_req_builder.query(&[("only_member_of", &local_var_str.to_string())]);
281    }
282    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
283        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
284    }
285    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
286        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
287    };
288
289    let local_var_req = local_var_req_builder.build()?;
290    let local_var_resp = local_var_client.execute(local_var_req).await?;
291
292    let local_var_status = local_var_resp.status();
293    let local_var_content = local_var_resp.text().await?;
294
295    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
296        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
297    } else {
298        let local_var_entity: Option<ListFolderNamesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
299        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
300        Err(Error::ResponseError(local_var_error))
301    }
302}
303
304pub async fn list_folders(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::Folder>, Error<ListFoldersError>> {
305    let local_var_configuration = configuration;
306
307    let local_var_client = &local_var_configuration.client;
308
309    let local_var_uri_str = format!("{}/w/{workspace}/folders/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
310    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
311
312    if let Some(ref local_var_str) = page {
313        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
314    }
315    if let Some(ref local_var_str) = per_page {
316        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
317    }
318    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
319        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
320    }
321    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
322        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
323    };
324
325    let local_var_req = local_var_req_builder.build()?;
326    let local_var_resp = local_var_client.execute(local_var_req).await?;
327
328    let local_var_status = local_var_resp.status();
329    let local_var_content = local_var_resp.text().await?;
330
331    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
332        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
333    } else {
334        let local_var_entity: Option<ListFoldersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
335        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
336        Err(Error::ResponseError(local_var_error))
337    }
338}
339
340pub async fn remove_owner_to_folder(configuration: &configuration::Configuration, workspace: &str, name: &str, remove_owner_to_folder_request: models::RemoveOwnerToFolderRequest) -> Result<String, Error<RemoveOwnerToFolderError>> {
341    let local_var_configuration = configuration;
342
343    let local_var_client = &local_var_configuration.client;
344
345    let local_var_uri_str = format!("{}/w/{workspace}/folders/removeowner/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
346    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
347
348    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
349        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
350    }
351    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
352        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
353    };
354    local_var_req_builder = local_var_req_builder.json(&remove_owner_to_folder_request);
355
356    let local_var_req = local_var_req_builder.build()?;
357    let local_var_resp = local_var_client.execute(local_var_req).await?;
358
359    let local_var_status = local_var_resp.status();
360    let local_var_content = local_var_resp.text().await?;
361
362    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
363        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
364    } else {
365        let local_var_entity: Option<RemoveOwnerToFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
366        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
367        Err(Error::ResponseError(local_var_error))
368    }
369}
370
371pub async fn update_folder(configuration: &configuration::Configuration, workspace: &str, name: &str, update_folder_request: models::UpdateFolderRequest) -> Result<String, Error<UpdateFolderError>> {
372    let local_var_configuration = configuration;
373
374    let local_var_client = &local_var_configuration.client;
375
376    let local_var_uri_str = format!("{}/w/{workspace}/folders/update/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
377    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
378
379    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
380        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
381    }
382    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
383        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
384    };
385    local_var_req_builder = local_var_req_builder.json(&update_folder_request);
386
387    let local_var_req = local_var_req_builder.build()?;
388    let local_var_resp = local_var_client.execute(local_var_req).await?;
389
390    let local_var_status = local_var_resp.status();
391    let local_var_content = local_var_resp.text().await?;
392
393    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
394        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
395    } else {
396        let local_var_entity: Option<UpdateFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
397        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
398        Err(Error::ResponseError(local_var_error))
399    }
400}
401