Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"generatorVersion": "3.34.8",
"generatorConfig": {
"publish-to": "central",
"client-class-name": "ExtendClient",
"client-class-name": "ExtendClientBase",
"exported-client-class-name": "ExtendClient",
"base-api-exception-class-name": "ExtendClientApiException",
"base-exception-class-name": "ExtendClientException",
"package-prefix": "ai.extend",
"enable-inline-types": false,
"inline-file-properties": false,
Expand All @@ -15,6 +18,6 @@
"testImplementation org.mockito:mockito-inline:4.11.0"
]
},
"originGitCommit": "3d99f65f34686b0f1567dcfce79ac4204c0634da",
"sdkVersion": "1.14.0"
"originGitCommit": "6dd03f55fc737ec02dbc158904c7274a58de36e7",
"sdkVersion": "1.15.0"
}
11 changes: 11 additions & 0 deletions .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ README.md
# Protect custom wrapper code
src/main/java/ai/extend/wrapper/

# Protect hand-written client classes (the customer-facing ExtendClient and its
# builder, plus the async/raw aliases). Fern generates the *Base versions of these
# (ExtendClientBase, AsyncExtendClientBase, etc.); these subclasses keep the
# historical public type names so upgrades don't break customer code.
src/main/java/ai/extend/ExtendClient.java
src/main/java/ai/extend/ExtendClientBuilder.java
src/main/java/ai/extend/AsyncExtendClient.java
src/main/java/ai/extend/AsyncExtendClientBuilder.java
src/main/java/ai/extend/RawExtendClient.java
src/main/java/ai/extend/AsyncRawExtendClient.java

