Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 104 additions & 1 deletion stac_fastapi/elasticsearch/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,107 @@
__date__ = '11 Jun 2021'
__copyright__ = 'Copyright 2018 United Kingdom Research and Innovation'
__license__ = 'BSD - see LICENSE file in top-level package directory'
__contact__ = '[email protected]'
__contact__ = '[email protected]'


from stac_fastapi.types.core import BaseTransactionsClient


class TransactionsClient(BaseTransactionsClient):
"""Defines a pattern for implementing the STAC transaction extension."""

@abc.abstractmethod
def create_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
"""Create a new item.

Called with `POST /collections/{collectionId}/items`.

Args:
item: the item

Returns:
The item that was created.

"""
...

@abc.abstractmethod
def update_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
"""Perform a complete update on an existing item.

Called with `PUT /collections/{collectionId}/items`. It is expected that this item already exists. The update
should do a diff against the saved item and perform any necessary updates. Partial updates are not supported
by the transactions extension.

Args:
item: the item (must be complete)

Returns:
The updated item.
"""
...

@abc.abstractmethod
def delete_item(
self, item_id: str, collection_id: str, **kwargs
) -> stac_types.Item:
"""Delete an item from a collection.

Called with `DELETE /collections/{collectionId}/items/{itemId}`

Args:
item_id: id of the item.
collection_id: id of the collection.

Returns:
The deleted item.
"""
...

@abc.abstractmethod
def create_collection(
self, collection: stac_types.Collection, **kwargs
) -> stac_types.Collection:
"""Create a new collection.

Called with `POST /collections`.

Args:
collection: the collection

Returns:
The collection that was created.
"""
...

@abc.abstractmethod
def update_collection(
self, collection: stac_types.Collection, **kwargs
) -> stac_types.Collection:
"""Perform a complete update on an existing collection.

Called with `PUT /collections`. It is expected that this item already exists. The update should do a diff
against the saved collection and perform any necessary updates. Partial updates are not supported by the
transactions extension.

Args:
collection: the collection (must be complete)

Returns:
The updated collection.
"""
...

@abc.abstractmethod
def delete_collection(self, collection_id: str, **kwargs) -> stac_types.Collection:
"""Delete a collection.

Called with `DELETE /collections/{collectionId}`

Args:
collection_id: id of the collection.

Returns:
The deleted collection.
"""
...