This repository contains a Google Cloud Function that leverages Looker Python SDK. The repository can be used as a starter template to build serverless microservices that interact with Looker through the following workflow:
- Trigger an HTTP-based Cloud Function
- Initialize the Looker Python SDK
- Call Looker SDK methods and build custom logic to manage users, content, queries, etc.
In this repository, the main.py
file takes an email address as an input and checks if this email has been registered with an existing Looker user. If a current user is found, an email to reset the password will be sent to the user. Otherwise, a new user will be created, and a setup email will be sent.
Check out Looker's Python SDK examples for more code examples.
The following steps assume deployment using Google Cloud UI Console. Check out "Your First Function: Python" for steps to deploy using the gcloud
command-line tool
-
Obtain a Looker API3 Key
-
Follow the steps provided here to create a new Google Cloud Function
-
If using Google Sheet: Grant "Viewer" permission to the email address associated with the "Runtime service account" in Cloud Functions. The recommendation is to use the Default App Engine Service Account and share its email (
YOUR_PROJECT_ID@appspot.gserviceaccount.com
) to the Google Sheet. -
Configure runtime environment variables using the Cloud Function UI: Edit > Configuration > Runtime, build, connections and security settings > Runtime environment variables. Alternatively, environment variables can be configured through the
os
module or a.ini
file. Check Configuring Looker Python SDK for more information
-
Copy and paste the contents of
main.py
in this repository into themain.py
file once inside Cloud Function's inline editor. Change the "Entry point" in the top right to the main function.main.py
is executed once the function is triggered -
Copy and paste the contents of
requirements.txt
in this repository to therequirements.txt
file once inside Cloud Function's inline editor. This file is used to install necessary libraries to execute the function -
Deploy and test the function. Check out this article for instruction