diff --git a/stac_fastapi/core/stac_fastapi/core/core.py b/stac_fastapi/core/stac_fastapi/core/core.py index 56afcbc8..dd9c9897 100644 --- a/stac_fastapi/core/stac_fastapi/core/core.py +++ b/stac_fastapi/core/stac_fastapi/core/core.py @@ -377,7 +377,7 @@ async def get_item( @staticmethod def _return_date( - interval: Optional[Union[DateTimeType, str]] + interval: Optional[Union[DateTimeType, str]], ) -> Dict[str, Optional[str]]: """ Convert a date interval. @@ -724,15 +724,14 @@ async def update_item( """ item = item.model_dump(mode="json") - base_url = str(kwargs["request"].base_url) now = datetime_type.now(timezone.utc).isoformat().replace("+00:00", "Z") item["properties"]["updated"] = now await self.database.check_collection_exists(collection_id) await self.delete_item(item_id=item_id, collection_id=collection_id) - await self.create_item(collection_id=collection_id, item=Item(**item), **kwargs) - - return ItemSerializer.db_to_stac(item, base_url) + return await self.create_item( + collection_id=collection_id, item=Item(**item), **kwargs + ) @overrides async def delete_item( diff --git a/stac_fastapi/core/stac_fastapi/core/serializers.py b/stac_fastapi/core/stac_fastapi/core/serializers.py index 9b0d36d4..22546703 100644 --- a/stac_fastapi/core/stac_fastapi/core/serializers.py +++ b/stac_fastapi/core/stac_fastapi/core/serializers.py @@ -1,4 +1,5 @@ """Serializers.""" + import abc from copy import deepcopy from typing import Any, List, Optional @@ -65,6 +66,10 @@ def stac_to_db(cls, stac_data: stac_types.Item, base_url: str) -> stac_types.Ite item_links = resolve_links(stac_data.get("links", []), base_url) stac_data["links"] = item_links + stac_data["assets"] = [ + {"es_key": k, **v} for k, v in stac_data.get("assets", {}).items() + ] + now = now_to_rfc3339_str() if "created" not in stac_data["properties"]: stac_data["properties"]["created"] = now @@ -102,7 +107,7 @@ def db_to_stac(cls, item: dict, base_url: str) -> stac_types.Item: bbox=item.get("bbox", []), properties=item.get("properties", {}), links=item_links, - assets=item.get("assets", {}), + assets={a.pop("es_key"): a for a in item.get("assets", [])}, ) @@ -127,6 +132,9 @@ def stac_to_db( collection["links"] = resolve_links( collection.get("links", []), str(request.base_url) ) + collection["assets"] = [ + {"es_key": k, **v} for k, v in collection.get("assets", {}).items() + ] return collection @classmethod @@ -173,5 +181,9 @@ def db_to_stac( collection_links += resolve_links(original_links, str(request.base_url)) collection["links"] = collection_links + collection["assets"] = { + a.pop("es_key"): a for a in collection.get("assets", []) + } + # Return the stac_types.Collection object return stac_types.Collection(**collection) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy