Skip to main content

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.771.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_permission_history`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetFolderPermissionHistoryError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_folder_usage`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetFolderUsageError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`list_folder_names`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListFolderNamesError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`list_folders`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ListFoldersError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`remove_owner_to_folder`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum RemoveOwnerToFolderError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`update_folder`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum UpdateFolderError {
92    UnknownValue(serde_json::Value),
93}
94
95
96pub async fn add_owner_to_folder(configuration: &configuration::Configuration, workspace: &str, name: &str, add_owner_to_folder_request: models::AddOwnerToFolderRequest) -> Result<String, Error<AddOwnerToFolderError>> {
97    let local_var_configuration = configuration;
98
99    let local_var_client = &local_var_configuration.client;
100
101    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));
102    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
103
104    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
105        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
106    }
107    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
108        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
109    };
110    local_var_req_builder = local_var_req_builder.json(&add_owner_to_folder_request);
111
112    let local_var_req = local_var_req_builder.build()?;
113    let local_var_resp = local_var_client.execute(local_var_req).await?;
114
115    let local_var_status = local_var_resp.status();
116    let local_var_content = local_var_resp.text().await?;
117
118    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
119        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
120    } else {
121        let local_var_entity: Option<AddOwnerToFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
122        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
123        Err(Error::ResponseError(local_var_error))
124    }
125}
126
127pub async fn create_folder(configuration: &configuration::Configuration, workspace: &str, create_folder_request: models::CreateFolderRequest) -> Result<String, Error<CreateFolderError>> {
128    let local_var_configuration = configuration;
129
130    let local_var_client = &local_var_configuration.client;
131
132    let local_var_uri_str = format!("{}/w/{workspace}/folders/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
133    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
134
135    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
136        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
137    }
138    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
139        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
140    };
141    local_var_req_builder = local_var_req_builder.json(&create_folder_request);
142
143    let local_var_req = local_var_req_builder.build()?;
144    let local_var_resp = local_var_client.execute(local_var_req).await?;
145
146    let local_var_status = local_var_resp.status();
147    let local_var_content = local_var_resp.text().await?;
148
149    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
150        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
151    } else {
152        let local_var_entity: Option<CreateFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
153        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
154        Err(Error::ResponseError(local_var_error))
155    }
156}
157
158pub async fn delete_folder(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<String, Error<DeleteFolderError>> {
159    let local_var_configuration = configuration;
160
161    let local_var_client = &local_var_configuration.client;
162
163    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));
164    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
165
166    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
167        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
168    }
169    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
170        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
171    };
172
173    let local_var_req = local_var_req_builder.build()?;
174    let local_var_resp = local_var_client.execute(local_var_req).await?;
175
176    let local_var_status = local_var_resp.status();
177    let local_var_content = local_var_resp.text().await?;
178
179    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
180        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
181    } else {
182        let local_var_entity: Option<DeleteFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
183        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
184        Err(Error::ResponseError(local_var_error))
185    }
186}
187
188pub async fn exists_folder(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<bool, Error<ExistsFolderError>> {
189    let local_var_configuration = configuration;
190
191    let local_var_client = &local_var_configuration.client;
192
193    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));
194    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
195
196    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
197        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
198    }
199    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
200        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
201    };
202
203    let local_var_req = local_var_req_builder.build()?;
204    let local_var_resp = local_var_client.execute(local_var_req).await?;
205
206    let local_var_status = local_var_resp.status();
207    let local_var_content = local_var_resp.text().await?;
208
209    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
210        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
211    } else {
212        let local_var_entity: Option<ExistsFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
213        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
214        Err(Error::ResponseError(local_var_error))
215    }
216}
217
218pub async fn get_folder(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<models::Folder, Error<GetFolderError>> {
219    let local_var_configuration = configuration;
220
221    let local_var_client = &local_var_configuration.client;
222
223    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));
224    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
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_token) = local_var_configuration.bearer_access_token {
230        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
231    };
232
233    let local_var_req = local_var_req_builder.build()?;
234    let local_var_resp = local_var_client.execute(local_var_req).await?;
235
236    let local_var_status = local_var_resp.status();
237    let local_var_content = local_var_resp.text().await?;
238
239    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
240        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
241    } else {
242        let local_var_entity: Option<GetFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
243        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
244        Err(Error::ResponseError(local_var_error))
245    }
246}
247
248pub async fn get_folder_permission_history(configuration: &configuration::Configuration, workspace: &str, name: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::GetFolderPermissionHistory200ResponseInner>, Error<GetFolderPermissionHistoryError>> {
249    let local_var_configuration = configuration;
250
251    let local_var_client = &local_var_configuration.client;
252
253    let local_var_uri_str = format!("{}/w/{workspace}/folders_history/get/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
254    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
255
256    if let Some(ref local_var_str) = page {
257        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
258    }
259    if let Some(ref local_var_str) = per_page {
260        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
261    }
262    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
263        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
264    }
265    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
266        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
267    };
268
269    let local_var_req = local_var_req_builder.build()?;
270    let local_var_resp = local_var_client.execute(local_var_req).await?;
271
272    let local_var_status = local_var_resp.status();
273    let local_var_content = local_var_resp.text().await?;
274
275    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
276        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
277    } else {
278        let local_var_entity: Option<GetFolderPermissionHistoryError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
279        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
280        Err(Error::ResponseError(local_var_error))
281    }
282}
283
284pub async fn get_folder_usage(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<models::GetFolderUsage200Response, Error<GetFolderUsageError>> {
285    let local_var_configuration = configuration;
286
287    let local_var_client = &local_var_configuration.client;
288
289    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));
290    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
291
292    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
293        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
294    }
295    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
296        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
297    };
298
299    let local_var_req = local_var_req_builder.build()?;
300    let local_var_resp = local_var_client.execute(local_var_req).await?;
301
302    let local_var_status = local_var_resp.status();
303    let local_var_content = local_var_resp.text().await?;
304
305    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
306        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
307    } else {
308        let local_var_entity: Option<GetFolderUsageError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
309        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
310        Err(Error::ResponseError(local_var_error))
311    }
312}
313
314pub async fn list_folder_names(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, only_member_of: Option<bool>) -> Result<Vec<String>, Error<ListFolderNamesError>> {
315    let local_var_configuration = configuration;
316
317    let local_var_client = &local_var_configuration.client;
318
319    let local_var_uri_str = format!("{}/w/{workspace}/folders/listnames", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
320    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
321
322    if let Some(ref local_var_str) = page {
323        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
324    }
325    if let Some(ref local_var_str) = per_page {
326        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
327    }
328    if let Some(ref local_var_str) = only_member_of {
329        local_var_req_builder = local_var_req_builder.query(&[("only_member_of", &local_var_str.to_string())]);
330    }
331    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
332        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
333    }
334    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
335        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
336    };
337
338    let local_var_req = local_var_req_builder.build()?;
339    let local_var_resp = local_var_client.execute(local_var_req).await?;
340
341    let local_var_status = local_var_resp.status();
342    let local_var_content = local_var_resp.text().await?;
343
344    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
345        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
346    } else {
347        let local_var_entity: Option<ListFolderNamesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
348        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
349        Err(Error::ResponseError(local_var_error))
350    }
351}
352
353pub async fn list_folders(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::Folder>, Error<ListFoldersError>> {
354    let local_var_configuration = configuration;
355
356    let local_var_client = &local_var_configuration.client;
357
358    let local_var_uri_str = format!("{}/w/{workspace}/folders/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
359    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
360
361    if let Some(ref local_var_str) = page {
362        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
363    }
364    if let Some(ref local_var_str) = per_page {
365        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
366    }
367    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
368        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
369    }
370    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
371        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
372    };
373
374    let local_var_req = local_var_req_builder.build()?;
375    let local_var_resp = local_var_client.execute(local_var_req).await?;
376
377    let local_var_status = local_var_resp.status();
378    let local_var_content = local_var_resp.text().await?;
379
380    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
381        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
382    } else {
383        let local_var_entity: Option<ListFoldersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
384        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
385        Err(Error::ResponseError(local_var_error))
386    }
387}
388
389pub async fn remove_owner_to_folder(configuration: &configuration::Configuration, workspace: &str, name: &str, remove_owner_to_folder_request: models::RemoveOwnerToFolderRequest) -> Result<String, Error<RemoveOwnerToFolderError>> {
390    let local_var_configuration = configuration;
391
392    let local_var_client = &local_var_configuration.client;
393
394    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));
395    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
396
397    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
398        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
399    }
400    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
401        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
402    };
403    local_var_req_builder = local_var_req_builder.json(&remove_owner_to_folder_request);
404
405    let local_var_req = local_var_req_builder.build()?;
406    let local_var_resp = local_var_client.execute(local_var_req).await?;
407
408    let local_var_status = local_var_resp.status();
409    let local_var_content = local_var_resp.text().await?;
410
411    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
412        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
413    } else {
414        let local_var_entity: Option<RemoveOwnerToFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
415        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
416        Err(Error::ResponseError(local_var_error))
417    }
418}
419
420pub async fn update_folder(configuration: &configuration::Configuration, workspace: &str, name: &str, update_folder_request: models::UpdateFolderRequest) -> Result<String, Error<UpdateFolderError>> {
421    let local_var_configuration = configuration;
422
423    let local_var_client = &local_var_configuration.client;
424
425    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));
426    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
427
428    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
429        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
430    }
431    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
432        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
433    };
434    local_var_req_builder = local_var_req_builder.json(&update_folder_request);
435
436    let local_var_req = local_var_req_builder.build()?;
437    let local_var_resp = local_var_client.execute(local_var_req).await?;
438
439    let local_var_status = local_var_resp.status();
440    let local_var_content = local_var_resp.text().await?;
441
442    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
443        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
444    } else {
445        let local_var_entity: Option<UpdateFolderError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
446        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
447        Err(Error::ResponseError(local_var_error))
448    }
449}
450