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, 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. |
| 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.
|
java.lang.String |
getSourceTag()
Returns the source tag.
|
java.lang.String |
getUserAgent()
Builds the user agent string for the Pinecone client.
|
java.lang.String |
getUserAgentGrpc()
Builds the user agent string for the Pinecone client's gRPC requests.
|
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 |
setSourceTag(java.lang.String sourceTag)
Sets the source tag.
|
void |
validate()
Validates the configuration, ensuring that the API key is not null or empty.
|
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 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 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.public java.lang.String getUserAgent()
public java.lang.String getUserAgentGrpc()