hi_jira2/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;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method [`bulk_get_users`]
18#[derive(Clone, Debug, Default)]
19pub struct BulkGetUsersParams {
20    /// The account ID of a user. To specify multiple users, pass multiple `accountId` parameters. For example, `accountId=5b10a2844c20165700ede21g&accountId=5b10ac8d82e05b22cc7d4ef5`.
21    pub account_id: Vec<String>,
22    /// The index of the first item to return in a page of results (page offset).
23    pub start_at: Option<i64>,
24    /// The maximum number of items to return per page.
25    pub max_results: Option<i32>,
26    /// This parameter is no longer available and will be removed from the documentation soon. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details.
27    pub username: Option<Vec<String>>,
28    /// This parameter is no longer available and will be removed from the documentation soon. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details.
29    pub key: Option<Vec<String>>
30}
31
32/// struct for passing parameters to the method [`bulk_get_users_migration`]
33#[derive(Clone, Debug, Default)]
34pub struct BulkGetUsersMigrationParams {
35    /// The index of the first item to return in a page of results (page offset).
36    pub start_at: Option<i64>,
37    /// The maximum number of items to return per page.
38    pub max_results: Option<i32>,
39    /// Username of a user. To specify multiple users, pass multiple copies of this parameter. For example, `username=fred&username=barney`. Required if `key` isn't provided. Cannot be provided if `key` is present.
40    pub username: Option<Vec<String>>,
41    /// Key of a user. To specify multiple users, pass multiple copies of this parameter. For example, `key=fred&key=barney`. Required if `username` isn't provided. Cannot be provided if `username` is present.
42    pub key: Option<Vec<String>>
43}
44
45/// struct for passing parameters to the method [`create_user`]
46#[derive(Clone, Debug, Default)]
47pub struct CreateUserParams {
48    /// Details about the user to be created.
49    pub request_body: ::std::collections::HashMap<String, serde_json::Value>
50}
51
52/// struct for passing parameters to the method [`get_all_users`]
53#[derive(Clone, Debug, Default)]
54pub struct GetAllUsersParams {
55    /// The index of the first item to return.
56    pub start_at: Option<i32>,
57    /// The maximum number of items to return.
58    pub max_results: Option<i32>
59}
60
61/// struct for passing parameters to the method [`get_all_users_default`]
62#[derive(Clone, Debug, Default)]
63pub struct GetAllUsersDefaultParams {
64    /// The index of the first item to return.
65    pub start_at: Option<i32>,
66    /// The maximum number of items to return.
67    pub max_results: Option<i32>
68}
69
70/// struct for passing parameters to the method [`get_user`]
71#[derive(Clone, Debug, Default)]
72pub struct GetUserParams {
73    /// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*. Required.
74    pub account_id: Option<String>,
75    /// This parameter is no longer available. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide) for details.
76    pub username: Option<String>,
77    /// This parameter is no longer available. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide) for details.
78    pub key: Option<String>,
79    /// Use [expand](#expansion) to include additional information about users in the response. This parameter accepts a comma-separated list. Expand options include:   *  `groups` includes all groups and nested groups to which the user belongs.  *  `applicationRoles` includes details of all the applications to which the user has access.
80    pub expand: Option<String>
81}
82
83/// struct for passing parameters to the method [`get_user_default_columns`]
84#[derive(Clone, Debug, Default)]
85pub struct GetUserDefaultColumnsParams {
86    /// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*.
87    pub account_id: Option<String>,
88    /// This parameter is no longer available See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details.
89    pub username: Option<String>
90}
91
92/// struct for passing parameters to the method [`get_user_email`]
93#[derive(Clone, Debug, Default)]
94pub struct GetUserEmailParams {
95    /// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, `5b10ac8d82e05b22cc7d4ef5`.
96    pub account_id: String
97}
98
99/// struct for passing parameters to the method [`get_user_email_bulk`]
100#[derive(Clone, Debug, Default)]
101pub struct GetUserEmailBulkParams {
102    /// The account IDs of the users for which emails are required. An `accountId` is an identifier that uniquely identifies the user across all Atlassian products. For example, `5b10ac8d82e05b22cc7d4ef5`. Note, this should be treated as an opaque identifier (that is, do not assume any structure in the value).
103    pub account_id: Vec<String>
104}
105
106/// struct for passing parameters to the method [`get_user_groups`]
107#[derive(Clone, Debug, Default)]
108pub struct GetUserGroupsParams {
109    /// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*.
110    pub account_id: String,
111    /// This parameter is no longer available. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details.
112    pub username: Option<String>,
113    /// This parameter is no longer available. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details.
114    pub key: Option<String>
115}
116
117/// struct for passing parameters to the method [`remove_user`]
118#[derive(Clone, Debug, Default)]
119pub struct RemoveUserParams {
120    /// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*.
121    pub account_id: String,
122    /// This parameter is no longer available. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details.
123    pub username: Option<String>,
124    /// This parameter is no longer available. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details.
125    pub key: Option<String>
126}
127
128/// struct for passing parameters to the method [`reset_user_columns`]
129#[derive(Clone, Debug, Default)]
130pub struct ResetUserColumnsParams {
131    /// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*.
132    pub account_id: Option<String>,
133    /// This parameter is no longer available. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details.
134    pub username: Option<String>
135}
136
137/// struct for passing parameters to the method [`set_user_columns`]
138#[derive(Clone, Debug, Default)]
139pub struct SetUserColumnsParams {
140    /// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*.
141    pub account_id: Option<String>,
142    /// The ID of a column to set. To set multiple columns, send multiple `columns` parameters.
143    pub request_body: Option<Vec<String>>
144}
145
146
147/// struct for typed errors of method [`bulk_get_users`]
148#[derive(Debug, Clone, Serialize, Deserialize)]
149#[serde(untagged)]
150pub enum BulkGetUsersError {
151    Status400(),
152    Status401(),
153    UnknownValue(serde_json::Value),
154}
155
156/// struct for typed errors of method [`bulk_get_users_migration`]
157#[derive(Debug, Clone, Serialize, Deserialize)]
158#[serde(untagged)]
159pub enum BulkGetUsersMigrationError {
160    Status400(),
161    Status401(),
162    UnknownValue(serde_json::Value),
163}
164
165/// struct for typed errors of method [`create_user`]
166#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum CreateUserError {
169    Status400(),
170    Status401(),
171    Status403(),
172    UnknownValue(serde_json::Value),
173}
174
175/// struct for typed errors of method [`get_all_users`]
176#[derive(Debug, Clone, Serialize, Deserialize)]
177#[serde(untagged)]
178pub enum GetAllUsersError {
179    Status400(),
180    Status403(),
181    Status409(),
182    UnknownValue(serde_json::Value),
183}
184
185/// struct for typed errors of method [`get_all_users_default`]
186#[derive(Debug, Clone, Serialize, Deserialize)]
187#[serde(untagged)]
188pub enum GetAllUsersDefaultError {
189    Status400(),
190    Status403(),
191    Status409(),
192    UnknownValue(serde_json::Value),
193}
194
195/// struct for typed errors of method [`get_user`]
196#[derive(Debug, Clone, Serialize, Deserialize)]
197#[serde(untagged)]
198pub enum GetUserError {
199    Status401(),
200    Status403(),
201    Status404(),
202    UnknownValue(serde_json::Value),
203}
204
205/// struct for typed errors of method [`get_user_default_columns`]
206#[derive(Debug, Clone, Serialize, Deserialize)]
207#[serde(untagged)]
208pub enum GetUserDefaultColumnsError {
209    Status401(),
210    Status403(),
211    Status404(),
212    UnknownValue(serde_json::Value),
213}
214
215/// struct for typed errors of method [`get_user_email`]
216#[derive(Debug, Clone, Serialize, Deserialize)]
217#[serde(untagged)]
218pub enum GetUserEmailError {
219    Status400(),
220    Status401(),
221    Status404(),
222    Status503(),
223    UnknownValue(serde_json::Value),
224}
225
226/// struct for typed errors of method [`get_user_email_bulk`]
227#[derive(Debug, Clone, Serialize, Deserialize)]
228#[serde(untagged)]
229pub enum GetUserEmailBulkError {
230    Status400(),
231    Status401(),
232    Status503(),
233    UnknownValue(serde_json::Value),
234}
235
236/// struct for typed errors of method [`get_user_groups`]
237#[derive(Debug, Clone, Serialize, Deserialize)]
238#[serde(untagged)]
239pub enum GetUserGroupsError {
240    Status401(),
241    Status403(),
242    Status404(),
243    UnknownValue(serde_json::Value),
244}
245
246/// struct for typed errors of method [`remove_user`]
247#[derive(Debug, Clone, Serialize, Deserialize)]
248#[serde(untagged)]
249pub enum RemoveUserError {
250    Status400(),
251    Status401(),
252    Status403(),
253    Status404(),
254    UnknownValue(serde_json::Value),
255}
256
257/// struct for typed errors of method [`reset_user_columns`]
258#[derive(Debug, Clone, Serialize, Deserialize)]
259#[serde(untagged)]
260pub enum ResetUserColumnsError {
261    Status401(),
262    Status403(),
263    UnknownValue(serde_json::Value),
264}
265
266/// struct for typed errors of method [`set_user_columns`]
267#[derive(Debug, Clone, Serialize, Deserialize)]
268#[serde(untagged)]
269pub enum SetUserColumnsError {
270    Status401(),
271    Status403(),
272    Status404(),
273    Status500(),
274    UnknownValue(serde_json::Value),
275}
276
277
278/// Returns a [paginated](#pagination) list of the users specified by one or more account IDs.  **[Permissions](#permissions) required:** Permission to access Jira.
279pub async fn bulk_get_users(configuration: &configuration::Configuration, params: BulkGetUsersParams) -> Result<crate::models::PageBeanUser, Error<BulkGetUsersError>> {
280    let local_var_configuration = configuration;
281
282    // unbox the parameters
283    let account_id = params.account_id;
284    let start_at = params.start_at;
285    let max_results = params.max_results;
286    let username = params.username;
287    let key = params.key;
288
289
290    let local_var_client = &local_var_configuration.client;
291
292    let local_var_uri_str = format!("{}/rest/api/2/user/bulk", local_var_configuration.base_path);
293    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
294
295    if let Some(ref local_var_str) = start_at {
296        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
297    }
298    if let Some(ref local_var_str) = max_results {
299        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
300    }
301    if let Some(ref local_var_str) = username {
302        local_var_req_builder = match "multi" {
303            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("username".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
304            _ => local_var_req_builder.query(&[("username", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
305        };
306    }
307    if let Some(ref local_var_str) = key {
308        local_var_req_builder = match "multi" {
309            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("key".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
310            _ => local_var_req_builder.query(&[("key", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
311        };
312    }
313    local_var_req_builder = match "multi" {
314        "multi" => local_var_req_builder.query(&account_id.into_iter().map(|p| ("accountId".to_owned(), p)).collect::<Vec<(std::string::String, std::string::String)>>()),
315        _ => local_var_req_builder.query(&[("accountId", &account_id.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
316    };
317    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
318        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
319    }
320    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
321        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
322    };
323    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
324        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
325    };
326
327    let local_var_req = local_var_req_builder.build()?;
328    let local_var_resp = local_var_client.execute(local_var_req).await?;
329
330    let local_var_status = local_var_resp.status();
331    let local_var_content = local_var_resp.text().await?;
332
333    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
334        serde_json::from_str(&local_var_content).map_err(Error::from)
335    } else {
336        let local_var_entity: Option<BulkGetUsersError> = serde_json::from_str(&local_var_content).ok();
337        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
338        Err(Error::ResponseError(local_var_error))
339    }
340}
341
342/// 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.
343pub async fn bulk_get_users_migration(configuration: &configuration::Configuration, params: BulkGetUsersMigrationParams) -> Result<Vec<crate::models::UserMigrationBean>, Error<BulkGetUsersMigrationError>> {
344    let local_var_configuration = configuration;
345
346    // unbox the parameters
347    let start_at = params.start_at;
348    let max_results = params.max_results;
349    let username = params.username;
350    let key = params.key;
351
352
353    let local_var_client = &local_var_configuration.client;
354
355    let local_var_uri_str = format!("{}/rest/api/2/user/bulk/migration", local_var_configuration.base_path);
356    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
357
358    if let Some(ref local_var_str) = start_at {
359        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
360    }
361    if let Some(ref local_var_str) = max_results {
362        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
363    }
364    if let Some(ref local_var_str) = username {
365        local_var_req_builder = match "multi" {
366            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("username".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
367            _ => local_var_req_builder.query(&[("username", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
368        };
369    }
370    if let Some(ref local_var_str) = key {
371        local_var_req_builder = match "multi" {
372            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("key".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
373            _ => local_var_req_builder.query(&[("key", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
374        };
375    }
376    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
377        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
378    }
379    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
380        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
381    };
382    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
383        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
384    };
385
386    let local_var_req = local_var_req_builder.build()?;
387    let local_var_resp = local_var_client.execute(local_var_req).await?;
388
389    let local_var_status = local_var_resp.status();
390    let local_var_content = local_var_resp.text().await?;
391
392    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
393        serde_json::from_str(&local_var_content).map_err(Error::from)
394    } else {
395        let local_var_entity: Option<BulkGetUsersMigrationError> = serde_json::from_str(&local_var_content).ok();
396        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
397        Err(Error::ResponseError(local_var_error))
398    }
399}
400
401/// 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).
402pub async fn create_user(configuration: &configuration::Configuration, params: CreateUserParams) -> Result<crate::models::User, Error<CreateUserError>> {
403    let local_var_configuration = configuration;
404
405    // unbox the parameters
406    let request_body = params.request_body;
407
408
409    let local_var_client = &local_var_configuration.client;
410
411    let local_var_uri_str = format!("{}/rest/api/2/user", local_var_configuration.base_path);
412    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
413
414    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
415        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
416    }
417    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
418        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
419    };
420    local_var_req_builder = local_var_req_builder.json(&request_body);
421
422    let local_var_req = local_var_req_builder.build()?;
423    let local_var_resp = local_var_client.execute(local_var_req).await?;
424
425    let local_var_status = local_var_resp.status();
426    let local_var_content = local_var_resp.text().await?;
427
428    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
429        serde_json::from_str(&local_var_content).map_err(Error::from)
430    } else {
431        let local_var_entity: Option<CreateUserError> = serde_json::from_str(&local_var_content).ok();
432        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
433        Err(Error::ResponseError(local_var_error))
434    }
435}
436
437/// Returns a list of all (active and inactive) users.  Privacy controls are applied to the response based on the users' preferences. This could mean, for example, that the user's email address is hidden. See the [Profile visibility overview](https://developer.atlassian.com/cloud/jira/platform/profile-visibility/) for more details.  **[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
438pub async fn get_all_users(configuration: &configuration::Configuration, params: GetAllUsersParams) -> Result<Vec<crate::models::User>, Error<GetAllUsersError>> {
439    let local_var_configuration = configuration;
440
441    // unbox the parameters
442    let start_at = params.start_at;
443    let max_results = params.max_results;
444
445
446    let local_var_client = &local_var_configuration.client;
447
448    let local_var_uri_str = format!("{}/rest/api/2/users/search", local_var_configuration.base_path);
449    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
450
451    if let Some(ref local_var_str) = start_at {
452        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
453    }
454    if let Some(ref local_var_str) = max_results {
455        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
456    }
457    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
458        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
459    }
460    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
461        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
462    };
463    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
464        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
465    };
466
467    let local_var_req = local_var_req_builder.build()?;
468    let local_var_resp = local_var_client.execute(local_var_req).await?;
469
470    let local_var_status = local_var_resp.status();
471    let local_var_content = local_var_resp.text().await?;
472
473    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
474        serde_json::from_str(&local_var_content).map_err(Error::from)
475    } else {
476        let local_var_entity: Option<GetAllUsersError> = serde_json::from_str(&local_var_content).ok();
477        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
478        Err(Error::ResponseError(local_var_error))
479    }
480}
481
482/// Returns a list of all (active and inactive) users.  Privacy controls are applied to the response based on the users' preferences. This could mean, for example, that the user's email address is hidden. See the [Profile visibility overview](https://developer.atlassian.com/cloud/jira/platform/profile-visibility/) for more details.  **[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
483pub async fn get_all_users_default(configuration: &configuration::Configuration, params: GetAllUsersDefaultParams) -> Result<Vec<crate::models::User>, Error<GetAllUsersDefaultError>> {
484    let local_var_configuration = configuration;
485
486    // unbox the parameters
487    let start_at = params.start_at;
488    let max_results = params.max_results;
489
490
491    let local_var_client = &local_var_configuration.client;
492
493    let local_var_uri_str = format!("{}/rest/api/2/users", local_var_configuration.base_path);
494    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
495
496    if let Some(ref local_var_str) = start_at {
497        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
498    }
499    if let Some(ref local_var_str) = max_results {
500        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
501    }
502    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
503        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
504    }
505    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
506        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
507    };
508    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
509        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
510    };
511
512    let local_var_req = local_var_req_builder.build()?;
513    let local_var_resp = local_var_client.execute(local_var_req).await?;
514
515    let local_var_status = local_var_resp.status();
516    let local_var_content = local_var_resp.text().await?;
517
518    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
519        serde_json::from_str(&local_var_content).map_err(Error::from)
520    } else {
521        let local_var_entity: Option<GetAllUsersDefaultError> = serde_json::from_str(&local_var_content).ok();
522        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
523        Err(Error::ResponseError(local_var_error))
524    }
525}
526
527/// Returns a user.  Privacy controls are applied to the response based on the user's preferences. This could mean, for example, that the user's email address is hidden. See the [Profile visibility overview](https://developer.atlassian.com/cloud/jira/platform/profile-visibility/) for more details.  **[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
528pub async fn get_user(configuration: &configuration::Configuration, params: GetUserParams) -> Result<crate::models::User, Error<GetUserError>> {
529    let local_var_configuration = configuration;
530
531    // unbox the parameters
532    let account_id = params.account_id;
533    let username = params.username;
534    let key = params.key;
535    let expand = params.expand;
536
537
538    let local_var_client = &local_var_configuration.client;
539
540    let local_var_uri_str = format!("{}/rest/api/2/user", local_var_configuration.base_path);
541    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
542
543    if let Some(ref local_var_str) = account_id {
544        local_var_req_builder = local_var_req_builder.query(&[("accountId", &local_var_str.to_string())]);
545    }
546    if let Some(ref local_var_str) = username {
547        local_var_req_builder = local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
548    }
549    if let Some(ref local_var_str) = key {
550        local_var_req_builder = local_var_req_builder.query(&[("key", &local_var_str.to_string())]);
551    }
552    if let Some(ref local_var_str) = expand {
553        local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
554    }
555    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
556        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
557    }
558    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
559        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
560    };
561    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
562        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
563    };
564
565    let local_var_req = local_var_req_builder.build()?;
566    let local_var_resp = local_var_client.execute(local_var_req).await?;
567
568    let local_var_status = local_var_resp.status();
569    let local_var_content = local_var_resp.text().await?;
570
571    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
572        serde_json::from_str(&local_var_content).map_err(Error::from)
573    } else {
574        let local_var_entity: Option<GetUserError> = serde_json::from_str(&local_var_content).ok();
575        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
576        Err(Error::ResponseError(local_var_error))
577    }
578}
579
580/// 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.
581pub async fn get_user_default_columns(configuration: &configuration::Configuration, params: GetUserDefaultColumnsParams) -> Result<Vec<crate::models::ColumnItem>, Error<GetUserDefaultColumnsError>> {
582    let local_var_configuration = configuration;
583
584    // unbox the parameters
585    let account_id = params.account_id;
586    let username = params.username;
587
588
589    let local_var_client = &local_var_configuration.client;
590
591    let local_var_uri_str = format!("{}/rest/api/2/user/columns", local_var_configuration.base_path);
592    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
593
594    if let Some(ref local_var_str) = account_id {
595        local_var_req_builder = local_var_req_builder.query(&[("accountId", &local_var_str.to_string())]);
596    }
597    if let Some(ref local_var_str) = username {
598        local_var_req_builder = local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
599    }
600    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
601        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
602    }
603    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
604        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
605    };
606    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
607        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
608    };
609
610    let local_var_req = local_var_req_builder.build()?;
611    let local_var_resp = local_var_client.execute(local_var_req).await?;
612
613    let local_var_status = local_var_resp.status();
614    let local_var_content = local_var_resp.text().await?;
615
616    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
617        serde_json::from_str(&local_var_content).map_err(Error::from)
618    } else {
619        let local_var_entity: Option<GetUserDefaultColumnsError> = serde_json::from_str(&local_var_content).ok();
620        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
621        Err(Error::ResponseError(local_var_error))
622    }
623}
624
625/// 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).
626pub async fn get_user_email(configuration: &configuration::Configuration, params: GetUserEmailParams) -> Result<crate::models::UnrestrictedUserEmail, Error<GetUserEmailError>> {
627    let local_var_configuration = configuration;
628
629    // unbox the parameters
630    let account_id = params.account_id;
631
632
633    let local_var_client = &local_var_configuration.client;
634
635    let local_var_uri_str = format!("{}/rest/api/2/user/email", local_var_configuration.base_path);
636    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
637
638    local_var_req_builder = local_var_req_builder.query(&[("accountId", &account_id.to_string())]);
639    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
640        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
641    }
642    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
643        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
644    };
645
646    let local_var_req = local_var_req_builder.build()?;
647    let local_var_resp = local_var_client.execute(local_var_req).await?;
648
649    let local_var_status = local_var_resp.status();
650    let local_var_content = local_var_resp.text().await?;
651
652    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
653        serde_json::from_str(&local_var_content).map_err(Error::from)
654    } else {
655        let local_var_entity: Option<GetUserEmailError> = serde_json::from_str(&local_var_content).ok();
656        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
657        Err(Error::ResponseError(local_var_error))
658    }
659}
660
661/// 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).
662pub async fn get_user_email_bulk(configuration: &configuration::Configuration, params: GetUserEmailBulkParams) -> Result<crate::models::UnrestrictedUserEmail, Error<GetUserEmailBulkError>> {
663    let local_var_configuration = configuration;
664
665    // unbox the parameters
666    let account_id = params.account_id;
667
668
669    let local_var_client = &local_var_configuration.client;
670
671    let local_var_uri_str = format!("{}/rest/api/2/user/email/bulk", local_var_configuration.base_path);
672    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
673
674    local_var_req_builder = match "multi" {
675        "multi" => local_var_req_builder.query(&account_id.into_iter().map(|p| ("accountId".to_owned(), p)).collect::<Vec<(std::string::String, std::string::String)>>()),
676        _ => local_var_req_builder.query(&[("accountId", &account_id.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
677    };
678    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
679        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
680    }
681    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
682        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
683    };
684
685    let local_var_req = local_var_req_builder.build()?;
686    let local_var_resp = local_var_client.execute(local_var_req).await?;
687
688    let local_var_status = local_var_resp.status();
689    let local_var_content = local_var_resp.text().await?;
690
691    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
692        serde_json::from_str(&local_var_content).map_err(Error::from)
693    } else {
694        let local_var_entity: Option<GetUserEmailBulkError> = serde_json::from_str(&local_var_content).ok();
695        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
696        Err(Error::ResponseError(local_var_error))
697    }
698}
699
700/// Returns the groups to which a user belongs.  **[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
701pub async fn get_user_groups(configuration: &configuration::Configuration, params: GetUserGroupsParams) -> Result<Vec<crate::models::GroupName>, Error<GetUserGroupsError>> {
702    let local_var_configuration = configuration;
703
704    // unbox the parameters
705    let account_id = params.account_id;
706    let username = params.username;
707    let key = params.key;
708
709
710    let local_var_client = &local_var_configuration.client;
711
712    let local_var_uri_str = format!("{}/rest/api/2/user/groups", local_var_configuration.base_path);
713    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
714
715    local_var_req_builder = local_var_req_builder.query(&[("accountId", &account_id.to_string())]);
716    if let Some(ref local_var_str) = username {
717        local_var_req_builder = local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
718    }
719    if let Some(ref local_var_str) = key {
720        local_var_req_builder = local_var_req_builder.query(&[("key", &local_var_str.to_string())]);
721    }
722    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
723        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
724    }
725    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
726        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
727    };
728    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
729        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
730    };
731
732    let local_var_req = local_var_req_builder.build()?;
733    let local_var_resp = local_var_client.execute(local_var_req).await?;
734
735    let local_var_status = local_var_resp.status();
736    let local_var_content = local_var_resp.text().await?;
737
738    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
739        serde_json::from_str(&local_var_content).map_err(Error::from)
740    } else {
741        let local_var_entity: Option<GetUserGroupsError> = serde_json::from_str(&local_var_content).ok();
742        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
743        Err(Error::ResponseError(local_var_error))
744    }
745}
746
747/// Deletes a user. If the operation completes successfully then the user is removed from Jira's user base. This operation does not delete the user's Atlassian account.  **[Permissions](#permissions) required:** Site administration (that is, membership of the *site-admin* [group](https://confluence.atlassian.com/x/24xjL)).
748pub async fn remove_user(configuration: &configuration::Configuration, params: RemoveUserParams) -> Result<(), Error<RemoveUserError>> {
749    let local_var_configuration = configuration;
750
751    // unbox the parameters
752    let account_id = params.account_id;
753    let username = params.username;
754    let key = params.key;
755
756
757    let local_var_client = &local_var_configuration.client;
758
759    let local_var_uri_str = format!("{}/rest/api/2/user", local_var_configuration.base_path);
760    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
761
762    local_var_req_builder = local_var_req_builder.query(&[("accountId", &account_id.to_string())]);
763    if let Some(ref local_var_str) = username {
764        local_var_req_builder = local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
765    }
766    if let Some(ref local_var_str) = key {
767        local_var_req_builder = local_var_req_builder.query(&[("key", &local_var_str.to_string())]);
768    }
769    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
770        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
771    }
772    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
773        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
774    };
775
776    let local_var_req = local_var_req_builder.build()?;
777    let local_var_resp = local_var_client.execute(local_var_req).await?;
778
779    let local_var_status = local_var_resp.status();
780    let local_var_content = local_var_resp.text().await?;
781
782    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
783        Ok(())
784    } else {
785        let local_var_entity: Option<RemoveUserError> = serde_json::from_str(&local_var_content).ok();
786        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
787        Err(Error::ResponseError(local_var_error))
788    }
789}
790
791/// 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.
792pub async fn reset_user_columns(configuration: &configuration::Configuration, params: ResetUserColumnsParams) -> Result<(), Error<ResetUserColumnsError>> {
793    let local_var_configuration = configuration;
794
795    // unbox the parameters
796    let account_id = params.account_id;
797    let username = params.username;
798
799
800    let local_var_client = &local_var_configuration.client;
801
802    let local_var_uri_str = format!("{}/rest/api/2/user/columns", local_var_configuration.base_path);
803    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
804
805    if let Some(ref local_var_str) = account_id {
806        local_var_req_builder = local_var_req_builder.query(&[("accountId", &local_var_str.to_string())]);
807    }
808    if let Some(ref local_var_str) = username {
809        local_var_req_builder = local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
810    }
811    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
812        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
813    }
814    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
815        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
816    };
817
818    let local_var_req = local_var_req_builder.build()?;
819    let local_var_resp = local_var_client.execute(local_var_req).await?;
820
821    let local_var_status = local_var_resp.status();
822    let local_var_content = local_var_resp.text().await?;
823
824    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
825        Ok(())
826    } else {
827        let local_var_entity: Option<ResetUserColumnsError> = serde_json::from_str(&local_var_content).ok();
828        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
829        Err(Error::ResponseError(local_var_error))
830    }
831}
832
833/// 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.
834pub async fn set_user_columns(configuration: &configuration::Configuration, params: SetUserColumnsParams) -> Result<serde_json::Value, Error<SetUserColumnsError>> {
835    let local_var_configuration = configuration;
836
837    // unbox the parameters
838    let account_id = params.account_id;
839    let request_body = params.request_body;
840
841
842    let local_var_client = &local_var_configuration.client;
843
844    let local_var_uri_str = format!("{}/rest/api/2/user/columns", local_var_configuration.base_path);
845    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
846
847    if let Some(ref local_var_str) = account_id {
848        local_var_req_builder = local_var_req_builder.query(&[("accountId", &local_var_str.to_string())]);
849    }
850    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
851        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
852    }
853    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
854        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
855    };
856    local_var_req_builder = local_var_req_builder.json(&request_body);
857
858    let local_var_req = local_var_req_builder.build()?;
859    let local_var_resp = local_var_client.execute(local_var_req).await?;
860
861    let local_var_status = local_var_resp.status();
862    let local_var_content = local_var_resp.text().await?;
863
864    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
865        serde_json::from_str(&local_var_content).map_err(Error::from)
866    } else {
867        let local_var_entity: Option<SetUserColumnsError> = serde_json::from_str(&local_var_content).ok();
868        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
869        Err(Error::ResponseError(local_var_error))
870    }
871}
872