Skip to content

Description:

  • Work with the Google Cloud API

Resources:

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 named example.jpeg.

Download an object as bytes and print the length of the object

import os
from 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))

Work with a Google service (like Google Drive, BigQuery, etc)

from googleapiclient.discovery import build
with build('drive', 'v3') as service:
print(service.about())

Work with a Google service

from apiclient.discovery import build
service = build('admin', 'directory_v1')
print(service.customer())

ganymede is made by Eugo