public static ExceptionData from( int code, String message, String reason, boolean retryable, Throwable cause) { return newBuilder() .setCode(code) .setMessage(message) .setReason(reason) .setRetryable(retryable) .setCause(cause) .build(); }
public static ExceptionHandler build() { return ExceptionHandler.newBuilder() .abortOn(RuntimeException.class) .addInterceptors( DatastoreImpl.EXCEPTION_HANDLER_INTERCEPTOR, TRANSACTION_EXCEPTION_HANDLER_INTERCEPTOR) .build(); }
/** Creates a {@code MonitoredResource} object given the resource's type and labels. */ public static MonitoredResource of(String type, Map<String, String> labels) { return newBuilder(type).setLabels(labels).build(); }
static Policy convertFromApiPolicy(com.google.api.services.storage.model.Policy apiPolicy) { Policy.Builder policyBuilder = Policy.newBuilder(); for (Bindings binding : apiPolicy.getBindings()) { for (String member : binding.getMembers()) { policyBuilder.addIdentity(Role.of(binding.getRole()), Identity.valueOf(member)); } } return policyBuilder.setEtag(apiPolicy.getEtag()).build(); }
public CustomServiceException(int code, String message, String reason, boolean idempotent) { super( ExceptionData.from( code, message, reason, BaseServiceException.isRetryable(code, reason, idempotent, RETRYABLE_ERRORS))); }
@Test public void testToAndFromPb() { compareResourceDescriptor( RESOURCE_DESCRIPTOR, MonitoredResourceDescriptor.fromPb(RESOURCE_DESCRIPTOR.toPb())); MonitoredResourceDescriptor resourceDescriptor = MonitoredResourceDescriptor.newBuilder(TYPE).build(); compareResourceDescriptor( resourceDescriptor, MonitoredResourceDescriptor.fromPb(resourceDescriptor.toPb())); }
/** Return the known values for LegacySQLTypeName. */ public static LegacySQLTypeName[] values() { return type.values(); } }
/** * Get the Type for the given String constant, and throw an exception if the constant is not * recognized. */ public static Type valueOfStrict(String constant) { return type.valueOfStrict(constant); }
@Override public void close() throws IOException { synchronized (this) { channel.close(); } }
/** * Returns the editor role. Encapsulates all viewer's permissions and permissions for actions that * modify the state of a resource. * * @see <a href="https://cloud.google.com/iam/docs/understanding-roles">Understanding Roles</a> */ public static Role editor() { return of("editor"); }
@Override public void close() throws IOException { synchronized (this) { channel.close(); } }
/** Sets a result and status as completed. Notifies all callbacks. */ protected void success(T result) { this.result = result; this.completed = true; for (Callback<T, E> callback : toBeNotified) { callback.success(result); } }
@Override public Identity apply(String identityPb) { return Identity.valueOf(identityPb); } };
@Override public LabelDescriptor apply(com.google.api.LabelDescriptor descriptorPb) { return fromPb(descriptorPb); } };
/** * Sets the project ID. If no project ID is set, {@link #getDefaultProjectId()} will be used to * attempt getting the project ID from the environment. * * @return the builder */ public B setProjectId(String projectId) { this.projectId = projectId; return self(); }
@Override public Letter apply(String constant) { return new Letter(constant); } };
/** Return the known values for Operator. */ static Operator[] values() { return type.values(); } }
/** * Get the Operator for the given String constant, and throw an exception if the constant is * not recognized. */ static Operator valueOfStrict(String constant) { return type.valueOfStrict(constant); }
/** * Returns the owner role. Encapsulates all editor's permissions and permissions to manage access * control for a resource or manage the billing options for a project. * * @see <a href="https://cloud.google.com/iam/docs/understanding-roles">Understanding Roles</a> */ public static Role owner() { return of("owner"); }
/** * Sets configuration parameters for request retries. * * @return the builder */ public B setRetrySettings(RetrySettings retrySettings) { this.retrySettings = retrySettings; return self(); }