Class ServiceOptions.Builder<ServiceT extends Service<OptionsT>,​OptionsT extends ServiceOptions<ServiceT,​OptionsT>,​B extends 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 Detail

      • credentials

        protected com.google.auth.Credentials credentials
    • 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

      • self

        protected B self()
      • 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'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
      • 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​(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
      • 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:
        See system parameter $userProject
      • getAllowedClientLibTokens

        protected Set<String> getAllowedClientLibTokens()