windmill_api/apis/
group_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.539.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_user_to_group`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddUserToGroupError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`add_user_to_instance_group`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum AddUserToInstanceGroupError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`create_group`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum CreateGroupError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`create_instance_group`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum CreateInstanceGroupError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`delete_group`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum DeleteGroupError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`delete_instance_group`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum DeleteInstanceGroupError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`export_instance_groups`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ExportInstanceGroupsError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`get_group`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetGroupError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`get_instance_group`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetInstanceGroupError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`list_group_names`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum ListGroupNamesError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`list_groups`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ListGroupsError {
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`list_instance_groups`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum ListInstanceGroupsError {
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`list_instance_groups_with_workspaces`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum ListInstanceGroupsWithWorkspacesError {
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`overwrite_instance_groups`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum OverwriteInstanceGroupsError {
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`remove_user_from_instance_group`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum RemoveUserFromInstanceGroupError {
120    UnknownValue(serde_json::Value),
121}
122
123/// struct for typed errors of method [`remove_user_to_group`]
124#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum RemoveUserToGroupError {
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`update_group`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum UpdateGroupError {
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`update_instance_group`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum UpdateInstanceGroupError {
141    UnknownValue(serde_json::Value),
142}
143
144
145pub async fn add_user_to_group(configuration: &configuration::Configuration, workspace: &str, name: &str, add_user_to_group_request: models::AddUserToGroupRequest) -> Result<String, Error<AddUserToGroupError>> {
146    let local_var_configuration = configuration;
147
148    let local_var_client = &local_var_configuration.client;
149
150    let local_var_uri_str = format!("{}/w/{workspace}/groups/adduser/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
151    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
152
153    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
154        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
155    }
156    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
157        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
158    };
159    local_var_req_builder = local_var_req_builder.json(&add_user_to_group_request);
160
161    let local_var_req = local_var_req_builder.build()?;
162    let local_var_resp = local_var_client.execute(local_var_req).await?;
163
164    let local_var_status = local_var_resp.status();
165    let local_var_content = local_var_resp.text().await?;
166
167    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
168        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
169    } else {
170        let local_var_entity: Option<AddUserToGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
171        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
172        Err(Error::ResponseError(local_var_error))
173    }
174}
175
176pub async fn add_user_to_instance_group(configuration: &configuration::Configuration, name: &str, add_user_to_instance_group_request: models::AddUserToInstanceGroupRequest) -> Result<String, Error<AddUserToInstanceGroupError>> {
177    let local_var_configuration = configuration;
178
179    let local_var_client = &local_var_configuration.client;
180
181    let local_var_uri_str = format!("{}/groups/adduser/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
182    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
183
184    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
185        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
186    }
187    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
188        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
189    };
190    local_var_req_builder = local_var_req_builder.json(&add_user_to_instance_group_request);
191
192    let local_var_req = local_var_req_builder.build()?;
193    let local_var_resp = local_var_client.execute(local_var_req).await?;
194
195    let local_var_status = local_var_resp.status();
196    let local_var_content = local_var_resp.text().await?;
197
198    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
199        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
200    } else {
201        let local_var_entity: Option<AddUserToInstanceGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
202        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
203        Err(Error::ResponseError(local_var_error))
204    }
205}
206
207pub async fn create_group(configuration: &configuration::Configuration, workspace: &str, create_instance_group_request: models::CreateInstanceGroupRequest) -> Result<String, Error<CreateGroupError>> {
208    let local_var_configuration = configuration;
209
210    let local_var_client = &local_var_configuration.client;
211
212    let local_var_uri_str = format!("{}/w/{workspace}/groups/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
213    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
214
215    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
216        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
217    }
218    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
219        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
220    };
221    local_var_req_builder = local_var_req_builder.json(&create_instance_group_request);
222
223    let local_var_req = local_var_req_builder.build()?;
224    let local_var_resp = local_var_client.execute(local_var_req).await?;
225
226    let local_var_status = local_var_resp.status();
227    let local_var_content = local_var_resp.text().await?;
228
229    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
230        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
231    } else {
232        let local_var_entity: Option<CreateGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
233        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
234        Err(Error::ResponseError(local_var_error))
235    }
236}
237
238pub async fn create_instance_group(configuration: &configuration::Configuration, create_instance_group_request: models::CreateInstanceGroupRequest) -> Result<String, Error<CreateInstanceGroupError>> {
239    let local_var_configuration = configuration;
240
241    let local_var_client = &local_var_configuration.client;
242
243    let local_var_uri_str = format!("{}/groups/create", local_var_configuration.base_path);
244    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
245
246    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
247        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
248    }
249    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
250        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
251    };
252    local_var_req_builder = local_var_req_builder.json(&create_instance_group_request);
253
254    let local_var_req = local_var_req_builder.build()?;
255    let local_var_resp = local_var_client.execute(local_var_req).await?;
256
257    let local_var_status = local_var_resp.status();
258    let local_var_content = local_var_resp.text().await?;
259
260    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
261        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
262    } else {
263        let local_var_entity: Option<CreateInstanceGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
264        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
265        Err(Error::ResponseError(local_var_error))
266    }
267}
268
269pub async fn delete_group(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<String, Error<DeleteGroupError>> {
270    let local_var_configuration = configuration;
271
272    let local_var_client = &local_var_configuration.client;
273
274    let local_var_uri_str = format!("{}/w/{workspace}/groups/delete/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
275    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
276
277    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
278        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
279    }
280    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
281        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
282    };
283
284    let local_var_req = local_var_req_builder.build()?;
285    let local_var_resp = local_var_client.execute(local_var_req).await?;
286
287    let local_var_status = local_var_resp.status();
288    let local_var_content = local_var_resp.text().await?;
289
290    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
291        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
292    } else {
293        let local_var_entity: Option<DeleteGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
294        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
295        Err(Error::ResponseError(local_var_error))
296    }
297}
298
299pub async fn delete_instance_group(configuration: &configuration::Configuration, name: &str) -> Result<String, Error<DeleteInstanceGroupError>> {
300    let local_var_configuration = configuration;
301
302    let local_var_client = &local_var_configuration.client;
303
304    let local_var_uri_str = format!("{}/groups/delete/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
305    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
306
307    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
308        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
309    }
310    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
311        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
312    };
313
314    let local_var_req = local_var_req_builder.build()?;
315    let local_var_resp = local_var_client.execute(local_var_req).await?;
316
317    let local_var_status = local_var_resp.status();
318    let local_var_content = local_var_resp.text().await?;
319
320    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
321        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
322    } else {
323        let local_var_entity: Option<DeleteInstanceGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
324        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
325        Err(Error::ResponseError(local_var_error))
326    }
327}
328
329pub async fn export_instance_groups(configuration: &configuration::Configuration, ) -> Result<Vec<models::ExportedInstanceGroup>, Error<ExportInstanceGroupsError>> {
330    let local_var_configuration = configuration;
331
332    let local_var_client = &local_var_configuration.client;
333
334    let local_var_uri_str = format!("{}/groups/export", local_var_configuration.base_path);
335    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
336
337    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
338        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
339    }
340    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
341        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
342    };
343
344    let local_var_req = local_var_req_builder.build()?;
345    let local_var_resp = local_var_client.execute(local_var_req).await?;
346
347    let local_var_status = local_var_resp.status();
348    let local_var_content = local_var_resp.text().await?;
349
350    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
351        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
352    } else {
353        let local_var_entity: Option<ExportInstanceGroupsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
354        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
355        Err(Error::ResponseError(local_var_error))
356    }
357}
358
359pub async fn get_group(configuration: &configuration::Configuration, workspace: &str, name: &str) -> Result<models::Group, Error<GetGroupError>> {
360    let local_var_configuration = configuration;
361
362    let local_var_client = &local_var_configuration.client;
363
364    let local_var_uri_str = format!("{}/w/{workspace}/groups/get/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
365    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
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<GetGroupError> = 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 get_instance_group(configuration: &configuration::Configuration, name: &str) -> Result<models::InstanceGroup, Error<GetInstanceGroupError>> {
390    let local_var_configuration = configuration;
391
392    let local_var_client = &local_var_configuration.client;
393
394    let local_var_uri_str = format!("{}/groups/get/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
395    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, 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
404    let local_var_req = local_var_req_builder.build()?;
405    let local_var_resp = local_var_client.execute(local_var_req).await?;
406
407    let local_var_status = local_var_resp.status();
408    let local_var_content = local_var_resp.text().await?;
409
410    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
411        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
412    } else {
413        let local_var_entity: Option<GetInstanceGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
414        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
415        Err(Error::ResponseError(local_var_error))
416    }
417}
418
419pub async fn list_group_names(configuration: &configuration::Configuration, workspace: &str, only_member_of: Option<bool>) -> Result<Vec<String>, Error<ListGroupNamesError>> {
420    let local_var_configuration = configuration;
421
422    let local_var_client = &local_var_configuration.client;
423
424    let local_var_uri_str = format!("{}/w/{workspace}/groups/listnames", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
425    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
426
427    if let Some(ref local_var_str) = only_member_of {
428        local_var_req_builder = local_var_req_builder.query(&[("only_member_of", &local_var_str.to_string())]);
429    }
430    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
431        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
432    }
433    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
434        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
435    };
436
437    let local_var_req = local_var_req_builder.build()?;
438    let local_var_resp = local_var_client.execute(local_var_req).await?;
439
440    let local_var_status = local_var_resp.status();
441    let local_var_content = local_var_resp.text().await?;
442
443    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
444        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
445    } else {
446        let local_var_entity: Option<ListGroupNamesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
447        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
448        Err(Error::ResponseError(local_var_error))
449    }
450}
451
452pub async fn list_groups(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::Group>, Error<ListGroupsError>> {
453    let local_var_configuration = configuration;
454
455    let local_var_client = &local_var_configuration.client;
456
457    let local_var_uri_str = format!("{}/w/{workspace}/groups/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
458    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
459
460    if let Some(ref local_var_str) = page {
461        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
462    }
463    if let Some(ref local_var_str) = per_page {
464        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
465    }
466    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
467        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
468    }
469    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
470        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
471    };
472
473    let local_var_req = local_var_req_builder.build()?;
474    let local_var_resp = local_var_client.execute(local_var_req).await?;
475
476    let local_var_status = local_var_resp.status();
477    let local_var_content = local_var_resp.text().await?;
478
479    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
480        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
481    } else {
482        let local_var_entity: Option<ListGroupsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
483        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
484        Err(Error::ResponseError(local_var_error))
485    }
486}
487
488pub async fn list_instance_groups(configuration: &configuration::Configuration, ) -> Result<Vec<models::InstanceGroup>, Error<ListInstanceGroupsError>> {
489    let local_var_configuration = configuration;
490
491    let local_var_client = &local_var_configuration.client;
492
493    let local_var_uri_str = format!("{}/groups/list", local_var_configuration.base_path);
494    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
495
496    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
497        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
498    }
499    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
500        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
501    };
502
503    let local_var_req = local_var_req_builder.build()?;
504    let local_var_resp = local_var_client.execute(local_var_req).await?;
505
506    let local_var_status = local_var_resp.status();
507    let local_var_content = local_var_resp.text().await?;
508
509    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
510        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
511    } else {
512        let local_var_entity: Option<ListInstanceGroupsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
513        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
514        Err(Error::ResponseError(local_var_error))
515    }
516}
517
518pub async fn list_instance_groups_with_workspaces(configuration: &configuration::Configuration, ) -> Result<Vec<models::InstanceGroupWithWorkspaces>, Error<ListInstanceGroupsWithWorkspacesError>> {
519    let local_var_configuration = configuration;
520
521    let local_var_client = &local_var_configuration.client;
522
523    let local_var_uri_str = format!("{}/groups/list_with_workspaces", local_var_configuration.base_path);
524    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
525
526    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
527        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
528    }
529    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
530        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
531    };
532
533    let local_var_req = local_var_req_builder.build()?;
534    let local_var_resp = local_var_client.execute(local_var_req).await?;
535
536    let local_var_status = local_var_resp.status();
537    let local_var_content = local_var_resp.text().await?;
538
539    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
540        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
541    } else {
542        let local_var_entity: Option<ListInstanceGroupsWithWorkspacesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
543        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
544        Err(Error::ResponseError(local_var_error))
545    }
546}
547
548pub async fn overwrite_instance_groups(configuration: &configuration::Configuration, exported_instance_group: Vec<models::ExportedInstanceGroup>) -> Result<String, Error<OverwriteInstanceGroupsError>> {
549    let local_var_configuration = configuration;
550
551    let local_var_client = &local_var_configuration.client;
552
553    let local_var_uri_str = format!("{}/groups/overwrite", local_var_configuration.base_path);
554    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
555
556    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
557        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
558    }
559    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
560        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
561    };
562    local_var_req_builder = local_var_req_builder.json(&exported_instance_group);
563
564    let local_var_req = local_var_req_builder.build()?;
565    let local_var_resp = local_var_client.execute(local_var_req).await?;
566
567    let local_var_status = local_var_resp.status();
568    let local_var_content = local_var_resp.text().await?;
569
570    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
571        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
572    } else {
573        let local_var_entity: Option<OverwriteInstanceGroupsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
574        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
575        Err(Error::ResponseError(local_var_error))
576    }
577}
578
579pub async fn remove_user_from_instance_group(configuration: &configuration::Configuration, name: &str, add_user_to_instance_group_request: models::AddUserToInstanceGroupRequest) -> Result<String, Error<RemoveUserFromInstanceGroupError>> {
580    let local_var_configuration = configuration;
581
582    let local_var_client = &local_var_configuration.client;
583
584    let local_var_uri_str = format!("{}/groups/removeuser/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
585    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
586
587    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
588        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
589    }
590    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
591        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
592    };
593    local_var_req_builder = local_var_req_builder.json(&add_user_to_instance_group_request);
594
595    let local_var_req = local_var_req_builder.build()?;
596    let local_var_resp = local_var_client.execute(local_var_req).await?;
597
598    let local_var_status = local_var_resp.status();
599    let local_var_content = local_var_resp.text().await?;
600
601    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
602        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
603    } else {
604        let local_var_entity: Option<RemoveUserFromInstanceGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
605        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
606        Err(Error::ResponseError(local_var_error))
607    }
608}
609
610pub async fn remove_user_to_group(configuration: &configuration::Configuration, workspace: &str, name: &str, add_user_to_group_request: models::AddUserToGroupRequest) -> Result<String, Error<RemoveUserToGroupError>> {
611    let local_var_configuration = configuration;
612
613    let local_var_client = &local_var_configuration.client;
614
615    let local_var_uri_str = format!("{}/w/{workspace}/groups/removeuser/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
616    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
617
618    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
619        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
620    }
621    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
622        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
623    };
624    local_var_req_builder = local_var_req_builder.json(&add_user_to_group_request);
625
626    let local_var_req = local_var_req_builder.build()?;
627    let local_var_resp = local_var_client.execute(local_var_req).await?;
628
629    let local_var_status = local_var_resp.status();
630    let local_var_content = local_var_resp.text().await?;
631
632    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
633        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
634    } else {
635        let local_var_entity: Option<RemoveUserToGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
636        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
637        Err(Error::ResponseError(local_var_error))
638    }
639}
640
641pub async fn update_group(configuration: &configuration::Configuration, workspace: &str, name: &str, update_group_request: models::UpdateGroupRequest) -> Result<String, Error<UpdateGroupError>> {
642    let local_var_configuration = configuration;
643
644    let local_var_client = &local_var_configuration.client;
645
646    let local_var_uri_str = format!("{}/w/{workspace}/groups/update/{name}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), name=crate::apis::urlencode(name));
647    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
648
649    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
650        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
651    }
652    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
653        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
654    };
655    local_var_req_builder = local_var_req_builder.json(&update_group_request);
656
657    let local_var_req = local_var_req_builder.build()?;
658    let local_var_resp = local_var_client.execute(local_var_req).await?;
659
660    let local_var_status = local_var_resp.status();
661    let local_var_content = local_var_resp.text().await?;
662
663    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
664        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
665    } else {
666        let local_var_entity: Option<UpdateGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
667        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
668        Err(Error::ResponseError(local_var_error))
669    }
670}
671
672pub async fn update_instance_group(configuration: &configuration::Configuration, name: &str, update_instance_group_request: models::UpdateInstanceGroupRequest) -> Result<String, Error<UpdateInstanceGroupError>> {
673    let local_var_configuration = configuration;
674
675    let local_var_client = &local_var_configuration.client;
676
677    let local_var_uri_str = format!("{}/groups/update/{name}", local_var_configuration.base_path, name=crate::apis::urlencode(name));
678    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
679
680    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
681        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
682    }
683    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
684        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
685    };
686    local_var_req_builder = local_var_req_builder.json(&update_instance_group_request);
687
688    let local_var_req = local_var_req_builder.build()?;
689    let local_var_resp = local_var_client.execute(local_var_req).await?;
690
691    let local_var_status = local_var_resp.status();
692    let local_var_content = local_var_resp.text().await?;
693
694    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
695        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
696    } else {
697        let local_var_entity: Option<UpdateInstanceGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
698        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
699        Err(Error::ResponseError(local_var_error))
700    }
701}
702