feat: richer Astra database creation (database_type and pcu_group_id)#413
Closed
erichare wants to merge 1 commit into
Closed
feat: richer Astra database creation (database_type and pcu_group_id)#413erichare wants to merge 1 commit into
erichare wants to merge 1 commit into
Conversation
Address #408 by lifting the two hard-coded constraints in `AstraDBAdmin.create_database` / `async_create_database`: - `database_type` (default "vector") selects the database flavor instead of always sending `dbType: vector`. Passing None omits the field so the DevOps API applies its own default, enabling non-vector databases. The value is not coerced/validated, so future database types need no astrapy upgrade. - `pcu_group_id` assigns the new database to a PCU group (`pcuGroupUUID`) at creation time. Both parameters are optional and keyword-only; existing callers keep getting a vector database with no PCU group, so the change is fully backward compatible. Adds unit tests asserting the DevOps payload for the default, non-vector and fully-specified cases (sync and async) against a mock DevOps API.
4 tasks
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
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.
Summary
Closes #408.
Database creation through
AstraDBAdmin.create_database/async_create_databasepreviously hard-coded two things in the DevOps payload:dbType: "vector"and the absence of any PCU-group assignment. This PR exposes both as optional, keyword-only parameters so the client keeps pace with recent Astra platform capabilities:database_type(default"vector") — selects the database flavor.NoneomitsdbTypeentirely, letting the DevOps API apply its own default — this is what enables non-vector databases.DatabaseStatusenum).pcu_group_id— assigns the new database to a PCU group (pcuGroupUUID) at creation time. Omitted when not supplied.This dovetails with the existing
pcu_typesgroundwork infind_available_regions("until full PCU support").Backward compatibility
Fully backward compatible. Both parameters are optional and keyword-only; existing callers (
create_database(name, cloud_provider=..., region=...)) continue to get a vector database with no PCU group and an unchanged payload.Payload behavior
dbTypepcuGroupUUIDcreate_database(...)(default)"vector"create_database(..., database_type=None)create_database(..., database_type="tabular", pcu_group_id="…")"tabular""…"A note on the design (for reviewers)
The issue proposed a
DatabaseCreationRequestobject. I went with keyword arguments instead, because every admin method inastrapyalready follows that style and it keeps the change fully backward compatible and minimal. The payload is built so that additional future knobs (further feature flags, etc.) can be added the same way. Happy to refactor toward an explicit request/definition object if you'd prefer that direction — just let me know.Scope is deliberately limited to database creation (the issue's core). Region discovery (
find_available_regionsis stillregion-type=vector) is left as a possible follow-up.Test plan
tests/base/unit/test_admin_create_database.pyassert the exact DevOps payload for the default / non-vector / fully-specified cases, sync and async, against a mock DevOps API (pytest_httpserver) — no live Astra needed.make formatpasses (ruff check + ruff format + mypy strict, on bothastrapyandtests).test_admin_conversions/test_importsunit tests still pass.tests/admin) against a real Astra account — not run locally (requires credentials); worth a maintainer run since payload changes touch the live DevOps API.