public class PineconeConfig
extends java.lang.Object
PineconeConfig class is responsible for managing the configuration settings
required to interact with the Pinecone API. It provides methods to set and retrieve
the necessary API key, host, source tag, proxyConfig, and custom managed channel.
import io.grpc.ManagedChannel;
import io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder;
import io.pinecone.configs.PineconeConfig;
import io.pinecone.exceptions.PineconeException;
import javax.net.ssl.SSLException;
import java.util.concurrent.TimeUnit;
...
PineconeConfig config = new PineconeConfig("apikey");
String endpoint = "some-endpoint";
NettyChannelBuilder builder = NettyChannelBuilder.forTarget(endpoint);
// Custom channel with timeouts
try {
builder = builder.overrideAuthority(endpoint)
.negotiationType(NegotiationType.TLS)
.keepAliveTimeout(5, TimeUnit.SECONDS)
.sslContext(GrpcSslContexts.forClient().build());
} catch (SSLException e) {
throw new PineconeException("SSL error opening gRPC channel", e);
}
// Build the managed channel with the configured options
ManagedChannel channel = builder.build();
config.setCustomManagedChannel(channel);
| Modifier and Type | Class and Description |
|---|---|
static interface |
PineconeConfig.CustomChannelBuilder |
| Constructor and Description |
|---|
PineconeConfig(java.lang.String apiKey)
Constructs a
PineconeConfig instance with the specified API key. |
PineconeConfig(java.lang.String apiKey,
java.lang.String sourceTag)
Constructs a
PineconeConfig instance with the specified API key and source tag. |
PineconeConfig(java.lang.String apiKey,
java.lang.String sourceTag,
ProxyConfig proxyConfig,
okhttp3.OkHttpClient customOkHttpClient)
Constructs a
PineconeConfig instance with the specified API key, source tag, a HTTP proxy configuration,
and a custom OkHttpClient. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getApiKey()
Returns the API key.
|
io.grpc.ManagedChannel |
getCustomManagedChannel()
Returns the custom gRPC managed channel.
|
okhttp3.OkHttpClient |
getCustomOkHttpClient()
Gets a custom OkHttpClient for making HTTP requests.
|
java.lang.String |
getHost()
Returns the host.
|
ProxyConfig |
getProxyConfig()
Returns the proxy configuration for control and data plane requests.
|
java.lang.String |
getSourceTag()
Returns the source tag.
|
java.lang.String |
getUserAgent()
Builds the user agent string for the Pinecone client.
|
boolean |
isTLSEnabled()
Returns true if TLS is enabled or false otherwise.
|
void |
setApiKey(java.lang.String apiKey)
Sets the API key.
|
void |
setCustomManagedChannel(io.grpc.ManagedChannel customManagedChannel)
Sets the custom gRPC managed channel if the user is not interested in using default gRPC channel initialized
and set in the Pinecone Builder class.
|
void |
setCustomOkHttpClient(okhttp3.OkHttpClient customOkHttpClient)
Sets a custom OkHttpClient for making HTTP requests.
|
void |
setHost(java.lang.String host)
Sets the host.
|
void |
setProxyConfig(ProxyConfig proxyConfig)
Sets the proxy configuration for control and data plane requests.
|
void |
setSourceTag(java.lang.String sourceTag)
Sets the source tag.
|
void |
setTLSEnabled(boolean enableTLS)
Sets whether TLS is enabled.
|
void |
validate()
Validates the configuration settings of the Pinecone client.
|
public PineconeConfig(java.lang.String apiKey)
PineconeConfig instance with the specified API key.apiKey - The API key required to authenticate with the Pinecone API.public PineconeConfig(java.lang.String apiKey,
java.lang.String sourceTag)
PineconeConfig instance with the specified API key and source tag.apiKey - The API key required to authenticate with the Pinecone API.sourceTag - An optional source tag to be included in the user agent.public PineconeConfig(java.lang.String apiKey,
java.lang.String sourceTag,
ProxyConfig proxyConfig,
okhttp3.OkHttpClient customOkHttpClient)
PineconeConfig instance with the specified API key, source tag, a HTTP proxy configuration,
and a custom OkHttpClient.apiKey - The API key required to authenticate with the Pinecone API.sourceTag - An optional source tag to be included in the user agent.proxyConfig - The proxy configuration for control and data plane requests. Can be null if not set.customOkHttpClient - The custom OkHttpClient for making HTTP requests. Can be null if not set.public java.lang.String getApiKey()
public void setApiKey(java.lang.String apiKey)
apiKey - The new API key.public java.lang.String getHost()
public void setHost(java.lang.String host)
host - The new host.public java.lang.String getSourceTag()
public void setSourceTag(java.lang.String sourceTag)
sourceTag - The new source tag.public ProxyConfig getProxyConfig()
public void setProxyConfig(ProxyConfig proxyConfig)
proxyConfig - The new proxy configuration for control and data plane requests.public io.grpc.ManagedChannel getCustomManagedChannel()
public okhttp3.OkHttpClient getCustomOkHttpClient()
public void setCustomOkHttpClient(okhttp3.OkHttpClient customOkHttpClient)
customOkHttpClient - The custom OkHttpClient.public void setCustomManagedChannel(io.grpc.ManagedChannel customManagedChannel)
customManagedChannel - The new custom gRPC managed channel.public void validate()
PineconeConfigurationException - If the API key is null or empty, or if any of the proxy configurations are invalid.public java.lang.String getUserAgent()
public boolean isTLSEnabled()
public void setTLSEnabled(boolean enableTLS)
enableTLS - true to enable TLS, false to disable it.