Skip to content

Implement Admin API #512

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Implement Admin API #512

wants to merge 7 commits into from

Conversation

jhamon
Copy link
Collaborator

@jhamon jhamon commented Jun 13, 2025

Problem

Currently the Admin API is not supported in the python SDK.

Solution

Implement an Admin class with support for CRUD on projects and API keys.

Usage

Projects

from pinecone import Admin

# Use service account credentials
admin = Admin(client_id='foo', client_secret='bar')

# Example: Create a project
project = admin.project.create(
    name="example-project",
    max_pods=5
)
print(f"Project {project.id} was created")

# Example: Rename a project
project = admin.project.get(name='example-project')
admin.project.update(
    project_id=project.id, 
    name='my-awesome-project'
)

# Example: Enable CMEK on all projects
project_list = admin.projects.list()
for proj in project_list_response.data:
    admin.projects.update(
      project_id=proj.id, 
      force_encryption_with_cmek=True
  )

# Example: Set pod quota to 0 for all projects
project_list = admin.projects.list()
for proj in project_list_response.data:
    admin.projects.update(project_id=proj.id, max_pods=0)

# Delete the project
admin.project.delete(project_id=project.id)

API Keys

from pinecone import Admin

# Use service account credentials
admin = Admin(client_id='foo', client_secret='bar')

project = admin.project.get(name='my-project')

# Create an API key
api_key_response = admin.api_keys.create(
    project_id=project.id,
    name="ci-key",
   roles=["ProjectEditor"]
)
key = api_key_response.value # 'pcsk_....'

# Look up info on a key by id
key_info = admin.api_keys.get(
    api_key_id=api_key_response.key.id
)

# Delete a key
admin.api_keys.delete(
    api_key_id=api_key_response.key.id
)

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)

Test Plan

Tests added. Also incorporated into CI.

Comment on lines +104 to +112
sphinx = [
{ version = "^7.4.7", python = ">=3.9,<3.11" },
{ version = "^8.2.3", python = ">=3.11" }
]
myst-parser = [
{ version = "^3.0.1", python = ">=3.9,<3.10" },
{ version = "^4.0.1", python = ">=3.10" }
]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A bit unrelated to this admin change, I figured out how to get the sphinx dev dependencies working even with our project supporting back to 3.9 by specifying different deps for different python versions. This was helpful for iterating on docs and making sure things look good in the rendered output.

@jhamon jhamon marked this pull request as ready for review June 13, 2025 18:05
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.

1 participant