/*
* Mattermost API Reference
*
* There is also a work-in-progress [Postman API reference](https://documenter.getpostman.com/view/4508214/RW8FERUn).
*
* The version of the OpenAPI document: 4.0.0
* Contact: feedback@mattermost.com
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use super::ResponseContent;
use super::{Error, configuration};
/// struct for passing parameters to the method [`attach_device_id`]
#[derive(Clone, Debug, Default)]
pub struct AttachDeviceIdParams {
pub attach_device_id_request: crate::openapi::models::AttachDeviceIdRequest,
}
/// struct for passing parameters to the method [`autocomplete_users`]
#[derive(Clone, Debug, Default)]
pub struct AutocompleteUsersParams {
/// Username, nickname first name or last name
pub name: String,
/// Team ID
pub team_id: Option<String>,
/// Channel ID
pub channel_id: Option<String>,
/// The maximum number of users to return in each subresult __Available as of server version 5.6. Defaults to `100` if not provided or on an earlier server version.__
pub limit: Option<i32>,
}
/// struct for passing parameters to the method [`check_user_mfa`]
#[derive(Clone, Debug, Default)]
pub struct CheckUserMfaParams {
pub check_user_mfa_request: crate::openapi::models::CheckUserMfaRequest,
}
/// struct for passing parameters to the method [`convert_bot_to_user`]
#[derive(Clone, Debug, Default)]
pub struct ConvertBotToUserParams {
/// Bot user ID
pub bot_user_id: String,
/// Data to be used in the user creation
pub convert_bot_to_user_request: crate::openapi::models::ConvertBotToUserRequest,
/// Whether to give the user the system admin role.
pub set_system_admin: Option<bool>,
}
/// struct for passing parameters to the method [`convert_user_to_bot`]
#[derive(Clone, Debug, Default)]
pub struct ConvertUserToBotParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`create_user`]
#[derive(Clone, Debug, Default)]
pub struct CreateUserParams {
/// User object to be created
pub create_user_request: crate::openapi::models::CreateUserRequest,
/// Token id from an email invitation
pub t: Option<String>,
/// Token id from an invitation link
pub iid: Option<String>,
}
/// struct for passing parameters to the method [`create_user_access_token`]
#[derive(Clone, Debug, Default)]
pub struct CreateUserAccessTokenParams {
/// User GUID
pub user_id: String,
pub create_user_access_token_request: crate::openapi::models::CreateUserAccessTokenRequest,
}
/// struct for passing parameters to the method [`delete_user`]
#[derive(Clone, Debug, Default)]
pub struct DeleteUserParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`demote_user_to_guest`]
#[derive(Clone, Debug, Default)]
pub struct DemoteUserToGuestParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`disable_user_access_token`]
#[derive(Clone, Debug, Default)]
pub struct DisableUserAccessTokenParams {
pub disable_user_access_token_request: crate::openapi::models::DisableUserAccessTokenRequest,
}
/// struct for passing parameters to the method [`enable_user_access_token`]
#[derive(Clone, Debug, Default)]
pub struct EnableUserAccessTokenParams {
pub enable_user_access_token_request: crate::openapi::models::EnableUserAccessTokenRequest,
}
/// struct for passing parameters to the method [`generate_mfa_secret`]
#[derive(Clone, Debug, Default)]
pub struct GenerateMfaSecretParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`get_channel_members_with_team_data_for_user`]
#[derive(Clone, Debug, Default)]
pub struct GetChannelMembersWithTeamDataForUserParams {
/// The ID of the user. This can also be \"me\" which will point to the current user.
pub user_id: String,
/// Page specifies which part of the results to return, by PageSize.
pub page: Option<i32>,
/// PageSize specifies the size of the returned chunk of results.
pub page_size: Option<i32>,
}
/// struct for passing parameters to the method [`get_default_profile_image`]
#[derive(Clone, Debug, Default)]
pub struct GetDefaultProfileImageParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`get_profile_image`]
#[derive(Clone, Debug, Default)]
pub struct GetProfileImageParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`get_sessions`]
#[derive(Clone, Debug, Default)]
pub struct GetSessionsParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`get_total_users_stats_filtered`]
#[derive(Clone, Debug, Default)]
pub struct GetTotalUsersStatsFilteredParams {
/// The ID of the team to get user stats for.
pub in_team: Option<String>,
/// The ID of the channel to get user stats for.
pub in_channel: Option<String>,
/// If deleted accounts should be included in the count.
pub include_deleted: Option<bool>,
/// If bot accounts should be included in the count.
pub include_bots: Option<bool>,
/// Comma separated string used to filter users based on any of the specified system roles Example: `?roles=system_admin,system_user` will include users that are either system admins or system users
pub roles: Option<String>,
/// Comma separated string used to filter users based on any of the specified channel roles, can only be used in conjunction with `in_channel` Example: `?in_channel=4eb6axxw7fg3je5iyasnfudc5y&channel_roles=channel_user` will include users that are only channel users and not admins or guests
pub channel_roles: Option<String>,
/// Comma separated string used to filter users based on any of the specified team roles, can only be used in conjunction with `in_team` Example: `?in_team=4eb6axxw7fg3je5iyasnfudc5y&team_roles=team_user` will include users that are only team users and not admins or guests
pub team_roles: Option<String>,
}
/// struct for passing parameters to the method [`get_uploads_for_user`]
#[derive(Clone, Debug, Default)]
pub struct GetUploadsForUserParams {
/// The ID of the user. This can also be \"me\" which will point to the current user.
pub user_id: String,
}
/// struct for passing parameters to the method [`get_user`]
#[derive(Clone, Debug, Default)]
pub struct GetUserParams {
/// User GUID. This can also be \"me\" which will point to the current user.
pub user_id: String,
}
/// struct for passing parameters to the method [`get_user_access_token`]
#[derive(Clone, Debug, Default)]
pub struct GetUserAccessTokenParams {
/// User access token GUID
pub token_id: String,
}
/// struct for passing parameters to the method [`get_user_access_tokens`]
#[derive(Clone, Debug, Default)]
pub struct GetUserAccessTokensParams {
/// The page to select.
pub page: Option<i32>,
/// The number of tokens per page.
pub per_page: Option<i32>,
}
/// struct for passing parameters to the method [`get_user_access_tokens_for_user`]
#[derive(Clone, Debug, Default)]
pub struct GetUserAccessTokensForUserParams {
/// User GUID
pub user_id: String,
/// The page to select.
pub page: Option<i32>,
/// The number of tokens per page.
pub per_page: Option<i32>,
}
/// struct for passing parameters to the method [`get_user_audits`]
#[derive(Clone, Debug, Default)]
pub struct GetUserAuditsParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`get_user_by_email`]
#[derive(Clone, Debug, Default)]
pub struct GetUserByEmailParams {
/// User Email
pub email: String,
}
/// struct for passing parameters to the method [`get_user_by_username`]
#[derive(Clone, Debug, Default)]
pub struct GetUserByUsernameParams {
/// Username
pub username: String,
}
/// struct for passing parameters to the method [`get_user_terms_of_service`]
#[derive(Clone, Debug, Default)]
pub struct GetUserTermsOfServiceParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`get_users`]
#[derive(Clone, Debug, Default)]
pub struct GetUsersParams {
/// The page to select.
pub page: Option<i32>,
/// The number of users per page. There is a maximum limit of 200 users per page.
pub per_page: Option<i32>,
/// The ID of the team to get users for.
pub in_team: Option<String>,
/// The ID of the team to exclude users for. Must not be used with \"in_team\" query parameter.
pub not_in_team: Option<String>,
/// The ID of the channel to get users for.
pub in_channel: Option<String>,
/// The ID of the channel to exclude users for. Must be used with \"in_channel\" query parameter.
pub not_in_channel: Option<String>,
/// The ID of the group to get users for. Must have `manage_system` permission.
pub in_group: Option<String>,
/// When used with `not_in_channel` or `not_in_team`, returns only the users that are allowed to join the channel or team based on its group constrains.
pub group_constrained: Option<bool>,
/// Whether or not to list users that are not on any team. This option takes precendence over `in_team`, `in_channel`, and `not_in_channel`.
pub without_team: Option<bool>,
/// Whether or not to list only users that are active. This option cannot be used along with the `inactive` option.
pub active: Option<bool>,
/// Whether or not to list only users that are deactivated. This option cannot be used along with the `active` option.
pub inactive: Option<bool>,
/// Returns users that have this role.
pub role: Option<String>,
/// Sort is only available in conjunction with certain options below. The paging parameter is also always available. ##### `in_team` Can be \"\", \"last_activity_at\" or \"create_at\". When left blank, sorting is done by username. __Minimum server version__: 4.0 ##### `in_channel` Can be \"\", \"status\". When left blank, sorting is done by username. `status` will sort by User's current status (Online, Away, DND, Offline), then by Username. __Minimum server version__: 4.7 ##### `in_group` Can be \"\", \"display_name\". When left blank, sorting is done by username. `display_name` will sort alphabetically by user's display name. __Minimum server version__: 7.7
pub sort: Option<String>,
/// Comma separated string used to filter users based on any of the specified system roles Example: `?roles=system_admin,system_user` will return users that are either system admins or system users __Minimum server version__: 5.26
pub roles: Option<String>,
/// Comma separated string used to filter users based on any of the specified channel roles, can only be used in conjunction with `in_channel` Example: `?in_channel=4eb6axxw7fg3je5iyasnfudc5y&channel_roles=channel_user` will return users that are only channel users and not admins or guests __Minimum server version__: 5.26
pub channel_roles: Option<String>,
/// Comma separated string used to filter users based on any of the specified team roles, can only be used in conjunction with `in_team` Example: `?in_team=4eb6axxw7fg3je5iyasnfudc5y&team_roles=team_user` will return users that are only team users and not admins or guests __Minimum server version__: 5.26
pub team_roles: Option<String>,
}
/// struct for passing parameters to the method [`get_users_by_group_channel_ids`]
#[derive(Clone, Debug, Default)]
pub struct GetUsersByGroupChannelIdsParams {
/// List of group channel ids
pub request_body: Vec<String>,
}
/// struct for passing parameters to the method [`get_users_by_ids`]
#[derive(Clone, Debug, Default)]
pub struct GetUsersByIdsParams {
/// List of user ids
pub request_body: Vec<String>,
/// Only return users that have been modified since the given Unix timestamp (in milliseconds). __Minimum server version__: 5.14
pub since: Option<i32>,
}
/// struct for passing parameters to the method [`get_users_by_usernames`]
#[derive(Clone, Debug, Default)]
pub struct GetUsersByUsernamesParams {
/// List of usernames
pub request_body: Vec<String>,
}
/// struct for passing parameters to the method [`login`]
#[derive(Clone, Debug, Default)]
pub struct LoginParams {
/// User authentication object
pub login_request: crate::openapi::models::LoginRequest,
}
/// struct for passing parameters to the method [`login_by_cws_token`]
#[derive(Clone, Debug, Default)]
pub struct LoginByCwsTokenParams {
/// User authentication object
pub login_by_cws_token_request: crate::openapi::models::LoginByCwsTokenRequest,
}
/// struct for passing parameters to the method [`migrate_auth_to_ldap`]
#[derive(Clone, Debug, Default)]
pub struct MigrateAuthToLdapParams {
pub migrate_auth_to_ldap_request: Option<crate::openapi::models::MigrateAuthToLdapRequest>,
}
/// struct for passing parameters to the method [`migrate_auth_to_saml`]
#[derive(Clone, Debug, Default)]
pub struct MigrateAuthToSamlParams {
pub migrate_auth_to_saml_request: Option<crate::openapi::models::MigrateAuthToSamlRequest>,
}
/// struct for passing parameters to the method [`patch_user`]
#[derive(Clone, Debug, Default)]
pub struct PatchUserParams {
/// User GUID
pub user_id: String,
/// User object that is to be updated
pub patch_user_request: crate::openapi::models::PatchUserRequest,
}
/// struct for passing parameters to the method [`promote_guest_to_user`]
#[derive(Clone, Debug, Default)]
pub struct PromoteGuestToUserParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`publish_user_typing`]
#[derive(Clone, Debug, Default)]
pub struct PublishUserTypingParams {
/// User GUID
pub user_id: String,
pub publish_user_typing_request: Option<crate::openapi::models::PublishUserTypingRequest>,
}
/// struct for passing parameters to the method [`register_terms_of_service_action`]
#[derive(Clone, Debug, Default)]
pub struct RegisterTermsOfServiceActionParams {
/// User GUID
pub user_id: String,
/// terms of service details
pub register_terms_of_service_action_request:
crate::openapi::models::RegisterTermsOfServiceActionRequest,
}
/// struct for passing parameters to the method [`reset_password`]
#[derive(Clone, Debug, Default)]
pub struct ResetPasswordParams {
pub reset_password_request: crate::openapi::models::ResetPasswordRequest,
}
/// struct for passing parameters to the method [`revoke_all_sessions`]
#[derive(Clone, Debug, Default)]
pub struct RevokeAllSessionsParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`revoke_session`]
#[derive(Clone, Debug, Default)]
pub struct RevokeSessionParams {
/// User GUID
pub user_id: String,
pub revoke_session_request: crate::openapi::models::RevokeSessionRequest,
}
/// struct for passing parameters to the method [`revoke_user_access_token`]
#[derive(Clone, Debug, Default)]
pub struct RevokeUserAccessTokenParams {
pub revoke_user_access_token_request: crate::openapi::models::RevokeUserAccessTokenRequest,
}
/// struct for passing parameters to the method [`search_user_access_tokens`]
#[derive(Clone, Debug, Default)]
pub struct SearchUserAccessTokensParams {
/// Search criteria
pub search_user_access_tokens_request: crate::openapi::models::SearchUserAccessTokensRequest,
}
/// struct for passing parameters to the method [`search_users`]
#[derive(Clone, Debug, Default)]
pub struct SearchUsersParams {
/// Search criteria
pub search_users_request: crate::openapi::models::SearchUsersRequest,
}
/// struct for passing parameters to the method [`send_password_reset_email`]
#[derive(Clone, Debug, Default)]
pub struct SendPasswordResetEmailParams {
pub send_password_reset_email_request: crate::openapi::models::SendPasswordResetEmailRequest,
}
/// struct for passing parameters to the method [`send_verification_email`]
#[derive(Clone, Debug, Default)]
pub struct SendVerificationEmailParams {
pub send_verification_email_request: crate::openapi::models::SendVerificationEmailRequest,
}
/// struct for passing parameters to the method [`set_default_profile_image`]
#[derive(Clone, Debug, Default)]
pub struct SetDefaultProfileImageParams {
/// User GUID
pub user_id: String,
}
/// struct for passing parameters to the method [`set_profile_image`]
#[derive(Clone, Debug, Default)]
pub struct SetProfileImageParams {
/// User GUID
pub user_id: String,
/// The image to be uploaded
pub image: std::path::PathBuf,
}
/// struct for passing parameters to the method [`switch_account_type`]
#[derive(Clone, Debug, Default)]
pub struct SwitchAccountTypeParams {
pub switch_account_type_request: crate::openapi::models::SwitchAccountTypeRequest,
}
/// struct for passing parameters to the method [`update_user`]
#[derive(Clone, Debug, Default)]
pub struct UpdateUserParams {
/// User GUID
pub user_id: String,
/// User object that is to be updated
pub update_user_request: crate::openapi::models::UpdateUserRequest,
}
/// struct for passing parameters to the method [`update_user_active`]
#[derive(Clone, Debug, Default)]
pub struct UpdateUserActiveParams {
/// User GUID
pub user_id: String,
/// Use `true` to set the user active, `false` for inactive
pub update_user_active_request: crate::openapi::models::UpdateUserActiveRequest,
}
/// struct for passing parameters to the method [`update_user_auth`]
#[derive(Clone, Debug, Default)]
pub struct UpdateUserAuthParams {
/// User GUID
pub user_id: String,
pub user_auth_data: crate::openapi::models::UserAuthData,
}
/// struct for passing parameters to the method [`update_user_mfa`]
#[derive(Clone, Debug, Default)]
pub struct UpdateUserMfaParams {
/// User GUID
pub user_id: String,
pub update_user_mfa_request: crate::openapi::models::UpdateUserMfaRequest,
}
/// struct for passing parameters to the method [`update_user_password`]
#[derive(Clone, Debug, Default)]
pub struct UpdateUserPasswordParams {
/// User GUID
pub user_id: String,
pub update_user_password_request: crate::openapi::models::UpdateUserPasswordRequest,
}
/// struct for passing parameters to the method [`update_user_roles`]
#[derive(Clone, Debug, Default)]
pub struct UpdateUserRolesParams {
/// User GUID
pub user_id: String,
/// Space-delimited system roles to assign to the user
pub update_user_roles_request: crate::openapi::models::UpdateUserRolesRequest,
}
/// struct for passing parameters to the method [`verify_user_email`]
#[derive(Clone, Debug, Default)]
pub struct VerifyUserEmailParams {
pub verify_user_email_request: crate::openapi::models::VerifyUserEmailRequest,
}
/// struct for passing parameters to the method [`verify_user_email_without_token`]
#[derive(Clone, Debug, Default)]
pub struct VerifyUserEmailWithoutTokenParams {
/// User GUID
pub user_id: String,
}
/// struct for typed errors of method [`attach_device_id`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum AttachDeviceIdError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`autocomplete_users`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum AutocompleteUsersError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`check_user_mfa`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum CheckUserMfaError {
Status400(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`convert_bot_to_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum ConvertBotToUserError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`convert_user_to_bot`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum ConvertUserToBotError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum CreateUserError {
Status400(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_user_access_token`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum CreateUserAccessTokenError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum DeleteUserError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`demote_user_to_guest`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum DemoteUserToGuestError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`disable_user_access_token`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum DisableUserAccessTokenError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`enable_user_access_token`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum EnableUserAccessTokenError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`generate_mfa_secret`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GenerateMfaSecretError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_channel_members_with_team_data_for_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetChannelMembersWithTeamDataForUserError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_default_profile_image`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetDefaultProfileImageError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_known_users`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetKnownUsersError {
Status401(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_profile_image`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetProfileImageError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_sessions`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetSessionsError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_total_users_stats`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetTotalUsersStatsError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_total_users_stats_filtered`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetTotalUsersStatsFilteredError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_uploads_for_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUploadsForUserError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUserError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_access_token`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUserAccessTokenError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_access_tokens`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUserAccessTokensError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_access_tokens_for_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUserAccessTokensForUserError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_audits`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUserAuditsError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_by_email`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUserByEmailError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_by_username`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUserByUsernameError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_terms_of_service`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUserTermsOfServiceError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_users`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUsersError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_users_by_group_channel_ids`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUsersByGroupChannelIdsError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_users_by_ids`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUsersByIdsError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_users_by_usernames`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum GetUsersByUsernamesError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`login`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum LoginError {
Status400(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`login_by_cws_token`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum LoginByCwsTokenError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`logout`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum LogoutError {
Status400(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`migrate_auth_to_ldap`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum MigrateAuthToLdapError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`migrate_auth_to_saml`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum MigrateAuthToSamlError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patch_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum PatchUserError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`permanent_delete_all_users`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum PermanentDeleteAllUsersError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`promote_guest_to_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum PromoteGuestToUserError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`publish_user_typing`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum PublishUserTypingError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`register_terms_of_service_action`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum RegisterTermsOfServiceActionError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reset_password`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum ResetPasswordError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`revoke_all_sessions`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum RevokeAllSessionsError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`revoke_session`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum RevokeSessionError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`revoke_sessions_from_all_users`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum RevokeSessionsFromAllUsersError {
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`revoke_user_access_token`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum RevokeUserAccessTokenError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_user_access_tokens`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SearchUserAccessTokensError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_users`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SearchUsersError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_password_reset_email`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SendPasswordResetEmailError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`send_verification_email`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SendVerificationEmailError {
Status400(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_default_profile_image`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SetDefaultProfileImageError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_profile_image`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SetProfileImageError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`switch_account_type`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum SwitchAccountTypeError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_user`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum UpdateUserError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_user_active`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum UpdateUserActiveError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_user_auth`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum UpdateUserAuthError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_user_mfa`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum UpdateUserMfaError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
Status501(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_user_password`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum UpdateUserPasswordError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_user_roles`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum UpdateUserRolesError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status403(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`verify_user_email`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum VerifyUserEmailError {
Status400(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`verify_user_email_without_token`]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
pub enum VerifyUserEmailWithoutTokenError {
Status400(crate::openapi::models::AppError),
Status401(crate::openapi::models::AppError),
Status404(crate::openapi::models::AppError),
UnknownValue(serde_json::Value),
}
/// Attach a mobile device id to the currently logged in session. This will enable push notifications for a user, if configured by the server. ##### Permissions Must be authenticated.
pub async fn attach_device_id(
configuration: &configuration::Configuration,
params: AttachDeviceIdParams,
) -> Result<crate::openapi::models::StatusOk, Error<AttachDeviceIdError>> {
let local_var_configuration = configuration;
// unbox the parameters
let attach_device_id_request = params.attach_device_id_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/sessions/device",
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&attach_device_id_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AttachDeviceIdError> =
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))
}
}
/// Get a list of users for the purpose of autocompleting based on the provided search term. Specify a combination of `team_id` and `channel_id` to filter results further. ##### Permissions Requires an active session and `view_team` and `read_channel` on any teams or channels used to filter the results further.
pub async fn autocomplete_users(
configuration: &configuration::Configuration,
params: AutocompleteUsersParams,
) -> Result<crate::openapi::models::UserAutocomplete, Error<AutocompleteUsersError>> {
let local_var_configuration = configuration;
// unbox the parameters
let name = params.name;
let team_id = params.team_id;
let channel_id = params.channel_id;
let limit = params.limit;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/autocomplete",
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) = team_id {
local_var_req_builder =
local_var_req_builder.query(&[("team_id", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = channel_id {
local_var_req_builder =
local_var_req_builder.query(&[("channel_id", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.query(&[("name", &name.to_string())]);
if let Some(ref local_var_str) = limit {
local_var_req_builder =
local_var_req_builder.query(&[("limit", &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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AutocompleteUsersError> =
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))
}
}
/// Check if a user has multi-factor authentication active on their account by providing a login id. Used to check whether an MFA code needs to be provided when logging in. ##### Permissions No permission required.
pub async fn check_user_mfa(
configuration: &configuration::Configuration,
params: CheckUserMfaParams,
) -> Result<crate::openapi::models::CheckUserMfa200Response, Error<CheckUserMfaError>> {
let local_var_configuration = configuration;
// unbox the parameters
let check_user_mfa_request = params.check_user_mfa_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/users/mfa", 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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&check_user_mfa_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CheckUserMfaError> =
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))
}
}
/// Convert a bot into a user. __Minimum server version__: 5.26 ##### Permissions Must have `manage_system` permission.
pub async fn convert_bot_to_user(
configuration: &configuration::Configuration,
params: ConvertBotToUserParams,
) -> Result<crate::openapi::models::StatusOk, Error<ConvertBotToUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let bot_user_id = params.bot_user_id;
let convert_bot_to_user_request = params.convert_bot_to_user_request;
let set_system_admin = params.set_system_admin;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/bots/{bot_user_id}/convert_to_user",
local_var_configuration.base_path,
bot_user_id = super::urlencode(bot_user_id)
);
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_str) = set_system_admin {
local_var_req_builder =
local_var_req_builder.query(&[("set_system_admin", &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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&convert_bot_to_user_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ConvertBotToUserError> =
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))
}
}
/// Convert a user into a bot. __Minimum server version__: 5.26 ##### Permissions Must have `manage_system` permission.
pub async fn convert_user_to_bot(
configuration: &configuration::Configuration,
params: ConvertUserToBotParams,
) -> Result<crate::openapi::models::StatusOk, Error<ConvertUserToBotError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/convert_to_bot",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ConvertUserToBotError> =
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))
}
}
/// Create a new user on the system. Password is required for email login. For other authentication types such as LDAP or SAML, auth_data and auth_service fields are required. ##### Permissions No permission required for creating email/username accounts on an open server. Auth Token is required for other authentication types such as LDAP or SAML.
pub async fn create_user(
configuration: &configuration::Configuration,
params: CreateUserParams,
) -> Result<crate::openapi::models::User, Error<CreateUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let create_user_request = params.create_user_request;
let t = params.t;
let iid = params.iid;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/users", 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_str) = t {
local_var_req_builder = local_var_req_builder.query(&[("t", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = iid {
local_var_req_builder = local_var_req_builder.query(&[("iid", &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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&create_user_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} 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))
}
}
/// Generate a user access token that can be used to authenticate with the Mattermost REST API. __Minimum server version__: 4.1 ##### Permissions Must have `create_user_access_token` permission. For non-self requests, must also have the `edit_other_users` permission.
pub async fn create_user_access_token(
configuration: &configuration::Configuration,
params: CreateUserAccessTokenParams,
) -> Result<crate::openapi::models::UserAccessToken, Error<CreateUserAccessTokenError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let create_user_access_token_request = params.create_user_access_token_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/tokens",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&create_user_access_token_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateUserAccessTokenError> =
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))
}
}
/// Deactivates the user and revokes all its sessions by archiving its user object. As of server version 5.28, optionally use the `permanent=true` query parameter to permanently delete the user for compliance reasons. To use this feature `ServiceSettings.EnableAPIUserDeletion` must be set to `true` in the server's configuration. ##### Permissions Must be logged in as the user being deactivated or have the `edit_other_users` permission.
pub async fn delete_user(
configuration: &configuration::Configuration,
params: DeleteUserParams,
) -> Result<crate::openapi::models::StatusOk, Error<DeleteUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DeleteUserError> =
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))
}
}
/// Convert a regular user into a guest. This will convert the user into a guest for the whole system while retaining their existing team and channel memberships. __Minimum server version__: 5.16 ##### Permissions Must be logged in as the user or have the `demote_to_guest` permission.
pub async fn demote_user_to_guest(
configuration: &configuration::Configuration,
params: DemoteUserToGuestParams,
) -> Result<crate::openapi::models::StatusOk, Error<DemoteUserToGuestError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/demote",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DemoteUserToGuestError> =
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))
}
}
/// Disable a personal access token and delete any sessions using the token. The token can be re-enabled using `/users/tokens/enable`. __Minimum server version__: 4.4 ##### Permissions Must have `revoke_user_access_token` permission. For non-self requests, must also have the `edit_other_users` permission.
pub async fn disable_user_access_token(
configuration: &configuration::Configuration,
params: DisableUserAccessTokenParams,
) -> Result<crate::openapi::models::StatusOk, Error<DisableUserAccessTokenError>> {
let local_var_configuration = configuration;
// unbox the parameters
let disable_user_access_token_request = params.disable_user_access_token_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/tokens/disable",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&disable_user_access_token_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DisableUserAccessTokenError> =
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))
}
}
/// Re-enable a personal access token that has been disabled. __Minimum server version__: 4.4 ##### Permissions Must have `create_user_access_token` permission. For non-self requests, must also have the `edit_other_users` permission.
pub async fn enable_user_access_token(
configuration: &configuration::Configuration,
params: EnableUserAccessTokenParams,
) -> Result<crate::openapi::models::StatusOk, Error<EnableUserAccessTokenError>> {
let local_var_configuration = configuration;
// unbox the parameters
let enable_user_access_token_request = params.enable_user_access_token_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/tokens/enable",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&enable_user_access_token_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<EnableUserAccessTokenError> =
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))
}
}
/// Generates an multi-factor authentication secret for a user and returns it as a string and as base64 encoded QR code image. ##### Permissions Must be logged in as the user or have the `edit_other_users` permission.
pub async fn generate_mfa_secret(
configuration: &configuration::Configuration,
params: GenerateMfaSecretParams,
) -> Result<crate::openapi::models::GenerateMfaSecret200Response, Error<GenerateMfaSecretError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/mfa/generate",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GenerateMfaSecretError> =
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))
}
}
/// Get all channel members from all teams for a user. __Minimum server version__: 6.2.0 ##### Permissions Logged in as the user, or have `edit_other_users` permission.
pub async fn get_channel_members_with_team_data_for_user(
configuration: &configuration::Configuration,
params: GetChannelMembersWithTeamDataForUserParams,
) -> Result<
Vec<crate::openapi::models::ChannelMemberWithTeamData>,
Error<GetChannelMembersWithTeamDataForUserError>,
> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let page = params.page;
let page_size = params.page_size;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/channel_members",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page_size {
local_var_req_builder =
local_var_req_builder.query(&[("pageSize", &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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetChannelMembersWithTeamDataForUserError> =
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 (generated) user profile image based on user_id string parameter. ##### Permissions Must be logged in. __Minimum server version__: 5.5
pub async fn get_default_profile_image(
configuration: &configuration::Configuration,
params: GetDefaultProfileImageParams,
) -> Result<(), Error<GetDefaultProfileImageError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/image/default",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
Ok(())
} else {
let local_var_entity: Option<GetDefaultProfileImageError> =
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))
}
}
/// Get the list of user IDs of users with any direct relationship with a user. That means any user sharing any channel, including direct and group channels. ##### Permissions Must be authenticated. __Minimum server version__: 5.23
pub async fn get_known_users(
configuration: &configuration::Configuration,
) -> Result<serde_json::Value, Error<GetKnownUsersError>> {
let local_var_configuration = configuration;
// unbox the parameters
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/users/known", 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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetKnownUsersError> =
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))
}
}
/// Get a user's profile image based on user_id string parameter. ##### Permissions Must be logged in.
pub async fn get_profile_image(
configuration: &configuration::Configuration,
params: GetProfileImageParams,
) -> Result<(), Error<GetProfileImageError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/image",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
Ok(())
} else {
let local_var_entity: Option<GetProfileImageError> =
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))
}
}
/// Get a list of sessions by providing the user GUID. Sensitive information will be sanitized out. ##### Permissions Must be logged in as the user being updated or have the `edit_other_users` permission.
pub async fn get_sessions(
configuration: &configuration::Configuration,
params: GetSessionsParams,
) -> Result<Vec<crate::openapi::models::Session>, Error<GetSessionsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/sessions",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetSessionsError> =
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))
}
}
/// Get a total count of users in the system. ##### Permissions Must be authenticated.
pub async fn get_total_users_stats(
configuration: &configuration::Configuration,
) -> Result<crate::openapi::models::UsersStats, Error<GetTotalUsersStatsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/users/stats", 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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetTotalUsersStatsError> =
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))
}
}
/// Get a count of users in the system matching the specified filters. __Minimum server version__: 5.26 ##### Permissions Must have `manage_system` permission.
pub async fn get_total_users_stats_filtered(
configuration: &configuration::Configuration,
params: GetTotalUsersStatsFilteredParams,
) -> Result<crate::openapi::models::UsersStats, Error<GetTotalUsersStatsFilteredError>> {
let local_var_configuration = configuration;
// unbox the parameters
let in_team = params.in_team;
let in_channel = params.in_channel;
let include_deleted = params.include_deleted;
let include_bots = params.include_bots;
let roles = params.roles;
let channel_roles = params.channel_roles;
let team_roles = params.team_roles;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/stats/filtered",
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) = in_team {
local_var_req_builder =
local_var_req_builder.query(&[("in_team", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = in_channel {
local_var_req_builder =
local_var_req_builder.query(&[("in_channel", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = include_deleted {
local_var_req_builder =
local_var_req_builder.query(&[("include_deleted", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = include_bots {
local_var_req_builder =
local_var_req_builder.query(&[("include_bots", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = roles {
local_var_req_builder =
local_var_req_builder.query(&[("roles", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = channel_roles {
local_var_req_builder =
local_var_req_builder.query(&[("channel_roles", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = team_roles {
local_var_req_builder =
local_var_req_builder.query(&[("team_roles", &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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetTotalUsersStatsFilteredError> =
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))
}
}
/// Gets all the upload sessions belonging to a user. __Minimum server version__: 5.28 ##### Permissions Must be logged in as the user who created the upload sessions.
pub async fn get_uploads_for_user(
configuration: &configuration::Configuration,
params: GetUploadsForUserParams,
) -> Result<Vec<crate::openapi::models::UploadSession>, Error<GetUploadsForUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/uploads",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUploadsForUserError> =
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))
}
}
/// Get a user a object. Sensitive information will be sanitized out. ##### Permissions Requires an active session but no other permissions.
pub async fn get_user(
configuration: &configuration::Configuration,
params: GetUserParams,
) -> Result<crate::openapi::models::User, Error<GetUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} 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))
}
}
/// Get a user access token. Does not include the actual authentication token. __Minimum server version__: 4.1 ##### Permissions Must have `read_user_access_token` permission. For non-self requests, must also have the `edit_other_users` permission.
pub async fn get_user_access_token(
configuration: &configuration::Configuration,
params: GetUserAccessTokenParams,
) -> Result<crate::openapi::models::UserAccessTokenSanitized, Error<GetUserAccessTokenError>> {
let local_var_configuration = configuration;
// unbox the parameters
let token_id = params.token_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/tokens/{token_id}",
local_var_configuration.base_path,
token_id = super::urlencode(token_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUserAccessTokenError> =
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))
}
}
/// Get a page of user access tokens for users on the system. Does not include the actual authentication tokens. Use query parameters for paging. __Minimum server version__: 4.7 ##### Permissions Must have `manage_system` permission.
pub async fn get_user_access_tokens(
configuration: &configuration::Configuration,
params: GetUserAccessTokensParams,
) -> Result<Vec<crate::openapi::models::UserAccessTokenSanitized>, Error<GetUserAccessTokensError>>
{
let local_var_configuration = configuration;
// unbox the parameters
let page = params.page;
let per_page = params.per_page;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/users/tokens", 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) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder =
local_var_req_builder.query(&[("per_page", &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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUserAccessTokensError> =
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))
}
}
/// Get a list of user access tokens for a user. Does not include the actual authentication tokens. Use query parameters for paging. __Minimum server version__: 4.1 ##### Permissions Must have `read_user_access_token` permission. For non-self requests, must also have the `edit_other_users` permission.
pub async fn get_user_access_tokens_for_user(
configuration: &configuration::Configuration,
params: GetUserAccessTokensForUserParams,
) -> Result<
Vec<crate::openapi::models::UserAccessTokenSanitized>,
Error<GetUserAccessTokensForUserError>,
> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let page = params.page;
let per_page = params.per_page;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/tokens",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder =
local_var_req_builder.query(&[("per_page", &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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUserAccessTokensForUserError> =
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))
}
}
/// Get a list of audit by providing the user GUID. ##### Permissions Must be logged in as the user or have the `edit_other_users` permission.
pub async fn get_user_audits(
configuration: &configuration::Configuration,
params: GetUserAuditsParams,
) -> Result<Vec<crate::openapi::models::Audit>, Error<GetUserAuditsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/audits",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUserAuditsError> =
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))
}
}
/// Get a user object by providing a user email. Sensitive information will be sanitized out. ##### Permissions Requires an active session and for the current session to be able to view another user's email based on the server's privacy settings.
pub async fn get_user_by_email(
configuration: &configuration::Configuration,
params: GetUserByEmailParams,
) -> Result<crate::openapi::models::User, Error<GetUserByEmailError>> {
let local_var_configuration = configuration;
// unbox the parameters
let email = params.email;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/email/{email}",
local_var_configuration.base_path,
email = super::urlencode(email)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUserByEmailError> =
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))
}
}
/// Get a user object by providing a username. Sensitive information will be sanitized out. ##### Permissions Requires an active session but no other permissions.
pub async fn get_user_by_username(
configuration: &configuration::Configuration,
params: GetUserByUsernameParams,
) -> Result<crate::openapi::models::User, Error<GetUserByUsernameError>> {
let local_var_configuration = configuration;
// unbox the parameters
let username = params.username;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/username/{username}",
local_var_configuration.base_path,
username = super::urlencode(username)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUserByUsernameError> =
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))
}
}
/// Will be deprecated in v6.0 Fetches user's latest terms of service action if the latest action was for acceptance. __Minimum server version__: 5.6 ##### Permissions Must be logged in as the user being acted on.
pub async fn get_user_terms_of_service(
configuration: &configuration::Configuration,
params: GetUserTermsOfServiceParams,
) -> Result<crate::openapi::models::UserTermsOfService, Error<GetUserTermsOfServiceError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/terms_of_service",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUserTermsOfServiceError> =
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))
}
}
/// Get a page of a list of users. Based on query string parameters, select users from a team, channel, or select users not in a specific channel. Since server version 4.0, some basic sorting is available using the `sort` query parameter. Sorting is currently only supported when selecting users on a team. ##### Permissions Requires an active session and (if specified) membership to the channel or team being selected from.
pub async fn get_users(
configuration: &configuration::Configuration,
params: GetUsersParams,
) -> Result<Vec<crate::openapi::models::User>, Error<GetUsersError>> {
let local_var_configuration = configuration;
// unbox the parameters
let page = params.page;
let per_page = params.per_page;
let in_team = params.in_team;
let not_in_team = params.not_in_team;
let in_channel = params.in_channel;
let not_in_channel = params.not_in_channel;
let in_group = params.in_group;
let group_constrained = params.group_constrained;
let without_team = params.without_team;
let active = params.active;
let inactive = params.inactive;
let role = params.role;
let sort = params.sort;
let roles = params.roles;
let channel_roles = params.channel_roles;
let team_roles = params.team_roles;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/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) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder =
local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = in_team {
local_var_req_builder =
local_var_req_builder.query(&[("in_team", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = not_in_team {
local_var_req_builder =
local_var_req_builder.query(&[("not_in_team", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = in_channel {
local_var_req_builder =
local_var_req_builder.query(&[("in_channel", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = not_in_channel {
local_var_req_builder =
local_var_req_builder.query(&[("not_in_channel", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = in_group {
local_var_req_builder =
local_var_req_builder.query(&[("in_group", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = group_constrained {
local_var_req_builder =
local_var_req_builder.query(&[("group_constrained", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = without_team {
local_var_req_builder =
local_var_req_builder.query(&[("without_team", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = active {
local_var_req_builder =
local_var_req_builder.query(&[("active", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = inactive {
local_var_req_builder =
local_var_req_builder.query(&[("inactive", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = role {
local_var_req_builder =
local_var_req_builder.query(&[("role", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder =
local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = roles {
local_var_req_builder =
local_var_req_builder.query(&[("roles", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = channel_roles {
local_var_req_builder =
local_var_req_builder.query(&[("channel_roles", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = team_roles {
local_var_req_builder =
local_var_req_builder.query(&[("team_roles", &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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUsersError> = 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))
}
}
/// Get an object containing a key per group channel id in the query and its value as a list of users members of that group channel. The user must be a member of the group ids in the query, or they will be omitted from the response. ##### Permissions Requires an active session but no other permissions. __Minimum server version__: 5.14
pub async fn get_users_by_group_channel_ids(
configuration: &configuration::Configuration,
params: GetUsersByGroupChannelIdsParams,
) -> Result<
crate::openapi::models::GetUsersByGroupChannelIds200Response,
Error<GetUsersByGroupChannelIdsError>,
> {
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!(
"{}/api/v4/users/group_channels",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUsersByGroupChannelIdsError> =
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))
}
}
/// Get a list of users based on a provided list of user ids. ##### Permissions Requires an active session but no other permissions.
pub async fn get_users_by_ids(
configuration: &configuration::Configuration,
params: GetUsersByIdsParams,
) -> Result<Vec<crate::openapi::models::User>, Error<GetUsersByIdsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let request_body = params.request_body;
let since = params.since;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/users/ids", 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_str) = since {
local_var_req_builder =
local_var_req_builder.query(&[("since", &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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUsersByIdsError> =
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))
}
}
/// Get a list of users based on a provided list of usernames. ##### Permissions Requires an active session but no other permissions.
pub async fn get_users_by_usernames(
configuration: &configuration::Configuration,
params: GetUsersByUsernamesParams,
) -> Result<Vec<crate::openapi::models::User>, Error<GetUsersByUsernamesError>> {
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!(
"{}/api/v4/users/usernames",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetUsersByUsernamesError> =
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))
}
}
/// ##### Permissions No permission required
pub async fn login(
configuration: &configuration::Configuration,
params: LoginParams,
) -> Result<crate::openapi::models::User, Error<LoginError>> {
let local_var_configuration = configuration;
// unbox the parameters
let login_request = params.login_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/users/login", 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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&login_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<LoginError> = 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))
}
}
/// CWS stands for Customer Web Server which is the cloud service used to manage cloud instances. ##### Permissions A Cloud license is required
pub async fn login_by_cws_token(
configuration: &configuration::Configuration,
params: LoginByCwsTokenParams,
) -> Result<(), Error<LoginByCwsTokenError>> {
let local_var_configuration = configuration;
// unbox the parameters
let login_by_cws_token_request = params.login_by_cws_token_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/login/cws",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&login_by_cws_token_request);
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() {
Ok(())
} else {
let local_var_entity: Option<LoginByCwsTokenError> =
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))
}
}
/// ##### Permissions An active session is required
pub async fn logout(
configuration: &configuration::Configuration,
) -> Result<crate::openapi::models::StatusOk, Error<LogoutError>> {
let local_var_configuration = configuration;
// unbox the parameters
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/users/logout", 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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<LogoutError> = 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))
}
}
/// Migrates accounts from one authentication provider to another. For example, you can upgrade your authentication provider from email to LDAP. __Minimum server version__: 5.28 ##### Permissions Must have `manage_system` permission.
pub async fn migrate_auth_to_ldap(
configuration: &configuration::Configuration,
params: MigrateAuthToLdapParams,
) -> Result<(), Error<MigrateAuthToLdapError>> {
let local_var_configuration = configuration;
// unbox the parameters
let migrate_auth_to_ldap_request = params.migrate_auth_to_ldap_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/migrate_auth/ldap",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&migrate_auth_to_ldap_request);
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() {
Ok(())
} else {
let local_var_entity: Option<MigrateAuthToLdapError> =
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))
}
}
/// Migrates accounts from one authentication provider to another. For example, you can upgrade your authentication provider from email to SAML. __Minimum server version__: 5.28 ##### Permissions Must have `manage_system` permission.
pub async fn migrate_auth_to_saml(
configuration: &configuration::Configuration,
params: MigrateAuthToSamlParams,
) -> Result<(), Error<MigrateAuthToSamlError>> {
let local_var_configuration = configuration;
// unbox the parameters
let migrate_auth_to_saml_request = params.migrate_auth_to_saml_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/migrate_auth/saml",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&migrate_auth_to_saml_request);
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() {
Ok(())
} else {
let local_var_entity: Option<MigrateAuthToSamlError> =
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))
}
}
/// Partially update a user by providing only the fields you want to update. Omitted fields will not be updated. The fields that can be updated are defined in the request body, all other provided fields will be ignored. ##### Permissions Must be logged in as the user being updated or have the `edit_other_users` permission.
pub async fn patch_user(
configuration: &configuration::Configuration,
params: PatchUserParams,
) -> Result<crate::openapi::models::User, Error<PatchUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let patch_user_request = params.patch_user_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/patch",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&patch_user_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<PatchUserError> =
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))
}
}
/// Permanently deletes all users and all their related information, including posts. __Minimum server version__: 5.26.0 __Local mode only__: This endpoint is only available through [local mode](https://docs.mattermost.com/administration/mmctl-cli-tool.html#local-mode).
pub async fn permanent_delete_all_users(
configuration: &configuration::Configuration,
) -> Result<(), Error<PermanentDeleteAllUsersError>> {
let local_var_configuration = configuration;
// unbox the parameters
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/users", 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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
Ok(())
} else {
let local_var_entity: Option<PermanentDeleteAllUsersError> =
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))
}
}
/// Convert a guest into a regular user. This will convert the guest into a user for the whole system while retaining any team and channel memberships and automatically joining them to the default channels. __Minimum server version__: 5.16 ##### Permissions Must be logged in as the user or have the `promote_guest` permission.
pub async fn promote_guest_to_user(
configuration: &configuration::Configuration,
params: PromoteGuestToUserParams,
) -> Result<crate::openapi::models::StatusOk, Error<PromoteGuestToUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/promote",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<PromoteGuestToUserError> =
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))
}
}
/// Notify users in the given channel via websocket that the given user is typing. __Minimum server version__: 5.26 ##### Permissions Must have `manage_system` permission to publish for any user other than oneself.
pub async fn publish_user_typing(
configuration: &configuration::Configuration,
params: PublishUserTypingParams,
) -> Result<(), Error<PublishUserTypingError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let publish_user_typing_request = params.publish_user_typing_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/typing",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&publish_user_typing_request);
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() {
Ok(())
} else {
let local_var_entity: Option<PublishUserTypingError> =
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))
}
}
/// Records user action when they accept or decline custom terms of service. Records the action in audit table. Updates user's last accepted terms of service ID if they accepted it. __Minimum server version__: 5.4 ##### Permissions Must be logged in as the user being acted on.
pub async fn register_terms_of_service_action(
configuration: &configuration::Configuration,
params: RegisterTermsOfServiceActionParams,
) -> Result<crate::openapi::models::StatusOk, Error<RegisterTermsOfServiceActionError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let register_terms_of_service_action_request = params.register_terms_of_service_action_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/terms_of_service",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(®ister_terms_of_service_action_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<RegisterTermsOfServiceActionError> =
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))
}
}
/// Update the password for a user using a one-use, timed recovery code tied to the user's account. Only works for non-SSO users. ##### Permissions No permissions required.
pub async fn reset_password(
configuration: &configuration::Configuration,
params: ResetPasswordParams,
) -> Result<crate::openapi::models::StatusOk, Error<ResetPasswordError>> {
let local_var_configuration = configuration;
// unbox the parameters
let reset_password_request = params.reset_password_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/password/reset",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&reset_password_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ResetPasswordError> =
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))
}
}
/// Revokes all user sessions from the provided user id and session id strings. ##### Permissions Must be logged in as the user being updated or have the `edit_other_users` permission. __Minimum server version__: 4.4
pub async fn revoke_all_sessions(
configuration: &configuration::Configuration,
params: RevokeAllSessionsParams,
) -> Result<crate::openapi::models::StatusOk, Error<RevokeAllSessionsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/sessions/revoke/all",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<RevokeAllSessionsError> =
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))
}
}
/// Revokes a user session from the provided user id and session id strings. ##### Permissions Must be logged in as the user being updated or have the `edit_other_users` permission.
pub async fn revoke_session(
configuration: &configuration::Configuration,
params: RevokeSessionParams,
) -> Result<crate::openapi::models::StatusOk, Error<RevokeSessionError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let revoke_session_request = params.revoke_session_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/sessions/revoke",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&revoke_session_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<RevokeSessionError> =
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))
}
}
/// For any session currently on the server (including admin) it will be revoked. Clients will be notified to log out users. __Minimum server version__: 5.14 ##### Permissions Must have `manage_system` permission.
pub async fn revoke_sessions_from_all_users(
configuration: &configuration::Configuration,
) -> Result<(), Error<RevokeSessionsFromAllUsersError>> {
let local_var_configuration = configuration;
// unbox the parameters
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/sessions/revoke/all",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
Ok(())
} else {
let local_var_entity: Option<RevokeSessionsFromAllUsersError> =
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))
}
}
/// Revoke a user access token and delete any sessions using the token. __Minimum server version__: 4.1 ##### Permissions Must have `revoke_user_access_token` permission. For non-self requests, must also have the `edit_other_users` permission.
pub async fn revoke_user_access_token(
configuration: &configuration::Configuration,
params: RevokeUserAccessTokenParams,
) -> Result<crate::openapi::models::StatusOk, Error<RevokeUserAccessTokenError>> {
let local_var_configuration = configuration;
// unbox the parameters
let revoke_user_access_token_request = params.revoke_user_access_token_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/tokens/revoke",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&revoke_user_access_token_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<RevokeUserAccessTokenError> =
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))
}
}
/// Get a list of tokens based on search criteria provided in the request body. Searches are done against the token id, user id and username. __Minimum server version__: 4.7 ##### Permissions Must have `manage_system` permission.
pub async fn search_user_access_tokens(
configuration: &configuration::Configuration,
params: SearchUserAccessTokensParams,
) -> Result<Vec<crate::openapi::models::UserAccessTokenSanitized>, Error<SearchUserAccessTokensError>>
{
let local_var_configuration = configuration;
// unbox the parameters
let search_user_access_tokens_request = params.search_user_access_tokens_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/tokens/search",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&search_user_access_tokens_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SearchUserAccessTokensError> =
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))
}
}
/// Get a list of users based on search criteria provided in the request body. Searches are typically done against username, full name, nickname and email unless otherwise configured by the server. ##### Permissions Requires an active session and `read_channel` and/or `view_team` permissions for any channels or teams specified in the request body.
pub async fn search_users(
configuration: &configuration::Configuration,
params: SearchUsersParams,
) -> Result<Vec<crate::openapi::models::User>, Error<SearchUsersError>> {
let local_var_configuration = configuration;
// unbox the parameters
let search_users_request = params.search_users_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api/v4/users/search", 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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&search_users_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SearchUsersError> =
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))
}
}
/// Send an email containing a link for resetting the user's password. The link will contain a one-use, timed recovery code tied to the user's account. Only works for non-SSO users. ##### Permissions No permissions required.
pub async fn send_password_reset_email(
configuration: &configuration::Configuration,
params: SendPasswordResetEmailParams,
) -> Result<crate::openapi::models::StatusOk, Error<SendPasswordResetEmailError>> {
let local_var_configuration = configuration;
// unbox the parameters
let send_password_reset_email_request = params.send_password_reset_email_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/password/reset/send",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&send_password_reset_email_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SendPasswordResetEmailError> =
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))
}
}
/// Send an email with a verification link to a user that has an email matching the one in the request body. This endpoint will return success even if the email does not match any users on the system. ##### Permissions No permissions required.
pub async fn send_verification_email(
configuration: &configuration::Configuration,
params: SendVerificationEmailParams,
) -> Result<crate::openapi::models::StatusOk, Error<SendVerificationEmailError>> {
let local_var_configuration = configuration;
// unbox the parameters
let send_verification_email_request = params.send_verification_email_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/email/verify/send",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&send_verification_email_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SendVerificationEmailError> =
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))
}
}
/// Delete user's profile image and reset to default image based on user_id string parameter. ##### Permissions Must be logged in as the user being updated or have the `edit_other_users` permission. __Minimum server version__: 5.5
pub async fn set_default_profile_image(
configuration: &configuration::Configuration,
params: SetDefaultProfileImageParams,
) -> Result<crate::openapi::models::StatusOk, Error<SetDefaultProfileImageError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/image",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SetDefaultProfileImageError> =
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))
}
}
/// Set a user's profile image based on user_id string parameter. ##### Permissions Must be logged in as the user being updated or have the `edit_other_users` permission.
pub async fn set_profile_image(
configuration: &configuration::Configuration,
params: SetProfileImageParams,
) -> Result<crate::openapi::models::StatusOk, Error<SetProfileImageError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let _image = params.image;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/image",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let mut local_var_form = reqwest::multipart::Form::new();
// TODO: support file upload for 'image' parameter
local_var_req_builder = local_var_req_builder.multipart(local_var_form);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SetProfileImageError> =
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))
}
}
/// Switch a user's login method from using email to OAuth2/SAML/LDAP or back to email. When switching to OAuth2/SAML, account switching is not complete until the user follows the returned link and completes any steps on the OAuth2/SAML service provider. To switch from email to OAuth2/SAML, specify `current_service`, `new_service`, `email` and `password`. To switch from OAuth2/SAML to email, specify `current_service`, `new_service`, `email` and `new_password`. To switch from email to LDAP/AD, specify `current_service`, `new_service`, `email`, `password`, `ldap_ip` and `new_password` (this is the user's LDAP password). To switch from LDAP/AD to email, specify `current_service`, `new_service`, `ldap_ip`, `password` (this is the user's LDAP password), `email` and `new_password`. Additionally, specify `mfa_code` when trying to switch an account on LDAP/AD or email that has MFA activated. ##### Permissions No current authentication required except when switching from OAuth2/SAML to email.
pub async fn switch_account_type(
configuration: &configuration::Configuration,
params: SwitchAccountTypeParams,
) -> Result<crate::openapi::models::SwitchAccountType200Response, Error<SwitchAccountTypeError>> {
let local_var_configuration = configuration;
// unbox the parameters
let switch_account_type_request = params.switch_account_type_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/login/switch",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&switch_account_type_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SwitchAccountTypeError> =
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))
}
}
/// Update a user by providing the user object. The fields that can be updated are defined in the request body, all other provided fields will be ignored. Any fields not included in the request body will be set to null or reverted to default values. ##### Permissions Must be logged in as the user being updated or have the `edit_other_users` permission.
pub async fn update_user(
configuration: &configuration::Configuration,
params: UpdateUserParams,
) -> Result<crate::openapi::models::User, Error<UpdateUserError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let update_user_request = params.update_user_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&update_user_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<UpdateUserError> =
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))
}
}
/// Update user active or inactive status. __Since server version 4.6, users using a SSO provider to login can be activated or deactivated with this endpoint. However, if their activation status in Mattermost does not reflect their status in the SSO provider, the next synchronization or login by that user will reset the activation status to that of their account in the SSO provider. Server versions 4.5 and before do not allow activation or deactivation of SSO users from this endpoint.__ ##### Permissions User can deactivate themselves. User with `manage_system` permission can activate or deactivate a user.
pub async fn update_user_active(
configuration: &configuration::Configuration,
params: UpdateUserActiveParams,
) -> Result<crate::openapi::models::StatusOk, Error<UpdateUserActiveError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let update_user_active_request = params.update_user_active_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/active",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&update_user_active_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<UpdateUserActiveError> =
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))
}
}
/// Updates a user's authentication method. This can be used to change them to/from LDAP authentication for example. __Minimum server version__: 4.6 ##### Permissions Must have the `edit_other_users` permission.
pub async fn update_user_auth(
configuration: &configuration::Configuration,
params: UpdateUserAuthParams,
) -> Result<crate::openapi::models::UserAuthData, Error<UpdateUserAuthError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let user_auth_data = params.user_auth_data;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/auth",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&user_auth_data);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<UpdateUserAuthError> =
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))
}
}
/// Activates multi-factor authentication for the user if `activate` is true and a valid `code` is provided. If activate is false, then `code` is not required and multi-factor authentication is disabled for the user. ##### Permissions Must be logged in as the user being updated or have the `edit_other_users` permission.
pub async fn update_user_mfa(
configuration: &configuration::Configuration,
params: UpdateUserMfaParams,
) -> Result<crate::openapi::models::StatusOk, Error<UpdateUserMfaError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let update_user_mfa_request = params.update_user_mfa_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/mfa",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&update_user_mfa_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<UpdateUserMfaError> =
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))
}
}
/// Update a user's password. New password must meet password policy set by server configuration. Current password is required if you're updating your own password. ##### Permissions Must be logged in as the user the password is being changed for or have `manage_system` permission.
pub async fn update_user_password(
configuration: &configuration::Configuration,
params: UpdateUserPasswordParams,
) -> Result<crate::openapi::models::StatusOk, Error<UpdateUserPasswordError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let update_user_password_request = params.update_user_password_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/password",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&update_user_password_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<UpdateUserPasswordError> =
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))
}
}
/// Update a user's system-level roles. Valid user roles are \"system_user\", \"system_admin\" or both of them. Overwrites any previously assigned system-level roles. ##### Permissions Must have the `manage_roles` permission.
pub async fn update_user_roles(
configuration: &configuration::Configuration,
params: UpdateUserRolesParams,
) -> Result<crate::openapi::models::StatusOk, Error<UpdateUserRolesError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let update_user_roles_request = params.update_user_roles_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/roles",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_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.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&update_user_roles_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<UpdateUserRolesError> =
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))
}
}
/// Verify the email used by a user to sign-up their account with. ##### Permissions No permissions required.
pub async fn verify_user_email(
configuration: &configuration::Configuration,
params: VerifyUserEmailParams,
) -> Result<crate::openapi::models::StatusOk, Error<VerifyUserEmailError>> {
let local_var_configuration = configuration;
// unbox the parameters
let verify_user_email_request = params.verify_user_email_request;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/email/verify",
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&verify_user_email_request);
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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<VerifyUserEmailError> =
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))
}
}
/// Verify the email used by a user without a token. __Minimum server version__: 5.24 ##### Permissions Must have `manage_system` permission.
pub async fn verify_user_email_without_token(
configuration: &configuration::Configuration,
params: VerifyUserEmailWithoutTokenParams,
) -> Result<crate::openapi::models::User, Error<VerifyUserEmailWithoutTokenError>> {
let local_var_configuration = configuration;
// unbox the parameters
let user_id = params.user_id;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/api/v4/users/{user_id}/email/verify/member",
local_var_configuration.base_path,
user_id = super::urlencode(user_id)
);
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_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.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() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<VerifyUserEmailWithoutTokenError> =
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))
}
}