Install & Compatibility
Where this runs
tested against v4.4.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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 2.658s · 76.7MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 5.8s · import 1.468s · 75MB
76MB installed
● package 76MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AssetServiceClient
✓ from google.cloud.asset_v1 import AssetServiceClient
✗ from google.cloud import asset_v1
This quickstart demonstrates how to initialize the `AssetServiceClient` and use it to list all resources within a specified Google Cloud project. It relies on Application Default Credentials for authentication.
import os
from google.cloud import asset_v1
def list_all_assets(project_id: str):
"""Lists all assets in a given project."""
if not project_id:
raise ValueError("GOOGLE_CLOUD_PROJECT environment variable not set. Please set it or provide a project ID directly.")
client = asset_v1.AssetServiceClient()
# The scope can be a project, folder, or organization
# Example: 'projects/YOUR_PROJECT_ID', 'folders/YOUR_FOLDER_ID', 'organizations/YOUR_ORG_ID'
parent_scope = f"projects/{project_id}"
# Call the API to search all resources. Returns all asset types by default if none are specified.
request = asset_v1.SearchAllResourcesRequest(scope=parent_scope)
print(f"Listing assets for scope: {parent_scope}")
try:
for asset in client.search_all_resources(request=request):
print(f"Asset Name: {asset.name}, Type: {asset.asset_type}, State: {asset.state}")
except Exception as e:
print(f"Error listing assets: {e}")
if __name__ == "__main__":
# Set this environment variable or replace directly with your GCP Project ID
project_id = os.environ.get("GOOGLE_CLOUD_PROJECT", "")
# For local development, ensure Application Default Credentials (ADC) are set up:
# Run `gcloud auth application-default login` in your terminal.
# Or, set the GOOGLE_APPLICATION_CREDENTIALS environment variable
# to the path of a service account key file.
list_all_assets(project_id)
Debug
Known issues
breakingVersion 4.x of `google-cloud-asset` requires Python 3.9 or newer. Projects using older Python versions (3.8 or below) must upgrade their Python environment or use an older major version of the library.fixUpgrade your Python environment to 3.9+ or pin the library version to `google-cloud-asset<4`.
affects: 4.x.x and higher
gotchaAuthentication is primarily handled via Application Default Credentials (ADC). Misconfiguration of ADC, such as not running `gcloud auth application-default login` for local development or not attaching a service account to a production workload, will result in authentication errors.fixEnsure ADC is correctly configured for your environment. For local development, run `gcloud auth application-default login`. For production, use a service account with appropriate permissions.
affects: All versions
gotchaThe library's logging can contain sensitive information. By default, logging events are not handled. If enabled, ensure that log storage and access are properly secured to prevent exposure of sensitive metadata.fixConfigure Python's standard logging module to handle logs from `google.cloud.asset` explicitly, paying attention to log destination and access controls.
affects: All versions
gotchaMany API calls require a correctly formatted 'scope' (e.g., `projects/PROJECT_ID`, `folders/FOLDER_ID`, or `organizations/ORG_ID`). Incorrectly formatted resource names or scopes are a common source of API errors.fixAlways construct resource names using the prescribed format for the specific API method, typically found in the client library documentation or API reference.
affects: All versions
Upgrade
Version history
4.4.0latest on PyPI · released Jun 3, 2026
Audit
Dependencies
PythonrequiredRequired runtime environment. Version 4.x requires Python 3.9 or newer.
google-api-corerequiredCore library for Google API clients, handles requests, retries, and pagination.
google-authrequiredHandles authentication for Google Cloud services, including Application Default Credentials.
protobufrequiredUsed for serialization and deserialization of API messages.