Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(services/gdrive): Support shared drives in Google Drive API integration #4591

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/src/services/gdrive/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ pub struct GdriveConfig {
pub client_id: Option<String>,
/// Client secret for gdrive.
pub client_secret: Option<String>,
/// ID of shared drive to search.
pub drive_id: Option<String>,
}

impl Debug for GdriveConfig {
Expand Down Expand Up @@ -127,6 +129,12 @@ impl GdriveBuilder {
self
}

/// Set the drive id for GoogleDrive
pub fn drive_id(&mut self, drive_id: &str) -> &mut Self {
self.config.drive_id = Some(drive_id.to_string());
self
}

/// Specify the http client that used by this service.
///
/// # Notes
Expand Down Expand Up @@ -219,6 +227,7 @@ impl Builder for GdriveBuilder {
Ok(GdriveBackend {
core: Arc::new(GdriveCore {
root,
drive_id: self.config.drive_id.clone(),
signer: signer.clone(),
client: client.clone(),
path_cache: PathCacher::new(GdrivePathQuery::new(client, signer)).with_lock(),
Expand Down
6 changes: 6 additions & 0 deletions core/src/services/gdrive/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ use crate::*;
pub struct GdriveCore {
pub root: String,

pub drive_id: Option<String>,

pub client: HttpClient,

pub signer: Arc<Mutex<GdriveSigner>>,
Expand Down Expand Up @@ -113,6 +115,10 @@ impl GdriveCore {
url += &format!("&pageToken={next_page_token}");
};

if let Some(drive_id) = self.drive_id.as_ref() {
url += &format!("&drive_id={}&supportsAllDrives=true", drive_id);
}

let mut req = Request::get(&url)
.body(Buffer::new())
.map_err(new_request_build_error)?;
Expand Down
Loading