Google Cloud Redis Cluster
raw JSON → 0.4.0 verified Mon Apr 27 auth: no python
Google Cloud Redis Cluster API client library for managing Redis clusters on GCP. Version 0.4.0 (pre-GA). Requires Python >=3.9.
pip install google-cloud-redis-cluster Common errors
error ImportError: cannot import name 'CloudRedisClusterClient' from 'google.cloud' ↓
cause Incorrect import path; missing '_cluster' in module name.
fix
Use: from google.cloud.redis_cluster import CloudRedisClusterClient
error google.api_core.exceptions.PermissionDenied: 403 The caller does not have permission ↓
cause Service account or user lacks required IAM roles (e.g., Redis Cluster Viewer).
fix
Grant appropriate IAM roles on the project or use a properly scoped service account.
Warnings
gotcha The library is pre-GA (version <1.0). API surface may change without major version bumps. ↓
fix Pin to exact version and review changelog before upgrading.
gotcha Default credentials (ADC) must be set up via GOOGLE_APPLICATION_CREDENTIALS or gcloud auth; otherwise calls fail with 'Could not automatically determine credentials.' ↓
fix Set GOOGLE_APPLICATION_CREDENTIALS to a service account key file or run 'gcloud auth application-default login'.
deprecated The method 'list_clusters' and others may require an explicit request object in future versions (proto-plus migration). ↓
fix Use positional arguments or a request dict as shown in current docs.
Imports
- CloudRedisClusterClient wrong
from google.cloud.rediscluster import CloudRedisClusterClientcorrectfrom google.cloud.redis_cluster import CloudRedisClusterClient - cloud_redis_cluster_v1 wrong
import google.cloud.redis_clustercorrectfrom google.cloud import redis_cluster_v1
Quickstart
from google.cloud.redis_cluster import CloudRedisClusterClient
client = CloudRedisClusterClient()
# List clusters in a region
parent = "projects/{project_id}/locations/{location}".format(
project_id=os.environ.get('GOOGLE_CLOUD_PROJECT', ''),
location="us-central1"
)
clusters = client.list_clusters(request={"parent": parent})
print(list(clusters))