Common protocol buffer definitions used across Google APIs and client libraries
npx @tessl/cli install tessl/pypi-googleapis-common-protos@1.70.0Common protocol buffer definitions used across Google APIs and client libraries. This package provides Python-generated protobuf classes for core Google API concepts including authentication, billing, logging, monitoring, quotas, and resource management, serving as foundational types for the Google Cloud ecosystem.
pip install googleapis-common-protospip install googleapis-common-protos[grpc]# Import specific message types
from google.api import field_behavior_pb2
from google.api import resource_pb2
from google.rpc import status_pb2
from google.type import money_pb2Module-specific imports:
# API framework types
from google.api.field_behavior_pb2 import FieldBehavior
from google.api.resource_pb2 import ResourceDescriptor, ResourceReference
# RPC status and error handling
from google.rpc.status_pb2 import Status
from google.rpc.code_pb2 import Code
from google.rpc.error_details_pb2 import ErrorInfo, RetryInfo
# Common data types
from google.type.money_pb2 import Money
from google.type.date_pb2 import Date
from google.type.latlng_pb2 import LatLng
# Long-running operations
from google.longrunning.operations_proto_pb2 import Operation, GetOperationRequest
# Logging types
from google.logging.type.log_severity_pb2 import LogSeverity
from google.logging.type.http_request_pb2 import HttpRequest
# API maturity levels
from google.api.launch_stage_pb2 import LaunchStagefrom google.api.field_behavior_pb2 import FieldBehavior
from google.rpc.status_pb2 import Status
from google.rpc.code_pb2 import Code
from google.type.money_pb2 import Money
# Working with field behavior annotations
field_behavior = FieldBehavior.REQUIRED
# Creating status messages for error handling
status = Status()
status.code = Code.INVALID_ARGUMENT
status.message = "Required field is missing"
# Working with monetary values
price = Money()
price.currency_code = "USD"
price.units = 29
price.nanos = 990000000 # $29.99The googleapis-common-protos package is organized into seven main namespaces:
All message classes inherit from google.protobuf.message.Message and provide full type safety through comprehensive .pyi type stub files. The package serves as the foundational layer for the entire Google Cloud client library ecosystem.
Core infrastructure for Google API definition including field behaviors, resource patterns, authentication, HTTP mapping, and client library configuration. These types enable consistent API design and automatic client generation across Google services.
# Field behavior annotations
class FieldBehavior(enum.Enum):
FIELD_BEHAVIOR_UNSPECIFIED = 0
OPTIONAL = 1
REQUIRED = 2
OUTPUT_ONLY = 3
INPUT_ONLY = 4
IMMUTABLE = 5
UNORDERED_LIST = 6
NON_EMPTY_DEFAULT = 7
IDENTIFIER = 8
# Resource descriptors for API resources
class ResourceDescriptor(message.Message):
type: str
pattern: list[str]
name_field: str
history: ResourceDescriptor.History
plural: str
singular: str
style: list[ResourceDescriptor.Style]
# HTTP rule mapping for gRPC services
class HttpRule(message.Message):
selector: str
get: str
put: str
post: str
delete: str
patch: str
custom: CustomHttpPattern
body: str
response_body: str
additional_bindings: list[HttpRule]
# API maturity levels
class LaunchStage(enum.Enum):
LAUNCH_STAGE_UNSPECIFIED = 0
UNIMPLEMENTED = 1
PRELAUNCH = 2
EARLY_ACCESS = 3
ALPHA = 4
BETA = 5
GA = 6
DEPRECATED = 7Standard RPC status codes, error details, and context information for robust error handling across Google services. Provides structured error reporting with detailed failure information.
# RPC status representation
class Status(message.Message):
code: int
message: str
details: list[Any]
# Standard gRPC status codes
class Code(enum.Enum):
OK = 0
CANCELLED = 1
UNKNOWN = 2
INVALID_ARGUMENT = 3
DEADLINE_EXCEEDED = 4
NOT_FOUND = 5
ALREADY_EXISTS = 6
PERMISSION_DENIED = 7
UNAUTHENTICATED = 16
RESOURCE_EXHAUSTED = 8
FAILED_PRECONDITION = 9
ABORTED = 10
OUT_OF_RANGE = 11
UNIMPLEMENTED = 12
INTERNAL = 13
UNAVAILABLE = 14
DATA_LOSS = 15
# Detailed error information
class ErrorInfo(message.Message):
reason: str
domain: str
metadata: dict[str, str]
class RetryInfo(message.Message):
retry_delay: DurationFundamental data types for temporal, geographic, financial, and contact information used across Google APIs. Includes types for dates, money, coordinates, phone numbers, and postal addresses.
# Monetary amounts with currency
class Money(message.Message):
currency_code: str
units: int
nanos: int
# Calendar dates
class Date(message.Message):
year: int
month: int
day: int
# Geographic coordinates
class LatLng(message.Message):
latitude: float
longitude: float
# Phone number representation
class PhoneNumber(message.Message):
e164_number: str
short_code: PhoneNumber.ShortCode
extension: str
# Postal addresses
class PostalAddress(message.Message):
revision: int
region_code: str
postal_code: str
administrative_area: str
locality: str
address_lines: list[str]Support for asynchronous operations that may take significant time to complete. Provides standard patterns for operation management, polling, and result retrieval.
# Operation representation
class Operation(message.Message):
name: str
metadata: Any
done: bool
error: Status
response: Any
# Operation management requests
class GetOperationRequest(message.Message):
name: str
class ListOperationsRequest(message.Message):
name: str
filter: str
page_size: int
page_token: str
class CancelOperationRequest(message.Message):
name: strTypes for metrics, distributions, monitored resources, and logging. Enables comprehensive observability and monitoring of Google services with structured data collection.
# Metric definitions
class MetricDescriptor(message.Message):
name: str
type: str
labels: list[LabelDescriptor]
metric_kind: MetricDescriptor.MetricKind
value_type: MetricDescriptor.ValueType
unit: str
description: str
# Statistical distributions
class Distribution(message.Message):
count: int
mean: float
sum_of_squared_deviation: float
range: Distribution.Range
bucket_options: Distribution.BucketOptions
bucket_counts: list[int]
# Monitored resource descriptors
class MonitoredResourceDescriptor(message.Message):
name: str
type: str
display_name: str
description: str
labels: list[LabelDescriptor]Cloud-specific extensions for location services, extended operations, and Google Cloud Platform integration. Provides types for multi-region services and cloud resource management.
# Cloud location representation
class Location(message.Message):
name: str
location_id: str
display_name: str
labels: dict[str, str]
metadata: Any
# Location service requests
class ListLocationsRequest(message.Message):
name: str
filter: str
page_size: int
page_token: str
class GetLocationRequest(message.Message):
name: strTypes for structured logging with severity levels and HTTP request information.
# Log severity levels
class LogSeverity(enum.Enum):
DEFAULT = 0
DEBUG = 100
INFO = 200
NOTICE = 300
WARNING = 400
ERROR = 500
CRITICAL = 600
ALERT = 700
EMERGENCY = 800
# HTTP request information for logging
class HttpRequest(message.Message):
request_method: str
request_url: str
request_size: int
status: int
response_size: int
user_agent: str
remote_ip: str
server_ip: str
referer: str
latency: Duration
cache_lookup: bool
cache_hit: bool
cache_validated_with_origin_server: bool
cache_fill_bytes: int
protocol: strAll protobuf message classes provide:
.pyi stub files__slots__ optimization for all classesFIELD_NUMBER constants for each field