Skip to content

feat: richer Astra database creation (database_type and pcu_group_id)#413

Closed
erichare wants to merge 1 commit into
mainfrom
feat-database-creation-options
Closed

feat: richer Astra database creation (database_type and pcu_group_id)#413
erichare wants to merge 1 commit into
mainfrom
feat-database-creation-options

Conversation

@erichare
Copy link
Copy Markdown
Collaborator

@erichare erichare commented Jun 3, 2026

Summary

Closes #408.

Database creation through AstraDBAdmin.create_database / async_create_database previously 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.
    • Default preserves today's behavior (a vector-enabled database).
    • Passing None omits dbType entirely, letting the DevOps API apply its own default — this is what enables non-vector databases.
    • Any other string is forwarded as-is. The value is intentionally not coerced or validated, so newly-introduced database types can be requested without waiting for an astrapy release (same conservative philosophy as the DatabaseStatus enum).
  • 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_types groundwork in find_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

Call dbType pcuGroupUUID
create_database(...) (default) "vector" (omitted)
create_database(..., database_type=None) (omitted) (omitted)
create_database(..., database_type="tabular", pcu_group_id="…") "tabular" "…"

A note on the design (for reviewers)

The issue proposed a DatabaseCreationRequest object. I went with keyword arguments instead, because every admin method in astrapy already 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_regions is still region-type=vector) is left as a possible follow-up.

Test plan

  • New unit tests in tests/base/unit/test_admin_create_database.py assert 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 format passes (ruff check + ruff format + mypy strict, on both astrapy and tests).
  • Existing test_admin_conversions / test_imports unit tests still pass.
  • Admin integration suite (tests/admin) against a real Astra account — not run locally (requires credentials); worth a maintainer run since payload changes touch the live DevOps API.

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

Database Creations enhancements in Astra

1 participant