public static class Pinecone.Builder
extends java.lang.Object
| Constructor and Description |
|---|
Builder(java.lang.String apiKey)
Constructs a new
Pinecone.Builder with the mandatory API key. |
| Modifier and Type | Method and Description |
|---|---|
Pinecone |
build()
Builds and returns a
Pinecone instance configured with the provided API key, optional source tag,
and OkHttpClient. |
Pinecone.Builder |
withHost(java.lang.String host)
Sets a custom host URL for the control and data plane operations.
|
Pinecone.Builder |
withOkHttpClient(okhttp3.OkHttpClient okHttpClient)
Sets a custom OkHttpClient for the Pinecone client to use for making HTTP requests.
|
Pinecone.Builder |
withProxy(java.lang.String proxyHost,
int proxyPort)
Sets a proxy for the Pinecone client to use for control and data plane requests.
|
Pinecone.Builder |
withSourceTag(java.lang.String sourceTag)
Sets the source tag to include with all requests made by the Pinecone client.
|
Pinecone.Builder |
withTlsEnabled(boolean enableTls)
Configures whether TLS (Transport Layer Security) should be enabled for data plane operations.
|
public Builder(java.lang.String apiKey)
Pinecone.Builder with the mandatory API key.
import io.pinecone.clients.Pinecone;
Pinecone client = new Pinecone.Builder("PINECONE_API_KEY").build();
apiKey - The API key required for authenticating requests to Pinecone services.public Pinecone.Builder withSourceTag(java.lang.String sourceTag)
Source tag is an optional string identifier used to help Pinecone attribute API activity to our partners. For more info, see https://docs.pinecone.io/integrations/build-integration/attribute-api-activity
Pinecone client = new Pinecone.Builder("PINECONE_API_KEY")
.withSourceTag("YOUR_SOURCE_TAG")
.build();
// The tag will be included in all requests made by the client, e.g.
client.listIndexes();
sourceTag - The source tag to identify the origin of the requests.Pinecone.Builder instance for chaining method calls.public Pinecone.Builder withOkHttpClient(okhttp3.OkHttpClient okHttpClient)
import okhttp3.OkHttpClient;
OkHttpClient myClient = new OkHttpClient();
Pinecone client = new Pinecone.Builder("PINECONE_API_KEY")
.withOkHttpClient(myClient)
.build();
// Network requests will now be made using your custom OkHttpClient
client.listIndexes();
okHttpClient - The custom OkHttpClient to be used. Must not be null.Pinecone.Builder instance for chaining method calls.public Pinecone.Builder withProxy(java.lang.String proxyHost, int proxyPort)
When a proxy is configured using this method, all control and data plane requests made by the Pinecone client will be routed through the specified proxy server.
It's important to note that both proxyHost and proxyPort parameters should be provided to establish the connection to the proxy server.
Example usage:
String proxyHost = System.getenv("PROXY_HOST");
int proxyPort = Integer.parseInt(System.getenv("PROXY_PORT"));
Pinecone pinecone = new Pinecone.Builder("PINECONE_API_KEY")
.withProxy(proxyHost, proxyPort)
.build();
// Network requests for control plane operations will now be made using the specified proxy.
pinecone.listIndexes();
// Network requests for data plane operations will now be made using the specified proxy.
Index index = pinecone.getIndexConnection("PINECONE_INDEX");
index.describeIndexStats();
proxyHost - The hostname or IP address of the proxy server. Must not be null.proxyPort - The port number of the proxy server. Must not be null.Pinecone.Builder instance for chaining method calls.public Pinecone.Builder withHost(java.lang.String host)
This method allows you to specify a custom base URL for Pinecone control and data plane requests.
Example usage:
Pinecone client = new Pinecone.Builder("PINECONE_API_KEY")
.withHost("http://localhost:5080")
.build();
// Requests will now be sent to the specified host.
client.listIndexes();
host - The custom host URL for the Pinecone service. Must be a valid URL.Pinecone.Builder instance for chaining method calls.public Pinecone.Builder withTlsEnabled(boolean enableTls)
By default, TLS is enabled for data plane requests to ensure secure communication for data plane operations. This method can be used to disable TLS if needed (e.g., for testing or when communicating with non-secure endpoints). Disabling TLS in a production environment is not recommended due to potential security risks.
Example usage:
Pinecone client = new Pinecone.Builder("PINECONE_API_KEY")
.withTlsEnabled(false)
.build();
// Get index for data plane operations
Index index = pinecone.getIndexConnection("PINECONE_INDEX_NAME");
// Requests will now be made without TLS encryption (not recommended for production use).
index.upsert("v1", Arrays.asList(1f, 2f, 3f));
enableTls - true to enable TLS (default), false to disable it.Pinecone.Builder instance for chaining method calls.public Pinecone build()
Pinecone instance configured with the provided API key, optional source tag,
and OkHttpClient.
This method also performs configuration validation, sets up the internal API client, and manages indexes API with debugging options based on the environment variables.
Pinecone instance configured based on the builder parameters.