/*
* The Jira Cloud platform REST API
*
* Jira Cloud platform REST API documentation
*
* The version of the OpenAPI document: 1001.0.0-SNAPSHOT
* Contact: ecosystem@atlassian.com
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
/// struct for passing parameters to the method [`bulk_get_users`]
#[derive(Clone, Debug, Default)]
pub struct BulkGetUsersParams {
/// The account ID of a user. To specify multiple users, pass multiple `accountId` parameters. For example, `accountId=5b10a2844c20165700ede21g&accountId=5b10ac8d82e05b22cc7d4ef5`.
pub account_id: Vec<String>,
/// The index of the first item to return in a page of results (page offset).
pub start_at: Option<i64>,
/// The maximum number of items to return per page.
pub max_results: Option<i32>,
/// 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.
pub username: Option<Vec<String>>,
/// 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.
pub key: Option<Vec<String>>
}
/// struct for passing parameters to the method [`bulk_get_users_migration`]
#[derive(Clone, Debug, Default)]
pub struct BulkGetUsersMigrationParams {
/// The index of the first item to return in a page of results (page offset).
pub start_at: Option<i64>,
/// The maximum number of items to return per page.
pub max_results: Option<i32>,
/// 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.
pub username: Option<Vec<String>>,
/// 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.
pub key: Option<Vec<String>>
}
/// struct for passing parameters to the method [`create_user`]
#[derive(Clone, Debug, Default)]
pub struct CreateUserParams {
/// Details about the user to be created.
pub request_body: ::std::collections::HashMap<String, serde_json::Value>
}
/// struct for passing parameters to the method [`get_all_users`]
#[derive(Clone, Debug, Default)]
pub struct GetAllUsersParams {
/// The index of the first item to return.
pub start_at: Option<i32>,
/// The maximum number of items to return.
pub max_results: Option<i32>
}
/// struct for passing parameters to the method [`get_all_users_default`]
#[derive(Clone, Debug, Default)]
pub struct GetAllUsersDefaultParams {
/// The index of the first item to return.
pub start_at: Option<i32>,
/// The maximum number of items to return.
pub max_results: Option<i32>
}
/// struct for passing parameters to the method [`get_user`]
#[derive(Clone, Debug, Default)]
pub struct GetUserParams {
/// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*. Required.
pub account_id: Option<String>,
/// 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.
pub username: Option<String>,
/// 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.
pub key: Option<String>,
/// 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.
pub expand: Option<String>
}
/// struct for passing parameters to the method [`get_user_default_columns`]
#[derive(Clone, Debug, Default)]
pub struct GetUserDefaultColumnsParams {
/// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*.
pub account_id: Option<String>,
/// 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.
pub username: Option<String>
}
/// struct for passing parameters to the method [`get_user_email`]
#[derive(Clone, Debug, Default)]
pub struct GetUserEmailParams {
/// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, `5b10ac8d82e05b22cc7d4ef5`.
pub account_id: String
}
/// struct for passing parameters to the method [`get_user_email_bulk`]
#[derive(Clone, Debug, Default)]
pub struct GetUserEmailBulkParams {
/// 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).
pub account_id: Vec<String>
}
/// struct for passing parameters to the method [`get_user_groups`]
#[derive(Clone, Debug, Default)]
pub struct GetUserGroupsParams {
/// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*.
pub account_id: String,
/// 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.
pub username: Option<String>,
/// 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.
pub key: Option<String>
}
/// struct for passing parameters to the method [`remove_user`]
#[derive(Clone, Debug, Default)]
pub struct RemoveUserParams {
/// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*.
pub account_id: String,
/// 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.
pub username: Option<String>,
/// 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.
pub key: Option<String>
}
/// struct for passing parameters to the method [`reset_user_columns`]
#[derive(Clone, Debug, Default)]
pub struct ResetUserColumnsParams {
/// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*.
pub account_id: Option<String>,
/// 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.
pub username: Option<String>
}
/// struct for passing parameters to the method [`set_user_columns`]
#[derive(Clone, Debug, Default)]
pub struct SetUserColumnsParams {
/// The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*.
pub account_id: Option<String>,
/// The ID of a column to set. To set multiple columns, send multiple `columns` parameters.
pub request_body: Option<Vec<String>>
}
/// struct for typed successes of method [`bulk_get_users`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkGetUsersSuccess {
Status200(crate::models::PageBeanUser),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`bulk_get_users_migration`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkGetUsersMigrationSuccess {
Status200(Vec<crate::models::UserMigrationBean>),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`create_user`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateUserSuccess {
Status201(crate::models::User),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_all_users`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllUsersSuccess {
Status200(Vec<crate::models::User>),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_all_users_default`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllUsersDefaultSuccess {
Status200(Vec<crate::models::User>),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_user`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserSuccess {
Status200(crate::models::User),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_user_default_columns`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserDefaultColumnsSuccess {
Status200(Vec<crate::models::ColumnItem>),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_user_email`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserEmailSuccess {
Status200(crate::models::UnrestrictedUserEmail),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_user_email_bulk`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserEmailBulkSuccess {
Status200(crate::models::UnrestrictedUserEmail),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`get_user_groups`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserGroupsSuccess {
Status200(Vec<crate::models::GroupName>),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`remove_user`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveUserSuccess {
Status204(),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`reset_user_columns`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResetUserColumnsSuccess {
Status204(),
UnknownValue(serde_json::Value),
}
/// struct for typed successes of method [`set_user_columns`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetUserColumnsSuccess {
Status200(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`bulk_get_users`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkGetUsersError {
Status400(),
Status401(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`bulk_get_users_migration`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkGetUsersMigrationError {
Status400(),
Status401(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_user`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateUserError {
Status400(),
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_all_users`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllUsersError {
Status400(),
Status403(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_all_users_default`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllUsersDefaultError {
Status400(),
Status403(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_default_columns`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserDefaultColumnsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_email`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserEmailError {
Status400(),
Status401(),
Status404(),
Status503(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_email_bulk`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserEmailBulkError {
Status400(),
Status401(),
Status503(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_groups`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserGroupsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_user`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveUserError {
Status400(),
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reset_user_columns`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResetUserColumnsError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_user_columns`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetUserColumnsError {
Status401(),
Status403(),
Status404(),
Status500(),
UnknownValue(serde_json::Value),
}
/// Returns a [paginated](#pagination) list of the users specified by one or more account IDs. **[Permissions](#permissions) required:** Permission to access Jira.
pub async fn bulk_get_users(configuration: &configuration::Configuration, params: BulkGetUsersParams) -> Result<ResponseContent<BulkGetUsersSuccess>, Error<BulkGetUsersError>> {
let local_var_configuration = configuration;
// unbox the parameters
let account_id = params.account_id;
let start_at = params.start_at;
let max_results = params.max_results;
let username = params.username;
let key = params.key;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user/bulk", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = start_at {
local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_results {
local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = username {
local_var_req_builder = match "multi" {
"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)>>()),
_ => local_var_req_builder.query(&[("username", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = key {
local_var_req_builder = match "multi" {
"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)>>()),
_ => local_var_req_builder.query(&[("key", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&account_id.into_iter().map(|p| ("accountId".to_owned(), p)).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("accountId", &account_id.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<BulkGetUsersSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<BulkGetUsersError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn bulk_get_users_migration(configuration: &configuration::Configuration, params: BulkGetUsersMigrationParams) -> Result<ResponseContent<BulkGetUsersMigrationSuccess>, Error<BulkGetUsersMigrationError>> {
let local_var_configuration = configuration;
// unbox the parameters
let start_at = params.start_at;
let max_results = params.max_results;
let username = params.username;
let key = params.key;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user/bulk/migration", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = start_at {
local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_results {
local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = username {
local_var_req_builder = match "multi" {
"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)>>()),
_ => local_var_req_builder.query(&[("username", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = key {
local_var_req_builder = match "multi" {
"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)>>()),
_ => local_var_req_builder.query(&[("key", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<BulkGetUsersMigrationSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<BulkGetUsersMigrationError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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).
pub async fn create_user(configuration: &configuration::Configuration, params: CreateUserParams) -> Result<ResponseContent<CreateUserSuccess>, Error<CreateUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let request_body = params.request_body;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&request_body);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<CreateUserSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<CreateUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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).
pub async fn get_all_users(configuration: &configuration::Configuration, params: GetAllUsersParams) -> Result<ResponseContent<GetAllUsersSuccess>, Error<GetAllUsersError>> {
let local_var_configuration = configuration;
// unbox the parameters
let start_at = params.start_at;
let max_results = params.max_results;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/users/search", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = start_at {
local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_results {
local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<GetAllUsersSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<GetAllUsersError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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).
pub async fn get_all_users_default(configuration: &configuration::Configuration, params: GetAllUsersDefaultParams) -> Result<ResponseContent<GetAllUsersDefaultSuccess>, Error<GetAllUsersDefaultError>> {
let local_var_configuration = configuration;
// unbox the parameters
let start_at = params.start_at;
let max_results = params.max_results;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/users", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = start_at {
local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_results {
local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<GetAllUsersDefaultSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<GetAllUsersDefaultError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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).
pub async fn get_user(configuration: &configuration::Configuration, params: GetUserParams) -> Result<ResponseContent<GetUserSuccess>, Error<GetUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let account_id = params.account_id;
let username = params.username;
let key = params.key;
let expand = params.expand;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = account_id {
local_var_req_builder = local_var_req_builder.query(&[("accountId", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = username {
local_var_req_builder = local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = key {
local_var_req_builder = local_var_req_builder.query(&[("key", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand {
local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<GetUserSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<GetUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn get_user_default_columns(configuration: &configuration::Configuration, params: GetUserDefaultColumnsParams) -> Result<ResponseContent<GetUserDefaultColumnsSuccess>, Error<GetUserDefaultColumnsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let account_id = params.account_id;
let username = params.username;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user/columns", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = account_id {
local_var_req_builder = local_var_req_builder.query(&[("accountId", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = username {
local_var_req_builder = local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<GetUserDefaultColumnsSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<GetUserDefaultColumnsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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).
pub async fn get_user_email(configuration: &configuration::Configuration, params: GetUserEmailParams) -> Result<ResponseContent<GetUserEmailSuccess>, Error<GetUserEmailError>> {
let local_var_configuration = configuration;
// unbox the parameters
let account_id = params.account_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user/email", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("accountId", &account_id.to_string())]);
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<GetUserEmailSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<GetUserEmailError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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).
pub async fn get_user_email_bulk(configuration: &configuration::Configuration, params: GetUserEmailBulkParams) -> Result<ResponseContent<GetUserEmailBulkSuccess>, Error<GetUserEmailBulkError>> {
let local_var_configuration = configuration;
// unbox the parameters
let account_id = params.account_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user/email/bulk", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&account_id.into_iter().map(|p| ("accountId".to_owned(), p)).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("accountId", &account_id.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<GetUserEmailBulkSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<GetUserEmailBulkError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Returns the groups to which a user belongs. **[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
pub async fn get_user_groups(configuration: &configuration::Configuration, params: GetUserGroupsParams) -> Result<ResponseContent<GetUserGroupsSuccess>, Error<GetUserGroupsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let account_id = params.account_id;
let username = params.username;
let key = params.key;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user/groups", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("accountId", &account_id.to_string())]);
if let Some(ref local_var_str) = username {
local_var_req_builder = local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = key {
local_var_req_builder = local_var_req_builder.query(&[("key", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<GetUserGroupsSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<GetUserGroupsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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)).
pub async fn remove_user(configuration: &configuration::Configuration, params: RemoveUserParams) -> Result<ResponseContent<RemoveUserSuccess>, Error<RemoveUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let account_id = params.account_id;
let username = params.username;
let key = params.key;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("accountId", &account_id.to_string())]);
if let Some(ref local_var_str) = username {
local_var_req_builder = local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = key {
local_var_req_builder = local_var_req_builder.query(&[("key", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<RemoveUserSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<RemoveUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn reset_user_columns(configuration: &configuration::Configuration, params: ResetUserColumnsParams) -> Result<ResponseContent<ResetUserColumnsSuccess>, Error<ResetUserColumnsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let account_id = params.account_id;
let username = params.username;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user/columns", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_str) = account_id {
local_var_req_builder = local_var_req_builder.query(&[("accountId", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = username {
local_var_req_builder = local_var_req_builder.query(&[("username", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<ResetUserColumnsSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<ResetUserColumnsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn set_user_columns(configuration: &configuration::Configuration, params: SetUserColumnsParams) -> Result<ResponseContent<SetUserColumnsSuccess>, Error<SetUserColumnsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let account_id = params.account_id;
let request_body = params.request_body;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/rest/api/2/user/columns", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_str) = account_id {
local_var_req_builder = local_var_req_builder.query(&[("accountId", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&request_body);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
let local_var_entity: Option<SetUserColumnsSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let local_var_entity: Option<SetUserColumnsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}