2323
2424import java .net .Authenticator ;
2525import java .net .MalformedURLException ;
26- import java .net .ProxySelector ;
2726import java .net .URL ;
2827import java .time .Duration ;
2928import java .util .Arrays ;
3534import java .util .function .BiFunction ;
3635import javax .annotation .Nonnull ;
3736import javax .annotation .Nullable ;
38- import javax .net .ssl .SSLContext ;
39-
40- import io .grpc .ProxyDetector ;
41- import io .netty .handler .ssl .SslContext ;
4237
4338import com .influxdb .v3 .client .write .WritePrecision ;
4439
6156 * <li><code>disableServerCertificateValidation</code> -
6257 * disable server certificate validation for HTTPS connections
6358 * </li>
64- * <li><code>proxy </code> - HTTP proxy selector </li>
59+ * <li><code>proxyUrl </code> - Proxy url for query api and write api </li>
6560 * <li><code>queryApiProxy</code> - HTTP query detector</li>
6661 * <li><code>authenticator</code> - HTTP proxy authenticator</li>
6762 * <li><code>headers</code> - headers to be added to requests</li>
63+ * <li><code>certificateFilePath</code> - Path to the stored certificates file</li>
6864 * </ul>
6965 * <p>
7066 * If you want to create a client with custom configuration, you can use following code:
7167 * <pre>
7268 * ClientConfig config = new ClientConfig.Builder()
73- * .host("https://us-east-1-1.aws.cloud2.influxdata.com")
69+ * .host("<a href=" https://us-east-1-1.aws.cloud2.influxdata.com">https://us-east-1-1.aws.cloud2.influxdata.com</a> ")
7470 * .token("my-token".toCharArray())
7571 * .database("my-database")
7672 * .writePrecision(WritePrecision.S)
8985 * Immutable class.
9086 */
9187public final class ClientConfig {
92-
88+ //todo check if main use proxySelector for backward compality
89+ //todo check comments
9390 private final String host ;
9491 private final char [] token ;
9592 private final String authScheme ;
@@ -101,12 +98,10 @@ public final class ClientConfig {
10198 private final Duration timeout ;
10299 private final Boolean allowHttpRedirects ;
103100 private final Boolean disableServerCertificateValidation ;
104- private final ProxySelector proxy ;
105- private final ProxyDetector queryApiProxy ;
101+ private final String proxyUrl ;
106102 private final Authenticator authenticator ;
107103 private final Map <String , String > headers ;
108- private final SslContext grpcSslContext ;
109- private final SSLContext sslContext ;
104+ private final String certificateFilePath ;
110105
111106 /**
112107 * Gets URL of the InfluxDB server.
@@ -218,23 +213,23 @@ public Boolean getDisableServerCertificateValidation() {
218213 }
219214
220215 /**
221- * Gets the proxy.
216+ * Gets the proxy url .
222217 *
223- * @return the proxy, may be null
218+ * @return the proxy url , may be null
224219 */
225220 @ Nullable
226- public ProxySelector getProxy () {
227- return proxy ;
221+ public String getProxyUrl () {
222+ return proxyUrl ;
228223 }
229224
230225 /**
231- * Gets the proxy for query api.
226+ * Gets certificates file path
232227 *
233- * @return the proxy , may be null
228+ * @return the certificates file path , may be null
234229 */
235230 @ Nullable
236- public ProxyDetector getQueryApiProxy () {
237- return queryApiProxy ;
231+ public String certificateFilePath () {
232+ return certificateFilePath ;
238233 }
239234
240235 /**
@@ -257,26 +252,6 @@ public Map<String, String> getHeaders() {
257252 return headers ;
258253 }
259254
260- /**
261- * Gets SslContext object from grpc.
262- *
263- * @return the SslContext object
264- */
265- @ Nullable
266- public SslContext getGrpcSslContext () {
267- return grpcSslContext ;
268- }
269-
270- /**
271- * Gets SSLContext object.
272- *
273- * @return the SSLContext object
274- */
275- @ Nullable
276- public SSLContext getSslContext () {
277- return sslContext ;
278- }
279-
280255 /**
281256 * Validates the configuration properties.
282257 */
@@ -306,21 +281,19 @@ public boolean equals(final Object o) {
306281 && Objects .equals (timeout , that .timeout )
307282 && Objects .equals (allowHttpRedirects , that .allowHttpRedirects )
308283 && Objects .equals (disableServerCertificateValidation , that .disableServerCertificateValidation )
309- && Objects .equals (proxy , that .proxy )
310- && Objects .equals (queryApiProxy , that .queryApiProxy )
284+ && Objects .equals (proxyUrl , that .proxyUrl )
311285 && Objects .equals (authenticator , that .authenticator )
312286 && Objects .equals (headers , that .headers )
313- && Objects .equals (grpcSslContext , that .grpcSslContext )
314- && Objects .equals (sslContext , that .sslContext );
287+ && Objects .equals (certificateFilePath , that .certificateFilePath );
315288 }
316289
317290 @ Override
318291 public int hashCode () {
319292 return Objects .hash (host , Arrays .hashCode (token ), authScheme , organization ,
320- database , writePrecision , gzipThreshold ,
321- timeout , allowHttpRedirects , disableServerCertificateValidation ,
322- proxy , queryApiProxy , authenticator , headers ,
323- defaultTags , grpcSslContext , sslContext );
293+ database , writePrecision , gzipThreshold ,
294+ timeout , allowHttpRedirects , disableServerCertificateValidation ,
295+ proxyUrl , authenticator , headers ,
296+ defaultTags , certificateFilePath );
324297 }
325298
326299 @ Override
@@ -334,13 +307,11 @@ public String toString() {
334307 .add ("timeout=" + timeout )
335308 .add ("allowHttpRedirects=" + allowHttpRedirects )
336309 .add ("disableServerCertificateValidation=" + disableServerCertificateValidation )
337- .add ("proxy=" + proxy )
338- .add ("queryApiProxy=" + queryApiProxy )
310+ .add ("proxy=" + proxyUrl )
339311 .add ("authenticator=" + authenticator )
340312 .add ("headers=" + headers )
341313 .add ("defaultTags=" + defaultTags )
342- .add ("grpcSslContext=" + grpcSslContext )
343- .add ("sslContext=" + sslContext )
314+ .add ("certificateFilePath=" + certificateFilePath )
344315 .toString ();
345316 }
346317
@@ -361,12 +332,10 @@ public static final class Builder {
361332 private Duration timeout ;
362333 private Boolean allowHttpRedirects ;
363334 private Boolean disableServerCertificateValidation ;
364- private ProxySelector proxy ;
365- private ProxyDetector queryApiProxy ;
335+ private String proxyUrl ;
366336 private Authenticator authenticator ;
367337 private Map <String , String > headers ;
368- private SslContext grpcSslContext ;
369- private SSLContext sslContext ;
338+ private String certificateFilePath ;
370339
371340 /**
372341 * Sets the URL of the InfluxDB server.
@@ -515,28 +484,15 @@ public Builder disableServerCertificateValidation(@Nullable final Boolean disabl
515484 }
516485
517486 /**
518- * Sets the proxy selector. Default is 'null'.
519- *
520- * @param proxy Proxy selector.
521- * @return this
522- */
523- @ Nonnull
524- public Builder proxy (@ Nullable final ProxySelector proxy ) {
525-
526- this .proxy = proxy ;
527- return this ;
528- }
529-
530- /**
531- * Sets the proxy detector for query api. Default is 'null'.
487+ * Sets the proxy url. Default is 'null'.
532488 *
533- * @param proxy Proxy detector .
489+ * @param proxyUrl Proxy url .
534490 * @return this
535491 */
536492 @ Nonnull
537- public Builder queryApiProxy (@ Nullable final ProxyDetector proxy ) {
493+ public Builder proxyUrl (@ Nullable final String proxyUrl ) {
538494
539- this .queryApiProxy = proxy ;
495+ this .proxyUrl = proxyUrl ;
540496 return this ;
541497 }
542498
@@ -558,7 +514,7 @@ public Builder authenticator(@Nullable final Authenticator authenticator) {
558514 * such as tracing headers. To add custom headers use following code:
559515 * <pre>
560516 * ClientConfig config = new ClientConfig.Builder()
561- * .host("https://us-east-1-1.aws.cloud2.influxdata.com")
517+ * .host("<a href=" https://us-east-1-1.aws.cloud2.influxdata.com">https://us-east-1-1.aws.cloud2.influxdata.com</a> ")
562518 * .token("my-token".toCharArray())
563519 * .database("my-database")
564520 * .headers(Map.of("X-Tracing-Id", "123"))
@@ -584,28 +540,15 @@ public Builder headers(@Nullable final Map<String, String> headers) {
584540 }
585541
586542 /**
587- * Sets SslContext for grpc client. Default is 'null'.
588- *
589- * @param grpcSslContext The SSLContext
590- * @return this
591- */
592- @ Nonnull
593- public Builder grpcSslContext (@ Nullable final SslContext grpcSslContext ) {
594-
595- this .grpcSslContext = grpcSslContext ;
596- return this ;
597- }
598-
599- /**
600- * Sets SSLContext for rest client. Default is 'null'.
543+ * Sets certificate file path. Default is 'null'.
601544 *
602- * @param sslContext The SSLContext
545+ * @param certificateFilePath The certificate file path
603546 * @return this
604547 */
605548 @ Nonnull
606- public Builder sslContext (@ Nullable final SSLContext sslContext ) {
549+ public Builder certificateFilePath (@ Nullable final String certificateFilePath ) {
607550
608- this .sslContext = sslContext ;
551+ this .certificateFilePath = certificateFilePath ;
609552 return this ;
610553 }
611554
@@ -743,11 +686,9 @@ private ClientConfig(@Nonnull final Builder builder) {
743686 allowHttpRedirects = builder .allowHttpRedirects != null ? builder .allowHttpRedirects : false ;
744687 disableServerCertificateValidation = builder .disableServerCertificateValidation != null
745688 ? builder .disableServerCertificateValidation : false ;
746- proxy = builder .proxy ;
747- queryApiProxy = builder .queryApiProxy ;
689+ proxyUrl = builder .proxyUrl ;
748690 authenticator = builder .authenticator ;
749691 headers = builder .headers ;
750- grpcSslContext = builder .grpcSslContext ;
751- sslContext = builder .sslContext ;
692+ certificateFilePath = builder .certificateFilePath ;
752693 }
753694}
0 commit comments