Crate google_drive[−][src]
A rust library for interacting with the Google Drive v3 API.
For more information, the Google Drive v3 API is documented at developers.google.com/drive/api/v3/reference.
Example:
use std::env; use google_drive::GoogleDrive; use yup_oauth2::{read_service_account_key, ServiceAccountAuthenticator}; async fn get_drives() { // 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/drive"]).await.expect("failed to get token"); if token.as_str().is_empty() { panic!("empty token is not valid"); } // Initialize the Google Drive client. let drive_client = GoogleDrive::new(token); // List drives. let drives = drive_client.list_drives().await.unwrap(); // Iterate over the drives. for drive in drives { println!("{:?}", drive); } }
Structs
APIError | Error type returned by our library. |
Drive | A drive. |
DriveBackgroundImageFile | An image file and cropping parameters from which a background image for this shared drive is set. This is a write only field; it can only be set on drive.drives.update requests that don’t set themeId. When specified, all fields of the backgroundImageFile must be set. |
DriveCapabilities | Capabilities the current user has on this shared drive. |
DriveRestrictions | A set of restrictions that apply to this shared drive or items inside this shared drive. |
File | A file. |
FileCapabilities | Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take. |
FileContentHints | Additional information about the content of the file. These fields are never populated in responses. |
FileContentHintsThumbnail | A thumbnail for the file. This will only be used if Google Drive cannot generate a standard thumbnail. |
FileImageMediaMetadata | Additional metadata about image media, if available. |
FileImageMediaMetadataLocation | Geographic location information stored in the image. |
FileVideoMediaMetadata | Additional metadata about video media. This may not be available immediately upon upload. |
GoogleDrive | Entrypoint for interacting with the Google Drive API. |
ObjectAclProjectTeam | |
ObjectAclResource | |
ObjectCustomerEncryption | |
ObjectOwner | |
ObjectResource | |
Permission | A permission for a file. A permission grants a user, group, domain or the world access to a file or a folder hierarchy. |
PermissionPermissionDetails | Details of whether the permissions on this shared drive item are inherited or directly on this item. This is an output-only field which is present only for shared drive items. |
PermissionTeamDrivePermissionDetails | Deprecated - use permissionDetails instead. |
TeamDriveBackgroundImageFile | An image file and cropping parameters from which a background image for this Team Drive is set. This is a write only field; it can only be set on drive.teamdrives.update requests that don’t set themeId. When specified, all fields of the backgroundImageFile must be set. |
TeamDriveCapabilities | Capabilities the current user has on this Team Drive. |
User | Information about a Drive user. |