From 6ef94ed56041e4a52460c0add61cb8ddf042940d Mon Sep 17 00:00:00 2001 From: CodeMash Date: Wed, 7 Oct 2026 21:43:42 +0300 Subject: [PATCH] feat(database): get_database_schema_index_status (step 6.6) New sync + async hub.database.get_database_schema_index_status(id) -> GET /{version}/database/schemas/{Id}/index-status; audit route test row (surface 23 -> 24); docs table row + usage line. Norbix now creates a published collection's obvious indexes itself (campaign 24 mongo-indexes: idx_ per reference, uniq_ per unique field, idx___id for the default sort, at most 8). The new call reads the last run: state building | ready | refused | partial, one entry per database. Co-Authored-By: Claude Fable 5.1 --- docs/hub/database.md | 2 ++ src/norbix_python/hub/database.py | 26 ++++++++++++++++++++++++++ tests/hub/test_database.py | 7 ++++--- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/docs/hub/database.md b/docs/hub/database.md index 5a3b6f7..69cb4dd 100644 --- a/docs/hub/database.md +++ b/docs/hub/database.md @@ -58,6 +58,7 @@ Access with `norbix.hub.database`. | `get_database_merged_term_tree` | `GET` | `/{version}/database/taxonomies/{TaxonomyName}/merged-tree` | `project` | | `get_database_taxonomy_term_tree` | `GET` | `/{version}/database/taxonomies/{TaxonomyName}/terms/tree` | `project` | | `apply_database_schema_bundle` | `POST` | `/{version}/database/schemas/apply-bundle` | `project` | +| `get_database_schema_index_status` | `GET` | `/{version}/database/schemas/{Id}/index-status` | `project` | | `get_database_schema_list_settings` | `GET` | `/{version}/database/schemas/{Id}/list-settings` | `project` | | `update_database_schema_list_settings` | `PUT` | `/{version}/database/schemas/{Id}/list-settings` | `project` | | `update_database_schema_embed` | `PUT` | `/{version}/database/schemas/{Id}/embed` | `project` | @@ -277,6 +278,7 @@ The request fields are listed under `RequestImportUploadUrlRequest`, terms of `services` are the roots, and the terms of its child taxonomies nest under them. - `get_database_schema_list_settings(id)` / `update_database_schema_list_settings(id, settings={...})` +- `get_database_schema_index_status(id)` — the last schema-index run (Norbix creates `idx_` per reference, `uniq_` per unique field and `idx___id` for the default sort, at most 8): `status.state` is `building`, `ready`, `refused` or `partial`, with one entry per database under `status.integrations` — how the record list shows a schema (the update replaces the whole settings object). Each environment keeps its own list layout: the client's `env` (the `norbix-env` header) picks which one you read and write. diff --git a/src/norbix_python/hub/database.py b/src/norbix_python/hub/database.py index 152f57e..b9c0a33 100644 --- a/src/norbix_python/hub/database.py +++ b/src/norbix_python/hub/database.py @@ -711,6 +711,19 @@ def apply_database_schema_bundle(self, *, timeout: float | None = None, bearer_t bearer_token=bearer_token, ) + def get_database_schema_index_status(self, id: str, *, timeout: float | None = None, bearer_token: str | None = None, **request: Any) -> Any: + """GET /{version}/database/schemas/{Id}/index-status — the last schema-index run of the collection (state building | ready | refused | partial, per database).""" + return self._transport.send( + target="hub", + path="/{version}/database/schemas/{Id}/index-status", + method="GET", + path_params={"Id": id}, + request=request, + scope="project", + timeout=timeout, + bearer_token=bearer_token, + ) + def get_database_schema_list_settings(self, id: str, *, timeout: float | None = None, bearer_token: str | None = None, **request: Any) -> Any: """GET /{version}/database/schemas/{Id}/list-settings""" return self._transport.send( @@ -1665,6 +1678,19 @@ async def apply_database_schema_bundle(self, *, timeout: float | None = None, be bearer_token=bearer_token, ) + async def get_database_schema_index_status(self, id: str, *, timeout: float | None = None, bearer_token: str | None = None, **request: Any) -> Any: + """GET /{version}/database/schemas/{Id}/index-status — the last schema-index run of the collection (state building | ready | refused | partial, per database).""" + return await self._transport.send( + target="hub", + path="/{version}/database/schemas/{Id}/index-status", + method="GET", + path_params={"Id": id}, + request=request, + scope="project", + timeout=timeout, + bearer_token=bearer_token, + ) + async def get_database_schema_list_settings(self, id: str, *, timeout: float | None = None, bearer_token: str | None = None, **request: Any) -> Any: """GET /{version}/database/schemas/{Id}/list-settings""" return await self._transport.send( diff --git a/tests/hub/test_database.py b/tests/hub/test_database.py index 79cbdc8..833fb59 100644 --- a/tests/hub/test_database.py +++ b/tests/hub/test_database.py @@ -405,6 +405,7 @@ def test_hub_database_reveal_managed_flex_connection_string_request_shape() -> N ("get_database_taxonomy_term_tree", "GET", f"{DB}/taxonomies/{TAX}/terms/tree", lambda m: m.get_database_taxonomy_term_tree(TAX)), # schemas ("apply_database_schema_bundle", "POST", f"{DB}/schemas/apply-bundle", lambda m: m.apply_database_schema_bundle()), + ("get_database_schema_index_status", "GET", f"{DB}/schemas/{SCHEMA}/index-status", lambda m: m.get_database_schema_index_status(SCHEMA)), ("get_database_schema_list_settings", "GET", f"{DB}/schemas/{SCHEMA}/list-settings", lambda m: m.get_database_schema_list_settings(SCHEMA)), ("update_database_schema_list_settings", "PUT", f"{DB}/schemas/{SCHEMA}/list-settings", lambda m: m.update_database_schema_list_settings(SCHEMA)), ("update_database_schema_embed", "PUT", f"{DB}/schemas/{SCHEMA}/embed", lambda m: m.update_database_schema_embed(SCHEMA)), @@ -447,9 +448,9 @@ def test_hub_database_audit_method_hits_the_gateway_route( def test_hub_database_audit_surface_size() -> None: - """23 Hub database routes were missing before the audit; all of them are covered here.""" - assert len(HUB_DB_AUDIT_CASES) == 23 - assert len({case[0] for case in HUB_DB_AUDIT_CASES}) == 23 + """23 Hub database routes were missing before the audit, plus the schema index status (campaign 24 mongo-indexes); all of them are covered here.""" + assert len(HUB_DB_AUDIT_CASES) == 24 + assert len({case[0] for case in HUB_DB_AUDIT_CASES}) == 24 def test_hub_database_find_records_sends_query_values() -> None: