Google Cloud API
Description:
- Work with the Google Cloud API
Resources:
- https://gcloud.readthedocs.io/en/latest/storage-client.html
- https://googleapis.github.io/google-api-python-client/docs/start.html
- https://github.com/googleapis/google-api-python-client
- https://developers.google.com/drive/v3/reference/
- https://googleapis.github.io/google-api-python-client/docs/epy/index.html
- https://googleapis.github.io/google-api-python-client/docs/dyn/
- https://github.com/googleapis/google-cloud-python
- https://cloud.google.com/python/docs/reference
- https://googleapis.github.io/google-api-python-client/docs/dyn/drive_v3.html
Environment variables
Section titled “Environment variables”This notebook reads these environment variables. Set them before you start Jupyter:
GOOGLE_CLOUD_PROJECT: your Google Cloud project id.GCS_BUCKET: a Google Cloud Storage bucket in that project that holds an object namedexample.jpeg.
Example 1
Section titled “Example 1”Download an object as bytes and print the length of the object
import osfrom google.cloud import storage
storage_client = storage.Client(project=os.environ["GOOGLE_CLOUD_PROJECT"])bucket = storage_client.bucket(os.environ["GCS_BUCKET"])blob = bucket.blob('example.jpeg')bts = blob.download_as_bytes()
print(len(bts))Example 2
Section titled “Example 2”Work with a Google service (like Google Drive, BigQuery, etc)
from googleapiclient.discovery import build
with build('drive', 'v3') as service: print(service.about())Example 3
Section titled “Example 3”Work with a Google service
from apiclient.discovery import build
service = build('admin', 'directory_v1')print(service.customer())ganymede is made by Eugo