Skip to main content

windmill_api/apis/
granular_acl_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.862.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_granular_acls`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddGranularAclsError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_granular_acls`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetGranularAclsError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_principal_access`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetPrincipalAccessError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`remove_granular_acls`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum RemoveGranularAclsError {
43    UnknownValue(serde_json::Value),
44}
45
46
47pub async fn add_granular_acls(configuration: &configuration::Configuration, workspace: &str, path: &str, kind: &str, remove_owner_to_folder_request: models::RemoveOwnerToFolderRequest) -> Result<String, Error<AddGranularAclsError>> {
48    let local_var_configuration = configuration;
49
50    let local_var_client = &local_var_configuration.client;
51
52    let local_var_uri_str = format!("{}/w/{workspace}/acls/add/{kind}/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path), kind=crate::apis::urlencode(kind));
53    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
54
55    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
56        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
57    }
58    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
59        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
60    };
61    local_var_req_builder = local_var_req_builder.json(&remove_owner_to_folder_request);
62
63    let local_var_req = local_var_req_builder.build()?;
64    let local_var_resp = local_var_client.execute(local_var_req).await?;
65
66    let local_var_status = local_var_resp.status();
67    let local_var_content = local_var_resp.text().await?;
68
69    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
70        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
71    } else {
72        let local_var_entity: Option<AddGranularAclsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
73        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
74        Err(Error::ResponseError(local_var_error))
75    }
76}
77
78pub async fn get_granular_acls(configuration: &configuration::Configuration, workspace: &str, path: &str, kind: &str) -> Result<std::collections::HashMap<String, bool>, Error<GetGranularAclsError>> {
79    let local_var_configuration = configuration;
80
81    let local_var_client = &local_var_configuration.client;
82
83    let local_var_uri_str = format!("{}/w/{workspace}/acls/get/{kind}/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path), kind=crate::apis::urlencode(kind));
84    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
85
86    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
87        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
88    }
89    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
90        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
91    };
92
93    let local_var_req = local_var_req_builder.build()?;
94    let local_var_resp = local_var_client.execute(local_var_req).await?;
95
96    let local_var_status = local_var_resp.status();
97    let local_var_content = local_var_resp.text().await?;
98
99    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
100        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
101    } else {
102        let local_var_entity: Option<GetGranularAclsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
103        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
104        Err(Error::ResponseError(local_var_error))
105    }
106}
107
108/// Workspace admins can query any principal; other members only themselves and the groups they belong to. An admin principal reaches everything, so `items` is empty. 
109pub async fn get_principal_access(configuration: &configuration::Configuration, workspace: &str, principal: &str) -> Result<models::PrincipalAccess, Error<GetPrincipalAccessError>> {
110    let local_var_configuration = configuration;
111
112    let local_var_client = &local_var_configuration.client;
113
114    let local_var_uri_str = format!("{}/w/{workspace}/access/get", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
115    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
116
117    local_var_req_builder = local_var_req_builder.query(&[("principal", &principal.to_string())]);
118    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
119        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
120    }
121    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
122        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
123    };
124
125    let local_var_req = local_var_req_builder.build()?;
126    let local_var_resp = local_var_client.execute(local_var_req).await?;
127
128    let local_var_status = local_var_resp.status();
129    let local_var_content = local_var_resp.text().await?;
130
131    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
132        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
133    } else {
134        let local_var_entity: Option<GetPrincipalAccessError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
135        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
136        Err(Error::ResponseError(local_var_error))
137    }
138}
139
140pub async fn remove_granular_acls(configuration: &configuration::Configuration, workspace: &str, path: &str, kind: &str, add_owner_to_folder_request: models::AddOwnerToFolderRequest) -> Result<String, Error<RemoveGranularAclsError>> {
141    let local_var_configuration = configuration;
142
143    let local_var_client = &local_var_configuration.client;
144
145    let local_var_uri_str = format!("{}/w/{workspace}/acls/remove/{kind}/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path), kind=crate::apis::urlencode(kind));
146    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
147
148    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
149        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
150    }
151    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
152        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
153    };
154    local_var_req_builder = local_var_req_builder.json(&add_owner_to_folder_request);
155
156    let local_var_req = local_var_req_builder.build()?;
157    let local_var_resp = local_var_client.execute(local_var_req).await?;
158
159    let local_var_status = local_var_resp.status();
160    let local_var_content = local_var_resp.text().await?;
161
162    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
163        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
164    } else {
165        let local_var_entity: Option<RemoveGranularAclsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
166        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
167        Err(Error::ResponseError(local_var_error))
168    }
169}
170