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.1.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file gaggle-0.2.1.tar.gz
.
File metadata
- Download URL: gaggle-0.2.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.4 CPython/3.7.1 Darwin/18.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8deec8639634fbc7e774b64a601f82bc93a66130cbdb829d5b2897a4ffaf7db0 |
|
MD5 | d75046db5e068def9d460edc9255d5bf |
|
BLAKE2b-256 | b8906c5dd3c3673e062744e55a4ce46704b2d8feb649aae401afb0106627c4da |
File details
Details for the file gaggle-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: gaggle-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.4 CPython/3.7.1 Darwin/18.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8133faecb97267f0cabcd24f8a648ec51bc5ba94386781b35df759af0b02d5aa |
|
MD5 | e3b02eea51142e1aa74fca66981be64c |
|
BLAKE2b-256 | f5e78ba2360c548814151f05a65554767d7a18c3d83b1668184c6a38277a3589 |