Registry /
gcp / google-cloud-service-control
Install & Compatibility
Where this runs
tested against v1.20.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.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 68.7MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 5.4s · import 0.000s · 66MB
67MB installed
● package 67MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ServiceControllerClient
✓ from google.cloud.service_control_v1 import ServiceControllerClient
✗ from google.cloud.service_control_v1 import ServiceControllerClient
This quickstart demonstrates how to instantiate the `ServiceControllerClient` and send a `ReportRequest`. It requires setting `SERVICE_NAME` to your managed service name and `CONSUMER_ID` to the Google Cloud project consuming the service. The example creates a basic `Operation` with a log entry and reports it. Ensure `GOOGLE_APPLICATION_CREDENTIALS` is set or default credentials are configured.
import os
from google.cloud import service_control_v1
from google.protobuf import timestamp_pb2
# Replace with your actual service name and consumer ID
# The service name must be registered in Google Service Management.
SERVICE_NAME = os.environ.get("GCP_SERVICE_CONTROL_SERVICE_NAME", "my-service.endpoints.project-id.cloud.goog")
CONSUMER_ID = os.environ.get("GCP_SERVICE_CONTROL_CONSUMER_ID", "project:your-gcp-project-id") # e.g., 'project:my-project-id'
# Create a client
client = service_control_v1.ServiceControllerClient()
# Prepare an operation
now = timestamp_pb2.Timestamp()
now.GetCurrentTime()
operation = service_control_v1.Operation(
operation_id="test-operation-123",
consumer_id=CONSUMER_ID,
start_time=now,
end_time=now,
operation_name="example.method",
user_labels={
"environment": "dev",
"component": "example"
},
log_entries=[
service_control_v1.LogEntry(
name="access_log",
text_payload="Example log message from service control."
)
]
)
# Create a ReportRequest
request = service_control_v1.ReportRequest(
service_name=SERVICE_NAME,
operations=[operation],
)
try:
# Send the report
response = client.report(request=request)
print(f"Report successful. Processed operations: {len(response.report_errors)}")
if response.report_errors:
for error in response.report_errors:
print(f" Error for operation '{error.operation_id}': {error.code} - {error.message}")
except Exception as e:
print(f"An error occurred during reporting: {e}")
Debug
Known issues
breakingFuture versions of `google-cloud-python` client libraries, including `google-cloud-service-control`, are actively dropping support for older Python versions. While 3.9 is currently supported, it's advisable to upgrade to Python 3.10+ to ensure compatibility with future releases and security updates across the Google Cloud ecosystem.fixUpgrade your Python environment to 3.10 or newer. Check the library's `pyproject.toml` or `setup.cfg` for exact `requires_python` specifications before upgrading the library.
affects: >=1.19.0 (anticipated for future minor/major versions)
gotchaAuthentication failures are common, often resulting in `DefaultCredentialsError` or similar messages indicating no credentials could be found. The client libraries rely on Google Application Default Credentials (ADC).fixEnsure your environment is properly authenticated. For local development, set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path of a service account key file (`export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json"`) or run `gcloud auth application-default login`. For production, ensure your service account or VM has the necessary IAM roles (e.g., `Service Controller` or custom roles).
affects: All versions
gotchaThe Service Control API has quotas and rate limits. Exceeding these limits can lead to `ResourceExhausted` errors (HTTP 429) or degraded performance.fixImplement exponential backoff and retry logic for API calls. Review your project's quota usage in the Google Cloud Console and request increases if necessary. Design your application to batch operations or reduce the frequency of calls where possible.
affects: All versions
Upgrade
Version history
1.20.0latest on PyPI · released Jun 3, 2026
Audit
Dependencies
No dependency data recorded yet.