Google Cloud Dataform

0.9.0 · active · verified Sat Mar 28

Google Cloud Dataform is a service for developing, creating, documenting, testing, and updating curated tables in BigQuery. This Python client library (version 0.9.0) provides an interface to interact with the Dataform API. Google Cloud client libraries typically follow a regular release cadence, often coinciding with API updates or bug fixes, and are generally well-maintained.

Warnings

Install

Imports

Quickstart

This quickstart initializes a Dataform client and lists all Dataform repositories within a specified Google Cloud project and location. Ensure your `GOOGLE_CLOUD_PROJECT` environment variable is set or replace 'your-project-id' with your actual project ID, and set the correct location. Authentication is handled automatically via Application Default Credentials (ADC).

import os
from google.cloud import dataform_v1beta

# Set your Google Cloud Project ID and Location
# For example, 'my-project-id' and 'us-central1'
project_id = os.environ.get('GOOGLE_CLOUD_PROJECT', 'your-project-id')
location = 'us-central1' # Replace with your Dataform repository location

def list_dataform_repositories(project_id: str, location: str):
    """Lists Dataform repositories in a given project and location."""
    client = dataform_v1beta.DataformClient()
    parent = f"projects/{project_id}/locations/{location}"

    print(f"Listing Dataform repositories in {parent}:")
    try:
        for repository in client.list_repositories(parent=parent):
            print(f"- Repository: {repository.name}")
    except Exception as e:
        print(f"Error listing repositories: {e}")
        print("Please ensure the Dataform API is enabled and your account has the necessary permissions.")

if __name__ == "__main__":
    list_dataform_repositories(project_id, location)

view raw JSON →