Java Protocol Buffer classes for Google's common protos, providing type-safe access to core Google Cloud API structures and gRPC service definitions
—
Cloud-specific types for audit logging, location services, policy violations, and platform integration. These types are essential for Google Cloud Platform services and enterprise audit requirements.
Cloud audit log entry containing comprehensive information about API calls and resource access.
class AuditLog {
String getServiceName(); // Service that processed the request
String getMethodName(); // Method that was called
String getResourceName(); // Resource that was accessed
String getResourceLocation(); // Location of the resource
String getResourceOriginalState(); // Resource state before operation
AuthenticationInfo getAuthenticationInfo();
repeated AuthorizationInfo getAuthorizationInfoList();
RequestMetadata getRequestMetadata();
Struct getRequest(); // Request message
Struct getResponse(); // Response message
Status getStatus(); // Operation status
int getNumResponseItems(); // Number of items in response
repeated ServiceAccountDelegationInfo getServiceAccountDelegationInfoList();
static AuditLog.Builder newBuilder();
}Authentication details for the principal making the request.
class AuthenticationInfo {
String getPrincipalEmail(); // Email of authenticated user
String getAuthoritySelector(); // Authority that authenticated
Struct getThirdPartyPrincipal(); // Third-party identity provider info
String getServiceAccountKeyName(); // Service account key used
repeated ServiceAccountDelegationInfo getServiceAccountDelegationInfoList();
String getPrincipalSubject(); // Subject from authentication token
static AuthenticationInfo.Builder newBuilder();
}Authorization details for each permission checked.
class AuthorizationInfo {
String getResource(); // Resource being accessed
String getPermission(); // Permission being checked
boolean getGranted(); // Whether permission was granted
AttributeContext getResourceAttributes(); // Resource attributes
static AuthorizationInfo.Builder newBuilder();
}Metadata about the request itself.
class RequestMetadata {
String getCallerIp(); // IP address of caller
String getCallerSuppliedUserAgent(); // User agent string
String getCallerNetwork(); // Network caller is on
Struct getDestinationAttributes(); // Destination service attributes
repeated AttributeContext.Request getRequestAttributesList();
static RequestMetadata.Builder newBuilder();
}Information about service account delegation.
class ServiceAccountDelegationInfo {
String getFirstPartyPrincipal(); // First party principal
Struct getThirdPartyPrincipal(); // Third party principal
static ServiceAccountDelegationInfo.Builder newBuilder();
}Represents a Google Cloud resource location.
class Location {
String getName(); // Full resource name
String getLocationId(); // Location identifier (e.g., "us-central1")
String getDisplayName(); // Human-readable name
Struct getLabels(); // Labels associated with location
Any getMetadata(); // Location-specific metadata
static Location.Builder newBuilder();
}Request to list available locations.
class ListLocationsRequest {
String getName(); // Parent resource name
String getFilter(); // Optional filter expression
int getPageSize(); // Maximum locations to return
String getPageToken(); // Pagination token
static ListLocationsRequest.Builder newBuilder();
}Response containing available locations.
class ListLocationsResponse {
repeated Location getLocationsList();
String getNextPageToken(); // Token for next page
static ListLocationsResponse.Builder newBuilder();
int getLocationsCount();
Location getLocations(int index);
}Request to get information about a specific location.
class GetLocationRequest {
String getName(); // Location resource name
static GetLocationRequest.Builder newBuilder();
}Information about policy violations.
class PolicyViolationInfo {
OrgPolicyViolationInfo getOrgPolicyViolationInfo();
static PolicyViolationInfo.Builder newBuilder();
boolean hasOrgPolicyViolationInfo();
}Specific information about organization policy violations.
class OrgPolicyViolationInfo {
Struct getPayload(); // Violation details
repeated String getResourceTagsList(); // Resource tags involved
String getResourceType(); // Type of resource
repeated ViolationInfo getViolationInfoList();
static OrgPolicyViolationInfo.Builder newBuilder();
}General violation information.
class ViolationInfo {
String getConstraint(); // Constraint that was violated
String getErrorMessage(); // Error message
CheckedValue getCheckedValue(); // Value that was checked
PolicyType getPolicyType(); // Type of policy
static ViolationInfo.Builder newBuilder();
}
enum PolicyType {
POLICY_TYPE_UNSPECIFIED(0),
BOOLEAN_POLICY(1),
LIST_POLICY(2),
RESTORE_POLICY(3);
int getNumber();
static PolicyType forNumber(int value);
}Extended operation information for cloud operations.
class ExtendedOperation {
UInt64Value getId(); // Operation ID
String getName(); // Operation name
Status getStatus(); // Current status
String getStatusMessage(); // Status message
String getUser(); // User who initiated
UInt64Value getProgress(); // Progress percentage
Timestamp getInsertTime(); // When operation started
Timestamp getStartTime(); // When execution began
Timestamp getEndTime(); // When operation completed
repeated ExtendedOperation.Error getErrorsList();
repeated ExtendedOperation.Warning getWarningsList();
UInt64Value getHttpErrorStatusCode(); // HTTP status code
String getHttpErrorMessage(); // HTTP error message
String getSelfLink(); // Link to operation resource
String getRegion(); // Region where operation runs
String getDescription(); // Operation description
String getOperationType(); // Type of operation
String getTargetLink(); // Link to target resource
UInt64Value getTargetId(); // Target resource ID
String getClientOperationId(); // Client-specified operation ID
static ExtendedOperation.Builder newBuilder();
}
class ExtendedOperation.Error {
String getCode(); // Error code
String getMessage(); // Error message
repeated ExtendedOperation.Error.ErrorDetail getErrorDetailsList();
static Error.Builder newBuilder();
}
class ExtendedOperation.Warning {
String getCode(); // Warning code
String getMessage(); // Warning message
repeated ExtendedOperation.Warning.WarningDataItem getDataList();
static Warning.Builder newBuilder();
}Maps operation response fields for different operation types.
enum OperationResponseMapping {
UNDEFINED(0),
NAME(1),
STATUS(2),
ERROR_CODE(3),
ERROR_MESSAGE(4);
int getNumber();
static OperationResponseMapping forNumber(int value);
}import com.google.cloud.audit.AuditLog;
import com.google.cloud.audit.AuthenticationInfo;
import com.google.cloud.audit.AuthorizationInfo;
public void processAuditLog(AuditLog auditLog) {
System.out.println("Service: " + auditLog.getServiceName());
System.out.println("Method: " + auditLog.getMethodName());
System.out.println("Resource: " + auditLog.getResourceName());
// Process authentication info
if (auditLog.hasAuthenticationInfo()) {
AuthenticationInfo authInfo = auditLog.getAuthenticationInfo();
System.out.println("Principal: " + authInfo.getPrincipalEmail());
}
// Process authorization info
for (AuthorizationInfo authzInfo : auditLog.getAuthorizationInfoList()) {
System.out.printf("Permission %s on %s: %s\n",
authzInfo.getPermission(),
authzInfo.getResource(),
authzInfo.getGranted() ? "GRANTED" : "DENIED");
}
// Check operation status
if (auditLog.hasStatus()) {
Status status = auditLog.getStatus();
if (status.getCode() != 0) {
System.err.println("Operation failed: " + status.getMessage());
}
}
}import com.google.cloud.location.Location;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
public void listAvailableRegions(String projectName) {
ListLocationsRequest request = ListLocationsRequest.newBuilder()
.setName(projectName)
.setPageSize(100)
.build();
ListLocationsResponse response = locationsClient.listLocations(request);
System.out.println("Available regions:");
for (Location location : response.getLocationsList()) {
System.out.printf("- %s (%s): %s\n",
location.getLocationId(),
location.getDisplayName(),
location.getName());
// Print labels if available
if (location.hasLabels()) {
Struct labels = location.getLabels();
System.out.println(" Labels: " + labels.toString());
}
}
}import com.google.cloud.audit.PolicyViolationInfo;
import com.google.cloud.audit.OrgPolicyViolationInfo;
import com.google.cloud.audit.ViolationInfo;
public void handlePolicyViolations(PolicyViolationInfo policyViolationInfo) {
if (policyViolationInfo.hasOrgPolicyViolationInfo()) {
OrgPolicyViolationInfo orgViolation = policyViolationInfo.getOrgPolicyViolationInfo();
System.out.println("Organization policy violation:");
System.out.println("Resource type: " + orgViolation.getResourceType());
for (String resourceTag : orgViolation.getResourceTagsList()) {
System.out.println("Resource tag: " + resourceTag);
}
for (ViolationInfo violation : orgViolation.getViolationInfoList()) {
System.out.printf("Constraint '%s' violated: %s\n",
violation.getConstraint(),
violation.getErrorMessage());
System.out.println("Policy type: " + violation.getPolicyType());
}
}
}import com.google.cloud.extended.operations.ExtendedOperation;
public void monitorExtendedOperation(ExtendedOperation operation) {
System.out.println("Operation: " + operation.getName());
System.out.println("Status: " + operation.getStatus());
System.out.println("Type: " + operation.getOperationType());
if (operation.hasProgress()) {
System.out.println("Progress: " + operation.getProgress().getValue() + "%");
}
if (operation.hasUser()) {
System.out.println("User: " + operation.getUser());
}
// Show timing information
if (operation.hasInsertTime()) {
System.out.println("Started: " + operation.getInsertTime());
}
if (operation.hasEndTime()) {
System.out.println("Completed: " + operation.getEndTime());
}
// Handle errors
if (!operation.getErrorsList().isEmpty()) {
System.err.println("Errors:");
for (ExtendedOperation.Error error : operation.getErrorsList()) {
System.err.println("- " + error.getCode() + ": " + error.getMessage());
}
}
// Handle warnings
if (!operation.getWarningsList().isEmpty()) {
System.out.println("Warnings:");
for (ExtendedOperation.Warning warning : operation.getWarningsList()) {
System.out.println("- " + warning.getCode() + ": " + warning.getMessage());
}
}
}public AuditLog createAuditLog(String serviceName, String methodName,
String resourceName, String principalEmail,
boolean success) {
AuthenticationInfo authInfo = AuthenticationInfo.newBuilder()
.setPrincipalEmail(principalEmail)
.build();
RequestMetadata requestMetadata = RequestMetadata.newBuilder()
.setCallerIp("192.168.1.100")
.setCallerSuppliedUserAgent("MyApp/1.0")
.build();
Status status = Status.newBuilder()
.setCode(success ? Code.OK.getNumber() : Code.INTERNAL.getNumber())
.setMessage(success ? "Success" : "Operation failed")
.build();
return AuditLog.newBuilder()
.setServiceName(serviceName)
.setMethodName(methodName)
.setResourceName(resourceName)
.setAuthenticationInfo(authInfo)
.setRequestMetadata(requestMetadata)
.setStatus(status)
.build();
}Install with Tessl CLI
npx tessl i tessl/maven-com-google-api-grpc--proto-google-common-protos