or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

api-framework.mdcloud-services.mdcommon-types.mdindex.mdmonitoring.mdoperations.mdrpc-status.md
tile.json

tessl/pypi-googleapis-common-protos

Common protocol buffer definitions used across Google APIs and client libraries

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/googleapis-common-protos@1.70.x

To install, run

npx @tessl/cli install tessl/pypi-googleapis-common-protos@1.70.0

index.mddocs/

Google APIs Common Protos

Common 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.

Package Information

  • Package Name: googleapis-common-protos
  • Language: Python
  • Installation: pip install googleapis-common-protos
  • Optional gRPC Support: pip install googleapis-common-protos[grpc]

Core Imports

# 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_pb2

Module-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 LaunchStage

Basic Usage

from 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.99

Architecture

The googleapis-common-protos package is organized into seven main namespaces:

  • google.api: API framework definitions for service configuration, authentication, resource management, and client generation
  • google.rpc: RPC framework types for status codes, error details, and request context
  • google.type: Common data types for temporal, geographic, financial, and contact information
  • google.longrunning: Support for asynchronous long-running operations
  • google.cloud: Cloud-specific extensions for location services and operations
  • google.gapic: Client generation metadata for automatic library creation
  • google.logging: Logging-specific types for structured log entries and severity levels

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.

Capabilities

API Framework Types

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 = 7

API Framework Types

RPC Status and Error Handling

Standard 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: Duration

RPC Status and Error Handling

Common Data Types

Fundamental 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]

Common Data Types

Long-Running Operations

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: str

Long-Running Operations

Monitoring and Observability

Types 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]

Monitoring and Observability

Cloud Services Integration

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: str

Cloud Services Integration

Logging Framework

Types 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: str

Type System

All protobuf message classes provide:

  • Type Safety: Full typing support with .pyi stub files
  • Field Access: Direct attribute access with validation
  • Serialization: Standard protobuf serialization/deserialization
  • Memory Efficiency: __slots__ optimization for all classes
  • Field Numbers: FIELD_NUMBER constants for each field
  • Nested Types: Support for nested messages and enums
  • Optional Fields: Constructor parameters are optional by default
  • Container Types: Specialized containers for repeated fields and maps