aiohttp wrapper for google-api-client-python
Project description
gaggle
An aiohttp-based Google API client.
The google-api-python-client requirement is because this library uses it to discover services and prepare requests, leveraging the prepare+execute pattern implemented in googleapiclient.HttpRequest.
Usage
JSON
import asyncio
import aiohttp
from gaggle import Client
async def main():
async with aiohttp.ClientSession() as session:
drive = Client(
session=session,
token=access_token,
# the following are optional and only required if the access_token is expired and can be refreshed
refresh_token=refresh_token,
client_id=client_id,
client_secret=client_secret
).drive('v3')
resp = await drive.files.list(q="parents in 'root'")
# resp is an instance of aiohttp.ClientResponse
if resp.status == 200:
data = await resp.json()
files = data.get('files', [])
for obj in files:
print(obj)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Results in something like:
{'kind': 'drive#file', 'id': '...', 'name': 'test.csv', 'mimeType': 'text/csv'}
{'kind': 'drive#file', 'id': '...', 'name': 'Test Folder', 'mimeType': 'application/vnd.google-apps.folder'}
{'kind': 'drive#file', 'id': '...', 'name': 'spreadsheet.xlsx', 'mimeType': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}
{'kind': 'drive#file', 'id': '...', 'name': 'spreadsheet', 'mimeType': 'application/vnd.google-apps.spreadsheet'}
Installation
$ pip install gaggle
Testing and developing
I've included a handy Makefile to make these things fairly easy.
$ make setup
$ make test
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
gaggle-0.2.2rc1.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for gaggle-0.2.2rc1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d8e92be09825f4c67debc7cc89f50d7eee1eb9a765decf2d798c4bef155fb0b |
|
MD5 | 4b47fca952ee2071c840f14e9be9507a |
|
BLAKE2b-256 | fc0f74d498c16687b23daf422759eb7ce40fa0db23730c12191d374a555afed2 |