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 subclass
OptionsT - the ServiceOptions subclass corresponding to the service
B - the ServiceOptions 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 for ServiceOptions.
  • Field Details

    • credentials

      protected com.google.auth.Credentials credentials
  • Constructor Details

  • Method Details

    • 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(ApiClock clock)
      Sets the service's clock. The clock is mainly used for testing purpose. ApiClock will be replaced by Java8's java.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
    • setHost

      public B setHost(String host)
      Sets service host.
      Returns:
      the builder
    • setUniverseDomain

      public B setUniverseDomain(String universeDomain)
      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`.

      If this value is not set, the resolved UniverseDomain will default to `googleapis.com`.

      Throws:
      NullPointerException - if universeDomain is null. The resolved universeDomain will be `googleapis.com` if this value is not set.
    • 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. Use NoCredentials.getInstance() to skip authentication, this is typically useful when using local service emulators.
      Parameters:
      credentials - authentication credentials, should not be null
      Returns:
      the builder
      Throws:
      NullPointerException - if credentials is null. To disable authentication use NoCredentials.getInstance()
    • setRetrySettings

      public B setRetrySettings(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(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
    • setClientLibToken

      @InternalApi public B setClientLibToken(String clientLibToken)
    • setQuotaProjectId

      public B setQuotaProjectId(String quotaProjectId)
      Sets the quotaProjectId that specifies the project used for quota and billing purposes.
      See Also:
    • setApiTracerFactory

      @BetaApi @InternalApi public B setApiTracerFactory(ApiTracerFactory apiTracerFactory)
      Sets the ApiTracerFactory. It will be used to create an ApiTracer that is annotated throughout the lifecycle of an RPC operation.
    • getAllowedClientLibTokens

      protected Set<String> getAllowedClientLibTokens()