Package com.influxdb.v3.client.config
Class ClientConfig.Builder
java.lang.Object
com.influxdb.v3.client.config.ClientConfig.Builder
- Enclosing class:
- ClientConfig
A builder for
ClientConfig
.
Mutable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallowHttpRedirects
(Boolean allowHttpRedirects) Sets the automatically following HTTP 3xx redirects.authenticator
(Authenticator authenticator) Sets the proxy authenticator.authScheme
(String authScheme) Sets authentication scheme.build()
Build an instance ofClientConfig
.Build an instance ofClientConfig
from connection string.build
(Map<String, String> env, Properties properties) Build an instance ofClientConfig
from environment variables and/or system properties.Sets database to be used for InfluxDB operations.defaultTags
(Map<String, String> defaultTags) Sets default tags to be written with points.disableServerCertificateValidation
(Boolean disableServerCertificateValidation) Sets the disable server SSL certificate validation.gzipThreshold
(Integer gzipThreshold) Sets the threshold for request body to be gzipped.Sets the custom headers that will be added to requests.Sets the URL of the InfluxDB server.organization
(String organization) Sets organization to be used for operations.proxy
(ProxySelector proxy) Sets the proxy selector.Sets the default timeout to use for the API calls.token
(char[] token) Sets the authentication token for accessing the InfluxDB server.writePrecision
(WritePrecision writePrecision) Sets the default precision to use for the timestamp of points if no precision is specified in the write API call.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
host
Sets the URL of the InfluxDB server.- Parameters:
host
- URL of the InfluxDB server- Returns:
- this
-
token
Sets the authentication token for accessing the InfluxDB server.- Parameters:
token
- authentication token for accessing the InfluxDB server- Returns:
- this
-
authScheme
Sets authentication scheme.- Parameters:
authScheme
- authentication scheme. Defaultnull
for Cloud access, set to 'Bearer' for Edge.- Returns:
- this
-
organization
Sets organization to be used for operations.- Parameters:
organization
- organization to be used for operations- Returns:
- this
-
database
Sets database to be used for InfluxDB operations.- Parameters:
database
- database to be used for InfluxDB operations- Returns:
- this
-
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
Sets the threshold for request body to be gzipped.- Parameters:
gzipThreshold
- threshold in bytes for request body to be gzipped- Returns:
- this
-
defaultTags
Sets default tags to be written with points.- Parameters:
defaultTags
- - tags to be used.- Returns:
- this
-
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
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
Sets the proxy selector. Default is 'null'.- Parameters:
proxy
- Proxy selector.- Returns:
- this
-
authenticator
Sets the proxy authenticator. Default is 'null'.- Parameters:
authenticator
- Proxy authenticator. Ignored if 'proxy' is not set.- Returns:
- this
-
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
Build an instance ofClientConfig
.- Returns:
- the configuration for an
InfluxDBClient
.
-
build
Build an instance ofClientConfig
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
Build an instance ofClientConfig
from environment variables and/or system properties.- Parameters:
env
- environment variablesproperties
- system properties- Returns:
- the configuration for an
InfluxDBClient
.
-