Package com.google.cloud
Class ServiceOptions<ServiceT extends Service<OptionsT>,OptionsT extends ServiceOptions<ServiceT,OptionsT>>
java.lang.Object
com.google.cloud.ServiceOptions<ServiceT,OptionsT>
- Type Parameters:
ServiceT- the service subclassOptionsT- theServiceOptionssubclass corresponding to the service
- All Implemented Interfaces:
Serializable
public abstract class ServiceOptions<ServiceT extends Service<OptionsT>,OptionsT extends ServiceOptions<ServiceT,OptionsT>>
extends Object
implements Serializable
Abstract class representing service options.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classServiceOptions.Builder<ServiceT extends Service<OptionsT>,OptionsT extends ServiceOptions<ServiceT, OptionsT>, B extends ServiceOptions.Builder<ServiceT, OptionsT, B>> Builder forServiceOptions. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedServiceOptions(Class<? extends ServiceFactory<ServiceT, OptionsT>> serviceFactoryClass, Class<? extends ServiceRpcFactory<OptionsT>> rpcFactoryClass, ServiceOptions.Builder<ServiceT, OptionsT, ?> builder, ServiceDefaults<ServiceT, OptionsT> serviceDefaults) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbaseEquals(ServiceOptions<?, ?> other) protected intprotected RetrySettingsSome services may have different backoff requirements listed in their SLAs.static Stringprotected static Stringprotected static StringReturns the application's name as a string in the formatgcloud-java/[version], optionally prepended with externally supplied User-Agent header value (via setting custom header provider).getClock()Returns the service's clock.com.google.auth.CredentialsReturns the authentication credentials.protected Stringprotected Stringstatic StringReturns the default project ID, ornullif no default project ID could be found.static RetrySettingsstatic <T> TgetFromServiceLoader(Class<? extends T> clazz, T defaultInstance) static StringReturns the library's name used by x-goog-api-client header as a string.protected static StringgetHost()Returns the service host.static StringReturns the library's name,gcloud-java, as a string.Returns the library's version as a string.final HeaderProvidergetMergedHeaderProvider(HeaderProvider internalHeaderProvider) static RetrySettingsReturns the project ID.Returns the quotaProjectId that specifies the project used for quota and billing purposes.getResolvedApiaryHost(String serviceName) Returns a host value to be used for BigQuery and Storage Apiary Wrapped Libraries.getResolvedHost(String serviceName) Returns the resolved host for the Service to connect to Google CloudReturns configuration parameters for request retries.getRpc()Returns a Service RPC object for the current service.com.google.auth.CredentialsReturns the authentication credentials.Returns a Service object for the current service.protected static StringReturns the transport-specific options for this service.Universe Domain is the domain for Google Cloud Services.final StringbooleanValidates that Credentials' Universe Domain matches the resolved Universe Domain.static <T> TnewInstance(String className) protected booleanReturns whether a service requires a project ID.protected booleanshouldRefreshRpc(ServiceRpc cachedRpc) protected booleanshouldRefreshService(ServiceT cachedService) abstract <B extends ServiceOptions.Builder<ServiceT,OptionsT, B>>
B
-
Field Details
-
CREDENTIAL_ENV_NAME
- See Also:
-
clientLibToken
-
credentials
protected com.google.auth.Credentials credentials
-
-
Constructor Details
-
ServiceOptions
@InternalApi("This class should only be extended within google-cloud-java") protected ServiceOptions(Class<? extends ServiceFactory<ServiceT, OptionsT>> serviceFactoryClass, Class<? extends ServiceRpcFactory<OptionsT>> rpcFactoryClass, ServiceOptions.Builder<ServiceT, OptionsT, ?> builder, ServiceDefaults<ServiceT, OptionsT> serviceDefaults)
-
-
Method Details
-
projectIdRequired
protected boolean projectIdRequired()Returns whether a service requires a project ID. This method may be overridden in service-specific Options objects.- Returns:
- true if a project ID is required to use the service, false if not
-
getDefaultHost
-
getDefaultProject
-
getDefaultProjectId
Returns the default project ID, ornullif no default project ID could be found. This method returns the first available project ID among the following sources:- The project ID specified by the GOOGLE_CLOUD_PROJECT environment variable
- The App Engine project ID
- The project ID specified in the JSON credentials file pointed by the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable - The Google Cloud SDK project ID
- The Compute Engine project ID
-
getAppEngineAppId
-
getGoogleCloudProjectId
-
getAppEngineProjectId
-
getAppEngineProjectIdFromAppId
-
getServiceAccountProjectId
-
getService
Returns a Service object for the current service. For instance, when using Google Cloud Storage, it returns a Storage object. -
shouldRefreshService
- Parameters:
cachedService- The currently cached service object- Returns:
- true if the currently cached service object should be refreshed.
-
getRpc
Returns a Service RPC object for the current service. For instance, when using Google Cloud Storage, it returns a StorageRpc object. -
shouldRefreshRpc
- Parameters:
cachedRpc- The currently cached service object- Returns:
- true if the currently cached service object should be refreshed.
-
getProjectId
Returns the project ID. Return value can be null (for services that don't require a project ID). -
getUniverseDomain
Universe Domain is the domain for Google Cloud Services. A Google Cloud endpoint follows the format of `{ServiceName}.{UniverseDomain}`. For example, speech.googleapis.com would have a Universe Domain value of `googleapis.com` and cloudasset.test.com would have a Universe Domain of `test.com`.- Returns:
- The universe domain value set in the Builder's setter. This is not the resolved Universe Domain
-
getHost
Returns the service host. -
getCredentials
public com.google.auth.Credentials getCredentials()Returns the authentication credentials. -
getScopedCredentials
public com.google.auth.Credentials getScopedCredentials()Returns the authentication credentials. If required, credentials are scoped. -
getRetrySettings
Returns configuration parameters for request retries. -
getClock
Returns the service's clock. Default time source usesSystem.currentTimeMillis()to get current time. -
getTransportOptions
Returns the transport-specific options for this service. -
getApplicationName
Returns the application's name as a string in the formatgcloud-java/[version], optionally prepended with externally supplied User-Agent header value (via setting custom header provider). -
getLibraryName
Returns the library's name,gcloud-java, as a string. -
getGoogApiClientLibName
Returns the library's name used by x-goog-api-client header as a string. -
getLibraryVersion
Returns the library's version as a string. -
getApiTracerFactory
-
getMergedHeaderProvider
@InternalApi public final HeaderProvider getMergedHeaderProvider(HeaderProvider internalHeaderProvider) -
getUserAgent
-
baseHashCode
protected int baseHashCode() -
baseEquals
-
newInstance
@InternalApi public static <T> T newInstance(String className) throws IOException, ClassNotFoundException - Throws:
IOExceptionClassNotFoundException
-
getDefaultRetrySettings
-
getNoRetrySettings
-
getScopes
-
toBuilder
-
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 inRetrySettings. -
getFromServiceLoader
-
getClientLibToken
-
getQuotaProjectId
Returns the quotaProjectId that specifies the project used for quota and billing purposes. -
getResolvedHost
Returns the resolved host for the Service to connect to Google CloudThe resolved host will be in `https://{serviceName}.{resolvedUniverseDomain}` format. The resolvedUniverseDomain will be set to `googleapis.com` if universeDomain is null. The format is similar to the DEFAULT_HOST value in java-core.
- See Also:
-
getResolvedApiaryHost
Returns a host value to be used for BigQuery and Storage Apiary Wrapped Libraries. To be removed in the future when Apiary clients can resolve their endpoints. Returns the host to be used as the rootUrl.The resolved host will be in `https://{serviceName}.{resolvedUniverseDomain}/` format. The resolvedUniverseDomain will be set to `googleapis.com` if universeDomain is null.
The host value is set to DEFAULT_HOST if the user didn't configure a host. Returns the host value the user set, otherwise constructs the host for the user.
- See Also:
-
hasValidUniverseDomain
Validates that Credentials' Universe Domain matches the resolved Universe Domain. Currently, this is only intended for BigQuery and Storage Apiary Wrapped Libraries.This validation call should be made prior to any RPC invocation. This call is used to gate the RPC invocation if there is no valid universe domain.
- Throws:
IOException
-