Skip to content

Commit 39d3a89

Browse files
committed
update collection
1 parent ef77d1f commit 39d3a89

File tree

1 file changed

+36
-3
lines changed
  • stac_fastapi/elasticsearch/stac_fastapi/elasticsearch

1 file changed

+36
-3
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/core.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,34 @@ async def update_item(self, collection_id: str, item_id: str, item: stac_types.I
456456
async def delete_item(
457457
self, item_id: str, collection_id: str, **kwargs
458458
) -> stac_types.Item:
459-
"""Delete item."""
459+
"""Delete an item from a collection.
460+
461+
Args:
462+
item_id (str): The identifier of the item to delete.
463+
collection_id (str): The identifier of the collection that contains the item.
464+
465+
Returns:
466+
Optional[stac_types.Item]: The deleted item, or `None` if the item was successfully deleted.
467+
"""
460468
await self.database.delete_item(item_id=item_id, collection_id=collection_id)
461469
return None # type: ignore
462470

463471
@overrides
464472
async def create_collection(
465473
self, collection: stac_types.Collection, **kwargs
466474
) -> stac_types.Collection:
467-
"""Create collection."""
475+
"""Create a new collection in the database.
476+
477+
Args:
478+
collection (stac_types.Collection): The collection to be created.
479+
kwargs: Additional keyword arguments.
480+
481+
Returns:
482+
stac_types.Collection: The created collection object.
483+
484+
Raises:
485+
ConflictError: If the collection already exists.
486+
"""
468487
base_url = str(kwargs["request"].base_url)
469488
collection_links = CollectionLinks(
470489
collection_id=collection["id"], base_url=base_url
@@ -478,7 +497,21 @@ async def create_collection(
478497
async def update_collection(
479498
self, collection: stac_types.Collection, **kwargs
480499
) -> stac_types.Collection:
481-
"""Update collection."""
500+
"""
501+
Update a collection.
502+
503+
This method updates an existing collection in the database by first finding
504+
the collection by its id, then deleting the old version, and finally creating
505+
a new version of the updated collection. The updated collection is then returned.
506+
507+
Args:
508+
collection: A STAC collection that needs to be updated.
509+
kwargs: Additional keyword arguments.
510+
511+
Returns:
512+
A STAC collection that has been updated in the database.
513+
514+
"""
482515
base_url = str(kwargs["request"].base_url)
483516

484517
await self.database.find_collection(collection_id=collection["id"])

0 commit comments

Comments
 (0)