Registry / gcp / google-cloud-asset

google-cloud-asset

JSON →
library4.4.0pypypi✓ verified 21d ago

The `google-cloud-asset` client library for Python provides programmatic access to the Google Cloud Asset Inventory API. It allows users to track, analyze, and export metadata for Google Cloud resources and IAM policies, maintaining a five-week history of changes. Part of the `google-cloud-python` monorepo, it receives regular updates. The current version is 4.3.0.

pip install google-cloud-asset
INSTALL
IMPORT
SIG · GOOGLE-CLOUD-ASSET
G
google-cloud-asset
gcppythonv4.4.0
Install
5.8s avg
Import
2063ms
Disk
76MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.658s · 76.7MB
glibc
py 3.103.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.
fix
Upgrade 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.
fix
Ensure 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.
fix
Configure 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.
fix
Always 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.
Agent activity
41 hits · last 30 days
node
36
OpenAI (training)
1
Resources
google-cloud-asset — pip install google-cloud-asset · libregistry