Skip to content

Conversation

@rohanshah18
Copy link
Contributor

@rohanshah18 rohanshah18 commented May 5, 2025

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.

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)
  • 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.

@rohanshah18 rohanshah18 changed the title generate code based on the 2025-04 protos Add support for list, describe, and delete namespace May 5, 2025
@rohanshah18 rohanshah18 marked this pull request as ready for review May 8, 2025 18:01
Copy link
Contributor

@austin-denoble austin-denoble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

@rohanshah18 rohanshah18 merged commit 3a2b71b into rshah/release-candidate/2025-04 May 9, 2025
5 of 7 checks passed
@rohanshah18 rohanshah18 deleted the rshah/namespaces branch May 9, 2025 15:58
@rohanshah18 rohanshah18 restored the rshah/namespaces branch May 14, 2025 17:08
@rohanshah18 rohanshah18 deleted the rshah/namespaces branch May 23, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants