google.drive
Platypush documentation
google.drive
- class platypush.plugins.google.drive.GoogleDrivePlugin(*args, **kwargs)[source]
Bases:
GooglePlugin
Google Drive plugin.
Requires:
google-api-python-client (
pip install google-api-python-client
)oauth2client (
pip install oauth2client
)
- __init__(*args, **kwargs)[source]
Initialized the Google plugin with the required scopes.
- Parameters:
scopes (list) – List of required scopes
- copy(file_id: str) GoogleDriveFile [source]
Create a copy of a file. :param file_id: File ID.
- create(name: str, description: Optional[str] = None, mime_type: Optional[str] = None, parents: Optional[List[str]] = None, starred: bool = False) GoogleDriveFile [source]
Create a file.
- Parameters:
name – File name.
description – File description.
mime_type – File MIME type.
parents – List of folder IDs that will contain the file (default: drive root).
starred – If True then the file will be marked as starred.
- download(file_id: str, path: str) str [source]
Download a Google Drive file locally.
- Parameters:
file_id – Path of the file to upload.
path – Path of the file to upload.
- Returns:
The local file path.
- files(filter: Optional[str] = None, folder_id: Optional[str] = None, limit: Optional[int] = 100, drive_id: Optional[str] = None, spaces: Optional[Union[str, List[str]]] = None, order_by: Optional[Union[str, List[str]]] = None) Union[GoogleDriveFile, List[GoogleDriveFile]] [source]
Get the list of files.
- Parameters:
filter – Optional filter (default: None). See Google Drive API docs for the supported syntax.
folder_id – Drive folder ID to search (default: get all files).
limit – Maximum number of entries to be retrieves (default: 100).
drive_id – Shared drive ID to search (default: None).
spaces –
Drive spaces to search. Supported values:
drive
appDataFolder
photos
order_by –
Order the results by a specific attribute or list of attributes (default: None). Supported attributes:
createdTime
folder
modifiedByMeTime
modifiedTime
name
name_natural
quotaBytesUsed
recency
sharedWithMeTime
starred
viewedByMeTime
Attributes will be sorted in ascending order by default. You can change that by by appending “
desc
” separated by a space to the attribute you want in descending order - e.g.["folder", "createdTime desc", "modifiedTime desc"]
.
- get(file_id: str)[source]
Get the information of a file on the Drive by file ID. :param file_id: File ID.
- update(file_id: str, name: Optional[str] = None, description: Optional[str] = None, add_parents: Optional[List[str]] = None, remove_parents: Optional[List[str]] = None, mime_type: Optional[str] = None, starred: bool = None, trashed: bool = None) GoogleDriveFile [source]
Update the metadata or the content of a file.
- Parameters:
file_id – File ID.
name – Set the file name.
description – Set the file description.
add_parents – Add the file to these parent folder IDs.
remove_parents – Remove the file from these parent folder IDs.
mime_type – Set the file MIME type.
starred – Change the starred flag.
trashed – Move/remove from trash.
- upload(path: str, mime_type: Optional[str] = None, name: Optional[str] = None, description: Optional[str] = None, parents: Optional[List[str]] = None, starred: bool = False, target_mime_type: Optional[str] = None) GoogleDriveFile [source]
Upload a file to Google Drive.
- Parameters:
path – Path of the file to upload.
mime_type – MIME type of the source file (e.g. “
image/jpeg
”).name – Name of the target file. Default: same name as the source file.
description – File description.
parents – List of folder IDs that will contain the file (default: drive root).
starred – If True, then the uploaded file will be marked as starred by the user.
target_mime_type – Target MIME type. Useful if you want to e.g. import a CSV file as a Google Sheet (use “
application/vnd.google-apps.spreadsheet
), or an ODT file to a Google Doc (use “application/vnd.google-apps.document
). See the official documentation for a complete list of supported types.