Package com.google.cloud
Class ServiceOptions.Builder<ServiceT extends Service<OptionsT>,OptionsT extends ServiceOptions<ServiceT,OptionsT>,B extends ServiceOptions.Builder<ServiceT,OptionsT,B>>
- java.lang.Object
-
- com.google.cloud.ServiceOptions.Builder<ServiceT,OptionsT,B>
-
- Type Parameters:
ServiceT
- the service subclassOptionsT
- theServiceOptions
subclass corresponding to the serviceB
- theServiceOptions
builder
- Enclosing class:
- ServiceOptions<ServiceT extends Service<OptionsT>,OptionsT extends ServiceOptions<ServiceT,OptionsT>>
public abstract static class ServiceOptions.Builder<ServiceT extends Service<OptionsT>,OptionsT extends ServiceOptions<ServiceT,OptionsT>,B extends ServiceOptions.Builder<ServiceT,OptionsT,B>> extends Object
Builder forServiceOptions
.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.google.auth.Credentials
credentials
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder()
protected
Builder(ServiceOptions<ServiceT,OptionsT> options)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ServiceOptions<ServiceT,OptionsT>
build()
protected Set<String>
getAllowedClientLibTokens()
protected B
self()
B
setClientLibToken(String clientLibToken)
B
setClock(com.google.api.core.ApiClock clock)
Sets the service's clock.B
setCredentials(com.google.auth.Credentials credentials)
Sets the service authentication credentials.B
setHeaderProvider(com.google.api.gax.rpc.HeaderProvider headerProvider)
Sets the static header provider.B
setHost(String host)
Sets service host.B
setProjectId(String projectId)
Sets the project ID.B
setQuotaProjectId(String quotaProjectId)
Sets the quotaProjectId that specifies the project used for quota and billing purposes.B
setRetrySettings(com.google.api.gax.retrying.RetrySettings retrySettings)
Sets configuration parameters for request retries.B
setServiceFactory(ServiceFactory<ServiceT,OptionsT> serviceFactory)
Sets the service factory.B
setServiceRpcFactory(ServiceRpcFactory<OptionsT> serviceRpcFactory)
Sets the factory for rpc services.B
setTransportOptions(TransportOptions transportOptions)
Sets the transport options.
-
-
-
Constructor Detail
-
Builder
@InternalApi("This class should only be extended within google-cloud-java") protected Builder()
-
Builder
@InternalApi("This class should only be extended within google-cloud-java") protected Builder(ServiceOptions<ServiceT,OptionsT> options)
-
-
Method Detail
-
build
protected abstract ServiceOptions<ServiceT,OptionsT> build()
-
self
protected B self()
-
setServiceFactory
public B setServiceFactory(ServiceFactory<ServiceT,OptionsT> serviceFactory)
Sets the service factory.
-
setClock
public B setClock(com.google.api.core.ApiClock clock)
Sets the service's clock. The clock is mainly used for testing purpose.ApiClock
will be replaced by Java8'sjava.time.Clock
.- Parameters:
clock
- the clock to set- Returns:
- the builder
-
setProjectId
public B setProjectId(String projectId)
Sets the project ID. If no project ID is set,ServiceOptions.getDefaultProjectId()
will be used to attempt getting the project ID from the environment.- Returns:
- the builder
-
setCredentials
public B setCredentials(com.google.auth.Credentials credentials)
Sets the service authentication credentials. If no credentials are set,GoogleCredentials.getApplicationDefault()
will be used to attempt getting credentials from the environment. UseNoCredentials.getInstance()
to skip authentication, this is typically useful when using local service emulators.- Parameters:
credentials
- authentication credentials, should not benull
- Returns:
- the builder
- Throws:
NullPointerException
- ifcredentials
isnull
. To disable authentication useNoCredentials.getInstance()
-
setRetrySettings
public B setRetrySettings(com.google.api.gax.retrying.RetrySettings retrySettings)
Sets configuration parameters for request retries.- Returns:
- the builder
-
setServiceRpcFactory
public B setServiceRpcFactory(ServiceRpcFactory<OptionsT> serviceRpcFactory)
Sets the factory for rpc services.- Returns:
- the builder
-
setTransportOptions
public B setTransportOptions(TransportOptions transportOptions)
Sets the transport options.- Returns:
- the builder
-
setHeaderProvider
@BetaApi public B setHeaderProvider(com.google.api.gax.rpc.HeaderProvider headerProvider)
Sets the static header provider. The header provider will be called during client construction only once. The headers returned by the provider will be cached and supplied as is for each request issued by the constructed client. Some reserved headers can be overridden (e.g. Content-Type) or merged with the default value (e.g. User-Agent) by the underlying transport layer.- Parameters:
headerProvider
- the header provider- Returns:
- the builder
-
setQuotaProjectId
public B setQuotaProjectId(String quotaProjectId)
Sets the quotaProjectId that specifies the project used for quota and billing purposes.- See Also:
- See system parameter $userProject
-
-