Add the Multi-Tenant Catalogs Endpoint Extension, for nested catalog support#366
Add the Multi-Tenant Catalogs Endpoint Extension, for nested catalog support#366jonhealy1 wants to merge 53 commits into
Conversation
|
It's going to be best to fix the extension so it supports python 3.11 |
…jonhealy1/stac-fastapi-pgstac into stac-fastapi-catalogs-extension
|
This is really close to being reviewable, just need some time to do some qa, documentation. |
|
@bkanuka Thanks for the feedback. I have implemented the two suggestions you made. Removing parent_ids from collection responses and fixing/ improving the self link generation. |
|
@vincentsarago Thanks for reviewing. I have implemented most of your suggestions - except for the name change. I have also updated the catalogs extension to v0.2.0 which basically just means a separate catalogs transactions class. My thinking is that the catalogs transaction routes will only be implemented when the core transaction extension is enabled. This may be too simplistic, let me know what you think. Additionally I added some documentation to the readme and settings.md. |
| catalog_id = cast(str, catalog.get("id")) | ||
| parent_ids_raw = catalog.get("parent_ids", []) | ||
| parent_ids: list[str] = ( | ||
| cast(list[str], parent_ids_raw) | ||
| if isinstance(parent_ids_raw, list) | ||
| else ([cast(str, parent_ids_raw)] if parent_ids_raw else []) | ||
| ) | ||
|
|
||
| # Get child catalogs for link generation | ||
| child_catalogs, _, _ = await self.database.get_sub_catalogs( | ||
| catalog_id=catalog_id, | ||
| limit=1000, | ||
| request=request, | ||
| ) | ||
| child_catalog_ids: list[str] = ( | ||
| [cast(str, c.get("id")) for c in child_catalogs] | ||
| if child_catalogs | ||
| else [] | ||
| ) | ||
|
|
||
| # Generate links | ||
| catalog["links"] = await CatalogLinks( | ||
| catalog_id=catalog_id, | ||
| request=request, | ||
| parent_ids=parent_ids, | ||
| child_catalog_ids=child_catalog_ids, | ||
| ).get_links(extra_links=catalog.get("links")) | ||
|
|
||
| # Remove internal metadata before returning | ||
| catalog.pop("parent_ids", None) |
There was a problem hiding this comment.
This link generation code is repeated a couple times - roughly line 172 and 260. I think it would make sense to pop it out to a (static) _generate_catalog_links method.
There was a problem hiding this comment.
Maybe the logic could go into the existing _build_response_links ? Sorry I don't have the brain space to come up with the solution right now!
| """ | ||
| await self.database.delete_catalog(catalog_id, refresh=True, request=request) | ||
|
|
||
| def _rewrite_collection_links( |
There was a problem hiding this comment.
This and a couple more _ methods could be static.
Related Issue(s):
Description:
Extension spec: https://github.com/StacLabs/multi-tenant-catalogs
STAC-FastAPI catalogs extension: https://github.com/StacLabs/stac-fastapi-catalogs-extension
PR Checklist:
pre-commithooks pass locallymake test)make docs)