jira_api_v2/apis/
users_api.rs

1/*
2 * The Jira Cloud platform REST API
3 *
4 * Jira Cloud platform REST API documentation
5 *
6 * The version of the OpenAPI document: 1001.0.0-SNAPSHOT
7 * Contact: ecosystem@atlassian.com
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 [`bulk_get_users`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum BulkGetUsersError {
22    Status400(),
23    Status401(),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`bulk_get_users_migration`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum BulkGetUsersMigrationError {
31    Status400(),
32    Status401(),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`create_user`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum CreateUserError {
40    Status400(),
41    Status401(),
42    Status403(),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_all_users`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetAllUsersError {
50    Status400(),
51    Status403(),
52    Status409(),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method [`get_all_users_default`]
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum GetAllUsersDefaultError {
60    Status400(),
61    Status403(),
62    Status409(),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`get_user`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum GetUserError {
70    Status401(),
71    Status403(),
72    Status404(),
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method [`get_user_default_columns`]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum GetUserDefaultColumnsError {
80    Status401(),
81    Status403(),
82    Status404(),
83    UnknownValue(serde_json::Value),
84}
85
86/// struct for typed errors of method [`get_user_email`]
87#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum GetUserEmailError {
90    Status400(),
91    Status401(),
92    Status404(),
93    Status503(),
94    UnknownValue(serde_json::Value),
95}
96
97/// struct for typed errors of method [`get_user_email_bulk`]
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum GetUserEmailBulkError {
101    Status400(),
102    Status401(),
103    Status503(),
104    UnknownValue(serde_json::Value),
105}
106
107/// struct for typed errors of method [`get_user_groups`]
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum GetUserGroupsError {
111    Status401(),
112    Status403(),
113    Status404(),
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method [`remove_user`]
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum RemoveUserError {
121    Status400(),
122    Status401(),
123    Status403(),
124    Status404(),
125    UnknownValue(serde_json::Value),
126}
127
128/// struct for typed errors of method [`reset_user_columns`]
129#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum ResetUserColumnsError {
132    Status401(),
133    Status403(),
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`set_user_columns`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum SetUserColumnsError {
141    Status401(),
142    Status403(),
143    Status404(),
144    Status500(),
145    UnknownValue(serde_json::Value),
146}
147
148
149/// Returns a [paginated](#pagination) list of the users specified by one or more account IDs.  **[Permissions](#permissions) required:** Permission to access Jira.
150pub async fn bulk_get_users(configuration: &configuration::Configuration, account_id: Vec<String>, start_at: Option<i64>, max_results: Option<i32>, username: Option<Vec<String>>, key: Option<Vec<String>>) -> Result<models::PageBeanUser, Error<BulkGetUsersError>> {
151    // add a prefix to parameters to efficiently prevent name collisions
152    let p_account_id = account_id;
153    let p_start_at = start_at;
154    let p_max_results = max_results;
155    let p_username = username;
156    let p_key = key;
157
158    let uri_str = format!("{}/rest/api/2/user/bulk", configuration.base_path);
159    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
160
161    if let Some(ref param_value) = p_start_at {
162        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
163    }
164    if let Some(ref param_value) = p_max_results {
165        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
166    }
167    if let Some(ref param_value) = p_username {
168        req_builder = match "multi" {
169            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("username".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
170            _ => req_builder.query(&[("username", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
171        };
172    }
173    if let Some(ref param_value) = p_key {
174        req_builder = match "multi" {
175            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("key".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
176            _ => req_builder.query(&[("key", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
177        };
178    }
179    req_builder = match "multi" {
180        "multi" => req_builder.query(&p_account_id.into_iter().map(|p| ("accountId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
181        _ => req_builder.query(&[("accountId", &p_account_id.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
182    };
183    if let Some(ref user_agent) = configuration.user_agent {
184        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
185    }
186    if let Some(ref token) = configuration.oauth_access_token {
187        req_builder = req_builder.bearer_auth(token.to_owned());
188    };
189    if let Some(ref auth_conf) = configuration.basic_auth {
190        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
191    };
192
193    let req = req_builder.build()?;
194    let resp = configuration.client.execute(req).await?;
195
196    let status = resp.status();
197
198    if !status.is_client_error() && !status.is_server_error() {
199        let content = resp.text().await?;
200        serde_json::from_str(&content).map_err(Error::from)
201    } else {
202        let content = resp.text().await?;
203        let entity: Option<BulkGetUsersError> = serde_json::from_str(&content).ok();
204        Err(Error::ResponseError(ResponseContent { status, content, entity }))
205    }
206}
207
208/// Returns the account IDs for the users specified in the `key` or `username` parameters. Note that multiple `key` or `username` parameters can be specified.  **[Permissions](#permissions) required:** Permission to access Jira.
209pub async fn bulk_get_users_migration(configuration: &configuration::Configuration, start_at: Option<i64>, max_results: Option<i32>, username: Option<Vec<String>>, key: Option<Vec<String>>) -> Result<Vec<models::UserMigrationBean>, Error<BulkGetUsersMigrationError>> {
210    // add a prefix to parameters to efficiently prevent name collisions
211    let p_start_at = start_at;
212    let p_max_results = max_results;
213    let p_username = username;
214    let p_key = key;
215
216    let uri_str = format!("{}/rest/api/2/user/bulk/migration", configuration.base_path);
217    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
218
219    if let Some(ref param_value) = p_start_at {
220        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
221    }
222    if let Some(ref param_value) = p_max_results {
223        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
224    }
225    if let Some(ref param_value) = p_username {
226        req_builder = match "multi" {
227            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("username".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
228            _ => req_builder.query(&[("username", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
229        };
230    }
231    if let Some(ref param_value) = p_key {
232        req_builder = match "multi" {
233            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("key".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
234            _ => req_builder.query(&[("key", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
235        };
236    }
237    if let Some(ref user_agent) = configuration.user_agent {
238        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
239    }
240    if let Some(ref token) = configuration.oauth_access_token {
241        req_builder = req_builder.bearer_auth(token.to_owned());
242    };
243    if let Some(ref auth_conf) = configuration.basic_auth {
244        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
245    };
246
247    let req = req_builder.build()?;
248    let resp = configuration.client.execute(req).await?;
249
250    let status = resp.status();
251
252    if !status.is_client_error() && !status.is_server_error() {
253        let content = resp.text().await?;
254        serde_json::from_str(&content).map_err(Error::from)
255    } else {
256        let content = resp.text().await?;
257        let entity: Option<BulkGetUsersMigrationError> = serde_json::from_str(&content).ok();
258        Err(Error::ResponseError(ResponseContent { status, content, entity }))
259    }
260}
261
262/// Creates a user. This resource is retained for legacy compatibility. As soon as a more suitable alternative is available this resource will be deprecated.  If the user exists and has access to Jira, the operation returns a 201 status. If the user exists but does not have access to Jira, the operation returns a 400 status.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
263pub async fn create_user(configuration: &configuration::Configuration, user_write_bean: models::UserWriteBean) -> Result<models::User, Error<CreateUserError>> {
264    // add a prefix to parameters to efficiently prevent name collisions
265    let p_user_write_bean = user_write_bean;
266
267    let uri_str = format!("{}/rest/api/2/user", configuration.base_path);
268    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
269
270    if let Some(ref user_agent) = configuration.user_agent {
271        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
272    }
273    if let Some(ref auth_conf) = configuration.basic_auth {
274        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
275    };
276    req_builder = req_builder.json(&p_user_write_bean);
277
278    let req = req_builder.build()?;
279    let resp = configuration.client.execute(req).await?;
280
281    let status = resp.status();
282
283    if !status.is_client_error() && !status.is_server_error() {
284        let content = resp.text().await?;
285        serde_json::from_str(&content).map_err(Error::from)
286    } else {
287        let content = resp.text().await?;
288        let entity: Option<CreateUserError> = serde_json::from_str(&content).ok();
289        Err(Error::ResponseError(ResponseContent { status, content, entity }))
290    }
291}
292
293/// Returns a list of all (active and inactive) users.  **[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
294pub async fn get_all_users(configuration: &configuration::Configuration, start_at: Option<i32>, max_results: Option<i32>) -> Result<Vec<models::User>, Error<GetAllUsersError>> {
295    // add a prefix to parameters to efficiently prevent name collisions
296    let p_start_at = start_at;
297    let p_max_results = max_results;
298
299    let uri_str = format!("{}/rest/api/2/users/search", configuration.base_path);
300    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
301
302    if let Some(ref param_value) = p_start_at {
303        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
304    }
305    if let Some(ref param_value) = p_max_results {
306        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
307    }
308    if let Some(ref user_agent) = configuration.user_agent {
309        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
310    }
311    if let Some(ref token) = configuration.oauth_access_token {
312        req_builder = req_builder.bearer_auth(token.to_owned());
313    };
314    if let Some(ref auth_conf) = configuration.basic_auth {
315        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
316    };
317
318    let req = req_builder.build()?;
319    let resp = configuration.client.execute(req).await?;
320
321    let status = resp.status();
322
323    if !status.is_client_error() && !status.is_server_error() {
324        let content = resp.text().await?;
325        serde_json::from_str(&content).map_err(Error::from)
326    } else {
327        let content = resp.text().await?;
328        let entity: Option<GetAllUsersError> = serde_json::from_str(&content).ok();
329        Err(Error::ResponseError(ResponseContent { status, content, entity }))
330    }
331}
332
333/// Returns a list of all (active and inactive) users.  **[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
334pub async fn get_all_users_default(configuration: &configuration::Configuration, start_at: Option<i32>, max_results: Option<i32>) -> Result<Vec<models::User>, Error<GetAllUsersDefaultError>> {
335    // add a prefix to parameters to efficiently prevent name collisions
336    let p_start_at = start_at;
337    let p_max_results = max_results;
338
339    let uri_str = format!("{}/rest/api/2/users", configuration.base_path);
340    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
341
342    if let Some(ref param_value) = p_start_at {
343        req_builder = req_builder.query(&[("startAt", &param_value.to_string())]);
344    }
345    if let Some(ref param_value) = p_max_results {
346        req_builder = req_builder.query(&[("maxResults", &param_value.to_string())]);
347    }
348    if let Some(ref user_agent) = configuration.user_agent {
349        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
350    }
351    if let Some(ref token) = configuration.oauth_access_token {
352        req_builder = req_builder.bearer_auth(token.to_owned());
353    };
354    if let Some(ref auth_conf) = configuration.basic_auth {
355        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
356    };
357
358    let req = req_builder.build()?;
359    let resp = configuration.client.execute(req).await?;
360
361    let status = resp.status();
362
363    if !status.is_client_error() && !status.is_server_error() {
364        let content = resp.text().await?;
365        serde_json::from_str(&content).map_err(Error::from)
366    } else {
367        let content = resp.text().await?;
368        let entity: Option<GetAllUsersDefaultError> = serde_json::from_str(&content).ok();
369        Err(Error::ResponseError(ResponseContent { status, content, entity }))
370    }
371}
372
373/// Returns a user.  **[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
374pub async fn get_user(configuration: &configuration::Configuration, account_id: Option<&str>, username: Option<&str>, key: Option<&str>, expand: Option<&str>) -> Result<models::User, Error<GetUserError>> {
375    // add a prefix to parameters to efficiently prevent name collisions
376    let p_account_id = account_id;
377    let p_username = username;
378    let p_key = key;
379    let p_expand = expand;
380
381    let uri_str = format!("{}/rest/api/2/user", configuration.base_path);
382    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
383
384    if let Some(ref param_value) = p_account_id {
385        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
386    }
387    if let Some(ref param_value) = p_username {
388        req_builder = req_builder.query(&[("username", &param_value.to_string())]);
389    }
390    if let Some(ref param_value) = p_key {
391        req_builder = req_builder.query(&[("key", &param_value.to_string())]);
392    }
393    if let Some(ref param_value) = p_expand {
394        req_builder = req_builder.query(&[("expand", &param_value.to_string())]);
395    }
396    if let Some(ref user_agent) = configuration.user_agent {
397        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
398    }
399    if let Some(ref token) = configuration.oauth_access_token {
400        req_builder = req_builder.bearer_auth(token.to_owned());
401    };
402    if let Some(ref auth_conf) = configuration.basic_auth {
403        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
404    };
405
406    let req = req_builder.build()?;
407    let resp = configuration.client.execute(req).await?;
408
409    let status = resp.status();
410
411    if !status.is_client_error() && !status.is_server_error() {
412        let content = resp.text().await?;
413        serde_json::from_str(&content).map_err(Error::from)
414    } else {
415        let content = resp.text().await?;
416        let entity: Option<GetUserError> = serde_json::from_str(&content).ok();
417        Err(Error::ResponseError(ResponseContent { status, content, entity }))
418    }
419}
420
421/// Returns the default [issue table columns](https://confluence.atlassian.com/x/XYdKLg) for the user. If `accountId` is not passed in the request, the calling user's details are returned.  **[Permissions](#permissions) required:**   *  *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLgl), to get the column details for any user.  *  Permission to access Jira, to get the calling user's column details.
422pub async fn get_user_default_columns(configuration: &configuration::Configuration, account_id: Option<&str>, username: Option<&str>) -> Result<Vec<models::ColumnItem>, Error<GetUserDefaultColumnsError>> {
423    // add a prefix to parameters to efficiently prevent name collisions
424    let p_account_id = account_id;
425    let p_username = username;
426
427    let uri_str = format!("{}/rest/api/2/user/columns", configuration.base_path);
428    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
429
430    if let Some(ref param_value) = p_account_id {
431        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
432    }
433    if let Some(ref param_value) = p_username {
434        req_builder = req_builder.query(&[("username", &param_value.to_string())]);
435    }
436    if let Some(ref user_agent) = configuration.user_agent {
437        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
438    }
439    if let Some(ref token) = configuration.oauth_access_token {
440        req_builder = req_builder.bearer_auth(token.to_owned());
441    };
442    if let Some(ref auth_conf) = configuration.basic_auth {
443        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
444    };
445
446    let req = req_builder.build()?;
447    let resp = configuration.client.execute(req).await?;
448
449    let status = resp.status();
450
451    if !status.is_client_error() && !status.is_server_error() {
452        let content = resp.text().await?;
453        serde_json::from_str(&content).map_err(Error::from)
454    } else {
455        let content = resp.text().await?;
456        let entity: Option<GetUserDefaultColumnsError> = serde_json::from_str(&content).ok();
457        Err(Error::ResponseError(ResponseContent { status, content, entity }))
458    }
459}
460
461/// Returns a user's email address. This API is only available to apps approved by Atlassian, according to these [guidelines](https://community.developer.atlassian.com/t/guidelines-for-requesting-access-to-email-address/27603).
462pub async fn get_user_email(configuration: &configuration::Configuration, account_id: &str) -> Result<models::UnrestrictedUserEmail, Error<GetUserEmailError>> {
463    // add a prefix to parameters to efficiently prevent name collisions
464    let p_account_id = account_id;
465
466    let uri_str = format!("{}/rest/api/2/user/email", configuration.base_path);
467    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
468
469    req_builder = req_builder.query(&[("accountId", &p_account_id.to_string())]);
470    if let Some(ref user_agent) = configuration.user_agent {
471        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
472    }
473    if let Some(ref auth_conf) = configuration.basic_auth {
474        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
475    };
476
477    let req = req_builder.build()?;
478    let resp = configuration.client.execute(req).await?;
479
480    let status = resp.status();
481
482    if !status.is_client_error() && !status.is_server_error() {
483        let content = resp.text().await?;
484        serde_json::from_str(&content).map_err(Error::from)
485    } else {
486        let content = resp.text().await?;
487        let entity: Option<GetUserEmailError> = serde_json::from_str(&content).ok();
488        Err(Error::ResponseError(ResponseContent { status, content, entity }))
489    }
490}
491
492/// Returns a user's email address. This API is only available to apps approved by Atlassian, according to these [guidelines](https://community.developer.atlassian.com/t/guidelines-for-requesting-access-to-email-address/27603).
493pub async fn get_user_email_bulk(configuration: &configuration::Configuration, account_id: Vec<String>) -> Result<models::UnrestrictedUserEmail, Error<GetUserEmailBulkError>> {
494    // add a prefix to parameters to efficiently prevent name collisions
495    let p_account_id = account_id;
496
497    let uri_str = format!("{}/rest/api/2/user/email/bulk", configuration.base_path);
498    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
499
500    req_builder = match "multi" {
501        "multi" => req_builder.query(&p_account_id.into_iter().map(|p| ("accountId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
502        _ => req_builder.query(&[("accountId", &p_account_id.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
503    };
504    if let Some(ref user_agent) = configuration.user_agent {
505        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
506    }
507    if let Some(ref auth_conf) = configuration.basic_auth {
508        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
509    };
510
511    let req = req_builder.build()?;
512    let resp = configuration.client.execute(req).await?;
513
514    let status = resp.status();
515
516    if !status.is_client_error() && !status.is_server_error() {
517        let content = resp.text().await?;
518        serde_json::from_str(&content).map_err(Error::from)
519    } else {
520        let content = resp.text().await?;
521        let entity: Option<GetUserEmailBulkError> = serde_json::from_str(&content).ok();
522        Err(Error::ResponseError(ResponseContent { status, content, entity }))
523    }
524}
525
526/// Returns the groups to which a user belongs.  **[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
527pub async fn get_user_groups(configuration: &configuration::Configuration, account_id: &str, username: Option<&str>, key: Option<&str>) -> Result<Vec<models::GroupName>, Error<GetUserGroupsError>> {
528    // add a prefix to parameters to efficiently prevent name collisions
529    let p_account_id = account_id;
530    let p_username = username;
531    let p_key = key;
532
533    let uri_str = format!("{}/rest/api/2/user/groups", configuration.base_path);
534    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
535
536    req_builder = req_builder.query(&[("accountId", &p_account_id.to_string())]);
537    if let Some(ref param_value) = p_username {
538        req_builder = req_builder.query(&[("username", &param_value.to_string())]);
539    }
540    if let Some(ref param_value) = p_key {
541        req_builder = req_builder.query(&[("key", &param_value.to_string())]);
542    }
543    if let Some(ref user_agent) = configuration.user_agent {
544        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
545    }
546    if let Some(ref token) = configuration.oauth_access_token {
547        req_builder = req_builder.bearer_auth(token.to_owned());
548    };
549    if let Some(ref auth_conf) = configuration.basic_auth {
550        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
551    };
552
553    let req = req_builder.build()?;
554    let resp = configuration.client.execute(req).await?;
555
556    let status = resp.status();
557
558    if !status.is_client_error() && !status.is_server_error() {
559        let content = resp.text().await?;
560        serde_json::from_str(&content).map_err(Error::from)
561    } else {
562        let content = resp.text().await?;
563        let entity: Option<GetUserGroupsError> = serde_json::from_str(&content).ok();
564        Err(Error::ResponseError(ResponseContent { status, content, entity }))
565    }
566}
567
568/// Deletes a user.  **[Permissions](#permissions) required:** Site administration (that is, membership of the *site-admin* [group](https://confluence.atlassian.com/x/24xjL)).
569pub async fn remove_user(configuration: &configuration::Configuration, account_id: &str, username: Option<&str>, key: Option<&str>) -> Result<(), Error<RemoveUserError>> {
570    // add a prefix to parameters to efficiently prevent name collisions
571    let p_account_id = account_id;
572    let p_username = username;
573    let p_key = key;
574
575    let uri_str = format!("{}/rest/api/2/user", configuration.base_path);
576    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
577
578    req_builder = req_builder.query(&[("accountId", &p_account_id.to_string())]);
579    if let Some(ref param_value) = p_username {
580        req_builder = req_builder.query(&[("username", &param_value.to_string())]);
581    }
582    if let Some(ref param_value) = p_key {
583        req_builder = req_builder.query(&[("key", &param_value.to_string())]);
584    }
585    if let Some(ref user_agent) = configuration.user_agent {
586        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
587    }
588    if let Some(ref auth_conf) = configuration.basic_auth {
589        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
590    };
591
592    let req = req_builder.build()?;
593    let resp = configuration.client.execute(req).await?;
594
595    let status = resp.status();
596
597    if !status.is_client_error() && !status.is_server_error() {
598        Ok(())
599    } else {
600        let content = resp.text().await?;
601        let entity: Option<RemoveUserError> = serde_json::from_str(&content).ok();
602        Err(Error::ResponseError(ResponseContent { status, content, entity }))
603    }
604}
605
606/// Resets the default [ issue table columns](https://confluence.atlassian.com/x/XYdKLg) for the user to the system default. If `accountId` is not passed, the calling user's default columns are reset.  **[Permissions](#permissions) required:**   *  *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg), to set the columns on any user.  *  Permission to access Jira, to set the calling user's columns.
607pub async fn reset_user_columns(configuration: &configuration::Configuration, account_id: Option<&str>, username: Option<&str>) -> Result<(), Error<ResetUserColumnsError>> {
608    // add a prefix to parameters to efficiently prevent name collisions
609    let p_account_id = account_id;
610    let p_username = username;
611
612    let uri_str = format!("{}/rest/api/2/user/columns", configuration.base_path);
613    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
614
615    if let Some(ref param_value) = p_account_id {
616        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
617    }
618    if let Some(ref param_value) = p_username {
619        req_builder = req_builder.query(&[("username", &param_value.to_string())]);
620    }
621    if let Some(ref user_agent) = configuration.user_agent {
622        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
623    }
624    if let Some(ref auth_conf) = configuration.basic_auth {
625        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
626    };
627
628    let req = req_builder.build()?;
629    let resp = configuration.client.execute(req).await?;
630
631    let status = resp.status();
632
633    if !status.is_client_error() && !status.is_server_error() {
634        Ok(())
635    } else {
636        let content = resp.text().await?;
637        let entity: Option<ResetUserColumnsError> = serde_json::from_str(&content).ok();
638        Err(Error::ResponseError(ResponseContent { status, content, entity }))
639    }
640}
641
642/// Sets the default [ issue table columns](https://confluence.atlassian.com/x/XYdKLg) for the user. If an account ID is not passed, the calling user's default columns are set. If no column details are sent, then all default columns are removed.  The parameters for this resource are expressed as HTML form data. For example, in curl:  `curl -X PUT -d columns=summary -d columns=description https://your-domain.atlassian.net/rest/api/2/user/columns?accountId=5b10ac8d82e05b22cc7d4ef5'`  **[Permissions](#permissions) required:**   *  *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg), to set the columns on any user.  *  Permission to access Jira, to set the calling user's columns.
643pub async fn set_user_columns(configuration: &configuration::Configuration, account_id: Option<&str>, request_body: Option<Vec<String>>) -> Result<serde_json::Value, Error<SetUserColumnsError>> {
644    // add a prefix to parameters to efficiently prevent name collisions
645    let p_account_id = account_id;
646    let p_request_body = request_body;
647
648    let uri_str = format!("{}/rest/api/2/user/columns", configuration.base_path);
649    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
650
651    if let Some(ref param_value) = p_account_id {
652        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
653    }
654    if let Some(ref user_agent) = configuration.user_agent {
655        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
656    }
657    if let Some(ref auth_conf) = configuration.basic_auth {
658        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
659    };
660    req_builder = req_builder.json(&p_request_body);
661
662    let req = req_builder.build()?;
663    let resp = configuration.client.execute(req).await?;
664
665    let status = resp.status();
666
667    if !status.is_client_error() && !status.is_server_error() {
668        let content = resp.text().await?;
669        serde_json::from_str(&content).map_err(Error::from)
670    } else {
671        let content = resp.text().await?;
672        let entity: Option<SetUserColumnsError> = serde_json::from_str(&content).ok();
673        Err(Error::ResponseError(ResponseContent { status, content, entity }))
674    }
675}
676