A simple wrapper for GoogleApi
Project description
TL:DR
Simple wrapper for some of google api functions for python namely: Google Shared Drive and Google Email
How to use
Example to use the googledrivewrapper.py
from googleapiwrapper.googledrivewrapper import GoogleSharedDrive
# Load your service account credentials. Google to find out how to do it
SERVICE_ACCOUNT_FILE = './credentials.json'
# instantiate the Drive
shared_drives = GoogleSharedDrive(SERVICE_ACCOUNT_FILE)
# Find the ID for the folder name
folder_1_id = shared_drives.fetch_folder_id('<YOURPROJECTNAME>')
# Create a new folder in previous folder
newFolder = shared_drives.create_new_folder(folder_1_id, '<new folder>')
# Create another folder in new folder's folder
subfile = shared_drives.create_new_folder(newFolder['id'], 'new sub folder')
# Upload a new file in new folder, will output the file meta data
file_metadata = shared_drives.upload_file(newFolder['id'], './<file you need>', 'new_file.xlsx')
# Get the file ID
fileID = file_metadata.get('id')
# Search a file ID using file Name in a specific folder
# You will need to provide the folder ID for this function
input_folder_id = "<YOURFOLDERID>"
file_name = "test.xlsx"
fileID = shared_drives.search_fileID_in_folder_using_fileName(input_folder_id, file_name)
# Download file from GoogleDrive
input_file_id = '<YOURFOLDERID>'
shared_drives.download_file(input_file_id, './test.xlsx')
Example to use the googleemailwrapper.py
from googleapiwrapper.googleemailwrapper import GoogleEmail
SERVICE_ACCOUNT_FILE = "./credentials.json"
EMAIL_FROM = "<YOUREMAILADDRESS>"
EMAIL_TO = "<OTHEREMAILADDRESS>"
EMAIL_SUBJECT = "Hello, Test"
EMAIL_CONTENT = "Testing. Thanks, it works"
# instantiate the Email
gmail = GoogleEmail(SERVICE_ACCOUNT_FILE, EMAIL_FROM)
# Create the email contents
message = gmail.create_message(EMAIL_TO, EMAIL_SUBJECT, EMAIL_CONTENT, ['test.csv'])
# Send email
sent = gmail.send_message()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file googleapiwrapper-0.2.0.tar.gz.
File metadata
- Download URL: googleapiwrapper-0.2.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.7.4 Darwin/19.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75a534203b5383a0288a2d9c543d0b2942390d86abe2a4b57f8ad69b8117b459
|
|
| MD5 |
fa88d221de4e4c7ddcda0dbc72bba1e2
|
|
| BLAKE2b-256 |
f72622a6ee98d9e84bba11f4d461fa97d7c439e806e73ff04825a5c6f5115a2e
|
File details
Details for the file googleapiwrapper-0.2.0-py3-none-any.whl.
File metadata
- Download URL: googleapiwrapper-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.7.4 Darwin/19.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcafbeb2535f84bd20b090e4a81f55ca038d043bb2c2f5bf517c5e556e53641e
|
|
| MD5 |
f54639307f0915188126e43ad93ca4fe
|
|
| BLAKE2b-256 |
43fce1b7fd870852051f13b120aa296cfab7fe1c757c753d2e9cd2ea0a0a531c
|