Registry / gcp / google-cloud-bigquery-datapolicies

google-cloud-bigquery-datapolicies

JSON →
library0.10.0pypypi✓ verified 82d ago

The Google Cloud BigQuery Data Policies API client library provides programmatic access to manage data policies (e.g., column-level security or data masking) within BigQuery datasets. This library allows users to create, retrieve, update, and delete data policies, enforcing fine-grained access control on BigQuery data. It is currently at version 0.9.0 and is part of the `google-cloud-python` monorepo, receiving updates aligned with the underlying API and shared client library components.

pip install google-cloud-bigquery-datapolicies
INSTALL
IMPORT
SIG · GOOGLE-CLOUD-BIGQU
G
google-cloud-bigquery-datapolicies
gcppythonv0.10.0
Install
5.6s avg
Import
1663ms
Disk
69MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 1.890s · 70.4MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 5.6s · import 1.435s · 68MB
69MB installed
● package 69MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DataPolicyServiceClient
from google.cloud.bigquery_datapolicies_v1 import DataPolicyServiceClient
from google.cloud import bigquery_datapolicies_v1

This quickstart initializes the BigQuery Data Policies client and lists all data policies within a specified Google Cloud project and location. Remember to authenticate your application (e.g., via `gcloud auth application-default login` or `GOOGLE_APPLICATION_CREDENTIALS`).

import os from google.cloud import bigquery_datapolicies_v1 from google.api_core.exceptions import GoogleAPIError def list_bigquery_data_policies(project_id: str, location: str): """Lists BigQuery data policies for a given project and location.""" # Ensure GOOGLE_CLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS # or other authentication methods are set in your environment. client = bigquery_datapolicies_v1.DataPolicyServiceClient() parent = f"projects/{project_id}/locations/{location}" print(f"Listing data policies for {parent}:") try: response = client.list_data_policies(parent=parent) policies_found = False for data_policy in response: print(f" - Data Policy: {data_policy.name}") policies_found = True if not policies_found: print(" No data policies found.") except GoogleAPIError as e: print(f"Error listing data policies: {e}") # Example usage: # Replace with your actual project ID and desired location PROJECT_ID = os.environ.get("GOOGLE_CLOUD_PROJECT", "your-gcp-project-id") LOCATION = os.environ.get("GCP_REGION", "us-central1") # e.g., "us-central1", "europe-west2" if PROJECT_ID == "your-gcp-project-id": print("Please set the GOOGLE_CLOUD_PROJECT environment variable or replace 'your-gcp-project-id' in the script.") else: list_bigquery_data_policies(PROJECT_ID, LOCATION)
Debug
Known issues
gotchaThe library is in `0.x.x` versioning. While generally stable, this indicates that the API is not yet declared stable and may introduce breaking changes in minor versions, not just major versions.
fix
Always pin to a specific `0.x.y` version in your `requirements.txt` (e.g., `google-cloud-bigquery-datapolicies==0.9.0`) and review release notes when upgrading.
affects: 0.1.0 - 0.9.0
gotchaBigQuery Data Policies are a regional resource. You must specify a valid `location` when interacting with the API, as operations on resources in a `global` location are not supported.
fix
Ensure that the `location` parameter (e.g., 'us-central1', 'europe-west2') in your API calls is correct and matches the region where your data policies are defined.
affects: All versions
gotchaPermissionDenied errors (HTTP 403) are common when your service account or user lacks the necessary IAM roles to manage BigQuery Data Policies. Required roles include 'BigQuery Data Policy Admin' or equivalent custom roles.
fix
Verify that the principal (user or service account) used for authentication has the appropriate IAM roles on the BigQuery project or dataset. For creating/managing policies, 'BigQuery Data Policy Admin' is typically required.
affects: All versions
Upgrade
Version history
0.10.0latest on PyPI · released Jun 3, 2026
Audit
Dependencies
google-api-corerequiredCore functionality for Google Cloud APIs, including authentication and API calls.
google-cloud-bigqueryoptionalOften used in conjunction with BigQuery Data Policies for complete data governance solutions.
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources
google-cloud-bigquery-datapolicies — pip install google-cloud-bigquery-datapolicies · libregistry