Crate gsuite_api[−][src]
Expand description
A rust library for interacting with the GSuite APIs.
For more information, the GSuite Directory API is documented at developers.google.com/admin-sdk/directory/v1/reference and the Google Groups settings API is documented at developers.google.com/admin-sdk/groups-settings/v1/reference/groups.
Example:
use std::env; use gsuite_api::GSuite; use yup_oauth2::{read_service_account_key, ServiceAccountAuthenticator}; async fn get_users() { // Get the GSuite credentials file. let gsuite_credential_file = env::var("GADMIN_CREDENTIAL_FILE").unwrap(); let gsuite_subject = env::var("GADMIN_SUBJECT").unwrap(); let gsuite_secret = read_service_account_key(gsuite_credential_file).await.expect("failed to read gsuite credential file"); let auth = ServiceAccountAuthenticator::builder(gsuite_secret) .subject(gsuite_subject.to_string()) .build() .await .expect("failed to create authenticator"); // Add the scopes to the secret and get the token. let token = auth .token(&[ "https://www.googleapis.com/auth/admin.directory.group", "https://www.googleapis.com/auth/admin.directory.resource.calendar", "https://www.googleapis.com/auth/admin.directory.user", "https://www.googleapis.com/auth/apps.groups.settings", ]) .await .expect("failed to get token"); if token.as_str().is_empty() { panic!("empty token is not valid"); } // Initialize the GSuite client. let gsuite_client = GSuite::new("customer_id", "domain", token.as_str().to_string()); // List users. let users = gsuite_client.list_users().await; // Iterate over the users. for user in users { println!("{:?}", user); } }
Structs
Error type returned by our library.
A building.
A building’s address.
A building’s coordinates.
A calendar. FROM: https://developers.google.com/calendar/v3/reference/calendarList#resource
A calendar event. FROM: https://developers.google.com/calendar/v3/reference/events#resource
A list of calendar events. FROM: https://developers.google.com/calendar/v3/reference/events/list
A feature of a calendar.
A calendar’s features.
A calendar resource.
A list of calendars. FROM: https://developers.google.com/calendar/v3/reference/calendarList/list
Entrypoint for interacting with the GSuite APIs.
A Google group. FROM: https://developers.google.com/admin-sdk/directory/v1/reference/groups
A Google group’s settings.
An organization
A user. FROM: https://developers.google.com/admin-sdk/directory/v1/reference/users#resource
A user’s address.
Custom properties for a user.
A user’s email.
A user’s external id.
A user’s gender.
A user’s instant messanger.
A user’s keyword.
A user’s language.
A user’s location.
A user’s name.
A user’s notes.
A user’s phone.
A user’s posix account.
A user’s relation.
A user’s ssh key.
A user’s website.
Functions
Generate a random string that we can use as a temporary password for new users when we set up their account.