Java Protocol Buffer classes for Google's common protos, providing type-safe access to core Google Cloud API structures and gRPC service definitions
npx @tessl/cli install tessl/maven-com-google-api-grpc--proto-google-common-protos@2.58.0Protocol Buffer classes for Google's common protos, providing Java implementations of standardized message types and service definitions used across Google APIs and services. This library enables type-safe access to core Google Cloud API structures, gRPC service definitions, and common data types.
implementation 'com.google.api.grpc:proto-google-common-protos:2.57.0'import com.google.api.Http;
import com.google.api.HttpRule;
import com.google.rpc.Status;
import com.google.rpc.Code;
import com.google.type.Money;
import com.google.type.Date;
import com.google.longrunning.Operation;// Working with HTTP rules for REST API mapping
HttpRule rule = HttpRule.newBuilder()
.setGet("/api/v1/users/{user_id}")
.build();
// Creating error status responses
Status errorStatus = Status.newBuilder()
.setCode(Code.INVALID_ARGUMENT.getNumber())
.setMessage("Invalid user ID provided")
.build();
// Working with monetary values
Money price = Money.newBuilder()
.setCurrencyCode("USD")
.setUnits(29)
.setNanos(990000000) // $29.99
.build();
// Handling long-running operations
Operation operation = Operation.newBuilder()
.setName("operations/my-operation-id")
.setDone(false)
.build();Proto Google Common Protos is structured around Protocol Buffer message definitions organized into functional packages:
com.google.api): Service configuration, HTTP mappings, authentication, and API annotationscom.google.rpc, com.google.rpc.context): Standard error handling, status codes, and context information for gRPC servicescom.google.type): Reusable types like Money, Date, Color, and geographic coordinatescom.google.longrunning): Support for asynchronous operations with status trackingcom.google.cloud): Cloud platform audit logging and location servicescom.google.apps): Google Apps Card UI components and interactionscom.google.geo.type): Viewport and geographic data structurescom.google.logging.type): HTTP request logging and severity levelscom.google.shopping.type): E-commerce related data types like Channel, Price, WeightAll classes follow Protocol Buffer Java conventions with message classes, OrBuilder interfaces, and Proto descriptor classes providing type-safe access to structured data.
Core service configuration including HTTP mappings, authentication rules, quota management, and API annotations. Essential for defining gRPC services with REST endpoints.
class Service {
String getName();
repeated Api getApisList();
Http getHttp();
Authentication getAuthentication();
Quota getQuota();
Documentation getDocumentation();
// Additional configuration methods
}
class Http {
repeated HttpRule getRulesList();
boolean getFullyDecodeReservedExpansion();
}
class HttpRule {
String getSelector();
String getGet();
String getPost();
String getPut();
String getDelete();
String getPatch();
HttpRule getCustom();
String getBody();
String getResponseBody();
repeated HttpRule getAdditionalBindingsList();
}Standard error model and status codes for consistent error handling across gRPC services. Includes structured error details and context information.
class Status {
int getCode();
String getMessage();
repeated Any getDetailsList();
static Status.Builder newBuilder();
Status.Builder toBuilder();
}
enum Code {
OK(0),
CANCELLED(1),
UNKNOWN(2),
INVALID_ARGUMENT(3),
DEADLINE_EXCEEDED(4),
NOT_FOUND(5),
ALREADY_EXISTS(6),
PERMISSION_DENIED(7),
RESOURCE_EXHAUSTED(8),
FAILED_PRECONDITION(9),
ABORTED(10),
OUT_OF_RANGE(11),
UNIMPLEMENTED(12),
INTERNAL(13),
UNAVAILABLE(14),
DATA_LOSS(15),
UNAUTHENTICATED(16);
}Standard data types for representing time, money, geographic coordinates, and other common concepts across Google APIs.
class Money {
String getCurrencyCode();
long getUnits();
int getNanos();
static Money.Builder newBuilder();
}
class Date {
int getYear();
int getMonth();
int getDay();
static Date.Builder newBuilder();
}
class LatLng {
double getLatitude();
double getLongitude();
static LatLng.Builder newBuilder();
}
class TimeOfDay {
int getHours();
int getMinutes();
int getSeconds();
int getNanos();
}Support for asynchronous operations that don't complete immediately, providing status tracking, cancellation, and result retrieval.
class Operation {
String getName();
Any getMetadata();
boolean getDone();
Status getError();
Any getResponse();
static Operation.Builder newBuilder();
}
class GetOperationRequest {
String getName();
static GetOperationRequest.Builder newBuilder();
}
class ListOperationsRequest {
String getName();
String getFilter();
int getPageSize();
String getPageToken();
static ListOperationsRequest.Builder newBuilder();
}Cloud-specific types for audit logging, location services, and platform integration.
class AuditLog {
String getServiceName();
String getMethodName();
String getResourceName();
AuthenticationInfo getAuthenticationInfo();
repeated AuthorizationInfo getAuthorizationInfoList();
RequestMetadata getRequestMetadata();
Struct getRequest();
Struct getResponse();
Status getStatus();
}
class Location {
String getName();
String getLocationId();
String getDisplayName();
Struct getLabels();
Any getMetadata();
}UI components and interactions for building cards in Google Workspace applications.
class Card {
repeated Section getSectionsList();
CardHeader getHeader();
String getName();
CardFixedFooter getFixedFooter();
DisplayStyle getDisplayStyle();
static Card.Builder newBuilder();
}
class Widget {
TextParagraph getTextParagraph();
Image getImage();
DecoratedText getDecoratedText();
ButtonList getButtonList();
TextInput getTextInput();
SelectionInput getSelectionInput();
DateTimePicker getDateTimePicker();
Divider getDivider();
Grid getGrid();
Columns getColumns();
}All message classes provide builder patterns for construction:
// Create a new message
Status status = Status.newBuilder()
.setCode(Code.NOT_FOUND.getNumber())
.setMessage("Resource not found")
.build();
// Modify existing message
Status updatedStatus = status.toBuilder()
.setMessage("Updated message")
.build();All message classes implement corresponding OrBuilder interfaces for read access during construction:
public interface StatusOrBuilder extends MessageOrBuilder {
int getCode();
String getMessage();
java.util.List<com.google.protobuf.Any> getDetailsList();
// Additional getter methods
}Standard Protocol Buffer serialization methods:
// Serialize to bytes
byte[] bytes = status.toByteArray();
// Parse from bytes
Status parsed = Status.parseFrom(bytes);
// JSON serialization (requires JsonFormat)
String json = JsonFormat.printer().print(status);
Status fromJson = Status.newBuilder();
JsonFormat.parser().merge(json, fromJson);Common patterns for working with status and error information:
// Check operation result
if (operation.getDone()) {
if (operation.hasError()) {
Status error = operation.getError();
Code code = Code.forNumber(error.getCode());
System.err.println("Operation failed: " + error.getMessage());
} else {
// Operation completed successfully
Any response = operation.getResponse();
// Process response
}
} else {
// Operation still in progress
System.out.println("Operation pending: " + operation.getName());
}This library requires:
com.google.protobuf:protobuf-java - Core Protocol Buffers runtimeCommonly used with: