leaf_engine.io.gdrive.find

Functions

find_drive_id(→ str)

Finds the ID of a shared Google Drive by name.

find_file_id(→ Optional[str])

Finds the ID of a file by Google Drive path.

find_folder_id(→ Optional[str])

Find the Google Drive ID of an existing folder in given parent.

find_resource(→ Optional[dict])

Finds resource (file, folder) on Google Drive.

Module Contents

leaf_engine.io.gdrive.find.find_drive_id(name: str) str

Finds the ID of a shared Google Drive by name.

Parameters:

name (str) –

Return type:

str

leaf_engine.io.gdrive.find.find_file_id(path: str, trashed: bool = False) str | None

Finds the ID of a file by Google Drive path.

Parameters:
  • path (str) – Google Drive path. First part of the path must be the name of a shared Google Drive.

  • trashed (bool, optional) – Search Trash. Defaults to False.

Returns:

Google Drive ID of file described by path.

Return type:

str

leaf_engine.io.gdrive.find.find_folder_id(name: str, parent_folder_id: str | None, drive_id: str, trashed: bool = False) str | None

Find the Google Drive ID of an existing folder in given parent.

Parameters:
  • name (str) – Folder name.

  • parent_folder_id (Optional[str]) – Optional. Where to look for the folder. Parent folder ID can be found in the parent folder URL or by using this method and searching for the parent folder name.

  • drive_id (str) –

  • trashed (bool) –

Returns:

Folder ID. Returns None if no folder is found.

Return type:

Optional[str]

leaf_engine.io.gdrive.find.find_resource(name: str, parent_folder_id: str | None, drive_id: str, mime_type: str | None = None, trashed: bool = False) dict | None

Finds resource (file, folder) on Google Drive.

Parameters:
  • name (str) – Resource name.

  • drive_id (str) – Drive ID to search in.

  • parent_folder_id (Optional[str]) – What folder to search for resource. Optional.

  • mime_type (Optional[str]) – Type of resource to look for. Defaults to None.

  • trashed (bool) – Search trash. Defaults to False.

Raises:
  • LeafGoogleDriveException – Raised when more than one resource matches the provided

  • query parameters.

Returns:

Dictionary containing resource name and id.

Return type:

dict