Skip to content

Commit 31af542

Browse files
authored
Implement Admin API (#512)
## 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 ```python 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 ```python 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 - [x] New feature (non-breaking change which adds functionality) - [x] Infrastructure change (CI configs, etc) - [x] Non-code change (docs, etc) ## Test Plan Tests added. Also incorporated into CI.
1 parent 193c99e commit 31af542

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+7646
-899
lines changed

.github/actions/build-docs/action.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,7 @@ runs:
1616
include_asyncio: 'true'
1717
python_version: ${{ inputs.python-version }}
1818

19-
- name: Pretend this project requires Python 3.11
20-
shell: bash
21-
run: |
22-
# Poetry won't let me install sphinx as a dev dependency in this project
23-
# because of the wide range of versions our library supports. So during this
24-
# action, we'll pretend this project requires Python 3.11 or greater.
25-
sed -i 's/python = "^3.9"/python = "^3.11"/' pyproject.toml
26-
poetry lock
27-
poetry install -E grpc -E asyncio
28-
29-
- name: Install sphinx
30-
shell: bash
31-
run: |
32-
poetry add sphinx myst-parser --group dev
33-
3419
- name: Build html documentation
3520
shell: bash
3621
run: |
3722
poetry run sphinx-build -b html docs docsbuild
38-
39-
- name: Discard changes to pyproject.toml and poetry.lock
40-
shell: bash
41-
run: |
42-
git checkout pyproject.toml
43-
git checkout poetry.lock

0 commit comments

Comments
 (0)