-
Notifications
You must be signed in to change notification settings - Fork 13
Generate code for 2025-04, automate ndjson handling, add backups, restore, and namespaces. #183
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Problem Add support for backups and restore. ## Solution Added support for backups and restore. Following code exactly shows how to add a backup from an index and restore a serverless index from a backup. ```java import io.pinecone.clients.Pinecone; import org.openapitools.db_control.client.ApiException; import org.openapitools.db_control.client.model.*; public class restoreAndBackups { public static void main(String[] args) throws ApiException, InterruptedException { Pinecone pinecone = new Pinecone.Builder("PINECONE_API_KEY").build(); String indexName1 = "test-index-1"; String indexName2 = "test-index-2"; // create a backup from index BackupModel backupModel1 = pinecone.createBackup(indexName1, "backup-id-1", "description-for-backup-1"); System.out.println("backupModel1: " + backupModel1); BackupModel backupModel2 = pinecone.createBackup(indexName2, "backup-id-2", "description-for-backup-2"); System.out.println("backupModel2: " + backupModel2); // list all backups for an index BackupList backupList = pinecone.listIndexBackups(indexName1); System.out.println("backupList for index1: " + backupList); // list all backups for a project backupList = pinecone.listProjectBackups(); System.out.println("backupList for project: " + backupList); // describe backup backupModel1 = pinecone.describeBackup(backupModel1.getBackupId()); System.out.println("describe backup for index1: " + backupModel1); backupModel2 = pinecone.describeBackup(backupModel2.getBackupId()); System.out.println("describe backup index2: " + backupModel2); // delete backup pinecone.deleteBackup(backupModel1.getBackupId()); // wait for the backup to be ready Thread.sleep(10000); // create index from a backup CreateIndexFromBackupResponse backupResponse = pinecone.createIndexFromBackup(backupModel1.getBackupId(), "test-index-3"); System.out.println(backupResponse.getRestoreJobId()); // wait for index to be created Thread.sleep(5000); // describeRestoreJob RestoreJobModel restoreJobModel = pinecone.describeRestoreJob(backupResponse.getRestoreJobId()); System.out.println("restore model: " + restoreJobModel); // listRestoreJobs RestoreJobList restoreJobList = pinecone.listRestoreJobs(2); System.out.println("restore job list: " + restoreJobList); } } ``` ## Type of Change - [X] New feature (non-breaking change which adds functionality) ## Test Plan Manually tested backups and restore by running the sample code above.
## Problem Add support for list, describe, and delete namespaces. ## Solution Generated code using 2025-04 protos and added the following methods for namespaces for both `index` and `asyncIndex`: 1. `listNamespaces()` 2. `listNamespaces(String paginationToken)` 3. `listNamespaces(String paginationToken, int limit)` 4. `describeNamespace(String namespace) ` 5. `deleteNamespace(String namespace) ` Following example shows `listNamespaces()`, `describeNamespace()`, and `deleteNamespace()` methods for both `index` and `asyncIndex`. ```java import io.pinecone.clients.AsyncIndex; import io.pinecone.clients.Index; import io.pinecone.clients.Pinecone; import io.pinecone.proto.ListNamespacesResponse; import io.pinecone.proto.NamespaceDescription; import java.util.concurrent.ExecutionException; ... String indexName = "PINECONE_INDEX_NAME"; Pinecone pinecone = new Pinecone.Builder("PINECONE_API_KEY").build(); //// Sync index example Index index = pinecone.getIndexConnection(indexName); // list namespaces without pagination token and limit (if no limit is passed, it'll default to 100) ListNamespacesResponse listNamespacesResponse = index.listNamespaces(); // list namespaces with pagination token listNamespacesResponse = index.listNamespaces("some-pagination-token"); // list namespaces with pagination token and a custom limit of 5 listNamespacesResponse = index.listNamespaces("some-pagination-token", 5); // describe a namespace NamespaceDescription namespaceDescription = index.describeNamespace("namespace"); // delete a namespace index.deleteNamespace("namespace"); //// AsyncIndex example AsyncIndex asyncIndex = pinecone.getAsyncIndexConnection(indexName); // list namespaces without pagination token and limit (if no limit is passed, it'll default to 100) ListNamespacesResponse asyncListNamespacesResponse = index.listNamespaces(); // list namespaces with pagination token asyncListNamespacesResponse = asyncIndex.listNamespaces("some-pagination-token").get(); // list namespaces with pagination token and a custom limit of 5 asyncListNamespacesResponse = asyncIndex.listNamespaces("some-pagination-token", 5).get(); // describe a namespace NamespaceDescription asyncNamespaceDescription = asyncIndex.describeNamespace("some-namespace").get(); // delete a namespace asyncIndex.deleteNamespace("some-namespace"); ``` ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan Added integration tests.
austin-denoble
approved these changes
May 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Solution
Type of Change
Test Plan
Integration tests were added for new features.