Package com.influxdb.client
Class InfluxDBClientOptions.Builder
java.lang.Object
com.influxdb.client.InfluxDBClientOptions.Builder
- Enclosing class:
InfluxDBClientOptions
A builder for
InfluxDBClientOptions
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddDefaultTag
(String key, String expression) Add default tag that will be use for writes by Point and POJO.authenticate
(String username, char[] password) Setup authorization byInfluxDBClientOptions.AuthScheme.SESSION
.authenticateToken
(char[] token) Setup authorization byInfluxDBClientOptions.AuthScheme.TOKEN
.Specify the default destination bucket for writes.build()
Build an instance of InfluxDBClientOptions.clientType
(String clientType) Set theclientType
to customize the User-Agent HTTP header.connectionString
(String connectionString) Configure Builder via connection string.consistency
(WriteConsistency consistency) Specify the write consistency for the point.Configure Builder viainflux2.properties
.Set the log level for the request and response information.okHttpClient
(okhttp3.OkHttpClient.Builder okHttpClient) Set the HTTP client to use for communication with InfluxDB.Specify the default destination organization for writes and queries.precision
(WritePrecision precision) Specify the default precision for unix timestamps in the line protocol.Set the url to connect to InfluxDB.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
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
Set theclientType
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
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 byInfluxDBClientOptions.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 authpassword
- the password to use in the basic auth- Returns:
this
-
authenticateToken
Setup authorization byInfluxDBClientOptions.AuthScheme.TOKEN
.- Parameters:
token
- the token to use for the authorization- Returns:
this
-
org
Specify the default destination organization for writes and queries.- Parameters:
org
- the default destination organization for writes and queries- Returns:
this
-
bucket
Specify the default destination bucket for writes.- Parameters:
bucket
- default destination bucket for writes- Returns:
this
-
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
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 nameexpression
- the tag value expression- Returns:
- this
-
connectionString
Configure Builder via connection string. The allowed configuration:org
- default destination organization for writes and queriesbucket
- default destination bucket for writestoken
- the token to use for the authorizationlogLevel
- rest client verbosity levelreadTimeout
- read timeoutwriteTimeout
- write timeoutconnectTimeout
- socket timeoutprecision
- default precision for unix timestamps in the line protocolconsistency
- specify the write consistency for the pointclientType
- 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
Configure Builder viainflux2.properties
.- Returns:
this
-
build
Build an instance of InfluxDBClientOptions.- Returns:
InfluxDBClientOptions
-