Crate gsuite_api[−][src]
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); // List users. let users = gsuite_client.list_users().await; // Iterate over the users. for user in users { println!("{:?}", user); } }
Structs
APIError | Error type returned by our library. |
Attachment | |
Attendee | |
Building | A building. |
BuildingAddress | A building’s address. |
BuildingCoordinates | A building’s coordinates. |
Calendar | A calendar. FROM: https://developers.google.com/calendar/v3/reference/calendarList#resource |
CalendarEvent | A calendar event. FROM: https://developers.google.com/calendar/v3/reference/events#resource |
CalendarEvents | A list of calendar events. FROM: https://developers.google.com/calendar/v3/reference/events/list |
CalendarFeature | A feature of a calendar. |
CalendarFeatures | A calendar’s features. |
CalendarResource | A calendar resource. |
Calendars | A list of calendars. FROM: https://developers.google.com/calendar/v3/reference/calendarList/list |
Date | |
GSuite | Entrypoint for interacting with the GSuite APIs. |
Group | A Google group. FROM: https://developers.google.com/admin-sdk/directory/v1/reference/groups |
GroupSettings | A Google group’s settings. |
Organization | An organization |
User | A user. FROM: https://developers.google.com/admin-sdk/directory/v1/reference/users#resource |
UserAddress | A user’s address. |
UserCustomProperties | Custom properties for a user. |
UserEmail | A user’s email. |
UserExternalId | A user’s external id. |
UserGender | A user’s gender. |
UserInstantMessenger | A user’s instant messanger. |
UserKeyword | A user’s keyword. |
UserLanguage | A user’s language. |
UserLocation | A user’s location. |
UserName | A user’s name. |
UserNotes | A user’s notes. |
UserPhone | A user’s phone. |
UserPosixAccount | A user’s posix account. |
UserRelation | A user’s relation. |
UserSSHKey | A user’s ssh key. |
UserWebsite | A user’s website. |
Functions
generate_password | Generate a random string that we can use as a temporary password for new users when we set up their account. |