Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for passing base path for control plane operations #168

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Changes from 1 commit
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
24 changes: 23 additions & 1 deletion src/main/java/io/pinecone/clients/Pinecone.java
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,11 @@ public static class Builder {
private final String apiKey;

// Optional fields
private String host;
private String sourceTag;
private ProxyConfig proxyConfig;
private OkHttpClient customOkHttpClient;
private boolean enableTls = true;

/**
* Constructs a new {@link Builder} with the mandatory API key.
Expand Down Expand Up @@ -1023,6 +1025,16 @@ public Builder withProxy(String proxyHost, int proxyPort) {
return this;
}

public Builder withHost(String host) {
this.host = host;
return this;
}

public Builder withTlsEnabled(boolean enableTls) {
this.enableTls = enableTls;
return this;
}

rohanshah18 marked this conversation as resolved.
Show resolved Hide resolved
/**
* Builds and returns a {@link Pinecone} instance configured with the provided API key, optional source tag,
* and OkHttpClient.
Expand All @@ -1034,13 +1046,23 @@ public Builder withProxy(String proxyHost, int proxyPort) {
*/
public Pinecone build() {
PineconeConfig config = new PineconeConfig(apiKey, sourceTag, proxyConfig, customOkHttpClient);
config.setTLSEnabled(enableTls);
rohanshah18 marked this conversation as resolved.
Show resolved Hide resolved
config.validate();

if (proxyConfig != null && customOkHttpClient != null) {
throw new PineconeConfigurationException("Invalid configuration: Both Custom OkHttpClient and Proxy are set. Please configure only one of these options.");
}

ApiClient apiClient = (customOkHttpClient != null) ? new ApiClient(customOkHttpClient) : new ApiClient(buildOkHttpClient(proxyConfig));
ApiClient apiClient;
if (customOkHttpClient != null) {
apiClient = new ApiClient(customOkHttpClient);
} else {
apiClient = new ApiClient(buildOkHttpClient(proxyConfig));
if(host!=null && !host.isEmpty()) {
config.setHost(host);
apiClient.setBasePath(host);
rohanshah18 marked this conversation as resolved.
Show resolved Hide resolved
}
}
apiClient.setApiKey(config.getApiKey());
apiClient.setUserAgent(config.getUserAgent());
apiClient.addDefaultHeader("X-Pinecone-Api-Version", Configuration.VERSION);
Expand Down
Loading