Registry / gcp / google-cloud-quotas

google-cloud-quotas

JSON →
library0.6.0pypypiunverified

The `google-cloud-quotas` library is the official Python client for the Google Cloud Quotas API. It allows developers to programmatically list and manage service quotas for their Google Cloud projects. As part of the larger `google-cloud-python` monorepo, it receives updates as new API features are released, typically aligning with the Google Cloud release cycle.

pip install google-cloud-quotas
INSTALL
IMPORT
SIG · GOOGLE-CLOUD-QUOTA
G
google-cloud-quotas
gcppythonv0.6.0
Install
5.5s avg
Import
Disk
67MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.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 0.000s · 69.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 5.5s · import 0.000s · 67MB
67MB installed
● package 67MB
Code
Verified usage

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

QuotasClient
from google.cloud import quotas
from google.cloud import quotas

This quickstart demonstrates how to initialize the `QuotasClient` and list the quotas for a specified Google Cloud project and location. It assumes default authentication is set up (e.g., `GOOGLE_APPLICATION_CREDENTIALS` or `gcloud auth application-default login`). Remember to replace 'your-project-id' or set the `GOOGLE_CLOUD_PROJECT` environment variable.

import os from google.cloud.quotas_v1 import QuotasClient # Ensure GOOGLE_CLOUD_PROJECT environment variable is set or replace with your actual project ID. # Ensure GOOGLE_APPLICATION_CREDENTIALS points to a service account key file # or that you have logged in via `gcloud auth application-default login`. project_id = os.environ.get("GOOGLE_CLOUD_PROJECT", "your-project-id") location = "global" # Quotas are often global or regional for many services client = QuotasClient() parent_resource = f"projects/{project_id}/locations/{location}" try: print(f"Attempting to list quotas for parent: {parent_resource}") # Iterate through the first few quotas, as there can be many. for i, quota in enumerate(client.list_quotas(parent=parent_resource)): print(f" Quota: {quota.name}, Metric: {quota.quota_metric}, Value: {quota.value}, Limit: {quota.limit}") if i >= 2: # Print up to 3 quotas break except Exception as e: print(f"An error occurred: {e}") print("Possible causes: Missing permissions (e.g., serviceusage.quotas.get), incorrect project ID, or authentication issues.") print("Verify GOOGLE_CLOUD_PROJECT is set correctly and your credentials have the required roles.")
Debug
Known issues
gotchaThe `google-cloud-quotas` library requires Python 3.9 or newer. Running on older Python versions will lead to installation or runtime errors.
fix
Upgrade your Python environment to 3.9+ using tools like `pyenv` or `conda`.
affects: <=0.6.0
gotchaAuthentication with Google Cloud APIs is a common hurdle. If you encounter `DefaultCredentialsError` or similar authentication failures, your environment credentials are not properly configured.
fix
Ensure `GOOGLE_APPLICATION_CREDENTIALS` environment variable points to a valid service account key file, or run `gcloud auth application-default login` to set up user credentials. The service account/user must have the necessary IAM roles (e.g., `Service Usage Viewer`).
affects: All
gotchaThe `parent` argument for `list_quotas` must follow a specific format: `projects/{project_id}/locations/{location_id}`. Incorrect formatting will result in an `InvalidArgument` error.
fix
Construct the `parent` string carefully, for example: `f"projects/{project_id}/locations/global"` or `f"projects/{project_id}/locations/us-central1"`.
affects: All
gotchaEven with correct authentication, API calls might fail due to insufficient IAM permissions. Listing quotas requires roles like 'Service Usage Viewer' (`serviceusage.quotas.get`).
fix
Grant the service account or user making the API call the `roles/serviceusage.serviceUsageViewer` role or a custom role with `serviceusage.quotas.get` permission on the target project.
affects: All
Upgrade
Version history
0.6.0latest on PyPI · released Mar 26, 2026
Audit
Dependencies
google-api-corerequiredCore library for interacting with Google APIs, handles API requests, responses, and errors.
google-authrequiredManages authentication with Google Cloud services.
proto-plusrequiredProvides Pythonic wrappers for Protobuf messages used by Google APIs.
protobufrequiredGoogle's language-neutral, platform-neutral, extensible mechanism for serializing structured data.
Agent activity
36 hits · last 30 days
node
32
OpenAI (training)
1
Resources
google-cloud-quotas — pip install google-cloud-quotas · libregistry