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