pub async fn create(
client: &mut BoxClient<'_>,
fields: Option<Vec<String>>,
user: PostUsersRequest,
) -> Result<UserFull, BoxAPIError>Expand description
Creates a new managed user in an enterprise. This endpoint is only available to users and applications with the right admin permissions.
Sample usage:
use rusty_box::{Config, DevAuth, BoxClient,BoxAPIError, users_api, users::models::{PostUsersRequest, Role, Status}};
use dotenv;
use std::env;
#[tokio::main]
async fn main() -> Result<(), BoxAPIError> {
dotenv::from_filename(".dev.env").ok();
let access_token = env::var("DEVELOPER_TOKEN").expect("DEVELOPER_TOKEN must be set");
let config = Config::new();
let auth = DevAuth::new(
config,
access_token,
);
let mut client = BoxClient::new(Box::new(auth));
let new_user_request = PostUsersRequest {
name: "Test User".to_string(),
login: Some("test.user@gmail.local".to_string()),
is_platform_access_only: Some(false),
role: Some(Role::Coadmin),
language: Some("en".to_string()),
is_sync_enabled: Some(true),
job_title: Some("Test Job Title".to_string()),
phone: Some("555-555-5555".to_string()),
address: Some("123 Test St".to_string()),
space_amount: Some(1073741824),
// tracking_codes: Some(vec!["test-tracking-code".to_string()]),
can_see_managed_users: Some(true),
timezone: Some("America/Los_Angeles".to_string()),
is_external_collab_restricted: Some(false),
is_exempt_from_device_limits: Some(false),
is_exempt_from_login_verification: Some(false),
status: Some(Status::Active),
external_app_user_id: Some("test-external-app-user-id".to_string()),
..Default::default()
};
let new_user = users_api::create(&mut client, None, new_user_request).await?;
println!("New User:{:#?}", new_user);
Ok(())
}