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