# Protect custom tests
src/test/java/ai/extend/wrapper/
.fern/replay.lock
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ java {

group = 'ai.extend'

version = '1.14.0'
version = '1.15.0'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand Down Expand Up @@ -81,7 +81,7 @@ publishing {
maven(MavenPublication) {
groupId = 'ai.extend'
artifactId = 'extend-java-sdk'
version = '1.14.0'
version = '1.15.0'
from components.java
pom {
name = 'Extend.ai'
Expand Down
2 changes: 1 addition & 1 deletion sample-app/src/main/java/sample/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

public final class App {
public static void main(String[] args) {
// import ai.extend.AsyncExtendClient
// import ai.extend.AsyncExtendClientBase
}
}
350 changes: 16 additions & 334 deletions src/main/java/ai/extend/AsyncExtendClient.java

Large diffs are not rendered by default.

358 changes: 358 additions & 0 deletions src/main/java/ai/extend/AsyncExtendClientBase.java

Large diffs are not rendered by default.

236 changes: 236 additions & 0 deletions src/main/java/ai/extend/AsyncExtendClientBaseBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package ai.extend;

import ai.extend.core.ClientOptions;
import ai.extend.core.Environment;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import okhttp3.OkHttpClient;

public class AsyncExtendClientBaseBuilder {
private Optional<Integer> timeout = Optional.empty();

private Optional<Integer> maxRetries = Optional.empty();

private final Map<String, String> customHeaders = new HashMap<>();

private String token = System.getenv("EXTEND_API_KEY");

private String extendApiVersion = "2026-02-09";

private Environment environment = Environment.PRODUCTION;

private OkHttpClient httpClient;

/**
* Sets token.
* Defaults to the EXTEND_API_KEY environment variable.
*/
public AsyncExtendClientBaseBuilder token(String token) {
this.token = token;
return this;
}

/**
* Sets extendApiVersion
*/
public AsyncExtendClientBaseBuilder extendApiVersion(String extendApiVersion) {
this.extendApiVersion = extendApiVersion;
return this;
}

public AsyncExtendClientBaseBuilder environment(Environment environment) {
this.environment = environment;
return this;
}

public AsyncExtendClientBaseBuilder url(String url) {
this.environment = Environment.custom(url);
return this;
}

/**
* Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
*/
public AsyncExtendClientBaseBuilder timeout(int timeout) {
this.timeout = Optional.of(timeout);
return this;
}

/**
* Sets the maximum number of retries for the client. Defaults to 2 retries.
*/
public AsyncExtendClientBaseBuilder maxRetries(int maxRetries) {
this.maxRetries = Optional.of(maxRetries);
return this;
}

/**
* Sets the underlying OkHttp client
*/
public AsyncExtendClientBaseBuilder httpClient(OkHttpClient httpClient) {
this.httpClient = httpClient;
return this;
}

/**
* Add a custom header to be sent with all requests.
* For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead.
*
* @param name The header name
* @param value The header value
* @return This builder for method chaining
*/
public AsyncExtendClientBaseBuilder addHeader(String name, String value) {
this.customHeaders.put(name, value);
return this;
}

protected ClientOptions buildClientOptions() {
ClientOptions.Builder builder = ClientOptions.builder();
setEnvironment(builder);
setAuthentication(builder);
setCustomHeaders(builder);
setHttpClient(builder);
setTimeouts(builder);
setRetries(builder);
for (Map.Entry<String, String> header : this.customHeaders.entrySet()) {
builder.addHeader(header.getKey(), header.getValue());
}
setAdditional(builder);
return builder.build();
}

/**
* Sets the environment configuration for the client.
* Override this method to modify URLs or add environment-specific logic.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setEnvironment(ClientOptions.Builder builder) {
builder.environment(this.environment);
}

/**
* Override this method to customize authentication.
* This method is called during client options construction to set up authentication headers.
*
* @param builder The ClientOptions.Builder to configure
*
* Example:
* <pre>{@code
* &#64;Override
* protected void setAuthentication(ClientOptions.Builder builder) {
* super.setAuthentication(builder); // Keep existing auth
* builder.addHeader("X-API-Key", this.apiKey);
* }
* }</pre>
*/
protected void setAuthentication(ClientOptions.Builder builder) {
if (this.token != null) {
builder.addHeader("Authorization", "Bearer " + this.token);
}
}

/**
* Override this method to add or modify custom headers.
* This method is called during client options construction to set up custom headers defined in the API.
*
* @param builder The ClientOptions.Builder to configure
*
* Example:
* <pre>{@code
* &#64;Override
* protected void setCustomHeaders(ClientOptions.Builder builder) {
* super.setCustomHeaders(builder); // Keep existing headers
* builder.addHeader("X-Trace-ID", generateTraceId());
* }
* }</pre>
*/
protected void setCustomHeaders(ClientOptions.Builder builder) {
builder.addHeader("x-extend-api-version", this.extendApiVersion);
}

/**
* Sets the request timeout configuration.
* Override this method to customize timeout behavior.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setTimeouts(ClientOptions.Builder builder) {
if (this.timeout.isPresent()) {
builder.timeout(this.timeout.get());
}
}

/**
* Sets the retry configuration for failed requests.
* Override this method to implement custom retry strategies.
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setRetries(ClientOptions.Builder builder) {
if (this.maxRetries.isPresent()) {
builder.maxRetries(this.maxRetries.get());
}
}

/**
* Sets the OkHttp client configuration.
* Override this method to customize HTTP client behavior (interceptors, connection pools, etc).
*
* @param builder The ClientOptions.Builder to configure
*/
protected void setHttpClient(ClientOptions.Builder builder) {
if (this.httpClient != null) {
builder.httpClient(this.httpClient);
}
}

/**
* Override this method to add any additional configuration to the client.
* This method is called at the end of the configuration chain, allowing you to add
* custom headers, modify settings, or perform any other client customization.
*
* @param builder The ClientOptions.Builder to configure
*
* Example:
* <pre>{@code
* &#64;Override
* protected void setAdditional(ClientOptions.Builder builder) {
* builder.addHeader("X-Request-ID", () -&gt; UUID.randomUUID().toString());
* builder.addHeader("X-Client-Version", "1.0.0");
* }
* }</pre>
*/
protected void setAdditional(ClientOptions.Builder builder) {}

/**
* Override this method to add custom validation logic before the client is built.
* This method is called at the beginning of the build() method to ensure the configuration is valid.
* Throw an exception to prevent client creation if validation fails.
*
* Example:
* <pre>{@code
* &#64;Override
* protected void validateConfiguration() {
* super.validateConfiguration(); // Run parent validations
* if (tenantId == null || tenantId.isEmpty()) {
* throw new IllegalStateException("tenantId is required");
* }
* }
* }</pre>
*/
protected void validateConfiguration() {}

public AsyncExtendClientBase build() {
if (token == null) {
throw new RuntimeException("Please provide token or set the EXTEND_API_KEY environment variable.");
}
validateConfiguration();
return new AsyncExtendClientBase(buildClientOptions());
}
}
Loading
Loading