Class ServiceOptions<ServiceT,OptionsT> (2.59.0)

public abstract class ServiceOptions<ServiceT,OptionsT> implements Serializable

Abstract class representing service options.

Inheritance

java.lang.Object > ServiceOptions<ServiceT,OptionsT>

Implements

Serializable

Type Parameters

Name Description
ServiceT
OptionsT

Static Fields

CREDENTIAL_ENV_NAME

public static final String CREDENTIAL_ENV_NAME
Field Value
Type Description
String

Static Methods

<T>getFromServiceLoader(Class<? extends T> clazz, T defaultInstance)

public static T <T>getFromServiceLoader(Class<? extends T> clazz, T defaultInstance)
Parameters
Name Description
clazz Class<? extends T>
defaultInstance T
Returns
Type Description
T

<T>newInstance(String className)

public static T <T>newInstance(String className)
Parameter
Name Description
className String
Returns
Type Description
T
Exceptions
Type Description
IOException
ClassNotFoundException

getAppEngineAppId()

public static String getAppEngineAppId()
Returns
Type Description
String

getAppEngineProjectId()

protected static String getAppEngineProjectId()
Returns
Type Description
String

getAppEngineProjectIdFromAppId()

protected static String getAppEngineProjectIdFromAppId()
Returns
Type Description
String

getDefaultProjectId()

public static String getDefaultProjectId()

Returns the default project ID, or null if no default project ID could be found. This method returns the first available project ID among the following sources:

  1. The project ID specified by the GOOGLE_CLOUD_PROJECT environment variable
  2. The App Engine project ID
  3. The project ID specified in the JSON credentials file pointed by the GOOGLE_APPLICATION_CREDENTIALS environment variable
  4. The Google Cloud SDK project ID
  5. The Compute Engine project ID
Returns
Type Description
String

getDefaultRetrySettings()

public static RetrySettings getDefaultRetrySettings()
Returns
Type Description
RetrySettings

getGoogApiClientLibName()

public static String getGoogApiClientLibName()

Returns the library's name used by x-goog-api-client header as a string.

Returns
Type Description
String

getGoogleCloudProjectId()

protected static String getGoogleCloudProjectId()
Returns
Type Description
String

getLibraryName()

public static String getLibraryName()

Returns the library's name, gcloud-java, as a string.

Returns
Type Description
String

getNoRetrySettings()

public static RetrySettings getNoRetrySettings()
Returns
Type Description
RetrySettings

getServiceAccountProjectId()

protected static String getServiceAccountProjectId()
Returns
Type Description
String

Constructors

ServiceOptions(Class<? extends ServiceFactory<ServiceT,OptionsT>> serviceFactoryClass, Class<? extends ServiceRpcFactory<OptionsT>> rpcFactoryClass, ServiceOptions.Builder<ServiceT,OptionsT,?> builder, ServiceDefaults<ServiceT,OptionsT> serviceDefaults)

protected ServiceOptions(Class<? extends ServiceFactory<ServiceT,OptionsT>> serviceFactoryClass, Class<? extends ServiceRpcFactory<OptionsT>> rpcFactoryClass, ServiceOptions.Builder<ServiceT,OptionsT,?> builder, ServiceDefaults<ServiceT,OptionsT> serviceDefaults)
Parameters
Name Description
serviceFactoryClass Class<? extends com.google.cloud.ServiceFactory<ServiceT,OptionsT>>
rpcFactoryClass Class<? extends com.google.cloud.spi.ServiceRpcFactory<OptionsT>>
builder Builder<ServiceT,OptionsT,?>
serviceDefaults ServiceDefaults<ServiceT,OptionsT>

Fields

clientLibToken

protected final String clientLibToken
Field Value
Type Description
String

credentials

protected Credentials credentials
Field Value
Type Description
com.google.auth.Credentials

Methods

<B>toBuilder()

public abstract B <B>toBuilder()
Returns
Type Description
B

baseEquals(ServiceOptions<?,?> other)

protected boolean baseEquals(ServiceOptions<?,?> other)
Parameter
Name Description
other ServiceOptions<?,?>
Returns
Type Description
boolean

baseHashCode()

protected int baseHashCode()
Returns
Type Description
int

defaultRetrySettings()

protected RetrySettings defaultRetrySettings()

Some services may have different backoff requirements listed in their SLAs. Be sure to override this method in options subclasses when the service's backoff requirement differs from the default parameters listed in RetrySettings.

Returns
Type Description
RetrySettings

getApiTracerFactory()

public ApiTracerFactory getApiTracerFactory()
Returns
Type Description
ApiTracerFactory

getApplicationName()

public String getApplicationName()

Returns the application's name as a string in the format gcloud-java/[version], optionally prepended with externally supplied User-Agent header value (via setting custom header provider).

Returns
Type Description
String

getClientLibToken()

public String getClientLibToken()
Returns
Type Description
String

getClock()

public ApiClock getClock()

Returns the service's clock. Default time source uses System#currentTimeMillis() to get current time.

Returns
Type Description
ApiClock

getCredentials()

public Credentials getCredentials()

Returns the authentication credentials.

Returns
Type Description
com.google.auth.Credentials

getDefaultHost()

protected String getDefaultHost()
Returns
Type Description
String

getDefaultProject()

protected String getDefaultProject()
Returns
Type Description
String

getHost()

public String getHost()

Returns the service host.

Returns
Type Description
String

getLibraryVersion()

public String getLibraryVersion()

Returns the library's version as a string.

Returns
Type Description
String

getMergedHeaderProvider(HeaderProvider internalHeaderProvider)

public final HeaderProvider getMergedHeaderProvider(HeaderProvider internalHeaderProvider)
Parameter
Name Description
internalHeaderProvider HeaderProvider
Returns
Type Description