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)
Constructs a
PineconeConfig instance with the specified API key, source tag, control plane proxy
configuration, and data plane proxy configuration. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getApiKey()
Returns the API key.
|
io.grpc.ManagedChannel |
getCustomManagedChannel()
Returns the custom gRPC managed channel.
|
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.
|
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 |
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 |
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)
PineconeConfig instance with the specified API key, source tag, control plane proxy
configuration, and data plane proxy configuration.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.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 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()