Class InfluxDBClientOptions.Builder

java.lang.Object
com.influxdb.client.InfluxDBClientOptions.Builder
Enclosing class:
InfluxDBClientOptions

@NotThreadSafe public static class InfluxDBClientOptions.Builder extends Object
A builder for InfluxDBClientOptions.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • url

      @Nonnull public InfluxDBClientOptions.Builder url(@Nonnull String url)
      Set the url to connect to InfluxDB.

      The url could be a connection string with various configurations. For more info see: connectionString(String).

      Parameters:
      url - the url to connect to InfluxDB (required). Example: http://localhost:8086?readTimeout=5000
      Returns:
      this
    • clientType

      @Nonnull public InfluxDBClientOptions.Builder clientType(@Nonnull String clientType)
      Set the clientType to customize the User-Agent HTTP header.

      If the clientType is set to "awesome-service" the User-Agent header will be: influxdb-client-awesome-service/6.2.0.

      Parameters:
      clientType - the client type to report as a part of User-Agent to remote server
      Returns:
      this
    • okHttpClient

      @Nonnull public InfluxDBClientOptions.Builder okHttpClient(@Nonnull okhttp3.OkHttpClient.Builder okHttpClient)
      Set the HTTP client to use for communication with InfluxDB.
      Parameters:
      okHttpClient - the HTTP client to use.
      Returns:
      this
    • logLevel

      @Nonnull public InfluxDBClientOptions.Builder logLevel(@Nonnull LogLevel logLevel)
      Set the log level for the request and response information.
      Parameters:
      logLevel - The log level for the request and response information.
      Returns:
      this
    • authenticate

      @Nonnull public InfluxDBClientOptions.Builder authenticate(@Nonnull String username, @Nonnull char[] password)
      Setup authorization by InfluxDBClientOptions.AuthScheme.SESSION.

      The username/password auth is based on HTTP "Basic" authentication. The authorization expires when the time-to-live (TTL) (default 60 minutes) is reached and client produces UnauthorizedException.

      Parameters:
      username - the username to use in the basic auth
      password - the password to use in the basic auth
      Returns:
      this
    • authenticateToken

      @Nonnull public InfluxDBClientOptions.Builder authenticateToken(char[] token)
      Parameters:
      token - the token to use for the authorization
      Returns:
      this
    • org

      @Nonnull public InfluxDBClientOptions.Builder org(@Nullable String org)
      Specify the default destination organization for writes and queries.
      Parameters:
      org - the default destination organization for writes and queries
      Returns:
      this
    • bucket

      @Nonnull public InfluxDBClientOptions.Builder bucket(@Nullable String bucket)
      Specify the default destination bucket for writes.
      Parameters:
      bucket - default destination bucket for writes
      Returns:
      this
    • precision

      @Nonnull public InfluxDBClientOptions.Builder precision(@Nullable WritePrecision precision)
      Specify the default precision for unix timestamps in the line protocol.
      Parameters:
      precision - default precision for unix timestamps in the line protocol
      Returns:
      this
    • consistency

      @Nonnull public InfluxDBClientOptions.Builder consistency(@Nullable WriteConsistency consistency)
      Specify the write consistency for the point.

      InfluxDB assumes that the write consistency is WriteConsistency.ONE if you do not specify consistency. See the InfluxDB Enterprise documentation for detailed descriptions of each consistency option. Available with InfluxDB Enterprise clusters only!

      Parameters:
      consistency - The write consistency for the point.
      Returns:
      this
    • addDefaultTag

      @Nonnull public InfluxDBClientOptions.Builder addDefaultTag(@Nonnull String key, @Nullable String expression)
      Add default tag that will be use for writes by Point and POJO.

      The expressions can be:

      • "California Miner" - static value
      • "${version}" - system property
      • "${env.hostname}" - environment property
      Parameters:
      key - the tag name
      expression - the tag value expression
      Returns:
      this
    • connectionString

      @Nonnull public InfluxDBClientOptions.Builder connectionString(@Nonnull String connectionString)
      Configure Builder via connection string. The allowed configuration:
      • org - default destination organization for writes and queries
      • bucket - default destination bucket for writes
      • token - the token to use for the authorization
      • logLevel - rest client verbosity level
      • readTimeout - read timeout
      • writeTimeout - write timeout
      • connectTimeout - socket timeout
      • precision - default precision for unix timestamps in the line protocol
      • consistency - specify the write consistency for the point
      • clientType - to customize the User-Agent HTTP header

      Connection string example:

       http://localhost:8086?readTimeout=30000&token=my-token&bucket=my-bucket&org=my-org
       
      Returns:
      this
    • loadProperties

      @Nonnull public InfluxDBClientOptions.Builder loadProperties()
      Configure Builder via influx2.properties.
      Returns:
      this
    • build

      @Nonnull public InfluxDBClientOptions build()
      Build an instance of InfluxDBClientOptions.
      Returns:
      InfluxDBClientOptions