Class ClientConfig.Builder

java.lang.Object
com.influxdb.v3.client.config.ClientConfig.Builder
Enclosing class:
ClientConfig

public static final class ClientConfig.Builder extends Object
A builder for ClientConfig.

Mutable.

  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • host

      @Nonnull public ClientConfig.Builder host(@Nonnull String host)
      Sets the URL of the InfluxDB server.
      Parameters:
      host - URL of the InfluxDB server
      Returns:
      this
    • token

      @Nonnull public ClientConfig.Builder token(@Nullable char[] token)
      Sets the authentication token for accessing the InfluxDB server.
      Parameters:
      token - authentication token for accessing the InfluxDB server
      Returns:
      this
    • organization

      @Nonnull public ClientConfig.Builder organization(@Nullable String organization)
      Sets organization to be used for operations.
      Parameters:
      organization - organization to be used for operations
      Returns:
      this
    • database

      @Nonnull public ClientConfig.Builder database(@Nullable String database)
      Sets database to be used for InfluxDB operations.
      Parameters:
      database - database to be used for InfluxDB operations
      Returns:
      this
    • writePrecision

      @Nonnull public ClientConfig.Builder writePrecision(@Nullable WritePrecision writePrecision)
      Sets the default precision to use for the timestamp of points if no precision is specified in the write API call.
      Parameters:
      writePrecision - default precision to use for the timestamp of points if no precision is specified in the write API call
      Returns:
      this
    • gzipThreshold

      @Nonnull public ClientConfig.Builder gzipThreshold(@Nullable Integer gzipThreshold)
      Sets the threshold for request body to be gzipped.
      Parameters:
      gzipThreshold - threshold in bytes for request body to be gzipped
      Returns:
      this
    • defaultTags

      @Nonnull public ClientConfig.Builder defaultTags(@Nullable Map<String,String> defaultTags)
      Sets default tags to be written with points.
      Parameters:
      defaultTags - - tags to be used.
      Returns:
      this
    • timeout

      @Nonnull public ClientConfig.Builder timeout(@Nullable Duration timeout)
      Sets the default timeout to use for the API calls. Default to '10 seconds'.
      Parameters:
      timeout - default timeout to use for the API calls. Default to '10 seconds'.
      Returns:
      this
    • allowHttpRedirects

      @Nonnull public ClientConfig.Builder allowHttpRedirects(@Nullable Boolean allowHttpRedirects)
      Sets the automatically following HTTP 3xx redirects. Default to 'false'.
      Parameters:
      allowHttpRedirects - automatically following HTTP 3xx redirects. Default to 'false'.
      Returns:
      this
    • disableServerCertificateValidation

      @Nonnull public ClientConfig.Builder disableServerCertificateValidation(@Nullable Boolean disableServerCertificateValidation)
      Sets the disable server SSL certificate validation. Default to 'false'.
      Parameters:
      disableServerCertificateValidation - Disable server SSL certificate validation. Default to 'false'.
      Returns:
      this
    • proxy

      @Nonnull public ClientConfig.Builder proxy(@Nullable ProxySelector proxy)
      Sets the proxy selector. Default is 'null'.
      Parameters:
      proxy - Proxy selector.
      Returns:
      this
    • authenticator

      @Nonnull public ClientConfig.Builder authenticator(@Nullable Authenticator authenticator)
      Sets the proxy authenticator. Default is 'null'.
      Parameters:
      authenticator - Proxy authenticator. Ignored if 'proxy' is not set.
      Returns:
      this
    • headers

      @Nonnull public ClientConfig.Builder headers(@Nullable Map<String,String> headers)
      Sets the custom headers that will be added to requests. This is useful for adding custom headers to requests, such as tracing headers. To add custom headers use following code:
       ClientConfig config = new ClientConfig.Builder()
           .host("https://us-east-1-1.aws.cloud2.influxdata.com")
           .token("my-token".toCharArray())
           .database("my-database")
           .headers(Map.of("X-Tracing-Id", "123"))
           .build();
      
       try (InfluxDBClient client = InfluxDBClient.getInstance(config)) {
           //
           // your code here
           //
       } catch (Exception e) {
           throw new RuntimeException(e);
       }
       
      Parameters:
      headers - the headers to be added to requests
      Returns:
      this
    • build

      @Nonnull public ClientConfig build()
      Build an instance of ClientConfig.
      Returns:
      the configuration for an InfluxDBClient.
    • build

      @Nonnull public ClientConfig build(@Nonnull String connectionString) throws MalformedURLException
      Build an instance of ClientConfig from connection string.
      Parameters:
      connectionString - connection string in URL format
      Returns:
      the configuration for an InfluxDBClient
      Throws:
      MalformedURLException - when argument is not valid URL
    • build

      @Nonnull public ClientConfig build(@Nonnull Map<String,String> env, Properties properties)
      Build an instance of ClientConfig from environment variables and/or system properties.
      Parameters:
      env - environment variables
      properties - system properties
      Returns:
      the configuration for an InfluxDBClient.