1- /**
2- * This file was auto-generated by Fern from our API Definition.
3- */
41package com .pipedream .api ;
52
63import com .pipedream .api .core .ClientOptions ;
1310import java .util .Optional ;
1411import okhttp3 .OkHttpClient ;
1512
16- public class AsyncBaseClientBuilder {
13+ public class AsyncBaseClientBuilder < T extends AsyncBaseClientBuilder < T >> {
1714 private Optional <Integer > timeout = Optional .empty ();
1815
1916 private Optional <Integer > maxRetries = Optional .empty ();
@@ -67,51 +64,51 @@ public static _Builder builder() {
6764 /**
6865 * Sets projectEnvironment
6966 */
70- public AsyncBaseClientBuilder projectEnvironment (String projectEnvironment ) {
67+ public T projectEnvironment (String projectEnvironment ) {
7168 this .projectEnvironment = projectEnvironment ;
72- return this ;
69+ return ( T ) this ;
7370 }
7471
75- public AsyncBaseClientBuilder environment (Environment environment ) {
72+ public T environment (Environment environment ) {
7673 this .environment = environment ;
77- return this ;
74+ return ( T ) this ;
7875 }
7976
80- public AsyncBaseClientBuilder url (String url ) {
77+ public T url (String url ) {
8178 this .environment = Environment .custom (url );
82- return this ;
79+ return ( T ) this ;
8380 }
8481
8582 /**
8683 * Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
8784 */
88- public AsyncBaseClientBuilder timeout (int timeout ) {
85+ public T timeout (int timeout ) {
8986 this .timeout = Optional .of (timeout );
90- return this ;
87+ return ( T ) this ;
9188 }
9289
9390 /**
9491 * Sets the maximum number of retries for the client. Defaults to 2 retries.
9592 */
96- public AsyncBaseClientBuilder maxRetries (int maxRetries ) {
93+ public T maxRetries (int maxRetries ) {
9794 this .maxRetries = Optional .of (maxRetries );
98- return this ;
95+ return ( T ) this ;
9996 }
10097
10198 /**
10299 * Sets the underlying OkHttp client
103100 */
104- public AsyncBaseClientBuilder httpClient (OkHttpClient httpClient ) {
101+ public T httpClient (OkHttpClient httpClient ) {
105102 this .httpClient = httpClient ;
106- return this ;
103+ return ( T ) this ;
107104 }
108105
109106 /**
110107 * Configure logging for the SDK. Silent by default — no log output unless explicitly configured.
111108 */
112- public AsyncBaseClientBuilder logging (LogConfig logging ) {
109+ public T logging (LogConfig logging ) {
113110 this .logging = Optional .of (logging );
114- return this ;
111+ return ( T ) this ;
115112 }
116113
117114 /**
@@ -122,14 +119,14 @@ public AsyncBaseClientBuilder logging(LogConfig logging) {
122119 * @param value The header value
123120 * @return This builder for method chaining
124121 */
125- public AsyncBaseClientBuilder addHeader (String name , String value ) {
122+ public T addHeader (String name , String value ) {
126123 this .customHeaders .put (name , value );
127- return this ;
124+ return ( T ) this ;
128125 }
129126
130- public AsyncBaseClientBuilder projectId (String projectId ) {
127+ public T projectId (String projectId ) {
131128 this .projectId = projectId ;
132- return this ;
129+ return ( T ) this ;
133130 }
134131
135132 protected ClientOptions buildClientOptions () {
@@ -298,7 +295,7 @@ public AsyncBaseClient build() {
298295 return new AsyncBaseClient (buildClientOptions ());
299296 }
300297
301- public static final class _TokenAuth extends AsyncBaseClientBuilder {
298+ public static final class _TokenAuth extends AsyncBaseClientBuilder < _TokenAuth > {
302299 private final String token ;
303300
304301 _TokenAuth (String token ) {
@@ -311,7 +308,7 @@ protected void setAuthentication(ClientOptions.Builder builder) {
311308 }
312309 }
313310
314- public static final class _CredentialsAuth extends AsyncBaseClientBuilder {
311+ public static final class _CredentialsAuth extends AsyncBaseClientBuilder < _CredentialsAuth > {
315312 private final String clientId ;
316313
317314 private final String clientSecret ;
@@ -351,6 +348,8 @@ public static final class _Builder {
351348
352349 private OkHttpClient httpClient ;
353350
351+ private Optional <LogConfig > logging = Optional .empty ();
352+
354353 private final Map <String , String > headers = new HashMap <>();
355354
356355 public _Builder environment (Environment environment ) {
@@ -387,6 +386,14 @@ public _Builder httpClient(OkHttpClient httpClient) {
387386 return this ;
388387 }
389388
389+ /**
390+ * Configure logging for the SDK. Silent by default — no log output unless explicitly configured.
391+ */
392+ public _Builder logging (LogConfig logging ) {
393+ this .logging = Optional .of (logging );
394+ return this ;
395+ }
396+
390397 /**
391398 * Add a custom header to be sent with all requests.
392399 * @param name The header name
@@ -408,21 +415,7 @@ public _Builder addHeader(String name, String value) {
408415 */
409416 public _TokenAuth token (String token ) {
410417 _TokenAuth auth = new _TokenAuth (token );
411- if (this .environment != null ) {
412- auth .environment = this .environment ;
413- }
414- if (this .timeout .isPresent ()) {
415- auth .timeout (this .timeout .get ());
416- }
417- if (this .maxRetries .isPresent ()) {
418- auth .maxRetries (this .maxRetries .get ());
419- }
420- if (this .httpClient != null ) {
421- auth .httpClient (this .httpClient );
422- }
423- for (Map .Entry <String , String > header : this .headers .entrySet ()) {
424- auth .addHeader (header .getKey (), header .getValue ());
425- }
418+ applyTo (auth );
426419 return auth ;
427420 }
428421
@@ -436,6 +429,11 @@ public _TokenAuth token(String token) {
436429 */
437430 public _CredentialsAuth credentials (String clientId , String clientSecret ) {
438431 _CredentialsAuth auth = new _CredentialsAuth (clientId , clientSecret );
432+ applyTo (auth );
433+ return auth ;
434+ }
435+
436+ private <B extends AsyncBaseClientBuilder <B >> void applyTo (B auth ) {
439437 if (this .environment != null ) {
440438 auth .environment = this .environment ;
441439 }
@@ -448,10 +446,12 @@ public _CredentialsAuth credentials(String clientId, String clientSecret) {
448446 if (this .httpClient != null ) {
449447 auth .httpClient (this .httpClient );
450448 }
449+ if (this .logging .isPresent ()) {
450+ auth .logging (this .logging .get ());
451+ }
451452 for (Map .Entry <String , String > header : this .headers .entrySet ()) {
452453 auth .addHeader (header .getKey (), header .getValue ());
453454 }
454- return auth ;
455455 }
456456 }
457457}
0 commit comments