Skip to content

Commit e6ebe29

Browse files
authored
Inherit from Base Database Logic (#355)
**Related Issue(s):** - #342 - #343 **Description:** **PR Checklist:** - [x] Code is formatted and linted (run `pre-commit run --all-files`) - [x] Tests pass (run `make test`) - [x] Documentation has been updated to reflect changes, if applicable - [x] Changes are added to the changelog
1 parent fe37609 commit e6ebe29

File tree

7 files changed

+27
-19
lines changed

7 files changed

+27
-19
lines changed

.github/workflows/deploy_mkdocs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
- name: Checkout main
2121
uses: actions/checkout@v4
2222

23-
- name: Set up Python 3.8
23+
- name: Set up Python 3.9
2424
uses: actions/setup-python@v5
2525
with:
26-
python-version: 3.8
26+
python-version: 3.9
2727

2828
- name: Install dependencies
2929
run: |

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Added
11+
12+
### Changed
13+
14+
### Fixed
15+
1016
## [v4.0.0a0]
1117

1218
### Added
@@ -22,6 +28,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2228

2329
### Fixed
2430
- Improved performance of `mk_actions` and `filter-links` methods [#351](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/351)
31+
- Fixed inheritance relating to BaseDatabaseSettings and ApiBaseSettings [#355](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/355)
32+
- Fixed delete_item and delete_collection methods return types [#355](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/355)
33+
- Fixed inheritance relating to DatabaseLogic and BaseDatabaseLogic, and ApiBaseSettings [#355](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/355)
2534

2635
## [v3.2.5] - 2025-04-07
2736

stac_fastapi/core/stac_fastapi/core/core.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -745,17 +745,15 @@ async def update_item(
745745
return ItemSerializer.db_to_stac(item, base_url)
746746

747747
@overrides
748-
async def delete_item(
749-
self, item_id: str, collection_id: str, **kwargs
750-
) -> Optional[stac_types.Item]:
748+
async def delete_item(self, item_id: str, collection_id: str, **kwargs) -> None:
751749
"""Delete an item from a collection.
752750
753751
Args:
754752
item_id (str): The identifier of the item to delete.
755753
collection_id (str): The identifier of the collection that contains the item.
756754
757755
Returns:
758-
Optional[stac_types.Item]: The deleted item, or `None` if the item was successfully deleted.
756+
None: Returns 204 No Content on successful deletion
759757
"""
760758
await self.database.delete_item(item_id=item_id, collection_id=collection_id)
761759
return None
@@ -825,23 +823,20 @@ async def update_collection(
825823
)
826824

827825
@overrides
828-
async def delete_collection(
829-
self, collection_id: str, **kwargs
830-
) -> Optional[stac_types.Collection]:
826+
async def delete_collection(self, collection_id: str, **kwargs) -> None:
831827
"""
832828
Delete a collection.
833829
834830
This method deletes an existing collection in the database.
835831
836832
Args:
837-
collection_id (str): The identifier of the collection that contains the item.
838-
kwargs: Additional keyword arguments.
833+
collection_id (str): The identifier of the collection to delete
839834
840835
Returns:
841-
None.
836+
None: Returns 204 No Content on successful deletion
842837
843838
Raises:
844-
NotFoundError: If the collection doesn't exist.
839+
NotFoundError: If the collection doesn't exist
845840
"""
846841
await self.database.delete_collection(collection_id=collection_id)
847842
return None

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import certifi
88

99
from elasticsearch import AsyncElasticsearch, Elasticsearch # type: ignore
10+
from stac_fastapi.core.base_settings import ApiBaseSettings
1011
from stac_fastapi.types.config import ApiSettings
1112

1213

@@ -69,7 +70,7 @@ def _es_config() -> Dict[str, Any]:
6970
_forbidden_fields: Set[str] = {"type"}
7071

7172

72-
class ElasticsearchSettings(ApiSettings):
73+
class ElasticsearchSettings(ApiSettings, ApiBaseSettings):
7374
"""API settings."""
7475

7576
# Fields which are defined by STAC but not included in the database model
@@ -82,7 +83,7 @@ def create_client(self):
8283
return Elasticsearch(**_es_config())
8384

8485

85-
class AsyncElasticsearchSettings(ApiSettings):
86+
class AsyncElasticsearchSettings(ApiSettings, ApiBaseSettings):
8687
"""API settings."""
8788

8889
# Fields which are defined by STAC but not included in the database model

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from starlette.requests import Request
1313

1414
from elasticsearch import exceptions, helpers # type: ignore
15+
from stac_fastapi.core.base_database_logic import BaseDatabaseLogic
1516
from stac_fastapi.core.database_logic import (
1617
COLLECTIONS_INDEX,
1718
DEFAULT_SORT,
@@ -124,7 +125,7 @@ async def delete_item_index(collection_id: str):
124125

125126

126127
@attr.s
127-
class DatabaseLogic:
128+
class DatabaseLogic(BaseDatabaseLogic):
128129
"""Database logic."""
129130

130131
client = AsyncElasticsearchSettings().create_client

stac_fastapi/opensearch/stac_fastapi/opensearch/config.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import certifi
77
from opensearchpy import AsyncOpenSearch, OpenSearch
88

9+
from stac_fastapi.core.base_settings import ApiBaseSettings
910
from stac_fastapi.types.config import ApiSettings
1011

1112

@@ -67,7 +68,7 @@ def _es_config() -> Dict[str, Any]:
6768
_forbidden_fields: Set[str] = {"type"}
6869

6970

70-
class OpensearchSettings(ApiSettings):
71+
class OpensearchSettings(ApiSettings, ApiBaseSettings):
7172
"""API settings."""
7273

7374
# Fields which are defined by STAC but not included in the database model
@@ -80,7 +81,7 @@ def create_client(self):
8081
return OpenSearch(**_es_config())
8182

8283

83-
class AsyncOpensearchSettings(ApiSettings):
84+
class AsyncOpensearchSettings(ApiSettings, ApiBaseSettings):
8485
"""API settings."""
8586

8687
# Fields which are defined by STAC but not included in the database model

stac_fastapi/opensearch/stac_fastapi/opensearch/database_logic.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from starlette.requests import Request
1616

1717
from stac_fastapi.core import serializers
18+
from stac_fastapi.core.base_database_logic import BaseDatabaseLogic
1819
from stac_fastapi.core.database_logic import (
1920
COLLECTIONS_INDEX,
2021
DEFAULT_SORT,
@@ -145,7 +146,7 @@ async def delete_item_index(collection_id: str):
145146

146147

147148
@attr.s
148-
class DatabaseLogic:
149+
class DatabaseLogic(BaseDatabaseLogic):
149150
"""Database logic."""
150151

151152
client = AsyncSearchSettings().create_client

0 commit comments

Comments
 (0)